From a7fb8758ffccad6a6f80dadcc68b12306ac0f615 Mon Sep 17 00:00:00 2001 From: Matias Date: Fri, 23 May 2025 08:50:57 -0300 Subject: [PATCH 001/157] feat: implement Indexing Agreements --- .../extensions/DataServiceFees.sol | 74 +- .../extensions/DataServiceFeesStorage.sol | 4 +- .../interfaces/IDataServiceFees.sol | 64 -- .../data-service/libraries/StakeClaims.sol | 213 +++++ .../utilities/ProvisionManager.sol | 36 +- .../interfaces/IRecurringCollector.sol | 416 ++++++++++ .../collectors/GraphTallyCollector.sol | 5 +- .../collectors/RecurringCollector.sol | 540 +++++++++++++ packages/horizon/package.json | 3 +- .../extensions/DataServiceFees.t.sol | 12 +- .../PaymentsEscrowMock.t.sol | 25 + .../RecurringCollectorAuthorizableTest.t.sol | 20 + .../RecurringCollectorControllerMock.t.sol | 25 + .../RecurringCollectorHelper.t.sol | 148 ++++ .../payments/recurring-collector/accept.t.sol | 51 ++ .../payments/recurring-collector/cancel.t.sol | 53 ++ .../recurring-collector/collect.t.sol | 267 +++++++ .../payments/recurring-collector/shared.t.sol | 194 +++++ .../payments/recurring-collector/update.t.sol | 157 ++++ .../test/unit/utilities/Authorizable.t.sol | 33 +- .../GraphDirectoryImplementation.sol | 1 + .../horizon/test/unit/utils/Bounder.t.sol | 29 +- .../contracts/DisputeManager.sol | 84 ++ .../contracts/SubgraphService.sol | 219 +++++- .../contracts/interfaces/IDisputeManager.sol | 65 +- .../contracts/interfaces/ISubgraphService.sol | 40 +- .../contracts/libraries/AllocationHandler.sol | 597 ++++++++++++++ .../contracts/libraries/IndexingAgreement.sol | 730 ++++++++++++++++++ .../libraries/IndexingAgreementDecoder.sol | 101 +++ .../libraries/IndexingAgreementDecoderRaw.sol | 65 ++ .../contracts/utilities/AllocationManager.sol | 340 ++------ .../contracts/utilities/Directory.sol | 35 +- packages/subgraph-service/package.json | 3 +- .../test/unit/SubgraphBaseTest.t.sol | 12 +- .../unit/disputeManager/DisputeManager.t.sol | 8 +- .../disputes/indexing/create.t.sol | 9 +- .../disputes/query/create.t.sol | 5 +- .../test/unit/libraries/IndexingAgreement.sol | 18 + .../unit/shared/SubgraphServiceShared.t.sol | 6 +- .../subgraphService/SubgraphService.t.sol | 66 +- .../subgraphService/allocation/resize.t.sol | 6 +- .../subgraphService/allocation/start.t.sol | 6 +- .../subgraphService/allocation/stop.t.sol | 1 - .../subgraphService/collect/collect.t.sol | 25 - .../collect/indexing/indexing.t.sol | 4 +- .../indexing-agreement/accept.t.sol | 251 ++++++ .../indexing-agreement/base.t.sol | 35 + .../indexing-agreement/cancel.t.sol | 215 ++++++ .../indexing-agreement/collect.t.sol | 251 ++++++ .../indexing-agreement/integration.t.sol | 142 ++++ .../indexing-agreement/shared.t.sol | 380 +++++++++ .../indexing-agreement/update.t.sol | 170 ++++ 52 files changed, 5718 insertions(+), 541 deletions(-) create mode 100644 packages/horizon/contracts/data-service/libraries/StakeClaims.sol create mode 100644 packages/horizon/contracts/interfaces/IRecurringCollector.sol create mode 100644 packages/horizon/contracts/payments/collectors/RecurringCollector.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/accept.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/collect.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/shared.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/update.t.sol create mode 100644 packages/subgraph-service/contracts/libraries/AllocationHandler.sol create mode 100644 packages/subgraph-service/contracts/libraries/IndexingAgreement.sol create mode 100644 packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol create mode 100644 packages/subgraph-service/contracts/libraries/IndexingAgreementDecoderRaw.sol create mode 100644 packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol delete mode 100644 packages/subgraph-service/test/unit/subgraphService/collect/collect.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol index a1c38a99a..7b978794b 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol @@ -5,6 +5,7 @@ import { IDataServiceFees } from "../interfaces/IDataServiceFees.sol"; import { ProvisionTracker } from "../libraries/ProvisionTracker.sol"; import { LinkedList } from "../../libraries/LinkedList.sol"; +import { StakeClaims } from "../libraries/StakeClaims.sol"; import { DataService } from "../DataService.sol"; import { DataServiceFeesV1Storage } from "./DataServiceFeesStorage.sol"; @@ -41,23 +42,17 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat * @param _unlockTimestamp The timestamp when the tokens can be released */ function _lockStake(address _serviceProvider, uint256 _tokens, uint256 _unlockTimestamp) internal { - require(_tokens != 0, DataServiceFeesZeroTokens()); - feesProvisionTracker.lock(_graphStaking(), _serviceProvider, _tokens, _delegationRatio); - - LinkedList.List storage claimsList = claimsLists[_serviceProvider]; - - // Save item and add to list - bytes32 claimId = _buildStakeClaimId(_serviceProvider, claimsList.nonce); - claims[claimId] = StakeClaim({ - tokens: _tokens, - createdAt: block.timestamp, - releasableAt: _unlockTimestamp, - nextClaim: bytes32(0) - }); - if (claimsList.count != 0) claims[claimsList.tail].nextClaim = claimId; - claimsList.addTail(claimId); - - emit StakeClaimLocked(_serviceProvider, claimId, _tokens, _unlockTimestamp); + StakeClaims.lockStake( + feesProvisionTracker, + claims, + claimsLists, + _graphStaking(), + address(this), + _delegationRatio, + _serviceProvider, + _tokens, + _unlockTimestamp + ); } /** @@ -80,7 +75,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat _numClaimsToRelease ); - emit StakeClaimsReleased(_serviceProvider, claimsReleased, abi.decode(data, (uint256))); + emit StakeClaims.StakeClaimsReleased(_serviceProvider, claimsReleased, abi.decode(data, (uint256))); } /** @@ -92,23 +87,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat * @return The updated accumulator data */ function _processStakeClaim(bytes32 _claimId, bytes memory _acc) private returns (bool, bytes memory) { - StakeClaim memory claim = _getStakeClaim(_claimId); - - // early exit - if (claim.releasableAt > block.timestamp) { - return (true, LinkedList.NULL_BYTES); - } - - // decode - (uint256 tokensClaimed, address serviceProvider) = abi.decode(_acc, (uint256, address)); - - // process - feesProvisionTracker.release(serviceProvider, claim.tokens); - emit StakeClaimReleased(serviceProvider, _claimId, claim.tokens, claim.releasableAt); - - // encode - _acc = abi.encode(tokensClaimed + claim.tokens, serviceProvider); - return (false, _acc); + return StakeClaims.processStakeClaim(feesProvisionTracker, claims, _claimId, _acc); } /** @@ -117,18 +96,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat * @param _claimId The ID of the stake claim to delete */ function _deleteStakeClaim(bytes32 _claimId) private { - delete claims[_claimId]; - } - - /** - * @notice Gets the details of a stake claim - * @param _claimId The ID of the stake claim - * @return The stake claim details - */ - function _getStakeClaim(bytes32 _claimId) private view returns (StakeClaim memory) { - StakeClaim memory claim = claims[_claimId]; - require(claim.createdAt != 0, DataServiceFeesClaimNotFound(_claimId)); - return claim; + StakeClaims.deleteStakeClaim(claims, _claimId); } /** @@ -138,16 +106,6 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat * @return The next stake claim ID */ function _getNextStakeClaim(bytes32 _claimId) private view returns (bytes32) { - return claims[_claimId].nextClaim; - } - - /** - * @notice Builds a stake claim ID - * @param _serviceProvider The address of the service provider - * @param _nonce A nonce of the stake claim - * @return The stake claim ID - */ - function _buildStakeClaimId(address _serviceProvider, uint256 _nonce) private view returns (bytes32) { - return keccak256(abi.encodePacked(address(this), _serviceProvider, _nonce)); + return StakeClaims.getNextStakeClaim(claims, _claimId); } } diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol index 30d1aa4ee..795206151 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.27; -import { IDataServiceFees } from "../interfaces/IDataServiceFees.sol"; +import { StakeClaims } from "../libraries/StakeClaims.sol"; import { LinkedList } from "../../libraries/LinkedList.sol"; @@ -15,7 +15,7 @@ abstract contract DataServiceFeesV1Storage { mapping(address serviceProvider => uint256 tokens) public feesProvisionTracker; /// @notice List of all locked stake claims to be released to service providers - mapping(bytes32 claimId => IDataServiceFees.StakeClaim claim) public claims; + mapping(bytes32 claimId => StakeClaims.StakeClaim claim) public claims; /// @notice Service providers registered in the data service mapping(address serviceProvider => LinkedList.List list) public claimsLists; diff --git a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol index 9d235f4f7..58dfd95f5 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol @@ -22,70 +22,6 @@ import { IDataService } from "./IDataService.sol"; * bugs. We may have an active bug bounty program. */ interface IDataServiceFees is IDataService { - /** - * @notice A stake claim, representing provisioned stake that gets locked - * to be released to a service provider. - * @dev StakeClaims are stored in linked lists by service provider, ordered by - * creation timestamp. - * @param tokens The amount of tokens to be locked in the claim - * @param createdAt The timestamp when the claim was created - * @param releasableAt The timestamp when the tokens can be released - * @param nextClaim The next claim in the linked list - */ - struct StakeClaim { - uint256 tokens; - uint256 createdAt; - uint256 releasableAt; - bytes32 nextClaim; - } - - /** - * @notice Emitted when a stake claim is created and stake is locked. - * @param serviceProvider The address of the service provider - * @param claimId The id of the stake claim - * @param tokens The amount of tokens to lock in the claim - * @param unlockTimestamp The timestamp when the tokens can be released - */ - event StakeClaimLocked( - address indexed serviceProvider, - bytes32 indexed claimId, - uint256 tokens, - uint256 unlockTimestamp - ); - - /** - * @notice Emitted when a stake claim is released and stake is unlocked. - * @param serviceProvider The address of the service provider - * @param claimId The id of the stake claim - * @param tokens The amount of tokens released - * @param releasableAt The timestamp when the tokens were released - */ - event StakeClaimReleased( - address indexed serviceProvider, - bytes32 indexed claimId, - uint256 tokens, - uint256 releasableAt - ); - - /** - * @notice Emitted when a series of stake claims are released. - * @param serviceProvider The address of the service provider - * @param claimsCount The number of stake claims being released - * @param tokensReleased The total amount of tokens being released - */ - event StakeClaimsReleased(address indexed serviceProvider, uint256 claimsCount, uint256 tokensReleased); - - /** - * @notice Thrown when attempting to get a stake claim that does not exist. - * @param claimId The id of the stake claim - */ - error DataServiceFeesClaimNotFound(bytes32 claimId); - - /** - * @notice Emitted when trying to lock zero tokens in a stake claim - */ - error DataServiceFeesZeroTokens(); - /** * @notice Releases expired stake claims for the caller. * @dev This function is only meant to be called if the service provider has enough diff --git a/packages/horizon/contracts/data-service/libraries/StakeClaims.sol b/packages/horizon/contracts/data-service/libraries/StakeClaims.sol new file mode 100644 index 000000000..5269d7ec4 --- /dev/null +++ b/packages/horizon/contracts/data-service/libraries/StakeClaims.sol @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { ProvisionTracker } from "./ProvisionTracker.sol"; +import { IHorizonStaking } from "../../interfaces/IHorizonStaking.sol"; +import { LinkedList } from "../../libraries/LinkedList.sol"; + +library StakeClaims { + using ProvisionTracker for mapping(address => uint256); + using LinkedList for LinkedList.List; + + /** + * @notice A stake claim, representing provisioned stake that gets locked + * to be released to a service provider. + * @dev StakeClaims are stored in linked lists by service provider, ordered by + * creation timestamp. + * @param tokens The amount of tokens to be locked in the claim + * @param createdAt The timestamp when the claim was created + * @param releasableAt The timestamp when the tokens can be released + * @param nextClaim The next claim in the linked list + */ + struct StakeClaim { + uint256 tokens; + uint256 createdAt; + uint256 releasableAt; + bytes32 nextClaim; + } + + /** + * @notice Emitted when a stake claim is created and stake is locked. + * @param serviceProvider The address of the service provider + * @param claimId The id of the stake claim + * @param tokens The amount of tokens to lock in the claim + * @param unlockTimestamp The timestamp when the tokens can be released + */ + event StakeClaimLocked( + address indexed serviceProvider, + bytes32 indexed claimId, + uint256 tokens, + uint256 unlockTimestamp + ); + + /** + * @notice Emitted when a stake claim is released and stake is unlocked. + * @param serviceProvider The address of the service provider + * @param claimId The id of the stake claim + * @param tokens The amount of tokens released + * @param releasableAt The timestamp when the tokens were released + */ + event StakeClaimReleased( + address indexed serviceProvider, + bytes32 indexed claimId, + uint256 tokens, + uint256 releasableAt + ); + + /** + * @notice Emitted when a series of stake claims are released. + * @param serviceProvider The address of the service provider + * @param claimsCount The number of stake claims being released + * @param tokensReleased The total amount of tokens being released + */ + event StakeClaimsReleased(address indexed serviceProvider, uint256 claimsCount, uint256 tokensReleased); + + /** + * @notice Thrown when attempting to get a stake claim that does not exist. + * @param claimId The id of the stake claim + */ + error StakeClaimsClaimNotFound(bytes32 claimId); + + /** + * @notice Emitted when trying to lock zero tokens in a stake claim + */ + error StakeClaimsZeroTokens(); + + /** + * @notice Locks stake for a service provider to back a payment. + * Creates a stake claim, which is stored in a linked list by service provider. + * @dev Requirements: + * - The associated provision must have enough available tokens to lock the stake. + * + * Emits a {StakeClaimLocked} event. + * + * @param feesProvisionTracker The mapping that tracks the provision tokens for each service provider + * @param claims The mapping that stores stake claims by their ID + * @param claimsLists The mapping that stores linked lists of stake claims by service provider + * @param graphStaking The Horizon staking contract used to lock the tokens + * @param _dataService The address of the data service + * @param _delegationRatio The delegation ratio to use for the stake claim + * @param _serviceProvider The address of the service provider + * @param _tokens The amount of tokens to lock in the claim + * @param _unlockTimestamp The timestamp when the tokens can be released + */ + function lockStake( + mapping(address => uint256) storage feesProvisionTracker, + mapping(bytes32 => StakeClaim) storage claims, + mapping(address serviceProvider => LinkedList.List list) storage claimsLists, + IHorizonStaking graphStaking, + address _dataService, + uint32 _delegationRatio, + address _serviceProvider, + uint256 _tokens, + uint256 _unlockTimestamp + ) external { + require(_tokens != 0, StakeClaimsZeroTokens()); + feesProvisionTracker.lock(graphStaking, _serviceProvider, _tokens, _delegationRatio); + + LinkedList.List storage claimsList = claimsLists[_serviceProvider]; + + // Save item and add to list + bytes32 claimId = _buildStakeClaimId(_dataService, _serviceProvider, claimsList.nonce); + claims[claimId] = StakeClaim({ + tokens: _tokens, + createdAt: block.timestamp, + releasableAt: _unlockTimestamp, + nextClaim: bytes32(0) + }); + if (claimsList.count != 0) claims[claimsList.tail].nextClaim = claimId; + claimsList.addTail(claimId); + + emit StakeClaimLocked(_serviceProvider, claimId, _tokens, _unlockTimestamp); + } + + /** + * @notice Processes a stake claim, releasing the tokens if the claim has expired. + * @dev This function is used as a callback in the stake claims linked list traversal. + * @param feesProvisionTracker The mapping that tracks the provision tokens for each service provider. + * @param claims The mapping that stores stake claims by their ID. + * @param _claimId The ID of the stake claim to process. + * @param _acc The accumulator data, which contains the total tokens claimed and the service provider address. + * @return Whether the stake claim is still locked, indicating that the traversal should continue or stop. + * @return The updated accumulator data + */ + function processStakeClaim( + mapping(address serviceProvider => uint256 tokens) storage feesProvisionTracker, + mapping(bytes32 claimId => StakeClaim claim) storage claims, + bytes32 _claimId, + bytes memory _acc + ) external returns (bool, bytes memory) { + StakeClaim memory claim = claims[_claimId]; + require(claim.createdAt != 0, StakeClaimsClaimNotFound(_claimId)); + + // early exit + if (claim.releasableAt > block.timestamp) { + return (true, LinkedList.NULL_BYTES); + } + + // decode + (uint256 tokensClaimed, address serviceProvider) = abi.decode(_acc, (uint256, address)); + + // process + feesProvisionTracker.release(serviceProvider, claim.tokens); + emit StakeClaimReleased(serviceProvider, _claimId, claim.tokens, claim.releasableAt); + + // encode + _acc = abi.encode(tokensClaimed + claim.tokens, serviceProvider); + return (false, _acc); + } + + /** + * @notice Deletes a stake claim. + * @dev This function is used as a callback in the stake claims linked list traversal. + * @param claims The mapping that stores stake claims by their ID + * @param claimId The ID of the stake claim to delete + */ + function deleteStakeClaim(mapping(bytes32 claimId => StakeClaim claim) storage claims, bytes32 claimId) external { + delete claims[claimId]; + } + + /** + * @notice Gets the next stake claim in the linked list + * @dev This function is used as a callback in the stake claims linked list traversal. + * @param claims The mapping that stores stake claims by their ID + * @param claimId The ID of the stake claim + * @return The next stake claim ID + */ + function getNextStakeClaim( + mapping(bytes32 claimId => StakeClaim claim) storage claims, + bytes32 claimId + ) external view returns (bytes32) { + return claims[claimId].nextClaim; + } + + /** + * @notice Builds a stake claim ID + * @param dataService The address of the data service + * @param serviceProvider The address of the service provider + * @param nonce A nonce of the stake claim + * @return The stake claim ID + */ + function buildStakeClaimId( + address dataService, + address serviceProvider, + uint256 nonce + ) public pure returns (bytes32) { + return _buildStakeClaimId(dataService, serviceProvider, nonce); + } + + /** + * @notice Builds a stake claim ID + * @param _dataService The address of the data service + * @param _serviceProvider The address of the service provider + * @param _nonce A nonce of the stake claim + * @return The stake claim ID + */ + function _buildStakeClaimId( + address _dataService, + address _serviceProvider, + uint256 _nonce + ) internal pure returns (bytes32) { + return keccak256(abi.encodePacked(_dataService, _serviceProvider, _nonce)); + } +} diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol index 699394c8d..a8f5de172 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol @@ -124,9 +124,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param serviceProvider The address of the service provider. */ modifier onlyValidProvision(address serviceProvider) virtual { - IHorizonStaking.Provision memory provision = _getProvision(serviceProvider); - _checkProvisionTokens(provision); - _checkProvisionParameters(provision, false); + _requireValidProvision(serviceProvider); _; } @@ -176,7 +174,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param _max The maximum allowed value for the provision tokens. */ function _setProvisionTokensRange(uint256 _min, uint256 _max) internal { - require(_min <= _max, ProvisionManagerInvalidRange(_min, _max)); + _requireLTE(_min, _max); _minimumProvisionTokens = _min; _maximumProvisionTokens = _max; emit ProvisionTokensRangeSet(_min, _max); @@ -188,7 +186,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param _max The maximum allowed value for the max verifier cut. */ function _setVerifierCutRange(uint32 _min, uint32 _max) internal { - require(_min <= _max, ProvisionManagerInvalidRange(_min, _max)); + _requireLTE(_min, _max); require(PPMMath.isValidPPM(_max), ProvisionManagerInvalidRange(_min, _max)); _minimumVerifierCut = _min; _maximumVerifierCut = _max; @@ -201,12 +199,23 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param _max The maximum allowed value for the thawing period. */ function _setThawingPeriodRange(uint64 _min, uint64 _max) internal { - require(_min <= _max, ProvisionManagerInvalidRange(_min, _max)); + _requireLTE(_min, _max); _minimumThawingPeriod = _min; _maximumThawingPeriod = _max; emit ThawingPeriodRangeSet(_min, _max); } + /** + * @notice Checks if a provision of a service provider is valid according + * to the parameter ranges established. + * @param _serviceProvider The address of the service provider. + */ + function _requireValidProvision(address _serviceProvider) internal view { + IHorizonStaking.Provision memory provision = _getProvision(_serviceProvider); + _checkProvisionTokens(provision); + _checkProvisionParameters(provision, false); + } + // -- checks -- /** @@ -214,8 +223,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param _serviceProvider The address of the service provider. */ function _checkProvisionTokens(address _serviceProvider) internal view virtual { - IHorizonStaking.Provision memory provision = _getProvision(_serviceProvider); - _checkProvisionTokens(provision); + _checkProvisionTokens(_getProvision(_serviceProvider)); } /** @@ -238,8 +246,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * @param _checkPending If true, checks the pending provision parameters. */ function _checkProvisionParameters(address _serviceProvider, bool _checkPending) internal view virtual { - IHorizonStaking.Provision memory provision = _getProvision(_serviceProvider); - _checkProvisionParameters(provision, _checkPending); + _checkProvisionParameters(_getProvision(_serviceProvider), _checkPending); } /** @@ -320,4 +327,13 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa function _checkValueInRange(uint256 _value, uint256 _min, uint256 _max, bytes memory _revertMessage) private pure { require(_value.isInRange(_min, _max), ProvisionManagerInvalidValue(_revertMessage, _value, _min, _max)); } + + /** + * @notice Requires that a value is less than or equal to another value. + * @param _a The value to check. + * @param _b The value to compare against. + */ + function _requireLTE(uint256 _a, uint256 _b) private pure { + require(_a <= _b, ProvisionManagerInvalidRange(_a, _b)); + } } diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol new file mode 100644 index 000000000..a53439a7c --- /dev/null +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -0,0 +1,416 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { IPaymentsCollector } from "./IPaymentsCollector.sol"; +import { IGraphPayments } from "./IGraphPayments.sol"; +import { IAuthorizable } from "./IAuthorizable.sol"; + +/** + * @title Interface for the {RecurringCollector} 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 + * recurrent payments. + */ +interface IRecurringCollector is IAuthorizable, IPaymentsCollector { + /// @notice The state of an agreement + enum AgreementState { + NotAccepted, + Accepted, + CanceledByServiceProvider, + CanceledByPayer + } + + /// @notice The party that can cancel an agreement + enum CancelAgreementBy { + ServiceProvider, + Payer, + ThirdParty + } + + /** + * @notice A representation of a signed Recurring Collection Agreement (RCA) + * @param rca The Recurring Collection Agreement to be signed + * @param signature The signature of the RCA - 65 bytes: r (32 Bytes) || s (32 Bytes) || v (1 Byte) + */ + struct SignedRCA { + RecurringCollectionAgreement rca; + bytes signature; + } + + /** + * @notice The Recurring Collection Agreement (RCA) + * @param agreementId The agreement ID of the RCA + * @param deadline The deadline for accepting the RCA + * @param endsAt The timestamp when the agreement ends + * @param payer The address of the payer the RCA was issued by + * @param dataService The address of the data service the RCA was issued to + * @param serviceProvider The address of the service provider the RCA was issued to + * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection + * on top of the amount allowed for subsequent collections + * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second + * except for the first collection + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param metadata Arbitrary metadata to extend functionality if a data service requires it + * + */ + struct RecurringCollectionAgreement { + bytes16 agreementId; + uint64 deadline; + uint64 endsAt; + address payer; + address dataService; + address serviceProvider; + uint256 maxInitialTokens; + uint256 maxOngoingTokensPerSecond; + uint32 minSecondsPerCollection; + uint32 maxSecondsPerCollection; + bytes metadata; + } + + /** + * @notice A representation of a signed Recurring Collection Agreement Update (RCAU) + * @param rcau The Recurring Collection Agreement Update to be signed + * @param signature The signature of the RCAU - 65 bytes: r (32 Bytes) || s (32 Bytes) || v (1 Byte) + */ + struct SignedRCAU { + RecurringCollectionAgreementUpdate rcau; + bytes signature; + } + + /** + * @notice The Recurring Collection Agreement Update (RCAU) + * @param agreementId The agreement ID of the RCAU + * @param deadline The deadline for upgrading the RCA + * @param endsAt The timestamp when the agreement ends + * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection + * on top of the amount allowed for subsequent collections + * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second + * except for the first collection + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param metadata Arbitrary metadata to extend functionality if a data service requires it + */ + struct RecurringCollectionAgreementUpdate { + bytes16 agreementId; + uint64 deadline; + uint64 endsAt; + uint256 maxInitialTokens; + uint256 maxOngoingTokensPerSecond; + uint32 minSecondsPerCollection; + uint32 maxSecondsPerCollection; + bytes metadata; + } + + /** + * @notice The data for an agreement + * @dev This struct is used to store the data of an agreement in the contract + * @param dataService The address of the data service + * @param payer The address of the payer + * @param serviceProvider The address of the service provider + * @param acceptedAt The timestamp when the agreement was accepted + * @param lastCollectionAt The timestamp when the agreement was last collected at + * @param endsAt The timestamp when the agreement ends + * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection + * on top of the amount allowed for subsequent collections + * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second + * except for the first collection + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param canceledAt The timestamp when the agreement was canceled + * @param state The state of the agreement + */ + struct AgreementData { + address dataService; + address payer; + address serviceProvider; + uint64 acceptedAt; + uint64 lastCollectionAt; + uint64 endsAt; + uint256 maxInitialTokens; + uint256 maxOngoingTokensPerSecond; + uint32 minSecondsPerCollection; + uint32 maxSecondsPerCollection; + uint64 canceledAt; + AgreementState state; + } + + /** + * @notice The params for collecting an agreement + * @param agreementId The agreement ID of the RCA + * @param collectionId The collection ID of the RCA + * @param tokens The amount of tokens to collect + * @param dataServiceCut The data service cut in parts per million + * @param receiverDestination The address where the collected fees should be sent + */ + struct CollectParams { + bytes16 agreementId; + bytes32 collectionId; + uint256 tokens; + uint256 dataServiceCut; + address receiverDestination; + } + + /** + * @notice Emitted when an agreement is accepted + * @param dataService The address of the data service + * @param payer The address of the payer + * @param serviceProvider The address of the service provider + * @param agreementId The agreement ID + * @param acceptedAt The timestamp when the agreement was accepted + * @param endsAt The timestamp when the agreement ends + * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection + * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + */ + event AgreementAccepted( + address indexed dataService, + address indexed payer, + address indexed serviceProvider, + bytes16 agreementId, + uint64 acceptedAt, + uint64 endsAt, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 minSecondsPerCollection, + uint32 maxSecondsPerCollection + ); + + /** + * @notice Emitted when an agreement is canceled + * @param dataService The address of the data service + * @param payer The address of the payer + * @param serviceProvider The address of the service provider + * @param agreementId The agreement ID + * @param canceledAt The timestamp when the agreement was canceled + * @param canceledBy The party that canceled the agreement + */ + event AgreementCanceled( + address indexed dataService, + address indexed payer, + address indexed serviceProvider, + bytes16 agreementId, + uint64 canceledAt, + CancelAgreementBy canceledBy + ); + + /** + * @notice Emitted when an agreement is updated + * @param dataService The address of the data service + * @param payer The address of the payer + * @param serviceProvider The address of the service provider + * @param agreementId The agreement ID + * @param updatedAt The timestamp when the agreement was updated + * @param endsAt The timestamp when the agreement ends + * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection + * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + */ + event AgreementUpdated( + address indexed dataService, + address indexed payer, + address indexed serviceProvider, + bytes16 agreementId, + uint64 updatedAt, + uint64 endsAt, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 minSecondsPerCollection, + uint32 maxSecondsPerCollection + ); + + /** + * @notice Emitted when an RCA is collected + * @param dataService The address of the data service + * @param payer The address of the payer + * @param serviceProvider The address of the service provider + * @param agreementId The agreement ID + * @param collectionId The collection ID + * @param tokens The amount of tokens collected + * @param dataServiceCut The tokens cut for the data service + */ + event RCACollected( + address indexed dataService, + address indexed payer, + address indexed serviceProvider, + bytes16 agreementId, + bytes32 collectionId, + uint256 tokens, + uint256 dataServiceCut + ); + + /** + * @notice Thrown when accepting an agreement with a zero ID + */ + error RecurringCollectorAgreementIdZero(); + + /** + * @notice Thrown when interacting with an agreement not owned by the message sender + * @param agreementId The agreement ID + * @param unauthorizedDataService The address of the unauthorized data service + */ + error RecurringCollectorDataServiceNotAuthorized(bytes16 agreementId, address unauthorizedDataService); + + /** + * @notice Thrown when interacting with an agreement with an elapsed deadline + * @param currentTimestamp The current timestamp + * @param deadline The elapsed deadline timestamp + */ + error RecurringCollectorAgreementDeadlineElapsed(uint256 currentTimestamp, uint64 deadline); + + /** + * @notice Thrown when the signer is invalid + */ + error RecurringCollectorInvalidSigner(); + + /** + * @notice Thrown when the payment type is not IndexingFee + * @param invalidPaymentType The invalid payment type + */ + error RecurringCollectorInvalidPaymentType(IGraphPayments.PaymentTypes invalidPaymentType); + + /** + * @notice Thrown when the caller is not the data service the RCA was issued to + * @param unauthorizedCaller The address of the caller + * @param dataService The address of the data service + */ + error RecurringCollectorUnauthorizedCaller(address unauthorizedCaller, address dataService); + + /** + * @notice Thrown when calling collect() with invalid data + * @param invalidData The invalid data + */ + error RecurringCollectorInvalidCollectData(bytes invalidData); + + /** + * @notice Thrown when calling collect() on a payer canceled agreement + * where the final collection has already been done + * @param agreementId The agreement ID + * @param finalCollectionAt The timestamp when the final collection was done + */ + error RecurringCollectorFinalCollectionDone(bytes16 agreementId, uint256 finalCollectionAt); + + /** + * @notice Thrown when interacting with an agreement that has an incorrect state + * @param agreementId The agreement ID + * @param incorrectState The incorrect state + */ + error RecurringCollectorAgreementIncorrectState(bytes16 agreementId, AgreementState incorrectState); + + /** + * @notice Thrown when accepting an agreement with an address that is not set + */ + error RecurringCollectorAgreementAddressNotSet(); + + /** + * @notice Thrown when accepting or upgrading an agreement with an elapsed endsAt + * @param currentTimestamp The current timestamp + * @param endsAt The agreement end timestamp + */ + error RecurringCollectorAgreementElapsedEndsAt(uint256 currentTimestamp, uint64 endsAt); + + /** + * @notice Thrown when accepting or upgrading an agreement with an elapsed endsAt + * @param allowedMinCollectionWindow The allowed minimum collection window + * @param minSecondsPerCollection The minimum seconds per collection + * @param maxSecondsPerCollection The maximum seconds per collection + */ + error RecurringCollectorAgreementInvalidCollectionWindow( + uint32 allowedMinCollectionWindow, + uint32 minSecondsPerCollection, + uint32 maxSecondsPerCollection + ); + + /** + * @notice Thrown when accepting or upgrading an agreement with an invalid duration + * @param requiredMinDuration The required minimum duration + * @param invalidDuration The invalid duration + */ + error RecurringCollectorAgreementInvalidDuration(uint32 requiredMinDuration, uint256 invalidDuration); + + /** + * @notice Thrown when calling collect() with a zero collection seconds + * @param agreementId The agreement ID + * @param currentTimestamp The current timestamp + * @param lastCollectionAt The timestamp when the last collection was done + * + */ + error RecurringCollectorZeroCollectionSeconds( + bytes16 agreementId, + uint256 currentTimestamp, + uint64 lastCollectionAt + ); + + /** + * @notice Thrown when calling collect() too soon + * @param agreementId The agreement ID + * @param secondsSinceLast Seconds since last collection + * @param minSeconds Minimum seconds between collections + */ + error RecurringCollectorCollectionTooSoon(bytes16 agreementId, uint32 secondsSinceLast, uint32 minSeconds); + + /** + * @notice Thrown when calling collect() too late + * @param agreementId The agreement ID + * @param secondsSinceLast Seconds since last collection + * @param maxSeconds Maximum seconds between collections + */ + error RecurringCollectorCollectionTooLate(bytes16 agreementId, uint64 secondsSinceLast, uint32 maxSeconds); + + /** + * @dev Accept an indexing agreement. + * @param signedRCA The signed Recurring Collection Agreement which is to be accepted. + */ + function accept(SignedRCA calldata signedRCA) external; + + /** + * @dev Cancel an indexing agreement. + * @param agreementId The agreement's ID. + * @param by The party that is canceling the agreement. + */ + function cancel(bytes16 agreementId, CancelAgreementBy by) external; + + /** + * @dev Update an indexing agreement. + * @param signedRCAU The signed Recurring Collection Agreement Update which is to be applied. + */ + function update(SignedRCAU calldata signedRCAU) external; + + /** + * @dev Computes the hash of a RecurringCollectionAgreement (RCA). + * @param rca The RCA for which to compute the hash. + * @return The hash of the RCA. + */ + function hashRCA(RecurringCollectionAgreement calldata rca) external view returns (bytes32); + + /** + * @dev Computes the hash of a RecurringCollectionAgreementUpdate (RCAU). + * @param rcau The RCAU for which to compute the hash. + * @return The hash of the RCAU. + */ + function hashRCAU(RecurringCollectionAgreementUpdate calldata rcau) external view returns (bytes32); + + /** + * @dev Recovers the signer address of a signed RecurringCollectionAgreement (RCA). + * @param signedRCA The SignedRCA containing the RCA and its signature. + * @return The address of the signer. + */ + function recoverRCASigner(SignedRCA calldata signedRCA) external view returns (address); + + /** + * @dev Recovers the signer address of a signed RecurringCollectionAgreementUpdate (RCAU). + * @param signedRCAU The SignedRCAU containing the RCAU and its signature. + * @return The address of the signer. + */ + function recoverRCAUSigner(SignedRCAU calldata signedRCAU) external view returns (address); + + /** + * @notice Gets an agreement. + * @param agreementId The ID of the agreement to retrieve. + * @return The AgreementData struct containing the agreement's data. + */ + function getAgreement(bytes16 agreementId) external view returns (AgreementData memory); +} diff --git a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol index bab1be09e..6eda16b5f 100644 --- a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol +++ b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol @@ -102,7 +102,10 @@ contract GraphTallyCollector is EIP712, GraphDirectory, Authorizable, IGraphTall bytes calldata _data, uint256 _tokensToCollect ) private returns (uint256) { - require(_paymentType == IGraphPayments.PaymentTypes.QueryFee, GraphTallyCollectorInvalidPaymentType(_paymentType)); + require( + _paymentType == IGraphPayments.PaymentTypes.QueryFee, + GraphTallyCollectorInvalidPaymentType(_paymentType) + ); (SignedRAV memory signedRAV, uint256 dataServiceCut, address receiverDestination) = abi.decode( _data, diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol new file mode 100644 index 000000000..99122a348 --- /dev/null +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -0,0 +1,540 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; + +import { Authorizable } from "../../utilities/Authorizable.sol"; +import { GraphDirectory } from "../../utilities/GraphDirectory.sol"; +// solhint-disable-next-line no-unused-import +import { IPaymentsCollector } from "../../interfaces/IPaymentsCollector.sol"; // for @inheritdoc +import { IRecurringCollector } from "../../interfaces/IRecurringCollector.sol"; +import { IGraphPayments } from "../../interfaces/IGraphPayments.sol"; +import { PPMMath } from "../../libraries/PPMMath.sol"; + +/** + * @title RecurringCollector contract + * @dev Implements the {IRecurringCollector} interface. + * @notice A payments collector contract that can be used to collect payments using a RCA (Recurring Collection Agreement). + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringCollector { + using PPMMath for uint256; + + /// @notice The minimum number of seconds that must be between two collections + uint32 public constant MIN_SECONDS_COLLECTION_WINDOW = 600; + + /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct + bytes32 public constant EIP712_RCA_TYPEHASH = + keccak256( + "RecurringCollectionAgreement(bytes16 agreementId,uint256 deadline,uint256 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" + ); + + /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct + bytes32 public constant EIP712_RCAU_TYPEHASH = + keccak256( + "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint256 deadline,uint256 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" + ); + + /// @notice Tracks agreements + mapping(bytes16 agreementId => AgreementData data) public agreements; + + /** + * @notice Constructs a new instance of the RecurringCollector 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. + * @param revokeSignerThawingPeriod The duration (in seconds) in which a signer is thawing before they can be revoked. + */ + constructor( + string memory eip712Name, + string memory eip712Version, + address controller, + uint256 revokeSignerThawingPeriod + ) EIP712(eip712Name, eip712Version) GraphDirectory(controller) Authorizable(revokeSignerThawingPeriod) {} + + /** + * @inheritdoc IPaymentsCollector + * @notice Initiate a payment collection through the payments protocol. + * See {IPaymentsCollector.collect}. + * @dev Caller must be the data service the RCA was issued to. + */ + function collect(IGraphPayments.PaymentTypes paymentType, bytes calldata data) external returns (uint256) { + require( + paymentType == IGraphPayments.PaymentTypes.IndexingFee, + RecurringCollectorInvalidPaymentType(paymentType) + ); + try this.decodeCollectData(data) returns (CollectParams memory collectParams) { + return _collect(collectParams); + } catch { + revert RecurringCollectorInvalidCollectData(data); + } + } + + /** + * @inheritdoc IRecurringCollector + * @notice Accept an indexing agreement. + * See {IRecurringCollector.accept}. + * @dev Caller must be the data service the RCA was issued to. + */ + function accept(SignedRCA calldata signedRCA) external { + require(signedRCA.rca.agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); + require( + msg.sender == signedRCA.rca.dataService, + RecurringCollectorUnauthorizedCaller(msg.sender, signedRCA.rca.dataService) + ); + require( + signedRCA.rca.deadline >= block.timestamp, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, signedRCA.rca.deadline) + ); + + // check that the voucher is signed by the payer (or proxy) + _requireAuthorizedRCASigner(signedRCA); + + require( + signedRCA.rca.dataService != address(0) && + signedRCA.rca.payer != address(0) && + signedRCA.rca.serviceProvider != address(0), + RecurringCollectorAgreementAddressNotSet() + ); + + _requireValidCollectionWindowParams( + signedRCA.rca.endsAt, + signedRCA.rca.minSecondsPerCollection, + signedRCA.rca.maxSecondsPerCollection + ); + + AgreementData storage agreement = _getAgreementStorage(signedRCA.rca.agreementId); + // check that the agreement is not already accepted + require( + agreement.state == AgreementState.NotAccepted, + RecurringCollectorAgreementIncorrectState(signedRCA.rca.agreementId, agreement.state) + ); + + // accept the agreement + agreement.acceptedAt = uint64(block.timestamp); + agreement.state = AgreementState.Accepted; + agreement.dataService = signedRCA.rca.dataService; + agreement.payer = signedRCA.rca.payer; + agreement.serviceProvider = signedRCA.rca.serviceProvider; + agreement.endsAt = signedRCA.rca.endsAt; + agreement.maxInitialTokens = signedRCA.rca.maxInitialTokens; + agreement.maxOngoingTokensPerSecond = signedRCA.rca.maxOngoingTokensPerSecond; + agreement.minSecondsPerCollection = signedRCA.rca.minSecondsPerCollection; + agreement.maxSecondsPerCollection = signedRCA.rca.maxSecondsPerCollection; + + emit AgreementAccepted( + agreement.dataService, + agreement.payer, + agreement.serviceProvider, + signedRCA.rca.agreementId, + agreement.acceptedAt, + agreement.endsAt, + agreement.maxInitialTokens, + agreement.maxOngoingTokensPerSecond, + agreement.minSecondsPerCollection, + agreement.maxSecondsPerCollection + ); + } + + /** + * @inheritdoc IRecurringCollector + * @notice Cancel an indexing agreement. + * See {IRecurringCollector.cancel}. + * @dev Caller must be the data service for the agreement. + */ + function cancel(bytes16 agreementId, CancelAgreementBy by) external { + AgreementData storage agreement = _getAgreementStorage(agreementId); + require( + agreement.state == AgreementState.Accepted, + RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) + ); + require( + agreement.dataService == msg.sender, + RecurringCollectorDataServiceNotAuthorized(agreementId, msg.sender) + ); + agreement.canceledAt = uint64(block.timestamp); + if (by == CancelAgreementBy.Payer) { + agreement.state = AgreementState.CanceledByPayer; + } else { + agreement.state = AgreementState.CanceledByServiceProvider; + } + + emit AgreementCanceled( + agreement.dataService, + agreement.payer, + agreement.serviceProvider, + agreementId, + agreement.canceledAt, + by + ); + } + + /** + * @inheritdoc IRecurringCollector + * @notice Update an indexing agreement. + * See {IRecurringCollector.update}. + * @dev Caller must be the data service for the agreement. + */ + function update(SignedRCAU calldata signedRCAU) external { + require( + signedRCAU.rcau.deadline >= block.timestamp, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, signedRCAU.rcau.deadline) + ); + + AgreementData storage agreement = _getAgreementStorage(signedRCAU.rcau.agreementId); + require( + agreement.state == AgreementState.Accepted, + RecurringCollectorAgreementIncorrectState(signedRCAU.rcau.agreementId, agreement.state) + ); + require( + agreement.dataService == msg.sender, + RecurringCollectorDataServiceNotAuthorized(signedRCAU.rcau.agreementId, msg.sender) + ); + + // check that the voucher is signed by the payer (or proxy) + _requireAuthorizedRCAUSigner(signedRCAU, agreement.payer); + + _requireValidCollectionWindowParams( + signedRCAU.rcau.endsAt, + signedRCAU.rcau.minSecondsPerCollection, + signedRCAU.rcau.maxSecondsPerCollection + ); + + // update the agreement + agreement.endsAt = signedRCAU.rcau.endsAt; + agreement.maxInitialTokens = signedRCAU.rcau.maxInitialTokens; + agreement.maxOngoingTokensPerSecond = signedRCAU.rcau.maxOngoingTokensPerSecond; + agreement.minSecondsPerCollection = signedRCAU.rcau.minSecondsPerCollection; + agreement.maxSecondsPerCollection = signedRCAU.rcau.maxSecondsPerCollection; + + emit AgreementUpdated( + agreement.dataService, + agreement.payer, + agreement.serviceProvider, + signedRCAU.rcau.agreementId, + uint64(block.timestamp), + agreement.endsAt, + agreement.maxInitialTokens, + agreement.maxOngoingTokensPerSecond, + agreement.minSecondsPerCollection, + agreement.maxSecondsPerCollection + ); + } + + /// @inheritdoc IRecurringCollector + function recoverRCASigner(SignedRCA calldata signedRCA) external view returns (address) { + return _recoverRCASigner(signedRCA); + } + + /// @inheritdoc IRecurringCollector + function recoverRCAUSigner(SignedRCAU calldata signedRCAU) external view returns (address) { + return _recoverRCAUSigner(signedRCAU); + } + + /// @inheritdoc IRecurringCollector + function hashRCA(RecurringCollectionAgreement calldata rca) external view returns (bytes32) { + return _hashRCA(rca); + } + + /// @inheritdoc IRecurringCollector + function hashRCAU(RecurringCollectionAgreementUpdate calldata rcau) external view returns (bytes32) { + return _hashRCAU(rcau); + } + + /// @inheritdoc IRecurringCollector + function getAgreement(bytes16 agreementId) external view returns (AgreementData memory) { + return _getAgreement(agreementId); + } + + /** + * @notice Decodes the collect data. + * @param data The encoded collect parameters. + * @return The decoded collect parameters. + */ + function decodeCollectData(bytes calldata data) public pure returns (CollectParams memory) { + return abi.decode(data, (CollectParams)); + } + + /** + * @notice Collect payment through the payments protocol. + * @dev Caller must be the data service the RCA was issued to. + * + * Emits {PaymentCollected} and {RCACollected} events. + * + * @param _params The decoded parameters for the collection + * @return The amount of tokens collected + */ + function _collect(CollectParams memory _params) private returns (uint256) { + AgreementData storage agreement = _getAgreementStorage(_params.agreementId); + require( + agreement.state == AgreementState.Accepted || agreement.state == AgreementState.CanceledByPayer, + RecurringCollectorAgreementIncorrectState(_params.agreementId, agreement.state) + ); + + require( + msg.sender == agreement.dataService, + RecurringCollectorDataServiceNotAuthorized(_params.agreementId, msg.sender) + ); + + uint256 tokensToCollect = 0; + if (_params.tokens != 0) { + tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens); + + _graphPaymentsEscrow().collect( + IGraphPayments.PaymentTypes.IndexingFee, + agreement.payer, + agreement.serviceProvider, + tokensToCollect, + agreement.dataService, + _params.dataServiceCut, + _params.receiverDestination + ); + } + agreement.lastCollectionAt = uint64(block.timestamp); + + emit PaymentCollected( + IGraphPayments.PaymentTypes.IndexingFee, + _params.collectionId, + agreement.payer, + agreement.serviceProvider, + agreement.dataService, + tokensToCollect + ); + + emit RCACollected( + agreement.dataService, + agreement.payer, + agreement.serviceProvider, + _params.agreementId, + _params.collectionId, + tokensToCollect, + _params.dataServiceCut + ); + + return tokensToCollect; + } + + /** + * @notice Requires that the collection window parameters are valid. + * + * @param _endsAt The end time of the agreement + * @param _minSecondsPerCollection The minimum seconds per collection + * @param _maxSecondsPerCollection The maximum seconds per collection + */ + function _requireValidCollectionWindowParams( + uint64 _endsAt, + uint32 _minSecondsPerCollection, + uint32 _maxSecondsPerCollection + ) private view { + // Agreement needs to end in the future + require(_endsAt > block.timestamp, RecurringCollectorAgreementElapsedEndsAt(block.timestamp, _endsAt)); + + // Collection window needs to be at least MIN_SECONDS_COLLECTION_WINDOW + require( + _maxSecondsPerCollection > _minSecondsPerCollection && + (_maxSecondsPerCollection - _minSecondsPerCollection >= MIN_SECONDS_COLLECTION_WINDOW), + RecurringCollectorAgreementInvalidCollectionWindow( + MIN_SECONDS_COLLECTION_WINDOW, + _minSecondsPerCollection, + _maxSecondsPerCollection + ) + ); + + // Agreement needs to last at least one min collection window + require( + _endsAt - block.timestamp >= _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, + RecurringCollectorAgreementInvalidDuration( + _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, + _endsAt - block.timestamp + ) + ); + } + + /** + * @notice Requires that the collection params are valid. + * @param _agreement The agreement data + * @param _agreementId The ID of the agreement + * @param _tokens The number of tokens to collect + * @return The number of tokens that can be collected + */ + function _requireValidCollect( + AgreementData memory _agreement, + bytes16 _agreementId, + uint256 _tokens + ) private view returns (uint256) { + bool canceledOrElapsed = _agreement.state == AgreementState.CanceledByPayer || + block.timestamp > _agreement.endsAt; + uint256 canceledOrNow = _agreement.state == AgreementState.CanceledByPayer + ? _agreement.canceledAt + : block.timestamp; + + // if canceled by the payer allow collection till canceledAt + // if elapsed allow collection till endsAt + // if both are true, use the earlier one + uint256 collectionEnd = canceledOrElapsed ? Math.min(canceledOrNow, _agreement.endsAt) : block.timestamp; + uint256 collectionStart = _agreementCollectionStartAt(_agreement); + require( + collectionEnd != collectionStart, + RecurringCollectorZeroCollectionSeconds(_agreementId, block.timestamp, uint64(collectionStart)) + ); + require(collectionEnd > collectionStart, RecurringCollectorFinalCollectionDone(_agreementId, collectionStart)); + + uint256 collectionSeconds = collectionEnd - collectionStart; + // Check that the collection window is long enough + // If the agreement is canceled or elapsed, allow a shorter collection window + if (!canceledOrElapsed) { + require( + collectionSeconds >= _agreement.minSecondsPerCollection, + RecurringCollectorCollectionTooSoon( + _agreementId, + uint32(collectionSeconds), + _agreement.minSecondsPerCollection + ) + ); + } + require( + collectionSeconds <= _agreement.maxSecondsPerCollection, + RecurringCollectorCollectionTooLate( + _agreementId, + uint64(collectionSeconds), + _agreement.maxSecondsPerCollection + ) + ); + + uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * collectionSeconds; + maxTokens += _agreement.lastCollectionAt == 0 ? _agreement.maxInitialTokens : 0; + + return Math.min(_tokens, maxTokens); + } + + /** + * @notice See {recoverRCASigner} + * @param _signedRCA The signed RCA to recover the signer from + * @return The address of the signer + */ + function _recoverRCASigner(SignedRCA memory _signedRCA) private view returns (address) { + bytes32 messageHash = _hashRCA(_signedRCA.rca); + return ECDSA.recover(messageHash, _signedRCA.signature); + } + + /** + * @notice See {recoverRCAUSigner} + * @param _signedRCAU The signed RCAU to recover the signer from + * @return The address of the signer + */ + function _recoverRCAUSigner(SignedRCAU memory _signedRCAU) private view returns (address) { + bytes32 messageHash = _hashRCAU(_signedRCAU.rcau); + return ECDSA.recover(messageHash, _signedRCAU.signature); + } + + /** + * @notice See {hashRCA} + * @param _rca The RCA to hash + * @return The EIP712 hash of the RCA + */ + function _hashRCA(RecurringCollectionAgreement memory _rca) private view returns (bytes32) { + return + _hashTypedDataV4( + keccak256( + abi.encode( + EIP712_RCA_TYPEHASH, + _rca.agreementId, + _rca.deadline, + _rca.endsAt, + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.maxInitialTokens, + _rca.maxOngoingTokensPerSecond, + _rca.minSecondsPerCollection, + _rca.maxSecondsPerCollection, + keccak256(_rca.metadata) + ) + ) + ); + } + + /** + * @notice See {hashRCAU} + * @param _rcau The RCAU to hash + * @return The EIP712 hash of the RCAU + */ + function _hashRCAU(RecurringCollectionAgreementUpdate memory _rcau) private view returns (bytes32) { + return + _hashTypedDataV4( + keccak256( + abi.encode( + EIP712_RCAU_TYPEHASH, + _rcau.agreementId, + _rcau.deadline, + _rcau.endsAt, + _rcau.maxInitialTokens, + _rcau.maxOngoingTokensPerSecond, + _rcau.minSecondsPerCollection, + _rcau.maxSecondsPerCollection, + keccak256(_rcau.metadata) + ) + ) + ); + } + + /** + * @notice Requires that the signer for the RCA is authorized + * by the payer of the RCA. + * @param _signedRCA The signed RCA to verify + * @return The address of the authorized signer + */ + function _requireAuthorizedRCASigner(SignedRCA memory _signedRCA) private view returns (address) { + address signer = _recoverRCASigner(_signedRCA); + require(_isAuthorized(_signedRCA.rca.payer, signer), RecurringCollectorInvalidSigner()); + + return signer; + } + + /** + * @notice Requires that the signer for the RCAU is authorized + * by the payer. + * @param _signedRCAU The signed RCAU to verify + * @param _payer The address of the payer + * @return The address of the authorized signer + */ + function _requireAuthorizedRCAUSigner( + SignedRCAU memory _signedRCAU, + address _payer + ) private view returns (address) { + address signer = _recoverRCAUSigner(_signedRCAU); + require(_isAuthorized(_payer, signer), RecurringCollectorInvalidSigner()); + + return signer; + } + + /** + * @notice Gets an agreement to be updated. + * @param _agreementId The ID of the agreement to get + * @return The storage reference to the agreement data + */ + function _getAgreementStorage(bytes16 _agreementId) private view returns (AgreementData storage) { + return agreements[_agreementId]; + } + + /** + * @notice See {getAgreement} + * @param _agreementId The ID of the agreement to get + * @return The agreement data + */ + function _getAgreement(bytes16 _agreementId) private view returns (AgreementData memory) { + return agreements[_agreementId]; + } + + /** + * @notice Gets the start time for the collection of an agreement. + * @param _agreement The agreement data + * @return The start time for the collection of the agreement + */ + function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { + return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; + } +} diff --git a/packages/horizon/package.json b/packages/horizon/package.json index c3f960433..641fc61dd 100644 --- a/packages/horizon/package.json +++ b/packages/horizon/package.json @@ -17,9 +17,10 @@ "scripts": { "lint": "pnpm lint:ts && pnpm lint:sol", "lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored", - "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint", + "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint && pnpm lint:sol:solhint:test", "lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"", "lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js", + "lint:sol:solhint:test": "solhint --noPrompt --fix \"test/unit/payments/recurring-collector/*\" --config node_modules/solhint-graph-config/index.js", "lint:sol:natspec": "natspec-smells --config natspec-smells.config.js", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "hardhat compile", diff --git a/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol b/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol index cd6e7bf46..6657ac315 100644 --- a/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol +++ b/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.27; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; import { DataServiceImpFees } from "../implementations/DataServiceImpFees.sol"; -import { IDataServiceFees } from "../../../../contracts/data-service/interfaces/IDataServiceFees.sol"; +import { StakeClaims } from "../../../../contracts/data-service/libraries/StakeClaims.sol"; import { ProvisionTracker } from "../../../../contracts/data-service/libraries/ProvisionTracker.sol"; import { LinkedList } from "../../../../contracts/libraries/LinkedList.sol"; @@ -13,7 +13,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { useIndexer useProvisionDataService(address(dataService), PROVISION_TOKENS, 0, 0) { - vm.expectRevert(abi.encodeWithSignature("DataServiceFeesZeroTokens()")); + vm.expectRevert(abi.encodeWithSignature("StakeClaimsZeroTokens()")); dataService.lockStake(users.indexer, 0); } @@ -132,6 +132,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { uint256 stakeToLock; bytes32 predictedClaimId; } + function _assert_lockStake(address serviceProvider, uint256 tokens) private { // before state (bytes32 beforeHead, , uint256 beforeNonce, uint256 beforeCount) = dataService.claimsLists(serviceProvider); @@ -146,7 +147,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { // it should emit a an event vm.expectEmit(); - emit IDataServiceFees.StakeClaimLocked( + emit StakeClaims.StakeClaimLocked( serviceProvider, calcValues.predictedClaimId, calcValues.stakeToLock, @@ -185,6 +186,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { uint256 tokensReleased; bytes32 head; } + function _assert_releaseStake(address serviceProvider, uint256 numClaimsToRelease) private { // before state (bytes32 beforeHead, bytes32 beforeTail, uint256 beforeNonce, uint256 beforeCount) = dataService.claimsLists( @@ -208,14 +210,14 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { break; } - emit IDataServiceFees.StakeClaimReleased(serviceProvider, calcValues.head, claimTokens, releasableAt); + emit StakeClaims.StakeClaimReleased(serviceProvider, calcValues.head, claimTokens, releasableAt); calcValues.head = nextClaim; calcValues.tokensReleased += claimTokens; calcValues.claimsCount++; } // it should emit a an event - emit IDataServiceFees.StakeClaimsReleased(serviceProvider, calcValues.claimsCount, calcValues.tokensReleased); + emit StakeClaims.StakeClaimsReleased(serviceProvider, calcValues.claimsCount, calcValues.tokensReleased); dataService.releaseStake(numClaimsToRelease); // after state diff --git a/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol b/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol new file mode 100644 index 000000000..36ebdda18 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; +import { IPaymentsEscrow } from "../../../../contracts/interfaces/IPaymentsEscrow.sol"; + +contract PaymentsEscrowMock is IPaymentsEscrow { + function initialize() external {} + + function collect(IGraphPayments.PaymentTypes, address, address, uint256, address, uint256, address) external {} + + function deposit(address, address, uint256) external {} + + function depositTo(address, address, address, uint256) external {} + + function thaw(address, address, uint256) external {} + + function cancelThaw(address, address) external {} + + function withdraw(address, address) external {} + + function getBalance(address, address, address) external pure returns (uint256) { + return 0; + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol new file mode 100644 index 000000000..ff5e39848 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IAuthorizable } from "../../../../contracts/interfaces/IAuthorizable.sol"; +import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; + +import { AuthorizableTest } from "../../../unit/utilities/Authorizable.t.sol"; +import { RecurringCollectorControllerMock } from "./RecurringCollectorControllerMock.t.sol"; + +contract RecurringCollectorAuthorizableTest is AuthorizableTest { + function newAuthorizable(uint256 thawPeriod) public override returns (IAuthorizable) { + return + new RecurringCollector( + "RecurringCollector", + "1", + address(new RecurringCollectorControllerMock(address(1))), + thawPeriod + ); + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol new file mode 100644 index 000000000..3425e8b01 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { IPaymentsEscrow } from "../../../../contracts/interfaces/IPaymentsEscrow.sol"; +import { ControllerMock } from "../../../../contracts/mocks/ControllerMock.sol"; + +contract RecurringCollectorControllerMock is ControllerMock, Test { + address private _invalidContractAddress; + IPaymentsEscrow private _paymentsEscrow; + + constructor(address paymentsEscrow) ControllerMock(address(0)) { + _invalidContractAddress = makeAddr("invalidContractAddress"); + _paymentsEscrow = IPaymentsEscrow(paymentsEscrow); + } + + function getContractProxy(bytes32 data) external view override returns (address) { + return data == keccak256("PaymentsEscrow") ? address(_paymentsEscrow) : _invalidContractAddress; + } + + function getPaymentsEscrow() external view returns (address) { + return address(_paymentsEscrow); + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol new file mode 100644 index 000000000..b3ccbc3b8 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; +import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; +import { AuthorizableHelper } from "../../../unit/utilities/Authorizable.t.sol"; +import { Bounder } from "../../../unit/utils/Bounder.t.sol"; + +contract RecurringCollectorHelper is AuthorizableHelper, Bounder { + RecurringCollector public collector; + + constructor( + RecurringCollector collector_ + ) AuthorizableHelper(collector_, collector_.REVOKE_AUTHORIZATION_THAWING_PERIOD()) { + collector = collector_; + } + + function generateSignedRCA( + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint256 signerPrivateKey + ) public view returns (IRecurringCollector.SignedRCA memory) { + bytes32 messageHash = collector.hashRCA(rca); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); + bytes memory signature = abi.encodePacked(r, s, v); + IRecurringCollector.SignedRCA memory signedRCA = IRecurringCollector.SignedRCA({ + rca: rca, + signature: signature + }); + + return signedRCA; + } + + function generateSignedRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + uint256 signerPrivateKey + ) public view returns (IRecurringCollector.SignedRCAU memory) { + bytes32 messageHash = collector.hashRCAU(rcau); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); + bytes memory signature = abi.encodePacked(r, s, v); + IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ + rcau: rcau, + signature: signature + }); + + return signedRCAU; + } + + function withElapsedAcceptDeadline( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + require(block.timestamp > 0, "block.timestamp can't be zero"); + require(block.timestamp <= type(uint64).max, "block.timestamp can't be huge"); + rca.deadline = uint64(bound(rca.deadline, 0, block.timestamp - 1)); + return rca; + } + + function withOKAcceptDeadline( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + require(block.timestamp <= type(uint64).max, "block.timestamp can't be huge"); + rca.deadline = uint64(boundTimestampMin(rca.deadline, block.timestamp)); + return rca; + } + + function sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + vm.assume(rca.agreementId != bytes16(0)); + vm.assume(rca.dataService != address(0)); + vm.assume(rca.payer != address(0)); + vm.assume(rca.serviceProvider != address(0)); + + rca.minSecondsPerCollection = _sensibleMinSecondsPerCollection(rca.minSecondsPerCollection); + rca.maxSecondsPerCollection = _sensibleMaxSecondsPerCollection( + rca.maxSecondsPerCollection, + rca.minSecondsPerCollection + ); + + rca.deadline = _sensibleDeadline(rca.deadline); + rca.endsAt = _sensibleEndsAt(rca.endsAt, rca.maxSecondsPerCollection); + + rca.maxInitialTokens = _sensibleMaxInitialTokens(rca.maxInitialTokens); + rca.maxOngoingTokensPerSecond = _sensibleMaxOngoingTokensPerSecond(rca.maxOngoingTokensPerSecond); + + return rca; + } + + function sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau + ) public view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + rcau.minSecondsPerCollection = _sensibleMinSecondsPerCollection(rcau.minSecondsPerCollection); + rcau.maxSecondsPerCollection = _sensibleMaxSecondsPerCollection( + rcau.maxSecondsPerCollection, + rcau.minSecondsPerCollection + ); + + rcau.deadline = _sensibleDeadline(rcau.deadline); + rcau.endsAt = _sensibleEndsAt(rcau.endsAt, rcau.maxSecondsPerCollection); + rcau.maxInitialTokens = _sensibleMaxInitialTokens(rcau.maxInitialTokens); + rcau.maxOngoingTokensPerSecond = _sensibleMaxOngoingTokensPerSecond(rcau.maxOngoingTokensPerSecond); + + return rcau; + } + + function _sensibleDeadline(uint256 _seed) internal view returns (uint64) { + return + uint64( + bound(_seed, block.timestamp + 1, block.timestamp + uint256(collector.MIN_SECONDS_COLLECTION_WINDOW())) + ); // between now and +MIN_SECONDS_COLLECTION_WINDOW + } + + function _sensibleEndsAt(uint256 _seed, uint32 _maxSecondsPerCollection) internal view returns (uint64) { + return + uint64( + bound( + _seed, + block.timestamp + (10 * uint256(_maxSecondsPerCollection)), + block.timestamp + (1_000_000 * uint256(_maxSecondsPerCollection)) + ) + ); // between 10 and 1M max collections + } + + function _sensibleMaxSecondsPerCollection( + uint32 _seed, + uint32 _minSecondsPerCollection + ) internal view returns (uint32) { + return + uint32( + bound( + _seed, + _minSecondsPerCollection + uint256(collector.MIN_SECONDS_COLLECTION_WINDOW()), + 60 * 60 * 24 * 30 + ) // between minSecondsPerCollection + 2h and 30 days + ); + } + + function _sensibleMaxInitialTokens(uint256 _seed) internal pure returns (uint256) { + return bound(_seed, 0, 1e18 * 100_000_000); // between 0 and 100M tokens + } + + function _sensibleMaxOngoingTokensPerSecond(uint256 _seed) internal pure returns (uint256) { + return bound(_seed, 1, 1e18); // between 1 and 1e18 tokens per second + } + + function _sensibleMinSecondsPerCollection(uint32 _seed) internal pure returns (uint32) { + return uint32(bound(_seed, 10 * 60, 24 * 60 * 60)); // between 10 min and 24h + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol new file mode 100644 index 000000000..d9479b955 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_Accept(FuzzyTestAccept calldata fuzzyTestAccept) public { + _sensibleAuthorizeAndAccept(fuzzyTestAccept); + } + + function test_Accept_Revert_WhenAcceptanceDeadlineElapsed( + IRecurringCollector.SignedRCA memory fuzzySignedRCA, + uint256 unboundedSkip + ) public { + vm.assume(fuzzySignedRCA.rca.agreementId != bytes16(0)); + skip(boundSkip(unboundedSkip, 1, type(uint64).max - block.timestamp)); + fuzzySignedRCA.rca = _recurringCollectorHelper.withElapsedAcceptDeadline(fuzzySignedRCA.rca); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + fuzzySignedRCA.rca.deadline + ); + vm.expectRevert(expectedErr); + vm.prank(fuzzySignedRCA.rca.dataService); + _recurringCollector.accept(fuzzySignedRCA); + } + + function test_Accept_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + accepted.rca.agreementId, + IRecurringCollector.AgreementState.Accepted + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.accept(accepted); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol new file mode 100644 index 000000000..fe938c825 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_Cancel(FuzzyTestAccept calldata fuzzyTestAccept, uint8 unboundedCanceler) public { + _sensibleAuthorizeAndAccept(fuzzyTestAccept); + _cancel(fuzzyTestAccept.rca, _fuzzyCancelAgreementBy(unboundedCanceler)); + } + + function test_Cancel_Revert_WhenNotAccepted( + IRecurringCollector.RecurringCollectionAgreement memory fuzzyRCA, + uint8 unboundedCanceler + ) public { + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + fuzzyRCA.agreementId, + IRecurringCollector.AgreementState.NotAccepted + ); + vm.expectRevert(expectedErr); + vm.prank(fuzzyRCA.dataService); + _recurringCollector.cancel(fuzzyRCA.agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); + } + + function test_Cancel_Revert_WhenNotDataService( + FuzzyTestAccept calldata fuzzyTestAccept, + uint8 unboundedCanceler, + address notDataService + ) public { + vm.assume(fuzzyTestAccept.rca.dataService != notDataService); + + _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, + fuzzyTestAccept.rca.agreementId, + notDataService + ); + vm.expectRevert(expectedErr); + vm.prank(notDataService); + _recurringCollector.cancel(fuzzyTestAccept.rca.agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); + } + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol new file mode 100644 index 000000000..8942c21bf --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_Collect_Revert_WhenInvalidPaymentType(uint8 unboundedPaymentType, bytes memory data) public { + IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes( + bound( + unboundedPaymentType, + uint256(type(IGraphPayments.PaymentTypes).min), + uint256(type(IGraphPayments.PaymentTypes).max) + ) + ); + vm.assume(paymentType != IGraphPayments.PaymentTypes.IndexingFee); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidPaymentType.selector, + paymentType + ); + vm.expectRevert(expectedErr); + _recurringCollector.collect(paymentType, data); + } + + function test_Collect_Revert_WhenInvalidData(address caller, bytes memory data) public { + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidCollectData.selector, + data + ); + vm.expectRevert(expectedErr); + vm.prank(caller); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_Revert_WhenCallerNotDataService( + FuzzyTestCollect calldata fuzzy, + address notDataService + ) public { + vm.assume(fuzzy.fuzzyTestAccept.rca.dataService != notDataService); + + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; + + collectParams.agreementId = accepted.rca.agreementId; + bytes memory data = _generateCollectData(collectParams); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, + collectParams.agreementId, + notDataService + ); + vm.expectRevert(expectedErr); + vm.prank(notDataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_Revert_WhenUnknownAgreement(FuzzyTestCollect memory fuzzy, address dataService) public { + bytes memory data = _generateCollectData(fuzzy.collectParams); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + fuzzy.collectParams.agreementId, + IRecurringCollector.AgreementState.NotAccepted + ); + vm.expectRevert(expectedErr); + vm.prank(dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_Revert_WhenCanceledAgreementByServiceProvider(FuzzyTestCollect calldata fuzzy) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + _cancel(accepted.rca, IRecurringCollector.CancelAgreementBy.ServiceProvider); + IRecurringCollector.CollectParams memory collectData = fuzzy.collectParams; + collectData.tokens = bound(collectData.tokens, 1, type(uint256).max); + IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( + accepted.rca, + collectData.collectionId, + collectData.tokens, + collectData.dataServiceCut + ); + bytes memory data = _generateCollectData(collectParams); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + collectParams.agreementId, + IRecurringCollector.AgreementState.CanceledByServiceProvider + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_Revert_WhenCollectingTooSoon( + FuzzyTestCollect calldata fuzzy, + uint256 unboundedCollectionSeconds + ) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + skip(accepted.rca.minSecondsPerCollection); + bytes memory data = _generateCollectData( + _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + 1, + fuzzy.collectParams.dataServiceCut + ) + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + + uint256 collectionSeconds = boundSkip(unboundedCollectionSeconds, 1, accepted.rca.minSecondsPerCollection - 1); + skip(collectionSeconds); + + IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + bound(fuzzy.collectParams.tokens, 1, type(uint256).max), + fuzzy.collectParams.dataServiceCut + ); + data = _generateCollectData(collectParams); + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorCollectionTooSoon.selector, + collectParams.agreementId, + collectionSeconds, + accepted.rca.minSecondsPerCollection + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_Revert_WhenCollectingTooLate( + FuzzyTestCollect calldata fuzzy, + uint256 unboundedFirstCollectionSeconds, + uint256 unboundedSecondCollectionSeconds + ) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + // skip to collectable time + skip( + boundSkip( + unboundedFirstCollectionSeconds, + accepted.rca.minSecondsPerCollection, + accepted.rca.maxSecondsPerCollection + ) + ); + bytes memory data = _generateCollectData( + _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + 1, + fuzzy.collectParams.dataServiceCut + ) + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + + // skip beyond collectable time but still within the agreement endsAt + uint256 collectionSeconds = boundSkip( + unboundedSecondCollectionSeconds, + accepted.rca.maxSecondsPerCollection + 1, + accepted.rca.endsAt - block.timestamp + ); + skip(collectionSeconds); + + data = _generateCollectData( + _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + bound(fuzzy.collectParams.tokens, 1, type(uint256).max), + fuzzy.collectParams.dataServiceCut + ) + ); + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorCollectionTooLate.selector, + accepted.rca.agreementId, + collectionSeconds, + accepted.rca.maxSecondsPerCollection + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_OK_WhenCollectingTooMuch( + FuzzyTestCollect calldata fuzzy, + uint256 unboundedInitialCollectionSeconds, + uint256 unboundedCollectionSeconds, + uint256 unboundedTokens, + bool testInitialCollection + ) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + if (!testInitialCollection) { + // skip to collectable time + skip( + boundSkip( + unboundedInitialCollectionSeconds, + accepted.rca.minSecondsPerCollection, + accepted.rca.maxSecondsPerCollection + ) + ); + bytes memory initialData = _generateCollectData( + _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + 1, + fuzzy.collectParams.dataServiceCut + ) + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, initialData); + } + + // skip to collectable time + uint256 collectionSeconds = boundSkip( + unboundedCollectionSeconds, + accepted.rca.minSecondsPerCollection, + accepted.rca.maxSecondsPerCollection + ); + skip(collectionSeconds); + uint256 maxTokens = accepted.rca.maxOngoingTokensPerSecond * collectionSeconds; + maxTokens += testInitialCollection ? accepted.rca.maxInitialTokens : 0; + uint256 tokens = bound(unboundedTokens, maxTokens + 1, type(uint256).max); + IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( + accepted.rca, + fuzzy.collectParams.collectionId, + tokens, + fuzzy.collectParams.dataServiceCut + ); + bytes memory data = _generateCollectData(collectParams); + vm.prank(accepted.rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, maxTokens); + } + + function test_Collect_OK( + FuzzyTestCollect calldata fuzzy, + uint256 unboundedCollectionSeconds, + uint256 unboundedTokens + ) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + (bytes memory data, uint256 collectionSeconds, uint256 tokens) = _generateValidCollection( + accepted.rca, + fuzzy.collectParams, + unboundedCollectionSeconds, + unboundedTokens + ); + skip(collectionSeconds); + _expectCollectCallAndEmit(accepted.rca, fuzzy.collectParams, tokens); + vm.prank(accepted.rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + } + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol new file mode 100644 index 000000000..397925600 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; +import { IPaymentsCollector } from "../../../../contracts/interfaces/IPaymentsCollector.sol"; +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; +import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; + +import { Bounder } from "../../../unit/utils/Bounder.t.sol"; +import { RecurringCollectorControllerMock } from "./RecurringCollectorControllerMock.t.sol"; +import { PaymentsEscrowMock } from "./PaymentsEscrowMock.t.sol"; +import { RecurringCollectorHelper } from "./RecurringCollectorHelper.t.sol"; + +contract RecurringCollectorSharedTest is Test, Bounder { + struct FuzzyTestCollect { + FuzzyTestAccept fuzzyTestAccept; + IRecurringCollector.CollectParams collectParams; + } + + struct FuzzyTestAccept { + IRecurringCollector.RecurringCollectionAgreement rca; + uint256 unboundedSignerKey; + } + + struct FuzzyTestUpdate { + FuzzyTestAccept fuzzyTestAccept; + IRecurringCollector.RecurringCollectionAgreementUpdate rcau; + } + + RecurringCollector internal _recurringCollector; + PaymentsEscrowMock internal _paymentsEscrow; + RecurringCollectorHelper internal _recurringCollectorHelper; + + function setUp() public { + _paymentsEscrow = new PaymentsEscrowMock(); + _recurringCollector = new RecurringCollector( + "RecurringCollector", + "1", + address(new RecurringCollectorControllerMock(address(_paymentsEscrow))), + 1 + ); + _recurringCollectorHelper = new RecurringCollectorHelper(_recurringCollector); + } + + function _sensibleAuthorizeAndAccept( + FuzzyTestAccept calldata _fuzzyTestAccept + ) internal returns (IRecurringCollector.SignedRCA memory, uint256 key) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + _fuzzyTestAccept.rca + ); + key = boundKey(_fuzzyTestAccept.unboundedSignerKey); + return (_authorizeAndAccept(rca, key), key); + } + + // authorizes signer, signs the RCA, and accepts it + function _authorizeAndAccept( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + uint256 _signerKey + ) internal returns (IRecurringCollector.SignedRCA memory) { + _recurringCollectorHelper.authorizeSignerWithChecks(_rca.payer, _signerKey); + IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(_rca, _signerKey); + + _accept(signedRCA); + + return signedRCA; + } + + function _accept(IRecurringCollector.SignedRCA memory _signedRCA) internal { + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementAccepted( + _signedRCA.rca.dataService, + _signedRCA.rca.payer, + _signedRCA.rca.serviceProvider, + _signedRCA.rca.agreementId, + uint64(block.timestamp), + _signedRCA.rca.endsAt, + _signedRCA.rca.maxInitialTokens, + _signedRCA.rca.maxOngoingTokensPerSecond, + _signedRCA.rca.minSecondsPerCollection, + _signedRCA.rca.maxSecondsPerCollection + ); + vm.prank(_signedRCA.rca.dataService); + _recurringCollector.accept(_signedRCA); + } + + function _cancel( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + IRecurringCollector.CancelAgreementBy _by + ) internal { + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementCanceled( + _rca.dataService, + _rca.payer, + _rca.serviceProvider, + _rca.agreementId, + uint64(block.timestamp), + _by + ); + vm.prank(_rca.dataService); + _recurringCollector.cancel(_rca.agreementId, _by); + } + + function _expectCollectCallAndEmit( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + IRecurringCollector.CollectParams memory _fuzzyParams, + uint256 _tokens + ) internal { + vm.expectCall( + address(_paymentsEscrow), + abi.encodeCall( + _paymentsEscrow.collect, + ( + IGraphPayments.PaymentTypes.IndexingFee, + _rca.payer, + _rca.serviceProvider, + _tokens, + _rca.dataService, + _fuzzyParams.dataServiceCut, + _rca.serviceProvider + ) + ) + ); + vm.expectEmit(address(_recurringCollector)); + emit IPaymentsCollector.PaymentCollected( + IGraphPayments.PaymentTypes.IndexingFee, + _fuzzyParams.collectionId, + _rca.payer, + _rca.serviceProvider, + _rca.dataService, + _tokens + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.RCACollected( + _rca.dataService, + _rca.payer, + _rca.serviceProvider, + _rca.agreementId, + _fuzzyParams.collectionId, + _tokens, + _fuzzyParams.dataServiceCut + ); + } + + function _generateValidCollection( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + IRecurringCollector.CollectParams memory _fuzzyParams, + uint256 _unboundedCollectionSkip, + uint256 _unboundedTokens + ) internal view returns (bytes memory, uint256, uint256) { + uint256 collectionSeconds = boundSkip( + _unboundedCollectionSkip, + _rca.minSecondsPerCollection, + _rca.maxSecondsPerCollection + ); + uint256 tokens = bound(_unboundedTokens, 1, _rca.maxOngoingTokensPerSecond * collectionSeconds); + bytes memory data = _generateCollectData( + _generateCollectParams(_rca, _fuzzyParams.collectionId, tokens, _fuzzyParams.dataServiceCut) + ); + + return (data, collectionSeconds, tokens); + } + + function _generateCollectParams( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + bytes32 _collectionId, + uint256 _tokens, + uint256 _dataServiceCut + ) internal pure returns (IRecurringCollector.CollectParams memory) { + return + IRecurringCollector.CollectParams({ + agreementId: _rca.agreementId, + collectionId: _collectionId, + tokens: _tokens, + dataServiceCut: _dataServiceCut, + receiverDestination: _rca.serviceProvider + }); + } + + function _generateCollectData( + IRecurringCollector.CollectParams memory _params + ) internal pure returns (bytes memory) { + return abi.encode(_params); + } + + function _fuzzyCancelAgreementBy(uint8 _seed) internal pure returns (IRecurringCollector.CancelAgreementBy) { + return + IRecurringCollector.CancelAgreementBy( + bound(_seed, 0, uint256(IRecurringCollector.CancelAgreementBy.Payer)) + ); + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol new file mode 100644 index 000000000..4fd8af1e7 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_Update_Revert_WhenUpdateElapsed( + IRecurringCollector.RecurringCollectionAgreement memory rca, + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + uint256 unboundedUpdateSkip + ) public { + rca = _recurringCollectorHelper.sensibleRCA(rca); + rcau = _recurringCollectorHelper.sensibleRCAU(rcau); + rcau.agreementId = rca.agreementId; + + boundSkipCeil(unboundedUpdateSkip, type(uint64).max); + rcau.deadline = uint64(bound(rcau.deadline, 0, block.timestamp - 1)); + IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ + rcau: rcau, + signature: "" + }); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + rcau.deadline + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_Revert_WhenNeverAccepted( + IRecurringCollector.RecurringCollectionAgreement memory rca, + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau + ) public { + rca = _recurringCollectorHelper.sensibleRCA(rca); + rcau = _recurringCollectorHelper.sensibleRCAU(rcau); + rcau.agreementId = rca.agreementId; + + rcau.deadline = uint64(block.timestamp); + IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ + rcau: rcau, + signature: "" + }); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + rcau.agreementId, + IRecurringCollector.AgreementState.NotAccepted + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_Revert_WhenDataServiceNotAuthorized( + FuzzyTestUpdate calldata fuzzyTestUpdate, + address notDataService + ) public { + vm.assume(fuzzyTestUpdate.fuzzyTestAccept.rca.dataService != notDataService); + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = accepted.rca.agreementId; + + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + rcau, + signerKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, + signedRCAU.rcau.agreementId, + notDataService + ); + vm.expectRevert(expectedErr); + vm.prank(notDataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_Revert_WhenInvalidSigner( + FuzzyTestUpdate calldata fuzzyTestUpdate, + uint256 unboundedInvalidSignerKey + ) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + uint256 invalidSignerKey = boundKey(unboundedInvalidSignerKey); + vm.assume(signerKey != invalidSignerKey); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = accepted.rca.agreementId; + + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + rcau, + invalidSignerKey + ); + + vm.expectRevert(IRecurringCollector.RecurringCollectorInvalidSigner.selector); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_OK(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = accepted.rca.agreementId; + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + rcau, + signerKey + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementUpdated( + accepted.rca.dataService, + accepted.rca.payer, + accepted.rca.serviceProvider, + rcau.agreementId, + uint64(block.timestamp), + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(accepted.rca.agreementId); + assertEq(rcau.endsAt, agreement.endsAt); + assertEq(rcau.maxInitialTokens, agreement.maxInitialTokens); + assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); + assertEq(rcau.minSecondsPerCollection, agreement.minSecondsPerCollection); + assertEq(rcau.maxSecondsPerCollection, agreement.maxSecondsPerCollection); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/utilities/Authorizable.t.sol b/packages/horizon/test/unit/utilities/Authorizable.t.sol index 4528b339d..20ca7e2b9 100644 --- a/packages/horizon/test/unit/utilities/Authorizable.t.sol +++ b/packages/horizon/test/unit/utilities/Authorizable.t.sol @@ -14,23 +14,27 @@ contract AuthorizableImp is Authorizable { } contract AuthorizableTest is Test, Bounder { - AuthorizableImp public authorizable; + IAuthorizable public authorizable; AuthorizableHelper authHelper; modifier withFuzzyThaw(uint256 _thawPeriod) { // Max thaw period is 1 year to allow for thawing tests _thawPeriod = bound(_thawPeriod, 1, 60 * 60 * 24 * 365); - setupAuthorizable(new AuthorizableImp(_thawPeriod)); + setupAuthorizable(_thawPeriod); _; } - function setUp() public virtual { - setupAuthorizable(new AuthorizableImp(0)); + function setUp() public { + setupAuthorizable(0); } - function setupAuthorizable(AuthorizableImp _authorizable) internal { - authorizable = _authorizable; - authHelper = new AuthorizableHelper(authorizable); + function setupAuthorizable(uint256 _thawPeriod) internal { + authorizable = newAuthorizable(_thawPeriod); + authHelper = new AuthorizableHelper(authorizable, _thawPeriod); + } + + function newAuthorizable(uint256 _thawPeriod) public virtual returns (IAuthorizable) { + return new AuthorizableImp(_thawPeriod); } function test_AuthorizeSigner(uint256 _unboundedKey, address _authorizer) public { @@ -303,12 +307,12 @@ contract AuthorizableTest is Test, Bounder { authHelper.authorizeAndThawSignerWithChecks(_authorizer, signerKey); - _skip = bound(_skip, 0, authorizable.REVOKE_AUTHORIZATION_THAWING_PERIOD() - 1); + _skip = bound(_skip, 0, authHelper.revokeAuthorizationThawingPeriod() - 1); skip(_skip); bytes memory expectedErr = abi.encodeWithSelector( IAuthorizable.AuthorizableSignerStillThawing.selector, block.timestamp, - block.timestamp - _skip + authorizable.REVOKE_AUTHORIZATION_THAWING_PERIOD() + block.timestamp - _skip + authHelper.revokeAuthorizationThawingPeriod() ); vm.expectRevert(expectedErr); vm.prank(_authorizer); @@ -321,17 +325,19 @@ contract AuthorizableTest is Test, Bounder { } contract AuthorizableHelper is Test { - AuthorizableImp internal authorizable; + IAuthorizable internal authorizable; + uint256 public revokeAuthorizationThawingPeriod; - constructor(AuthorizableImp _authorizable) { + constructor(IAuthorizable _authorizable, uint256 _thawPeriod) { authorizable = _authorizable; + revokeAuthorizationThawingPeriod = _thawPeriod; } function authorizeAndThawSignerWithChecks(address _authorizer, uint256 _signerKey) public { address signer = vm.addr(_signerKey); authorizeSignerWithChecks(_authorizer, _signerKey); - uint256 thawEndTimestamp = block.timestamp + authorizable.REVOKE_AUTHORIZATION_THAWING_PERIOD(); + uint256 thawEndTimestamp = block.timestamp + revokeAuthorizationThawingPeriod; vm.expectEmit(address(authorizable)); emit IAuthorizable.SignerThawing(_authorizer, signer, thawEndTimestamp); vm.prank(_authorizer); @@ -343,7 +349,7 @@ contract AuthorizableHelper is Test { function authorizeAndRevokeSignerWithChecks(address _authorizer, uint256 _signerKey) public { address signer = vm.addr(_signerKey); authorizeAndThawSignerWithChecks(_authorizer, _signerKey); - skip(authorizable.REVOKE_AUTHORIZATION_THAWING_PERIOD() + 1); + skip(revokeAuthorizationThawingPeriod + 1); vm.expectEmit(address(authorizable)); emit IAuthorizable.SignerRevoked(_authorizer, signer); vm.prank(_authorizer); @@ -356,6 +362,7 @@ contract AuthorizableHelper is Test { address signer = vm.addr(_signerKey); assertNotAuthorized(_authorizer, signer); + require(block.timestamp < type(uint256).max, "Test cannot be run at the end of time"); uint256 proofDeadline = block.timestamp + 1; bytes memory proof = generateAuthorizationProof( block.chainid, diff --git a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol index bf40a35b8..8e06d2875 100644 --- a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol +++ b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol @@ -22,6 +22,7 @@ contract GraphDirectoryImplementation is GraphDirectory { function getContractFromController(bytes memory contractName) external view returns (address) { return _graphController().getContractProxy(keccak256(contractName)); } + function graphToken() external view returns (IGraphToken) { return _graphToken(); } diff --git a/packages/horizon/test/unit/utils/Bounder.t.sol b/packages/horizon/test/unit/utils/Bounder.t.sol index 44e977f57..9b95a3425 100644 --- a/packages/horizon/test/unit/utils/Bounder.t.sol +++ b/packages/horizon/test/unit/utils/Bounder.t.sol @@ -6,18 +6,22 @@ import { Test } from "forge-std/Test.sol"; contract Bounder is Test { uint256 constant SECP256K1_CURVE_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141; + function boundKeyAndAddr(uint256 _value) internal pure returns (uint256, address) { + uint256 key = bound(_value, 1, SECP256K1_CURVE_ORDER - 1); + return (key, vm.addr(key)); + } + function boundAddrAndKey(uint256 _value) internal pure returns (uint256, address) { - uint256 signerKey = bound(_value, 1, SECP256K1_CURVE_ORDER - 1); - return (signerKey, vm.addr(signerKey)); + return boundKeyAndAddr(_value); } function boundAddr(uint256 _value) internal pure returns (address) { - (, address addr) = boundAddrAndKey(_value); + (, address addr) = boundKeyAndAddr(_value); return addr; } function boundKey(uint256 _value) internal pure returns (uint256) { - (uint256 key, ) = boundAddrAndKey(_value); + (uint256 key, ) = boundKeyAndAddr(_value); return key; } @@ -28,4 +32,21 @@ contract Bounder is Test { function boundTimestampMin(uint256 _value, uint256 _min) internal pure returns (uint256) { return bound(_value, _min, type(uint256).max); } + + function boundSkipFloor(uint256 _value, uint256 _min) internal view returns (uint256) { + return boundSkip(_value, _min, type(uint256).max); + } + + function boundSkipCeil(uint256 _value, uint256 _max) internal view returns (uint256) { + return boundSkip(_value, 0, _max); + } + + function boundSkip(uint256 _value, uint256 _min, uint256 _max) internal view returns (uint256) { + return bound(_value, orTillEndOfTime(_min), orTillEndOfTime(_max)); + } + + function orTillEndOfTime(uint256 _value) internal view returns (uint256) { + uint256 tillEndOfTime = type(uint256).max - block.timestamp; + return _value < tillEndOfTime ? _value : tillEndOfTime; + } } diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 573e8f67e..e509f1410 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -11,6 +11,7 @@ import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol" import { MathUtils } from "@graphprotocol/horizon/contracts/libraries/MathUtils.sol"; import { Allocation } from "./libraries/Allocation.sol"; import { Attestation } from "./libraries/Attestation.sol"; +import { IndexingAgreement } from "./libraries/IndexingAgreement.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; @@ -132,6 +133,20 @@ contract DisputeManager is return _createIndexingDisputeWithAllocation(msg.sender, disputeDeposit, allocationId, poi, blockNumber); } + /// @inheritdoc IDisputeManager + function createIndexingFeeDisputeV1( + bytes16 agreementId, + bytes32 poi, + uint256 entities, + uint256 blockNumber + ) external override returns (bytes32) { + // Get funds from fisherman + _graphToken().pullTokens(msg.sender, disputeDeposit); + + // Create a dispute + return _createIndexingFeeDisputeV1(msg.sender, disputeDeposit, agreementId, poi, entities, blockNumber); + } + /// @inheritdoc IDisputeManager function createQueryDispute(bytes calldata attestationData) external override returns (bytes32) { // Get funds from fisherman @@ -501,6 +516,75 @@ contract DisputeManager is return disputeId; } + /** + * @notice Create indexing fee (version 1) dispute internal function. + * @param _fisherman The fisherman creating the dispute + * @param _deposit Amount of tokens staked as deposit + * @param _agreementId The agreement id being disputed + * @param _poi The POI being disputed + * @param _entities The number of entities disputed + * @param _blockNumber The block number of the disputed POI + * @return The dispute id + */ + function _createIndexingFeeDisputeV1( + address _fisherman, + uint256 _deposit, + bytes16 _agreementId, + bytes32 _poi, + uint256 _entities, + uint256 _blockNumber + ) private returns (bytes32) { + IndexingAgreement.AgreementWrapper memory wrapper = _getSubgraphService().getIndexingAgreement(_agreementId); + + // Agreement must have been collected on and be a version 1 + require( + wrapper.collectorAgreement.lastCollectionAt > 0, + DisputeManagerIndexingAgreementNotDisputable(_agreementId) + ); + require( + wrapper.agreement.version == IndexingAgreement.IndexingAgreementVersion.V1, + DisputeManagerIndexingAgreementInvalidVersion(wrapper.agreement.version) + ); + + // Create a disputeId + bytes32 disputeId = keccak256( + abi.encodePacked("IndexingFeeDisputeWithAgreement", _agreementId, _poi, _entities, _blockNumber) + ); + + // Only one dispute at a time + require(!isDisputeCreated(disputeId), DisputeManagerDisputeAlreadyCreated(disputeId)); + + // The indexer must be disputable + uint256 stakeSnapshot = _getStakeSnapshot(wrapper.collectorAgreement.serviceProvider); + require(stakeSnapshot != 0, DisputeManagerZeroTokens()); + + disputes[disputeId] = Dispute( + wrapper.collectorAgreement.serviceProvider, + _fisherman, + _deposit, + 0, // no related dispute, + DisputeType.IndexingFeeDispute, + IDisputeManager.DisputeStatus.Pending, + block.timestamp, + block.timestamp + disputePeriod, + stakeSnapshot + ); + + emit IndexingFeeDisputeCreated( + disputeId, + wrapper.collectorAgreement.serviceProvider, + _fisherman, + _deposit, + wrapper.collectorAgreement.payer, + _agreementId, + _poi, + _entities, + stakeSnapshot + ); + + return disputeId; + } + /** * @notice Accept a dispute * @param _disputeId The id of the dispute diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 140ab9c34..919c1d7ed 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -7,6 +7,7 @@ import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interface import { IRewardsIssuer } from "@graphprotocol/contracts/contracts/rewards/IRewardsIssuer.sol"; import { IDataService } from "@graphprotocol/horizon/contracts/data-service/interfaces/IDataService.sol"; import { ISubgraphService } from "./interfaces/ISubgraphService.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { MulticallUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; @@ -22,6 +23,8 @@ import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils. import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; import { Allocation } from "./libraries/Allocation.sol"; import { LegacyAllocation } from "./libraries/LegacyAllocation.sol"; +import { IndexingAgreementDecoder } from "./libraries/IndexingAgreementDecoder.sol"; +import { IndexingAgreement } from "./libraries/IndexingAgreement.sol"; /** * @title SubgraphService contract @@ -45,13 +48,14 @@ contract SubgraphService is using Allocation for mapping(address => Allocation.State); using Allocation for Allocation.State; using TokenUtils for IGraphToken; + using IndexingAgreement for IndexingAgreement.StorageManager; /** * @notice Checks that an indexer is registered * @param indexer The address of the indexer */ modifier onlyRegisteredIndexer(address indexer) { - require(indexers[indexer].registeredAt != 0, SubgraphServiceIndexerNotRegistered(indexer)); + _requireRegisteredIndexer(indexer); _; } @@ -62,13 +66,18 @@ contract SubgraphService is * @param disputeManager The address of the DisputeManager contract * @param graphTallyCollector The address of the GraphTallyCollector contract * @param curation The address of the Curation contract + * @param recurringCollector The address of the RecurringCollector contract */ constructor( address graphController, address disputeManager, address graphTallyCollector, - address curation - ) DataService(graphController) Directory(address(this), disputeManager, graphTallyCollector, curation) { + address curation, + address recurringCollector + ) + DataService(graphController) + Directory(address(this), disputeManager, graphTallyCollector, curation, recurringCollector) + { _disableInitializers(); } @@ -226,13 +235,14 @@ contract SubgraphService is _allocations.get(allocationId).indexer == indexer, SubgraphServiceAllocationNotAuthorized(indexer, allocationId) ); + _onCloseAllocation(allocationId, false); _closeAllocation(allocationId, false); emit ServiceStopped(indexer, data); } /** * @notice Collects payment for the service provided by the indexer - * Allows collecting different types of payments such as query fees and indexing rewards. + * Allows collecting different types of payments such as query fees, indexing rewards and indexing fees. * It uses Graph Horizon payments protocol to process payments. * Reverts if the payment type is not supported. * @dev This function is the equivalent of the `collect` function for query fees and the `closeAllocation` function @@ -246,6 +256,12 @@ contract SubgraphService is * * For query fees, see {SubgraphService-_collectQueryFees} for more details. * For indexing rewards, see {AllocationManager-_collectIndexingRewards} for more details. + * For indexing fees, see {SubgraphService-_collectIndexingFees} for more details. + * + * Note that collecting any type of payment will require locking provisioned stake as collateral for a period of time. + * All types of payment share the same pool of provisioned stake however they each have separate accounting: + * - Indexing rewards can make full use of the available stake + * - Query and indexing fees share the pool, combined they can also make full use of the available stake * * @param indexer The address of the indexer * @param paymentType The type of payment to collect as defined in {IGraphPayments} @@ -256,6 +272,9 @@ contract SubgraphService is * - address `allocationId`: The id of the allocation * - bytes32 `poi`: The POI being presented * - bytes `poiMetadata`: The metadata associated with the POI. See {AllocationManager-_collectIndexingRewards} for more details. + * - For indexing fees: + * - bytes16 `agreementId`: The id of the indexing agreement + * - bytes `agreementCollectionMetadata`: The metadata required by the indexing agreement version. */ /// @inheritdoc IDataService function collect( @@ -265,10 +284,10 @@ contract SubgraphService is ) external override + whenNotPaused onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) onlyRegisteredIndexer(indexer) - whenNotPaused returns (uint256) { uint256 paymentCollected = 0; @@ -277,6 +296,9 @@ contract SubgraphService is paymentCollected = _collectQueryFees(indexer, data); } else if (paymentType == IGraphPayments.PaymentTypes.IndexingRewards) { paymentCollected = _collectIndexingRewards(indexer, data); + } else if (paymentType == IGraphPayments.PaymentTypes.IndexingFee) { + (bytes16 agreementId, bytes memory iaCollectionData) = IndexingAgreementDecoder.decodeCollectData(data); + paymentCollected = _collectIndexingFees(agreementId, paymentsDestination[indexer], iaCollectionData); } else { revert SubgraphServiceInvalidPaymentType(paymentType); } @@ -302,6 +324,7 @@ contract SubgraphService is Allocation.State memory allocation = _allocations.get(allocationId); require(allocation.isStale(maxPOIStaleness), SubgraphServiceCannotForceCloseAllocation(allocationId)); require(!allocation.isAltruistic(), SubgraphServiceAllocationIsAltruistic(allocationId)); + _onCloseAllocation(allocationId, true); _closeAllocation(allocationId, true); } @@ -370,6 +393,121 @@ contract SubgraphService is emit CurationCutSet(curationCut); } + /** + * @inheritdoc ISubgraphService + * @notice Accept an indexing agreement. + * + * See {ISubgraphService.acceptIndexingAgreement}. + * + * Requirements: + * - The agreement's indexer must be registered + * - The caller must be authorized by the agreement's indexer + * - The provision must be valid according to the subgraph service rules + * - Allocation must belong to the indexer and be open + * - Agreement must be for this data service + * - Agreement's subgraph deployment must match the allocation's subgraph deployment + * - Agreement must not have been accepted before + * - Allocation must not have an agreement already + * + * @dev signedRCA.rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata} + * + * Emits {IndexingAgreement.IndexingAgreementAccepted} event + * + * @param allocationId The id of the allocation + * @param signedRCA The signed Recurring Collection Agreement + */ + function acceptIndexingAgreement( + address allocationId, + IRecurringCollector.SignedRCA calldata signedRCA + ) + external + whenNotPaused + onlyAuthorizedForProvision(signedRCA.rca.serviceProvider) + onlyValidProvision(signedRCA.rca.serviceProvider) + onlyRegisteredIndexer(signedRCA.rca.serviceProvider) + { + IndexingAgreement._getStorageManager().accept(_allocations, allocationId, signedRCA); + } + + /** + * @inheritdoc ISubgraphService + * @notice Update an indexing agreement. + * + * See {IndexingAgreement.update}. + * + * Requirements: + * - The contract must not be paused + * - The indexer must be valid + * + * @param indexer The indexer address + * @param signedRCAU The signed Recurring Collection Agreement Update + */ + function updateIndexingAgreement( + address indexer, + IRecurringCollector.SignedRCAU calldata signedRCAU + ) + external + whenNotPaused + onlyAuthorizedForProvision(indexer) + onlyValidProvision(indexer) + onlyRegisteredIndexer(indexer) + { + IndexingAgreement._getStorageManager().update(indexer, signedRCAU); + } + + /** + * @inheritdoc ISubgraphService + * @notice Cancel an indexing agreement by indexer / operator. + * + * See {IndexingAgreement.cancel}. + * + * @dev Can only be canceled on behalf of a valid indexer. + * + * Requirements: + * - The contract must not be paused + * - The indexer must be valid + * + * @param indexer The indexer address + * @param agreementId The id of the agreement + */ + function cancelIndexingAgreement( + address indexer, + bytes16 agreementId + ) + external + whenNotPaused + onlyAuthorizedForProvision(indexer) + onlyValidProvision(indexer) + onlyRegisteredIndexer(indexer) + { + IndexingAgreement._getStorageManager().cancel(indexer, agreementId); + } + + /** + * @inheritdoc ISubgraphService + * @notice Cancel an indexing agreement by payer / signer. + * + * See {ISubgraphService.cancelIndexingAgreementByPayer}. + * + * Requirements: + * - The caller must be authorized by the payer + * - The agreement must be active + * + * Emits {IndexingAgreementCanceled} event + * + * @param agreementId The id of the agreement + */ + function cancelIndexingAgreementByPayer(bytes16 agreementId) external whenNotPaused { + IndexingAgreement._getStorageManager().cancelByPayer(agreementId); + } + + /// @inheritdoc ISubgraphService + function getIndexingAgreement( + bytes16 agreementId + ) external view returns (IndexingAgreement.AgreementWrapper memory) { + return IndexingAgreement._getStorageManager().get(agreementId); + } + /// @inheritdoc ISubgraphService function getAllocation(address allocationId) external view override returns (Allocation.State memory) { return _allocations[allocationId]; @@ -425,6 +563,16 @@ contract SubgraphService is return _isOverAllocated(indexer, _delegationRatio); } + /** + * @notice Internal function to handle closing an allocation + * @dev This function is called when an allocation is closed, either by the indexer or by a third party + * @param _allocationId The id of the allocation being closed + * @param _stale Whether the allocation is stale or not + */ + function _onCloseAllocation(address _allocationId, bool _stale) internal { + IndexingAgreement._getStorageManager().onCloseAllocation(_allocationId, _stale); + } + /** * @notice Sets the payments destination for an indexer to receive payments * @dev Emits a {PaymentsDestinationSet} event @@ -436,6 +584,14 @@ contract SubgraphService is emit PaymentsDestinationSet(_indexer, _paymentsDestination); } + /** + * @notice Requires that the indexer is registered + * @param _indexer The address of the indexer + */ + function _requireRegisteredIndexer(address _indexer) internal view { + require(indexers[_indexer].registeredAt != 0, SubgraphServiceIndexerNotRegistered(_indexer)); + } + // -- Data service parameter getters -- /** * @notice Getter for the accepted thawing period range for provisions @@ -578,6 +734,59 @@ contract SubgraphService is return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[_indexer]); } + /** + * @notice Collect Indexing fees + * Stake equal to the amount being collected times the `stakeToFeesRatio` is locked into a stake claim. + * This claim can be released at a later stage once expired. + * + * It's important to note that before collecting this function will attempt to release any expired stake claims. + * This could lead to an out of gas error if there are too many expired claims. In that case, the indexer will need to + * manually release the claims, see {IDataServiceFees-releaseStake}, before attempting to collect again. + * + * @dev Uses the {RecurringCollector} to collect payment from Graph Horizon payments protocol. + * Fees are distributed to service provider and delegators by {GraphPayments} + * + * Requirements: + * - Indexer must have enough available tokens to lock as economic security for fees + * - Allocation must be open + * + * Emits a {StakeClaimsReleased} event, and a {StakeClaimReleased} event for each claim released. + * Emits a {StakeClaimLocked} event. + * Emits a {IndexingFeesCollectedV1} event. + * + * @param _agreementId The id of the indexing agreement + * @param _paymentsDestination The address where the fees should be sent + * @param _data The indexing agreement collection data + * @return The amount of fees collected + */ + function _collectIndexingFees( + bytes16 _agreementId, + address _paymentsDestination, + bytes memory _data + ) private returns (uint256) { + (address indexer, uint256 tokensCollected) = IndexingAgreement._getStorageManager().collect( + _allocations, + IndexingAgreement.CollectParams({ + agreementId: _agreementId, + currentEpoch: _graphEpochManager().currentEpoch(), + receiverDestination: _paymentsDestination, + data: _data + }) + ); + + _releaseStake(indexer, 0); + if (tokensCollected > 0) { + // lock stake as economic security for fees + _lockStake( + indexer, + tokensCollected * stakeToFeesRatio, + block.timestamp + _disputeManager().getDisputePeriod() + ); + } + + return tokensCollected; + } + /** * @notice Set the stake to fees ratio. * @param _stakeToFeesRatio The stake to fees ratio diff --git a/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol b/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol index 217b1c154..5133b38a0 100644 --- a/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol +++ b/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol @@ -3,6 +3,7 @@ pragma solidity 0.8.27; import { Attestation } from "../libraries/Attestation.sol"; +import { IndexingAgreement } from "../libraries/IndexingAgreement.sol"; /** * @title IDisputeManager @@ -16,7 +17,8 @@ interface IDisputeManager { Null, IndexingDispute, QueryDispute, - LegacyDispute + LegacyDispute, + IndexingFeeDispute } /// @notice Status of a dispute @@ -113,6 +115,32 @@ interface IDisputeManager { uint256 cancellableAt ); + /** + * @dev Emitted when an indexing fee dispute is created for `agreementId` and `indexer` + * by `fisherman`. + * The event emits the amount of `tokens` deposited by the fisherman. + * @param disputeId The dispute id + * @param indexer The indexer address + * @param fisherman The fisherman address + * @param tokens The amount of tokens deposited by the fisherman + * @param payer The address of the payer of the indexing fee + * @param agreementId The agreement id + * @param poi The POI disputed + * @param entities The entities disputed + * @param stakeSnapshot The stake snapshot of the indexer at the time of the dispute + */ + event IndexingFeeDisputeCreated( + bytes32 indexed disputeId, + address indexed indexer, + address indexed fisherman, + uint256 tokens, + address payer, + bytes16 agreementId, + bytes32 poi, + uint256 entities, + uint256 stakeSnapshot + ); + /** * @dev Emitted when an indexing dispute is created for `allocationId` and `indexer` * by `fisherman`. @@ -352,6 +380,18 @@ interface IDisputeManager { */ error DisputeManagerSubgraphServiceNotSet(); + /** + * @notice Thrown when the Indexing Agreement is not disputable + * @param agreementId The indexing agreement id + */ + error DisputeManagerIndexingAgreementNotDisputable(bytes16 agreementId); + + /** + * @notice Thrown when the Indexing Agreement is not disputable + * @param version The indexing agreement version + */ + error DisputeManagerIndexingAgreementInvalidVersion(IndexingAgreement.IndexingAgreementVersion version); + /** * @notice Initialize this contract. * @param owner The owner of the contract @@ -498,6 +538,29 @@ interface IDisputeManager { uint256 tokensRewards ) external returns (bytes32); + /** + * @notice Create an indexing fee (version 1) dispute for the arbitrator to resolve. + * The disputes are created in reference to a version 1 indexing agreement and specifically + * a POI and entities provided when collecting that agreement. + * This function is called by a fisherman and it will pull `disputeDeposit` GRT tokens. + * + * Requirements: + * - fisherman must have previously approved this contract to pull `disputeDeposit` amount + * of tokens from their balance. + * + * @param agreementId The indexing agreement to dispute + * @param poi The Proof of Indexing (POI) being disputed + * @param entities The number of entities disputed + * @param blockNumber The block number at which the indexing fee was collected + * @return The dispute id + */ + function createIndexingFeeDisputeV1( + bytes16 agreementId, + bytes32 poi, + uint256 entities, + uint256 blockNumber + ) external returns (bytes32); + // -- Arbitrator -- /** diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index 5c35296f2..2a852ffce 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -3,7 +3,9 @@ pragma solidity 0.8.27; import { IDataServiceFees } from "@graphprotocol/horizon/contracts/data-service/interfaces/IDataServiceFees.sol"; import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { IndexingAgreement } from "../libraries/IndexingAgreement.sol"; import { Allocation } from "../libraries/Allocation.sol"; import { LegacyAllocation } from "../libraries/LegacyAllocation.sol"; @@ -108,7 +110,7 @@ interface ISubgraphService is IDataServiceFees { error SubgraphServiceInconsistentCollection(uint256 balanceBefore, uint256 balanceAfter); /** - * @notice @notice Thrown when the service provider in the RAV does not match the expected indexer. + * @notice @notice Thrown when the service provider does not match the expected indexer. * @param providedIndexer The address of the provided indexer. * @param expectedIndexer The address of the expected indexer. */ @@ -257,6 +259,42 @@ interface ISubgraphService is IDataServiceFees { */ function setPaymentsDestination(address paymentsDestination) external; + /** + * @notice Accept an indexing agreement. + * @param allocationId The id of the allocation + * @param signedRCA The signed recurring collector agreement (RCA) that the indexer accepts + */ + function acceptIndexingAgreement(address allocationId, IRecurringCollector.SignedRCA calldata signedRCA) external; + + /** + * @notice Update an indexing agreement. + * @param indexer The address of the indexer + * @param signedRCAU The signed recurring collector agreement update (RCAU) that the indexer accepts + */ + function updateIndexingAgreement(address indexer, IRecurringCollector.SignedRCAU calldata signedRCAU) external; + + /** + * @notice Cancel an indexing agreement by indexer / operator. + * @param indexer The address of the indexer + * @param agreementId The id of the indexing agreement + */ + function cancelIndexingAgreement(address indexer, bytes16 agreementId) external; + + /** + * @notice Cancel an indexing agreement by payer / signer. + * @param agreementId The id of the indexing agreement + */ + function cancelIndexingAgreementByPayer(bytes16 agreementId) external; + + /** + * @notice Get the indexing agreement for a given agreement ID. + * @param agreementId The id of the indexing agreement + * @return The indexing agreement details + */ + function getIndexingAgreement( + bytes16 agreementId + ) external view returns (IndexingAgreement.AgreementWrapper memory); + /** * @notice Gets the details of an allocation * For legacy allocations use {getLegacyAllocation} diff --git a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol new file mode 100644 index 000000000..394430cad --- /dev/null +++ b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol @@ -0,0 +1,597 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { IEpochManager } from "@graphprotocol/contracts/contracts/epochs/IEpochManager.sol"; +import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToken.sol"; +import { IRewardsManager } from "@graphprotocol/contracts/contracts/rewards/IRewardsManager.sol"; +import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol"; +import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interfaces/internal/IHorizonStakingTypes.sol"; +import { IHorizonStaking } from "@graphprotocol/horizon/contracts/interfaces/IHorizonStaking.sol"; +import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; +import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol"; +import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; + +import { Allocation } from "../libraries/Allocation.sol"; +import { LegacyAllocation } from "../libraries/LegacyAllocation.sol"; + +/** + * @title AllocationHandler contract + * @notice A helper contract implementing allocation lifecycle management. + * Allows opening, resizing, and closing allocations, as well as collecting indexing rewards by presenting a Proof + * of Indexing (POI). + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +library AllocationHandler { + using ProvisionTracker for mapping(address => uint256); + using Allocation for mapping(address => Allocation.State); + using Allocation for Allocation.State; + using LegacyAllocation for mapping(address => LegacyAllocation.State); + using PPMMath for uint256; + using TokenUtils for IGraphToken; + + /** + * @notice Parameters for the allocation creation + * @param currentEpoch The current epoch at the time of allocation creation + * @param graphStaking The Horizon staking contract to handle token locking + * @param graphRewardsManager The rewards manager to handle rewards distribution + * @param _encodeAllocationProof The EIP712 encoded allocation proof + * @param _indexer The address of the indexer creating the allocation + * @param _allocationId The id of the allocation to be created + * @param _subgraphDeploymentId The id of the subgraph deployment for which the allocation is created + * @param _tokens The amount of tokens to allocate + * @param _allocationProof The EIP712 proof, an EIP712 signed message of (indexer,allocationId) + * @param _delegationRatio The delegation ratio to consider when locking tokens + */ + struct AllocateParams { + uint256 currentEpoch; + IHorizonStaking graphStaking; + IRewardsManager graphRewardsManager; + bytes32 _encodeAllocationProof; + address _indexer; + address _allocationId; + bytes32 _subgraphDeploymentId; + uint256 _tokens; + bytes _allocationProof; + uint32 _delegationRatio; + } + + /** + * @notice Parameters for the POI presentation + * @param maxPOIStaleness The maximum staleness of the POI in epochs + * @param graphEpochManager The epoch manager to get the current epoch + * @param graphStaking The Horizon staking contract to handle token locking + * @param graphRewardsManager The rewards manager to handle rewards distribution + * @param graphToken The Graph token contract to handle token transfers + * @param _allocationId The id of the allocation for which the POI is presented + * @param _poi The proof of indexing (POI) to be presented + * @param _poiMetadata The metadata associated with the POI + * @param _delegationRatio The delegation ratio to consider when locking tokens + * @param _paymentsDestination The address to which the indexing rewards should be sent + */ + struct PresentParams { + uint256 maxPOIStaleness; + IEpochManager graphEpochManager; + IHorizonStaking graphStaking; + IRewardsManager graphRewardsManager; + IGraphToken graphToken; + address dataService; + address _allocationId; + bytes32 _poi; + bytes _poiMetadata; + uint32 _delegationRatio; + address _paymentsDestination; + } + + /** + * @notice Emitted when an indexer creates an allocation + * @param indexer The address of the indexer + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param tokens The amount of tokens allocated + * @param currentEpoch The current epoch + */ + event AllocationCreated( + address indexed indexer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId, + uint256 tokens, + uint256 currentEpoch + ); + + /** + * @notice Emitted when an indexer collects indexing rewards for an allocation + * @param indexer The address of the indexer + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param tokensRewards The amount of tokens collected + * @param tokensIndexerRewards The amount of tokens collected for the indexer + * @param tokensDelegationRewards The amount of tokens collected for delegators + * @param poi The POI presented + * @param currentEpoch The current epoch + * @param poiMetadata The metadata associated with the POI + */ + event IndexingRewardsCollected( + address indexed indexer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId, + uint256 tokensRewards, + uint256 tokensIndexerRewards, + uint256 tokensDelegationRewards, + bytes32 poi, + bytes poiMetadata, + uint256 currentEpoch + ); + + /** + * @notice Emitted when an indexer resizes an allocation + * @param indexer The address of the indexer + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param newTokens The new amount of tokens allocated + * @param oldTokens The old amount of tokens allocated + */ + event AllocationResized( + address indexed indexer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId, + uint256 newTokens, + uint256 oldTokens + ); + + /** + * @dev Emitted when an indexer closes an allocation + * @param indexer The address of the indexer + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param tokens The amount of tokens allocated + * @param forceClosed Whether the allocation was force closed + */ + event AllocationClosed( + address indexed indexer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId, + uint256 tokens, + bool forceClosed + ); + + /** + * @notice Emitted when a legacy allocation is migrated into the subgraph service + * @param indexer The address of the indexer + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + */ + event LegacyAllocationMigrated( + address indexed indexer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId + ); + + /** + * @notice Emitted when the maximum POI staleness is updated + * @param maxPOIStaleness The max POI staleness in seconds + */ + event MaxPOIStalenessSet(uint256 maxPOIStaleness); + + /** + * @notice Thrown when an allocation proof is invalid + * Both `signer` and `allocationId` should match for a valid proof. + * @param signer The address that signed the proof + * @param allocationId The id of the allocation + */ + error AllocationHandlerInvalidAllocationProof(address signer, address allocationId); + + /** + * @notice Thrown when attempting to create an allocation with a zero allocation id + */ + error AllocationHandlerInvalidZeroAllocationId(); + + /** + * @notice Thrown when attempting to collect indexing rewards on a closed allocationl + * @param allocationId The id of the allocation + */ + error AllocationHandlerAllocationClosed(address allocationId); + + /** + * @notice Thrown when attempting to resize an allocation with the same size + * @param allocationId The id of the allocation + * @param tokens The amount of tokens + */ + error AllocationHandlerAllocationSameSize(address allocationId, uint256 tokens); + + /** + * @notice Create an allocation + * @dev The `_allocationProof` is a 65-bytes Ethereum signed message of `keccak256(indexerAddress,allocationId)` + * + * Requirements: + * - `_allocationId` must not be the zero address + * + * Emits a {AllocationCreated} event + * + * @param _allocations The mapping of allocation ids to allocation states + * @param _legacyAllocations The mapping of legacy allocation ids to legacy allocation states + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens + * @param params The parameters for the allocation + */ + function allocate( + mapping(address allocationId => Allocation.State allocation) storage _allocations, + mapping(address allocationId => LegacyAllocation.State allocation) storage _legacyAllocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + AllocateParams memory params + ) external { + require(params._allocationId != address(0), AllocationHandler.AllocationHandlerInvalidZeroAllocationId()); + + _verifyAllocationProof(params._encodeAllocationProof, params._allocationId, params._allocationProof); + + // Ensure allocation id is not reused + // need to check both subgraph service (on allocations.create()) and legacy allocations + _legacyAllocations.revertIfExists(params.graphStaking, params._allocationId); + + Allocation.State memory allocation = _allocations.create( + params._indexer, + params._allocationId, + params._subgraphDeploymentId, + params._tokens, + params.graphRewardsManager.onSubgraphAllocationUpdate(params._subgraphDeploymentId), + params.currentEpoch + ); + + // Check that the indexer has enough tokens available + // Note that the delegation ratio ensures overdelegation cannot be used + allocationProvisionTracker.lock(params.graphStaking, params._indexer, params._tokens, params._delegationRatio); + + // Update total allocated tokens for the subgraph deployment + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] = + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] + + allocation.tokens; + + emit AllocationHandler.AllocationCreated( + params._indexer, + params._allocationId, + params._subgraphDeploymentId, + allocation.tokens, + params.currentEpoch + ); + } + + /** + * @notice Present a POI to collect indexing rewards for an allocation + * This function will mint indexing rewards using the {RewardsManager} and distribute them to the indexer and delegators. + * + * Conditions to qualify for indexing rewards: + * - POI must be non-zero + * - POI must not be stale, i.e: older than `maxPOIStaleness` + * - allocation must not be altruistic (allocated tokens = 0) + * - allocation must be open for at least one epoch + * + * Note that indexers are required to periodically (at most every `maxPOIStaleness`) present POIs to collect rewards. + * Rewards will not be issued to stale POIs, which means that indexers are advised to present a zero POI if they are + * unable to present a valid one to prevent being locked out of future rewards. + * + * Note on allocation duration restriction: this is required to ensure that non protocol chains have a valid block number for + * which to calculate POIs. EBO posts once per epoch typically at each epoch change, so we restrict rewards to allocations + * that have gone through at least one epoch change. + * + * Emits a {IndexingRewardsCollected} event. + * + * @param _allocations The mapping of allocation ids to allocation states + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens + * @param params The parameters for the POI presentation + * @return The amount of tokens collected + */ + function presentPOI( + mapping(address allocationId => Allocation.State allocation) storage _allocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + PresentParams memory params + ) external returns (uint256) { + Allocation.State memory allocation = _allocations.get(params._allocationId); + require(allocation.isOpen(), AllocationHandler.AllocationHandlerAllocationClosed(params._allocationId)); + + // Mint indexing rewards if all conditions are met + uint256 tokensRewards = (!allocation.isStale(params.maxPOIStaleness) && + !allocation.isAltruistic() && + params._poi != bytes32(0)) && params.graphEpochManager.currentEpoch() > allocation.createdAtEpoch + ? params.graphRewardsManager.takeRewards(params._allocationId) + : 0; + + // ... but we still take a snapshot to ensure the rewards are not accumulated for the next valid POI + _allocations.snapshotRewards( + params._allocationId, + params.graphRewardsManager.onSubgraphAllocationUpdate(allocation.subgraphDeploymentId) + ); + _allocations.presentPOI(params._allocationId); + + // Any pending rewards should have been collected now + _allocations.clearPendingRewards(params._allocationId); + + uint256 tokensIndexerRewards = 0; + uint256 tokensDelegationRewards = 0; + if (tokensRewards != 0) { + // Distribute rewards to delegators + uint256 delegatorCut = params.graphStaking.getDelegationFeeCut( + allocation.indexer, + params.dataService, + IGraphPayments.PaymentTypes.IndexingRewards + ); + IHorizonStakingTypes.DelegationPool memory delegationPool = params.graphStaking.getDelegationPool( + allocation.indexer, + params.dataService + ); + // If delegation pool has no shares then we don't need to distribute rewards to delegators + tokensDelegationRewards = delegationPool.shares > 0 ? tokensRewards.mulPPM(delegatorCut) : 0; + if (tokensDelegationRewards > 0) { + params.graphToken.approve(address(params.graphStaking), tokensDelegationRewards); + params.graphStaking.addToDelegationPool( + allocation.indexer, + params.dataService, + tokensDelegationRewards + ); + } + + // Distribute rewards to indexer + tokensIndexerRewards = tokensRewards - tokensDelegationRewards; + if (tokensIndexerRewards > 0) { + if (params._paymentsDestination == address(0)) { + params.graphToken.approve(address(params.graphStaking), tokensIndexerRewards); + params.graphStaking.stakeToProvision(allocation.indexer, params.dataService, tokensIndexerRewards); + } else { + params.graphToken.pushTokens(params._paymentsDestination, tokensIndexerRewards); + } + } + } + + emit AllocationHandler.IndexingRewardsCollected( + allocation.indexer, + params._allocationId, + allocation.subgraphDeploymentId, + tokensRewards, + tokensIndexerRewards, + tokensDelegationRewards, + params._poi, + params._poiMetadata, + params.graphEpochManager.currentEpoch() + ); + + // Check if the indexer is over-allocated and force close the allocation if necessary + if ( + _isOverAllocated( + allocationProvisionTracker, + params.graphStaking, + allocation.indexer, + params._delegationRatio + ) + ) { + _closeAllocation( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + params.graphRewardsManager, + params._allocationId, + true + ); + } + + return tokensRewards; + } + + /** + * @notice Close an allocation + * Does not require presenting a POI, use {_collectIndexingRewards} to present a POI and collect rewards + * @dev Note that allocations are nowlong lived. All service payments, including indexing rewards, should be collected periodically + * without the need of closing the allocation. Allocations should only be closed when indexers want to reclaim the allocated + * tokens for other purposes. + * + * Emits a {AllocationClosed} event + * + * @param _allocations The mapping of allocation ids to allocation states + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens + * @param graphRewardsManager The rewards manager to handle rewards distribution + * @param _allocationId The id of the allocation to be closed + * @param _forceClosed Whether the allocation was force closed + */ + function closeAllocation( + mapping(address allocationId => Allocation.State allocation) storage _allocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + IRewardsManager graphRewardsManager, + address _allocationId, + bool _forceClosed + ) external { + _closeAllocation( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + graphRewardsManager, + _allocationId, + _forceClosed + ); + } + + /** + * @notice Resize an allocation + * @dev Will lock or release tokens in the provision tracker depending on the new allocation size. + * Rewards accrued but not issued before the resize will be accounted for as pending rewards. + * These will be paid out when the indexer presents a POI. + * + * Requirements: + * - `_indexer` must be the owner of the allocation + * - Allocation must be open + * - `_tokens` must be different from the current allocation size + * + * Emits a {AllocationResized} event. + * + * @param _allocations The mapping of allocation ids to allocation states + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens + * @param graphStaking The Horizon staking contract to handle token locking + * @param graphRewardsManager The rewards manager to handle rewards distribution + * @param _allocationId The id of the allocation to be resized + * @param _tokens The new amount of tokens to allocate + * @param _delegationRatio The delegation ratio to consider when locking tokens + */ + function resizeAllocation( + mapping(address allocationId => Allocation.State allocation) storage _allocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + IHorizonStaking graphStaking, + IRewardsManager graphRewardsManager, + address _allocationId, + uint256 _tokens, + uint32 _delegationRatio + ) external { + Allocation.State memory allocation = _allocations.get(_allocationId); + require(allocation.isOpen(), AllocationHandler.AllocationHandlerAllocationClosed(_allocationId)); + require( + _tokens != allocation.tokens, + AllocationHandler.AllocationHandlerAllocationSameSize(_allocationId, _tokens) + ); + + // Update provision tracker + uint256 oldTokens = allocation.tokens; + if (_tokens > oldTokens) { + allocationProvisionTracker.lock(graphStaking, allocation.indexer, _tokens - oldTokens, _delegationRatio); + } else { + allocationProvisionTracker.release(allocation.indexer, oldTokens - _tokens); + } + + // Calculate rewards that have been accrued since the last snapshot but not yet issued + uint256 accRewardsPerAllocatedToken = graphRewardsManager.onSubgraphAllocationUpdate( + allocation.subgraphDeploymentId + ); + uint256 accRewardsPerAllocatedTokenPending = !allocation.isAltruistic() + ? accRewardsPerAllocatedToken - allocation.accRewardsPerAllocatedToken + : 0; + + // Update the allocation + _allocations[_allocationId].tokens = _tokens; + _allocations[_allocationId].accRewardsPerAllocatedToken = accRewardsPerAllocatedToken; + _allocations[_allocationId].accRewardsPending += graphRewardsManager.calcRewards( + oldTokens, + accRewardsPerAllocatedTokenPending + ); + + // Update total allocated tokens for the subgraph deployment + if (_tokens > oldTokens) { + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] += (_tokens - oldTokens); + } else { + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] -= (oldTokens - _tokens); + } + + emit AllocationHandler.AllocationResized( + allocation.indexer, + _allocationId, + allocation.subgraphDeploymentId, + _tokens, + oldTokens + ); + } + + /** + * @notice Checks if an allocation is over-allocated + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param graphStaking The Horizon staking contract to check delegation ratios + * @param _indexer The address of the indexer + * @param _delegationRatio The delegation ratio to consider when locking tokens + * @return True if the allocation is over-allocated, false otherwise + */ + function isOverAllocated( + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + IHorizonStaking graphStaking, + address _indexer, + uint32 _delegationRatio + ) external view returns (bool) { + return _isOverAllocated(allocationProvisionTracker, graphStaking, _indexer, _delegationRatio); + } + + /** + * @notice Close an allocation + * Does not require presenting a POI, use {_collectIndexingRewards} to present a POI and collect rewards + * @dev Note that allocations are nowlong lived. All service payments, including indexing rewards, should be collected periodically + * without the need of closing the allocation. Allocations should only be closed when indexers want to reclaim the allocated + * tokens for other purposes. + * + * Emits a {AllocationClosed} event + * + * @param _allocations The mapping of allocation ids to allocation states + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens + * @param graphRewardsManager The rewards manager to handle rewards distribution + * @param _allocationId The id of the allocation to be closed + * @param _forceClosed Whether the allocation was force closed + */ + function _closeAllocation( + mapping(address allocationId => Allocation.State allocation) storage _allocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + IRewardsManager graphRewardsManager, + address _allocationId, + bool _forceClosed + ) private { + Allocation.State memory allocation = _allocations.get(_allocationId); + + // Take rewards snapshot to prevent other allos from counting tokens from this allo + _allocations.snapshotRewards( + _allocationId, + graphRewardsManager.onSubgraphAllocationUpdate(allocation.subgraphDeploymentId) + ); + + _allocations.close(_allocationId); + allocationProvisionTracker.release(allocation.indexer, allocation.tokens); + + // Update total allocated tokens for the subgraph deployment + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] = + _subgraphAllocatedTokens[allocation.subgraphDeploymentId] - + allocation.tokens; + + emit AllocationHandler.AllocationClosed( + allocation.indexer, + _allocationId, + allocation.subgraphDeploymentId, + allocation.tokens, + _forceClosed + ); + } + + /** + * @notice Checks if an allocation is over-allocated + * @param allocationProvisionTracker The mapping of indexers to their locked tokens + * @param graphStaking The Horizon staking contract to check delegation ratios + * @param _indexer The address of the indexer + * @param _delegationRatio The delegation ratio to consider when locking tokens + * @return True if the allocation is over-allocated, false otherwise + */ + function _isOverAllocated( + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + IHorizonStaking graphStaking, + address _indexer, + uint32 _delegationRatio + ) private view returns (bool) { + return !allocationProvisionTracker.check(graphStaking, _indexer, _delegationRatio); + } + + /** + * @notice Verifies ownership of an allocation id by verifying an EIP712 allocation proof + * @dev Requirements: + * - Signer must be the allocation id address + * @param _encodeAllocationProof The EIP712 encoded allocation proof + * @param _allocationId The id of the allocation + * @param _proof The EIP712 proof, an EIP712 signed message of (indexer,allocationId) + */ + function _verifyAllocationProof( + bytes32 _encodeAllocationProof, + address _allocationId, + bytes memory _proof + ) private pure { + address signer = ECDSA.recover(_encodeAllocationProof, _proof); + require( + signer == _allocationId, + AllocationHandler.AllocationHandlerInvalidAllocationProof(signer, _allocationId) + ); + } +} diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol new file mode 100644 index 000000000..a3669fffc --- /dev/null +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -0,0 +1,730 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; + +import { ISubgraphService } from "../interfaces/ISubgraphService.sol"; +import { AllocationHandler } from "../libraries/AllocationHandler.sol"; +import { Directory } from "../utilities/Directory.sol"; +import { Allocation } from "./Allocation.sol"; +import { IndexingAgreementDecoder } from "./IndexingAgreementDecoder.sol"; + +library IndexingAgreement { + using IndexingAgreement for StorageManager; + using Allocation for Allocation.State; + using Allocation for mapping(address => Allocation.State); + + /// @notice Versions of Indexing Agreement Metadata + enum IndexingAgreementVersion { + V1 + } + + /** + * @notice Indexer Agreement Data + * @param allocationId The allocation ID + * @param version The indexing agreement version + */ + struct State { + address allocationId; + IndexingAgreementVersion version; + } + + /** + * @notice Wrapper for Indexing Agreement and Collector Agreement Data + * @dev This struct is used to encapsulate the state of an indexing agreement + * @param agreement The indexing agreement state + * @param collectorAgreement The collector agreement data + */ + struct AgreementWrapper { + State agreement; + IRecurringCollector.AgreementData collectorAgreement; + } + + /** + * @notice Accept Indexing Agreement metadata + * @param subgraphDeploymentId The subgraph deployment ID + * @param version The indexing agreement version + * @param terms The indexing agreement terms + */ + struct AcceptIndexingAgreementMetadata { + bytes32 subgraphDeploymentId; + IndexingAgreementVersion version; + bytes terms; + } + + /** + * @notice Update Indexing Agreement metadata + * @param version The indexing agreement version + * @param terms The indexing agreement terms + */ + struct UpdateIndexingAgreementMetadata { + IndexingAgreementVersion version; + bytes terms; + } + + /** + * @notice Indexing Agreement Terms (Version 1) + * @param tokensPerSecond The amount of tokens per second + * @param tokensPerEntityPerSecond The amount of tokens per entity per second + */ + struct IndexingAgreementTermsV1 { + uint256 tokensPerSecond; + uint256 tokensPerEntityPerSecond; + } + + /** + * @notice Parameters for collecting indexing fees + * @param agreementId The ID of the indexing agreement + * @param currentEpoch The current epoch + * @param receiverDestination The address where the collected fees should be sent + * @param data The encoded data containing the number of entities indexed, proof of indexing, and epoch + */ + struct CollectParams { + bytes16 agreementId; + uint256 currentEpoch; + address receiverDestination; + bytes data; + } + + /** + * @notice Nested data for collecting indexing fees V1. + * + * @param entities The number of entities + * @param poi The proof of indexing (POI) + * @param poiBlockNumber The block number of the POI + * @param metadata Additional metadata associated with the collection + */ + struct CollectIndexingFeeDataV1 { + uint256 entities; + bytes32 poi; + uint256 poiBlockNumber; + bytes metadata; + } + + /** + * @notice Storage manager for indexing agreements + * @dev This struct holds the state of indexing agreements and their terms. + * It is used to manage the lifecycle of indexing agreements in the subgraph service. + * @param agreements Mapping of agreement IDs to their states + * @param termsV1 Mapping of agreement IDs to their terms for version 1 agreements + * @param allocationToActiveAgreementId Mapping of allocation IDs to their active agreement IDs + * @custom:storage-location erc7201:graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement + */ + struct StorageManager { + mapping(bytes16 => State) agreements; + mapping(bytes16 agreementId => IndexingAgreementTermsV1 data) termsV1; + mapping(address allocationId => bytes16 agreementId) allocationToActiveAgreementId; + } + + /** + * @notice Storage location for the indexing agreement storage manager + * @dev Equals keccak256(abi.encode(uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1)) & ~bytes32(uint256(0xff)) + */ + bytes32 public constant INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION = + 0xb59b65b7215c7fb95ac34d2ad5aed7c775c8bc77ad936b1b43e17b95efc8e400; + + /** + * @notice Emitted when an indexer collects indexing fees from a V1 agreement + * @param indexer The address of the indexer + * @param payer The address paying for the indexing fees + * @param agreementId The id of the agreement + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param currentEpoch The current epoch + * @param tokensCollected The amount of tokens collected + * @param entities The number of entities indexed + * @param poi The proof of indexing + * @param poiBlockNumber The block number of the proof of indexing + * @param metadata Additional metadata associated with the collection + */ + event IndexingFeesCollectedV1( + address indexed indexer, + address indexed payer, + bytes16 indexed agreementId, + address allocationId, + bytes32 subgraphDeploymentId, + uint256 currentEpoch, + uint256 tokensCollected, + uint256 entities, + bytes32 poi, + uint256 poiBlockNumber, + bytes metadata + ); + + /** + * @notice Emitted when an indexing agreement is canceled + * @param indexer The address of the indexer + * @param payer The address of the payer + * @param agreementId The id of the agreement + * @param canceledOnBehalfOf The address of the entity that canceled the agreement + */ + event IndexingAgreementCanceled( + address indexed indexer, + address indexed payer, + bytes16 indexed agreementId, + address canceledOnBehalfOf + ); + + /** + * @notice Emitted when an indexing agreement is accepted + * @param indexer The address of the indexer + * @param payer The address of the payer + * @param agreementId The id of the agreement + * @param allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment + * @param version The version of the indexing agreement + * @param versionTerms The version data of the indexing agreement + */ + event IndexingAgreementAccepted( + address indexed indexer, + address indexed payer, + bytes16 indexed agreementId, + address allocationId, + bytes32 subgraphDeploymentId, + IndexingAgreementVersion version, + bytes versionTerms + ); + + /** + * @notice Emitted when an indexing agreement is updated + * @param indexer The address of the indexer + * @param payer The address of the payer + * @param agreementId The id of the agreement + * @param allocationId The id of the allocation + * @param version The version of the indexing agreement + * @param versionTerms The version data of the indexing agreement + */ + event IndexingAgreementUpdated( + address indexed indexer, + address indexed payer, + bytes16 indexed agreementId, + address allocationId, + IndexingAgreementVersion version, + bytes versionTerms + ); + + /** + * @notice Thrown when trying to interact with an agreement with an invalid version + * @param version The invalid version + */ + error IndexingAgreementInvalidVersion(IndexingAgreementVersion version); + + /** + * @notice Thrown when an agreement is not for the subgraph data service + * @param expectedDataService The expected data service address + * @param wrongDataService The wrong data service address + */ + error IndexingAgreementWrongDataService(address expectedDataService, address wrongDataService); + + /** + * @notice Thrown when an agreement and the allocation correspond to different deployment IDs + * @param agreementDeploymentId The agreement's deployment ID + * @param allocationId The allocation ID + * @param allocationDeploymentId The allocation's deployment ID + */ + error IndexingAgreementDeploymentIdMismatch( + bytes32 agreementDeploymentId, + address allocationId, + bytes32 allocationDeploymentId + ); + + /** + * @notice Thrown when the agreement is already accepted + * @param agreementId The agreement ID + */ + error IndexingAgreementAlreadyAccepted(bytes16 agreementId); + + /** + * @notice Thrown when an allocation already has an active agreement + * @param allocationId The allocation ID + */ + error AllocationAlreadyHasIndexingAgreement(address allocationId); + + /** + * @notice Thrown when caller or proxy can not cancel an agreement + * @param owner The address of the owner of the agreement + * @param unauthorized The unauthorized caller + */ + error IndexingAgreementNonCancelableBy(address owner, address unauthorized); + + /** + * @notice Thrown when the agreement is not active + * @param agreementId The agreement ID + */ + error IndexingAgreementNotActive(bytes16 agreementId); + + /** + * @notice Thrown when trying to interact with an agreement not owned by the indexer + * @param agreementId The agreement ID + * @param unauthorizedIndexer The unauthorized indexer + */ + error IndexingAgreementNotAuthorized(bytes16 agreementId, address unauthorizedIndexer); + + /** + * @notice Accept an indexing agreement. + * + * Requirements: + * - Allocation must belong to the indexer and be open + * - Agreement must be for this data service + * - Agreement's subgraph deployment must match the allocation's subgraph deployment + * - Agreement must not have been accepted before + * - Allocation must not have an agreement already + * + * @dev signedRCA.rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata} + * + * Emits {IndexingAgreementAccepted} event + * + * @param self The indexing agreement storage manager + * @param allocations The mapping of allocation IDs to their states + * @param allocationId The id of the allocation + * @param signedRCA The signed Recurring Collection Agreement + */ + function accept( + StorageManager storage self, + mapping(address allocationId => Allocation.State allocation) storage allocations, + address allocationId, + IRecurringCollector.SignedRCA calldata signedRCA + ) external { + Allocation.State memory allocation = _requireValidAllocation( + allocations, + allocationId, + signedRCA.rca.serviceProvider + ); + + require( + signedRCA.rca.dataService == address(this), + IndexingAgreementWrongDataService(address(this), signedRCA.rca.dataService) + ); + + AcceptIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAMetadata( + signedRCA.rca.metadata + ); + + State storage agreement = self.agreements[signedRCA.rca.agreementId]; + + require(agreement.allocationId == address(0), IndexingAgreementAlreadyAccepted(signedRCA.rca.agreementId)); + + require( + allocation.subgraphDeploymentId == metadata.subgraphDeploymentId, + IndexingAgreementDeploymentIdMismatch( + metadata.subgraphDeploymentId, + allocationId, + allocation.subgraphDeploymentId + ) + ); + + // Ensure that an allocation can only have one active indexing agreement + require( + self.allocationToActiveAgreementId[allocationId] == bytes16(0), + AllocationAlreadyHasIndexingAgreement(allocationId) + ); + self.allocationToActiveAgreementId[allocationId] = signedRCA.rca.agreementId; + + agreement.version = metadata.version; + agreement.allocationId = allocationId; + + require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); + _setTermsV1(self, signedRCA.rca.agreementId, metadata.terms); + + emit IndexingAgreementAccepted( + signedRCA.rca.serviceProvider, + signedRCA.rca.payer, + signedRCA.rca.agreementId, + allocationId, + metadata.subgraphDeploymentId, + metadata.version, + metadata.terms + ); + + _directory().recurringCollector().accept(signedRCA); + } + + /** + * @notice Update an indexing agreement. + * + * Requirements: + * - Agreement must be active + * - The indexer must be the service provider of the agreement + * + * @dev signedRCA.rcau.metadata is an encoding of {IndexingAgreement.UpdateIndexingAgreementMetadata} + * + * Emits {IndexingAgreementUpdated} event + * + * @param self The indexing agreement storage manager + * @param indexer The indexer address + * @param signedRCAU The signed Recurring Collection Agreement Update + */ + function update( + StorageManager storage self, + address indexer, + IRecurringCollector.SignedRCAU calldata signedRCAU + ) external { + AgreementWrapper memory wrapper = _get(self, signedRCAU.rcau.agreementId); + require(_isActive(wrapper), IndexingAgreementNotActive(signedRCAU.rcau.agreementId)); + require( + wrapper.collectorAgreement.serviceProvider == indexer, + IndexingAgreementNotAuthorized(signedRCAU.rcau.agreementId, indexer) + ); + + UpdateIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAUMetadata( + signedRCAU.rcau.metadata + ); + + wrapper.agreement.version = metadata.version; + + require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); + _setTermsV1(self, signedRCAU.rcau.agreementId, metadata.terms); + + emit IndexingAgreementUpdated({ + indexer: wrapper.collectorAgreement.serviceProvider, + payer: wrapper.collectorAgreement.payer, + agreementId: signedRCAU.rcau.agreementId, + allocationId: wrapper.agreement.allocationId, + version: metadata.version, + versionTerms: metadata.terms + }); + + _directory().recurringCollector().update(signedRCAU); + } + + /** + * @notice Cancel an indexing agreement. + * + * @dev This function allows the indexer to cancel an indexing agreement. + * + * Requirements: + * - Agreement must be active + * - The indexer must be the service provider of the agreement + * + * Emits {IndexingAgreementCanceled} event + * + * @param self The indexing agreement storage manager + * @param indexer The indexer address + * @param agreementId The id of the agreement to cancel + */ + function cancel(StorageManager storage self, address indexer, bytes16 agreementId) external { + AgreementWrapper memory wrapper = _get(self, agreementId); + require(_isActive(wrapper), IndexingAgreementNotActive(agreementId)); + require( + wrapper.collectorAgreement.serviceProvider == indexer, + IndexingAgreementNonCancelableBy(wrapper.collectorAgreement.serviceProvider, indexer) + ); + _cancel( + self, + agreementId, + wrapper.agreement, + wrapper.collectorAgreement, + IRecurringCollector.CancelAgreementBy.ServiceProvider + ); + } + + /** + * @notice Cancel an allocation's indexing agreement if it exists. + * + * @dev This function is to be called by the data service when an allocation is closed. + * + * Requirements: + * - The allocation must have an active agreement + * - Agreement must be active + * + * Emits {IndexingAgreementCanceled} event + * + * @param self The indexing agreement storage manager + * @param _allocationId The allocation ID + * @param stale Whether the allocation is stale or not + * + */ + function onCloseAllocation(StorageManager storage self, address _allocationId, bool stale) external { + bytes16 agreementId = self.allocationToActiveAgreementId[_allocationId]; + if (agreementId == bytes16(0)) { + return; + } + + AgreementWrapper memory wrapper = _get(self, agreementId); + if (!_isActive(wrapper)) { + return; + } + + _cancel( + self, + agreementId, + wrapper.agreement, + wrapper.collectorAgreement, + stale + ? IRecurringCollector.CancelAgreementBy.ThirdParty + : IRecurringCollector.CancelAgreementBy.ServiceProvider + ); + } + + /** + * @notice Cancel an indexing agreement by the payer. + * + * @dev This function allows the payer to cancel an indexing agreement. + * + * Requirements: + * - Agreement must be active + * - The caller must be authorized to cancel the agreement in the collector on the payer's behalf + * + * Emits {IndexingAgreementCanceled} event + * + * @param self The indexing agreement storage manager + * @param agreementId The id of the agreement to cancel + */ + function cancelByPayer(StorageManager storage self, bytes16 agreementId) external { + AgreementWrapper memory wrapper = _get(self, agreementId); + require(_isActive(wrapper), IndexingAgreementNotActive(agreementId)); + require( + _directory().recurringCollector().isAuthorized(wrapper.collectorAgreement.payer, msg.sender), + IndexingAgreementNonCancelableBy(wrapper.collectorAgreement.payer, msg.sender) + ); + _cancel( + self, + agreementId, + wrapper.agreement, + wrapper.collectorAgreement, + IRecurringCollector.CancelAgreementBy.Payer + ); + } + + /** + * @notice Collect Indexing fees + * @dev Uses the {RecurringCollector} to collect payment from Graph Horizon payments protocol. + * Fees are distributed to service provider and delegators by {GraphPayments} + * + * Requirements: + * - Allocation must be open + * - Agreement must be active + * - Agreement must be of version V1 + * - The data must be encoded as per {IndexingAgreementDecoder.decodeCollectIndexingFeeDataV1} + * + * Emits a {IndexingFeesCollectedV1} event. + * + * @param self The indexing agreement storage manager + * @param allocations The mapping of allocation IDs to their states + * @param params The parameters for collecting indexing fees + * @return The address of the service provider that collected the fees + * @return The amount of fees collected + */ + function collect( + StorageManager storage self, + mapping(address allocationId => Allocation.State allocation) storage allocations, + CollectParams memory params + ) external returns (address, uint256) { + AgreementWrapper memory wrapper = _get(self, params.agreementId); + Allocation.State memory allocation = _requireValidAllocation( + allocations, + wrapper.agreement.allocationId, + wrapper.collectorAgreement.serviceProvider + ); + require(_isActive(wrapper), IndexingAgreementNotActive(params.agreementId)); + + require( + wrapper.agreement.version == IndexingAgreementVersion.V1, + IndexingAgreementInvalidVersion(wrapper.agreement.version) + ); + + CollectIndexingFeeDataV1 memory data = IndexingAgreementDecoder.decodeCollectIndexingFeeDataV1(params.data); + + uint256 expectedTokens = (data.entities == 0 && data.poi == bytes32(0)) + ? 0 + : _tokensToCollect(self, params.agreementId, wrapper.collectorAgreement, data.entities); + + // `tokensCollected` <= `expectedTokens` because the recurring collector will further narrow + // down the tokens allowed, based on the RCA terms. + uint256 tokensCollected = _directory().recurringCollector().collect( + IGraphPayments.PaymentTypes.IndexingFee, + abi.encode( + IRecurringCollector.CollectParams({ + agreementId: params.agreementId, + collectionId: bytes32(uint256(uint160(wrapper.agreement.allocationId))), + tokens: expectedTokens, + dataServiceCut: 0, + receiverDestination: params.receiverDestination + }) + ) + ); + + emit IndexingFeesCollectedV1( + wrapper.collectorAgreement.serviceProvider, + wrapper.collectorAgreement.payer, + params.agreementId, + wrapper.agreement.allocationId, + allocation.subgraphDeploymentId, + params.currentEpoch, + tokensCollected, + data.entities, + data.poi, + data.poiBlockNumber, + data.metadata + ); + + return (wrapper.collectorAgreement.serviceProvider, tokensCollected); + } + + /** + * @notice Get the indexing agreement for a given agreement ID. + * + * @param self The indexing agreement storage manager + * @param agreementId The id of the indexing agreement + * @return The indexing agreement wrapper containing the agreement state and collector agreement data + */ + function get(StorageManager storage self, bytes16 agreementId) external view returns (AgreementWrapper memory) { + AgreementWrapper memory wrapper = _get(self, agreementId); + require(wrapper.collectorAgreement.dataService == address(this), IndexingAgreementNotActive(agreementId)); + + return wrapper; + } + + /** + * @notice Get the storage manager for indexing agreements. + * @dev This function retrieves the storage manager for indexing agreements. + * @return m The storage manager for indexing agreements + */ + function _getStorageManager() internal pure returns (StorageManager storage m) { + // solhint-disable-next-line no-inline-assembly + assembly { + m.slot := INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION + } + } + + /** + * @notice Set the terms for an indexing agreement of version V1. + * @dev This function updates the terms of an indexing agreement in the storage manager. + * @param _manager The indexing agreement storage manager + * @param _agreementId The id of the agreement to update + * @param _data The encoded terms data + */ + function _setTermsV1(StorageManager storage _manager, bytes16 _agreementId, bytes memory _data) private { + IndexingAgreementTermsV1 memory newTerms = IndexingAgreementDecoder.decodeIndexingAgreementTermsV1(_data); + _manager.termsV1[_agreementId].tokensPerSecond = newTerms.tokensPerSecond; + _manager.termsV1[_agreementId].tokensPerEntityPerSecond = newTerms.tokensPerEntityPerSecond; + } + + /** + * @notice Cancel an indexing agreement. + * + * @dev This function does the actual agreement cancelation. + * + * Emits {IndexingAgreementCanceled} event + * + * @param _manager The indexing agreement storage manager + * @param _agreementId The id of the agreement to cancel + * @param _agreement The indexing agreement state + * @param _collectorAgreement The collector agreement data + * @param _cancelBy The entity that is canceling the agreement + */ + function _cancel( + StorageManager storage _manager, + bytes16 _agreementId, + State memory _agreement, + IRecurringCollector.AgreementData memory _collectorAgreement, + IRecurringCollector.CancelAgreementBy _cancelBy + ) private { + // Delete the allocation to active agreement link, so that the allocation + // can be assigned a new indexing agreement in the future. + delete _manager.allocationToActiveAgreementId[_agreement.allocationId]; + + emit IndexingAgreementCanceled( + _collectorAgreement.serviceProvider, + _collectorAgreement.payer, + _agreementId, + _cancelBy == IRecurringCollector.CancelAgreementBy.Payer + ? _collectorAgreement.payer + : _collectorAgreement.serviceProvider + ); + + _directory().recurringCollector().cancel(_agreementId, _cancelBy); + } + + /** + * @notice Requires that the allocation is valid and owned by the indexer. + * + * Requirements: + * - Allocation must belong to the indexer + * - Allocation must be open + * + * @param _allocations The mapping of allocation IDs to their states + * @param _allocationId The id of the allocation + * @param _indexer The address of the indexer + * @return The allocation state + */ + function _requireValidAllocation( + mapping(address => Allocation.State) storage _allocations, + address _allocationId, + address _indexer + ) private view returns (Allocation.State memory) { + Allocation.State memory allocation = _allocations.get(_allocationId); + require( + allocation.indexer == _indexer, + ISubgraphService.SubgraphServiceAllocationNotAuthorized(_indexer, _allocationId) + ); + require(allocation.isOpen(), AllocationHandler.AllocationHandlerAllocationClosed(_allocationId)); + + return allocation; + } + + /** + * @notice Calculate the number of tokens to collect for an indexing agreement. + * + * @dev This function calculates the number of tokens to collect based on the agreement terms and the collection time. + * + * @param _manager The indexing agreement storage manager + * @param _agreementId The id of the agreement + * @param _agreement The collector agreement data + * @param _entities The number of entities indexed + * @return The number of tokens to collect + */ + function _tokensToCollect( + StorageManager storage _manager, + bytes16 _agreementId, + IRecurringCollector.AgreementData memory _agreement, + uint256 _entities + ) private view returns (uint256) { + IndexingAgreementTermsV1 memory termsV1 = _manager.termsV1[_agreementId]; + + uint256 collectionSeconds = block.timestamp; + collectionSeconds -= _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; + + return collectionSeconds * (termsV1.tokensPerSecond + termsV1.tokensPerEntityPerSecond * _entities); + } + + /** + * @notice Checks if the agreement is active + * Requirements: + * - The underlying collector agreement has been accepted + * - The underlying collector agreement's data service is this contract + * - The indexing agreement has been accepted and has a valid allocation ID + * @param wrapper The agreement wrapper containing the indexing agreement and collector agreement data + * @return True if the agreement is active, false otherwise + **/ + function _isActive(AgreementWrapper memory wrapper) private view returns (bool) { + return + wrapper.collectorAgreement.dataService == address(this) && + wrapper.collectorAgreement.state == IRecurringCollector.AgreementState.Accepted && + wrapper.agreement.allocationId != address(0); + } + + /** + * @notice Gets the Directory + * @return The Directory contract + */ + function _directory() private view returns (Directory) { + return Directory(address(this)); + } + + /** + * @notice Gets the indexing agreement wrapper for a given agreement ID. + * @dev This function retrieves the indexing agreement wrapper containing the agreement state and collector agreement data. + * @param self The indexing agreement storage manager + * @param agreementId The id of the indexing agreement + * @return The indexing agreement wrapper containing the agreement state and collector agreement data + */ + function _get(StorageManager storage self, bytes16 agreementId) private view returns (AgreementWrapper memory) { + return + AgreementWrapper({ + agreement: self.agreements[agreementId], + collectorAgreement: _directory().recurringCollector().getAgreement(agreementId) + }); + } +} diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol new file mode 100644 index 000000000..f8f5af811 --- /dev/null +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { IndexingAgreementDecoderRaw } from "./IndexingAgreementDecoderRaw.sol"; +import { IndexingAgreement } from "./IndexingAgreement.sol"; + +library IndexingAgreementDecoder { + /** + * @notice Thrown when the data can't be decoded as expected + * @param t The type of data that was expected + * @param data The invalid data + */ + error IndexingAgreementDecoderInvalidData(string t, bytes data); + + /** + * @notice Decodes the data for collecting indexing fees. + * + * @param data The data to decode. + * @return agreementId The agreement ID + * @return nestedData The nested encoded data + */ + function decodeCollectData(bytes memory data) public pure returns (bytes16, bytes memory) { + try IndexingAgreementDecoderRaw.decodeCollectData(data) returns (bytes16 agreementId, bytes memory nestedData) { + return (agreementId, nestedData); + } catch { + revert IndexingAgreementDecoderInvalidData("decodeCollectData", data); + } + } + + /** + * @notice Decodes the RCA metadata. + * + * @param data The data to decode. + * @return The decoded data. See {IndexingAgreement.AcceptIndexingAgreementMetadata} + */ + function decodeRCAMetadata( + bytes memory data + ) public pure returns (IndexingAgreement.AcceptIndexingAgreementMetadata memory) { + try IndexingAgreementDecoderRaw.decodeRCAMetadata(data) returns ( + IndexingAgreement.AcceptIndexingAgreementMetadata memory decoded + ) { + return decoded; + } catch { + revert IndexingAgreementDecoderInvalidData("decodeRCAMetadata", data); + } + } + + /** + * @notice Decodes the RCAU metadata. + * + * @param data The data to decode. + * @return The decoded data. See {IndexingAgreement.UpdateIndexingAgreementMetadata} + */ + function decodeRCAUMetadata( + bytes memory data + ) public pure returns (IndexingAgreement.UpdateIndexingAgreementMetadata memory) { + try IndexingAgreementDecoderRaw.decodeRCAUMetadata(data) returns ( + IndexingAgreement.UpdateIndexingAgreementMetadata memory decoded + ) { + return decoded; + } catch { + revert IndexingAgreementDecoderInvalidData("decodeRCAUMetadata", data); + } + } + + /** + * @notice Decodes the collect data for indexing fees V1. + * + * @param data The data to decode. + * @return The decoded data structure. See {IndexingAgreement.CollectIndexingFeeDataV1} + */ + function decodeCollectIndexingFeeDataV1( + bytes memory data + ) public pure returns (IndexingAgreement.CollectIndexingFeeDataV1 memory) { + try IndexingAgreementDecoderRaw.decodeCollectIndexingFeeDataV1(data) returns ( + IndexingAgreement.CollectIndexingFeeDataV1 memory decoded + ) { + return decoded; + } catch { + revert IndexingAgreementDecoderInvalidData("decodeCollectIndexingFeeDataV1", data); + } + } + + /** + * @notice Decodes the data for indexing agreement terms V1. + * + * @param data The data to decode. + * @return The decoded data structure. See {IndexingAgreement.IndexingAgreementTermsV1} + */ + function decodeIndexingAgreementTermsV1( + bytes memory data + ) public pure returns (IndexingAgreement.IndexingAgreementTermsV1 memory) { + try IndexingAgreementDecoderRaw.decodeIndexingAgreementTermsV1(data) returns ( + IndexingAgreement.IndexingAgreementTermsV1 memory decoded + ) { + return decoded; + } catch { + revert IndexingAgreementDecoderInvalidData("decodeCollectIndexingFeeData", data); + } + } +} diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoderRaw.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoderRaw.sol new file mode 100644 index 000000000..93b1718bf --- /dev/null +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoderRaw.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +import { IndexingAgreement } from "./IndexingAgreement.sol"; + +library IndexingAgreementDecoderRaw { + /** + * @notice See {IndexingAgreementDecoder.decodeCollectIndexingFeeData} + * @param data The data to decode + * @return agreementId The agreement ID + * @return nestedData The nested encoded data + */ + function decodeCollectData(bytes calldata data) public pure returns (bytes16, bytes memory) { + return abi.decode(data, (bytes16, bytes)); + } + + /** + * @notice See {IndexingAgreementDecoder.decodeRCAMetadata} + * @dev The data should be encoded as {IndexingAgreement.AcceptIndexingAgreementMetadata} + * @param data The data to decode + * @return The decoded data + */ + function decodeRCAMetadata( + bytes calldata data + ) public pure returns (IndexingAgreement.AcceptIndexingAgreementMetadata memory) { + return abi.decode(data, (IndexingAgreement.AcceptIndexingAgreementMetadata)); + } + + /** + * @notice See {IndexingAgreementDecoder.decodeRCAUMetadata} + * @dev The data should be encoded as {IndexingAgreement.UpdateIndexingAgreementMetadata} + * @param data The data to decode + * @return The decoded data + */ + function decodeRCAUMetadata( + bytes calldata data + ) public pure returns (IndexingAgreement.UpdateIndexingAgreementMetadata memory) { + return abi.decode(data, (IndexingAgreement.UpdateIndexingAgreementMetadata)); + } + + /** + * @notice See {IndexingAgreementDecoder.decodeCollectIndexingFeeDataV1} + * @dev The data should be encoded as (uint256 entities, bytes32 poi, uint256 epoch) + * @param data The data to decode + * @return The decoded collect indexing fee V1 data + * + */ + function decodeCollectIndexingFeeDataV1( + bytes memory data + ) public pure returns (IndexingAgreement.CollectIndexingFeeDataV1 memory) { + return abi.decode(data, (IndexingAgreement.CollectIndexingFeeDataV1)); + } + + /** + * @notice See {IndexingAgreementDecoder.decodeIndexingAgreementTermsV1} + * @dev The data should be encoded as {IndexingAgreement.IndexingAgreementTermsV1} + * @param data The data to decode + * @return The decoded indexing agreement terms + */ + function decodeIndexingAgreementTermsV1( + bytes memory data + ) public pure returns (IndexingAgreement.IndexingAgreementTermsV1 memory) { + return abi.decode(data, (IndexingAgreement.IndexingAgreementTermsV1)); + } +} diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index 78e5fa190..bc64d0eb6 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -1,20 +1,18 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.27; -import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToken.sol"; -import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interfaces/internal/IHorizonStakingTypes.sol"; import { GraphDirectory } from "@graphprotocol/horizon/contracts/utilities/GraphDirectory.sol"; import { AllocationManagerV1Storage } from "./AllocationManagerStorage.sol"; import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol"; -import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; import { Allocation } from "../libraries/Allocation.sol"; import { LegacyAllocation } from "../libraries/LegacyAllocation.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol"; +import { AllocationHandler } from "../libraries/AllocationHandler.sol"; /** * @title AllocationManager contract @@ -36,122 +34,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca bytes32 private constant EIP712_ALLOCATION_ID_PROOF_TYPEHASH = keccak256("AllocationIdProof(address indexer,address allocationId)"); - /** - * @notice Emitted when an indexer creates an allocation - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - * @param tokens The amount of tokens allocated - * @param currentEpoch The current epoch - */ - event AllocationCreated( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId, - uint256 tokens, - uint256 currentEpoch - ); - - /** - * @notice Emitted when an indexer collects indexing rewards for an allocation - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - * @param tokensRewards The amount of tokens collected - * @param tokensIndexerRewards The amount of tokens collected for the indexer - * @param tokensDelegationRewards The amount of tokens collected for delegators - * @param poi The POI presented - * @param currentEpoch The current epoch - * @param poiMetadata The metadata associated with the POI - */ - event IndexingRewardsCollected( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId, - uint256 tokensRewards, - uint256 tokensIndexerRewards, - uint256 tokensDelegationRewards, - bytes32 poi, - bytes poiMetadata, - uint256 currentEpoch - ); - - /** - * @notice Emitted when an indexer resizes an allocation - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - * @param newTokens The new amount of tokens allocated - * @param oldTokens The old amount of tokens allocated - */ - event AllocationResized( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId, - uint256 newTokens, - uint256 oldTokens - ); - - /** - * @dev Emitted when an indexer closes an allocation - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - * @param tokens The amount of tokens allocated - * @param forceClosed Whether the allocation was force closed - */ - event AllocationClosed( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId, - uint256 tokens, - bool forceClosed - ); - - /** - * @notice Emitted when a legacy allocation is migrated into the subgraph service - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - */ - event LegacyAllocationMigrated( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId - ); - - /** - * @notice Emitted when the maximum POI staleness is updated - * @param maxPOIStaleness The max POI staleness in seconds - */ - event MaxPOIStalenessSet(uint256 maxPOIStaleness); - - /** - * @notice Thrown when an allocation proof is invalid - * Both `signer` and `allocationId` should match for a valid proof. - * @param signer The address that signed the proof - * @param allocationId The id of the allocation - */ - error AllocationManagerInvalidAllocationProof(address signer, address allocationId); - - /** - * @notice Thrown when attempting to create an allocation with a zero allocation id - */ - error AllocationManagerInvalidZeroAllocationId(); - - /** - * @notice Thrown when attempting to collect indexing rewards on a closed allocationl - * @param allocationId The id of the allocation - */ - error AllocationManagerAllocationClosed(address allocationId); - - /** - * @notice Thrown when attempting to resize an allocation with the same size - * @param allocationId The id of the allocation - * @param tokens The amount of tokens - */ - error AllocationManagerAllocationSameSize(address allocationId, uint256 tokens); - /** * @notice Initializes the contract and parent contracts * @param _name The name to use for EIP712 domain separation @@ -177,7 +59,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca */ function _migrateLegacyAllocation(address _indexer, address _allocationId, bytes32 _subgraphDeploymentId) internal { _legacyAllocations.migrate(_indexer, _allocationId, _subgraphDeploymentId); - emit LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentId); + emit AllocationHandler.LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentId); } /** @@ -204,34 +86,24 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca bytes memory _allocationProof, uint32 _delegationRatio ) internal { - require(_allocationId != address(0), AllocationManagerInvalidZeroAllocationId()); - - _verifyAllocationProof(_indexer, _allocationId, _allocationProof); - - // Ensure allocation id is not reused - // need to check both subgraph service (on allocations.create()) and legacy allocations - _legacyAllocations.revertIfExists(_graphStaking(), _allocationId); - - uint256 currentEpoch = _graphEpochManager().currentEpoch(); - Allocation.State memory allocation = _allocations.create( - _indexer, - _allocationId, - _subgraphDeploymentId, - _tokens, - _graphRewardsManager().onSubgraphAllocationUpdate(_subgraphDeploymentId), - currentEpoch + AllocationHandler.allocate( + _allocations, + _legacyAllocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + AllocationHandler.AllocateParams({ + _allocationId: _allocationId, + _allocationProof: _allocationProof, + _encodeAllocationProof: _encodeAllocationProof(_indexer, _allocationId), + _delegationRatio: _delegationRatio, + _indexer: _indexer, + _subgraphDeploymentId: _subgraphDeploymentId, + _tokens: _tokens, + currentEpoch: _graphEpochManager().currentEpoch(), + graphRewardsManager: _graphRewardsManager(), + graphStaking: _graphStaking() + }) ); - - // Check that the indexer has enough tokens available - // Note that the delegation ratio ensures overdelegation cannot be used - allocationProvisionTracker.lock(_graphStaking(), _indexer, _tokens, _delegationRatio); - - // Update total allocated tokens for the subgraph deployment - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] = - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] + - allocation.tokens; - - emit AllocationCreated(_indexer, _allocationId, _subgraphDeploymentId, allocation.tokens, currentEpoch); } /** @@ -268,76 +140,25 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca uint32 _delegationRatio, address _paymentsDestination ) internal returns (uint256) { - Allocation.State memory allocation = _allocations.get(_allocationId); - require(allocation.isOpen(), AllocationManagerAllocationClosed(_allocationId)); - - // Mint indexing rewards if all conditions are met - uint256 tokensRewards = (!allocation.isStale(maxPOIStaleness) && - !allocation.isAltruistic() && - _poi != bytes32(0)) && _graphEpochManager().currentEpoch() > allocation.createdAtEpoch - ? _graphRewardsManager().takeRewards(_allocationId) - : 0; - - // ... but we still take a snapshot to ensure the rewards are not accumulated for the next valid POI - _allocations.snapshotRewards( - _allocationId, - _graphRewardsManager().onSubgraphAllocationUpdate(allocation.subgraphDeploymentId) - ); - _allocations.presentPOI(_allocationId); - - // Any pending rewards should have been collected now - _allocations.clearPendingRewards(_allocationId); - - uint256 tokensIndexerRewards = 0; - uint256 tokensDelegationRewards = 0; - if (tokensRewards != 0) { - // Distribute rewards to delegators - uint256 delegatorCut = _graphStaking().getDelegationFeeCut( - allocation.indexer, - address(this), - IGraphPayments.PaymentTypes.IndexingRewards - ); - IHorizonStakingTypes.DelegationPool memory delegationPool = _graphStaking().getDelegationPool( - allocation.indexer, - address(this) + return + AllocationHandler.presentPOI( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + AllocationHandler.PresentParams({ + maxPOIStaleness: maxPOIStaleness, + graphEpochManager: _graphEpochManager(), + graphStaking: _graphStaking(), + graphRewardsManager: _graphRewardsManager(), + graphToken: _graphToken(), + dataService: address(this), + _allocationId: _allocationId, + _poi: _poi, + _poiMetadata: _poiMetadata, + _delegationRatio: _delegationRatio, + _paymentsDestination: _paymentsDestination + }) ); - // If delegation pool has no shares then we don't need to distribute rewards to delegators - tokensDelegationRewards = delegationPool.shares > 0 ? tokensRewards.mulPPM(delegatorCut) : 0; - if (tokensDelegationRewards > 0) { - _graphToken().approve(address(_graphStaking()), tokensDelegationRewards); - _graphStaking().addToDelegationPool(allocation.indexer, address(this), tokensDelegationRewards); - } - - // Distribute rewards to indexer - tokensIndexerRewards = tokensRewards - tokensDelegationRewards; - if (tokensIndexerRewards > 0) { - if (_paymentsDestination == address(0)) { - _graphToken().approve(address(_graphStaking()), tokensIndexerRewards); - _graphStaking().stakeToProvision(allocation.indexer, address(this), tokensIndexerRewards); - } else { - _graphToken().pushTokens(_paymentsDestination, tokensIndexerRewards); - } - } - } - - emit IndexingRewardsCollected( - allocation.indexer, - _allocationId, - allocation.subgraphDeploymentId, - tokensRewards, - tokensIndexerRewards, - tokensDelegationRewards, - _poi, - _poiMetadata, - _graphEpochManager().currentEpoch() - ); - - // Check if the indexer is over-allocated and force close the allocation if necessary - if (_isOverAllocated(allocation.indexer, _delegationRatio)) { - _closeAllocation(_allocationId, true); - } - - return tokensRewards; } /** @@ -358,42 +179,16 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @param _delegationRatio The delegation ratio to consider when locking tokens */ function _resizeAllocation(address _allocationId, uint256 _tokens, uint32 _delegationRatio) internal { - Allocation.State memory allocation = _allocations.get(_allocationId); - require(allocation.isOpen(), AllocationManagerAllocationClosed(_allocationId)); - require(_tokens != allocation.tokens, AllocationManagerAllocationSameSize(_allocationId, _tokens)); - - // Update provision tracker - uint256 oldTokens = allocation.tokens; - if (_tokens > oldTokens) { - allocationProvisionTracker.lock(_graphStaking(), allocation.indexer, _tokens - oldTokens, _delegationRatio); - } else { - allocationProvisionTracker.release(allocation.indexer, oldTokens - _tokens); - } - - // Calculate rewards that have been accrued since the last snapshot but not yet issued - uint256 accRewardsPerAllocatedToken = _graphRewardsManager().onSubgraphAllocationUpdate( - allocation.subgraphDeploymentId - ); - uint256 accRewardsPerAllocatedTokenPending = !allocation.isAltruistic() - ? accRewardsPerAllocatedToken - allocation.accRewardsPerAllocatedToken - : 0; - - // Update the allocation - _allocations[_allocationId].tokens = _tokens; - _allocations[_allocationId].accRewardsPerAllocatedToken = accRewardsPerAllocatedToken; - _allocations[_allocationId].accRewardsPending += _graphRewardsManager().calcRewards( - oldTokens, - accRewardsPerAllocatedTokenPending + AllocationHandler.resizeAllocation( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + _graphStaking(), + _graphRewardsManager(), + _allocationId, + _tokens, + _delegationRatio ); - - // Update total allocated tokens for the subgraph deployment - if (_tokens > oldTokens) { - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] += (_tokens - oldTokens); - } else { - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] -= (oldTokens - _tokens); - } - - emit AllocationResized(allocation.indexer, _allocationId, allocation.subgraphDeploymentId, _tokens, oldTokens); } /** @@ -409,27 +204,12 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @param _forceClosed Whether the allocation was force closed */ function _closeAllocation(address _allocationId, bool _forceClosed) internal { - Allocation.State memory allocation = _allocations.get(_allocationId); - - // Take rewards snapshot to prevent other allos from counting tokens from this allo - _allocations.snapshotRewards( + AllocationHandler.closeAllocation( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + _graphRewardsManager(), _allocationId, - _graphRewardsManager().onSubgraphAllocationUpdate(allocation.subgraphDeploymentId) - ); - - _allocations.close(_allocationId); - allocationProvisionTracker.release(allocation.indexer, allocation.tokens); - - // Update total allocated tokens for the subgraph deployment - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] = - _subgraphAllocatedTokens[allocation.subgraphDeploymentId] - - allocation.tokens; - - emit AllocationClosed( - allocation.indexer, - _allocationId, - allocation.subgraphDeploymentId, - allocation.tokens, _forceClosed ); } @@ -441,7 +221,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca */ function _setMaxPOIStaleness(uint256 _maxPOIStaleness) internal { maxPOIStaleness = _maxPOIStaleness; - emit MaxPOIStalenessSet(_maxPOIStaleness); + emit AllocationHandler.MaxPOIStalenessSet(_maxPOIStaleness); } /** @@ -461,19 +241,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @return True if the allocation is over-allocated, false otherwise */ function _isOverAllocated(address _indexer, uint32 _delegationRatio) internal view returns (bool) { - return !allocationProvisionTracker.check(_graphStaking(), _indexer, _delegationRatio); - } - - /** - * @notice Verifies ownership of an allocation id by verifying an EIP712 allocation proof - * @dev Requirements: - * - Signer must be the allocation id address - * @param _indexer The address of the indexer - * @param _allocationId The id of the allocation - * @param _proof The EIP712 proof, an EIP712 signed message of (indexer,allocationId) - */ - function _verifyAllocationProof(address _indexer, address _allocationId, bytes memory _proof) private view { - address signer = ECDSA.recover(_encodeAllocationProof(_indexer, _allocationId), _proof); - require(signer == _allocationId, AllocationManagerInvalidAllocationProof(signer, _allocationId)); + return + AllocationHandler.isOverAllocated(allocationProvisionTracker, _graphStaking(), _indexer, _delegationRatio); } } diff --git a/packages/subgraph-service/contracts/utilities/Directory.sol b/packages/subgraph-service/contracts/utilities/Directory.sol index d068c74b3..8b58d31b4 100644 --- a/packages/subgraph-service/contracts/utilities/Directory.sol +++ b/packages/subgraph-service/contracts/utilities/Directory.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.27; import { IDisputeManager } from "../interfaces/IDisputeManager.sol"; import { ISubgraphService } from "../interfaces/ISubgraphService.sol"; import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; import { ICuration } from "@graphprotocol/contracts/contracts/curation/ICuration.sol"; /** @@ -25,6 +26,10 @@ abstract contract Directory { /// @dev Required to collect payments via Graph Horizon payments protocol IGraphTallyCollector private immutable GRAPH_TALLY_COLLECTOR; + /// @notice The Recurring Collector contract address + /// @dev Required to collect indexing agreement payments via Graph Horizon payments protocol + IRecurringCollector private immutable RECURRING_COLLECTOR; + /// @notice The Curation contract address /// @dev Required for curation fees distribution ICuration private immutable CURATION; @@ -35,12 +40,14 @@ abstract contract Directory { * @param disputeManager The Dispute Manager contract address * @param graphTallyCollector The Graph Tally Collector contract address * @param curation The Curation contract address + * @param recurringCollector The Recurring Collector contract address */ event SubgraphServiceDirectoryInitialized( address subgraphService, address disputeManager, address graphTallyCollector, - address curation + address curation, + address recurringCollector ); /** @@ -67,14 +74,36 @@ abstract contract Directory { * @param disputeManager The Dispute Manager contract address * @param graphTallyCollector The Graph Tally Collector contract address * @param curation The Curation contract address + * @param recurringCollector_ The Recurring Collector contract address */ - constructor(address subgraphService, address disputeManager, address graphTallyCollector, address curation) { + constructor( + address subgraphService, + address disputeManager, + address graphTallyCollector, + address curation, + address recurringCollector_ + ) { SUBGRAPH_SERVICE = ISubgraphService(subgraphService); DISPUTE_MANAGER = IDisputeManager(disputeManager); GRAPH_TALLY_COLLECTOR = IGraphTallyCollector(graphTallyCollector); CURATION = ICuration(curation); + RECURRING_COLLECTOR = IRecurringCollector(recurringCollector_); - emit SubgraphServiceDirectoryInitialized(subgraphService, disputeManager, graphTallyCollector, curation); + emit SubgraphServiceDirectoryInitialized( + subgraphService, + disputeManager, + graphTallyCollector, + curation, + recurringCollector_ + ); + } + + /** + * @notice Returns the Recurring Collector contract address + * @return The Recurring Collector contract + */ + function recurringCollector() external view returns (IRecurringCollector) { + return RECURRING_COLLECTOR; } /** diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index c9b23e0f5..0b000778c 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -17,9 +17,10 @@ "scripts": { "lint": "pnpm lint:ts && pnpm lint:sol", "lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored", - "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint", + "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint && pnpm lint:sol:solhint:test", "lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"", "lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js", + "lint:sol:solhint:test": "solhint --noPrompt --fix \"test/unit/subgraphService/indexing-agreement/*\" --config node_modules/solhint-graph-config/index.js", "lint:sol:natspec": "natspec-smells --config natspec-smells.config.js", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "hardhat compile", diff --git a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol index 0f59013be..639f183d1 100644 --- a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol @@ -14,6 +14,7 @@ import { IHorizonStaking } from "@graphprotocol/horizon/contracts/interfaces/IHo import { IPaymentsEscrow } from "@graphprotocol/horizon/contracts/interfaces/IPaymentsEscrow.sol"; import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; import { GraphTallyCollector } from "@graphprotocol/horizon/contracts/payments/collectors/GraphTallyCollector.sol"; +import { RecurringCollector } from "@graphprotocol/horizon/contracts/payments/collectors/RecurringCollector.sol"; import { PaymentsEscrow } from "@graphprotocol/horizon/contracts/payments/PaymentsEscrow.sol"; import { UnsafeUpgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol"; @@ -43,6 +44,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { GraphPayments graphPayments; IPaymentsEscrow escrow; GraphTallyCollector graphTallyCollector; + RecurringCollector recurringCollector; HorizonStaking private stakingBase; HorizonStakingExtension private stakingExtension; @@ -156,12 +158,20 @@ abstract contract SubgraphBaseTest is Utils, Constants { address(controller), revokeSignerThawingPeriod ); + recurringCollector = new RecurringCollector( + "RecurringCollector", + "1", + address(controller), + revokeSignerThawingPeriod + ); + address subgraphServiceImplementation = address( new SubgraphService( address(controller), address(disputeManager), address(graphTallyCollector), - address(curation) + address(curation), + address(recurringCollector) ) ); address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy( diff --git a/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol b/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol index 720460bc4..6df3474b2 100644 --- a/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol +++ b/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol @@ -69,7 +69,11 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { assertEq(address(disputeManager.subgraphService()), _subgraphService, "Subgraph service should be set."); } - function _createIndexingDispute(address _allocationId, bytes32 _poi, uint256 _blockNumber) internal returns (bytes32) { + function _createIndexingDispute( + address _allocationId, + bytes32 _poi, + uint256 _blockNumber + ) internal returns (bytes32) { (, address fisherman, ) = vm.readCallers(); bytes32 expectedDisputeId = keccak256(abi.encodePacked(_allocationId, _poi, _blockNumber)); uint256 disputeDeposit = disputeManager.disputeDeposit(); @@ -88,7 +92,7 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { fisherman, disputeDeposit, _allocationId, - _poi, + _poi, _blockNumber, stakeSnapshot, cancellableAt diff --git a/packages/subgraph-service/test/unit/disputeManager/disputes/indexing/create.t.sol b/packages/subgraph-service/test/unit/disputeManager/disputes/indexing/create.t.sol index 62b368835..6ebafebed 100644 --- a/packages/subgraph-service/test/unit/disputeManager/disputes/indexing/create.t.sol +++ b/packages/subgraph-service/test/unit/disputeManager/disputes/indexing/create.t.sol @@ -105,9 +105,7 @@ contract DisputeManagerIndexingCreateDisputeTest is DisputeManagerTest { vm.stopPrank(); } - function test_Indexing_Create_DisputesSamePOIAndAllo( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Indexing_Create_DisputesSamePOIAndAllo(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"), block.number); @@ -158,7 +156,10 @@ contract DisputeManagerIndexingCreateDisputeTest is DisputeManagerTest { disputeManager.createIndexingDispute(allocationID, bytes32("POI1"), block.number); } - function test_Indexing_Create_DontRevertIf_IndexerIsBelowStake_WithDelegation(uint256 tokens, uint256 delegationTokens) public useIndexer useAllocation(tokens) { + function test_Indexing_Create_DontRevertIf_IndexerIsBelowStake_WithDelegation( + uint256 tokens, + uint256 delegationTokens + ) public useIndexer useAllocation(tokens) { // Close allocation bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); diff --git a/packages/subgraph-service/test/unit/disputeManager/disputes/query/create.t.sol b/packages/subgraph-service/test/unit/disputeManager/disputes/query/create.t.sol index 94f2fe615..c2b8f1ab3 100644 --- a/packages/subgraph-service/test/unit/disputeManager/disputes/query/create.t.sol +++ b/packages/subgraph-service/test/unit/disputeManager/disputes/query/create.t.sol @@ -156,7 +156,10 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { disputeManager.createQueryDispute(attestationData); } - function test_Query_Create_DontRevertIf_IndexerIsBelowStake_WithDelegation(uint256 tokens, uint256 delegationTokens) public useIndexer useAllocation(tokens) { + function test_Query_Create_DontRevertIf_IndexerIsBelowStake_WithDelegation( + uint256 tokens, + uint256 delegationTokens + ) public useIndexer useAllocation(tokens) { // Close allocation bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); diff --git a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol new file mode 100644 index 000000000..4afc6707e --- /dev/null +++ b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; +import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol"; + +contract IndexingAgreementTest is Test { + function test_StorageManagerLocation() public pure { + assertEq( + IndexingAgreement.INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION, + keccak256( + abi.encode( + uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1 + ) + ) & ~bytes32(uint256(0xff)) + ); + } +} diff --git a/packages/subgraph-service/test/unit/shared/SubgraphServiceShared.t.sol b/packages/subgraph-service/test/unit/shared/SubgraphServiceShared.t.sol index 9c018d282..8a1c403bb 100644 --- a/packages/subgraph-service/test/unit/shared/SubgraphServiceShared.t.sol +++ b/packages/subgraph-service/test/unit/shared/SubgraphServiceShared.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.27; import "forge-std/Test.sol"; import { Allocation } from "../../../contracts/libraries/Allocation.sol"; -import { AllocationManager } from "../../../contracts/utilities/AllocationManager.sol"; +import { AllocationHandler } from "../../../contracts/libraries/AllocationHandler.sol"; import { IDataService } from "@graphprotocol/horizon/contracts/data-service/interfaces/IDataService.sol"; import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService.sol"; @@ -103,7 +103,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest { vm.expectEmit(address(subgraphService)); emit IDataService.ServiceStarted(_indexer, _data); - emit AllocationManager.AllocationCreated(_indexer, allocationId, subgraphDeploymentId, tokens, currentEpoch); + emit AllocationHandler.AllocationCreated(_indexer, allocationId, subgraphDeploymentId, tokens, currentEpoch); // TODO: improve this uint256 accRewardsPerAllocatedToken = 0; @@ -141,7 +141,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest { ); vm.expectEmit(address(subgraphService)); - emit AllocationManager.AllocationClosed( + emit AllocationHandler.AllocationClosed( _indexer, allocationId, allocation.subgraphDeploymentId, diff --git a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol index 3b1a74e18..4f3444c62 100644 --- a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol @@ -10,11 +10,11 @@ import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interface 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"; import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interfaces/internal/IHorizonStakingTypes.sol"; +import { StakeClaims } from "@graphprotocol/horizon/contracts/data-service/libraries/StakeClaims.sol"; import { Allocation } from "../../../contracts/libraries/Allocation.sol"; -import { AllocationManager } from "../../../contracts/utilities/AllocationManager.sol"; +import { AllocationHandler } from "../../../contracts/libraries/AllocationHandler.sol"; import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService.sol"; import { LegacyAllocation } from "../../../contracts/libraries/LegacyAllocation.sol"; import { SubgraphServiceSharedTest } from "../shared/SubgraphServiceShared.t.sol"; @@ -114,7 +114,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } vm.expectEmit(address(subgraphService)); - emit AllocationManager.AllocationResized( + emit AllocationHandler.AllocationResized( _indexer, _allocationId, subgraphDeploymentId, @@ -156,7 +156,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { ); vm.expectEmit(address(subgraphService)); - emit AllocationManager.AllocationClosed( + emit AllocationHandler.AllocationClosed( allocation.indexer, _allocationId, allocation.subgraphDeploymentId, @@ -205,7 +205,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { uint256 paymentCollected = 0; address allocationId; IndexingRewardsData memory indexingRewardsData; - CollectPaymentData memory collectPaymentDataBefore = _collectPaymentDataBefore(_indexer); + CollectPaymentData memory collectPaymentDataBefore = _collectPaymentData(_indexer); if (_paymentType == IGraphPayments.PaymentTypes.QueryFee) { paymentCollected = _handleQueryFeeCollection(_indexer, _data); @@ -219,7 +219,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { // collect rewards subgraphService.collect(_indexer, _paymentType, _data); - CollectPaymentData memory collectPaymentDataAfter = _collectPaymentDataAfter(_indexer); + CollectPaymentData memory collectPaymentDataAfter = _collectPaymentData(_indexer); if (_paymentType == IGraphPayments.PaymentTypes.QueryFee) { _verifyQueryFeeCollection( @@ -240,42 +240,24 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } } - function _collectPaymentDataBefore(address _indexer) private view returns (CollectPaymentData memory) { + function _collectPaymentData( + address _indexer + ) internal view returns (CollectPaymentData memory collectPaymentData) { address paymentsDestination = subgraphService.paymentsDestination(_indexer); - CollectPaymentData memory collectPaymentDataBefore; - collectPaymentDataBefore.rewardsDestinationBalance = token.balanceOf(paymentsDestination); - collectPaymentDataBefore.indexerProvisionBalance = staking.getProviderTokensAvailable( + collectPaymentData.rewardsDestinationBalance = token.balanceOf(paymentsDestination); + collectPaymentData.indexerProvisionBalance = staking.getProviderTokensAvailable( _indexer, address(subgraphService) ); - collectPaymentDataBefore.delegationPoolBalance = staking.getDelegatedTokensAvailable( + collectPaymentData.delegationPoolBalance = staking.getDelegatedTokensAvailable( _indexer, address(subgraphService) ); - collectPaymentDataBefore.indexerBalance = token.balanceOf(_indexer); - collectPaymentDataBefore.curationBalance = token.balanceOf(address(curation)); - collectPaymentDataBefore.lockedTokens = subgraphService.feesProvisionTracker(_indexer); - collectPaymentDataBefore.indexerStake = staking.getStake(_indexer); - return collectPaymentDataBefore; - } - - function _collectPaymentDataAfter(address _indexer) private view returns (CollectPaymentData memory) { - CollectPaymentData memory collectPaymentDataAfter; - address paymentsDestination = subgraphService.paymentsDestination(_indexer); - collectPaymentDataAfter.rewardsDestinationBalance = token.balanceOf(paymentsDestination); - collectPaymentDataAfter.indexerProvisionBalance = staking.getProviderTokensAvailable( - _indexer, - address(subgraphService) - ); - collectPaymentDataAfter.delegationPoolBalance = staking.getDelegatedTokensAvailable( - _indexer, - address(subgraphService) - ); - collectPaymentDataAfter.indexerBalance = token.balanceOf(_indexer); - collectPaymentDataAfter.curationBalance = token.balanceOf(address(curation)); - collectPaymentDataAfter.lockedTokens = subgraphService.feesProvisionTracker(_indexer); - collectPaymentDataAfter.indexerStake = staking.getStake(_indexer); - return collectPaymentDataAfter; + collectPaymentData.indexerBalance = token.balanceOf(_indexer); + collectPaymentData.curationBalance = token.balanceOf(address(curation)); + collectPaymentData.lockedTokens = subgraphService.feesProvisionTracker(_indexer); + collectPaymentData.indexerStake = staking.getStake(_indexer); + return collectPaymentData; } function _handleQueryFeeCollection( @@ -359,7 +341,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { indexingRewardsData.tokensIndexerRewards = paymentCollected - indexingRewardsData.tokensDelegationRewards; vm.expectEmit(address(subgraphService)); - emit AllocationManager.IndexingRewardsCollected( + emit AllocationHandler.IndexingRewardsCollected( allocation.indexer, allocationId, allocation.subgraphDeploymentId, @@ -381,7 +363,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { CollectPaymentData memory collectPaymentDataBefore, CollectPaymentData memory collectPaymentDataAfter ) private view { - (IGraphTallyCollector.SignedRAV memory signedRav, uint256 tokensToCollect) = abi.decode( + (IGraphTallyCollector.SignedRAV memory signedRav, ) = abi.decode( _data, (IGraphTallyCollector.SignedRAV, uint256) ); @@ -422,7 +404,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { // Check the stake claim LinkedList.List memory claimsList = _getClaimList(_indexer); bytes32 claimId = _buildStakeClaimId(_indexer, claimsList.nonce - 1); - IDataServiceFees.StakeClaim memory stakeClaim = _getStakeClaim(claimId); + StakeClaims.StakeClaim memory stakeClaim = _getStakeClaim(claimId); uint64 disputePeriod = disputeManager.getDisputePeriod(); assertEq(stakeClaim.tokens, tokensToLock); assertEq(stakeClaim.createdAt, block.timestamp); @@ -486,7 +468,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { function _migrateLegacyAllocation(address _indexer, address _allocationId, bytes32 _subgraphDeploymentID) internal { vm.expectEmit(address(subgraphService)); - emit AllocationManager.LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentID); + emit AllocationHandler.LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentID); subgraphService.migrateLegacyAllocation(_indexer, _allocationId, _subgraphDeploymentID); @@ -531,12 +513,12 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } function _buildStakeClaimId(address _indexer, uint256 _nonce) private view returns (bytes32) { - return keccak256(abi.encodePacked(address(subgraphService), _indexer, _nonce)); + return StakeClaims.buildStakeClaimId(address(subgraphService), _indexer, _nonce); } - function _getStakeClaim(bytes32 _claimId) private view returns (IDataServiceFees.StakeClaim memory) { + function _getStakeClaim(bytes32 _claimId) private view returns (StakeClaims.StakeClaim memory) { (uint256 tokens, uint256 createdAt, uint256 releasableAt, bytes32 nextClaim) = subgraphService.claims(_claimId); - return IDataServiceFees.StakeClaim(tokens, createdAt, releasableAt, nextClaim); + return StakeClaims.StakeClaim(tokens, createdAt, releasableAt, nextClaim); } // This doesn't matter for testing because the metadata is not decoded onchain but it's expected to be of the form: diff --git a/packages/subgraph-service/test/unit/subgraphService/allocation/resize.t.sol b/packages/subgraph-service/test/unit/subgraphService/allocation/resize.t.sol index c9984bdba..ad70e3abc 100644 --- a/packages/subgraph-service/test/unit/subgraphService/allocation/resize.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/allocation/resize.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.27; import "forge-std/Test.sol"; import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; -import { AllocationManager } from "../../../../contracts/utilities/AllocationManager.sol"; +import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol"; import { SubgraphServiceTest } from "../SubgraphService.t.sol"; import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; @@ -86,7 +86,7 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { uint256 tokens ) public useIndexer useAllocation(tokens) { vm.expectRevert( - abi.encodeWithSelector(AllocationManager.AllocationManagerAllocationSameSize.selector, allocationID, tokens) + abi.encodeWithSelector(AllocationHandler.AllocationHandlerAllocationSameSize.selector, allocationID, tokens) ); subgraphService.resizeAllocation(users.indexer, allocationID, tokens); } @@ -99,7 +99,7 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); vm.expectRevert( - abi.encodeWithSelector(AllocationManager.AllocationManagerAllocationClosed.selector, allocationID) + abi.encodeWithSelector(AllocationHandler.AllocationHandlerAllocationClosed.selector, allocationID) ); subgraphService.resizeAllocation(users.indexer, allocationID, resizeTokens); } diff --git a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol index 2f132e132..0a762e958 100644 --- a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol @@ -8,7 +8,7 @@ import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/ import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol"; import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; -import { AllocationManager } from "../../../../contracts/utilities/AllocationManager.sol"; +import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol"; import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; import { LegacyAllocation } from "../../../../contracts/libraries/LegacyAllocation.sol"; import { SubgraphServiceTest } from "../SubgraphService.t.sol"; @@ -97,7 +97,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { bytes32 digest = subgraphService.encodeAllocationProof(users.indexer, address(0)); (uint8 v, bytes32 r, bytes32 s) = vm.sign(allocationIDPrivateKey, digest); bytes memory data = abi.encode(subgraphDeployment, tokens, address(0), abi.encodePacked(r, s, v)); - vm.expectRevert(abi.encodeWithSelector(AllocationManager.AllocationManagerInvalidZeroAllocationId.selector)); + vm.expectRevert(abi.encodeWithSelector(AllocationHandler.AllocationHandlerInvalidZeroAllocationId.selector)); subgraphService.startService(users.indexer, data); } @@ -113,7 +113,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { bytes memory data = abi.encode(subgraphDeployment, tokens, allocationID, abi.encodePacked(r, s, v)); vm.expectRevert( abi.encodeWithSelector( - AllocationManager.AllocationManagerInvalidAllocationProof.selector, + AllocationHandler.AllocationHandlerInvalidAllocationProof.selector, signer, allocationID ) diff --git a/packages/subgraph-service/test/unit/subgraphService/allocation/stop.t.sol b/packages/subgraph-service/test/unit/subgraphService/allocation/stop.t.sol index 2c4391cb2..456ed081f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/allocation/stop.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/allocation/stop.t.sol @@ -8,7 +8,6 @@ import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/ import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol"; import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; -import { AllocationManager } from "../../../../contracts/utilities/AllocationManager.sol"; import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; import { LegacyAllocation } from "../../../../contracts/libraries/LegacyAllocation.sol"; import { SubgraphServiceTest } from "../SubgraphService.t.sol"; diff --git a/packages/subgraph-service/test/unit/subgraphService/collect/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/collect/collect.t.sol deleted file mode 100644 index aff11d578..000000000 --- a/packages/subgraph-service/test/unit/subgraphService/collect/collect.t.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; - -import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; -import { SubgraphServiceTest } from "../SubgraphService.t.sol"; - -contract SubgraphServiceCollectTest is SubgraphServiceTest { - /* - * TESTS - */ - - function test_SubgraphService_Collect_RevertWhen_InvalidPayment( - uint256 tokens - ) public useIndexer useAllocation(tokens) { - IGraphPayments.PaymentTypes invalidPaymentType = IGraphPayments.PaymentTypes.IndexingFee; - vm.expectRevert( - abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidPaymentType.selector, invalidPaymentType) - ); - subgraphService.collect(users.indexer, invalidPaymentType, ""); - } -} diff --git a/packages/subgraph-service/test/unit/subgraphService/collect/indexing/indexing.t.sol b/packages/subgraph-service/test/unit/subgraphService/collect/indexing/indexing.t.sol index c97416157..a1beb5f30 100644 --- a/packages/subgraph-service/test/unit/subgraphService/collect/indexing/indexing.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/collect/indexing/indexing.t.sol @@ -172,7 +172,9 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { subgraphService.collect(newIndexer, paymentType, data); } - function test_SubgraphService_Collect_Indexing_RevertWhen_IncorrectPaymentType(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Collect_Indexing_RevertWhen_IncorrectPaymentType( + uint256 tokens + ) public useIndexer useAllocation(tokens) { bytes memory data = abi.encode(allocationID, bytes32("POI"), _getHardcodedPOIMetadata()); // skip time to ensure allocation gets rewards diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol new file mode 100644 index 000000000..29f83126c --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; + +import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; +import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol"; +import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol"; +import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenPaused( + address allocationId, + address operator, + IRecurringCollector.SignedRCA calldata signedRCA + ) public withSafeIndexerOrOperator(operator) { + resetPrank(users.pauseGuardian); + subgraphService.pause(); + + resetPrank(operator); + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenNotAuthorized( + address allocationId, + address operator, + IRecurringCollector.SignedRCA calldata signedRCA + ) public withSafeIndexerOrOperator(operator) { + vm.assume(operator != signedRCA.rca.serviceProvider); + resetPrank(operator); + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + signedRCA.rca.serviceProvider, + operator + ); + vm.expectRevert(expectedErr); + subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidProvision( + address indexer, + uint256 unboundedTokens, + address allocationId, + IRecurringCollector.SignedRCA memory signedRCA + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + + signedRCA.rca.serviceProvider = indexer; + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "tokens", + tokens, + minimumProvisionTokens, + maximumProvisionTokens + ); + vm.expectRevert(expectedErr); + subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenIndexerNotRegistered( + address indexer, + uint256 unboundedTokens, + address allocationId, + IRecurringCollector.SignedRCA memory signedRCA + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + signedRCA.rca.serviceProvider = indexer; + bytes memory expectedErr = abi.encodeWithSelector( + ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, + indexer + ); + vm.expectRevert(expectedErr); + subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenNotDataService( + Seed memory seed, + address incorrectDataService + ) public { + vm.assume(incorrectDataService != address(subgraphService)); + + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + acceptable.rca.dataService = incorrectDataService; + IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( + acceptable.rca, + ctx.payer.signerPrivateKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementWrongDataService.selector, + address(subgraphService), + unacceptable.rca.dataService + ); + vm.expectRevert(expectedErr); + vm.prank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + acceptable.rca.metadata = bytes("invalid"); + IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( + acceptable.rca, + ctx.payer.signerPrivateKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, + "decodeRCAMetadata", + unacceptable.rca.metadata + ); + vm.expectRevert(expectedErr); + vm.prank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidAllocation( + Seed memory seed, + address invalidAllocationId + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + + bytes memory expectedErr = abi.encodeWithSelector( + Allocation.AllocationDoesNotExist.selector, + invalidAllocationId + ); + vm.expectRevert(expectedErr); + vm.prank(indexerState.addr); + subgraphService.acceptIndexingAgreement(invalidAllocationId, acceptable); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAllocationNotAuthorized(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerStateA = _withIndexer(ctx); + IndexerState memory indexerStateB = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptableA = _generateAcceptableSignedRCA(ctx, indexerStateA.addr); + + bytes memory expectedErr = abi.encodeWithSelector( + ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, + indexerStateA.addr, + indexerStateB.allocationId + ); + vm.expectRevert(expectedErr); + vm.prank(indexerStateA.addr); + subgraphService.acceptIndexingAgreement(indexerStateB.allocationId, acceptableA); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAllocationClosed(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + + resetPrank(indexerState.addr); + subgraphService.stopService(indexerState.addr, abi.encode(indexerState.allocationId)); + + bytes memory expectedErr = abi.encodeWithSelector( + AllocationHandler.AllocationHandlerAllocationClosed.selector, + indexerState.allocationId + ); + vm.expectRevert(expectedErr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenDeploymentIdMismatch( + Seed memory seed, + bytes32 wrongSubgraphDeploymentId + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + vm.assume(indexerState.subgraphDeploymentId != wrongSubgraphDeploymentId); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + acceptable.rca.metadata = abi.encode(_newAcceptIndexingAgreementMetadataV1(wrongSubgraphDeploymentId)); + IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( + acceptable.rca, + ctx.payer.signerPrivateKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementDeploymentIdMismatch.selector, + wrongSubgraphDeploymentId, + indexerState.allocationId, + indexerState.subgraphDeploymentId + ); + vm.expectRevert(expectedErr); + vm.prank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAccepted(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementAlreadyAccepted.selector, + accepted.rca.agreementId + ); + vm.expectRevert(expectedErr); + resetPrank(ctx.indexers[0].addr); + subgraphService.acceptIndexingAgreement(ctx.indexers[0].allocationId, accepted); + } + + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated() public {} + + function test_SubgraphService_AcceptIndexingAgreement(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = abi.decode( + acceptable.rca.metadata, + (IndexingAgreement.AcceptIndexingAgreementMetadata) + ); + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementAccepted( + acceptable.rca.serviceProvider, + acceptable.rca.payer, + acceptable.rca.agreementId, + indexerState.allocationId, + metadata.subgraphDeploymentId, + metadata.version, + metadata.terms + ); + + resetPrank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + } + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol new file mode 100644 index 000000000..822cc21d7 --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_Revert_WhenUnsafeAddress_WhenProxyAdmin(address indexer, bytes16 agreementId) public { + address operator = _transparentUpgradeableProxyAdmin(); + assertFalse(_isSafeSubgraphServiceCaller(operator)); + + vm.expectRevert(TransparentUpgradeableProxy.ProxyDeniedAdminAccess.selector); + resetPrank(address(operator)); + subgraphService.cancelIndexingAgreement(indexer, agreementId); + } + + function test_SubgraphService_Revert_WhenUnsafeAddress_WhenGraphProxyAdmin(uint256 unboundedTokens) public { + address indexer = GRAPH_PROXY_ADMIN_ADDRESS; + assertFalse(_isSafeSubgraphServiceCaller(indexer)); + + uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS); + mint(indexer, tokens); + resetPrank(indexer); + vm.expectRevert("Cannot fallback to proxy target"); + staking.provision(indexer, address(subgraphService), tokens, maxSlashingPercentage, disputePeriod); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol new file mode 100644 index 000000000..60a28169c --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -0,0 +1,215 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; + +import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenPaused( + address rando, + bytes16 agreementId + ) public withSafeIndexerOrOperator(rando) { + resetPrank(users.pauseGuardian); + subgraphService.pause(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + resetPrank(rando); + subgraphService.cancelIndexingAgreementByPayer(agreementId); + } + + function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenNotAuthorized( + Seed memory seed, + address rando + ) public withSafeIndexerOrOperator(rando) { + Context storage ctx = _newCtx(seed); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNonCancelableBy.selector, + accepted.rca.payer, + rando + ); + vm.expectRevert(expectedErr); + resetPrank(rando); + subgraphService.cancelIndexingAgreementByPayer(accepted.rca.agreementId); + } + + function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenNotAccepted( + Seed memory seed, + bytes16 agreementId + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + + resetPrank(indexerState.addr); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotActive.selector, + agreementId + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreementByPayer(agreementId); + } + + function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenCanceled( + Seed memory seed, + bool cancelSource + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + IRecurringCollector.CancelAgreementBy by = cancelSource + ? IRecurringCollector.CancelAgreementBy.ServiceProvider + : IRecurringCollector.CancelAgreementBy.Payer; + _cancelAgreement(ctx, accepted.rca.agreementId, indexerState.addr, accepted.rca.payer, by); + + resetPrank(indexerState.addr); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotActive.selector, + accepted.rca.agreementId + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreementByPayer(accepted.rca.agreementId); + } + + function test_SubgraphService_CancelIndexingAgreementByPayer(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + + _cancelAgreement( + ctx, + accepted.rca.agreementId, + accepted.rca.serviceProvider, + accepted.rca.payer, + IRecurringCollector.CancelAgreementBy.Payer + ); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenPaused( + address operator, + address indexer, + bytes16 agreementId + ) public withSafeIndexerOrOperator(operator) { + resetPrank(users.pauseGuardian); + subgraphService.pause(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + resetPrank(operator); + subgraphService.cancelIndexingAgreement(indexer, agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotAuthorized( + address operator, + address indexer, + bytes16 agreementId + ) public withSafeIndexerOrOperator(operator) { + vm.assume(operator != indexer); + resetPrank(operator); + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + indexer, + operator + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreement(indexer, agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenInvalidProvision( + address indexer, + bytes16 agreementId, + uint256 unboundedTokens + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "tokens", + tokens, + minimumProvisionTokens, + maximumProvisionTokens + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreement(indexer, agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenIndexerNotRegistered( + address indexer, + bytes16 agreementId, + uint256 unboundedTokens + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + bytes memory expectedErr = abi.encodeWithSelector( + ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, + indexer + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreement(indexer, agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotAccepted( + Seed memory seed, + bytes16 agreementId + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + + resetPrank(indexerState.addr); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotActive.selector, + agreementId + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreement(indexerState.addr, agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenCanceled( + Seed memory seed, + bool cancelSource + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + IRecurringCollector.CancelAgreementBy by = cancelSource + ? IRecurringCollector.CancelAgreementBy.ServiceProvider + : IRecurringCollector.CancelAgreementBy.Payer; + _cancelAgreement(ctx, accepted.rca.agreementId, accepted.rca.serviceProvider, accepted.rca.payer, by); + + resetPrank(indexerState.addr); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotActive.selector, + accepted.rca.agreementId + ); + vm.expectRevert(expectedErr); + subgraphService.cancelIndexingAgreement(indexerState.addr, accepted.rca.agreementId); + } + + function test_SubgraphService_CancelIndexingAgreement_OK(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + + _cancelAgreement( + ctx, + accepted.rca.agreementId, + accepted.rca.serviceProvider, + accepted.rca.payer, + IRecurringCollector.CancelAgreementBy.ServiceProvider + ); + } + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol new file mode 100644 index 000000000..85c203b6e --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { IPaymentsCollector } from "@graphprotocol/horizon/contracts/interfaces/IPaymentsCollector.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; + +import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; +import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; +import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol"; +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_CollectIndexingFees_OK( + Seed memory seed, + uint256 entities, + bytes32 poi, + uint256 unboundedTokensCollected + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + assertEq(subgraphService.feesProvisionTracker(indexerState.addr), 0, "Should be 0 before collect"); + + resetPrank(indexerState.addr); + subgraphService.setPaymentsDestination(indexerState.addr); + + bytes memory data = abi.encode( + IRecurringCollector.CollectParams({ + agreementId: accepted.rca.agreementId, + collectionId: bytes32(uint256(uint160(indexerState.allocationId))), + tokens: 0, + dataServiceCut: 0, + receiverDestination: indexerState.addr + }) + ); + uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / stakeToFeesRatio); + vm.mockCall( + address(recurringCollector), + abi.encodeWithSelector(IPaymentsCollector.collect.selector, IGraphPayments.PaymentTypes.IndexingFee, data), + abi.encode(tokensCollected) + ); + vm.expectCall( + address(recurringCollector), + abi.encodeCall(IPaymentsCollector.collect, (IGraphPayments.PaymentTypes.IndexingFee, data)) + ); + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingFeesCollectedV1( + indexerState.addr, + accepted.rca.payer, + accepted.rca.agreementId, + indexerState.allocationId, + indexerState.subgraphDeploymentId, + epochManager.currentEpoch(), + tokensCollected, + entities, + poi, + epochManager.currentEpochBlock(), + bytes("") + ); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, epochManager.currentEpochBlock(), bytes("")) + ); + + assertEq( + subgraphService.feesProvisionTracker(indexerState.addr), + tokensCollected * stakeToFeesRatio, + "Should be exactly locked tokens" + ); + } + + function test_SubgraphService_CollectIndexingFees_Revert_WhenPaused( + address indexer, + bytes16 agreementId, + uint256 entities, + bytes32 poi + ) public withSafeIndexerOrOperator(indexer) { + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + resetPrank(users.pauseGuardian); + subgraphService.pause(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + resetPrank(indexer); + subgraphService.collect( + indexer, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Revert_WhenNotAuthorized( + address operator, + address indexer, + bytes16 agreementId, + uint256 entities, + bytes32 poi + ) public withSafeIndexerOrOperator(operator) { + vm.assume(operator != indexer); + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + resetPrank(operator); + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + indexer, + operator + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexer, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Revert_WhenInvalidProvision( + uint256 unboundedTokens, + address indexer, + bytes16 agreementId, + uint256 entities, + bytes32 poi + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1); + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "tokens", + tokens, + minimumProvisionTokens, + maximumProvisionTokens + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexer, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Revert_WhenIndexerNotRegistered( + uint256 unboundedTokens, + address indexer, + bytes16 agreementId, + uint256 entities, + bytes32 poi + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS); + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + bytes memory expectedErr = abi.encodeWithSelector( + ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, + indexer + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexer, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Revert_WhenInvalidAgreement( + Seed memory seed, + bytes16 agreementId, + uint256 entities, + bytes32 poi + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + + bytes memory expectedErr = abi.encodeWithSelector(Allocation.AllocationDoesNotExist.selector, address(0)); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Reverts_WhenStopService( + Seed memory seed, + uint256 entities, + bytes32 poi + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + resetPrank(indexerState.addr); + subgraphService.stopService(indexerState.addr, abi.encode(indexerState.allocationId)); + + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + + bytes memory expectedErr = abi.encodeWithSelector( + AllocationHandler.AllocationHandlerAllocationClosed.selector, + indexerState.allocationId + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + + function test_SubgraphService_CollectIndexingFees_Reverts_WhenCloseStaleAllocation( + Seed memory seed, + uint256 entities, + bytes32 poi + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + skip(maxPOIStaleness + 1); + resetPrank(indexerState.addr); + subgraphService.closeStaleAllocation(indexerState.allocationId); + + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + + bytes memory expectedErr = abi.encodeWithSelector( + AllocationHandler.AllocationHandlerAllocationClosed.selector, + indexerState.allocationId + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol new file mode 100644 index 000000000..433ee0103 --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; +import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; + +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndexingAgreementSharedTest { + using PPMMath for uint256; + + struct TestState { + uint256 escrowBalance; + uint256 indexerBalance; + uint256 indexerTokensLocked; + } + + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_CollectIndexingFee_Integration( + Seed memory seed, + uint256 fuzzyTokensCollected + ) public { + uint256 expectedTotalTokensCollected = bound(fuzzyTokensCollected, 1000, 1_000_000); + uint256 expectedTokensLocked = stakeToFeesRatio * expectedTotalTokensCollected; + uint256 expectedProtocolTokensBurnt = expectedTotalTokensCollected.mulPPMRoundUp( + graphPayments.PROTOCOL_PAYMENT_CUT() + ); + uint256 expectedIndexerTokensCollected = expectedTotalTokensCollected - expectedProtocolTokensBurnt; + + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + _addTokensToProvision(indexerState, expectedTokensLocked); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + ctx.ctxInternal.seed.rca + ); + uint256 agreementTokensPerSecond = 1; + rca.deadline = uint64(block.timestamp); // accept now + rca.endsAt = type(uint64).max; // no expiration + rca.maxInitialTokens = 0; // no initial payment + rca.maxOngoingTokensPerSecond = type(uint32).max; // unlimited tokens per second + rca.minSecondsPerCollection = 1; // 1 second between collections + rca.maxSecondsPerCollection = type(uint32).max; // no maximum time between collections + rca.serviceProvider = indexerState.addr; // service provider is the indexer + rca.dataService = address(subgraphService); // data service is the subgraph service + rca.metadata = _encodeAcceptIndexingAgreementMetadataV1( + indexerState.subgraphDeploymentId, + IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: agreementTokensPerSecond, + tokensPerEntityPerSecond: 0 // no payment for entities + }) + ); + + _setupPayerWithEscrow(rca.payer, ctx.payer.signerPrivateKey, indexerState.addr, expectedTotalTokensCollected); + + resetPrank(indexerState.addr); + // Set the payments destination to the indexer address + subgraphService.setPaymentsDestination(indexerState.addr); + // Accept the Indexing Agreement + subgraphService.acceptIndexingAgreement( + indexerState.allocationId, + _recurringCollectorHelper.generateSignedRCA(rca, ctx.payer.signerPrivateKey) + ); + // Skip ahead to collection point + skip(expectedTotalTokensCollected / agreementTokensPerSecond); + // vm.assume(block.timestamp < type(uint64).max); + TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); + bytes16 agreementId = rca.agreementId; + uint256 tokensCollected = subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1( + agreementId, + 1, + keccak256(abi.encodePacked("poi")), + epochManager.currentEpochBlock(), + bytes("") + ) + ); + TestState memory afterCollect = _getState(rca.payer, indexerState.addr); + uint256 indexerTokensCollected = afterCollect.indexerBalance - beforeCollect.indexerBalance; + uint256 protocolTokensBurnt = tokensCollected - indexerTokensCollected; + assertEq( + afterCollect.escrowBalance, + beforeCollect.escrowBalance - tokensCollected, + "Escrow balance should be reduced by the amount collected" + ); + assertEq(tokensCollected, expectedTotalTokensCollected, "Total tokens collected should match"); + assertEq(expectedProtocolTokensBurnt, protocolTokensBurnt, "Protocol tokens burnt should match"); + assertEq(indexerTokensCollected, expectedIndexerTokensCollected, "Indexer tokens collected should match"); + assertEq( + afterCollect.indexerTokensLocked, + beforeCollect.indexerTokensLocked + expectedTokensLocked, + "Locked tokens should match" + ); + } + + /* solhint-enable graph/func-name-mixedcase */ + + function _addTokensToProvision(IndexerState memory _indexerState, uint256 _tokensToAddToProvision) private { + deal({ token: address(token), to: _indexerState.addr, give: _tokensToAddToProvision }); + vm.startPrank(_indexerState.addr); + _addToProvision(_indexerState.addr, _tokensToAddToProvision); + vm.stopPrank(); + } + + function _setupPayerWithEscrow( + address _payer, + uint256 _signerPrivateKey, + address _indexer, + uint256 _escrowTokens + ) private { + _recurringCollectorHelper.authorizeSignerWithChecks(_payer, _signerPrivateKey); + + deal({ token: address(token), to: _payer, give: _escrowTokens }); + vm.startPrank(_payer); + _escrow(_escrowTokens, _indexer); + vm.stopPrank(); + } + + function _escrow(uint256 _tokens, address _indexer) private { + token.approve(address(escrow), _tokens); + escrow.deposit(address(recurringCollector), _indexer, _tokens); + } + + function _getState(address _payer, address _indexer) private view returns (TestState memory) { + CollectPaymentData memory collect = _collectPaymentData(_indexer); + + return + TestState({ + escrowBalance: escrow.getBalance(_payer, address(recurringCollector), _indexer), + indexerBalance: collect.indexerBalance, + indexerTokensLocked: collect.lockedTokens + }); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol new file mode 100644 index 000000000..8574e60e7 --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; + +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; + +import { Bounder } from "@graphprotocol/horizon/test/unit/utils/Bounder.t.sol"; +import { RecurringCollectorHelper } from "@graphprotocol/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol"; +import { SubgraphServiceTest } from "../SubgraphService.t.sol"; + +contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Bounder { + struct Context { + PayerState payer; + IndexerState[] indexers; + mapping(address allocationId => address indexer) allocations; + ContextInternal ctxInternal; + } + + struct IndexerState { + address addr; + address allocationId; + bytes32 subgraphDeploymentId; + uint256 tokens; + } + + struct PayerState { + address signer; + uint256 signerPrivateKey; + } + + struct ContextInternal { + IndexerSeed[] indexers; + Seed seed; + bool initialized; + } + + struct Seed { + IndexerSeed indexer0; + IndexerSeed indexer1; + IRecurringCollector.RecurringCollectionAgreement rca; + IRecurringCollector.RecurringCollectionAgreementUpdate rcau; + IndexingAgreement.IndexingAgreementTermsV1 termsV1; + PayerSeed payer; + } + + struct IndexerSeed { + address addr; + string label; + uint256 unboundedProvisionTokens; + uint256 unboundedAllocationPrivateKey; + bytes32 subgraphDeploymentId; + } + + struct PayerSeed { + uint256 unboundedSignerPrivateKey; + } + + Context internal _context; + + bytes32 internal constant TRANSPARENT_UPGRADEABLE_PROXY_ADMIN_ADDRESS_SLOT = + 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + address internal constant GRAPH_PROXY_ADMIN_ADDRESS = 0x15c603B7eaA8eE1a272a69C4af3462F926de777F; + + RecurringCollectorHelper internal _recurringCollectorHelper; + + modifier withSafeIndexerOrOperator(address operator) { + vm.assume(_isSafeSubgraphServiceCaller(operator)); + _; + } + + function setUp() public override { + super.setUp(); + + _recurringCollectorHelper = new RecurringCollectorHelper(recurringCollector); + } + + /* + * HELPERS + */ + + function _subgraphServiceSafePrank(address _addr) internal returns (address) { + address originalPrankAddress = msg.sender; + vm.assume(_isSafeSubgraphServiceCaller(_addr)); + resetPrank(_addr); + + return originalPrankAddress; + } + + function _stopOrResetPrank(address _originalSender) internal { + if (_originalSender == 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38) { + vm.stopPrank(); + } else { + resetPrank(_originalSender); + } + } + + function _cancelAgreement( + Context storage _ctx, + bytes16 _agreementId, + address _indexer, + address _payer, + IRecurringCollector.CancelAgreementBy _by + ) internal { + bool byIndexer = _by == IRecurringCollector.CancelAgreementBy.ServiceProvider; + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementCanceled(_indexer, _payer, _agreementId, byIndexer ? _indexer : _payer); + + if (byIndexer) { + _subgraphServiceSafePrank(_indexer); + subgraphService.cancelIndexingAgreement(_indexer, _agreementId); + } else { + _subgraphServiceSafePrank(_ctx.payer.signer); + subgraphService.cancelIndexingAgreementByPayer(_agreementId); + } + } + + function _withIndexer(Context storage _ctx) internal returns (IndexerState memory) { + require(_ctx.ctxInternal.indexers.length > 0, "No indexer seeds available"); + + IndexerSeed memory indexerSeed = _ctx.ctxInternal.indexers[_ctx.ctxInternal.indexers.length - 1]; + _ctx.ctxInternal.indexers.pop(); + + indexerSeed.label = string.concat("_withIndexer-", Strings.toString(_ctx.ctxInternal.indexers.length)); + + return _setupIndexer(_ctx, indexerSeed); + } + + function _setupIndexer(Context storage _ctx, IndexerSeed memory _seed) internal returns (IndexerState memory) { + vm.assume(_getIndexer(_ctx, _seed.addr).addr == address(0)); + + (uint256 allocationKey, address allocationId) = boundKeyAndAddr(_seed.unboundedAllocationPrivateKey); + vm.assume(_ctx.allocations[allocationId] == address(0)); + _ctx.allocations[allocationId] = _seed.addr; + + uint256 tokens = bound(_seed.unboundedProvisionTokens, minimumProvisionTokens, MAX_TOKENS); + + IndexerState memory indexer = IndexerState({ + addr: _seed.addr, + allocationId: allocationId, + subgraphDeploymentId: _seed.subgraphDeploymentId, + tokens: tokens + }); + vm.label(indexer.addr, string.concat("_setupIndexer-", _seed.label)); + + // Mint tokens to the indexer + mint(_seed.addr, tokens); + + // Create the indexer + address originalPrank = _subgraphServiceSafePrank(indexer.addr); + _createProvision(indexer.addr, indexer.tokens, fishermanRewardPercentage, disputePeriod); + _register(indexer.addr, abi.encode("url", "geoHash", address(0))); + bytes memory data = _createSubgraphAllocationData( + indexer.addr, + indexer.subgraphDeploymentId, + allocationKey, + indexer.tokens + ); + _startService(indexer.addr, data); + + _ctx.indexers.push(indexer); + + _stopOrResetPrank(originalPrank); + + return indexer; + } + + function _withAcceptedIndexingAgreement( + Context storage _ctx, + IndexerState memory _indexerState + ) internal returns (IRecurringCollector.SignedRCA memory) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _ctx.ctxInternal.seed.rca; + + IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = _newAcceptIndexingAgreementMetadataV1( + _indexerState.subgraphDeploymentId + ); + rca.serviceProvider = _indexerState.addr; + rca.dataService = address(subgraphService); + rca.metadata = abi.encode(metadata); + + rca = _recurringCollectorHelper.sensibleRCA(rca); + + IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA( + rca, + _ctx.payer.signerPrivateKey + ); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, _ctx.payer.signerPrivateKey); + + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementAccepted( + rca.serviceProvider, + rca.payer, + rca.agreementId, + _indexerState.allocationId, + metadata.subgraphDeploymentId, + metadata.version, + metadata.terms + ); + _subgraphServiceSafePrank(_indexerState.addr); + subgraphService.acceptIndexingAgreement(_indexerState.allocationId, signedRCA); + + return signedRCA; + } + + function _newCtx(Seed memory _seed) internal returns (Context storage) { + require(_context.ctxInternal.initialized == false, "Context already initialized"); + Context storage ctx = _context; + + // Initialize + ctx.ctxInternal.initialized = true; + + // Setup seeds + ctx.ctxInternal.seed = _seed; + ctx.ctxInternal.indexers.push(_seed.indexer0); + ctx.ctxInternal.indexers.push(_seed.indexer1); + + // Setup payer + ctx.payer.signerPrivateKey = boundKey(ctx.ctxInternal.seed.payer.unboundedSignerPrivateKey); + ctx.payer.signer = vm.addr(ctx.payer.signerPrivateKey); + + return ctx; + } + + function _generateAcceptableSignedRCA( + Context storage _ctx, + address _indexerAddress + ) internal returns (IRecurringCollector.SignedRCA memory) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _generateAcceptableRecurringCollectionAgreement( + _ctx, + _indexerAddress + ); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, _ctx.payer.signerPrivateKey); + + return _recurringCollectorHelper.generateSignedRCA(rca, _ctx.payer.signerPrivateKey); + } + + function _generateAcceptableRecurringCollectionAgreement( + Context storage _ctx, + address _indexerAddress + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + IndexerState memory indexer = _requireIndexer(_ctx, _indexerAddress); + IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = _newAcceptIndexingAgreementMetadataV1( + indexer.subgraphDeploymentId + ); + IRecurringCollector.RecurringCollectionAgreement memory rca = _ctx.ctxInternal.seed.rca; + rca.serviceProvider = indexer.addr; + rca.dataService = address(subgraphService); + rca.metadata = abi.encode(metadata); + + return _recurringCollectorHelper.sensibleRCA(rca); + } + + function _generateAcceptableSignedRCAU( + Context storage _ctx, + IRecurringCollector.RecurringCollectionAgreement memory _rca + ) internal view returns (IRecurringCollector.SignedRCAU memory) { + return + _recurringCollectorHelper.generateSignedRCAU( + _generateAcceptableRecurringCollectionAgreementUpdate(_ctx, _rca), + _ctx.payer.signerPrivateKey + ); + } + + function _generateAcceptableRecurringCollectionAgreementUpdate( + Context storage _ctx, + IRecurringCollector.RecurringCollectionAgreement memory _rca + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _ctx.ctxInternal.seed.rcau; + rcau.agreementId = _rca.agreementId; + rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( + _newUpdateIndexingAgreementMetadataV1( + _ctx.ctxInternal.seed.termsV1.tokensPerSecond, + _ctx.ctxInternal.seed.termsV1.tokensPerEntityPerSecond + ) + ); + return _recurringCollectorHelper.sensibleRCAU(rcau); + } + + function _requireIndexer(Context storage _ctx, address _indexer) internal view returns (IndexerState memory) { + IndexerState memory indexerState = _getIndexer(_ctx, _indexer); + require(indexerState.addr != address(0), "Indexer not found in context"); + + return indexerState; + } + + function _getIndexer(Context storage _ctx, address _indexer) internal view returns (IndexerState memory zero) { + for (uint256 i = 0; i < _ctx.indexers.length; i++) { + if (_ctx.indexers[i].addr == _indexer) { + return _ctx.indexers[i]; + } + } + + return zero; + } + + function _isSafeSubgraphServiceCaller(address _candidate) internal view returns (bool) { + return + _candidate != address(0) && + _candidate != address(_transparentUpgradeableProxyAdmin()) && + _candidate != address(proxyAdmin); + } + + function _transparentUpgradeableProxyAdmin() internal view returns (address) { + return + address( + uint160(uint256(vm.load(address(subgraphService), TRANSPARENT_UPGRADEABLE_PROXY_ADMIN_ADDRESS_SLOT))) + ); + } + + function _newAcceptIndexingAgreementMetadataV1( + bytes32 _subgraphDeploymentId + ) internal pure returns (IndexingAgreement.AcceptIndexingAgreementMetadata memory) { + return + IndexingAgreement.AcceptIndexingAgreementMetadata({ + subgraphDeploymentId: _subgraphDeploymentId, + version: IndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode( + IndexingAgreement.IndexingAgreementTermsV1({ tokensPerSecond: 0, tokensPerEntityPerSecond: 0 }) + ) + }); + } + + function _newUpdateIndexingAgreementMetadataV1( + uint256 _tokensPerSecond, + uint256 _tokensPerEntityPerSecond + ) internal pure returns (IndexingAgreement.UpdateIndexingAgreementMetadata memory) { + return + IndexingAgreement.UpdateIndexingAgreementMetadata({ + version: IndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode( + IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: _tokensPerSecond, + tokensPerEntityPerSecond: _tokensPerEntityPerSecond + }) + ) + }); + } + + function _encodeCollectDataV1( + bytes16 _agreementId, + uint256 _entities, + bytes32 _poi, + uint256 _poiBlock, + bytes memory _metadata + ) internal pure returns (bytes memory) { + return + abi.encode( + _agreementId, + abi.encode( + IndexingAgreement.CollectIndexingFeeDataV1({ + entities: _entities, + poi: _poi, + poiBlockNumber: _poiBlock, + metadata: _metadata + }) + ) + ); + } + + function _encodeAcceptIndexingAgreementMetadataV1( + bytes32 _subgraphDeploymentId, + IndexingAgreement.IndexingAgreementTermsV1 memory _terms + ) internal pure returns (bytes memory) { + return + abi.encode( + IndexingAgreement.AcceptIndexingAgreementMetadata({ + subgraphDeploymentId: _subgraphDeploymentId, + version: IndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode(_terms) + }) + ); + } + + function _encodeUpdateIndexingAgreementMetadataV1( + IndexingAgreement.UpdateIndexingAgreementMetadata memory _t + ) internal pure returns (bytes memory) { + return abi.encode(_t); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol new file mode 100644 index 000000000..336ef97de --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; + +import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol"; +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; +import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; + +contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_UpdateIndexingAgreementIndexingAgreement_Revert_WhenPaused( + address operator, + IRecurringCollector.SignedRCAU calldata signedRCAU + ) public withSafeIndexerOrOperator(operator) { + resetPrank(users.pauseGuardian); + subgraphService.pause(); + + resetPrank(operator); + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + subgraphService.updateIndexingAgreement(operator, signedRCAU); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorized( + address indexer, + address notAuthorized, + IRecurringCollector.SignedRCAU calldata signedRCAU + ) public withSafeIndexerOrOperator(notAuthorized) { + vm.assume(notAuthorized != indexer); + resetPrank(notAuthorized); + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + indexer, + notAuthorized + ); + vm.expectRevert(expectedErr); + subgraphService.updateIndexingAgreement(indexer, signedRCAU); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidProvision( + address indexer, + uint256 unboundedTokens, + IRecurringCollector.SignedRCAU memory signedRCAU + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + + bytes memory expectedErr = abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "tokens", + tokens, + minimumProvisionTokens, + maximumProvisionTokens + ); + vm.expectRevert(expectedErr); + subgraphService.updateIndexingAgreement(indexer, signedRCAU); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenIndexerNotRegistered( + address indexer, + uint256 unboundedTokens, + IRecurringCollector.SignedRCAU memory signedRCAU + ) public withSafeIndexerOrOperator(indexer) { + uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS); + mint(indexer, tokens); + resetPrank(indexer); + _createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod); + + bytes memory expectedErr = abi.encodeWithSelector( + ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, + indexer + ); + vm.expectRevert(expectedErr); + subgraphService.updateIndexingAgreement(indexer, signedRCAU); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAccepted(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU( + ctx, + _generateAcceptableRecurringCollectionAgreement(ctx, indexerState.addr) + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotActive.selector, + acceptableUpdate.rcau.agreementId + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableUpdate); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorizedForAgreement( + Seed memory seed + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerStateA = _withIndexer(ctx); + IndexerState memory indexerStateB = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerStateA); + IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotAuthorized.selector, + acceptableUpdate.rcau.agreementId, + indexerStateB.addr + ); + vm.expectRevert(expectedErr); + resetPrank(indexerStateB.addr); + subgraphService.updateIndexingAgreement(indexerStateB.addr, acceptableUpdate); + } + + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + IRecurringCollector.RecurringCollectionAgreementUpdate + memory acceptableUpdate = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, accepted.rca); + acceptableUpdate.metadata = bytes("invalid"); + IRecurringCollector.SignedRCAU memory unacceptableUpdate = _recurringCollectorHelper.generateSignedRCAU( + acceptableUpdate, + ctx.payer.signerPrivateKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, + "decodeRCAUMetadata", + unacceptableUpdate.rcau.metadata + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, unacceptableUpdate); + } + + function test_SubgraphService_UpdateIndexingAgreement_OK(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); + + IndexingAgreement.UpdateIndexingAgreementMetadata memory metadata = abi.decode( + acceptableUpdate.rcau.metadata, + (IndexingAgreement.UpdateIndexingAgreementMetadata) + ); + + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementUpdated( + accepted.rca.serviceProvider, + accepted.rca.payer, + acceptableUpdate.rcau.agreementId, + indexerState.allocationId, + metadata.version, + metadata.terms + ); + + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableUpdate); + } + /* solhint-enable graph/func-name-mixedcase */ +} From 1651716f094c2e3195f0afa03af260131f682be8 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 16 Jun 2025 15:06:43 -0300 Subject: [PATCH 002/157] test: Add extra tests for Indexing Agreements --- packages/horizon/package.json | 4 +- .../utilities/ProvisionManager.t.sol | 53 +++++++++ .../utilities/ProvisionManagerImpl.t.sol | 15 +++ .../test/unit/libraries/StakeClaims.t.sol | 18 +++ .../test/unit/mocks/HorizonStakingMock.t.sol | 32 ++++++ .../unit/mocks/InvalidControllerMock.t.sol | 8 ++ .../unit/mocks/PartialControllerMock.t.sol | 33 ++++++ .../RecurringCollectorAuthorizableTest.t.sol | 10 +- .../RecurringCollectorControllerMock.t.sol | 25 ---- .../payments/recurring-collector/base.t.sol | 44 +++++++ .../payments/recurring-collector/shared.t.sol | 6 +- packages/subgraph-service/package.json | 4 +- .../test/unit/libraries/IndexingAgreement.sol | 18 --- .../unit/libraries/IndexingAgreement.t.sol | 107 ++++++++++++++++++ .../indexing-agreement/accept.t.sol | 19 ++++ .../indexing-agreement/base.t.sol | 21 ++++ .../indexing-agreement/collect.t.sol | 37 ++++++ .../indexing-agreement/shared.t.sol | 59 ++++++++-- 18 files changed, 446 insertions(+), 67 deletions(-) create mode 100644 packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol create mode 100644 packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol create mode 100644 packages/horizon/test/unit/libraries/StakeClaims.t.sol create mode 100644 packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol create mode 100644 packages/horizon/test/unit/mocks/InvalidControllerMock.t.sol create mode 100644 packages/horizon/test/unit/mocks/PartialControllerMock.t.sol delete mode 100644 packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/base.t.sol delete mode 100644 packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol create mode 100644 packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol diff --git a/packages/horizon/package.json b/packages/horizon/package.json index 641fc61dd..4e2d86374 100644 --- a/packages/horizon/package.json +++ b/packages/horizon/package.json @@ -26,7 +26,9 @@ "build": "hardhat compile", "test": "forge test", "test:deployment": "SECURE_ACCOUNTS_DISABLE_PROVIDER=true hardhat test test/deployment/*.ts", - "test:integration": "./scripts/integration" + "test:integration": "./scripts/integration", + "test:coverage": "forge coverage --no-match-coverage \"test/*|contracts/mocks/*\"", + "test:coverage:lcov": "forge coverage --no-match-coverage \"test/*|contracts/mocks/*\" --report lcov" }, "devDependencies": { "@defi-wonderland/natspec-smells": "^1.1.6", diff --git a/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol b/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol new file mode 100644 index 000000000..3617e95a5 --- /dev/null +++ b/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { ProvisionManager } from "../../../../contracts/data-service/utilities/ProvisionManager.sol"; +import { IHorizonStakingTypes } from "../../../../contracts/interfaces/internal/IHorizonStakingTypes.sol"; +import { PartialControllerMock } from "../../mocks/PartialControllerMock.t.sol"; +import { HorizonStakingMock } from "../../mocks/HorizonStakingMock.t.sol"; +import { ProvisionManagerImpl } from "./ProvisionManagerImpl.t.sol"; + +contract ProvisionManagerTest is Test { + ProvisionManagerImpl internal _provisionManager; + HorizonStakingMock internal _horizonStakingMock; + + function setUp() public { + _horizonStakingMock = new HorizonStakingMock(); + + PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](1); + entries[0] = PartialControllerMock.Entry({ name: "Staking", addr: address(_horizonStakingMock) }); + _provisionManager = new ProvisionManagerImpl(address(new PartialControllerMock(entries))); + } + + /* solhint-disable graph/func-name-mixedcase */ + + function test_OnlyValidProvision(address serviceProvider) public { + vm.expectRevert( + abi.encodeWithSelector(ProvisionManager.ProvisionManagerProvisionNotFound.selector, serviceProvider) + ); + _provisionManager.onlyValidProvision_(serviceProvider); + + IHorizonStakingTypes.Provision memory provision; + provision.createdAt = 1; + + _horizonStakingMock.setProvision(serviceProvider, address(_provisionManager), provision); + + _provisionManager.onlyValidProvision_(serviceProvider); + } + + function test_OnlyAuthorizedForProvision(address serviceProvider, address sender) public { + vm.expectRevert( + abi.encodeWithSelector(ProvisionManager.ProvisionManagerNotAuthorized.selector, serviceProvider, sender) + ); + vm.prank(sender); + _provisionManager.onlyAuthorizedForProvision_(serviceProvider); + + _horizonStakingMock.setIsAuthorized(serviceProvider, address(_provisionManager), sender, true); + vm.prank(sender); + _provisionManager.onlyAuthorizedForProvision_(serviceProvider); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol b/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol new file mode 100644 index 000000000..4170d17da --- /dev/null +++ b/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.27; + +import { ProvisionManager } from "../../../../contracts/data-service/utilities/ProvisionManager.sol"; +import { GraphDirectory } from "../../../../contracts/utilities/GraphDirectory.sol"; + +contract ProvisionManagerImpl is GraphDirectory, ProvisionManager { + constructor(address controller) GraphDirectory(controller) {} + + function onlyValidProvision_(address serviceProvider) public view onlyValidProvision(serviceProvider) {} + + function onlyAuthorizedForProvision_( + address serviceProvider + ) public view onlyAuthorizedForProvision(serviceProvider) {} +} diff --git a/packages/horizon/test/unit/libraries/StakeClaims.t.sol b/packages/horizon/test/unit/libraries/StakeClaims.t.sol new file mode 100644 index 000000000..d98bdf78e --- /dev/null +++ b/packages/horizon/test/unit/libraries/StakeClaims.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { StakeClaims } from "../../../contracts/data-service/libraries/StakeClaims.sol"; + +contract StakeClaimsTest is Test { + /* solhint-disable graph/func-name-mixedcase */ + + function test_BuildStakeClaimId(address dataService, address serviceProvider, uint256 nonce) public pure { + bytes32 id = StakeClaims.buildStakeClaimId(dataService, serviceProvider, nonce); + bytes32 expectedId = keccak256(abi.encodePacked(dataService, serviceProvider, nonce)); + assertEq(id, expectedId, "StakeClaim ID does not match expected value"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol b/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol new file mode 100644 index 000000000..647df06f7 --- /dev/null +++ b/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IHorizonStakingTypes } from "../../../contracts/interfaces/internal/IHorizonStakingTypes.sol"; + +contract HorizonStakingMock { + mapping(address => mapping(address => IHorizonStakingTypes.Provision)) public provisions; + mapping(address => mapping(address => mapping(address => bool))) public authorizations; + + function setProvision( + address serviceProvider, + address verifier, + IHorizonStakingTypes.Provision memory provision + ) external { + provisions[serviceProvider][verifier] = provision; + } + + function getProvision( + address serviceProvider, + address verifier + ) external view returns (IHorizonStakingTypes.Provision memory) { + return provisions[serviceProvider][verifier]; + } + + function isAuthorized(address serviceProvider, address verifier, address operator) external view returns (bool) { + return authorizations[serviceProvider][verifier][operator]; + } + + function setIsAuthorized(address serviceProvider, address verifier, address operator, bool authorized) external { + authorizations[serviceProvider][verifier][operator] = authorized; + } +} diff --git a/packages/horizon/test/unit/mocks/InvalidControllerMock.t.sol b/packages/horizon/test/unit/mocks/InvalidControllerMock.t.sol new file mode 100644 index 000000000..f4d31da12 --- /dev/null +++ b/packages/horizon/test/unit/mocks/InvalidControllerMock.t.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { PartialControllerMock } from "./PartialControllerMock.t.sol"; + +contract InvalidControllerMock is PartialControllerMock { + constructor() PartialControllerMock(new PartialControllerMock.Entry[](0)) {} +} diff --git a/packages/horizon/test/unit/mocks/PartialControllerMock.t.sol b/packages/horizon/test/unit/mocks/PartialControllerMock.t.sol new file mode 100644 index 000000000..f315ff5ea --- /dev/null +++ b/packages/horizon/test/unit/mocks/PartialControllerMock.t.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { ControllerMock } from "../../../contracts/mocks/ControllerMock.sol"; + +contract PartialControllerMock is ControllerMock, Test { + struct Entry { + string name; + address addr; + } + + address private _invalidContractAddress; + + Entry[] private _contracts; + + constructor(Entry[] memory contracts) ControllerMock(address(0)) { + for (uint256 i = 0; i < contracts.length; i++) { + _contracts.push(Entry({ name: contracts[i].name, addr: contracts[i].addr })); + } + _invalidContractAddress = makeAddr("invalidContractAddress"); + } + + function getContractProxy(bytes32 data) external view override returns (address) { + for (uint256 i = 0; i < _contracts.length; i++) { + if (keccak256(abi.encodePacked(_contracts[i].name)) == data) { + return _contracts[i].addr; + } + } + return _invalidContractAddress; + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol index ff5e39848..91244fea1 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol @@ -5,16 +5,10 @@ import { IAuthorizable } from "../../../../contracts/interfaces/IAuthorizable.so import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; import { AuthorizableTest } from "../../../unit/utilities/Authorizable.t.sol"; -import { RecurringCollectorControllerMock } from "./RecurringCollectorControllerMock.t.sol"; +import { InvalidControllerMock } from "../../mocks/InvalidControllerMock.t.sol"; contract RecurringCollectorAuthorizableTest is AuthorizableTest { function newAuthorizable(uint256 thawPeriod) public override returns (IAuthorizable) { - return - new RecurringCollector( - "RecurringCollector", - "1", - address(new RecurringCollectorControllerMock(address(1))), - thawPeriod - ); + return new RecurringCollector("RecurringCollector", "1", address(new InvalidControllerMock()), thawPeriod); } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol deleted file mode 100644 index 3425e8b01..000000000 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorControllerMock.t.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import { Test } from "forge-std/Test.sol"; - -import { IPaymentsEscrow } from "../../../../contracts/interfaces/IPaymentsEscrow.sol"; -import { ControllerMock } from "../../../../contracts/mocks/ControllerMock.sol"; - -contract RecurringCollectorControllerMock is ControllerMock, Test { - address private _invalidContractAddress; - IPaymentsEscrow private _paymentsEscrow; - - constructor(address paymentsEscrow) ControllerMock(address(0)) { - _invalidContractAddress = makeAddr("invalidContractAddress"); - _paymentsEscrow = IPaymentsEscrow(paymentsEscrow); - } - - function getContractProxy(bytes32 data) external view override returns (address) { - return data == keccak256("PaymentsEscrow") ? address(_paymentsEscrow) : _invalidContractAddress; - } - - function getPaymentsEscrow() external view returns (address) { - return address(_paymentsEscrow); - } -} diff --git a/packages/horizon/test/unit/payments/recurring-collector/base.t.sol b/packages/horizon/test/unit/payments/recurring-collector/base.t.sol new file mode 100644 index 000000000..9512fbf87 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/base.t.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorBaseTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_RecoverRCASigner(FuzzyTestAccept memory fuzzyTestAccept) public view { + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA( + fuzzyTestAccept.rca, + signerKey + ); + + assertEq( + _recurringCollector.recoverRCASigner(signedRCA), + vm.addr(signerKey), + "Recovered RCA signer does not match" + ); + } + + function test_RecoverRCAUSigner(FuzzyTestUpdate memory fuzzyTestUpdate) public view { + uint256 signerKey = boundKey(fuzzyTestUpdate.fuzzyTestAccept.unboundedSignerKey); + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + fuzzyTestUpdate.rcau, + signerKey + ); + + assertEq( + _recurringCollector.recoverRCAUSigner(signedRCAU), + vm.addr(signerKey), + "Recovered RCAU signer does not match" + ); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 397925600..8dd270b2f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -9,7 +9,7 @@ import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurring import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; import { Bounder } from "../../../unit/utils/Bounder.t.sol"; -import { RecurringCollectorControllerMock } from "./RecurringCollectorControllerMock.t.sol"; +import { PartialControllerMock } from "../../mocks/PartialControllerMock.t.sol"; import { PaymentsEscrowMock } from "./PaymentsEscrowMock.t.sol"; import { RecurringCollectorHelper } from "./RecurringCollectorHelper.t.sol"; @@ -35,10 +35,12 @@ contract RecurringCollectorSharedTest is Test, Bounder { function setUp() public { _paymentsEscrow = new PaymentsEscrowMock(); + PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](1); + entries[0] = PartialControllerMock.Entry({ name: "PaymentsEscrow", addr: address(_paymentsEscrow) }); _recurringCollector = new RecurringCollector( "RecurringCollector", "1", - address(new RecurringCollectorControllerMock(address(_paymentsEscrow))), + address(new PartialControllerMock(entries)), 1 ); _recurringCollectorHelper = new RecurringCollectorHelper(_recurringCollector); diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index 0b000778c..6138c0c61 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -26,7 +26,9 @@ "build": "hardhat compile", "test": "forge test", "test:deployment": "SECURE_ACCOUNTS_DISABLE_PROVIDER=true hardhat test test/deployment/*.ts", - "test:integration": "./scripts/integration" + "test:integration": "./scripts/integration", + "test:coverage": "forge coverage --no-match-coverage \"test/*|contracts/mocks/*\"", + "test:coverage:lcov": "forge coverage --no-match-coverage \"test/*|contracts/mocks/*\" --report lcov" }, "devDependencies": { "@defi-wonderland/natspec-smells": "^1.1.6", diff --git a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol deleted file mode 100644 index 4afc6707e..000000000 --- a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.sol +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; - -import { Test } from "forge-std/Test.sol"; -import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol"; - -contract IndexingAgreementTest is Test { - function test_StorageManagerLocation() public pure { - assertEq( - IndexingAgreement.INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION, - keccak256( - abi.encode( - uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1 - ) - ) & ~bytes32(uint256(0xff)) - ); - } -} diff --git a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol new file mode 100644 index 000000000..a545c8571 --- /dev/null +++ b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol"; +import { Directory } from "../../../contracts/utilities/Directory.sol"; + +contract IndexingAgreementTest is Test { + IndexingAgreement.StorageManager private _storageManager; + address private _mockCollector; + + function setUp() public { + _mockCollector = makeAddr("mockCollector"); + } + + function test_IndexingAgreement_Get(bytes16 agreementId) public { + vm.assume(agreementId != bytes16(0)); + + vm.mockCall( + address(this), + abi.encodeWithSelector(Directory.recurringCollector.selector), + abi.encode(IRecurringCollector(_mockCollector)) + ); + + IRecurringCollector.AgreementData memory collectorAgreement; + vm.mockCall( + _mockCollector, + abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), + abi.encode(collectorAgreement) + ); + + vm.expectRevert(abi.encodeWithSelector(IndexingAgreement.IndexingAgreementNotActive.selector, agreementId)); + IndexingAgreement.get(_storageManager, agreementId); + + collectorAgreement.dataService = address(this); + vm.mockCall( + _mockCollector, + abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), + abi.encode(collectorAgreement) + ); + + IndexingAgreement.AgreementWrapper memory wrapper = IndexingAgreement.get(_storageManager, agreementId); + assertEq(wrapper.collectorAgreement.dataService, address(this)); + } + + function test_IndexingAgreement_OnCloseAllocation(bytes16 agreementId, address allocationId, bool stale) public { + vm.assume(agreementId != bytes16(0)); + vm.assume(allocationId != address(0)); + + delete _storageManager; + vm.clearMockedCalls(); + + // No active agreement for allocation ID, returns early, no assertions needed + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + + // Active agreement for allocation ID, but collector agreement is not set, returns early, no assertions needed + _storageManager.allocationToActiveAgreementId[allocationId] = agreementId; + + IRecurringCollector.AgreementData memory collectorAgreement; + + vm.mockCall( + address(this), + abi.encodeWithSelector(Directory.recurringCollector.selector), + abi.encode(IRecurringCollector(_mockCollector)) + ); + + vm.mockCall( + _mockCollector, + abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), + abi.encode(collectorAgreement) + ); + + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + + // Active agreement for allocation ID, collector agreement is set, should cancel the agreement + collectorAgreement.dataService = address(this); + collectorAgreement.state = IRecurringCollector.AgreementState.Accepted; + + _storageManager.agreements[agreementId] = IndexingAgreement.State({ + allocationId: allocationId, + version: IndexingAgreement.IndexingAgreementVersion.V1 + }); + + vm.mockCall( + _mockCollector, + abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), + abi.encode(collectorAgreement) + ); + + vm.expectCall(_mockCollector, abi.encodeWithSelector(IRecurringCollector.cancel.selector, agreementId)); + + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + } + + function test_IndexingAgreement_StorageManagerLocation() public pure { + assertEq( + IndexingAgreement.INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION, + keccak256( + abi.encode( + uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1 + ) + ) & ~bytes32(uint256(0xff)) + ); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index 29f83126c..77b18308c 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -225,6 +225,25 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated() public {} + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidTermsData(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + bytes memory invalidTermsData = bytes("invalid terms data"); + acceptable.rca.metadata = abi.encode( + _newAcceptIndexingAgreementMetadataV1Terms(indexerState.subgraphDeploymentId, invalidTermsData) + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, + "decodeCollectIndexingFeeData", + invalidTermsData + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + } + function test_SubgraphService_AcceptIndexingAgreement(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol index 822cc21d7..2eda9dfc0 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol @@ -2,7 +2,9 @@ pragma solidity 0.8.27; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol"; +import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgreementSharedTest { @@ -11,6 +13,25 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre */ /* solhint-disable graph/func-name-mixedcase */ + function test_SubgraphService_GetIndexingAgreement(Seed memory seed, address operator, bytes16 agreementId) public { + vm.assume(_isSafeSubgraphServiceCaller(operator)); + + resetPrank(address(operator)); + + // Get unkown indexing agreement + vm.expectRevert(abi.encodeWithSelector(IndexingAgreement.IndexingAgreementNotActive.selector, agreementId)); + subgraphService.getIndexingAgreement(agreementId); + + // Accept an indexing agreement + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement( + accepted.rca.agreementId + ); + _assertEqualAgreement(accepted.rca, agreement); + } + function test_SubgraphService_Revert_WhenUnsafeAddress_WhenProxyAdmin(address indexer, bytes16 agreementId) public { address operator = _transparentUpgradeableProxyAdmin(); assertFalse(_isSafeSubgraphServiceCaller(operator)); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 85c203b6e..57a7a907f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -11,6 +11,7 @@ import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphServ import { Allocation } from "../../../../contracts/libraries/Allocation.sol"; import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol"; import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; +import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol"; import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol"; @@ -175,6 +176,21 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); } + function test_SubgraphService_CollectIndexingFees_Revert_WhenInvalidData(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + + bytes memory invalidData = bytes("invalid data"); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, + "decodeCollectData", + invalidData + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.collect(indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, invalidData); + } + function test_SubgraphService_CollectIndexingFees_Revert_WhenInvalidAgreement( Seed memory seed, bytes16 agreementId, @@ -195,6 +211,27 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); } + function test_SubgraphService_CollectIndexingFees_Reverts_WhenInvalidNestedData(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + resetPrank(indexerState.addr); + + bytes memory invalidNestedData = bytes("invalid nested data"); + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, + "decodeCollectIndexingFeeDataV1", + invalidNestedData + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectData(accepted.rca.agreementId, invalidNestedData) + ); + } + function test_SubgraphService_CollectIndexingFees_Reverts_WhenStopService( Seed memory seed, uint256 entities, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index 8574e60e7..2a5b2385a 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -310,14 +310,25 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _newAcceptIndexingAgreementMetadataV1( bytes32 _subgraphDeploymentId + ) internal pure returns (IndexingAgreement.AcceptIndexingAgreementMetadata memory) { + return + _newAcceptIndexingAgreementMetadataV1Terms( + _subgraphDeploymentId, + abi.encode( + IndexingAgreement.IndexingAgreementTermsV1({ tokensPerSecond: 0, tokensPerEntityPerSecond: 0 }) + ) + ); + } + + function _newAcceptIndexingAgreementMetadataV1Terms( + bytes32 _subgraphDeploymentId, + bytes memory _terms ) internal pure returns (IndexingAgreement.AcceptIndexingAgreementMetadata memory) { return IndexingAgreement.AcceptIndexingAgreementMetadata({ subgraphDeploymentId: _subgraphDeploymentId, version: IndexingAgreement.IndexingAgreementVersion.V1, - terms: abi.encode( - IndexingAgreement.IndexingAgreementTermsV1({ tokensPerSecond: 0, tokensPerEntityPerSecond: 0 }) - ) + terms: _terms }); } @@ -343,18 +354,28 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun bytes32 _poi, uint256 _poiBlock, bytes memory _metadata + ) internal pure returns (bytes memory) { + return _encodeCollectData(_agreementId, _encodeV1Data(_entities, _poi, _poiBlock, _metadata)); + } + + function _encodeCollectData(bytes16 _agreementId, bytes memory _nestedData) internal pure returns (bytes memory) { + return abi.encode(_agreementId, _nestedData); + } + + function _encodeV1Data( + uint256 _entities, + bytes32 _poi, + uint256 _poiBlock, + bytes memory _metadata ) internal pure returns (bytes memory) { return abi.encode( - _agreementId, - abi.encode( - IndexingAgreement.CollectIndexingFeeDataV1({ - entities: _entities, - poi: _poi, - poiBlockNumber: _poiBlock, - metadata: _metadata - }) - ) + IndexingAgreement.CollectIndexingFeeDataV1({ + entities: _entities, + poi: _poi, + poiBlockNumber: _poiBlock, + metadata: _metadata + }) ); } @@ -377,4 +398,18 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun ) internal pure returns (bytes memory) { return abi.encode(_t); } + + function _assertEqualAgreement( + IRecurringCollector.RecurringCollectionAgreement memory _expected, + IndexingAgreement.AgreementWrapper memory _actual + ) internal pure { + assertEq(_expected.dataService, _actual.collectorAgreement.dataService); + assertEq(_expected.payer, _actual.collectorAgreement.payer); + assertEq(_expected.serviceProvider, _actual.collectorAgreement.serviceProvider); + assertEq(_expected.endsAt, _actual.collectorAgreement.endsAt); + assertEq(_expected.maxInitialTokens, _actual.collectorAgreement.maxInitialTokens); + assertEq(_expected.maxOngoingTokensPerSecond, _actual.collectorAgreement.maxOngoingTokensPerSecond); + assertEq(_expected.minSecondsPerCollection, _actual.collectorAgreement.minSecondsPerCollection); + assertEq(_expected.maxSecondsPerCollection, _actual.collectorAgreement.maxSecondsPerCollection); + } } From b53ca01e3837392d80cc66050443dfd418e51eba Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 19 Jun 2025 14:37:42 -0300 Subject: [PATCH 003/157] fix: [TRST-H-1] IndexingAgreement.collect() on CanceledByPayer --- .../interfaces/IRecurringCollector.sol | 9 + .../collectors/RecurringCollector.sol | 16 +- .../contracts/libraries/IndexingAgreement.sol | 40 +++- .../indexing-agreement/integration.t.sol | 188 +++++++++++++----- 4 files changed, 196 insertions(+), 57 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index a53439a7c..954b1be94 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -413,4 +413,13 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @return The AgreementData struct containing the agreement's data. */ function getAgreement(bytes16 agreementId) external view returns (AgreementData memory); + + /** + * @notice Checks if an agreement is collectable. + * @dev "Collectable" means the agreement is in a valid state that allows collection attempts, + * not that there are necessarily funds available to collect. + * @param agreement The agreement data + * @return The boolean indicating if the agreement is collectable + */ + function isCollectable(AgreementData memory agreement) external view returns (bool); } diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 99122a348..e1225f6fa 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -249,6 +249,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return _getAgreement(agreementId); } + /// @inheritdoc IRecurringCollector + function isCollectable(AgreementData memory agreement) external pure returns (bool) { + return _isCollectable(agreement); + } + /** * @notice Decodes the collect data. * @param data The encoded collect parameters. @@ -270,7 +275,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC function _collect(CollectParams memory _params) private returns (uint256) { AgreementData storage agreement = _getAgreementStorage(_params.agreementId); require( - agreement.state == AgreementState.Accepted || agreement.state == AgreementState.CanceledByPayer, + _isCollectable(agreement), RecurringCollectorAgreementIncorrectState(_params.agreementId, agreement.state) ); @@ -537,4 +542,13 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; } + + /** + * @notice Requires that the agreement is collectable. + * @param _agreement The agreement data + * @return The boolean indicating if the agreement is collectable + */ + function _isCollectable(AgreementData memory _agreement) private pure returns (bool) { + return _agreement.state == AgreementState.Accepted || _agreement.state == AgreementState.CanceledByPayer; + } } diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index a3669fffc..d1bea35c8 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -254,6 +254,12 @@ library IndexingAgreement { */ error IndexingAgreementNotActive(bytes16 agreementId); + /** + * @notice Thrown when the agreement is not collectable + * @param agreementId The agreement ID + */ + error IndexingAgreementNotCollectable(bytes16 agreementId); + /** * @notice Thrown when trying to interact with an agreement not owned by the indexer * @param agreementId The agreement ID @@ -517,7 +523,7 @@ library IndexingAgreement { wrapper.agreement.allocationId, wrapper.collectorAgreement.serviceProvider ); - require(_isActive(wrapper), IndexingAgreementNotActive(params.agreementId)); + require(_isCollectable(wrapper), IndexingAgreementNotCollectable(params.agreementId)); require( wrapper.agreement.version == IndexingAgreementVersion.V1, @@ -692,17 +698,37 @@ library IndexingAgreement { /** * @notice Checks if the agreement is active * Requirements: + * - The indexing agreement is valid * - The underlying collector agreement has been accepted - * - The underlying collector agreement's data service is this contract - * - The indexing agreement has been accepted and has a valid allocation ID * @param wrapper The agreement wrapper containing the indexing agreement and collector agreement data * @return True if the agreement is active, false otherwise **/ function _isActive(AgreementWrapper memory wrapper) private view returns (bool) { - return - wrapper.collectorAgreement.dataService == address(this) && - wrapper.collectorAgreement.state == IRecurringCollector.AgreementState.Accepted && - wrapper.agreement.allocationId != address(0); + return _isValid(wrapper) && wrapper.collectorAgreement.state == IRecurringCollector.AgreementState.Accepted; + } + + /** + * @notice Checks if the agreement is collectable + * Requirements: + * - The indexing agreement is valid + * - The underlying collector agreement is collectable + * @param wrapper The agreement wrapper containing the indexing agreement and collector agreement data + * @return True if the agreement is collectable, false otherwise + **/ + function _isCollectable(AgreementWrapper memory wrapper) private view returns (bool) { + return _isValid(wrapper) && _directory().recurringCollector().isCollectable(wrapper.collectorAgreement); + } + + /** + * @notice Checks if the agreement is valid + * Requirements: + * - The underlying collector agreement's data service is this contract + * - The indexing agreement has been accepted and has a valid allocation ID + * @param wrapper The agreement wrapper containing the indexing agreement and collector agreement data + * @return True if the agreement is valid, false otherwise + **/ + function _isValid(AgreementWrapper memory wrapper) private view returns (bool) { + return wrapper.collectorAgreement.dataService == address(this) && wrapper.agreement.allocationId != address(0); } /** diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 433ee0103..5c8758370 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -18,6 +18,13 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex uint256 indexerTokensLocked; } + struct ExpectedTokens { + uint256 expectedTotalTokensCollected; + uint256 expectedTokensLocked; + uint256 expectedProtocolTokensBurnt; + uint256 expectedIndexerTokensCollected; + } + /* * TESTS */ @@ -27,81 +34,164 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex Seed memory seed, uint256 fuzzyTokensCollected ) public { - uint256 expectedTotalTokensCollected = bound(fuzzyTokensCollected, 1000, 1_000_000); - uint256 expectedTokensLocked = stakeToFeesRatio * expectedTotalTokensCollected; - uint256 expectedProtocolTokensBurnt = expectedTotalTokensCollected.mulPPMRoundUp( - graphPayments.PROTOCOL_PAYMENT_CUT() - ); - uint256 expectedIndexerTokensCollected = expectedTotalTokensCollected - expectedProtocolTokensBurnt; - + // Setup + ExpectedTokens memory expectedTokens = _newExpectedTokens(fuzzyTokensCollected); Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - _addTokensToProvision(indexerState, expectedTokensLocked); + _addTokensToProvision(indexerState, expectedTokens.expectedTokensLocked); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); - uint256 agreementTokensPerSecond = 1; - rca.deadline = uint64(block.timestamp); // accept now - rca.endsAt = type(uint64).max; // no expiration - rca.maxInitialTokens = 0; // no initial payment - rca.maxOngoingTokensPerSecond = type(uint32).max; // unlimited tokens per second - rca.minSecondsPerCollection = 1; // 1 second between collections - rca.maxSecondsPerCollection = type(uint32).max; // no maximum time between collections - rca.serviceProvider = indexerState.addr; // service provider is the indexer - rca.dataService = address(subgraphService); // data service is the subgraph service - rca.metadata = _encodeAcceptIndexingAgreementMetadataV1( - indexerState.subgraphDeploymentId, - IndexingAgreement.IndexingAgreementTermsV1({ - tokensPerSecond: agreementTokensPerSecond, - tokensPerEntityPerSecond: 0 // no payment for entities - }) - ); + _sharedSetup(ctx, rca, indexerState, expectedTokens); - _setupPayerWithEscrow(rca.payer, ctx.payer.signerPrivateKey, indexerState.addr, expectedTotalTokensCollected); + TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); + // Collect resetPrank(indexerState.addr); - // Set the payments destination to the indexer address - subgraphService.setPaymentsDestination(indexerState.addr); - // Accept the Indexing Agreement - subgraphService.acceptIndexingAgreement( - indexerState.allocationId, - _recurringCollectorHelper.generateSignedRCA(rca, ctx.payer.signerPrivateKey) + uint256 tokensCollected = subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1( + rca.agreementId, + 1, + keccak256(abi.encodePacked("poi")), + epochManager.currentEpochBlock(), + bytes("") + ) ); - // Skip ahead to collection point - skip(expectedTotalTokensCollected / agreementTokensPerSecond); - // vm.assume(block.timestamp < type(uint64).max); + + TestState memory afterCollect = _getState(rca.payer, indexerState.addr); + _sharedAssert(beforeCollect, afterCollect, expectedTokens, tokensCollected); + } + + function test_SubgraphService_CollectIndexingFee_WhenCanceledByPayer_Integration( + Seed memory seed, + uint256 fuzzyTokensCollected + ) public { + // Setup + ExpectedTokens memory expectedTokens = _newExpectedTokens(fuzzyTokensCollected); + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + ctx.ctxInternal.seed.rca + ); + _sharedSetup(ctx, rca, indexerState, expectedTokens); + + // Cancel the indexing agreement by the payer + resetPrank(ctx.payer.signer); + subgraphService.cancelIndexingAgreementByPayer(rca.agreementId); + TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); - bytes16 agreementId = rca.agreementId; + + // Collect + resetPrank(indexerState.addr); uint256 tokensCollected = subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, _encodeCollectDataV1( - agreementId, + rca.agreementId, 1, keccak256(abi.encodePacked("poi")), epochManager.currentEpochBlock(), bytes("") ) ); + TestState memory afterCollect = _getState(rca.payer, indexerState.addr); - uint256 indexerTokensCollected = afterCollect.indexerBalance - beforeCollect.indexerBalance; - uint256 protocolTokensBurnt = tokensCollected - indexerTokensCollected; + _sharedAssert(beforeCollect, afterCollect, expectedTokens, tokensCollected); + } + + /* solhint-enable graph/func-name-mixedcase */ + + function _sharedSetup( + Context storage _ctx, + IRecurringCollector.RecurringCollectionAgreement memory _rca, + IndexerState memory _indexerState, + ExpectedTokens memory _expectedTokens + ) internal { + _addTokensToProvision(_indexerState, _expectedTokens.expectedTokensLocked); + + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 1, + tokensPerEntityPerSecond: 0 // no payment for entities + }); + _rca.deadline = uint64(block.timestamp); // accept now + _rca.endsAt = type(uint64).max; // no expiration + _rca.maxInitialTokens = 0; // no initial payment + _rca.maxOngoingTokensPerSecond = type(uint32).max; // unlimited tokens per second + _rca.minSecondsPerCollection = 1; // 1 second between collections + _rca.maxSecondsPerCollection = type(uint32).max; // no maximum time between collections + _rca.serviceProvider = _indexerState.addr; // service provider is the indexer + _rca.dataService = address(subgraphService); // data service is the subgraph service + _rca.metadata = _encodeAcceptIndexingAgreementMetadataV1(_indexerState.subgraphDeploymentId, terms); + + _setupPayerWithEscrow( + _rca.payer, + _ctx.payer.signerPrivateKey, + _indexerState.addr, + _expectedTokens.expectedTotalTokensCollected + ); + + resetPrank(_indexerState.addr); + // Set the payments destination to the indexer address + subgraphService.setPaymentsDestination(_indexerState.addr); + + // Accept the Indexing Agreement + subgraphService.acceptIndexingAgreement( + _indexerState.allocationId, + _recurringCollectorHelper.generateSignedRCA(_rca, _ctx.payer.signerPrivateKey) + ); + + // Skip ahead to collection point + skip(_expectedTokens.expectedTotalTokensCollected / terms.tokensPerSecond); + } + + function _newExpectedTokens(uint256 _fuzzyTokensCollected) internal view returns (ExpectedTokens memory) { + uint256 expectedTotalTokensCollected = bound(_fuzzyTokensCollected, 1000, 1_000_000); + uint256 expectedTokensLocked = stakeToFeesRatio * expectedTotalTokensCollected; + uint256 expectedProtocolTokensBurnt = expectedTotalTokensCollected.mulPPMRoundUp( + graphPayments.PROTOCOL_PAYMENT_CUT() + ); + uint256 expectedIndexerTokensCollected = expectedTotalTokensCollected - expectedProtocolTokensBurnt; + return + ExpectedTokens({ + expectedTotalTokensCollected: expectedTotalTokensCollected, + expectedTokensLocked: expectedTokensLocked, + expectedProtocolTokensBurnt: expectedProtocolTokensBurnt, + expectedIndexerTokensCollected: expectedIndexerTokensCollected + }); + } + + function _sharedAssert( + TestState memory _beforeCollect, + TestState memory _afterCollect, + ExpectedTokens memory _expectedTokens, + uint256 _tokensCollected + ) internal pure { + uint256 indexerTokensCollected = _afterCollect.indexerBalance - _beforeCollect.indexerBalance; + assertEq(_expectedTokens.expectedTotalTokensCollected, _tokensCollected, "Total tokens collected should match"); assertEq( - afterCollect.escrowBalance, - beforeCollect.escrowBalance - tokensCollected, - "Escrow balance should be reduced by the amount collected" + _expectedTokens.expectedProtocolTokensBurnt, + _tokensCollected - indexerTokensCollected, + "Protocol tokens burnt should match" ); - assertEq(tokensCollected, expectedTotalTokensCollected, "Total tokens collected should match"); - assertEq(expectedProtocolTokensBurnt, protocolTokensBurnt, "Protocol tokens burnt should match"); - assertEq(indexerTokensCollected, expectedIndexerTokensCollected, "Indexer tokens collected should match"); assertEq( - afterCollect.indexerTokensLocked, - beforeCollect.indexerTokensLocked + expectedTokensLocked, - "Locked tokens should match" + _expectedTokens.expectedIndexerTokensCollected, + indexerTokensCollected, + "Indexer tokens collected should match" + ); + assertEq( + _afterCollect.escrowBalance, + _beforeCollect.escrowBalance - _expectedTokens.expectedTotalTokensCollected, + "_Escrow balance should be reduced by the amount collected" ); - } - /* solhint-enable graph/func-name-mixedcase */ + assertEq( + _afterCollect.indexerTokensLocked, + _beforeCollect.indexerTokensLocked + _expectedTokens.expectedTokensLocked, + "_Locked tokens should match" + ); + } function _addTokensToProvision(IndexerState memory _indexerState, uint256 _tokensToAddToProvision) private { deal({ token: address(token), to: _indexerState.addr, give: _tokensToAddToProvision }); From da42fb417c4119179e0874da48872a8ac62896dd Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 23 Jun 2025 11:55:05 -0300 Subject: [PATCH 004/157] fix: Remove PaymentType constraint from RecurringCollector --- .../collectors/RecurringCollector.sol | 16 +++---- .../recurring-collector/collect.t.sol | 46 ++++++------------- .../payments/recurring-collector/shared.t.sol | 17 ++++++- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index e1225f6fa..662dc549f 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -62,12 +62,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @dev Caller must be the data service the RCA was issued to. */ function collect(IGraphPayments.PaymentTypes paymentType, bytes calldata data) external returns (uint256) { - require( - paymentType == IGraphPayments.PaymentTypes.IndexingFee, - RecurringCollectorInvalidPaymentType(paymentType) - ); try this.decodeCollectData(data) returns (CollectParams memory collectParams) { - return _collect(collectParams); + return _collect(paymentType, collectParams); } catch { revert RecurringCollectorInvalidCollectData(data); } @@ -269,10 +265,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * * Emits {PaymentCollected} and {RCACollected} events. * + * @param _paymentType The type of payment to collect * @param _params The decoded parameters for the collection * @return The amount of tokens collected */ - function _collect(CollectParams memory _params) private returns (uint256) { + function _collect( + IGraphPayments.PaymentTypes _paymentType, + CollectParams memory _params + ) private returns (uint256) { AgreementData storage agreement = _getAgreementStorage(_params.agreementId); require( _isCollectable(agreement), @@ -289,7 +289,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens); _graphPaymentsEscrow().collect( - IGraphPayments.PaymentTypes.IndexingFee, + _paymentType, agreement.payer, agreement.serviceProvider, tokensToCollect, @@ -301,7 +301,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.lastCollectionAt = uint64(block.timestamp); emit PaymentCollected( - IGraphPayments.PaymentTypes.IndexingFee, + _paymentType, _params.collectionId, agreement.payer, agreement.serviceProvider, diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 8942c21bf..4382fa852 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.27; -import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; - import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -14,32 +12,14 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ - function test_Collect_Revert_WhenInvalidPaymentType(uint8 unboundedPaymentType, bytes memory data) public { - IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes( - bound( - unboundedPaymentType, - uint256(type(IGraphPayments.PaymentTypes).min), - uint256(type(IGraphPayments.PaymentTypes).max) - ) - ); - vm.assume(paymentType != IGraphPayments.PaymentTypes.IndexingFee); - - bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorInvalidPaymentType.selector, - paymentType - ); - vm.expectRevert(expectedErr); - _recurringCollector.collect(paymentType, data); - } - - function test_Collect_Revert_WhenInvalidData(address caller, bytes memory data) public { + function test_Collect_Revert_WhenInvalidData(address caller, uint8 unboundedPaymentType, bytes memory data) public { bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorInvalidCollectData.selector, data ); vm.expectRevert(expectedErr); vm.prank(caller); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(unboundedPaymentType), data); } function test_Collect_Revert_WhenCallerNotDataService( @@ -61,7 +41,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(notDataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } function test_Collect_Revert_WhenUnknownAgreement(FuzzyTestCollect memory fuzzy, address dataService) public { @@ -74,7 +54,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } function test_Collect_Revert_WhenCanceledAgreementByServiceProvider(FuzzyTestCollect calldata fuzzy) public { @@ -97,7 +77,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } function test_Collect_Revert_WhenCollectingTooSoon( @@ -116,7 +96,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ) ); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); uint256 collectionSeconds = boundSkip(unboundedCollectionSeconds, 1, accepted.rca.minSecondsPerCollection - 1); skip(collectionSeconds); @@ -136,7 +116,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } function test_Collect_Revert_WhenCollectingTooLate( @@ -163,7 +143,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ) ); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); // skip beyond collectable time but still within the agreement endsAt uint256 collectionSeconds = boundSkip( @@ -189,7 +169,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } function test_Collect_OK_WhenCollectingTooMuch( @@ -219,7 +199,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ) ); vm.prank(accepted.rca.dataService); - _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, initialData); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), initialData); } // skip to collectable time @@ -240,7 +220,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); bytes memory data = _generateCollectData(collectParams); vm.prank(accepted.rca.dataService); - uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, maxTokens); } @@ -258,9 +238,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { unboundedTokens ); skip(collectionSeconds); - _expectCollectCallAndEmit(accepted.rca, fuzzy.collectParams, tokens); + _expectCollectCallAndEmit(accepted.rca, _paymentType(fuzzy.unboundedPaymentType), fuzzy.collectParams, tokens); vm.prank(accepted.rca.dataService); - uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, tokens); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 8dd270b2f..2dbd0e1a0 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -16,6 +16,7 @@ import { RecurringCollectorHelper } from "./RecurringCollectorHelper.t.sol"; contract RecurringCollectorSharedTest is Test, Bounder { struct FuzzyTestCollect { FuzzyTestAccept fuzzyTestAccept; + uint8 unboundedPaymentType; IRecurringCollector.CollectParams collectParams; } @@ -106,6 +107,7 @@ contract RecurringCollectorSharedTest is Test, Bounder { function _expectCollectCallAndEmit( IRecurringCollector.RecurringCollectionAgreement memory _rca, + IGraphPayments.PaymentTypes __paymentType, IRecurringCollector.CollectParams memory _fuzzyParams, uint256 _tokens ) internal { @@ -114,7 +116,7 @@ contract RecurringCollectorSharedTest is Test, Bounder { abi.encodeCall( _paymentsEscrow.collect, ( - IGraphPayments.PaymentTypes.IndexingFee, + __paymentType, _rca.payer, _rca.serviceProvider, _tokens, @@ -126,7 +128,7 @@ contract RecurringCollectorSharedTest is Test, Bounder { ); vm.expectEmit(address(_recurringCollector)); emit IPaymentsCollector.PaymentCollected( - IGraphPayments.PaymentTypes.IndexingFee, + __paymentType, _fuzzyParams.collectionId, _rca.payer, _rca.serviceProvider, @@ -193,4 +195,15 @@ contract RecurringCollectorSharedTest is Test, Bounder { bound(_seed, 0, uint256(IRecurringCollector.CancelAgreementBy.Payer)) ); } + + function _paymentType(uint8 _unboundedPaymentType) internal pure returns (IGraphPayments.PaymentTypes) { + return + IGraphPayments.PaymentTypes( + bound( + _unboundedPaymentType, + uint256(type(IGraphPayments.PaymentTypes).min), + uint256(type(IGraphPayments.PaymentTypes).max) + ) + ); + } } From 7695c9ec5f03ed265f6f78fc80e2a192d83db823 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 21 Jul 2025 14:38:04 -0300 Subject: [PATCH 005/157] fix: [TRST-H-2] Only agreement owner can collect indexing fee --- .../contracts/SubgraphService.sol | 10 ++++++- .../contracts/libraries/IndexingAgreement.sol | 6 ++++ .../indexing-agreement/collect.t.sol | 29 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 919c1d7ed..6e77e66f9 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -298,7 +298,12 @@ contract SubgraphService is paymentCollected = _collectIndexingRewards(indexer, data); } else if (paymentType == IGraphPayments.PaymentTypes.IndexingFee) { (bytes16 agreementId, bytes memory iaCollectionData) = IndexingAgreementDecoder.decodeCollectData(data); - paymentCollected = _collectIndexingFees(agreementId, paymentsDestination[indexer], iaCollectionData); + paymentCollected = _collectIndexingFees( + indexer, + agreementId, + paymentsDestination[indexer], + iaCollectionData + ); } else { revert SubgraphServiceInvalidPaymentType(paymentType); } @@ -754,12 +759,14 @@ contract SubgraphService is * Emits a {StakeClaimLocked} event. * Emits a {IndexingFeesCollectedV1} event. * + * @param _indexer The address of the indexer * @param _agreementId The id of the indexing agreement * @param _paymentsDestination The address where the fees should be sent * @param _data The indexing agreement collection data * @return The amount of fees collected */ function _collectIndexingFees( + address _indexer, bytes16 _agreementId, address _paymentsDestination, bytes memory _data @@ -767,6 +774,7 @@ contract SubgraphService is (address indexer, uint256 tokensCollected) = IndexingAgreement._getStorageManager().collect( _allocations, IndexingAgreement.CollectParams({ + indexer: _indexer, agreementId: _agreementId, currentEpoch: _graphEpochManager().currentEpoch(), receiverDestination: _paymentsDestination, diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index d1bea35c8..1b07922c7 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -75,12 +75,14 @@ library IndexingAgreement { /** * @notice Parameters for collecting indexing fees + * @param indexer The address of the indexer * @param agreementId The ID of the indexing agreement * @param currentEpoch The current epoch * @param receiverDestination The address where the collected fees should be sent * @param data The encoded data containing the number of entities indexed, proof of indexing, and epoch */ struct CollectParams { + address indexer; bytes16 agreementId; uint256 currentEpoch; address receiverDestination; @@ -523,6 +525,10 @@ library IndexingAgreement { wrapper.agreement.allocationId, wrapper.collectorAgreement.serviceProvider ); + require( + allocation.indexer == params.indexer, + IndexingAgreementNotAuthorized(params.agreementId, params.indexer) + ); require(_isCollectable(wrapper), IndexingAgreementNotCollectable(params.agreementId)); require( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 57a7a907f..6f9c2563d 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -232,6 +232,35 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); } + function test_SubgraphService_CollectIndexingFees_Reverts_WhenIndexingAgreementNotAuthorized( + Seed memory seed, + uint256 entities, + bytes32 poi + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + IndexerState memory otherIndexerState = _withIndexer(ctx); + IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + + vm.assume(otherIndexerState.addr != indexerState.addr); + + resetPrank(otherIndexerState.addr); + + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotAuthorized.selector, + accepted.rca.agreementId, + otherIndexerState.addr + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + otherIndexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + function test_SubgraphService_CollectIndexingFees_Reverts_WhenStopService( Seed memory seed, uint256 entities, From 8048c4cbb45d3cb6c40444beb140e3882365eaeb Mon Sep 17 00:00:00 2001 From: Matias Date: Tue, 22 Jul 2025 15:46:32 -0300 Subject: [PATCH 006/157] fix: [TRST-H-3] collect() checks provision --- .../interfaces/IRecurringCollector.sol | 5 +++ .../collectors/RecurringCollector.sol | 11 ++++++ .../test/unit/mocks/HorizonStakingMock.t.sol | 5 +++ .../recurring-collector/collect.t.sol | 37 +++++++++++++++++++ .../payments/recurring-collector/shared.t.sol | 29 ++++++++++++++- 5 files changed, 86 insertions(+), 1 deletion(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index 954b1be94..ef7ba05f7 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -253,6 +253,11 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param unauthorizedDataService The address of the unauthorized data service */ error RecurringCollectorDataServiceNotAuthorized(bytes16 agreementId, address unauthorizedDataService); + /** + * @notice Thrown when the data service is not authorized for the service provider + * @param dataService The address of the unauthorized data service + */ + error RecurringCollectorUnauthorizedDataService(address dataService); /** * @notice Thrown when interacting with an agreement with an elapsed deadline diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 662dc549f..5f43c482e 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -284,6 +284,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC RecurringCollectorDataServiceNotAuthorized(_params.agreementId, msg.sender) ); + // Check the service provider has an active provision with the data service + // This prevents an attack where the payer can deny the service provider from collecting payments + // by using a signer as data service to syphon off the tokens in the escrow to an account they control + { + uint256 tokensAvailable = _graphStaking().getProviderTokensAvailable( + agreement.serviceProvider, + agreement.dataService + ); + require(tokensAvailable > 0, RecurringCollectorUnauthorizedDataService(agreement.dataService)); + } + uint256 tokensToCollect = 0; if (_params.tokens != 0) { tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens); diff --git a/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol b/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol index 647df06f7..d08975e09 100644 --- a/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol +++ b/packages/horizon/test/unit/mocks/HorizonStakingMock.t.sol @@ -29,4 +29,9 @@ contract HorizonStakingMock { function setIsAuthorized(address serviceProvider, address verifier, address operator, bool authorized) external { authorizations[serviceProvider][verifier][operator] = authorized; } + + function getProviderTokensAvailable(address serviceProvider, address verifier) external view returns (uint256) { + IHorizonStakingTypes.Provision memory provision = provisions[serviceProvider][verifier]; + return provision.tokens - provision.tokensThawing; + } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 4382fa852..0002c68af 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -2,6 +2,7 @@ pragma solidity 0.8.27; import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; +import { IHorizonStakingTypes } from "../../../../contracts/interfaces/internal/IHorizonStakingTypes.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -44,6 +45,42 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } + function test_Collect_Revert_WhenUnauthorizedDataService(FuzzyTestCollect calldata fuzzy) public { + (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; + + collectParams.agreementId = accepted.rca.agreementId; + collectParams.tokens = bound(collectParams.tokens, 1, type(uint256).max); + bytes memory data = _generateCollectData(collectParams); + + // Set up the scenario where service provider has no tokens staked with data service + // This simulates an unauthorized data service attack + _horizonStaking.setProvision( + accepted.rca.serviceProvider, + accepted.rca.dataService, + IHorizonStakingTypes.Provision({ + tokens: 0, // No tokens staked - this triggers the vulnerability + tokensThawing: 0, + sharesThawing: 0, + maxVerifierCut: 100000, + thawingPeriod: 604800, + createdAt: uint64(block.timestamp), + maxVerifierCutPending: 100000, + thawingPeriodPending: 604800, + lastParametersStagedAt: 0, + thawingNonce: 0 + }) + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorUnauthorizedDataService.selector, + accepted.rca.dataService + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + } + function test_Collect_Revert_WhenUnknownAgreement(FuzzyTestCollect memory fuzzy, address dataService) public { bytes memory data = _generateCollectData(fuzzy.collectParams); diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 2dbd0e1a0..d8d9483e7 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -6,10 +6,12 @@ import { Test } from "forge-std/Test.sol"; import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; import { IPaymentsCollector } from "../../../../contracts/interfaces/IPaymentsCollector.sol"; import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; +import { IHorizonStakingTypes } from "../../../../contracts/interfaces/internal/IHorizonStakingTypes.sol"; import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; import { Bounder } from "../../../unit/utils/Bounder.t.sol"; import { PartialControllerMock } from "../../mocks/PartialControllerMock.t.sol"; +import { HorizonStakingMock } from "../../mocks/HorizonStakingMock.t.sol"; import { PaymentsEscrowMock } from "./PaymentsEscrowMock.t.sol"; import { RecurringCollectorHelper } from "./RecurringCollectorHelper.t.sol"; @@ -32,12 +34,15 @@ contract RecurringCollectorSharedTest is Test, Bounder { RecurringCollector internal _recurringCollector; PaymentsEscrowMock internal _paymentsEscrow; + HorizonStakingMock internal _horizonStaking; RecurringCollectorHelper internal _recurringCollectorHelper; function setUp() public { _paymentsEscrow = new PaymentsEscrowMock(); - PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](1); + _horizonStaking = new HorizonStakingMock(); + PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](2); entries[0] = PartialControllerMock.Entry({ name: "PaymentsEscrow", addr: address(_paymentsEscrow) }); + entries[1] = PartialControllerMock.Entry({ name: "Staking", addr: address(_horizonStaking) }); _recurringCollector = new RecurringCollector( "RecurringCollector", "1", @@ -71,6 +76,9 @@ contract RecurringCollectorSharedTest is Test, Bounder { } function _accept(IRecurringCollector.SignedRCA memory _signedRCA) internal { + // Set up valid staking provision by default to allow collections to succeed + _setupValidProvision(_signedRCA.rca.serviceProvider, _signedRCA.rca.dataService); + vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementAccepted( _signedRCA.rca.dataService, @@ -88,6 +96,25 @@ contract RecurringCollectorSharedTest is Test, Bounder { _recurringCollector.accept(_signedRCA); } + function _setupValidProvision(address _serviceProvider, address _dataService) internal { + _horizonStaking.setProvision( + _serviceProvider, + _dataService, + IHorizonStakingTypes.Provision({ + tokens: 1000 ether, + tokensThawing: 0, + sharesThawing: 0, + maxVerifierCut: 100000, // 10% + thawingPeriod: 604800, // 7 days + createdAt: uint64(block.timestamp), + maxVerifierCutPending: 100000, + thawingPeriodPending: 604800, + lastParametersStagedAt: 0, + thawingNonce: 0 + }) + ); + } + function _cancel( IRecurringCollector.RecurringCollectionAgreement memory _rca, IRecurringCollector.CancelAgreementBy _by From 29dfdccadf74dce4b7a52ae658328ad026f59c9c Mon Sep 17 00:00:00 2001 From: Matias Date: Tue, 22 Jul 2025 15:51:03 -0300 Subject: [PATCH 007/157] fix: [TRST-M-1] correct TYPEHASH string for RCAU Fixes TRST-M-1 audit finding: Wrong TYPEHASH string is used for agreement updates, limiting functionality. * Fixed EIP712_RCAU_TYPEHASH to use correct uint64 types for deadline and endsAt fields (was incorrectly using uint256) * This prevents signature verification failures for RecurringCollectionAgreementUpdate --- .../contracts/payments/collectors/RecurringCollector.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 5f43c482e..4e11fb532 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -35,7 +35,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct bytes32 public constant EIP712_RCAU_TYPEHASH = keccak256( - "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint256 deadline,uint256 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" + "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" ); /// @notice Tracks agreements From 345cfc8d6331e19e4e16900bde3b9348624b123c Mon Sep 17 00:00:00 2001 From: Matias Date: Tue, 22 Jul 2025 21:42:14 -0300 Subject: [PATCH 008/157] fix: [TRST-M-2] shared collection window logic Fixes TRST-M-2 audit finding: Collection for an elapsed or canceled agreement could be wrong due to temporal calculation inconsistencies between IndexingAgreement and RecurringCollector layers. * Replace isCollectable() with getCollectionInfo() that returns both collectability and duration * Make RecurringCollector the single source of truth for temporal logic * Update IndexingAgreement to call getCollectionInfo() once and pass duration to _tokensToCollect() --- .../interfaces/IRecurringCollector.sol | 20 ++-- .../collectors/RecurringCollector.sol | 92 +++++++++++-------- .../recurring-collector/collect.t.sol | 4 + .../contracts/libraries/IndexingAgreement.sol | 32 +++---- 4 files changed, 79 insertions(+), 69 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index ef7ba05f7..cb31125c3 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -290,14 +290,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorInvalidCollectData(bytes invalidData); - /** - * @notice Thrown when calling collect() on a payer canceled agreement - * where the final collection has already been done - * @param agreementId The agreement ID - * @param finalCollectionAt The timestamp when the final collection was done - */ - error RecurringCollectorFinalCollectionDone(bytes16 agreementId, uint256 finalCollectionAt); - /** * @notice Thrown when interacting with an agreement that has an incorrect state * @param agreementId The agreement ID @@ -420,11 +412,13 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { function getAgreement(bytes16 agreementId) external view returns (AgreementData memory); /** - * @notice Checks if an agreement is collectable. - * @dev "Collectable" means the agreement is in a valid state that allows collection attempts, - * not that there are necessarily funds available to collect. + * @notice Get collection info for an agreement * @param agreement The agreement data - * @return The boolean indicating if the agreement is collectable + * @return isCollectable Whether the agreement is in a valid state that allows collection attempts, + * not that there are necessarily funds available to collect. + * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) */ - function isCollectable(AgreementData memory agreement) external view returns (bool); + function getCollectionInfo( + AgreementData memory agreement + ) external view returns (bool isCollectable, uint256 collectionSeconds); } diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 4e11fb532..945f34279 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -246,8 +246,10 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } /// @inheritdoc IRecurringCollector - function isCollectable(AgreementData memory agreement) external pure returns (bool) { - return _isCollectable(agreement); + function getCollectionInfo( + AgreementData memory agreement + ) external view returns (bool isCollectable, uint256 collectionSeconds) { + return _getCollectionInfo(agreement); } /** @@ -274,9 +276,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC CollectParams memory _params ) private returns (uint256) { AgreementData storage agreement = _getAgreementStorage(_params.agreementId); + + // Check if agreement exists first (for unknown agreements) + (bool isCollectable, uint256 collectionSeconds) = _getCollectionInfo(agreement); + require(isCollectable, RecurringCollectorAgreementIncorrectState(_params.agreementId, agreement.state)); + require( - _isCollectable(agreement), - RecurringCollectorAgreementIncorrectState(_params.agreementId, agreement.state) + collectionSeconds > 0, + RecurringCollectorZeroCollectionSeconds(_params.agreementId, block.timestamp, agreement.lastCollectionAt) ); require( @@ -297,7 +304,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC uint256 tokensToCollect = 0; if (_params.tokens != 0) { - tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens); + tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens, collectionSeconds); _graphPaymentsEscrow().collect( _paymentType, @@ -374,53 +381,37 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @param _agreement The agreement data * @param _agreementId The ID of the agreement * @param _tokens The number of tokens to collect + * @param _collectionSeconds Collection duration from _getCollectionInfo() * @return The number of tokens that can be collected */ function _requireValidCollect( AgreementData memory _agreement, bytes16 _agreementId, - uint256 _tokens + uint256 _tokens, + uint256 _collectionSeconds ) private view returns (uint256) { bool canceledOrElapsed = _agreement.state == AgreementState.CanceledByPayer || block.timestamp > _agreement.endsAt; - uint256 canceledOrNow = _agreement.state == AgreementState.CanceledByPayer - ? _agreement.canceledAt - : block.timestamp; - - // if canceled by the payer allow collection till canceledAt - // if elapsed allow collection till endsAt - // if both are true, use the earlier one - uint256 collectionEnd = canceledOrElapsed ? Math.min(canceledOrNow, _agreement.endsAt) : block.timestamp; - uint256 collectionStart = _agreementCollectionStartAt(_agreement); - require( - collectionEnd != collectionStart, - RecurringCollectorZeroCollectionSeconds(_agreementId, block.timestamp, uint64(collectionStart)) - ); - require(collectionEnd > collectionStart, RecurringCollectorFinalCollectionDone(_agreementId, collectionStart)); - - uint256 collectionSeconds = collectionEnd - collectionStart; - // Check that the collection window is long enough - // If the agreement is canceled or elapsed, allow a shorter collection window if (!canceledOrElapsed) { require( - collectionSeconds >= _agreement.minSecondsPerCollection, + _collectionSeconds >= _agreement.minSecondsPerCollection, RecurringCollectorCollectionTooSoon( _agreementId, - uint32(collectionSeconds), + uint32(_collectionSeconds), _agreement.minSecondsPerCollection ) ); } require( - collectionSeconds <= _agreement.maxSecondsPerCollection, + _collectionSeconds <= _agreement.maxSecondsPerCollection, RecurringCollectorCollectionTooLate( _agreementId, - uint64(collectionSeconds), + uint64(_collectionSeconds), _agreement.maxSecondsPerCollection ) ); - uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * collectionSeconds; + uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * _collectionSeconds; maxTokens += _agreement.lastCollectionAt == 0 ? _agreement.maxInitialTokens : 0; return Math.min(_tokens, maxTokens); @@ -546,20 +537,47 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } /** - * @notice Gets the start time for the collection of an agreement. + * @notice Internal function to get collection info for an agreement + * @dev This is the single source of truth for collection window logic * @param _agreement The agreement data - * @return The start time for the collection of the agreement + * @return isCollectable Whether the agreement can be collected from + * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) */ - function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { - return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; + function _getCollectionInfo( + AgreementData memory _agreement + ) private view returns (bool isCollectable, uint256 collectionSeconds) { + // Check if agreement is in collectable state + isCollectable = + _agreement.state == AgreementState.Accepted || + _agreement.state == AgreementState.CanceledByPayer; + + if (!isCollectable) { + return (false, 0); + } + + bool canceledOrElapsed = _agreement.state == AgreementState.CanceledByPayer || + block.timestamp > _agreement.endsAt; + uint256 canceledOrNow = _agreement.state == AgreementState.CanceledByPayer + ? _agreement.canceledAt + : block.timestamp; + + uint256 collectionEnd = canceledOrElapsed ? Math.min(canceledOrNow, _agreement.endsAt) : block.timestamp; + uint256 collectionStart = _agreementCollectionStartAt(_agreement); + + if (collectionEnd < collectionStart) { + return (false, 0); + } + + collectionSeconds = collectionEnd - collectionStart; + return (isCollectable, collectionSeconds); } /** - * @notice Requires that the agreement is collectable. + * @notice Gets the start time for the collection of an agreement. * @param _agreement The agreement data - * @return The boolean indicating if the agreement is collectable + * @return The start time for the collection of the agreement */ - function _isCollectable(AgreementData memory _agreement) private pure returns (bool) { - return _agreement.state == AgreementState.Accepted || _agreement.state == AgreementState.CanceledByPayer; + function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { + return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 0002c68af..c99098c7b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -32,6 +32,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; + skip(1); + collectParams.agreementId = accepted.rca.agreementId; bytes memory data = _generateCollectData(collectParams); @@ -53,6 +55,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { collectParams.tokens = bound(collectParams.tokens, 1, type(uint256).max); bytes memory data = _generateCollectData(collectParams); + skip(1); + // Set up the scenario where service provider has no tokens staked with data service // This simulates an unauthorized data service attack _horizonStaking.setProvision( diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 1b07922c7..ce94418ac 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -529,7 +529,11 @@ library IndexingAgreement { allocation.indexer == params.indexer, IndexingAgreementNotAuthorized(params.agreementId, params.indexer) ); - require(_isCollectable(wrapper), IndexingAgreementNotCollectable(params.agreementId)); + // Get collection info from RecurringCollector (single source of truth for temporal logic) + (bool isCollectable, uint256 collectionSeconds) = _directory().recurringCollector().getCollectionInfo( + wrapper.collectorAgreement + ); + require(_isValid(wrapper) && isCollectable, IndexingAgreementNotCollectable(params.agreementId)); require( wrapper.agreement.version == IndexingAgreementVersion.V1, @@ -540,7 +544,7 @@ library IndexingAgreement { uint256 expectedTokens = (data.entities == 0 && data.poi == bytes32(0)) ? 0 - : _tokensToCollect(self, params.agreementId, wrapper.collectorAgreement, data.entities); + : _tokensToCollect(self, params.agreementId, data.entities, collectionSeconds); // `tokensCollected` <= `expectedTokens` because the recurring collector will further narrow // down the tokens allowed, based on the RCA terms. @@ -677,28 +681,21 @@ library IndexingAgreement { } /** - * @notice Calculate the number of tokens to collect for an indexing agreement. - * - * @dev This function calculates the number of tokens to collect based on the agreement terms and the collection time. - * - * @param _manager The indexing agreement storage manager - * @param _agreementId The id of the agreement - * @param _agreement The collector agreement data + * @notice Calculate tokens to collect based on pre-validated duration + * @param _manager The storage manager + * @param _agreementId The agreement ID * @param _entities The number of entities indexed + * @param _collectionSeconds Pre-calculated valid collection duration * @return The number of tokens to collect */ function _tokensToCollect( StorageManager storage _manager, bytes16 _agreementId, - IRecurringCollector.AgreementData memory _agreement, - uint256 _entities + uint256 _entities, + uint256 _collectionSeconds ) private view returns (uint256) { IndexingAgreementTermsV1 memory termsV1 = _manager.termsV1[_agreementId]; - - uint256 collectionSeconds = block.timestamp; - collectionSeconds -= _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; - - return collectionSeconds * (termsV1.tokensPerSecond + termsV1.tokensPerEntityPerSecond * _entities); + return _collectionSeconds * (termsV1.tokensPerSecond + termsV1.tokensPerEntityPerSecond * _entities); } /** @@ -721,9 +718,6 @@ library IndexingAgreement { * @param wrapper The agreement wrapper containing the indexing agreement and collector agreement data * @return True if the agreement is collectable, false otherwise **/ - function _isCollectable(AgreementWrapper memory wrapper) private view returns (bool) { - return _isValid(wrapper) && _directory().recurringCollector().isCollectable(wrapper.collectorAgreement); - } /** * @notice Checks if the agreement is valid From 8b2e93a342fd1b5e22b3b314927849699e108c33 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 23 Jul 2025 11:55:45 -0300 Subject: [PATCH 009/157] fix: [TRST-M-3] Add nonce-based replay protection Fixes signature replay attack vulnerability where old signed RecurringCollectionAgreementUpdate messages could be replayed to revert agreements to previous terms. ## Changes - Add `nonce` field to RecurringCollectionAgreementUpdate struct (uint32) - Add `updateNonce` field to AgreementData struct to track current nonce - Add nonce validation in RecurringCollector.update() to ensure sequential updates - Update EIP712_RCAU_TYPEHASH to include nonce field - Add comprehensive tests for nonce validation and replay attack prevention - Add RecurringCollectorInvalidUpdateNonce error for invalid nonce attempts ## Implementation Details - Nonces start at 0 when agreement is accepted - Each update must use current nonce + 1 - Nonce is incremented after successful update - Uses uint32 for gas optimization (supports 4B+ updates per agreement) - Single source of truth: nonce stored in AgreementData struct --- .../interfaces/IRecurringCollector.sol | 12 ++ .../collectors/RecurringCollector.sol | 12 +- .../RecurringCollectorHelper.t.sol | 11 ++ .../payments/recurring-collector/update.t.sol | 149 +++++++++++++++++- .../indexing-agreement/shared.t.sol | 10 +- .../indexing-agreement/update.t.sol | 2 + 6 files changed, 189 insertions(+), 7 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index cb31125c3..19388062b 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -90,6 +90,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param nonce The nonce for preventing replay attacks (must be current nonce + 1) * @param metadata Arbitrary metadata to extend functionality if a data service requires it */ struct RecurringCollectionAgreementUpdate { @@ -100,6 +101,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 maxOngoingTokensPerSecond; uint32 minSecondsPerCollection; uint32 maxSecondsPerCollection; + uint32 nonce; bytes metadata; } @@ -118,6 +120,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param updateNonce The current nonce for updates (prevents replay attacks) * @param canceledAt The timestamp when the agreement was canceled * @param state The state of the agreement */ @@ -132,6 +135,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 maxOngoingTokensPerSecond; uint32 minSecondsPerCollection; uint32 maxSecondsPerCollection; + uint32 updateNonce; uint64 canceledAt; AgreementState state; } @@ -357,6 +361,14 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorCollectionTooLate(bytes16 agreementId, uint64 secondsSinceLast, uint32 maxSeconds); + /** + * @notice Thrown when calling update() with an invalid nonce + * @param agreementId The agreement ID + * @param expected The expected nonce + * @param provided The provided nonce + */ + error RecurringCollectorInvalidUpdateNonce(bytes16 agreementId, uint32 expected, uint32 provided); + /** * @dev Accept an indexing agreement. * @param signedRCA The signed Recurring Collection Agreement which is to be accepted. diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 945f34279..e16db74db 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -35,7 +35,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct bytes32 public constant EIP712_RCAU_TYPEHASH = keccak256( - "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" + "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint32 nonce,bytes metadata)" ); /// @notice Tracks agreements @@ -120,6 +120,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.maxOngoingTokensPerSecond = signedRCA.rca.maxOngoingTokensPerSecond; agreement.minSecondsPerCollection = signedRCA.rca.minSecondsPerCollection; agreement.maxSecondsPerCollection = signedRCA.rca.maxSecondsPerCollection; + agreement.updateNonce = 0; emit AgreementAccepted( agreement.dataService, @@ -193,6 +194,13 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC // check that the voucher is signed by the payer (or proxy) _requireAuthorizedRCAUSigner(signedRCAU, agreement.payer); + // validate nonce to prevent replay attacks + uint32 expectedNonce = agreement.updateNonce + 1; + require( + signedRCAU.rcau.nonce == expectedNonce, + RecurringCollectorInvalidUpdateNonce(signedRCAU.rcau.agreementId, expectedNonce, signedRCAU.rcau.nonce) + ); + _requireValidCollectionWindowParams( signedRCAU.rcau.endsAt, signedRCAU.rcau.minSecondsPerCollection, @@ -205,6 +213,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.maxOngoingTokensPerSecond = signedRCAU.rcau.maxOngoingTokensPerSecond; agreement.minSecondsPerCollection = signedRCAU.rcau.minSecondsPerCollection; agreement.maxSecondsPerCollection = signedRCAU.rcau.maxSecondsPerCollection; + agreement.updateNonce = signedRCAU.rcau.nonce; emit AgreementUpdated( agreement.dataService, @@ -482,6 +491,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _rcau.maxOngoingTokensPerSecond, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection, + _rcau.nonce, keccak256(_rcau.metadata) ) ) diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index b3ccbc3b8..611f554e7 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -45,6 +45,17 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { return signedRCAU; } + function generateSignedRCAUWithCorrectNonce( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + uint256 signerPrivateKey + ) public view returns (IRecurringCollector.SignedRCAU memory) { + // Automatically set the correct nonce based on current agreement state + IRecurringCollector.AgreementData memory agreement = collector.getAgreement(rcau.agreementId); + rcau.nonce = agreement.updateNonce + 1; + + return generateSignedRCAU(rcau, signerPrivateKey); + } + function withElapsedAcceptDeadline( IRecurringCollector.RecurringCollectionAgreement memory rca ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index 4fd8af1e7..1676fc0bc 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -76,7 +76,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { ); rcau.agreementId = accepted.rca.agreementId; - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAUWithCorrectNonce( rcau, signerKey ); @@ -124,6 +124,8 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { fuzzyTestUpdate.rcau ); rcau.agreementId = accepted.rca.agreementId; + // Don't use fuzzed nonce - use correct nonce for first update + rcau.nonce = 1; IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( rcau, signerKey @@ -151,6 +153,151 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); assertEq(rcau.minSecondsPerCollection, agreement.minSecondsPerCollection); assertEq(rcau.maxSecondsPerCollection, agreement.maxSecondsPerCollection); + assertEq(rcau.nonce, agreement.updateNonce); + } + + function test_Update_Revert_WhenInvalidNonce_TooLow(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = accepted.rca.agreementId; + rcau.nonce = 0; // Invalid: should be 1 for first update + + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + rcau, + signerKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, + rcau.agreementId, + 1, // expected + 0 // provided + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_Revert_WhenInvalidNonce_TooHigh(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = accepted.rca.agreementId; + rcau.nonce = 5; // Invalid: should be 1 for first update + + IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( + rcau, + signerKey + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, + rcau.agreementId, + 1, // expected + 5 // provided + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU); + } + + function test_Update_Revert_WhenReplayAttack(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau1.agreementId = accepted.rca.agreementId; + rcau1.nonce = 1; + + // First update succeeds + IRecurringCollector.SignedRCAU memory signedRCAU1 = _recurringCollectorHelper.generateSignedRCAU( + rcau1, + signerKey + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU1); + + // Second update with different terms and nonce 2 succeeds + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = rcau1; + rcau2.nonce = 2; + rcau2.maxOngoingTokensPerSecond = rcau1.maxOngoingTokensPerSecond * 2; // Different terms + + IRecurringCollector.SignedRCAU memory signedRCAU2 = _recurringCollectorHelper.generateSignedRCAU( + rcau2, + signerKey + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU2); + + // Attempting to replay first update should fail + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, + rcau1.agreementId, + 3, // expected (current nonce + 1) + 1 // provided (old nonce) + ); + vm.expectRevert(expectedErr); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU1); + } + + function test_Update_OK_NonceIncrementsCorrectly(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( + fuzzyTestUpdate.fuzzyTestAccept + ); + + // Initial nonce should be 0 + IRecurringCollector.AgreementData memory initialAgreement = _recurringCollector.getAgreement( + accepted.rca.agreementId + ); + assertEq(initialAgreement.updateNonce, 0); + + // First update with nonce 1 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau1.agreementId = accepted.rca.agreementId; + rcau1.nonce = 1; + + IRecurringCollector.SignedRCAU memory signedRCAU1 = _recurringCollectorHelper.generateSignedRCAU( + rcau1, + signerKey + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU1); + + // Verify nonce incremented to 1 + IRecurringCollector.AgreementData memory updatedAgreement1 = _recurringCollector.getAgreement( + accepted.rca.agreementId + ); + assertEq(updatedAgreement1.updateNonce, 1); + + // Second update with nonce 2 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = rcau1; + rcau2.nonce = 2; + rcau2.maxOngoingTokensPerSecond = rcau1.maxOngoingTokensPerSecond * 2; // Different terms + + IRecurringCollector.SignedRCAU memory signedRCAU2 = _recurringCollectorHelper.generateSignedRCAU( + rcau2, + signerKey + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.update(signedRCAU2); + + // Verify nonce incremented to 2 + IRecurringCollector.AgreementData memory updatedAgreement2 = _recurringCollector.getAgreement( + accepted.rca.agreementId + ); + assertEq(updatedAgreement2.updateNonce, 2); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index 2a5b2385a..c23727f20 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -255,11 +255,11 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun Context storage _ctx, IRecurringCollector.RecurringCollectionAgreement memory _rca ) internal view returns (IRecurringCollector.SignedRCAU memory) { - return - _recurringCollectorHelper.generateSignedRCAU( - _generateAcceptableRecurringCollectionAgreementUpdate(_ctx, _rca), - _ctx.payer.signerPrivateKey - ); + IRecurringCollector.RecurringCollectionAgreementUpdate + memory rcau = _generateAcceptableRecurringCollectionAgreementUpdate(_ctx, _rca); + // Set correct nonce for first update (should be 1) + rcau.nonce = 1; + return _recurringCollectorHelper.generateSignedRCAU(rcau, _ctx.payer.signerPrivateKey); } function _generateAcceptableRecurringCollectionAgreementUpdate( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index 336ef97de..ebd9200d1 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -127,6 +127,8 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableUpdate = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, accepted.rca); acceptableUpdate.metadata = bytes("invalid"); + // Set correct nonce for first update (should be 1) + acceptableUpdate.nonce = 1; IRecurringCollector.SignedRCAU memory unacceptableUpdate = _recurringCollectorHelper.generateSignedRCAU( acceptableUpdate, ctx.payer.signerPrivateKey From aac9f8b7d9db82d854b73dd3c2c140e256ba13d4 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 23 Jul 2025 16:06:59 -0300 Subject: [PATCH 010/157] fix: [TRST-L-3] Add deterministic agreement ID --- .../interfaces/IRecurringCollector.sol | 24 ++++- .../collectors/RecurringCollector.sol | 54 ++++++++-- .../RecurringCollectorHelper.t.sol | 40 ++++++- .../payments/recurring-collector/accept.t.sol | 16 ++- .../payments/recurring-collector/cancel.t.sol | 26 +++-- .../recurring-collector/collect.t.sol | 53 +++++++--- .../payments/recurring-collector/shared.t.sol | 55 +++++++--- .../payments/recurring-collector/update.t.sol | 100 +++++++++++------- .../contracts/SubgraphService.sol | 4 +- .../contracts/interfaces/ISubgraphService.sol | 6 +- .../contracts/libraries/IndexingAgreement.sol | 23 ++-- .../indexing-agreement/accept.t.sol | 27 ++++- .../indexing-agreement/base.t.sol | 19 ++-- .../indexing-agreement/cancel.t.sol | 43 +++++--- .../indexing-agreement/collect.t.sol | 79 ++++++++------ .../indexing-agreement/integration.t.sol | 16 +-- .../indexing-agreement/shared.t.sol | 28 ++++- .../indexing-agreement/update.t.sol | 6 +- 18 files changed, 449 insertions(+), 170 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index 19388062b..704515aa7 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -40,7 +40,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { /** * @notice The Recurring Collection Agreement (RCA) - * @param agreementId The agreement ID of the RCA * @param deadline The deadline for accepting the RCA * @param endsAt The timestamp when the agreement ends * @param payer The address of the payer the RCA was issued by @@ -52,11 +51,11 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param nonce A unique nonce for preventing collisions (user-chosen) * @param metadata Arbitrary metadata to extend functionality if a data service requires it * */ struct RecurringCollectionAgreement { - bytes16 agreementId; uint64 deadline; uint64 endsAt; address payer; @@ -66,6 +65,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 maxOngoingTokensPerSecond; uint32 minSecondsPerCollection; uint32 maxSecondsPerCollection; + uint256 nonce; bytes metadata; } @@ -372,8 +372,9 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { /** * @dev Accept an indexing agreement. * @param signedRCA The signed Recurring Collection Agreement which is to be accepted. + * @return agreementId The deterministically generated agreement ID */ - function accept(SignedRCA calldata signedRCA) external; + function accept(SignedRCA calldata signedRCA) external returns (bytes16 agreementId); /** * @dev Cancel an indexing agreement. @@ -433,4 +434,21 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { function getCollectionInfo( AgreementData memory agreement ) external view returns (bool isCollectable, uint256 collectionSeconds); + + /** + * @notice Generate a deterministic agreement ID from agreement parameters + * @param payer The address of the payer + * @param dataService The address of the data service + * @param serviceProvider The address of the service provider + * @param deadline The deadline for accepting the agreement + * @param nonce A unique nonce for preventing collisions + * @return agreementId The deterministically generated agreement ID + */ + function generateAgreementId( + address payer, + address dataService, + address serviceProvider, + uint64 deadline, + uint256 nonce + ) external pure returns (bytes16 agreementId); } diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index e16db74db..56d2b9d5b 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -29,7 +29,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct bytes32 public constant EIP712_RCA_TYPEHASH = keccak256( - "RecurringCollectionAgreement(bytes16 agreementId,uint256 deadline,uint256 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,bytes metadata)" + "RecurringCollectionAgreement(uint64 deadline,uint64 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint256 nonce,bytes metadata)" ); /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct @@ -75,8 +75,16 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * See {IRecurringCollector.accept}. * @dev Caller must be the data service the RCA was issued to. */ - function accept(SignedRCA calldata signedRCA) external { - require(signedRCA.rca.agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); + function accept(SignedRCA calldata signedRCA) external returns (bytes16) { + bytes16 agreementId = _generateAgreementId( + signedRCA.rca.payer, + signedRCA.rca.dataService, + signedRCA.rca.serviceProvider, + signedRCA.rca.deadline, + signedRCA.rca.nonce + ); + + require(agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); require( msg.sender == signedRCA.rca.dataService, RecurringCollectorUnauthorizedCaller(msg.sender, signedRCA.rca.dataService) @@ -102,11 +110,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC signedRCA.rca.maxSecondsPerCollection ); - AgreementData storage agreement = _getAgreementStorage(signedRCA.rca.agreementId); + AgreementData storage agreement = _getAgreementStorage(agreementId); // check that the agreement is not already accepted require( agreement.state == AgreementState.NotAccepted, - RecurringCollectorAgreementIncorrectState(signedRCA.rca.agreementId, agreement.state) + RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) ); // accept the agreement @@ -126,7 +134,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.dataService, agreement.payer, agreement.serviceProvider, - signedRCA.rca.agreementId, + agreementId, agreement.acceptedAt, agreement.endsAt, agreement.maxInitialTokens, @@ -134,6 +142,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.minSecondsPerCollection, agreement.maxSecondsPerCollection ); + + return agreementId; } /** @@ -261,6 +271,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return _getCollectionInfo(agreement); } + /// @inheritdoc IRecurringCollector + function generateAgreementId( + address payer, + address dataService, + address serviceProvider, + uint64 deadline, + uint256 nonce + ) external pure returns (bytes16) { + return _generateAgreementId(payer, dataService, serviceProvider, deadline, nonce); + } + /** * @notice Decodes the collect data. * @param data The encoded collect parameters. @@ -457,7 +478,6 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC keccak256( abi.encode( EIP712_RCA_TYPEHASH, - _rca.agreementId, _rca.deadline, _rca.endsAt, _rca.payer, @@ -467,6 +487,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _rca.maxOngoingTokensPerSecond, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection, + _rca.nonce, keccak256(_rca.metadata) ) ) @@ -590,4 +611,23 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; } + + /** + * @notice Internal function to generate deterministic agreement ID + * @param _payer The address of the payer + * @param _dataService The address of the data service + * @param _serviceProvider The address of the service provider + * @param _deadline The deadline for accepting the agreement + * @param _nonce A unique nonce for preventing collisions + * @return agreementId The deterministically generated agreement ID + */ + function _generateAgreementId( + address _payer, + address _dataService, + address _serviceProvider, + uint64 _deadline, + uint256 _nonce + ) private pure returns (bytes16) { + return bytes16(keccak256(abi.encode(_payer, _dataService, _serviceProvider, _deadline, _nonce))); + } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index 611f554e7..6ddbdfa0b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -45,17 +45,47 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { return signedRCAU; } - function generateSignedRCAUWithCorrectNonce( + function generateSignedRCAUForAgreement( + bytes16 agreementId, IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, uint256 signerPrivateKey ) public view returns (IRecurringCollector.SignedRCAU memory) { // Automatically set the correct nonce based on current agreement state - IRecurringCollector.AgreementData memory agreement = collector.getAgreement(rcau.agreementId); + IRecurringCollector.AgreementData memory agreement = collector.getAgreement(agreementId); rcau.nonce = agreement.updateNonce + 1; return generateSignedRCAU(rcau, signerPrivateKey); } + function generateSignedRCAUWithCorrectNonce( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + uint256 signerPrivateKey + ) public view returns (IRecurringCollector.SignedRCAU memory) { + // This is kept for backwards compatibility but should not be used with new interface + // since we can't determine agreementId without it being passed separately + return generateSignedRCAU(rcau, signerPrivateKey); + } + + function generateSignedRCAWithCalculatedId( + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint256 signerPrivateKey + ) public view returns (IRecurringCollector.SignedRCA memory, bytes16) { + // Ensure we have sensible values + rca = sensibleRCA(rca); + + // Calculate the agreement ID + bytes16 agreementId = collector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + IRecurringCollector.SignedRCA memory signedRCA = generateSignedRCA(rca, signerPrivateKey); + return (signedRCA, agreementId); + } + function withElapsedAcceptDeadline( IRecurringCollector.RecurringCollectionAgreement memory rca ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { @@ -76,11 +106,15 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { function sensibleRCA( IRecurringCollector.RecurringCollectionAgreement memory rca ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory) { - vm.assume(rca.agreementId != bytes16(0)); vm.assume(rca.dataService != address(0)); vm.assume(rca.payer != address(0)); vm.assume(rca.serviceProvider != address(0)); + // Ensure we have a nonce if it's zero + if (rca.nonce == 0) { + rca.nonce = 1; + } + rca.minSecondsPerCollection = _sensibleMinSecondsPerCollection(rca.minSecondsPerCollection); rca.maxSecondsPerCollection = _sensibleMaxSecondsPerCollection( rca.maxSecondsPerCollection, diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index d9479b955..f7a4c3823 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -20,7 +20,15 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { IRecurringCollector.SignedRCA memory fuzzySignedRCA, uint256 unboundedSkip ) public { - vm.assume(fuzzySignedRCA.rca.agreementId != bytes16(0)); + // Generate deterministic agreement ID for validation + bytes16 agreementId = _recurringCollector.generateAgreementId( + fuzzySignedRCA.rca.payer, + fuzzySignedRCA.rca.dataService, + fuzzySignedRCA.rca.serviceProvider, + fuzzySignedRCA.rca.deadline, + fuzzySignedRCA.rca.nonce + ); + vm.assume(agreementId != bytes16(0)); skip(boundSkip(unboundedSkip, 1, type(uint64).max - block.timestamp)); fuzzySignedRCA.rca = _recurringCollectorHelper.withElapsedAcceptDeadline(fuzzySignedRCA.rca); @@ -35,11 +43,13 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { } function test_Accept_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzyTestAccept + ); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, - accepted.rca.agreementId, + agreementId, IRecurringCollector.AgreementState.Accepted ); vm.expectRevert(expectedErr); diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol index fe938c825..fa3b595a0 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol @@ -13,22 +13,34 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ function test_Cancel(FuzzyTestAccept calldata fuzzyTestAccept, uint8 unboundedCanceler) public { - _sensibleAuthorizeAndAccept(fuzzyTestAccept); - _cancel(fuzzyTestAccept.rca, _fuzzyCancelAgreementBy(unboundedCanceler)); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzyTestAccept + ); + + _cancel(accepted.rca, agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); } function test_Cancel_Revert_WhenNotAccepted( IRecurringCollector.RecurringCollectionAgreement memory fuzzyRCA, uint8 unboundedCanceler ) public { + // Generate deterministic agreement ID + bytes16 agreementId = _recurringCollector.generateAgreementId( + fuzzyRCA.payer, + fuzzyRCA.dataService, + fuzzyRCA.serviceProvider, + fuzzyRCA.deadline, + fuzzyRCA.nonce + ); + bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, - fuzzyRCA.agreementId, + agreementId, IRecurringCollector.AgreementState.NotAccepted ); vm.expectRevert(expectedErr); vm.prank(fuzzyRCA.dataService); - _recurringCollector.cancel(fuzzyRCA.agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); + _recurringCollector.cancel(agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); } function test_Cancel_Revert_WhenNotDataService( @@ -38,16 +50,16 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { ) public { vm.assume(fuzzyTestAccept.rca.dataService != notDataService); - _sensibleAuthorizeAndAccept(fuzzyTestAccept); + (, , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, - fuzzyTestAccept.rca.agreementId, + agreementId, notDataService ); vm.expectRevert(expectedErr); vm.prank(notDataService); - _recurringCollector.cancel(fuzzyTestAccept.rca.agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); + _recurringCollector.cancel(agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index c99098c7b..a972734a6 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -29,12 +29,11 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ) public { vm.assume(fuzzy.fuzzyTestAccept.rca.dataService != notDataService); - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (, , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; skip(1); - - collectParams.agreementId = accepted.rca.agreementId; + collectParams.agreementId = agreementId; bytes memory data = _generateCollectData(collectParams); bytes memory expectedErr = abi.encodeWithSelector( @@ -48,10 +47,11 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { } function test_Collect_Revert_WhenUnauthorizedDataService(FuzzyTestCollect calldata fuzzy) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; - - collectParams.agreementId = accepted.rca.agreementId; + collectParams.agreementId = agreementId; collectParams.tokens = bound(collectParams.tokens, 1, type(uint256).max); bytes memory data = _generateCollectData(collectParams); @@ -99,12 +99,15 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { } function test_Collect_Revert_WhenCanceledAgreementByServiceProvider(FuzzyTestCollect calldata fuzzy) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); - _cancel(accepted.rca, IRecurringCollector.CancelAgreementBy.ServiceProvider); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); + _cancel(accepted.rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); IRecurringCollector.CollectParams memory collectData = fuzzy.collectParams; collectData.tokens = bound(collectData.tokens, 1, type(uint256).max); IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( accepted.rca, + agreementId, collectData.collectionId, collectData.tokens, collectData.dataServiceCut @@ -125,12 +128,15 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { FuzzyTestCollect calldata fuzzy, uint256 unboundedCollectionSeconds ) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); skip(accepted.rca.minSecondsPerCollection); bytes memory data = _generateCollectData( _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut @@ -144,6 +150,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, bound(fuzzy.collectParams.tokens, 1, type(uint256).max), fuzzy.collectParams.dataServiceCut @@ -165,9 +172,12 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedFirstCollectionSeconds, uint256 unboundedSecondCollectionSeconds ) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); // skip to collectable time + skip( boundSkip( unboundedFirstCollectionSeconds, @@ -178,6 +188,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { bytes memory data = _generateCollectData( _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut @@ -197,6 +208,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { data = _generateCollectData( _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, bound(fuzzy.collectParams.tokens, 1, type(uint256).max), fuzzy.collectParams.dataServiceCut @@ -204,7 +216,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorCollectionTooLate.selector, - accepted.rca.agreementId, + agreementId, collectionSeconds, accepted.rca.maxSecondsPerCollection ); @@ -220,7 +232,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedTokens, bool testInitialCollection ) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); if (!testInitialCollection) { // skip to collectable time @@ -234,6 +248,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { bytes memory initialData = _generateCollectData( _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut @@ -255,6 +270,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 tokens = bound(unboundedTokens, maxTokens + 1, type(uint256).max); IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( accepted.rca, + agreementId, fuzzy.collectParams.collectionId, tokens, fuzzy.collectParams.dataServiceCut @@ -270,7 +286,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedCollectionSeconds, uint256 unboundedTokens ) public { - (IRecurringCollector.SignedRCA memory accepted, ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); (bytes memory data, uint256 collectionSeconds, uint256 tokens) = _generateValidCollection( accepted.rca, @@ -278,8 +296,15 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { unboundedCollectionSeconds, unboundedTokens ); + skip(collectionSeconds); - _expectCollectCallAndEmit(accepted.rca, _paymentType(fuzzy.unboundedPaymentType), fuzzy.collectParams, tokens); + _expectCollectCallAndEmit( + accepted.rca, + agreementId, + _paymentType(fuzzy.unboundedPaymentType), + fuzzy.collectParams, + tokens + ); vm.prank(accepted.rca.dataService); uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, tokens); diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index d8d9483e7..9a564086e 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -54,37 +54,47 @@ contract RecurringCollectorSharedTest is Test, Bounder { function _sensibleAuthorizeAndAccept( FuzzyTestAccept calldata _fuzzyTestAccept - ) internal returns (IRecurringCollector.SignedRCA memory, uint256 key) { + ) internal returns (IRecurringCollector.SignedRCA memory, uint256 key, bytes16 agreementId) { IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( _fuzzyTestAccept.rca ); key = boundKey(_fuzzyTestAccept.unboundedSignerKey); - return (_authorizeAndAccept(rca, key), key); + IRecurringCollector.SignedRCA memory signedRCA; + (signedRCA, agreementId) = _authorizeAndAccept(rca, key); + return (signedRCA, key, agreementId); } // authorizes signer, signs the RCA, and accepts it function _authorizeAndAccept( IRecurringCollector.RecurringCollectionAgreement memory _rca, uint256 _signerKey - ) internal returns (IRecurringCollector.SignedRCA memory) { + ) internal returns (IRecurringCollector.SignedRCA memory, bytes16 agreementId) { _recurringCollectorHelper.authorizeSignerWithChecks(_rca.payer, _signerKey); IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(_rca, _signerKey); - _accept(signedRCA); - - return signedRCA; + agreementId = _accept(signedRCA); + return (signedRCA, agreementId); } - function _accept(IRecurringCollector.SignedRCA memory _signedRCA) internal { + function _accept(IRecurringCollector.SignedRCA memory _signedRCA) internal returns (bytes16) { // Set up valid staking provision by default to allow collections to succeed _setupValidProvision(_signedRCA.rca.serviceProvider, _signedRCA.rca.dataService); + // Calculate the expected agreement ID for verification + bytes16 expectedAgreementId = _recurringCollector.generateAgreementId( + _signedRCA.rca.payer, + _signedRCA.rca.dataService, + _signedRCA.rca.serviceProvider, + _signedRCA.rca.deadline, + _signedRCA.rca.nonce + ); + vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementAccepted( _signedRCA.rca.dataService, _signedRCA.rca.payer, _signedRCA.rca.serviceProvider, - _signedRCA.rca.agreementId, + expectedAgreementId, uint64(block.timestamp), _signedRCA.rca.endsAt, _signedRCA.rca.maxInitialTokens, @@ -93,7 +103,11 @@ contract RecurringCollectorSharedTest is Test, Bounder { _signedRCA.rca.maxSecondsPerCollection ); vm.prank(_signedRCA.rca.dataService); - _recurringCollector.accept(_signedRCA); + bytes16 actualAgreementId = _recurringCollector.accept(_signedRCA); + + // Verify the agreement ID matches expectation + assertEq(actualAgreementId, expectedAgreementId); + return actualAgreementId; } function _setupValidProvision(address _serviceProvider, address _dataService) internal { @@ -117,6 +131,7 @@ contract RecurringCollectorSharedTest is Test, Bounder { function _cancel( IRecurringCollector.RecurringCollectionAgreement memory _rca, + bytes16 _agreementId, IRecurringCollector.CancelAgreementBy _by ) internal { vm.expectEmit(address(_recurringCollector)); @@ -124,16 +139,17 @@ contract RecurringCollectorSharedTest is Test, Bounder { _rca.dataService, _rca.payer, _rca.serviceProvider, - _rca.agreementId, + _agreementId, uint64(block.timestamp), _by ); vm.prank(_rca.dataService); - _recurringCollector.cancel(_rca.agreementId, _by); + _recurringCollector.cancel(_agreementId, _by); } function _expectCollectCallAndEmit( IRecurringCollector.RecurringCollectionAgreement memory _rca, + bytes16 _agreementId, IGraphPayments.PaymentTypes __paymentType, IRecurringCollector.CollectParams memory _fuzzyParams, uint256 _tokens @@ -168,7 +184,7 @@ contract RecurringCollectorSharedTest is Test, Bounder { _rca.dataService, _rca.payer, _rca.serviceProvider, - _rca.agreementId, + _agreementId, _fuzzyParams.collectionId, _tokens, _fuzzyParams.dataServiceCut @@ -187,8 +203,18 @@ contract RecurringCollectorSharedTest is Test, Bounder { _rca.maxSecondsPerCollection ); uint256 tokens = bound(_unboundedTokens, 1, _rca.maxOngoingTokensPerSecond * collectionSeconds); + + // Generate the agreement ID deterministically + bytes16 agreementId = _recurringCollector.generateAgreementId( + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.deadline, + _rca.nonce + ); + bytes memory data = _generateCollectData( - _generateCollectParams(_rca, _fuzzyParams.collectionId, tokens, _fuzzyParams.dataServiceCut) + _generateCollectParams(_rca, agreementId, _fuzzyParams.collectionId, tokens, _fuzzyParams.dataServiceCut) ); return (data, collectionSeconds, tokens); @@ -196,13 +222,14 @@ contract RecurringCollectorSharedTest is Test, Bounder { function _generateCollectParams( IRecurringCollector.RecurringCollectionAgreement memory _rca, + bytes16 _agreementId, bytes32 _collectionId, uint256 _tokens, uint256 _dataServiceCut ) internal pure returns (IRecurringCollector.CollectParams memory) { return IRecurringCollector.CollectParams({ - agreementId: _rca.agreementId, + agreementId: _agreementId, collectionId: _collectionId, tokens: _tokens, dataServiceCut: _dataServiceCut, diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index 1676fc0bc..ea34f895b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -19,7 +19,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { ) public { rca = _recurringCollectorHelper.sensibleRCA(rca); rcau = _recurringCollectorHelper.sensibleRCAU(rcau); - rcau.agreementId = rca.agreementId; + // Generate deterministic agreement ID + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + rcau.agreementId = agreementId; boundSkipCeil(unboundedUpdateSkip, type(uint64).max); rcau.deadline = uint64(bound(rcau.deadline, 0, block.timestamp - 1)); @@ -44,7 +52,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { ) public { rca = _recurringCollectorHelper.sensibleRCA(rca); rcau = _recurringCollectorHelper.sensibleRCAU(rcau); - rcau.agreementId = rca.agreementId; + // Generate deterministic agreement ID + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + rcau.agreementId = agreementId; rcau.deadline = uint64(block.timestamp); IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ @@ -67,14 +83,12 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { address notDataService ) public { vm.assume(fuzzyTestUpdate.fuzzyTestAccept.rca.dataService != notDataService); - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + (, uint256 signerKey, bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau.agreementId = accepted.rca.agreementId; + rcau.agreementId = agreementId; IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAUWithCorrectNonce( rcau, @@ -95,16 +109,18 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { FuzzyTestUpdate calldata fuzzyTestUpdate, uint256 unboundedInvalidSignerKey ) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); uint256 invalidSignerKey = boundKey(unboundedInvalidSignerKey); vm.assume(signerKey != invalidSignerKey); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau.agreementId = accepted.rca.agreementId; + rcau.agreementId = agreementId; IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( rcau, @@ -117,13 +133,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { } function test_Update_OK(FuzzyTestUpdate calldata fuzzyTestUpdate) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau.agreementId = accepted.rca.agreementId; + rcau.agreementId = agreementId; // Don't use fuzzed nonce - use correct nonce for first update rcau.nonce = 1; IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( @@ -147,7 +165,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { vm.prank(accepted.rca.dataService); _recurringCollector.update(signedRCAU); - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(accepted.rca.agreementId); + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(rcau.endsAt, agreement.endsAt); assertEq(rcau.maxInitialTokens, agreement.maxInitialTokens); assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); @@ -157,13 +175,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { } function test_Update_Revert_WhenInvalidNonce_TooLow(FuzzyTestUpdate calldata fuzzyTestUpdate) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau.agreementId = accepted.rca.agreementId; + rcau.agreementId = agreementId; rcau.nonce = 0; // Invalid: should be 1 for first update IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( @@ -183,13 +203,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { } function test_Update_Revert_WhenInvalidNonce_TooHigh(FuzzyTestUpdate calldata fuzzyTestUpdate) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau.agreementId = accepted.rca.agreementId; + rcau.agreementId = agreementId; rcau.nonce = 5; // Invalid: should be 1 for first update IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( @@ -209,13 +231,15 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { } function test_Update_Revert_WhenReplayAttack(FuzzyTestUpdate calldata fuzzyTestUpdate) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau1.agreementId = accepted.rca.agreementId; + rcau1.agreementId = agreementId; rcau1.nonce = 1; // First update succeeds @@ -251,21 +275,21 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { } function test_Update_OK_NonceIncrementsCorrectly(FuzzyTestUpdate calldata fuzzyTestUpdate) public { - (IRecurringCollector.SignedRCA memory accepted, uint256 signerKey) = _sensibleAuthorizeAndAccept( - fuzzyTestUpdate.fuzzyTestAccept - ); + ( + IRecurringCollector.SignedRCA memory accepted, + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); // Initial nonce should be 0 - IRecurringCollector.AgreementData memory initialAgreement = _recurringCollector.getAgreement( - accepted.rca.agreementId - ); + IRecurringCollector.AgreementData memory initialAgreement = _recurringCollector.getAgreement(agreementId); assertEq(initialAgreement.updateNonce, 0); // First update with nonce 1 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); - rcau1.agreementId = accepted.rca.agreementId; + rcau1.agreementId = agreementId; rcau1.nonce = 1; IRecurringCollector.SignedRCAU memory signedRCAU1 = _recurringCollectorHelper.generateSignedRCAU( @@ -276,9 +300,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { _recurringCollector.update(signedRCAU1); // Verify nonce incremented to 1 - IRecurringCollector.AgreementData memory updatedAgreement1 = _recurringCollector.getAgreement( - accepted.rca.agreementId - ); + IRecurringCollector.AgreementData memory updatedAgreement1 = _recurringCollector.getAgreement(agreementId); assertEq(updatedAgreement1.updateNonce, 1); // Second update with nonce 2 @@ -294,9 +316,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { _recurringCollector.update(signedRCAU2); // Verify nonce incremented to 2 - IRecurringCollector.AgreementData memory updatedAgreement2 = _recurringCollector.getAgreement( - accepted.rca.agreementId - ); + IRecurringCollector.AgreementData memory updatedAgreement2 = _recurringCollector.getAgreement(agreementId); assertEq(updatedAgreement2.updateNonce, 2); } diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 6e77e66f9..d311c6c62 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -420,6 +420,7 @@ contract SubgraphService is * * @param allocationId The id of the allocation * @param signedRCA The signed Recurring Collection Agreement + * @return agreementId The ID of the accepted indexing agreement */ function acceptIndexingAgreement( address allocationId, @@ -430,8 +431,9 @@ contract SubgraphService is onlyAuthorizedForProvision(signedRCA.rca.serviceProvider) onlyValidProvision(signedRCA.rca.serviceProvider) onlyRegisteredIndexer(signedRCA.rca.serviceProvider) + returns (bytes16) { - IndexingAgreement._getStorageManager().accept(_allocations, allocationId, signedRCA); + return IndexingAgreement._getStorageManager().accept(_allocations, allocationId, signedRCA); } /** diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index 2a852ffce..17ff4cbd0 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -263,8 +263,12 @@ interface ISubgraphService is IDataServiceFees { * @notice Accept an indexing agreement. * @param allocationId The id of the allocation * @param signedRCA The signed recurring collector agreement (RCA) that the indexer accepts + * @return agreementId The ID of the accepted indexing agreement */ - function acceptIndexingAgreement(address allocationId, IRecurringCollector.SignedRCA calldata signedRCA) external; + function acceptIndexingAgreement( + address allocationId, + IRecurringCollector.SignedRCA calldata signedRCA + ) external returns (bytes16); /** * @notice Update an indexing agreement. diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index ce94418ac..d1f42f2b5 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -293,7 +293,7 @@ library IndexingAgreement { mapping(address allocationId => Allocation.State allocation) storage allocations, address allocationId, IRecurringCollector.SignedRCA calldata signedRCA - ) external { + ) external returns (bytes16) { Allocation.State memory allocation = _requireValidAllocation( allocations, allocationId, @@ -309,9 +309,17 @@ library IndexingAgreement { signedRCA.rca.metadata ); - State storage agreement = self.agreements[signedRCA.rca.agreementId]; + bytes16 agreementId = _directory().recurringCollector().generateAgreementId( + signedRCA.rca.payer, + signedRCA.rca.dataService, + signedRCA.rca.serviceProvider, + signedRCA.rca.deadline, + signedRCA.rca.nonce + ); + + State storage agreement = self.agreements[agreementId]; - require(agreement.allocationId == address(0), IndexingAgreementAlreadyAccepted(signedRCA.rca.agreementId)); + require(agreement.allocationId == address(0), IndexingAgreementAlreadyAccepted(agreementId)); require( allocation.subgraphDeploymentId == metadata.subgraphDeploymentId, @@ -327,25 +335,26 @@ library IndexingAgreement { self.allocationToActiveAgreementId[allocationId] == bytes16(0), AllocationAlreadyHasIndexingAgreement(allocationId) ); - self.allocationToActiveAgreementId[allocationId] = signedRCA.rca.agreementId; + self.allocationToActiveAgreementId[allocationId] = agreementId; agreement.version = metadata.version; agreement.allocationId = allocationId; require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); - _setTermsV1(self, signedRCA.rca.agreementId, metadata.terms); + _setTermsV1(self, agreementId, metadata.terms); emit IndexingAgreementAccepted( signedRCA.rca.serviceProvider, signedRCA.rca.payer, - signedRCA.rca.agreementId, + agreementId, allocationId, metadata.subgraphDeploymentId, metadata.version, metadata.terms ); - _directory().recurringCollector().accept(signedRCA); + require(_directory().recurringCollector().accept(signedRCA) == agreementId, "internal: agreement ID mismatch"); + return agreementId; } /** diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index 77b18308c..db2a859dd 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -212,11 +212,14 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAccepted(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementAlreadyAccepted.selector, - accepted.rca.agreementId + agreementId ); vm.expectRevert(expectedErr); resetPrank(ctx.indexers[0].addr); @@ -229,10 +232,15 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + IRecurringCollector.RecurringCollectionAgreement memory notAcceptableRCA = acceptable.rca; bytes memory invalidTermsData = bytes("invalid terms data"); - acceptable.rca.metadata = abi.encode( + notAcceptableRCA.metadata = abi.encode( _newAcceptIndexingAgreementMetadataV1Terms(indexerState.subgraphDeploymentId, invalidTermsData) ); + IRecurringCollector.SignedRCA memory notAcceptable = _recurringCollectorHelper.generateSignedRCA( + notAcceptableRCA, + ctx.payer.signerPrivateKey + ); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, @@ -241,7 +249,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, notAcceptable); } function test_SubgraphService_AcceptIndexingAgreement(Seed memory seed) public { @@ -252,11 +260,20 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg acceptable.rca.metadata, (IndexingAgreement.AcceptIndexingAgreementMetadata) ); + // Generate deterministic agreement ID for event expectation + bytes16 expectedAgreementId = recurringCollector.generateAgreementId( + acceptable.rca.payer, + acceptable.rca.dataService, + acceptable.rca.serviceProvider, + acceptable.rca.deadline, + acceptable.rca.nonce + ); + vm.expectEmit(address(subgraphService)); emit IndexingAgreement.IndexingAgreementAccepted( acceptable.rca.serviceProvider, acceptable.rca.payer, - acceptable.rca.agreementId, + expectedAgreementId, indexerState.allocationId, metadata.subgraphDeploymentId, metadata.version, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol index 2eda9dfc0..5b7aba56f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol @@ -13,22 +13,29 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre */ /* solhint-disable graph/func-name-mixedcase */ - function test_SubgraphService_GetIndexingAgreement(Seed memory seed, address operator, bytes16 agreementId) public { + function test_SubgraphService_GetIndexingAgreement( + Seed memory seed, + address operator, + bytes16 fuzzyAgreementId + ) public { vm.assume(_isSafeSubgraphServiceCaller(operator)); resetPrank(address(operator)); // Get unkown indexing agreement - vm.expectRevert(abi.encodeWithSelector(IndexingAgreement.IndexingAgreementNotActive.selector, agreementId)); - subgraphService.getIndexingAgreement(agreementId); + vm.expectRevert( + abi.encodeWithSelector(IndexingAgreement.IndexingAgreementNotActive.selector, fuzzyAgreementId) + ); + subgraphService.getIndexingAgreement(fuzzyAgreementId); // Accept an indexing agreement Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); - IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement( - accepted.rca.agreementId + (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( + ctx, + indexerState ); + IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId); _assertEqualAgreement(accepted.rca, agreement); } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index 60a28169c..2c904f156 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -33,7 +33,10 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg address rando ) public withSafeIndexerOrOperator(rando) { Context storage ctx = _newCtx(seed); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( + ctx, + _withIndexer(ctx) + ); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNonCancelableBy.selector, @@ -42,7 +45,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); resetPrank(rando); - subgraphService.cancelIndexingAgreementByPayer(accepted.rca.agreementId); + subgraphService.cancelIndexingAgreementByPayer(agreementId); } function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenNotAccepted( @@ -67,28 +70,34 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); IRecurringCollector.CancelAgreementBy by = cancelSource ? IRecurringCollector.CancelAgreementBy.ServiceProvider : IRecurringCollector.CancelAgreementBy.Payer; - _cancelAgreement(ctx, accepted.rca.agreementId, indexerState.addr, accepted.rca.payer, by); + _cancelAgreement(ctx, acceptedAgreementId, indexerState.addr, accepted.rca.payer, by); resetPrank(indexerState.addr); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNotActive.selector, - accepted.rca.agreementId + acceptedAgreementId ); vm.expectRevert(expectedErr); - subgraphService.cancelIndexingAgreementByPayer(accepted.rca.agreementId); + subgraphService.cancelIndexingAgreementByPayer(acceptedAgreementId); } function test_SubgraphService_CancelIndexingAgreementByPayer(Seed memory seed) public { Context storage ctx = _newCtx(seed); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( + ctx, + _withIndexer(ctx) + ); _cancelAgreement( ctx, - accepted.rca.agreementId, + acceptedAgreementId, accepted.rca.serviceProvider, accepted.rca.payer, IRecurringCollector.CancelAgreementBy.Payer @@ -184,28 +193,34 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); IRecurringCollector.CancelAgreementBy by = cancelSource ? IRecurringCollector.CancelAgreementBy.ServiceProvider : IRecurringCollector.CancelAgreementBy.Payer; - _cancelAgreement(ctx, accepted.rca.agreementId, accepted.rca.serviceProvider, accepted.rca.payer, by); + _cancelAgreement(ctx, acceptedAgreementId, accepted.rca.serviceProvider, accepted.rca.payer, by); resetPrank(indexerState.addr); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNotActive.selector, - accepted.rca.agreementId + acceptedAgreementId ); vm.expectRevert(expectedErr); - subgraphService.cancelIndexingAgreement(indexerState.addr, accepted.rca.agreementId); + subgraphService.cancelIndexingAgreement(indexerState.addr, acceptedAgreementId); } function test_SubgraphService_CancelIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); + (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( + ctx, + _withIndexer(ctx) + ); _cancelAgreement( ctx, - accepted.rca.agreementId, + acceptedAgreementId, accepted.rca.serviceProvider, accepted.rca.payer, IRecurringCollector.CancelAgreementBy.ServiceProvider diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 6f9c2563d..711154be5 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -29,7 +29,10 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); assertEq(subgraphService.feesProvisionTracker(indexerState.addr), 0, "Should be 0 before collect"); @@ -38,7 +41,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA bytes memory data = abi.encode( IRecurringCollector.CollectParams({ - agreementId: accepted.rca.agreementId, + agreementId: acceptedAgreementId, collectionId: bytes32(uint256(uint160(indexerState.allocationId))), tokens: 0, dataServiceCut: 0, @@ -46,33 +49,18 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA }) ); uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / stakeToFeesRatio); + vm.mockCall( address(recurringCollector), abi.encodeWithSelector(IPaymentsCollector.collect.selector, IGraphPayments.PaymentTypes.IndexingFee, data), abi.encode(tokensCollected) ); - vm.expectCall( - address(recurringCollector), - abi.encodeCall(IPaymentsCollector.collect, (IGraphPayments.PaymentTypes.IndexingFee, data)) - ); - vm.expectEmit(address(subgraphService)); - emit IndexingAgreement.IndexingFeesCollectedV1( - indexerState.addr, - accepted.rca.payer, - accepted.rca.agreementId, - indexerState.allocationId, - indexerState.subgraphDeploymentId, - epochManager.currentEpoch(), - tokensCollected, - entities, - poi, - epochManager.currentEpochBlock(), - bytes("") - ); + _expectCollectCallAndEmit(data, indexerState, accepted, acceptedAgreementId, tokensCollected, entities, poi); + subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, epochManager.currentEpochBlock(), bytes("")) + _encodeCollectDataV1(acceptedAgreementId, entities, poi, epochManager.currentEpochBlock(), bytes("")) ); assertEq( @@ -214,7 +202,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA function test_SubgraphService_CollectIndexingFees_Reverts_WhenInvalidNestedData(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); resetPrank(indexerState.addr); @@ -225,10 +213,11 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA invalidNestedData ); vm.expectRevert(expectedErr); + subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectData(accepted.rca.agreementId, invalidNestedData) + _encodeCollectData(acceptedAgreementId, invalidNestedData) ); } @@ -240,7 +229,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); IndexerState memory otherIndexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); vm.assume(otherIndexerState.addr != indexerState.addr); @@ -250,14 +239,14 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNotAuthorized.selector, - accepted.rca.agreementId, + acceptedAgreementId, otherIndexerState.addr ); vm.expectRevert(expectedErr); subgraphService.collect( otherIndexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + _encodeCollectDataV1(acceptedAgreementId, entities, poi, currentEpochBlock, bytes("")) ); } @@ -268,7 +257,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); resetPrank(indexerState.addr); subgraphService.stopService(indexerState.addr, abi.encode(indexerState.allocationId)); @@ -283,7 +272,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + _encodeCollectDataV1(acceptedAgreementId, entities, poi, currentEpochBlock, bytes("")) ); } @@ -294,7 +283,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); skip(maxPOIStaleness + 1); resetPrank(indexerState.addr); @@ -310,8 +299,38 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectDataV1(accepted.rca.agreementId, entities, poi, currentEpochBlock, bytes("")) + _encodeCollectDataV1(acceptedAgreementId, entities, poi, currentEpochBlock, bytes("")) ); } + /* solhint-enable graph/func-name-mixedcase */ + + function _expectCollectCallAndEmit( + bytes memory _data, + IndexerState memory _indexerState, + IRecurringCollector.SignedRCA memory _accepted, + bytes16 _acceptedAgreementId, + uint256 _tokensCollected, + uint256 _entities, + bytes32 _poi + ) private { + vm.expectCall( + address(recurringCollector), + abi.encodeCall(IPaymentsCollector.collect, (IGraphPayments.PaymentTypes.IndexingFee, _data)) + ); + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingFeesCollectedV1( + _indexerState.addr, + _accepted.rca.payer, + _acceptedAgreementId, + _indexerState.allocationId, + _indexerState.subgraphDeploymentId, + epochManager.currentEpoch(), + _tokensCollected, + _entities, + _poi, + epochManager.currentEpochBlock(), + bytes("") + ); + } } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 5c8758370..45b7db8d8 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -42,7 +42,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); - _sharedSetup(ctx, rca, indexerState, expectedTokens); + bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); @@ -52,7 +52,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, _encodeCollectDataV1( - rca.agreementId, + acceptedAgreementId, 1, keccak256(abi.encodePacked("poi")), epochManager.currentEpochBlock(), @@ -75,11 +75,11 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); - _sharedSetup(ctx, rca, indexerState, expectedTokens); + bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); // Cancel the indexing agreement by the payer resetPrank(ctx.payer.signer); - subgraphService.cancelIndexingAgreementByPayer(rca.agreementId); + subgraphService.cancelIndexingAgreementByPayer(acceptedAgreementId); TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); @@ -89,7 +89,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, _encodeCollectDataV1( - rca.agreementId, + acceptedAgreementId, 1, keccak256(abi.encodePacked("poi")), epochManager.currentEpochBlock(), @@ -108,7 +108,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory _rca, IndexerState memory _indexerState, ExpectedTokens memory _expectedTokens - ) internal { + ) internal returns (bytes16) { _addTokensToProvision(_indexerState, _expectedTokens.expectedTokensLocked); IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ @@ -137,13 +137,15 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex subgraphService.setPaymentsDestination(_indexerState.addr); // Accept the Indexing Agreement - subgraphService.acceptIndexingAgreement( + bytes16 agreementId = subgraphService.acceptIndexingAgreement( _indexerState.allocationId, _recurringCollectorHelper.generateSignedRCA(_rca, _ctx.payer.signerPrivateKey) ); // Skip ahead to collection point skip(_expectedTokens.expectedTotalTokensCollected / terms.tokensPerSecond); + + return agreementId; } function _newExpectedTokens(uint256 _fuzzyTokensCollected) internal view returns (ExpectedTokens memory) { diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index c23727f20..f04be267b 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -169,7 +169,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _withAcceptedIndexingAgreement( Context storage _ctx, IndexerState memory _indexerState - ) internal returns (IRecurringCollector.SignedRCA memory) { + ) internal returns (IRecurringCollector.SignedRCA memory, bytes16 agreementId) { IRecurringCollector.RecurringCollectionAgreement memory rca = _ctx.ctxInternal.seed.rca; IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = _newAcceptIndexingAgreementMetadataV1( @@ -187,20 +187,31 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun ); _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, _ctx.payer.signerPrivateKey); + // Generate deterministic agreement ID for event expectation + agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + vm.expectEmit(address(subgraphService)); emit IndexingAgreement.IndexingAgreementAccepted( rca.serviceProvider, rca.payer, - rca.agreementId, + agreementId, _indexerState.allocationId, metadata.subgraphDeploymentId, metadata.version, metadata.terms ); _subgraphServiceSafePrank(_indexerState.addr); - subgraphService.acceptIndexingAgreement(_indexerState.allocationId, signedRCA); + bytes16 actualAgreementId = subgraphService.acceptIndexingAgreement(_indexerState.allocationId, signedRCA); - return signedRCA; + // Verify the agreement ID matches expectation + assertEq(actualAgreementId, agreementId); + return (signedRCA, agreementId); } function _newCtx(Seed memory _seed) internal returns (Context storage) { @@ -267,7 +278,14 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun IRecurringCollector.RecurringCollectionAgreement memory _rca ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _ctx.ctxInternal.seed.rcau; - rcau.agreementId = _rca.agreementId; + // Generate deterministic agreement ID for the update + rcau.agreementId = recurringCollector.generateAgreementId( + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.deadline, + _rca.nonce + ); rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( _newUpdateIndexingAgreementMetadataV1( _ctx.ctxInternal.seed.termsV1.tokensPerSecond, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index ebd9200d1..ba14d8e55 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -107,7 +107,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA Context storage ctx = _newCtx(seed); IndexerState memory indexerStateA = _withIndexer(ctx); IndexerState memory indexerStateB = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerStateA); + (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerStateA); IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); bytes memory expectedErr = abi.encodeWithSelector( @@ -123,7 +123,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableUpdate = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, accepted.rca); acceptableUpdate.metadata = bytes("invalid"); @@ -147,7 +147,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA function test_SubgraphService_UpdateIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory accepted = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); IndexingAgreement.UpdateIndexingAgreementMetadata memory metadata = abi.decode( From 836c0c2ec01551a4cc09cd5143f88eab62e8ea9b Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 23 Jul 2025 21:55:11 -0300 Subject: [PATCH 011/157] fix: [TRST-L-5] Add slippage protection Implements slippage protection mechanism to prevent silent token loss during rate-limited collections in RecurringCollector agreements. The implementation uses type(uint256).max convention to disable slippage checks, providing users full control over acceptable token loss during rate limiting. Resolves audit finding TRST-L-5: "RecurringCollector silently reduces collected tokens without user consent" --- .../interfaces/IRecurringCollector.sol | 10 ++ .../collectors/RecurringCollector.sol | 6 + .../recurring-collector/collect.t.sol | 134 ++++++++++++++++++ .../payments/recurring-collector/shared.t.sol | 3 +- .../contracts/libraries/IndexingAgreement.sol | 5 +- .../indexing-agreement/collect.t.sol | 3 +- .../indexing-agreement/shared.t.sol | 3 +- 7 files changed, 160 insertions(+), 4 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index 704515aa7..5bf597090 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -147,6 +147,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param tokens The amount of tokens to collect * @param dataServiceCut The data service cut in parts per million * @param receiverDestination The address where the collected fees should be sent + * @param maxSlippage Max acceptable tokens to lose due to rate limiting, or type(uint256).max to ignore */ struct CollectParams { bytes16 agreementId; @@ -154,6 +155,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 tokens; uint256 dataServiceCut; address receiverDestination; + uint256 maxSlippage; } /** @@ -369,6 +371,14 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorInvalidUpdateNonce(bytes16 agreementId, uint32 expected, uint32 provided); + /** + * @notice Thrown when collected tokens are less than requested beyond the allowed slippage + * @param requested The amount of tokens requested to collect + * @param actual The actual amount that would be collected + * @param maxSlippage The maximum allowed slippage + */ + error RecurringCollectorExcessiveSlippage(uint256 requested, uint256 actual, uint256 maxSlippage); + /** * @dev Accept an indexing agreement. * @param signedRCA The signed Recurring Collection Agreement which is to be accepted. diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 56d2b9d5b..79f1d1a12 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -336,6 +336,12 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC if (_params.tokens != 0) { tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens, collectionSeconds); + uint256 slippage = _params.tokens - tokensToCollect; + require( + slippage <= _params.maxSlippage, + RecurringCollectorExcessiveSlippage(_params.tokens, tokensToCollect, _params.maxSlippage) + ); + _graphPaymentsEscrow().collect( _paymentType, agreement.payer, diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index a972734a6..d44284e9f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -2,6 +2,7 @@ pragma solidity 0.8.27; import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol"; +import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; import { IHorizonStakingTypes } from "../../../../contracts/interfaces/internal/IHorizonStakingTypes.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -309,5 +310,138 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, tokens); } + + function test_Collect_RevertWhen_ExceedsMaxSlippage() public { + // Setup: Create agreement with known parameters + IRecurringCollector.RecurringCollectionAgreement memory rca; + rca.deadline = uint64(block.timestamp + 1000); + rca.endsAt = uint64(block.timestamp + 2000); + rca.payer = address(0x123); + rca.dataService = address(0x456); + rca.serviceProvider = address(0x789); + rca.maxInitialTokens = 0; // No initial tokens to keep calculation simple + rca.maxOngoingTokensPerSecond = 1 ether; // 1 token per second + rca.minSecondsPerCollection = 60; // 1 minute + rca.maxSecondsPerCollection = 3600; // 1 hour + rca.nonce = 1; + rca.metadata = ""; + + // Accept the agreement + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, 1); + IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(rca, 1); + bytes16 agreementId = _accept(signedRCA); + + // Do a first collection to use up initial tokens allowance + skip(rca.minSecondsPerCollection); + IRecurringCollector.CollectParams memory firstCollection = IRecurringCollector.CollectParams({ + agreementId: agreementId, + collectionId: keccak256("first"), + tokens: 1 ether, // Small amount + dataServiceCut: 0, + receiverDestination: rca.serviceProvider, + maxSlippage: type(uint256).max + }); + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, _generateCollectData(firstCollection)); + + // Wait minimum collection time again for second collection + skip(rca.minSecondsPerCollection); + + // Calculate expected narrowing: max allowed is 60 tokens (60 seconds * 1 token/second) + uint256 maxAllowed = rca.maxOngoingTokensPerSecond * rca.minSecondsPerCollection; // 60 tokens + uint256 requested = maxAllowed + 50 ether; // Request 110 tokens + uint256 expectedSlippage = requested - maxAllowed; // 50 tokens + uint256 maxSlippage = expectedSlippage - 1; // Allow up to 49 tokens slippage + + // Create collect params with slippage protection + IRecurringCollector.CollectParams memory collectParams = IRecurringCollector.CollectParams({ + agreementId: agreementId, + collectionId: keccak256("test"), + tokens: requested, + dataServiceCut: 0, + receiverDestination: rca.serviceProvider, + maxSlippage: maxSlippage + }); + + bytes memory data = _generateCollectData(collectParams); + + // Expect revert due to excessive slippage (50 > 49) + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorExcessiveSlippage.selector, + requested, + maxAllowed, + maxSlippage + ) + ); + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_OK_WithMaxSlippageDisabled() public { + // Setup: Create agreement with known parameters + IRecurringCollector.RecurringCollectionAgreement memory rca; + rca.deadline = uint64(block.timestamp + 1000); + rca.endsAt = uint64(block.timestamp + 2000); + rca.payer = address(0x123); + rca.dataService = address(0x456); + rca.serviceProvider = address(0x789); + rca.maxInitialTokens = 0; // No initial tokens to keep calculation simple + rca.maxOngoingTokensPerSecond = 1 ether; // 1 token per second + rca.minSecondsPerCollection = 60; // 1 minute + rca.maxSecondsPerCollection = 3600; // 1 hour + rca.nonce = 1; + rca.metadata = ""; + + // Accept the agreement + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, 1); + IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(rca, 1); + bytes16 agreementId = _accept(signedRCA); + + // Do a first collection to use up initial tokens allowance + skip(rca.minSecondsPerCollection); + IRecurringCollector.CollectParams memory firstCollection = IRecurringCollector.CollectParams({ + agreementId: agreementId, + collectionId: keccak256("first"), + tokens: 1 ether, // Small amount + dataServiceCut: 0, + receiverDestination: rca.serviceProvider, + maxSlippage: type(uint256).max + }); + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, _generateCollectData(firstCollection)); + + // Wait minimum collection time again for second collection + skip(rca.minSecondsPerCollection); + + // Calculate expected narrowing: max allowed is 60 tokens (60 seconds * 1 token/second) + uint256 maxAllowed = rca.maxOngoingTokensPerSecond * rca.minSecondsPerCollection; // 60 tokens + uint256 requested = maxAllowed + 50 ether; // Request 110 tokens (will be narrowed to 60) + + // Create collect params with slippage disabled (type(uint256).max) + IRecurringCollector.CollectParams memory collectParams = IRecurringCollector.CollectParams({ + agreementId: agreementId, + collectionId: keccak256("test"), + tokens: requested, + dataServiceCut: 0, + receiverDestination: rca.serviceProvider, + maxSlippage: type(uint256).max + }); + + bytes memory data = _generateCollectData(collectParams); + + // Should succeed despite slippage when maxSlippage is disabled + _expectCollectCallAndEmit( + rca, + agreementId, + IGraphPayments.PaymentTypes.IndexingFee, + collectParams, + maxAllowed // Will collect the narrowed amount + ); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, maxAllowed); + } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 9a564086e..2e76c048e 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -233,7 +233,8 @@ contract RecurringCollectorSharedTest is Test, Bounder { collectionId: _collectionId, tokens: _tokens, dataServiceCut: _dataServiceCut, - receiverDestination: _rca.serviceProvider + receiverDestination: _rca.serviceProvider, + maxSlippage: type(uint256).max }); } diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index d1f42f2b5..1935a6197 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -96,12 +96,14 @@ library IndexingAgreement { * @param poi The proof of indexing (POI) * @param poiBlockNumber The block number of the POI * @param metadata Additional metadata associated with the collection + * @param maxSlippage Max acceptable tokens to lose due to rate limiting, or type(uint256).max to ignore */ struct CollectIndexingFeeDataV1 { uint256 entities; bytes32 poi; uint256 poiBlockNumber; bytes metadata; + uint256 maxSlippage; } /** @@ -565,7 +567,8 @@ library IndexingAgreement { collectionId: bytes32(uint256(uint160(wrapper.agreement.allocationId))), tokens: expectedTokens, dataServiceCut: 0, - receiverDestination: params.receiverDestination + receiverDestination: params.receiverDestination, + maxSlippage: data.maxSlippage }) ) ); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 711154be5..f41bdf976 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -45,7 +45,8 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA collectionId: bytes32(uint256(uint160(indexerState.allocationId))), tokens: 0, dataServiceCut: 0, - receiverDestination: indexerState.addr + receiverDestination: indexerState.addr, + maxSlippage: type(uint256).max }) ); uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / stakeToFeesRatio); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index f04be267b..b51008c20 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -392,7 +392,8 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun entities: _entities, poi: _poi, poiBlockNumber: _poiBlock, - metadata: _metadata + metadata: _metadata, + maxSlippage: type(uint256).max }) ); } From e3d2787b6d123b53ff87cebdc5e735403f5157a9 Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 10:32:26 -0300 Subject: [PATCH 012/157] fix: [TRST-L-6] Proper agreement version check --- .../contracts/libraries/IndexingAgreement.sol | 3 +- .../indexing-agreement/accept.t.sol | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 1935a6197..487db627e 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -390,8 +390,7 @@ library IndexingAgreement { signedRCAU.rcau.metadata ); - wrapper.agreement.version = metadata.version; - + require(wrapper.agreement.version == IndexingAgreementVersion.V1, "internal: invalid version"); require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); _setTermsV1(self, signedRCAU.rcau.agreementId, metadata.terms); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index db2a859dd..ac8981466 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -226,7 +226,38 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg subgraphService.acceptIndexingAgreement(ctx.indexers[0].allocationId, accepted); } - function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated() public {} + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated( + Seed memory seed, + uint256 alternativeNonce + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + + // First, accept an indexing agreement on the allocation + (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); + vm.assume(accepted.rca.nonce != alternativeNonce); + + // Now try to accept a different agreement on the same allocation + // Create a new agreement with different nonce to ensure different agreement ID + IRecurringCollector.RecurringCollectionAgreement + memory newRCA = _generateAcceptableRecurringCollectionAgreement(ctx, indexerState.addr); + newRCA.nonce = alternativeNonce; // Different nonce to ensure different agreement ID + + // Sign the new agreement + IRecurringCollector.SignedRCA memory newSignedRCA = _recurringCollectorHelper.generateSignedRCA( + newRCA, + ctx.payer.signerPrivateKey + ); + + // Expect the error when trying to accept a second agreement on the same allocation + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.AllocationAlreadyHasIndexingAgreement.selector, + indexerState.allocationId + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, newSignedRCA); + } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidTermsData(Seed memory seed) public { Context storage ctx = _newCtx(seed); From 308d6e6d07e6dfcf499494f47d06f8f9580bf1a7 Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 11:08:20 -0300 Subject: [PATCH 013/157] document: [TRST-L-7] update() --- .../contracts/payments/collectors/RecurringCollector.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 79f1d1a12..465e806d4 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -184,6 +184,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @notice Update an indexing agreement. * See {IRecurringCollector.update}. * @dev Caller must be the data service for the agreement. + * @dev Note: Updated pricing terms apply immediately and will affect the next collection + * for the entire period since lastCollectionAt. */ function update(SignedRCAU calldata signedRCAU) external { require( From 17b794e49c8144558210a04e93230761cfd7161f Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 14:10:28 -0300 Subject: [PATCH 014/157] fix: [TRST-L-9] Cancel agreement if over-allocated --- .../contracts/SubgraphService.sol | 21 ++++++++-- .../contracts/libraries/AllocationHandler.sol | 9 ++-- .../contracts/libraries/IndexingAgreement.sol | 6 +-- .../contracts/utilities/AllocationManager.sol | 5 ++- .../unit/shared/HorizonStakingShared.t.sol | 6 +++ .../indexing-agreement/integration.t.sol | 42 +++++++++++++++++-- 6 files changed, 74 insertions(+), 15 deletions(-) diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index d311c6c62..c5901eda7 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -574,10 +574,10 @@ contract SubgraphService is * @notice Internal function to handle closing an allocation * @dev This function is called when an allocation is closed, either by the indexer or by a third party * @param _allocationId The id of the allocation being closed - * @param _stale Whether the allocation is stale or not + * @param _forceClosed Whether the allocation was force closed */ - function _onCloseAllocation(address _allocationId, bool _stale) internal { - IndexingAgreement._getStorageManager().onCloseAllocation(_allocationId, _stale); + function _onCloseAllocation(address _allocationId, bool _forceClosed) internal { + IndexingAgreement._getStorageManager().onCloseAllocation(_allocationId, _forceClosed); } /** @@ -738,7 +738,20 @@ contract SubgraphService is _allocations.get(allocationId).indexer == _indexer, SubgraphServiceAllocationNotAuthorized(_indexer, allocationId) ); - return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[_indexer]); + + (uint256 paymentCollected, bool allocationForceClosed) = _presentPOI( + allocationId, + poi_, + poiMetadata_, + _delegationRatio, + paymentsDestination[_indexer] + ); + + if (allocationForceClosed) { + _onCloseAllocation(allocationId, true); + } + + return paymentCollected; } /** diff --git a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol index 394430cad..62720951c 100644 --- a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol +++ b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol @@ -281,14 +281,15 @@ library AllocationHandler { * @param allocationProvisionTracker The mapping of indexers to their locked tokens * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens * @param params The parameters for the POI presentation - * @return The amount of tokens collected + * @return tokensCollected The amount of tokens collected + * @return allocationForceClosed True if the allocation was automatically closed due to over-allocation, false otherwise */ function presentPOI( mapping(address allocationId => Allocation.State allocation) storage _allocations, mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, PresentParams memory params - ) external returns (uint256) { + ) external returns (uint256, bool) { Allocation.State memory allocation = _allocations.get(params._allocationId); require(allocation.isOpen(), AllocationHandler.AllocationHandlerAllocationClosed(params._allocationId)); @@ -358,6 +359,7 @@ library AllocationHandler { ); // Check if the indexer is over-allocated and force close the allocation if necessary + bool allocationForceClosed; if ( _isOverAllocated( allocationProvisionTracker, @@ -366,6 +368,7 @@ library AllocationHandler { params._delegationRatio ) ) { + allocationForceClosed = true; _closeAllocation( _allocations, allocationProvisionTracker, @@ -376,7 +379,7 @@ library AllocationHandler { ); } - return tokensRewards; + return (tokensRewards, allocationForceClosed); } /** diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 487db627e..f5f04c602 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -450,10 +450,10 @@ library IndexingAgreement { * * @param self The indexing agreement storage manager * @param _allocationId The allocation ID - * @param stale Whether the allocation is stale or not + * @param forceClosed Whether the allocation was force closed * */ - function onCloseAllocation(StorageManager storage self, address _allocationId, bool stale) external { + function onCloseAllocation(StorageManager storage self, address _allocationId, bool forceClosed) external { bytes16 agreementId = self.allocationToActiveAgreementId[_allocationId]; if (agreementId == bytes16(0)) { return; @@ -469,7 +469,7 @@ library IndexingAgreement { agreementId, wrapper.agreement, wrapper.collectorAgreement, - stale + forceClosed ? IRecurringCollector.CancelAgreementBy.ThirdParty : IRecurringCollector.CancelAgreementBy.ServiceProvider ); diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index bc64d0eb6..a7d228744 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -131,7 +131,8 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @param _poiMetadata The metadata associated with the POI. The data and encoding format is for off-chain components to define, this function will only emit the value in an event as-is. * @param _delegationRatio The delegation ratio to consider when locking tokens * @param _paymentsDestination The address where indexing rewards should be sent - * @return The amount of tokens collected + * @return tokensCollected The amount of tokens collected + * @return allocationForceClosed True if the allocation was automatically closed due to over-allocation, false otherwise */ function _presentPOI( address _allocationId, @@ -139,7 +140,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca bytes memory _poiMetadata, uint32 _delegationRatio, address _paymentsDestination - ) internal returns (uint256) { + ) internal returns (uint256, bool) { return AllocationHandler.presentPOI( _allocations, diff --git a/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol b/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol index 55990a2b7..bd143a74f 100644 --- a/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol +++ b/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol @@ -38,6 +38,12 @@ abstract contract HorizonStakingSharedTest is SubgraphBaseTest { staking.addToProvision(_indexer, address(subgraphService), _tokens); } + function _removeFromProvision(address _indexer, uint256 _tokens) internal { + staking.thaw(_indexer, address(subgraphService), _tokens); + skip(staking.getProvision(_indexer, address(subgraphService)).thawingPeriod + 1); + staking.deprovision(_indexer, address(subgraphService), 0); + } + function _delegate(address _indexer, address _verifier, uint256 _tokens, uint256 _minSharesOut) internal { staking.delegate(_indexer, _verifier, _tokens, _minSharesOut); } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 45b7db8d8..660658450 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -101,6 +101,35 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex _sharedAssert(beforeCollect, afterCollect, expectedTokens, tokensCollected); } + function test_SubgraphService_CollectIndexingRewards_CancelsAgreementWhenOverAllocated_Integration( + Seed memory seed + ) public { + // Setup context and indexer with active agreement + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (, bytes16 agreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Reduce indexer's provision to force over-allocation after collecting rewards + uint256 extraTokens = indexerState.tokens - minimumProvisionTokens; + vm.assume(extraTokens > 0); + _removeTokensFromProvision(indexerState, extraTokens); + + // Verify indexer will be over-allocated after presenting POI + assertTrue(subgraphService.isOverAllocated(indexerState.addr)); + + // Collect indexing rewards - this should trigger allocation closure and agreement cancellation + bytes memory collectData = abi.encode(indexerState.allocationId, bytes32("poi"), bytes("metadata")); + resetPrank(indexerState.addr); + subgraphService.collect(indexerState.addr, IGraphPayments.PaymentTypes.IndexingRewards, collectData); + + // Verify the indexing agreement was properly cancelled + IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId); + assertEq( + uint8(agreement.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider) + ); + } + /* solhint-enable graph/func-name-mixedcase */ function _sharedSetup( @@ -195,10 +224,17 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex ); } - function _addTokensToProvision(IndexerState memory _indexerState, uint256 _tokensToAddToProvision) private { - deal({ token: address(token), to: _indexerState.addr, give: _tokensToAddToProvision }); + function _addTokensToProvision(IndexerState memory _indexerState, uint256 _tokens) private { + deal({ token: address(token), to: _indexerState.addr, give: _tokens }); + vm.startPrank(_indexerState.addr); + _addToProvision(_indexerState.addr, _tokens); + vm.stopPrank(); + } + + function _removeTokensFromProvision(IndexerState memory _indexerState, uint256 _tokens) private { + deal({ token: address(token), to: _indexerState.addr, give: _tokens }); vm.startPrank(_indexerState.addr); - _addToProvision(_indexerState.addr, _tokensToAddToProvision); + _removeFromProvision(_indexerState.addr, _tokens); vm.stopPrank(); } From 6d9a18c52e99430f92676c2f89379cdf5e64819e Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 14:39:28 -0300 Subject: [PATCH 015/157] fix: [TRST-R-1] minor fixes --- .../contracts/payments/collectors/RecurringCollector.sol | 6 +++--- .../contracts/libraries/IndexingAgreementDecoder.sol | 2 +- .../unit/subgraphService/indexing-agreement/accept.t.sol | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 465e806d4..41a67aaf8 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -71,7 +71,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @inheritdoc IRecurringCollector - * @notice Accept an indexing agreement. + * @notice Accept a Recurring Collection Agreement. * See {IRecurringCollector.accept}. * @dev Caller must be the data service the RCA was issued to. */ @@ -148,7 +148,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @inheritdoc IRecurringCollector - * @notice Cancel an indexing agreement. + * @notice Cancel a Recurring Collection Agreement. * See {IRecurringCollector.cancel}. * @dev Caller must be the data service for the agreement. */ @@ -181,7 +181,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @inheritdoc IRecurringCollector - * @notice Update an indexing agreement. + * @notice Update a Recurring Collection Agreement. * See {IRecurringCollector.update}. * @dev Caller must be the data service for the agreement. * @dev Note: Updated pricing terms apply immediately and will affect the next collection diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol index f8f5af811..a50e53f0d 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreementDecoder.sol @@ -95,7 +95,7 @@ library IndexingAgreementDecoder { ) { return decoded; } catch { - revert IndexingAgreementDecoderInvalidData("decodeCollectIndexingFeeData", data); + revert IndexingAgreementDecoderInvalidData("decodeIndexingAgreementTermsV1", data); } } } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index ac8981466..8e7cafdf6 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -275,7 +275,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, - "decodeCollectIndexingFeeData", + "decodeIndexingAgreementTermsV1", invalidTermsData ); vm.expectRevert(expectedErr); From 58b7a28e52f772e4572339d7702b10b80b65a031 Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 14:55:24 -0300 Subject: [PATCH 016/157] fix: [TRST-R-4] CEI violation --- .../contracts/payments/collectors/RecurringCollector.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 41a67aaf8..a24e2aac9 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -343,7 +343,10 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC slippage <= _params.maxSlippage, RecurringCollectorExcessiveSlippage(_params.tokens, tokensToCollect, _params.maxSlippage) ); + } + agreement.lastCollectionAt = uint64(block.timestamp); + if (tokensToCollect > 0) { _graphPaymentsEscrow().collect( _paymentType, agreement.payer, @@ -354,7 +357,6 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _params.receiverDestination ); } - agreement.lastCollectionAt = uint64(block.timestamp); emit PaymentCollected( _paymentType, From 5f732aceb290efc4103f735903bd4cd953748201 Mon Sep 17 00:00:00 2001 From: Matias Date: Thu, 24 Jul 2025 15:19:37 -0300 Subject: [PATCH 017/157] fix: [TRST-R-5] Terms validation --- .../contracts/libraries/IndexingAgreement.sol | 40 +++++++++++++++++-- .../indexing-agreement/shared.t.sol | 2 +- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index f5f04c602..1035f2d62 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -271,6 +271,13 @@ library IndexingAgreement { */ error IndexingAgreementNotAuthorized(bytes16 agreementId, address unauthorizedIndexer); + /** + * @notice Thrown when indexing agreement terms are invalid + * @param tokensPerSecond The indexing agreement tokens per second + * @param maxOngoingTokensPerSecond The RCA maximum tokens per second + */ + error IndexingAgreementInvalidTerms(uint256 tokensPerSecond, uint256 maxOngoingTokensPerSecond); + /** * @notice Accept an indexing agreement. * @@ -343,7 +350,7 @@ library IndexingAgreement { agreement.allocationId = allocationId; require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); - _setTermsV1(self, agreementId, metadata.terms); + _setTermsV1(self, agreementId, metadata.terms, signedRCA.rca.maxOngoingTokensPerSecond); emit IndexingAgreementAccepted( signedRCA.rca.serviceProvider, @@ -392,7 +399,12 @@ library IndexingAgreement { require(wrapper.agreement.version == IndexingAgreementVersion.V1, "internal: invalid version"); require(metadata.version == IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version)); - _setTermsV1(self, signedRCAU.rcau.agreementId, metadata.terms); + _setTermsV1( + self, + signedRCAU.rcau.agreementId, + metadata.terms, + wrapper.collectorAgreement.maxOngoingTokensPerSecond + ); emit IndexingAgreementUpdated({ indexer: wrapper.collectorAgreement.serviceProvider, @@ -621,9 +633,16 @@ library IndexingAgreement { * @param _manager The indexing agreement storage manager * @param _agreementId The id of the agreement to update * @param _data The encoded terms data + * @param maxOngoingTokensPerSecond The RCA maximum tokens per second limit for validation */ - function _setTermsV1(StorageManager storage _manager, bytes16 _agreementId, bytes memory _data) private { + function _setTermsV1( + StorageManager storage _manager, + bytes16 _agreementId, + bytes memory _data, + uint256 maxOngoingTokensPerSecond + ) private { IndexingAgreementTermsV1 memory newTerms = IndexingAgreementDecoder.decodeIndexingAgreementTermsV1(_data); + _validateTermsAgainstRCA(newTerms, maxOngoingTokensPerSecond); _manager.termsV1[_agreementId].tokensPerSecond = newTerms.tokensPerSecond; _manager.termsV1[_agreementId].tokensPerEntityPerSecond = newTerms.tokensPerEntityPerSecond; } @@ -764,4 +783,19 @@ library IndexingAgreement { collectorAgreement: _directory().recurringCollector().getAgreement(agreementId) }); } + + /** + * @notice Validates indexing agreement terms against RCA limits + * @param terms The indexing agreement terms to validate + * @param maxOngoingTokensPerSecond The RCA maximum tokens per second limit + */ + function _validateTermsAgainstRCA( + IndexingAgreementTermsV1 memory terms, + uint256 maxOngoingTokensPerSecond + ) private pure { + require( + terms.tokensPerSecond <= maxOngoingTokensPerSecond, + IndexingAgreementInvalidTerms(terms.tokensPerSecond, maxOngoingTokensPerSecond) + ); + } } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index b51008c20..09660ff57 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -288,7 +288,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun ); rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( _newUpdateIndexingAgreementMetadataV1( - _ctx.ctxInternal.seed.termsV1.tokensPerSecond, + bound(_ctx.ctxInternal.seed.termsV1.tokensPerSecond, 0, _rca.maxOngoingTokensPerSecond), _ctx.ctxInternal.seed.termsV1.tokensPerEntityPerSecond ) ); From b492251395565ab97869b9e3e34b5840c1e6eb18 Mon Sep 17 00:00:00 2001 From: Matias Date: Fri, 25 Jul 2025 10:31:09 -0300 Subject: [PATCH 018/157] fix: [TRST-R-6] Configurable indexing fees cut --- .../contracts/SubgraphService.sol | 10 +++++++++- .../contracts/SubgraphServiceStorage.sol | 3 +++ .../contracts/interfaces/ISubgraphService.sol | 19 +++++++++++++++++++ .../contracts/libraries/IndexingAgreement.sol | 4 +++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index c5901eda7..653149267 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -398,6 +398,13 @@ contract SubgraphService is emit CurationCutSet(curationCut); } + /// @inheritdoc ISubgraphService + function setIndexingFeesCut(uint256 indexingFeesCut_) external override onlyOwner { + require(PPMMath.isValidPPM(indexingFeesCut_), SubgraphServiceInvalidIndexingFeesCut(indexingFeesCut_)); + indexingFeesCut = indexingFeesCut_; + emit IndexingFeesCutSet(indexingFeesCut_); + } + /** * @inheritdoc ISubgraphService * @notice Accept an indexing agreement. @@ -793,7 +800,8 @@ contract SubgraphService is agreementId: _agreementId, currentEpoch: _graphEpochManager().currentEpoch(), receiverDestination: _paymentsDestination, - data: _data + data: _data, + indexingFeesCut: indexingFeesCut }) ); diff --git a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol index 06ada3a59..1e0b608d6 100644 --- a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol +++ b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol @@ -21,4 +21,7 @@ abstract contract SubgraphServiceV1Storage { /// @notice Destination of indexer payments mapping(address indexer => address destination) public paymentsDestination; + + /// @notice The cut data service takes from indexing fee payments. In PPM. + uint256 public indexingFeesCut; } diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index 17ff4cbd0..54ebf4396 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -69,12 +69,24 @@ interface ISubgraphService is IDataServiceFees { */ event CurationCutSet(uint256 curationCut); + /** + * @notice Emitted when indexing fees cut is set + * @param indexingFeesCut The indexing fees cut + */ + event IndexingFeesCutSet(uint256 indexingFeesCut); + /** * @notice Thrown when trying to set a curation cut that is not a valid PPM value * @param curationCut The curation cut value */ error SubgraphServiceInvalidCurationCut(uint256 curationCut); + /** + * @notice Thrown when trying to set an indexing fees cut that is not a valid PPM value + * @param indexingFeesCut The indexing fees cut value + */ + error SubgraphServiceInvalidIndexingFeesCut(uint256 indexingFeesCut); + /** * @notice Thrown when an indexer tries to register with an empty URL */ @@ -252,6 +264,13 @@ interface ISubgraphService is IDataServiceFees { */ function setCurationCut(uint256 curationCut) external; + /** + * @notice Sets the data service payment cut for indexing fees + * @dev Emits a {IndexingFeesCutSet} event + * @param indexingFeesCut The indexing fees cut for the payment type + */ + function setIndexingFeesCut(uint256 indexingFeesCut) external; + /** * @notice Sets the payments destination for an indexer to receive payments * @dev Emits a {PaymentsDestinationSet} event diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 1035f2d62..f9648e4fb 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -80,6 +80,7 @@ library IndexingAgreement { * @param currentEpoch The current epoch * @param receiverDestination The address where the collected fees should be sent * @param data The encoded data containing the number of entities indexed, proof of indexing, and epoch + * @param indexingFeesCut The indexing fees cut in PPM */ struct CollectParams { address indexer; @@ -87,6 +88,7 @@ library IndexingAgreement { uint256 currentEpoch; address receiverDestination; bytes data; + uint256 indexingFeesCut; } /** @@ -577,7 +579,7 @@ library IndexingAgreement { agreementId: params.agreementId, collectionId: bytes32(uint256(uint160(wrapper.agreement.allocationId))), tokens: expectedTokens, - dataServiceCut: 0, + dataServiceCut: params.indexingFeesCut, receiverDestination: params.receiverDestination, maxSlippage: data.maxSlippage }) From 0e469beeba0ec433e313be8c9129bcf99acdaac6 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 11 Aug 2025 15:20:20 -0300 Subject: [PATCH 019/157] fix: [TRST-M-2] improve _getCollectionInfo() --- .../interfaces/IRecurringCollector.sol | 18 ++++++++++- .../collectors/RecurringCollector.sol | 32 +++++++++---------- .../recurring-collector/collect.t.sol | 8 ++--- .../contracts/libraries/IndexingAgreement.sol | 2 +- .../indexing-agreement/collect.t.sol | 4 +++ 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IRecurringCollector.sol b/packages/horizon/contracts/interfaces/IRecurringCollector.sol index 5bf597090..c4930a954 100644 --- a/packages/horizon/contracts/interfaces/IRecurringCollector.sol +++ b/packages/horizon/contracts/interfaces/IRecurringCollector.sol @@ -28,6 +28,14 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { ThirdParty } + /// @notice Reasons why an agreement is not collectable + enum AgreementNotCollectableReason { + None, + InvalidAgreementState, + ZeroCollectionSeconds, + InvalidTemporalWindow + } + /** * @notice A representation of a signed Recurring Collection Agreement (RCA) * @param rca The Recurring Collection Agreement to be signed @@ -303,6 +311,13 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorAgreementIncorrectState(bytes16 agreementId, AgreementState incorrectState); + /** + * @notice Thrown when an agreement is not collectable + * @param agreementId The agreement ID + * @param reason The reason why the agreement is not collectable + */ + error RecurringCollectorAgreementNotCollectable(bytes16 agreementId, AgreementNotCollectableReason reason); + /** * @notice Thrown when accepting an agreement with an address that is not set */ @@ -440,10 +455,11 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @return isCollectable Whether the agreement is in a valid state that allows collection attempts, * not that there are necessarily funds available to collect. * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) + * @return reason The reason why the agreement is not collectable (None if collectable) */ function getCollectionInfo( AgreementData memory agreement - ) external view returns (bool isCollectable, uint256 collectionSeconds); + ) external view returns (bool isCollectable, uint256 collectionSeconds, AgreementNotCollectableReason reason); /** * @notice Generate a deterministic agreement ID from agreement parameters diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index a24e2aac9..99bf5d3fb 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -269,7 +269,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @inheritdoc IRecurringCollector function getCollectionInfo( AgreementData memory agreement - ) external view returns (bool isCollectable, uint256 collectionSeconds) { + ) external view returns (bool isCollectable, uint256 collectionSeconds, AgreementNotCollectableReason reason) { return _getCollectionInfo(agreement); } @@ -309,14 +309,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ) private returns (uint256) { AgreementData storage agreement = _getAgreementStorage(_params.agreementId); - // Check if agreement exists first (for unknown agreements) - (bool isCollectable, uint256 collectionSeconds) = _getCollectionInfo(agreement); - require(isCollectable, RecurringCollectorAgreementIncorrectState(_params.agreementId, agreement.state)); - - require( - collectionSeconds > 0, - RecurringCollectorZeroCollectionSeconds(_params.agreementId, block.timestamp, agreement.lastCollectionAt) + // Check if agreement is collectable first + (bool isCollectable, uint256 collectionSeconds, AgreementNotCollectableReason reason) = _getCollectionInfo( + agreement ); + require(isCollectable, RecurringCollectorAgreementNotCollectable(_params.agreementId, reason)); require( msg.sender == agreement.dataService, @@ -583,17 +580,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @param _agreement The agreement data * @return isCollectable Whether the agreement can be collected from * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) + * @return reason The reason why the agreement is not collectable (None if collectable) */ function _getCollectionInfo( AgreementData memory _agreement - ) private view returns (bool isCollectable, uint256 collectionSeconds) { + ) private view returns (bool, uint256, AgreementNotCollectableReason) { // Check if agreement is in collectable state - isCollectable = - _agreement.state == AgreementState.Accepted || + bool hasValidState = _agreement.state == AgreementState.Accepted || _agreement.state == AgreementState.CanceledByPayer; - if (!isCollectable) { - return (false, 0); + if (!hasValidState) { + return (false, 0, AgreementNotCollectableReason.InvalidAgreementState); } bool canceledOrElapsed = _agreement.state == AgreementState.CanceledByPayer || @@ -606,11 +603,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC uint256 collectionStart = _agreementCollectionStartAt(_agreement); if (collectionEnd < collectionStart) { - return (false, 0); + return (false, 0, AgreementNotCollectableReason.InvalidTemporalWindow); + } + + if (collectionStart == collectionEnd) { + return (false, 0, AgreementNotCollectableReason.ZeroCollectionSeconds); } - collectionSeconds = collectionEnd - collectionStart; - return (isCollectable, collectionSeconds); + return (true, collectionEnd - collectionStart, AgreementNotCollectableReason.None); } /** diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index d44284e9f..738a0415c 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -90,9 +90,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { bytes memory data = _generateCollectData(fuzzy.collectParams); bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + IRecurringCollector.RecurringCollectorAgreementNotCollectable.selector, fuzzy.collectParams.agreementId, - IRecurringCollector.AgreementState.NotAccepted + IRecurringCollector.AgreementNotCollectableReason.InvalidAgreementState ); vm.expectRevert(expectedErr); vm.prank(dataService); @@ -116,9 +116,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { bytes memory data = _generateCollectData(collectParams); bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + IRecurringCollector.RecurringCollectorAgreementNotCollectable.selector, collectParams.agreementId, - IRecurringCollector.AgreementState.CanceledByServiceProvider + IRecurringCollector.AgreementNotCollectableReason.InvalidAgreementState ); vm.expectRevert(expectedErr); vm.prank(accepted.rca.dataService); diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index f9648e4fb..02f99be88 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -554,7 +554,7 @@ library IndexingAgreement { IndexingAgreementNotAuthorized(params.agreementId, params.indexer) ); // Get collection info from RecurringCollector (single source of truth for temporal logic) - (bool isCollectable, uint256 collectionSeconds) = _directory().recurringCollector().getCollectionInfo( + (bool isCollectable, uint256 collectionSeconds, ) = _directory().recurringCollector().getCollectionInfo( wrapper.collectorAgreement ); require(_isValid(wrapper) && isCollectable, IndexingAgreementNotCollectable(params.agreementId)); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index f41bdf976..3f7a5657c 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -58,6 +58,8 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); _expectCollectCallAndEmit(data, indexerState, accepted, acceptedAgreementId, tokensCollected, entities, poi); + skip(1); // To make agreement collectable + subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, @@ -215,6 +217,8 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); vm.expectRevert(expectedErr); + skip(1); // To make agreement collectable + subgraphService.collect( indexerState.addr, IGraphPayments.PaymentTypes.IndexingFee, From f65877e889c176457d08a9d3d88947535aa8ce63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 28 Nov 2025 17:35:40 -0300 Subject: [PATCH 020/157] feat(interfaces): remove staking extension from interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/horizon/IHorizonStaking.sol | 7 +- .../horizon/internal/IHorizonStakingBase.sol | 12 +- .../internal/IHorizonStakingExtension.sol | 215 ------------------ .../horizon/internal/IHorizonStakingMain.sol | 17 +- .../subgraph-service/IDisputeManager.sol | 54 +---- 5 files changed, 12 insertions(+), 293 deletions(-) delete mode 100644 packages/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol diff --git a/packages/interfaces/contracts/horizon/IHorizonStaking.sol b/packages/interfaces/contracts/horizon/IHorizonStaking.sol index 4e680a1e5..9b16ad368 100644 --- a/packages/interfaces/contracts/horizon/IHorizonStaking.sol +++ b/packages/interfaces/contracts/horizon/IHorizonStaking.sol @@ -5,15 +5,14 @@ pragma solidity ^0.8.22; import { IHorizonStakingTypes } from "./internal/IHorizonStakingTypes.sol"; import { IHorizonStakingMain } from "./internal/IHorizonStakingMain.sol"; import { IHorizonStakingBase } from "./internal/IHorizonStakingBase.sol"; -import { IHorizonStakingExtension } from "./internal/IHorizonStakingExtension.sol"; /** * @title Complete interface for the Horizon Staking contract * @author Edge & Node - * @notice This interface exposes all functions implemented by the {HorizonStaking} contract and its extension - * {HorizonStakingExtension} as well as the custom data types used by the contract. + * @notice This interface exposes all functions implemented by the {HorizonStaking} contract + * as well as the custom data types used by the contract. * @dev Use this interface to interact with the Horizon Staking contract. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ -interface IHorizonStaking is IHorizonStakingTypes, IHorizonStakingBase, IHorizonStakingMain, IHorizonStakingExtension {} +interface IHorizonStaking is IHorizonStakingTypes, IHorizonStakingBase, IHorizonStakingMain {} diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol index c48f20099..ccdcc1837 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol @@ -13,23 +13,13 @@ import { ILinkedList } from "./ILinkedList.sol"; /** * @title Interface for the {HorizonStakingBase} contract. * @author Edge & Node - * @notice Provides getters for {HorizonStaking} and {HorizonStakingExtension} storage variables. + * @notice Provides getters for {HorizonStaking} storage variables. * @dev Most functions operate over {HorizonStaking} provisions. To uniquely identify a provision * functions take `serviceProvider` and `verifier` addresses. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ interface IHorizonStakingBase { - /** - * @notice Emitted when a service provider stakes tokens. - * @dev TRANSITION PERIOD: After transition period move to IHorizonStakingMain. Temporarily it - * needs to be here since it's emitted by {_stake} which is used by both {HorizonStaking} - * and {HorizonStakingExtension}. - * @param serviceProvider The address of the service provider. - * @param tokens The amount of tokens staked. - */ - event HorizonStakeDeposited(address indexed serviceProvider, uint256 tokens); - /** * @notice Thrown when using an invalid thaw request type. */ diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol deleted file mode 100644 index d487b2eca..000000000 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol +++ /dev/null @@ -1,215 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -pragma solidity ^0.8.22; - -// TODO: Re-enable and fix issues when publishing a new version -// solhint-disable gas-indexed-events - -import { IRewardsIssuer } from "../../contracts/rewards/IRewardsIssuer.sol"; - -/** - * @title Interface for {HorizonStakingExtension} contract. - * @author Edge & Node - * @notice Provides functions for managing legacy allocations. - * @custom:security-contact Please email security+contracts@thegraph.com if you find any - * bugs. We may have an active bug bounty program. - */ -interface IHorizonStakingExtension is IRewardsIssuer { - /** - * @dev Allocate GRT tokens for the purpose of serving queries of a subgraph deployment - * An allocation is created in the allocate() function and closed in closeAllocation() - * @param indexer The indexer address - * @param subgraphDeploymentID The subgraph deployment ID - * @param tokens The amount of tokens allocated to the subgraph deployment - * @param createdAtEpoch The epoch when the allocation was created - * @param closedAtEpoch The epoch when the allocation was closed - * @param collectedFees The amount of collected fees for the allocation - * @param __DEPRECATED_effectiveAllocation Deprecated field. - * @param accRewardsPerAllocatedToken Snapshot used for reward calculation - * @param distributedRebates The amount of collected rebates that have been rebated - */ - struct Allocation { - address indexer; - bytes32 subgraphDeploymentID; - uint256 tokens; - uint256 createdAtEpoch; - uint256 closedAtEpoch; - uint256 collectedFees; - uint256 __DEPRECATED_effectiveAllocation; - uint256 accRewardsPerAllocatedToken; - uint256 distributedRebates; - } - - /** - * @dev Possible states an allocation can be. - * States: - * - Null = indexer == address(0) - * - Active = not Null && tokens > 0 - * - Closed = Active && closedAtEpoch != 0 - */ - enum AllocationState { - Null, - Active, - Closed - } - - /** - * @notice Emitted when `indexer` close an allocation in `epoch` for `allocationID`. - * An amount of `tokens` get unallocated from `subgraphDeploymentID`. - * This event also emits the POI (proof of indexing) submitted by the indexer. - * `isPublic` is true if the sender was someone other than the indexer. - * @param indexer The indexer address - * @param subgraphDeploymentID The subgraph deployment ID - * @param epoch The protocol epoch the allocation was closed on - * @param tokens The amount of tokens unallocated from the allocation - * @param allocationID The allocation identifier - * @param sender The address closing the allocation - * @param poi The proof of indexing submitted by the sender - * @param isPublic True if the allocation was force closed by someone other than the indexer/operator - */ - event AllocationClosed( - address indexed indexer, - bytes32 indexed subgraphDeploymentID, - uint256 epoch, - uint256 tokens, - address indexed allocationID, - address sender, - bytes32 poi, - bool isPublic - ); - - /** - * @notice Emitted when `indexer` collects a rebate on `subgraphDeploymentID` for `allocationID`. - * `epoch` is the protocol epoch the rebate was collected on - * The rebate is for `tokens` amount which are being provided by `assetHolder`; `queryFees` - * is the amount up for rebate after `curationFees` are distributed and `protocolTax` is burnt. - * `queryRebates` is the amount distributed to the `indexer` with `delegationFees` collected - * and sent to the delegation pool. - * @param assetHolder The address of the asset holder, the entity paying the query fees - * @param indexer The indexer address - * @param subgraphDeploymentID The subgraph deployment ID - * @param allocationID The allocation identifier - * @param epoch The protocol epoch the rebate was collected on - * @param tokens The amount of tokens collected - * @param protocolTax The amount of tokens burnt as protocol tax - * @param curationFees The amount of tokens distributed to the curation pool - * @param queryFees The amount of tokens collected as query fees - * @param queryRebates The amount of tokens distributed to the indexer - * @param delegationRewards The amount of tokens collected from the delegation pool - */ - event RebateCollected( - address assetHolder, - address indexed indexer, - bytes32 indexed subgraphDeploymentID, - address indexed allocationID, - uint256 epoch, - uint256 tokens, - uint256 protocolTax, - uint256 curationFees, - uint256 queryFees, - uint256 queryRebates, - uint256 delegationRewards - ); - - /** - * @notice Emitted when `indexer` was slashed for a total of `tokens` amount. - * Tracks `reward` amount of tokens given to `beneficiary`. - * @param indexer The indexer address - * @param tokens The amount of tokens slashed - * @param reward The amount of reward tokens to send to a beneficiary - * @param beneficiary The address of a beneficiary to receive a reward for the slashing - */ - event StakeSlashed(address indexed indexer, uint256 tokens, uint256 reward, address beneficiary); - - /** - * @notice Close an allocation and free the staked tokens. - * To be eligible for rewards a proof of indexing must be presented. - * Presenting a bad proof is subject to slashable condition. - * To opt out of rewards set _poi to 0x0 - * @param allocationID The allocation identifier - * @param poi Proof of indexing submitted for the allocated period - */ - function closeAllocation(address allocationID, bytes32 poi) external; - - /** - * @notice Collect and rebate query fees to the indexer - * This function will accept calls with zero tokens. - * We use an exponential rebate formula to calculate the amount of tokens to rebate to the indexer. - * This implementation allows collecting multiple times on the same allocation, keeping track of the - * total amount rebated, the total amount collected and compensating the indexer for the difference. - * @param tokens Amount of tokens to collect - * @param allocationID Allocation where the tokens will be assigned - */ - function collect(uint256 tokens, address allocationID) external; - - /** - * @notice Slash the indexer stake. Delegated tokens are not subject to slashing. - * Note that depending on the state of the indexer's stake, the slashed amount might be smaller than the - * requested slash amount. This can happen if the indexer has moved a significant part of their stake to - * a provision. Any outstanding slashing amount should be settled using Horizon's slash function - * {IHorizonStaking.slash}. - * @dev Can only be called by the slasher role. - * @param indexer Address of indexer to slash - * @param tokens Amount of tokens to slash from the indexer stake - * @param reward Amount of reward tokens to send to a beneficiary - * @param beneficiary Address of a beneficiary to receive a reward for the slashing - */ - function legacySlash(address indexer, uint256 tokens, uint256 reward, address beneficiary) external; - - /** - * @notice (Legacy) Return true if operator is allowed for the service provider on the subgraph data service. - * @param operator Address of the operator - * @param indexer Address of the service provider - * @return True if operator is allowed for indexer, false otherwise - */ - function isOperator(address operator, address indexer) external view returns (bool); - - /** - * @notice Getter that returns if an indexer has any stake. - * @param indexer Address of the indexer - * @return True if indexer has staked tokens - */ - function hasStake(address indexer) external view returns (bool); - - /** - * @notice Get the total amount of tokens staked by the indexer. - * @param indexer Address of the indexer - * @return Amount of tokens staked by the indexer - */ - function getIndexerStakedTokens(address indexer) external view returns (uint256); - - /** - * @notice Return the allocation by ID. - * @param allocationID Address used as allocation identifier - * @return Allocation data - */ - function getAllocation(address allocationID) external view returns (Allocation memory); - - /** - * @notice Return the current state of an allocation - * @param allocationID Allocation identifier - * @return AllocationState enum with the state of the allocation - */ - function getAllocationState(address allocationID) external view returns (AllocationState); - - /** - * @notice Return if allocationID is used. - * @param allocationID Address used as signer by the indexer for an allocation - * @return True if allocationID already used - */ - function isAllocation(address allocationID) external view returns (bool); - - /** - * @notice Return the time in blocks to unstake - * Deprecated, now enforced by each data service (verifier) - * @return Thawing period in blocks - */ - function __DEPRECATED_getThawingPeriod() external view returns (uint64); - - /** - * @notice Return the address of the subgraph data service. - * @dev TRANSITION PERIOD: After transition period move to main HorizonStaking contract - * @return Address of the subgraph data service - */ - function getSubgraphService() external view returns (address); -} diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index 19c1e1cf8..e0a5c082d 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -12,10 +12,6 @@ import { IHorizonStakingTypes } from "./IHorizonStakingTypes.sol"; * @title Inferface for the {HorizonStaking} contract. * @author Edge & Node * @notice Provides functions for managing stake, provisions, delegations, and slashing. - * @dev Note that this interface only includes the functions implemented by {HorizonStaking} contract, - * and not those implemented by {HorizonStakingExtension}. - * Do not use this interface to interface with the {HorizonStaking} contract, use {IHorizonStaking} for - * the complete interface. * @dev Most functions operate over {HorizonStaking} provisions. To uniquely identify a provision * functions take `serviceProvider` and `verifier` addresses. * @dev TRANSITION PERIOD: After transition period rename to IHorizonStaking. @@ -25,6 +21,13 @@ import { IHorizonStakingTypes } from "./IHorizonStakingTypes.sol"; interface IHorizonStakingMain { // -- Events: stake -- + /** + * @notice Emitted when a service provider stakes tokens. + * @param serviceProvider The address of the service provider. + * @param tokens The amount of tokens staked. + */ + event HorizonStakeDeposited(address indexed serviceProvider, uint256 tokens); + /** * @notice Emitted when a service provider unstakes tokens during the transition period. * @param serviceProvider The address of the service provider @@ -1002,10 +1005,4 @@ interface IHorizonStakingMain { * @return Whether the operator is authorized or not */ function isAuthorized(address serviceProvider, address verifier, address operator) external view returns (bool); - - /** - * @notice Get the address of the staking extension. - * @return The address of the staking extension - */ - function getStakingExtension() external view returns (address); } diff --git a/packages/interfaces/contracts/subgraph-service/IDisputeManager.sol b/packages/interfaces/contracts/subgraph-service/IDisputeManager.sol index da1324cc9..c7a7dc2dd 100644 --- a/packages/interfaces/contracts/subgraph-service/IDisputeManager.sol +++ b/packages/interfaces/contracts/subgraph-service/IDisputeManager.sol @@ -20,7 +20,7 @@ interface IDisputeManager { Null, IndexingDispute, QueryDispute, - LegacyDispute + __DEPRECATED_LegacyDispute } /// @notice Status of a dispute @@ -143,25 +143,6 @@ interface IDisputeManager { uint256 cancellableAt ); - /** - * @notice Emitted when a legacy dispute is created for `allocationId` and `fisherman`. - * The event emits the amount of `tokensSlash` to slash and `tokensRewards` to reward the fisherman. - * @param disputeId The dispute id - * @param indexer The indexer address - * @param fisherman The fisherman address to be credited with the rewards - * @param allocationId The allocation id - * @param tokensSlash The amount of tokens to slash - * @param tokensRewards The amount of tokens to reward the fisherman - */ - event LegacyDisputeCreated( - bytes32 indexed disputeId, - address indexed indexer, - address indexed fisherman, - address allocationId, - uint256 tokensSlash, - uint256 tokensRewards - ); - /** * @notice Emitted when arbitrator accepts a `disputeId` to `indexer` created by `fisherman`. * The event emits the amount `tokens` transferred to the fisherman, the deposit plus reward. @@ -469,39 +450,6 @@ interface IDisputeManager { */ function createIndexingDispute(address allocationId, bytes32 poi, uint256 blockNumber) external returns (bytes32); - /** - * @notice Creates and auto-accepts a legacy dispute. - * This disputes can be created to settle outstanding slashing amounts with an indexer that has been - * "legacy slashed" during or shortly after the transition period. See {HorizonStakingExtension.legacySlash} - * for more details. - * - * Note that this type of dispute: - * - can only be created by the arbitrator - * - does not require a bond - * - is automatically accepted when created - * - * Additionally, note that this type of disputes allow the arbitrator to directly set the slash and rewards - * amounts, bypassing the usual mechanisms that impose restrictions on those. This is done to give arbitrators - * maximum flexibility to ensure outstanding slashing amounts are settled fairly. This function needs to be removed - * after the transition period. - * - * Requirements: - * - Indexer must have been legacy slashed during or shortly after the transition period - * - Indexer must have provisioned funds to the Subgraph Service - * - * @param allocationId The allocation to dispute - * @param fisherman The fisherman address to be credited with the rewards - * @param tokensSlash The amount of tokens to slash - * @param tokensRewards The amount of tokens to reward the fisherman - * @return The dispute id - */ - function createAndAcceptLegacyDispute( - address allocationId, - address fisherman, - uint256 tokensSlash, - uint256 tokensRewards - ) external returns (bytes32); - // -- Arbitrator -- /** From 714b32cd25097ac3a3af46cd97b170342de5842c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 28 Nov 2025 17:41:18 -0300 Subject: [PATCH 021/157] chore: more interface removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../horizon/internal/IHorizonStakingMain.sol | 72 +------------------ 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index e0a5c082d..4add15391 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -14,7 +14,6 @@ import { IHorizonStakingTypes } from "./IHorizonStakingTypes.sol"; * @notice Provides functions for managing stake, provisions, delegations, and slashing. * @dev Most functions operate over {HorizonStaking} provisions. To uniquely identify a provision * functions take `serviceProvider` and `verifier` addresses. - * @dev TRANSITION PERIOD: After transition period rename to IHorizonStaking. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ @@ -28,21 +27,6 @@ interface IHorizonStakingMain { */ event HorizonStakeDeposited(address indexed serviceProvider, uint256 tokens); - /** - * @notice Emitted when a service provider unstakes tokens during the transition period. - * @param serviceProvider The address of the service provider - * @param tokens The amount of tokens now locked (including previously locked tokens) - * @param until The block number until the stake is locked - */ - event HorizonStakeLocked(address indexed serviceProvider, uint256 tokens, uint256 until); - - /** - * @notice Emitted when a service provider withdraws tokens during the transition period. - * @param serviceProvider The address of the service provider - * @param tokens The amount of tokens withdrawn - */ - event HorizonStakeWithdrawn(address indexed serviceProvider, uint256 tokens); - // -- Events: provision -- /** @@ -327,12 +311,6 @@ interface IHorizonStakingMain { */ event AllowedLockedVerifierSet(address indexed verifier, bool allowed); - /** - * @notice Emitted when the legacy global thawing period is set to zero. - * @dev This marks the end of the transition period. - */ - event ThawingPeriodCleared(); - /** * @notice Emitted when the delegation slashing global flag is set. */ @@ -376,13 +354,6 @@ interface IHorizonStakingMain { */ error HorizonStakingNotAuthorized(address serviceProvider, address verifier, address caller); - /** - * @notice Thrown when attempting to create a provision with a verifier other than the - * subgraph data service. This restriction only applies during the transition period. - * @param verifier The verifier address - */ - error HorizonStakingInvalidVerifier(address verifier); - /** * @notice Thrown when attempting to create a provision with an invalid maximum verifier cut. * @param maxVerifierCut The maximum verifier cut @@ -410,14 +381,6 @@ interface IHorizonStakingMain { */ error HorizonStakingInsufficientIdleStake(uint256 tokens, uint256 minTokens); - /** - * @notice Thrown during the transition period when the service provider has insufficient stake to - * cover their existing legacy allocations. - * @param tokens The actual token amount - * @param minTokens The minimum required token amount - */ - error HorizonStakingInsufficientStakeForLegacyAllocations(uint256 tokens, uint256 minTokens); - // -- Errors: delegation -- /** @@ -488,13 +451,6 @@ interface IHorizonStakingMain { error HorizonStakingNothingToWithdraw(); // -- Errors: misc -- - /** - * @notice Thrown during the transition period when attempting to withdraw tokens that are still thawing. - * @dev Note this thawing refers to the global thawing period applied to legacy allocated tokens, - * it does not refer to thaw requests. - * @param until The block number until the stake is locked - */ - error HorizonStakingStillThawing(uint256 until); /** * @notice Thrown when a service provider attempts to operate on verifiers that are not allowed. @@ -574,40 +530,24 @@ interface IHorizonStakingMain { /** * @notice Move idle stake back to the owner's account. - * Stake is removed from the protocol: - * - During the transition period it's locked for a period of time before it can be withdrawn - * by calling {withdraw}. - * - After the transition period it's immediately withdrawn. - * Note that after the transition period if there are tokens still locked they will have to be - * withdrawn by calling {withdraw}. + * Stake is immediately removed from the protocol. * @dev Requirements: * - `_tokens` cannot be zero. * - `_serviceProvider` must have enough idle stake to cover the staking amount and any * legacy allocation. * - * Emits a {HorizonStakeLocked} event during the transition period. - * Emits a {HorizonStakeWithdrawn} event after the transition period. + * Emits a {HorizonStakeWithdrawn} event. * * @param tokens Amount of tokens to unstake */ function unstake(uint256 tokens) external; - /** - * @notice Withdraw service provider tokens once the thawing period (initiated by {unstake}) has passed. - * All thawed tokens are withdrawn. - * @dev This is only needed during the transition period while we still have - * a global lock. After that, unstake() will automatically withdraw. - */ - function withdraw() external; - /** * @notice Provision stake to a verifier. The tokens will be locked with a thawing period * and will be slashable by the verifier. This is the main mechanism to provision stake to a data * service, where the data service is the verifier. * This function can be called by the service provider or by an operator authorized by the provider * for this specific verifier. - * @dev During the transition period, only the subgraph data service can be used as a verifier. This - * prevents an escape hatch for legacy allocation stake. * @dev Requirements: * - `tokens` cannot be zero. * - The `serviceProvider` must have enough idle stake to cover the tokens to provision. @@ -974,14 +914,6 @@ interface IHorizonStakingMain { */ function setDelegationSlashingEnabled() external; - /** - * @notice Clear the legacy global thawing period. - * This signifies the end of the transition period, after which no legacy allocations should be left. - * @dev This function can only be called by the contract governor. - * @dev Emits a {ThawingPeriodCleared} event. - */ - function clearThawingPeriod() external; - /** * @notice Sets the global maximum thawing period allowed for provisions. * @param maxThawingPeriod The new maximum thawing period, in seconds From 392047cb3497d40151eac808202697bd150f8c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 28 Nov 2025 18:23:46 -0300 Subject: [PATCH 022/157] feat: clean up post horizon on horizon contracts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStaking.sol | 100 +--- .../contracts/staking/HorizonStakingBase.sol | 25 +- .../staking/HorizonStakingExtension.sol | 484 ------------------ .../staking/HorizonStakingStorage.sol | 5 +- .../staking/libraries/ExponentialRebates.sol | 68 --- .../contracts/utilities/GraphDirectory.sol | 25 +- .../horizon/internal/IHorizonStakingMain.sol | 30 +- .../subgraph-service/ISubgraphService.sol | 10 - .../toolshed/internal/IAllocationManager.sol | 6 - 9 files changed, 50 insertions(+), 703 deletions(-) delete mode 100644 packages/horizon/contracts/staking/HorizonStakingExtension.sol delete mode 100644 packages/horizon/contracts/staking/libraries/ExponentialRebates.sol diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 73f48c354..5384e7698 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -9,7 +9,6 @@ pragma solidity 0.8.27; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol"; @@ -28,9 +27,6 @@ import { HorizonStakingBase } from "./HorizonStakingBase.sol"; * @dev Implements the {IHorizonStakingMain} interface. * @dev This is the main Staking contract in The Graph protocol after the Horizon upgrade. * It is designed to be deployed as an upgrade to the L2Staking contract from the legacy contracts package. - * @dev It uses a {HorizonStakingExtension} contract to implement the full {IHorizonStaking} interface through delegatecalls. - * This is due to the contract size limit on Arbitrum (24kB). The extension contract implements functionality to support - * the legacy staking functions. It can be eventually removed without affecting the main staking contract. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ @@ -407,21 +403,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { uint256 tokensVerifier, address verifierDestination ) external override notPaused { - // TRANSITION PERIOD: remove after the transition period - // Check if sender is authorized to slash on the deprecated list - if (__DEPRECATED_slashers[msg.sender]) { - // Forward call to staking extension - // solhint-disable-next-line avoid-low-level-calls - (bool success, ) = STAKING_EXTENSION_ADDRESS.delegatecall( - abi.encodeCall( - IHorizonStakingExtension.legacySlash, - (serviceProvider, tokens, tokensVerifier, verifierDestination) - ) - ); - require(success, HorizonStakingLegacySlashFailed()); - return; - } - address verifier = msg.sender; Provision storage prov = _provisions[serviceProvider][verifier]; DelegationPoolInternal storage pool = _getDelegationPool(serviceProvider, verifier); @@ -538,12 +519,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { emit DelegationSlashingEnabled(); } - /// @inheritdoc IHorizonStakingMain - function clearThawingPeriod() external override onlyGovernor { - __DEPRECATED_thawingPeriod = 0; - emit ThawingPeriodCleared(); - } - /// @inheritdoc IHorizonStakingMain function setMaxThawingPeriod(uint64 maxThawingPeriod) external override onlyGovernor { _maxThawingPeriod = maxThawingPeriod; @@ -569,17 +544,19 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { } /* - * GETTERS + * PRIVATE FUNCTIONS */ - /// @inheritdoc IHorizonStakingMain - function getStakingExtension() external view override returns (address) { - return STAKING_EXTENSION_ADDRESS; - } - - /* - * PRIVATE FUNCTIONS + /** + * @notice Deposit tokens into the service provider stake. + * Emits a {HorizonStakeDeposited} event. + * @param _serviceProvider The address of the service provider. + * @param _tokens The amount of tokens to deposit. */ + function _stake(address _serviceProvider, uint256 _tokens) internal { + _serviceProviders[_serviceProvider].tokensStaked = _serviceProviders[_serviceProvider].tokensStaked + _tokens; + emit HorizonStakeDeposited(_serviceProvider, _tokens); + } /** * @notice Deposit tokens on the service provider stake, on behalf of the service provider. @@ -599,12 +576,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { /** * @notice Move idle stake back to the owner's account. - * Stake is removed from the protocol: - * - During the transition period it's locked for a period of time before it can be withdrawn - * by calling {withdraw}. - * - After the transition period it's immediately withdrawn. - * Note that after the transition period if there are tokens still locked they will have to be - * withdrawn by calling {withdraw}. + * Stake is immediately removed from the protocol. * @param _tokens Amount of tokens to unstake */ function _unstake(uint256 _tokens) private { @@ -616,43 +588,18 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { ServiceProviderInternal storage sp = _serviceProviders[serviceProvider]; uint256 stakedTokens = sp.tokensStaked; - // This is also only during the transition period: we need - // to ensure tokens stay locked after closing legacy allocations. - // After sufficient time (56 days?) we should remove the closeAllocation function - // and set the thawing period to 0. - uint256 lockingPeriod = __DEPRECATED_thawingPeriod; - if (lockingPeriod == 0) { - sp.tokensStaked = stakedTokens - _tokens; - _graphToken().pushTokens(serviceProvider, _tokens); - emit HorizonStakeWithdrawn(serviceProvider, _tokens); - } else { - // Before locking more tokens, withdraw any unlocked ones if possible - if (sp.__DEPRECATED_tokensLocked != 0 && block.number >= sp.__DEPRECATED_tokensLockedUntil) { - _withdraw(serviceProvider); - } - // TRANSITION PERIOD: remove after the transition period - // Take into account period averaging for multiple unstake requests - if (sp.__DEPRECATED_tokensLocked > 0) { - lockingPeriod = MathUtils.weightedAverageRoundingUp( - MathUtils.diffOrZero(sp.__DEPRECATED_tokensLockedUntil, block.number), // Remaining thawing period - sp.__DEPRECATED_tokensLocked, // Weighted by remaining unstaked tokens - lockingPeriod, // Thawing period - _tokens // Weighted by new tokens to unstake - ); - } - - // Update balances - sp.__DEPRECATED_tokensLocked = sp.__DEPRECATED_tokensLocked + _tokens; - sp.__DEPRECATED_tokensLockedUntil = block.number + lockingPeriod; - emit HorizonStakeLocked(serviceProvider, sp.__DEPRECATED_tokensLocked, sp.__DEPRECATED_tokensLockedUntil); - } + sp.tokensStaked = stakedTokens - _tokens; + _graphToken().pushTokens(serviceProvider, _tokens); + emit HorizonStakeWithdrawn(serviceProvider, _tokens); } /** * @notice Withdraw service provider tokens once the thawing period (initiated by {unstake}) has passed. * All thawed tokens are withdrawn. - * @dev TRANSITION PERIOD: This is only needed during the transition period while we still have - * a global lock. After that, unstake() will automatically withdraw. + * This function is for backwards compatibility with the legacy staking contract. + * It only allows withdrawing tokens unstaked before horizon upgrade. + * @dev This function can't be removed in case there are still pre-horizon unstakes. + * Note that it's assumed unstakes have already passed their thawing period. * @param _serviceProvider Address of service provider to withdraw funds from */ function _withdraw(address _serviceProvider) private { @@ -660,10 +607,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { ServiceProviderInternal storage sp = _serviceProviders[_serviceProvider]; uint256 tokensToWithdraw = sp.__DEPRECATED_tokensLocked; require(tokensToWithdraw != 0, HorizonStakingInvalidZeroTokens()); - require( - block.number >= sp.__DEPRECATED_tokensLockedUntil, - HorizonStakingStillThawing(sp.__DEPRECATED_tokensLockedUntil) - ); // Reset locked tokens sp.__DEPRECATED_tokensLocked = 0; @@ -683,8 +626,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { * service, where the data service is the verifier. * This function can be called by the service provider or by an operator authorized by the provider * for this specific verifier. - * @dev TRANSITION PERIOD: During the transition period, only the subgraph data service can be used as a verifier. This - * prevents an escape hatch for legacy allocation stake. * @param _serviceProvider The service provider address * @param _tokens The amount of tokens that will be locked and slashable * @param _verifier The verifier address for which the tokens are provisioned (who will be able to slash the tokens) @@ -699,11 +640,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { uint64 _thawingPeriod ) private { require(_tokens > 0, HorizonStakingInvalidZeroTokens()); - // TRANSITION PERIOD: Remove this after the transition period - it prevents an early escape hatch for legacy allocations - require( - _verifier == SUBGRAPH_DATA_SERVICE_ADDRESS || __DEPRECATED_thawingPeriod == 0, - HorizonStakingInvalidVerifier(_verifier) - ); require(PPMMath.isValidPPM(_maxVerifierCut), HorizonStakingInvalidMaxVerifierCut(_maxVerifierCut)); require( _thawingPeriod <= _maxThawingPeriod, diff --git a/packages/horizon/contracts/staking/HorizonStakingBase.sol b/packages/horizon/contracts/staking/HorizonStakingBase.sol index 9c52a2171..520bd4dd6 100644 --- a/packages/horizon/contracts/staking/HorizonStakingBase.sol +++ b/packages/horizon/contracts/staking/HorizonStakingBase.sol @@ -23,9 +23,7 @@ import { HorizonStakingV1Storage } from "./HorizonStakingStorage.sol"; * @author Edge & Node * @notice This contract is the base staking contract implementing storage getters for both internal * and external use. - * @dev Implementation of the {IHorizonStakingBase} interface. - * @dev It's meant to be inherited by the {HorizonStaking} and {HorizonStakingExtension} - * contracts so some internal functions are also included here. + * @dev Implementation of the {IHorizonStakingBase} interface, meant to be inherited by {HorizonStaking}. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ @@ -218,31 +216,18 @@ abstract contract HorizonStakingBase is return _delegationSlashingEnabled; } - /** - * @notice Deposit tokens into the service provider stake. - * @dev TRANSITION PERIOD: After transition period move to IHorizonStakingMain. Temporarily it - * needs to be here since it's used by both {HorizonStaking} and {HorizonStakingExtension}. - * - * Emits a {HorizonStakeDeposited} event. - * @param _serviceProvider The address of the service provider. - * @param _tokens The amount of tokens to deposit. - */ - function _stake(address _serviceProvider, uint256 _tokens) internal { - _serviceProviders[_serviceProvider].tokensStaked = _serviceProviders[_serviceProvider].tokensStaked + _tokens; - emit HorizonStakeDeposited(_serviceProvider, _tokens); - } - /** * @notice Gets the service provider's idle stake which is the stake that is not being * used for any provision. Note that this only includes service provider's self stake. - * @dev Note that the calculation considers tokens that were locked in the legacy staking contract. - * @dev TRANSITION PERIOD: update the calculation after the transition period. + * @dev Note that the calculation: + * - assumes tokens that were allocated to a subgraph deployment pre-horizon were all unallocated. + * - considers tokens that were locked in the legacy staking contract and never withdrawn. + * * @param _serviceProvider The address of the service provider. * @return The amount of tokens that are idle. */ function _getIdleStake(address _serviceProvider) internal view returns (uint256) { uint256 tokensUsed = _serviceProviders[_serviceProvider].tokensProvisioned + - _serviceProviders[_serviceProvider].__DEPRECATED_tokensAllocated + _serviceProviders[_serviceProvider].__DEPRECATED_tokensLocked; uint256 tokensStaked = _serviceProviders[_serviceProvider].tokensStaked; return tokensStaked > tokensUsed ? tokensStaked - tokensUsed : 0; diff --git a/packages/horizon/contracts/staking/HorizonStakingExtension.sol b/packages/horizon/contracts/staking/HorizonStakingExtension.sol deleted file mode 100644 index b1adcde0d..000000000 --- a/packages/horizon/contracts/staking/HorizonStakingExtension.sol +++ /dev/null @@ -1,484 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -pragma solidity 0.8.27; - -// TODO: Re-enable and fix issues when publishing a new version -// solhint-disable function-max-lines, gas-strict-inequalities - -import { ICuration } from "@graphprotocol/interfaces/contracts/contracts/curation/ICuration.sol"; -import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; -import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol"; - -import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol"; -import { MathUtils } from "../libraries/MathUtils.sol"; -import { ExponentialRebates } from "./libraries/ExponentialRebates.sol"; -import { PPMMath } from "../libraries/PPMMath.sol"; - -import { HorizonStakingBase } from "./HorizonStakingBase.sol"; - -/** - * @title Horizon Staking extension contract - * @author Edge & Node - * @notice The {HorizonStakingExtension} contract implements the legacy functionality required to support the transition - * to the Horizon Staking contract. It allows indexers to close allocations and collect pending query fees, but it - * does not allow for the creation of new allocations. This should allow indexers to migrate to a subgraph data service - * without losing rewards or having service interruptions. - * @dev TRANSITION PERIOD: Once the transition period passes this contract can be removed (note that an upgrade to the - * RewardsManager will also be required). It's expected the transition period to last for at least a full allocation cycle - * (28 epochs). - * @custom:security-contact Please email security+contracts@thegraph.com if you find any - * bugs. We may have an active bug bounty program. - */ -contract HorizonStakingExtension is HorizonStakingBase, IHorizonStakingExtension { - using TokenUtils for IGraphToken; - using PPMMath for uint256; - - /** - * @dev Check if the caller is the slasher. - */ - modifier onlySlasher() { - require(__DEPRECATED_slashers[msg.sender], "!slasher"); - _; - } - - /** - * @notice The staking contract is upgradeable however we still use the constructor to set a few immutable variables - * @param controller The address of the Graph controller contract - * @param subgraphDataServiceAddress The address of the subgraph data service - */ - constructor( - address controller, - address subgraphDataServiceAddress - ) HorizonStakingBase(controller, subgraphDataServiceAddress) {} - - /// @inheritdoc IHorizonStakingExtension - function closeAllocation(address allocationID, bytes32 poi) external override notPaused { - _closeAllocation(allocationID, poi); - } - - /// @inheritdoc IHorizonStakingExtension - function collect(uint256 tokens, address allocationID) external override notPaused { - // Allocation identifier validation - require(allocationID != address(0), "!alloc"); - - // Allocation must exist - AllocationState allocState = _getAllocationState(allocationID); - require(allocState != AllocationState.Null, "!collect"); - - // If the query fees are zero, we don't want to revert - // but we also don't need to do anything, so just return - if (tokens == 0) { - return; - } - - Allocation storage alloc = __DEPRECATED_allocations[allocationID]; - bytes32 subgraphDeploymentID = alloc.subgraphDeploymentID; - - uint256 queryFees = tokens; // Tokens collected from the channel - uint256 protocolTax = 0; // Tokens burnt as protocol tax - uint256 curationFees = 0; // Tokens distributed to curators as curation fees - uint256 queryRebates = 0; // Tokens to distribute to indexer - uint256 delegationRewards = 0; // Tokens to distribute to delegators - - { - // -- Pull tokens from the sender -- - _graphToken().pullTokens(msg.sender, queryFees); - - // -- Collect protocol tax -- - protocolTax = _collectTax(queryFees, __DEPRECATED_protocolPercentage); - queryFees = queryFees - protocolTax; - - // -- Collect curation fees -- - // Only if the subgraph deployment is curated - curationFees = _collectCurationFees(subgraphDeploymentID, queryFees, __DEPRECATED_curationPercentage); - queryFees = queryFees - curationFees; - - // -- Process rebate reward -- - // Using accumulated fees and subtracting previously distributed rebates - // allows for multiple vouchers to be collected while following the rebate formula - alloc.collectedFees = alloc.collectedFees + queryFees; - - // No rebates if indexer has no stake or if lambda is zero - uint256 newRebates = (alloc.tokens == 0 || __DEPRECATED_lambdaNumerator == 0) - ? 0 - : ExponentialRebates.exponentialRebates( - alloc.collectedFees, - alloc.tokens, - __DEPRECATED_alphaNumerator, - __DEPRECATED_alphaDenominator, - __DEPRECATED_lambdaNumerator, - __DEPRECATED_lambdaDenominator - ); - - // -- Ensure rebates to distribute are within bounds -- - // Indexers can become under or over rebated if rebate parameters (alpha, lambda) - // change between successive collect calls for the same allocation - - // Ensure rebates to distribute are not negative (indexer is over-rebated) - queryRebates = MathUtils.diffOrZero(newRebates, alloc.distributedRebates); - - // Ensure rebates to distribute are not greater than available (indexer is under-rebated) - queryRebates = MathUtils.min(queryRebates, queryFees); - - // -- Burn rebates remanent -- - _graphToken().burnTokens(queryFees - queryRebates); - - // -- Distribute rebates -- - if (queryRebates > 0) { - alloc.distributedRebates = alloc.distributedRebates + queryRebates; - - // -- Collect delegation rewards into the delegation pool -- - delegationRewards = _collectDelegationQueryRewards(alloc.indexer, queryRebates); - queryRebates = queryRebates - delegationRewards; - - // -- Transfer or restake rebates -- - _sendRewards(queryRebates, alloc.indexer, __DEPRECATED_rewardsDestination[alloc.indexer] == address(0)); - } - } - - emit RebateCollected( - msg.sender, - alloc.indexer, - subgraphDeploymentID, - allocationID, - _graphEpochManager().currentEpoch(), - tokens, - protocolTax, - curationFees, - queryFees, - queryRebates, - delegationRewards - ); - } - - /// @inheritdoc IHorizonStakingExtension - function legacySlash( - address indexer, - uint256 tokens, - uint256 reward, - address beneficiary - ) external override onlySlasher notPaused { - ServiceProviderInternal storage indexerStake = _serviceProviders[indexer]; - - // Only able to slash a non-zero number of tokens - require(tokens > 0, "!tokens"); - - // Rewards comes from tokens slashed balance - require(tokens >= reward, "rewards>slash"); - - // Cannot slash stake of an indexer without any or enough stake - require(indexerStake.tokensStaked > 0, "!stake"); - require(tokens <= indexerStake.tokensStaked, "slash>stake"); - - // Validate beneficiary of slashed tokens - require(beneficiary != address(0), "!beneficiary"); - - // Slashing tokens that are already provisioned would break provision accounting, we need to limit - // the slash amount. This can be compensated for, by slashing with the main slash function if needed. - uint256 slashableStake = indexerStake.tokensStaked - indexerStake.tokensProvisioned; - if (slashableStake == 0) { - emit StakeSlashed(indexer, 0, 0, beneficiary); - return; - } - if (tokens > slashableStake) { - reward = (reward * slashableStake) / tokens; - tokens = slashableStake; - } - - // Slashing more tokens than freely available (over allocation condition) - // Unlock locked tokens to avoid the indexer to withdraw them - uint256 tokensUsed = indexerStake.__DEPRECATED_tokensAllocated + indexerStake.__DEPRECATED_tokensLocked; - uint256 tokensAvailable = tokensUsed > indexerStake.tokensStaked ? 0 : indexerStake.tokensStaked - tokensUsed; - if (tokens > tokensAvailable && indexerStake.__DEPRECATED_tokensLocked > 0) { - uint256 tokensOverAllocated = tokens - tokensAvailable; - uint256 tokensToUnlock = MathUtils.min(tokensOverAllocated, indexerStake.__DEPRECATED_tokensLocked); - indexerStake.__DEPRECATED_tokensLocked = indexerStake.__DEPRECATED_tokensLocked - tokensToUnlock; - if (indexerStake.__DEPRECATED_tokensLocked == 0) { - indexerStake.__DEPRECATED_tokensLockedUntil = 0; - } - } - - // Remove tokens to slash from the stake - indexerStake.tokensStaked = indexerStake.tokensStaked - tokens; - - // -- Interactions -- - - // Set apart the reward for the beneficiary and burn remaining slashed stake - _graphToken().burnTokens(tokens - reward); - - // Give the beneficiary a reward for slashing - _graphToken().pushTokens(beneficiary, reward); - - emit StakeSlashed(indexer, tokens, reward, beneficiary); - } - - /// @inheritdoc IHorizonStakingExtension - function isAllocation(address allocationID) external view override returns (bool) { - return _getAllocationState(allocationID) != AllocationState.Null; - } - - /// @inheritdoc IHorizonStakingExtension - function getAllocation(address allocationID) external view override returns (Allocation memory) { - return __DEPRECATED_allocations[allocationID]; - } - - /// @inheritdoc IRewardsIssuer - function getAllocationData( - address allocationID - ) external view override returns (bool, address, bytes32, uint256, uint256, uint256) { - Allocation memory allo = __DEPRECATED_allocations[allocationID]; - bool isActive = _getAllocationState(allocationID) == AllocationState.Active; - return (isActive, allo.indexer, allo.subgraphDeploymentID, allo.tokens, allo.accRewardsPerAllocatedToken, 0); - } - - /// @inheritdoc IHorizonStakingExtension - function getAllocationState(address allocationID) external view override returns (AllocationState) { - return _getAllocationState(allocationID); - } - - /// @inheritdoc IRewardsIssuer - function getSubgraphAllocatedTokens(bytes32 subgraphDeploymentID) external view override returns (uint256) { - return __DEPRECATED_subgraphAllocations[subgraphDeploymentID]; - } - - /// @inheritdoc IHorizonStakingExtension - function getIndexerStakedTokens(address indexer) external view override returns (uint256) { - return _serviceProviders[indexer].tokensStaked; - } - - /// @inheritdoc IHorizonStakingExtension - function getSubgraphService() external view override returns (address) { - return SUBGRAPH_DATA_SERVICE_ADDRESS; - } - - /// @inheritdoc IHorizonStakingExtension - function hasStake(address indexer) external view override returns (bool) { - return _serviceProviders[indexer].tokensStaked > 0; - } - - /// @inheritdoc IHorizonStakingExtension - function __DEPRECATED_getThawingPeriod() external view returns (uint64) { - return __DEPRECATED_thawingPeriod; - } - - /// @inheritdoc IHorizonStakingExtension - function isOperator(address operator, address serviceProvider) public view override returns (bool) { - return _legacyOperatorAuth[serviceProvider][operator]; - } - - /** - * @notice Collect tax to burn for an amount of tokens - * @param _tokens Total tokens received used to calculate the amount of tax to collect - * @param _percentage Percentage of tokens to burn as tax - * @return Amount of tax charged - */ - function _collectTax(uint256 _tokens, uint256 _percentage) private returns (uint256) { - uint256 tax = _tokens.mulPPMRoundUp(_percentage); - _graphToken().burnTokens(tax); // Burn tax if any - return tax; - } - - /** - * @notice Triggers an update of rewards due to a change in allocations - * @param _subgraphDeploymentID Subgraph deployment updated - */ - function _updateRewards(bytes32 _subgraphDeploymentID) private { - _graphRewardsManager().onSubgraphAllocationUpdate(_subgraphDeploymentID); - } - - /** - * @notice Assign rewards for the closed allocation to indexer and delegators - * @param _allocationID Allocation - * @param _indexer Address of the indexer that did the allocation - */ - function _distributeRewards(address _allocationID, address _indexer) private { - // Automatically triggers update of rewards snapshot as allocation will change - // after this call. Take rewards mint tokens for the Staking contract to distribute - // between indexer and delegators - uint256 totalRewards = _graphRewardsManager().takeRewards(_allocationID); - if (totalRewards == 0) { - return; - } - - // Calculate delegation rewards and add them to the delegation pool - uint256 delegationRewards = _collectDelegationIndexingRewards(_indexer, totalRewards); - uint256 indexerRewards = totalRewards - delegationRewards; - - // Send the indexer rewards - _sendRewards(indexerRewards, _indexer, __DEPRECATED_rewardsDestination[_indexer] == address(0)); - } - - /** - * @notice Send rewards to the appropriate destination - * @param _tokens Number of rewards tokens - * @param _beneficiary Address of the beneficiary of rewards - * @param _restake Whether to restake or not - */ - function _sendRewards(uint256 _tokens, address _beneficiary, bool _restake) private { - if (_tokens == 0) return; - - if (_restake) { - // Restake to place fees into the indexer stake - _stake(_beneficiary, _tokens); - } else { - // Transfer funds to the beneficiary's designated rewards destination if set - address destination = __DEPRECATED_rewardsDestination[_beneficiary]; - _graphToken().pushTokens(destination == address(0) ? _beneficiary : destination, _tokens); - } - } - - /** - * @notice Close an allocation and free the staked tokens - * @param _allocationID The allocation identifier - * @param _poi Proof of indexing submitted for the allocated period - */ - function _closeAllocation(address _allocationID, bytes32 _poi) private { - // Allocation must exist and be active - AllocationState allocState = _getAllocationState(_allocationID); - require(allocState == AllocationState.Active, "!active"); - - // Get allocation - Allocation memory alloc = __DEPRECATED_allocations[_allocationID]; - - // Validate that an allocation cannot be closed before one epoch - alloc.closedAtEpoch = _graphEpochManager().currentEpoch(); - uint256 epochs = MathUtils.diffOrZero(alloc.closedAtEpoch, alloc.createdAtEpoch); - - // Indexer or operator can close an allocation - // Anyone is allowed to close ONLY under two concurrent conditions - // - After maxAllocationEpochs passed - // - When the allocation is for non-zero amount of tokens - bool isIndexerOrOperator = msg.sender == alloc.indexer || isOperator(msg.sender, alloc.indexer); - if (epochs <= __DEPRECATED_maxAllocationEpochs || alloc.tokens == 0) { - require(isIndexerOrOperator, "!auth"); - } - - // -- Rewards Distribution -- - - // Process non-zero-allocation rewards tracking - if (alloc.tokens > 0) { - // Distribute rewards if proof of indexing was presented by the indexer or operator - if (isIndexerOrOperator && _poi != 0 && epochs > 0) { - _distributeRewards(_allocationID, alloc.indexer); - } else { - _updateRewards(alloc.subgraphDeploymentID); - } - - // Free allocated tokens from use - _serviceProviders[alloc.indexer].__DEPRECATED_tokensAllocated = - _serviceProviders[alloc.indexer].__DEPRECATED_tokensAllocated - alloc.tokens; - - // Track total allocations per subgraph - // Used for rewards calculations - __DEPRECATED_subgraphAllocations[alloc.subgraphDeploymentID] = - __DEPRECATED_subgraphAllocations[alloc.subgraphDeploymentID] - alloc.tokens; - } - - // Close the allocation - // Note that this breaks CEI pattern. We update after the rewards distribution logic as it expects the allocation - // to still be active. There shouldn't be reentrancy risk here as all internal calls are to trusted contracts. - __DEPRECATED_allocations[_allocationID].closedAtEpoch = alloc.closedAtEpoch; - - emit AllocationClosed( - alloc.indexer, - alloc.subgraphDeploymentID, - alloc.closedAtEpoch, - alloc.tokens, - _allocationID, - msg.sender, - _poi, - !isIndexerOrOperator - ); - } - - /** - * @notice Collect the delegation rewards for query fees - * @dev This function will assign the collected fees to the delegation pool - * @param _indexer Indexer to which the tokens to distribute are related - * @param _tokens Total tokens received used to calculate the amount of fees to collect - * @return Amount of delegation rewards - */ - function _collectDelegationQueryRewards(address _indexer, uint256 _tokens) private returns (uint256) { - uint256 delegationRewards = 0; - DelegationPoolInternal storage pool = _legacyDelegationPools[_indexer]; - if (pool.tokens > 0 && uint256(pool.__DEPRECATED_queryFeeCut).isValidPPM()) { - uint256 indexerCut = uint256(pool.__DEPRECATED_queryFeeCut).mulPPM(_tokens); - delegationRewards = _tokens - indexerCut; - pool.tokens = pool.tokens + delegationRewards; - } - return delegationRewards; - } - - /** - * @notice Collect the delegation rewards for indexing - * @dev This function will assign the collected fees to the delegation pool - * @param _indexer Indexer to which the tokens to distribute are related - * @param _tokens Total tokens received used to calculate the amount of fees to collect - * @return Amount of delegation rewards - */ - function _collectDelegationIndexingRewards(address _indexer, uint256 _tokens) private returns (uint256) { - uint256 delegationRewards = 0; - DelegationPoolInternal storage pool = _legacyDelegationPools[_indexer]; - if (pool.tokens > 0 && uint256(pool.__DEPRECATED_indexingRewardCut).isValidPPM()) { - uint256 indexerCut = uint256(pool.__DEPRECATED_indexingRewardCut).mulPPM(_tokens); - delegationRewards = _tokens - indexerCut; - pool.tokens = pool.tokens + delegationRewards; - } - return delegationRewards; - } - - /** - * @notice Collect the curation fees for a subgraph deployment from an amount of tokens - * @dev This function transfer curation fees to the Curation contract by calling Curation.collect - * @param _subgraphDeploymentID Subgraph deployment to which the curation fees are related - * @param _tokens Total tokens received used to calculate the amount of fees to collect - * @param _curationCut Percentage of tokens to collect as fees - * @return Amount of curation fees - */ - function _collectCurationFees( - bytes32 _subgraphDeploymentID, - uint256 _tokens, - uint256 _curationCut - ) private returns (uint256) { - if (_tokens == 0) { - return 0; - } - - ICuration curation = _graphCuration(); - bool isCurationEnabled = _curationCut > 0 && address(curation) != address(0); - - if (isCurationEnabled && curation.isCurated(_subgraphDeploymentID)) { - uint256 curationFees = _tokens.mulPPMRoundUp(_curationCut); - if (curationFees > 0) { - // Transfer and call collect() - // This function transfer tokens to a trusted protocol contracts - // Then we call collect() to do the transfer Bookkeeping - _graphRewardsManager().onSubgraphSignalUpdate(_subgraphDeploymentID); - _graphToken().pushTokens(address(curation), curationFees); - curation.collect(_subgraphDeploymentID, curationFees); - } - return curationFees; - } - return 0; - } - - /** - * @notice Return the current state of an allocation - * @param _allocationID Allocation identifier - * @return AllocationState enum with the state of the allocation - */ - function _getAllocationState(address _allocationID) private view returns (AllocationState) { - Allocation storage alloc = __DEPRECATED_allocations[_allocationID]; - - if (alloc.indexer == address(0)) { - return AllocationState.Null; - } - - if (alloc.createdAtEpoch != 0 && alloc.closedAtEpoch == 0) { - return AllocationState.Active; - } - - return AllocationState.Closed; - } -} diff --git a/packages/horizon/contracts/staking/HorizonStakingStorage.sol b/packages/horizon/contracts/staking/HorizonStakingStorage.sol index 5f63af9df..a10b853a8 100644 --- a/packages/horizon/contracts/staking/HorizonStakingStorage.sol +++ b/packages/horizon/contracts/staking/HorizonStakingStorage.sol @@ -2,7 +2,6 @@ pragma solidity 0.8.27; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol"; @@ -62,7 +61,7 @@ abstract contract HorizonStakingV1Storage { /// @dev Allocation details. /// Deprecated, now applied on the subgraph data service - mapping(address allocationId => IHorizonStakingExtension.Allocation allocation) internal __DEPRECATED_allocations; + mapping(address allocationId => bytes32 __DEPRECATED_allocation) internal __DEPRECATED_allocations; /// @dev Subgraph allocations, tracks the tokens allocated to a subgraph deployment /// Deprecated, now applied on the SubgraphService @@ -89,7 +88,7 @@ abstract contract HorizonStakingV1Storage { uint32 internal __DEPRECATED_delegationParametersCooldown; /// @dev Time in epochs a delegator needs to wait to withdraw delegated stake - /// Deprecated, now only enforced during a transition period + /// Deprecated, enforced by each data service as needed. uint32 internal __DEPRECATED_delegationUnbondingPeriod; /// @dev Percentage of tokens to tax a delegation deposit diff --git a/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol b/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol deleted file mode 100644 index 974e7197b..000000000 --- a/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -pragma solidity 0.8.27; - -import { LibFixedMath } from "../../libraries/LibFixedMath.sol"; - -/** - * @title ExponentialRebates library - * @author Edge & Node - * @notice A library to compute query fee rebates using an exponential formula - * @dev This is only used for backwards compatibility in HorizonStaking, and should - * be removed after the transition period. - * @custom:security-contact Please email security+contracts@thegraph.com if you find any - * bugs. We may have an active bug bounty program. - */ -library ExponentialRebates { - /// @dev Maximum value of the exponent for which to compute the exponential before clamping to zero. - uint32 private constant MAX_EXPONENT = 15; - - /** - * @notice The exponential formula used to compute fee-based rewards for staking pools in a given epoch - * @dev This function does not perform bounds checking on the inputs, but the following conditions - * need to be true: - * 0 <= alphaNumerator / alphaDenominator <= 1 - * 0 < lambdaNumerator / lambdaDenominator - * The exponential rebates function has the form: - * `(1 - alpha * exp ^ (-lambda * stake / fees)) * fees` - * @param fees Fees generated by indexer in the staking pool - * @param stake Stake attributed to the indexer in the staking pool - * @param alphaNumerator Numerator of `alpha` in the rebates function - * @param alphaDenominator Denominator of `alpha` in the rebates function - * @param lambdaNumerator Numerator of `lambda` in the rebates function - * @param lambdaDenominator Denominator of `lambda` in the rebates function - * @return rewards Rewards owed to the staking pool - */ - function exponentialRebates( - uint256 fees, - uint256 stake, - uint32 alphaNumerator, - uint32 alphaDenominator, - uint32 lambdaNumerator, - uint32 lambdaDenominator - ) external pure returns (uint256) { - // If alpha is zero indexer gets 100% fees rebate - int256 alpha = LibFixedMath.toFixed(int32(alphaNumerator), int32(alphaDenominator)); - if (alpha == 0) { - return fees; - } - - // No rebates if no fees... - if (fees == 0) { - return 0; - } - - // Award all fees as rebate if the exponent is too large - int256 lambda = LibFixedMath.toFixed(int32(lambdaNumerator), int32(lambdaDenominator)); - int256 exponent = LibFixedMath.mulDiv(lambda, int256(stake), int256(fees)); - if (LibFixedMath.toInteger(exponent) > int256(uint256(MAX_EXPONENT))) { - return fees; - } - - // Compute `1 - alpha * exp ^(-exponent)` - int256 factor = LibFixedMath.sub(LibFixedMath.one(), LibFixedMath.mul(alpha, LibFixedMath.exp(-exponent))); - - // Weight the fees by the factor - return LibFixedMath.uintMul(factor, fees); - } -} diff --git a/packages/horizon/contracts/utilities/GraphDirectory.sol b/packages/horizon/contracts/utilities/GraphDirectory.sol index 6e657c6d7..f5f86841e 100644 --- a/packages/horizon/contracts/utilities/GraphDirectory.sol +++ b/packages/horizon/contracts/utilities/GraphDirectory.sol @@ -13,8 +13,6 @@ import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/r import { ITokenGateway } from "@graphprotocol/interfaces/contracts/contracts/arbitrum/ITokenGateway.sol"; import { IGraphProxyAdmin } from "@graphprotocol/interfaces/contracts/contracts/upgrades/IGraphProxyAdmin.sol"; -import { ICuration } from "@graphprotocol/interfaces/contracts/contracts/curation/ICuration.sol"; - /** * @title GraphDirectory contract * @author Edge & Node @@ -55,13 +53,6 @@ abstract contract GraphDirectory { /// @notice The Graph Proxy Admin contract address IGraphProxyAdmin private immutable GRAPH_PROXY_ADMIN; - // -- Legacy Graph contracts -- - // These are required for backwards compatibility on HorizonStakingExtension - // TRANSITION PERIOD: remove these once HorizonStakingExtension is removed - - /// @notice The Curation contract address - ICuration private immutable GRAPH_CURATION; - /** * @notice Emitted when the GraphDirectory is initialized * @param graphToken The Graph Token contract address @@ -73,7 +64,6 @@ abstract contract GraphDirectory { * @param graphRewardsManager The Rewards Manager contract address * @param graphTokenGateway The Token Gateway contract address * @param graphProxyAdmin The Graph Proxy Admin contract address - * @param graphCuration The Curation contract address */ event GraphDirectoryInitialized( address indexed graphToken, @@ -84,8 +74,7 @@ abstract contract GraphDirectory { address graphEpochManager, address graphRewardsManager, address graphTokenGateway, - address graphProxyAdmin, - address graphCuration + address graphProxyAdmin ); /** @@ -116,7 +105,6 @@ abstract contract GraphDirectory { GRAPH_REWARDS_MANAGER = IRewardsManager(_getContractFromController("RewardsManager")); GRAPH_TOKEN_GATEWAY = ITokenGateway(_getContractFromController("GraphTokenGateway")); GRAPH_PROXY_ADMIN = IGraphProxyAdmin(_getContractFromController("GraphProxyAdmin")); - GRAPH_CURATION = ICuration(_getContractFromController("Curation")); emit GraphDirectoryInitialized( address(GRAPH_TOKEN), @@ -127,8 +115,7 @@ abstract contract GraphDirectory { address(GRAPH_EPOCH_MANAGER), address(GRAPH_REWARDS_MANAGER), address(GRAPH_TOKEN_GATEWAY), - address(GRAPH_PROXY_ADMIN), - address(GRAPH_CURATION) + address(GRAPH_PROXY_ADMIN) ); } @@ -204,14 +191,6 @@ abstract contract GraphDirectory { return GRAPH_PROXY_ADMIN; } - /** - * @notice Get the Curation contract - * @return The Curation contract - */ - function _graphCuration() internal view returns (ICuration) { - return GRAPH_CURATION; - } - /** * @notice Get a contract address from the controller * @dev Requirements: diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index 4add15391..f4f9499ae 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -27,6 +27,13 @@ interface IHorizonStakingMain { */ event HorizonStakeDeposited(address indexed serviceProvider, uint256 tokens); + /** + * @notice Emitted when a service provider unstakes tokens. + * @param serviceProvider The address of the service provider + * @param tokens The amount of tokens withdrawn + */ + event HorizonStakeWithdrawn(address indexed serviceProvider, uint256 tokens); + // -- Events: provision -- /** @@ -206,7 +213,7 @@ interface IHorizonStakingMain { /** * @notice Emitted when `delegator` withdrew delegated `tokens` from `indexer` using `withdrawDelegated`. - * @dev This event is for the legacy `withdrawDelegated` function. + * @dev This event is for the legacy `withdrawDelegated` function, only emitted for pre-horizon undelegations. * @param indexer The address of the indexer * @param delegator The address of the delegator * @param tokens The amount of tokens withdrawn @@ -446,7 +453,8 @@ interface IHorizonStakingMain { error HorizonStakingTooManyThawRequests(); /** - * @notice Thrown when attempting to withdraw tokens that have not thawed (legacy undelegate). + * @notice Thrown when attempting to withdraw tokens that have not thawed. + * @dev This error is only thrown for pre-horizon undelegations. */ error HorizonStakingNothingToWithdraw(); @@ -470,11 +478,6 @@ interface IHorizonStakingMain { */ error HorizonStakingInvalidDelegationFeeCut(uint256 feeCut); - /** - * @notice Thrown when a legacy slash fails. - */ - error HorizonStakingLegacySlashFailed(); - /** * @notice Thrown when there attempting to slash a provision with no tokens to slash. */ @@ -542,6 +545,18 @@ interface IHorizonStakingMain { */ function unstake(uint256 tokens) external; + /** + * @notice Withdraw service provider tokens once the thawing period (initiated by {unstake}) has passed. + * All thawed tokens are withdrawn. + * This function is for backwards compatibility with the legacy staking contract. + * It only allows withdrawing tokens unstaked before horizon upgrade. + * @dev This function can't be removed in case there are still pre-horizon unstakes. + * + * Emits a {HorizonStakeWithdrawn} event. + * + */ + function withdraw() external; + /** * @notice Provision stake to a verifier. The tokens will be locked with a thawing period * and will be slashable by the verifier. This is the main mechanism to provision stake to a data @@ -826,6 +841,7 @@ interface IHorizonStakingMain { * @notice Withdraw undelegated tokens from the subgraph data service provision after thawing. * This function is for backwards compatibility with the legacy staking contract. * It only allows withdrawing tokens undelegated before horizon upgrade. + * @dev This function can't be removed in case there are still pre-horizon undelegations. * @dev See {delegate}. * @param serviceProvider The service provider address * @param deprecated Deprecated parameter kept for backwards compatibility diff --git a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol index 5b084c7a7..18829a024 100644 --- a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol +++ b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol @@ -198,16 +198,6 @@ interface ISubgraphService is IDataServiceFees { */ function resizeAllocation(address indexer, address allocationId, uint256 tokens) external; - /** - * @notice Imports a legacy allocation id into the subgraph service - * This is a governor only action that is required to prevent indexers from re-using allocation ids from the - * legacy staking contract. - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - */ - function migrateLegacyAllocation(address indexer, address allocationId, bytes32 subgraphDeploymentId) external; - /** * @notice Sets a pause guardian * @param pauseGuardian The address of the pause guardian diff --git a/packages/interfaces/contracts/toolshed/internal/IAllocationManager.sol b/packages/interfaces/contracts/toolshed/internal/IAllocationManager.sol index 9e6e8b704..3b6809a63 100644 --- a/packages/interfaces/contracts/toolshed/internal/IAllocationManager.sol +++ b/packages/interfaces/contracts/toolshed/internal/IAllocationManager.sol @@ -44,12 +44,6 @@ interface IAllocationManager { bool forceClosed ); - event LegacyAllocationMigrated( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId - ); - event MaxPOIStalenessSet(uint256 maxPOIStaleness); // Errors From 28f26618e5e069d1627e4762e14bee925079743b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 28 Nov 2025 18:44:25 -0300 Subject: [PATCH 023/157] test: update horizon tests after cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/horizon/test/unit/GraphBase.t.sol | 10 +- .../HorizonStakingShared.t.sol | 703 +----------------- .../unit/staking/allocation/allocation.t.sol | 33 - .../test/unit/staking/allocation/close.t.sol | 116 --- .../unit/staking/allocation/collect.t.sol | 81 -- .../staking/delegation/legacyWithdraw.t.sol | 1 - .../unit/staking/governance/governance.t.sol | 13 - .../unit/staking/provision/provision.t.sol | 16 - .../serviceProvider/serviceProvider.t.sol | 31 - .../test/unit/staking/slash/legacySlash.t.sol | 253 ------- .../test/unit/staking/stake/unstake.t.sol | 73 -- .../test/unit/staking/stake/withdraw.t.sol | 15 - .../test/unit/utilities/GraphDirectory.t.sol | 4 +- .../GraphDirectoryImplementation.sol | 5 - 14 files changed, 19 insertions(+), 1335 deletions(-) delete mode 100644 packages/horizon/test/unit/staking/allocation/allocation.t.sol delete mode 100644 packages/horizon/test/unit/staking/allocation/close.t.sol delete mode 100644 packages/horizon/test/unit/staking/allocation/collect.t.sol delete mode 100644 packages/horizon/test/unit/staking/slash/legacySlash.t.sol diff --git a/packages/horizon/test/unit/GraphBase.t.sol b/packages/horizon/test/unit/GraphBase.t.sol index f3f55b96a..1433cc802 100644 --- a/packages/horizon/test/unit/GraphBase.t.sol +++ b/packages/horizon/test/unit/GraphBase.t.sol @@ -14,7 +14,6 @@ import { GraphPayments } from "contracts/payments/GraphPayments.sol"; import { GraphTallyCollector } from "contracts/payments/collectors/GraphTallyCollector.sol"; import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; import { HorizonStaking } from "contracts/staking/HorizonStaking.sol"; -import { HorizonStakingExtension } from "contracts/staking/HorizonStakingExtension.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { MockGRTToken } from "../../contracts/mocks/MockGRTToken.sol"; import { EpochManagerMock } from "contracts/mocks/EpochManagerMock.sol"; @@ -43,7 +42,6 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { GraphTallyCollector graphTallyCollector; HorizonStaking private stakingBase; - HorizonStakingExtension private stakingExtension; address subgraphDataServiceLegacyAddress = makeAddr("subgraphDataServiceLegacyAddress"); address subgraphDataServiceAddress = makeAddr("subgraphDataServiceAddress"); @@ -86,7 +84,6 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { vm.label({ account: address(payments), newLabel: "GraphPayments" }); 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(graphTallyCollector), newLabel: "GraphTallyCollector" }); // Ensure caller is back to the original msg.sender @@ -194,12 +191,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { escrow = PaymentsEscrow(escrowProxyAddress); } - stakingExtension = new HorizonStakingExtension(address(controller), subgraphDataServiceLegacyAddress); - stakingBase = new HorizonStaking( - address(controller), - address(stakingExtension), - subgraphDataServiceLegacyAddress - ); + stakingBase = new HorizonStaking(address(controller), address(0), subgraphDataServiceLegacyAddress); graphTallyCollector = new GraphTallyCollector( "GraphTallyCollector", diff --git a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol index f89a7fafa..85f0bb755 100644 --- a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol @@ -7,14 +7,12 @@ import { GraphBaseTest } from "../../GraphBase.t.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IHorizonStakingBase } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol"; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol"; import { LinkedList } from "../../../../contracts/libraries/LinkedList.sol"; import { MathUtils } from "../../../../contracts/libraries/MathUtils.sol"; import { PPMMath } from "../../../../contracts/libraries/PPMMath.sol"; -import { ExponentialRebates } from "../../../../contracts/staking/libraries/ExponentialRebates.sol"; abstract contract HorizonStakingSharedTest is GraphBaseTest { using LinkedList for ILinkedList.List; @@ -23,13 +21,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { event Transfer(address indexed from, address indexed to, uint tokens); address internal _allocationId = makeAddr("allocationId"); - bytes32 internal constant _subgraphDeploymentID = keccak256("subgraphDeploymentID"); - uint256 internal constant MAX_ALLOCATION_EPOCHS = 28; - - uint32 internal alphaNumerator = 100; - uint32 internal alphaDenominator = 100; - uint32 internal lambdaNumerator = 60; - uint32 internal lambdaDenominator = 100; /* * MODIFIERS @@ -80,17 +71,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { _createProvision(users.indexer, dataService, tokens, maxVerifierCut, thawingPeriod); } - modifier useAllocation(uint256 tokens) { - vm.assume(tokens <= MAX_STAKING_TOKENS); - _createAllocation(users.indexer, _allocationId, _subgraphDeploymentID, tokens); - _; - } - - modifier useRebateParameters() { - _setStorage_RebateParameters(alphaNumerator, alphaDenominator, lambdaNumerator, lambdaDenominator); - _; - } - /* * HELPERS: these are shortcuts to perform common actions that often involve multiple contract calls */ @@ -105,34 +85,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { _provision(serviceProvider, verifier, tokens, maxVerifierCut, thawingPeriod); } - // This allows setting up contract state with legacy allocations - function _createAllocation( - address serviceProvider, - address allocationId, - bytes32 subgraphDeploymentID, - uint256 tokens - ) internal { - _setStorage_MaxAllocationEpochs(MAX_ALLOCATION_EPOCHS); - - IHorizonStakingExtension.Allocation memory _allocation = IHorizonStakingExtension.Allocation({ - indexer: serviceProvider, - subgraphDeploymentID: subgraphDeploymentID, - tokens: tokens, - createdAtEpoch: block.timestamp, - closedAtEpoch: 0, - collectedFees: 0, - __DEPRECATED_effectiveAllocation: 0, - accRewardsPerAllocatedToken: 0, - distributedRebates: 0 - }); - _setStorage_allocation(_allocation, allocationId, tokens); - - // delegation pool initialized - _setStorage_DelegationPool(serviceProvider, 0, uint32(PPMMath.MAX_PPM), uint32(PPMMath.MAX_PPM)); - - token.transfer(address(staking), tokens); - } - /* * ACTIONS: these are individual contract calls wrapped in assertion blocks to ensure they work as expected */ @@ -152,7 +104,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // stakeTo token.approve(address(staking), tokens); vm.expectEmit(); - emit IHorizonStakingBase.HorizonStakeDeposited(serviceProvider, tokens); + emit IHorizonStakingMain.HorizonStakeDeposited(serviceProvider, tokens); staking.stakeTo(serviceProvider, tokens); // after @@ -185,7 +137,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // stakeTo token.approve(address(staking), tokens); vm.expectEmit(); - emit IHorizonStakingBase.HorizonStakeDeposited(serviceProvider, tokens); + emit IHorizonStakingMain.HorizonStakeDeposited(serviceProvider, tokens); vm.expectEmit(); emit IHorizonStakingMain.ProvisionIncreased(serviceProvider, verifier, tokens); staking.stakeToProvision(serviceProvider, verifier, tokens); @@ -232,48 +184,15 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { function _unstake(uint256 _tokens) internal { (, address msgSender, ) = vm.readCallers(); - uint256 deprecatedThawingPeriod = staking.__DEPRECATED_getThawingPeriod(); - // before uint256 beforeSenderBalance = token.balanceOf(msgSender); uint256 beforeStakingBalance = token.balanceOf(address(staking)); ServiceProviderInternal memory beforeServiceProvider = _getStorage_ServiceProviderInternal(msgSender); - bool withdrawCalled = beforeServiceProvider.__DEPRECATED_tokensLocked != 0 && - block.number >= beforeServiceProvider.__DEPRECATED_tokensLockedUntil; - - if (deprecatedThawingPeriod != 0 && beforeServiceProvider.__DEPRECATED_tokensLocked > 0) { - deprecatedThawingPeriod = MathUtils.weightedAverageRoundingUp( - MathUtils.diffOrZero( - withdrawCalled ? 0 : beforeServiceProvider.__DEPRECATED_tokensLockedUntil, - block.number - ), - withdrawCalled ? 0 : beforeServiceProvider.__DEPRECATED_tokensLocked, - deprecatedThawingPeriod, - _tokens - ); - } - // unstake - if (deprecatedThawingPeriod == 0) { - vm.expectEmit(address(staking)); - emit IHorizonStakingMain.HorizonStakeWithdrawn(msgSender, _tokens); - } else { - if (withdrawCalled) { - vm.expectEmit(address(staking)); - emit IHorizonStakingMain.HorizonStakeWithdrawn( - msgSender, - beforeServiceProvider.__DEPRECATED_tokensLocked - ); - } + vm.expectEmit(address(staking)); + emit IHorizonStakingMain.HorizonStakeWithdrawn(msgSender, _tokens); - vm.expectEmit(address(staking)); - emit IHorizonStakingMain.HorizonStakeLocked( - msgSender, - withdrawCalled ? _tokens : beforeServiceProvider.__DEPRECATED_tokensLocked + _tokens, - block.number + deprecatedThawingPeriod - ); - } staking.unstake(_tokens); // after @@ -282,41 +201,19 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { ServiceProviderInternal memory afterServiceProvider = _getStorage_ServiceProviderInternal(msgSender); // assert - if (deprecatedThawingPeriod == 0) { - assertEq(afterSenderBalance, _tokens + beforeSenderBalance); - assertEq(afterStakingBalance, beforeStakingBalance - _tokens); - assertEq(afterServiceProvider.tokensStaked, beforeServiceProvider.tokensStaked - _tokens); - assertEq(afterServiceProvider.tokensProvisioned, beforeServiceProvider.tokensProvisioned); - assertEq( - afterServiceProvider.__DEPRECATED_tokensAllocated, - beforeServiceProvider.__DEPRECATED_tokensAllocated - ); - assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, beforeServiceProvider.__DEPRECATED_tokensLocked); - assertEq( - afterServiceProvider.__DEPRECATED_tokensLockedUntil, - beforeServiceProvider.__DEPRECATED_tokensLockedUntil - ); - } else { - assertEq( - afterServiceProvider.tokensStaked, - withdrawCalled - ? beforeServiceProvider.tokensStaked - beforeServiceProvider.__DEPRECATED_tokensLocked - : beforeServiceProvider.tokensStaked - ); - assertEq( - afterServiceProvider.__DEPRECATED_tokensLocked, - _tokens + (withdrawCalled ? 0 : beforeServiceProvider.__DEPRECATED_tokensLocked) - ); - assertEq(afterServiceProvider.__DEPRECATED_tokensLockedUntil, block.number + deprecatedThawingPeriod); - assertEq(afterServiceProvider.tokensProvisioned, beforeServiceProvider.tokensProvisioned); - assertEq( - afterServiceProvider.__DEPRECATED_tokensAllocated, - beforeServiceProvider.__DEPRECATED_tokensAllocated - ); - uint256 tokensTransferred = (withdrawCalled ? beforeServiceProvider.__DEPRECATED_tokensLocked : 0); - assertEq(afterSenderBalance, beforeSenderBalance + tokensTransferred); - assertEq(afterStakingBalance, beforeStakingBalance - tokensTransferred); - } + assertEq(afterSenderBalance, _tokens + beforeSenderBalance); + assertEq(afterStakingBalance, beforeStakingBalance - _tokens); + assertEq(afterServiceProvider.tokensStaked, beforeServiceProvider.tokensStaked - _tokens); + assertEq(afterServiceProvider.tokensProvisioned, beforeServiceProvider.tokensProvisioned); + assertEq( + afterServiceProvider.__DEPRECATED_tokensAllocated, + beforeServiceProvider.__DEPRECATED_tokensAllocated + ); + assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq( + afterServiceProvider.__DEPRECATED_tokensLockedUntil, + beforeServiceProvider.__DEPRECATED_tokensLockedUntil + ); } function _withdraw() internal { @@ -1460,19 +1357,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { assertEq(afterEnabled, true); } - function _clearThawingPeriod() internal { - // clearThawingPeriod - vm.expectEmit(address(staking)); - emit IHorizonStakingMain.ThawingPeriodCleared(); - staking.clearThawingPeriod(); - - // after - uint64 afterThawingPeriod = staking.__DEPRECATED_getThawingPeriod(); - - // assert - assertEq(afterThawingPeriod, 0); - } - function _setMaxThawingPeriod(uint64 maxThawingPeriod) internal { // setMaxThawingPeriod vm.expectEmit(address(staking)); @@ -1619,318 +1503,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { } } - // use struct to avoid 'stack too deep' error - struct CalcValues_CloseAllocation { - uint256 rewards; - uint256 delegatorRewards; - uint256 indexerRewards; - } - struct BeforeValues_CloseAllocation { - IHorizonStakingExtension.Allocation allocation; - DelegationPoolInternalTest pool; - ServiceProviderInternal serviceProvider; - uint256 subgraphAllocations; - uint256 stakingBalance; - uint256 indexerBalance; - uint256 beneficiaryBalance; - } - - // Current rewards manager is mocked and assumed to mint fixed rewards - function _closeAllocation(address allocationId, bytes32 poi) internal { - (, address msgSender, ) = vm.readCallers(); - - // before - BeforeValues_CloseAllocation memory beforeValues; - beforeValues.allocation = staking.getAllocation(allocationId); - beforeValues.pool = _getStorage_DelegationPoolInternal( - beforeValues.allocation.indexer, - subgraphDataServiceLegacyAddress, - true - ); - beforeValues.serviceProvider = _getStorage_ServiceProviderInternal(beforeValues.allocation.indexer); - beforeValues.subgraphAllocations = _getStorage_SubgraphAllocations( - beforeValues.allocation.subgraphDeploymentID - ); - beforeValues.stakingBalance = token.balanceOf(address(staking)); - beforeValues.indexerBalance = token.balanceOf(beforeValues.allocation.indexer); - beforeValues.beneficiaryBalance = token.balanceOf( - _getStorage_RewardsDestination(beforeValues.allocation.indexer) - ); - - bool isAuth = staking.isAuthorized( - beforeValues.allocation.indexer, - subgraphDataServiceLegacyAddress, - msgSender - ); - address rewardsDestination = _getStorage_RewardsDestination(beforeValues.allocation.indexer); - - CalcValues_CloseAllocation memory calcValues = CalcValues_CloseAllocation({ - rewards: ALLOCATIONS_REWARD_CUT, - delegatorRewards: ALLOCATIONS_REWARD_CUT - - uint256(beforeValues.pool.__DEPRECATED_indexingRewardCut).mulPPM(ALLOCATIONS_REWARD_CUT), - indexerRewards: 0 - }); - calcValues.indexerRewards = - ALLOCATIONS_REWARD_CUT - (beforeValues.pool.tokens > 0 ? calcValues.delegatorRewards : 0); - - // closeAllocation - vm.expectEmit(address(staking)); - emit IHorizonStakingExtension.AllocationClosed( - beforeValues.allocation.indexer, - beforeValues.allocation.subgraphDeploymentID, - epochManager.currentEpoch(), - beforeValues.allocation.tokens, - allocationId, - msgSender, - poi, - !isAuth - ); - staking.closeAllocation(allocationId, poi); - - // after - IHorizonStakingExtension.Allocation memory afterAllocation = staking.getAllocation(allocationId); - DelegationPoolInternalTest memory afterPool = _getStorage_DelegationPoolInternal( - beforeValues.allocation.indexer, - subgraphDataServiceLegacyAddress, - true - ); - ServiceProviderInternal memory afterServiceProvider = _getStorage_ServiceProviderInternal( - beforeValues.allocation.indexer - ); - uint256 afterSubgraphAllocations = _getStorage_SubgraphAllocations( - beforeValues.allocation.subgraphDeploymentID - ); - uint256 afterStakingBalance = token.balanceOf(address(staking)); - uint256 afterIndexerBalance = token.balanceOf(beforeValues.allocation.indexer); - uint256 afterBeneficiaryBalance = token.balanceOf(rewardsDestination); - - if (beforeValues.allocation.tokens > 0) { - if (isAuth && poi != 0) { - if (rewardsDestination != address(0)) { - assertEq( - beforeValues.stakingBalance + calcValues.rewards - calcValues.indexerRewards, - afterStakingBalance - ); - assertEq(beforeValues.indexerBalance, afterIndexerBalance); - assertEq(beforeValues.beneficiaryBalance + calcValues.indexerRewards, afterBeneficiaryBalance); - } else { - assertEq(beforeValues.stakingBalance + calcValues.rewards, afterStakingBalance); - assertEq(beforeValues.indexerBalance, afterIndexerBalance); - assertEq(beforeValues.beneficiaryBalance, afterBeneficiaryBalance); - } - } else { - assertEq(beforeValues.stakingBalance, afterStakingBalance); - assertEq(beforeValues.indexerBalance, afterIndexerBalance); - assertEq(beforeValues.beneficiaryBalance, afterBeneficiaryBalance); - } - } else { - assertEq(beforeValues.stakingBalance, afterStakingBalance); - assertEq(beforeValues.indexerBalance, afterIndexerBalance); - assertEq(beforeValues.beneficiaryBalance, afterBeneficiaryBalance); - } - - assertEq(afterAllocation.indexer, beforeValues.allocation.indexer); - assertEq(afterAllocation.subgraphDeploymentID, beforeValues.allocation.subgraphDeploymentID); - assertEq(afterAllocation.tokens, beforeValues.allocation.tokens); - assertEq(afterAllocation.createdAtEpoch, beforeValues.allocation.createdAtEpoch); - assertEq(afterAllocation.closedAtEpoch, epochManager.currentEpoch()); - assertEq(afterAllocation.collectedFees, beforeValues.allocation.collectedFees); - assertEq( - afterAllocation.__DEPRECATED_effectiveAllocation, - beforeValues.allocation.__DEPRECATED_effectiveAllocation - ); - assertEq(afterAllocation.accRewardsPerAllocatedToken, beforeValues.allocation.accRewardsPerAllocatedToken); - assertEq(afterAllocation.distributedRebates, beforeValues.allocation.distributedRebates); - - if (beforeValues.allocation.tokens > 0 && isAuth && poi != 0 && rewardsDestination == address(0)) { - assertEq( - afterServiceProvider.tokensStaked, - beforeValues.serviceProvider.tokensStaked + calcValues.indexerRewards - ); - } else { - assertEq(afterServiceProvider.tokensStaked, beforeValues.serviceProvider.tokensStaked); - } - assertEq(afterServiceProvider.tokensProvisioned, beforeValues.serviceProvider.tokensProvisioned); - assertEq( - afterServiceProvider.__DEPRECATED_tokensAllocated + beforeValues.allocation.tokens, - beforeValues.serviceProvider.__DEPRECATED_tokensAllocated - ); - assertEq( - afterServiceProvider.__DEPRECATED_tokensLocked, - beforeValues.serviceProvider.__DEPRECATED_tokensLocked - ); - assertEq( - afterServiceProvider.__DEPRECATED_tokensLockedUntil, - beforeValues.serviceProvider.__DEPRECATED_tokensLockedUntil - ); - - assertEq(afterSubgraphAllocations + beforeValues.allocation.tokens, beforeValues.subgraphAllocations); - - if (beforeValues.allocation.tokens > 0 && isAuth && poi != 0 && beforeValues.pool.tokens > 0) { - assertEq(afterPool.tokens, beforeValues.pool.tokens + calcValues.delegatorRewards); - } else { - assertEq(afterPool.tokens, beforeValues.pool.tokens); - } - } - - // use struct to avoid 'stack too deep' error - struct BeforeValues_Collect { - IHorizonStakingExtension.Allocation allocation; - DelegationPoolInternalTest pool; - ServiceProviderInternal serviceProvider; - uint256 stakingBalance; - uint256 senderBalance; - uint256 curationBalance; - uint256 beneficiaryBalance; - } - struct CalcValues_Collect { - uint256 protocolTaxTokens; - uint256 queryFees; - uint256 curationCutTokens; - uint256 newRebates; - uint256 payment; - uint256 delegationFeeCut; - } - struct AfterValues_Collect { - IHorizonStakingExtension.Allocation allocation; - DelegationPoolInternalTest pool; - ServiceProviderInternal serviceProvider; - uint256 stakingBalance; - uint256 senderBalance; - uint256 curationBalance; - uint256 beneficiaryBalance; - } - - function _collect(uint256 tokens, address allocationId) internal { - (, address msgSender, ) = vm.readCallers(); - - // before - BeforeValues_Collect memory beforeValues; - beforeValues.allocation = staking.getAllocation(allocationId); - beforeValues.pool = _getStorage_DelegationPoolInternal( - beforeValues.allocation.indexer, - subgraphDataServiceLegacyAddress, - true - ); - beforeValues.serviceProvider = _getStorage_ServiceProviderInternal(beforeValues.allocation.indexer); - - (uint32 curationPercentage, uint32 protocolPercentage) = _getStorage_ProtocolTaxAndCuration(); - address rewardsDestination = _getStorage_RewardsDestination(beforeValues.allocation.indexer); - - beforeValues.stakingBalance = token.balanceOf(address(staking)); - beforeValues.senderBalance = token.balanceOf(msgSender); - beforeValues.curationBalance = token.balanceOf(address(curation)); - beforeValues.beneficiaryBalance = token.balanceOf(rewardsDestination); - - // calc some stuff - CalcValues_Collect memory calcValues; - calcValues.protocolTaxTokens = tokens.mulPPMRoundUp(protocolPercentage); - calcValues.queryFees = tokens - calcValues.protocolTaxTokens; - calcValues.curationCutTokens = 0; - if (curation.isCurated(beforeValues.allocation.subgraphDeploymentID)) { - calcValues.curationCutTokens = calcValues.queryFees.mulPPMRoundUp(curationPercentage); - calcValues.queryFees -= calcValues.curationCutTokens; - } - calcValues.newRebates = ExponentialRebates.exponentialRebates( - calcValues.queryFees + beforeValues.allocation.collectedFees, - beforeValues.allocation.tokens, - alphaNumerator, - alphaDenominator, - lambdaNumerator, - lambdaDenominator - ); - calcValues.payment = calcValues.newRebates > calcValues.queryFees - ? calcValues.queryFees - : calcValues.newRebates; - calcValues.delegationFeeCut = 0; - if (beforeValues.pool.tokens > 0) { - calcValues.delegationFeeCut = - calcValues.payment - calcValues.payment.mulPPM(beforeValues.pool.__DEPRECATED_queryFeeCut); - calcValues.payment -= calcValues.delegationFeeCut; - } - - // staking.collect() - if (tokens > 0) { - vm.expectEmit(address(staking)); - emit IHorizonStakingExtension.RebateCollected( - msgSender, - beforeValues.allocation.indexer, - beforeValues.allocation.subgraphDeploymentID, - allocationId, - epochManager.currentEpoch(), - tokens, - calcValues.protocolTaxTokens, - calcValues.curationCutTokens, - calcValues.queryFees, - calcValues.payment, - calcValues.delegationFeeCut - ); - } - staking.collect(tokens, allocationId); - - // after - AfterValues_Collect memory afterValues; - afterValues.allocation = staking.getAllocation(allocationId); - afterValues.pool = _getStorage_DelegationPoolInternal( - beforeValues.allocation.indexer, - subgraphDataServiceLegacyAddress, - true - ); - afterValues.serviceProvider = _getStorage_ServiceProviderInternal(beforeValues.allocation.indexer); - afterValues.stakingBalance = token.balanceOf(address(staking)); - afterValues.senderBalance = token.balanceOf(msgSender); - afterValues.curationBalance = token.balanceOf(address(curation)); - afterValues.beneficiaryBalance = token.balanceOf(rewardsDestination); - - // assert - assertEq(afterValues.senderBalance + tokens, beforeValues.senderBalance); - assertEq(afterValues.curationBalance, beforeValues.curationBalance + calcValues.curationCutTokens); - if (rewardsDestination != address(0)) { - assertEq(afterValues.beneficiaryBalance, beforeValues.beneficiaryBalance + calcValues.payment); - assertEq(afterValues.stakingBalance, beforeValues.stakingBalance + calcValues.delegationFeeCut); - } else { - assertEq(afterValues.beneficiaryBalance, beforeValues.beneficiaryBalance); - assertEq( - afterValues.stakingBalance, - beforeValues.stakingBalance + calcValues.delegationFeeCut + calcValues.payment - ); - } - - assertEq( - afterValues.allocation.collectedFees, - beforeValues.allocation.collectedFees + tokens - calcValues.protocolTaxTokens - calcValues.curationCutTokens - ); - assertEq(afterValues.allocation.indexer, beforeValues.allocation.indexer); - assertEq(afterValues.allocation.subgraphDeploymentID, beforeValues.allocation.subgraphDeploymentID); - assertEq(afterValues.allocation.tokens, beforeValues.allocation.tokens); - assertEq(afterValues.allocation.createdAtEpoch, beforeValues.allocation.createdAtEpoch); - assertEq(afterValues.allocation.closedAtEpoch, beforeValues.allocation.closedAtEpoch); - assertEq( - afterValues.allocation.accRewardsPerAllocatedToken, - beforeValues.allocation.accRewardsPerAllocatedToken - ); - assertEq( - afterValues.allocation.distributedRebates, - beforeValues.allocation.distributedRebates + calcValues.newRebates - ); - - assertEq(afterValues.pool.tokens, beforeValues.pool.tokens + calcValues.delegationFeeCut); - assertEq(afterValues.pool.shares, beforeValues.pool.shares); - assertEq(afterValues.pool.tokensThawing, beforeValues.pool.tokensThawing); - assertEq(afterValues.pool.sharesThawing, beforeValues.pool.sharesThawing); - assertEq(afterValues.pool.thawingNonce, beforeValues.pool.thawingNonce); - - assertEq(afterValues.serviceProvider.tokensProvisioned, beforeValues.serviceProvider.tokensProvisioned); - if (rewardsDestination != address(0)) { - assertEq(afterValues.serviceProvider.tokensStaked, beforeValues.serviceProvider.tokensStaked); - } else { - assertEq( - afterValues.serviceProvider.tokensStaked, - beforeValues.serviceProvider.tokensStaked + calcValues.payment - ); - } - } - /* * STORAGE HELPERS */ @@ -1975,22 +1547,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { return vm.load(address(staking), bytes32(slot)) == bytes32(uint256(1)); } - function _setStorage_DeprecatedThawingPeriod(uint32 _thawingPeriod) internal { - uint256 slot = 13; - - // Read the current value of the slot - uint256 currentSlotValue = uint256(vm.load(address(staking), bytes32(slot))); - - // Create a mask to clear the bits for __DEPRECATED_thawingPeriod (bits 0-31) - uint256 mask = ~(uint256(0xFFFFFFFF)); // Mask to clear the first 32 bits - - // Clear the bits for __DEPRECATED_thawingPeriod and set the new value - uint256 newSlotValue = (currentSlotValue & mask) | uint256(_thawingPeriod); - - // Store the updated value back into the slot - vm.store(address(staking), bytes32(slot), bytes32(newSlotValue)); - } - function _setStorage_ServiceProvider( address _indexer, uint256 _tokensStaked, @@ -2096,59 +1652,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { return delegation; } - function _setStorage_allocation( - IHorizonStakingExtension.Allocation memory allocation, - address allocationId, - uint256 tokens - ) internal { - // __DEPRECATED_allocations - uint256 allocationsSlot = 15; - bytes32 allocationBaseSlot = keccak256(abi.encode(allocationId, allocationsSlot)); - vm.store(address(staking), allocationBaseSlot, bytes32(uint256(uint160(allocation.indexer)))); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 1), allocation.subgraphDeploymentID); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 2), bytes32(tokens)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 3), bytes32(allocation.createdAtEpoch)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 4), bytes32(allocation.closedAtEpoch)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 5), bytes32(allocation.collectedFees)); - vm.store( - address(staking), - bytes32(uint256(allocationBaseSlot) + 6), - bytes32(allocation.__DEPRECATED_effectiveAllocation) - ); - vm.store( - address(staking), - bytes32(uint256(allocationBaseSlot) + 7), - bytes32(allocation.accRewardsPerAllocatedToken) - ); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 8), bytes32(allocation.distributedRebates)); - - // _serviceProviders - uint256 serviceProviderSlot = 14; - bytes32 serviceProviderBaseSlot = keccak256(abi.encode(allocation.indexer, serviceProviderSlot)); - uint256 currentTokensStaked = uint256(vm.load(address(staking), serviceProviderBaseSlot)); - uint256 currentTokensProvisioned = uint256( - vm.load(address(staking), bytes32(uint256(serviceProviderBaseSlot) + 1)) - ); - vm.store( - address(staking), - bytes32(uint256(serviceProviderBaseSlot) + 0), - bytes32(currentTokensStaked + tokens) - ); - vm.store( - address(staking), - bytes32(uint256(serviceProviderBaseSlot) + 1), - bytes32(currentTokensProvisioned + tokens) - ); - - // __DEPRECATED_subgraphAllocations - uint256 subgraphsAllocationsSlot = 16; - bytes32 subgraphAllocationsBaseSlot = keccak256( - abi.encode(allocation.subgraphDeploymentID, subgraphsAllocationsSlot) - ); - uint256 currentAllocatedTokens = uint256(vm.load(address(staking), subgraphAllocationsBaseSlot)); - vm.store(address(staking), subgraphAllocationsBaseSlot, bytes32(currentAllocatedTokens + tokens)); - } - function _getStorage_SubgraphAllocations(bytes32 subgraphDeploymentID) internal view returns (uint256) { uint256 subgraphsAllocationsSlot = 16; bytes32 subgraphAllocationsBaseSlot = keccak256(abi.encode(subgraphDeploymentID, subgraphsAllocationsSlot)); @@ -2167,40 +1670,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { return address(uint160(uint256(vm.load(address(staking), rewardsDestinationSlotBaseSlot)))); } - function _setStorage_MaxAllocationEpochs(uint256 maxAllocationEpochs) internal { - uint256 slot = 13; - - // Read the current value of the storage slot - uint256 currentSlotValue = uint256(vm.load(address(staking), bytes32(slot))); - - // Mask to clear the specific bits for __DEPRECATED_maxAllocationEpochs (bits 128-159) - uint256 mask = ~(uint256(0xFFFFFFFF) << 128); - - // Clear the bits and set the new maxAllocationEpochs value - uint256 newSlotValue = (currentSlotValue & mask) | (uint256(maxAllocationEpochs) << 128); - - // Store the updated value back into the slot - vm.store(address(staking), bytes32(slot), bytes32(newSlotValue)); - - uint256 readMaxAllocationEpochs = _getStorage_MaxAllocationEpochs(); - assertEq(readMaxAllocationEpochs, maxAllocationEpochs); - } - - function _getStorage_MaxAllocationEpochs() internal view returns (uint256) { - uint256 slot = 13; - - // Read the current value of the storage slot - uint256 currentSlotValue = uint256(vm.load(address(staking), bytes32(slot))); - - // Mask to isolate bits 128-159 - uint256 mask = uint256(0xFFFFFFFF) << 128; - - // Extract the maxAllocationEpochs by masking and shifting - uint256 maxAllocationEpochs = (currentSlotValue & mask) >> 128; - - return maxAllocationEpochs; - } - function _setStorage_DelegationPool( address serviceProvider, uint256 tokens, @@ -2216,144 +1685,6 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { vm.store(address(staking), tokensSlot, bytes32(tokens)); } - function _setStorage_RebateParameters( - uint32 alphaNumerator_, - uint32 alphaDenominator_, - uint32 lambdaNumerator_, - uint32 lambdaDenominator_ - ) internal { - // Store alpha numerator and denominator in slot 13 - uint256 alphaSlot = 13; - - uint256 newAlphaSlotValue; - { - uint256 alphaNumeratorOffset = 160; // Offset for __DEPRECATED_alphaNumerator (20th byte) - uint256 alphaDenominatorOffset = 192; // Offset for __DEPRECATED_alphaDenominator (24th byte) - - // Read current value of the slot - uint256 currentAlphaSlotValue = uint256(vm.load(address(staking), bytes32(alphaSlot))); - - // Create a mask to clear the bits for alphaNumerator and alphaDenominator - uint256 alphaMask = ~(uint256(0xFFFFFFFF) << alphaNumeratorOffset) & - ~(uint256(0xFFFFFFFF) << alphaDenominatorOffset); - - // Clear and set new values - newAlphaSlotValue = - (currentAlphaSlotValue & alphaMask) | - (uint256(alphaNumerator_) << alphaNumeratorOffset) | - (uint256(alphaDenominator_) << alphaDenominatorOffset); - } - - // Store the updated value back into the slot - vm.store(address(staking), bytes32(alphaSlot), bytes32(newAlphaSlotValue)); - - // Store lambda numerator and denominator in slot 25 - uint256 lambdaSlot = 25; - - uint256 newLambdaSlotValue; - { - uint256 lambdaNumeratorOffset = 160; // Offset for lambdaNumerator (20th byte) - uint256 lambdaDenominatorOffset = 192; // Offset for lambdaDenominator (24th byte) - - // Read current value of the slot - uint256 currentLambdaSlotValue = uint256(vm.load(address(staking), bytes32(lambdaSlot))); - - // Create a mask to clear the bits for lambdaNumerator and lambdaDenominator - uint256 lambdaMask = ~(uint256(0xFFFFFFFF) << lambdaNumeratorOffset) & - ~(uint256(0xFFFFFFFF) << lambdaDenominatorOffset); - - // Clear and set new values - newLambdaSlotValue = - (currentLambdaSlotValue & lambdaMask) | - (uint256(lambdaNumerator_) << lambdaNumeratorOffset) | - (uint256(lambdaDenominator_) << lambdaDenominatorOffset); - } - - // Store the updated value back into the slot - vm.store(address(staking), bytes32(lambdaSlot), bytes32(newLambdaSlotValue)); - - // Verify the storage - ( - uint32 readAlphaNumerator, - uint32 readAlphaDenominator, - uint32 readLambdaNumerator, - uint32 readLambdaDenominator - ) = _getStorage_RebateParameters(); - assertEq(readAlphaNumerator, alphaNumerator_); - assertEq(readAlphaDenominator, alphaDenominator_); - assertEq(readLambdaNumerator, lambdaNumerator_); - assertEq(readLambdaDenominator, lambdaDenominator_); - } - - function _getStorage_RebateParameters() internal view returns (uint32, uint32, uint32, uint32) { - // Read alpha numerator and denominator - uint256 alphaSlot = 13; - uint256 alphaValues = uint256(vm.load(address(staking), bytes32(alphaSlot))); - uint32 alphaNumerator_ = uint32(alphaValues >> 160); - uint32 alphaDenominator_ = uint32(alphaValues >> 192); - - // Read lambda numerator and denominator - uint256 lambdaSlot = 25; - uint256 lambdaValues = uint256(vm.load(address(staking), bytes32(lambdaSlot))); - uint32 lambdaNumerator_ = uint32(lambdaValues >> 160); - uint32 lambdaDenominator_ = uint32(lambdaValues >> 192); - - return (alphaNumerator_, alphaDenominator_, lambdaNumerator_, lambdaDenominator_); - } - - // function _setStorage_ProtocolTaxAndCuration(uint32 curationPercentage, uint32 taxPercentage) private { - // bytes32 slot = bytes32(uint256(13)); - // uint256 curationOffset = 4; - // uint256 protocolTaxOffset = 8; - // bytes32 originalValue = vm.load(address(staking), slot); - - // bytes32 newProtocolTaxValue = bytes32( - // ((uint256(originalValue) & - // ~((0xFFFFFFFF << (8 * curationOffset)) | (0xFFFFFFFF << (8 * protocolTaxOffset)))) | - // (uint256(curationPercentage) << (8 * curationOffset))) | - // (uint256(taxPercentage) << (8 * protocolTaxOffset)) - // ); - // vm.store(address(staking), slot, newProtocolTaxValue); - - // (uint32 readCurationPercentage, uint32 readTaxPercentage) = _getStorage_ProtocolTaxAndCuration(); - // assertEq(readCurationPercentage, curationPercentage); - // } - - function _setStorage_ProtocolTaxAndCuration(uint32 curationPercentage, uint32 taxPercentage) internal { - bytes32 slot = bytes32(uint256(13)); - - // Offsets for the percentages - uint256 curationOffset = 32; // __DEPRECATED_curationPercentage (2nd uint32, bits 32-63) - uint256 protocolTaxOffset = 64; // __DEPRECATED_protocolPercentage (3rd uint32, bits 64-95) - - // Read the current slot value - uint256 originalValue = uint256(vm.load(address(staking), slot)); - - // Create masks to clear the specific bits for the two percentages - uint256 mask = ~(uint256(0xFFFFFFFF) << curationOffset) & ~(uint256(0xFFFFFFFF) << protocolTaxOffset); // Mask for curationPercentage // Mask for protocolTax - - // Clear the existing bits and set the new values - uint256 newSlotValue = (originalValue & mask) | - (uint256(curationPercentage) << curationOffset) | - (uint256(taxPercentage) << protocolTaxOffset); - - // Store the updated slot value - vm.store(address(staking), slot, bytes32(newSlotValue)); - - // Verify the values were set correctly - (uint32 readCurationPercentage, uint32 readTaxPercentage) = _getStorage_ProtocolTaxAndCuration(); - assertEq(readCurationPercentage, curationPercentage); - assertEq(readTaxPercentage, taxPercentage); - } - - function _getStorage_ProtocolTaxAndCuration() internal view returns (uint32, uint32) { - bytes32 slot = bytes32(uint256(13)); - bytes32 value = vm.load(address(staking), slot); - uint32 curationPercentage = uint32(uint256(value) >> 32); - uint32 taxPercentage = uint32(uint256(value) >> 64); - return (curationPercentage, taxPercentage); - } - /* * MISC: private functions to help with testing */ diff --git a/packages/horizon/test/unit/staking/allocation/allocation.t.sol b/packages/horizon/test/unit/staking/allocation/allocation.t.sol deleted file mode 100644 index 5c9bb179d..000000000 --- a/packages/horizon/test/unit/staking/allocation/allocation.t.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { HorizonStakingTest } from "../HorizonStaking.t.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; - -contract HorizonStakingAllocationTest is HorizonStakingTest { - /* - * TESTS - */ - - function testAllocation_GetAllocationState_Active(uint256 tokens) public useIndexer useAllocation(tokens) { - IHorizonStakingExtension.AllocationState state = staking.getAllocationState(_allocationId); - assertEq(uint16(state), uint16(IHorizonStakingExtension.AllocationState.Active)); - } - - function testAllocation_GetAllocationState_Null() public view { - IHorizonStakingExtension.AllocationState state = staking.getAllocationState(_allocationId); - assertEq(uint16(state), uint16(IHorizonStakingExtension.AllocationState.Null)); - } - - function testAllocation_IsAllocation(uint256 tokens) public useIndexer useAllocation(tokens) { - bool isAllocation = staking.isAllocation(_allocationId); - assertTrue(isAllocation); - } - - function testAllocation_IsNotAllocation() public view { - bool isAllocation = staking.isAllocation(_allocationId); - assertFalse(isAllocation); - } -} diff --git a/packages/horizon/test/unit/staking/allocation/close.t.sol b/packages/horizon/test/unit/staking/allocation/close.t.sol deleted file mode 100644 index cac390099..000000000 --- a/packages/horizon/test/unit/staking/allocation/close.t.sol +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { HorizonStakingTest } from "../HorizonStaking.t.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; -import { PPMMath } from "../../../../contracts/libraries/PPMMath.sol"; - -contract HorizonStakingCloseAllocationTest is HorizonStakingTest { - using PPMMath for uint256; - - bytes32 internal constant _poi = keccak256("poi"); - - /* - * MODIFIERS - */ - - modifier useLegacyOperator() { - resetPrank(users.indexer); - _setOperator(subgraphDataServiceLegacyAddress, users.operator, true); - vm.startPrank(users.operator); - _; - vm.stopPrank(); - } - - /* - * TESTS - */ - - function testCloseAllocation(uint256 tokens) public useIndexer useAllocation(1 ether) { - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - // Skip 15 epochs - vm.roll(15); - - _closeAllocation(_allocationId, _poi); - } - - function testCloseAllocation_Operator(uint256 tokens) public useLegacyOperator useAllocation(1 ether) { - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - // Skip 15 epochs - vm.roll(15); - - _closeAllocation(_allocationId, _poi); - } - - function testCloseAllocation_WithBeneficiaryAddress(uint256 tokens) public useIndexer useAllocation(1 ether) { - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - address beneficiary = makeAddr("beneficiary"); - _setStorage_RewardsDestination(users.indexer, beneficiary); - - // Skip 15 epochs - vm.roll(15); - - _closeAllocation(_allocationId, _poi); - } - - function testCloseAllocation_RevertWhen_NotActive() public { - vm.expectRevert("!active"); - staking.closeAllocation(_allocationId, _poi); - } - - function testCloseAllocation_RevertWhen_NotIndexer() public useIndexer useAllocation(1 ether) { - resetPrank(users.delegator); - vm.expectRevert("!auth"); - staking.closeAllocation(_allocationId, _poi); - } - - function testCloseAllocation_AfterMaxEpochs_AnyoneCanClose( - uint256 tokens - ) public useIndexer useAllocation(1 ether) { - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - // Skip to over the max allocation epochs - vm.roll((MAX_ALLOCATION_EPOCHS + 1) * EPOCH_LENGTH + 1); - - resetPrank(users.delegator); - _closeAllocation(_allocationId, 0x0); - } - - function testCloseAllocation_RevertWhen_ZeroTokensNotAuthorized() public useIndexer useAllocation(1 ether) { - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, 100 ether, 0, 0); - - resetPrank(users.delegator); - vm.expectRevert("!auth"); - staking.closeAllocation(_allocationId, 0x0); - } - - function testCloseAllocation_WithDelegation( - uint256 tokens, - uint256 delegationTokens, - uint32 indexingRewardCut - ) public useIndexer useAllocation(1 ether) { - tokens = bound(tokens, 2, MAX_STAKING_TOKENS); - delegationTokens = bound(delegationTokens, 0, MAX_STAKING_TOKENS); - vm.assume(indexingRewardCut <= MAX_PPM); - - uint256 legacyAllocationTokens = tokens / 2; - uint256 provisionTokens = tokens - legacyAllocationTokens; - - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, provisionTokens, 0, 0); - _setStorage_DelegationPool(users.indexer, delegationTokens, indexingRewardCut, 0); - - // Skip 15 epochs - vm.roll(15); - - _closeAllocation(_allocationId, _poi); - } -} diff --git a/packages/horizon/test/unit/staking/allocation/collect.t.sol b/packages/horizon/test/unit/staking/allocation/collect.t.sol deleted file mode 100644 index 31a5138b2..000000000 --- a/packages/horizon/test/unit/staking/allocation/collect.t.sol +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { HorizonStakingTest } from "../HorizonStaking.t.sol"; -import { ExponentialRebates } from "../../../../contracts/staking/libraries/ExponentialRebates.sol"; -import { PPMMath } from "../../../../contracts/libraries/PPMMath.sol"; - -contract HorizonStakingCollectAllocationTest is HorizonStakingTest { - using PPMMath for uint256; - - /* - * TESTS - */ - - function testCollectAllocation_RevertWhen_InvalidAllocationId( - uint256 tokens - ) public useIndexer useAllocation(1 ether) { - vm.expectRevert("!alloc"); - staking.collect(tokens, address(0)); - } - - function testCollectAllocation_RevertWhen_Null(uint256 tokens) public { - vm.expectRevert("!collect"); - staking.collect(tokens, _allocationId); - } - - function testCollect_Tokens( - uint256 allocationTokens, - uint256 collectTokens, - uint256 curationTokens, - uint32 curationPercentage, - uint32 protocolTaxPercentage, - uint256 delegationTokens, - uint32 queryFeeCut - ) public useIndexer useRebateParameters useAllocation(allocationTokens) { - collectTokens = bound(collectTokens, 0, MAX_STAKING_TOKENS); - curationTokens = bound(curationTokens, 0, MAX_STAKING_TOKENS); - delegationTokens = bound(delegationTokens, 0, MAX_STAKING_TOKENS); - vm.assume(curationPercentage <= MAX_PPM); - vm.assume(protocolTaxPercentage <= MAX_PPM); - vm.assume(queryFeeCut <= MAX_PPM); - - resetPrank(users.indexer); - _setStorage_ProtocolTaxAndCuration(curationPercentage, protocolTaxPercentage); - console.log("queryFeeCut", queryFeeCut); - _setStorage_DelegationPool(users.indexer, delegationTokens, 0, queryFeeCut); - curation.signal(_subgraphDeploymentID, curationTokens); - - resetPrank(users.gateway); - approve(address(staking), collectTokens); - _collect(collectTokens, _allocationId); - } - - function testCollect_WithBeneficiaryAddress( - uint256 allocationTokens, - uint256 collectTokens - ) public useIndexer useRebateParameters useAllocation(allocationTokens) { - collectTokens = bound(collectTokens, 0, MAX_STAKING_TOKENS); - - address beneficiary = makeAddr("beneficiary"); - _setStorage_RewardsDestination(users.indexer, beneficiary); - - resetPrank(users.gateway); - approve(address(staking), collectTokens); - _collect(collectTokens, _allocationId); - - uint256 newRebates = ExponentialRebates.exponentialRebates( - collectTokens, - allocationTokens, - alphaNumerator, - alphaDenominator, - lambdaNumerator, - lambdaDenominator - ); - uint256 payment = newRebates > collectTokens ? collectTokens : newRebates; - - assertEq(token.balanceOf(beneficiary), payment); - } -} diff --git a/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol b/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol index e5ba447e4..400d5a4f1 100644 --- a/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol +++ b/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol @@ -5,7 +5,6 @@ import "forge-std/Test.sol"; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; import { LinkedList } from "../../../../contracts/libraries/LinkedList.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/governance/governance.t.sol b/packages/horizon/test/unit/staking/governance/governance.t.sol index 2fe4a46da..040629b05 100644 --- a/packages/horizon/test/unit/staking/governance/governance.t.sol +++ b/packages/horizon/test/unit/staking/governance/governance.t.sol @@ -39,19 +39,6 @@ contract HorizonStakingGovernanceTest is HorizonStakingTest { staking.setDelegationSlashingEnabled(); } - function testGovernance_ClearThawingPeriod(uint32 thawingPeriod) public useGovernor { - // simulate previous thawing period - _setStorage_DeprecatedThawingPeriod(thawingPeriod); - - _clearThawingPeriod(); - } - - function testGovernance_ClearThawingPeriod_NotGovernor() public useIndexer { - bytes memory expectedError = abi.encodeWithSignature("ManagedOnlyGovernor()"); - vm.expectRevert(expectedError); - staking.clearThawingPeriod(); - } - function testGovernance__SetMaxThawingPeriod(uint64 maxThawingPeriod) public useGovernor { _setMaxThawingPeriod(maxThawingPeriod); } diff --git a/packages/horizon/test/unit/staking/provision/provision.t.sol b/packages/horizon/test/unit/staking/provision/provision.t.sol index c87e13a45..8cfafff5b 100644 --- a/packages/horizon/test/unit/staking/provision/provision.t.sol +++ b/packages/horizon/test/unit/staking/provision/provision.t.sol @@ -96,22 +96,6 @@ contract HorizonStakingProvisionTest is HorizonStakingTest { staking.provision(users.indexer, subgraphDataServiceAddress, amount, maxVerifierCut, thawingPeriod); } - function testProvision_RevertWhen_VerifierIsNotSubgraphDataServiceDuringTransitionPeriod( - uint256 amount - ) public useIndexer useStake(amount) { - // simulate the transition period - _setStorage_DeprecatedThawingPeriod(THAWING_PERIOD_IN_BLOCKS); - - // oddly we use subgraphDataServiceLegacyAddress as the subgraph service address - // so subgraphDataServiceAddress is not the subgraph service ¯\_(ツ)_/¯ - bytes memory expectedError = abi.encodeWithSignature( - "HorizonStakingInvalidVerifier(address)", - subgraphDataServiceAddress - ); - vm.expectRevert(expectedError); - staking.provision(users.indexer, subgraphDataServiceAddress, amount, 0, 0); - } - function testProvision_AddTokensToProvision( uint256 amount, uint32 maxVerifierCut, diff --git a/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol b/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol index 9d6a87fc0..af4449211 100644 --- a/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol +++ b/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol @@ -101,37 +101,6 @@ contract HorizonStakingServiceProviderTest is HorizonStakingTest { assertEq(providerTokensAvailable, amount); } - function testServiceProvider_HasStake( - uint256 amount - ) public useIndexer useProvision(amount, MAX_PPM, MAX_THAWING_PERIOD) { - assertTrue(staking.hasStake(users.indexer)); - - _thaw(users.indexer, subgraphDataServiceAddress, amount); - skip(MAX_THAWING_PERIOD + 1); - _deprovision(users.indexer, subgraphDataServiceAddress, 0); - staking.unstake(amount); - - assertFalse(staking.hasStake(users.indexer)); - } - - function testServiceProvider_GetIndexerStakedTokens( - uint256 amount - ) public useIndexer useProvision(amount, MAX_PPM, MAX_THAWING_PERIOD) { - assertEq(staking.getIndexerStakedTokens(users.indexer), amount); - - _thaw(users.indexer, subgraphDataServiceAddress, amount); - // Does not discount thawing tokens - assertEq(staking.getIndexerStakedTokens(users.indexer), amount); - - skip(MAX_THAWING_PERIOD + 1); - _deprovision(users.indexer, subgraphDataServiceAddress, 0); - // Does not discount thawing tokens - assertEq(staking.getIndexerStakedTokens(users.indexer), amount); - - staking.unstake(amount); - assertEq(staking.getIndexerStakedTokens(users.indexer), 0); - } - function testServiceProvider_RevertIf_InvalidDelegationFeeCut( uint256 cut, uint8 paymentTypeInput diff --git a/packages/horizon/test/unit/staking/slash/legacySlash.t.sol b/packages/horizon/test/unit/staking/slash/legacySlash.t.sol deleted file mode 100644 index 1af4670db..000000000 --- a/packages/horizon/test/unit/staking/slash/legacySlash.t.sol +++ /dev/null @@ -1,253 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; - -import { HorizonStakingTest } from "../HorizonStaking.t.sol"; - -contract HorizonStakingLegacySlashTest is HorizonStakingTest { - /* - * MODIFIERS - */ - - modifier useLegacySlasher(address slasher) { - bytes32 storageKey = keccak256(abi.encode(slasher, 18)); - vm.store(address(staking), storageKey, bytes32(uint256(1))); - _; - } - - /* - * HELPERS - */ - - function _setIndexer( - address _indexer, - uint256 _tokensStaked, - uint256 _tokensAllocated, - uint256 _tokensLocked, - uint256 _tokensLockedUntil - ) public { - bytes32 baseSlot = keccak256(abi.encode(_indexer, 14)); - - vm.store(address(staking), bytes32(uint256(baseSlot)), bytes32(_tokensStaked)); - vm.store(address(staking), bytes32(uint256(baseSlot) + 1), bytes32(_tokensAllocated)); - vm.store(address(staking), bytes32(uint256(baseSlot) + 2), bytes32(_tokensLocked)); - vm.store(address(staking), bytes32(uint256(baseSlot) + 3), bytes32(_tokensLockedUntil)); - } - - /* - * ACTIONS - */ - - function _legacySlash(address _indexer, uint256 _tokens, uint256 _rewards, address _beneficiary) internal { - // before - uint256 beforeStakingBalance = token.balanceOf(address(staking)); - uint256 beforeRewardsDestinationBalance = token.balanceOf(_beneficiary); - ServiceProviderInternal memory beforeIndexer = _getStorage_ServiceProviderInternal(_indexer); - - // calculate slashable stake - uint256 slashableStake = beforeIndexer.tokensStaked - beforeIndexer.tokensProvisioned; - uint256 actualTokens = _tokens; - uint256 actualRewards = _rewards; - if (slashableStake == 0) { - actualTokens = 0; - actualRewards = 0; - } else if (_tokens > slashableStake) { - actualRewards = (_rewards * slashableStake) / _tokens; - actualTokens = slashableStake; - } - - // slash - vm.expectEmit(address(staking)); - emit IHorizonStakingExtension.StakeSlashed(_indexer, actualTokens, actualRewards, _beneficiary); - staking.slash(_indexer, _tokens, _rewards, _beneficiary); - - // after - uint256 afterStakingBalance = token.balanceOf(address(staking)); - uint256 afterRewardsDestinationBalance = token.balanceOf(_beneficiary); - ServiceProviderInternal memory afterIndexer = _getStorage_ServiceProviderInternal(_indexer); - - assertEq(beforeStakingBalance - actualTokens, afterStakingBalance); - assertEq(beforeRewardsDestinationBalance, afterRewardsDestinationBalance - actualRewards); - assertEq(afterIndexer.tokensStaked, beforeIndexer.tokensStaked - actualTokens); - } - - /* - * TESTS - */ - function testSlash_Legacy( - uint256 tokensStaked, - uint256 tokensProvisioned, - uint256 slashTokens, - uint256 reward - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokensStaked > 0); - vm.assume(tokensStaked <= MAX_STAKING_TOKENS); - vm.assume(tokensProvisioned > 0); - vm.assume(tokensProvisioned <= tokensStaked); - slashTokens = bound(slashTokens, 1, tokensStaked); - reward = bound(reward, 0, slashTokens); - - _stake(tokensStaked); - _provision(users.indexer, subgraphDataServiceLegacyAddress, tokensProvisioned, 0, 0); - - resetPrank(users.legacySlasher); - _legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_UsingLockedTokens( - uint256 tokens, - uint256 slashTokens, - uint256 reward - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokens > 1); - slashTokens = bound(slashTokens, 1, tokens); - reward = bound(reward, 0, slashTokens); - - _setIndexer(users.indexer, tokens, 0, tokens, block.timestamp + 1); - // Send tokens manually to staking - token.transfer(address(staking), tokens); - - resetPrank(users.legacySlasher); - _legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_UsingAllocatedTokens( - uint256 tokens, - uint256 slashTokens, - uint256 reward - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokens > 1); - slashTokens = bound(slashTokens, 1, tokens); - reward = bound(reward, 0, slashTokens); - - _setIndexer(users.indexer, tokens, 0, tokens, 0); - // Send tokens manually to staking - token.transfer(address(staking), tokens); - - resetPrank(users.legacySlasher); - staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_RevertWhen_CallerNotSlasher( - uint256 tokens, - uint256 slashTokens, - uint256 reward - ) public useIndexer { - vm.assume(tokens > 0); - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - vm.expectRevert("!slasher"); - staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_RevertWhen_RewardsOverSlashTokens( - uint256 tokens, - uint256 slashTokens, - uint256 reward - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokens > 0); - vm.assume(slashTokens > 0); - vm.assume(reward > slashTokens); - - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - resetPrank(users.legacySlasher); - vm.expectRevert("rewards>slash"); - staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_RevertWhen_NoStake( - uint256 slashTokens, - uint256 reward - ) public useLegacySlasher(users.legacySlasher) { - vm.assume(slashTokens > 0); - reward = bound(reward, 0, slashTokens); - - resetPrank(users.legacySlasher); - vm.expectRevert("!stake"); - staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); - } - - function testSlash_Legacy_RevertWhen_ZeroTokens( - uint256 tokens - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokens > 0); - - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - resetPrank(users.legacySlasher); - vm.expectRevert("!tokens"); - staking.legacySlash(users.indexer, 0, 0, makeAddr("fisherman")); - } - - function testSlash_Legacy_RevertWhen_NoBeneficiary( - uint256 tokens, - uint256 slashTokens, - uint256 reward - ) public useIndexer useLegacySlasher(users.legacySlasher) { - vm.assume(tokens > 0); - slashTokens = bound(slashTokens, 1, tokens); - reward = bound(reward, 0, slashTokens); - - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - - resetPrank(users.legacySlasher); - vm.expectRevert("!beneficiary"); - staking.legacySlash(users.indexer, slashTokens, reward, address(0)); - } - - function test_LegacySlash_WhenTokensAllocatedGreaterThanStake() - public - useIndexer - useLegacySlasher(users.legacySlasher) - { - // Setup indexer with: - // - tokensStaked = 1000 GRT - // - tokensAllocated = 800 GRT - // - tokensLocked = 300 GRT - // This means tokensUsed (1100 GRT) > tokensStaked (1000 GRT) - _setIndexer( - users.indexer, - 1000 ether, // tokensStaked - 800 ether, // tokensAllocated - 300 ether, // tokensLocked - 0 // tokensLockedUntil - ); - - // Send tokens manually to staking - token.transfer(address(staking), 1100 ether); - - resetPrank(users.legacySlasher); - _legacySlash(users.indexer, 1000 ether, 500 ether, makeAddr("fisherman")); - } - - function test_LegacySlash_WhenDelegateCallFails() public useIndexer useLegacySlasher(users.legacySlasher) { - // Setup indexer with: - // - tokensStaked = 1000 GRT - // - tokensAllocated = 800 GRT - // - tokensLocked = 300 GRT - - _setIndexer( - users.indexer, - 1000 ether, // tokensStaked - 800 ether, // tokensAllocated - 300 ether, // tokensLocked - 0 // tokensLockedUntil - ); - - // Send tokens manually to staking - token.transfer(address(staking), 1100 ether); - - // Change staking extension code to an invalid opcode so the delegatecall reverts - address stakingExtension = staking.getStakingExtension(); - vm.etch(stakingExtension, hex"fe"); - - resetPrank(users.legacySlasher); - bytes memory expectedError = abi.encodeWithSignature("HorizonStakingLegacySlashFailed()"); - vm.expectRevert(expectedError); - staking.slash(users.indexer, 1000 ether, 500 ether, makeAddr("fisherman")); - } -} diff --git a/packages/horizon/test/unit/staking/stake/unstake.t.sol b/packages/horizon/test/unit/staking/stake/unstake.t.sol index 83c6a0a81..147edf233 100644 --- a/packages/horizon/test/unit/staking/stake/unstake.t.sol +++ b/packages/horizon/test/unit/staking/stake/unstake.t.sol @@ -26,79 +26,6 @@ contract HorizonStakingUnstakeTest is HorizonStakingTest { _unstake(tokensToUnstake); } - function testUnstake_LockingPeriodGreaterThanZero_NoThawing( - uint256 tokens, - uint256 tokensToUnstake, - uint32 maxVerifierCut, - uint64 thawingPeriod - ) public useIndexer useProvision(tokens, maxVerifierCut, thawingPeriod) { - tokensToUnstake = bound(tokensToUnstake, 1, tokens); - - // simulate transition period - _setStorage_DeprecatedThawingPeriod(THAWING_PERIOD_IN_BLOCKS); - - // thaw, wait and deprovision - _thaw(users.indexer, subgraphDataServiceAddress, tokens); - skip(thawingPeriod + 1); - _deprovision(users.indexer, subgraphDataServiceAddress, 0); - - // unstake - _unstake(tokensToUnstake); - } - - function testUnstake_LockingPeriodGreaterThanZero_TokensDoneThawing( - uint256 tokens, - uint256 tokensToUnstake, - uint256 tokensLocked - ) public useIndexer { - // bounds - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - tokensToUnstake = bound(tokensToUnstake, 1, tokens); - tokensLocked = bound(tokensLocked, 1, MAX_STAKING_TOKENS); - - // simulate locked tokens with past locking period - _setStorage_DeprecatedThawingPeriod(THAWING_PERIOD_IN_BLOCKS); - token.transfer(address(staking), tokensLocked); - _setStorage_ServiceProvider(users.indexer, tokensLocked, 0, tokensLocked, block.number, 0); - - // create provision, thaw and deprovision - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, MAX_THAWING_PERIOD); - _thaw(users.indexer, subgraphDataServiceLegacyAddress, tokens); - skip(MAX_THAWING_PERIOD + 1); - _deprovision(users.indexer, subgraphDataServiceLegacyAddress, 0); - - // unstake - _unstake(tokensToUnstake); - } - - function testUnstake_LockingPeriodGreaterThanZero_TokensStillThawing( - uint256 tokens, - uint256 tokensToUnstake, - uint256 tokensThawing, - uint32 tokensThawingUntilBlock - ) public useIndexer { - // bounds - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - tokensToUnstake = bound(tokensToUnstake, 1, tokens); - tokensThawing = bound(tokensThawing, 1, MAX_STAKING_TOKENS); - vm.assume(tokensThawingUntilBlock > block.number); - vm.assume(tokensThawingUntilBlock < block.number + THAWING_PERIOD_IN_BLOCKS); - - // simulate locked tokens still thawing - _setStorage_DeprecatedThawingPeriod(THAWING_PERIOD_IN_BLOCKS); - token.transfer(address(staking), tokensThawing); - _setStorage_ServiceProvider(users.indexer, tokensThawing, 0, tokensThawing, tokensThawingUntilBlock, 0); - - // create provision, thaw and deprovision - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, MAX_THAWING_PERIOD); - _thaw(users.indexer, subgraphDataServiceLegacyAddress, tokens); - skip(MAX_THAWING_PERIOD + 1); - _deprovision(users.indexer, subgraphDataServiceLegacyAddress, 0); - - // unstake - _unstake(tokensToUnstake); - } - function testUnstake_RevertWhen_ZeroTokens( uint256 amount, uint32 maxVerifierCut, diff --git a/packages/horizon/test/unit/staking/stake/withdraw.t.sol b/packages/horizon/test/unit/staking/stake/withdraw.t.sol index eac19e416..188a3dcee 100644 --- a/packages/horizon/test/unit/staking/stake/withdraw.t.sol +++ b/packages/horizon/test/unit/staking/stake/withdraw.t.sol @@ -37,19 +37,4 @@ contract HorizonStakingWithdrawTest is HorizonStakingTest { vm.expectRevert(abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidZeroTokens.selector)); staking.withdraw(); } - - function testWithdraw_RevertWhen_StillThawing(uint256 tokens, uint256 tokensLocked) public useIndexer { - tokens = bound(tokens, 1, MAX_STAKING_TOKENS); - tokensLocked = bound(tokensLocked, 1, tokens); - - // simulate locked tokens still thawing - uint256 thawUntil = block.timestamp + 1; - token.transfer(address(staking), tokens); - _setStorage_ServiceProvider(users.indexer, tokens, 0, tokensLocked, thawUntil, 0); - - _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, MAX_THAWING_PERIOD); - - vm.expectRevert(abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingStillThawing.selector, thawUntil)); - staking.withdraw(); - } } diff --git a/packages/horizon/test/unit/utilities/GraphDirectory.t.sol b/packages/horizon/test/unit/utilities/GraphDirectory.t.sol index 180590a1e..6399be255 100644 --- a/packages/horizon/test/unit/utilities/GraphDirectory.t.sol +++ b/packages/horizon/test/unit/utilities/GraphDirectory.t.sol @@ -19,8 +19,7 @@ contract GraphDirectoryTest is GraphBaseTest { _getContractFromController("EpochManager"), _getContractFromController("RewardsManager"), _getContractFromController("GraphTokenGateway"), - _getContractFromController("GraphProxyAdmin"), - _getContractFromController("Curation") + _getContractFromController("GraphProxyAdmin") ); _deployImplementation(address(controller)); } @@ -49,7 +48,6 @@ contract GraphDirectoryTest is GraphBaseTest { assertEq(_getContractFromController("RewardsManager"), address(directory.graphRewardsManager())); assertEq(_getContractFromController("GraphTokenGateway"), address(directory.graphTokenGateway())); assertEq(_getContractFromController("GraphProxyAdmin"), address(directory.graphProxyAdmin())); - assertEq(_getContractFromController("Curation"), address(directory.graphCuration())); } function test_RevertWhen_AnInvalidContractGetterIsCalled() external { diff --git a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol index 4a88bf0cd..f10741296 100644 --- a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol +++ b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol @@ -12,7 +12,6 @@ import { IEpochManager } from "@graphprotocol/interfaces/contracts/contracts/epo import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManager.sol"; import { ITokenGateway } from "@graphprotocol/interfaces/contracts/contracts/arbitrum/ITokenGateway.sol"; import { IGraphProxyAdmin } from "@graphprotocol/interfaces/contracts/contracts/upgrades/IGraphProxyAdmin.sol"; -import { ICuration } from "@graphprotocol/interfaces/contracts/contracts/curation/ICuration.sol"; import { GraphDirectory } from "./../../../contracts/utilities/GraphDirectory.sol"; @@ -57,8 +56,4 @@ contract GraphDirectoryImplementation is GraphDirectory { function graphProxyAdmin() external view returns (IGraphProxyAdmin) { return _graphProxyAdmin(); } - - function graphCuration() external view returns (ICuration) { - return _graphCuration(); - } } From 1d2b76d1f217bb306d0f5be3b048b46b4d97ebe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 09:25:14 -0300 Subject: [PATCH 024/157] fix: more cleanup on horizon, interfaces and toolshed packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStaking.sol | 43 +- .../contracts/staking/HorizonStakingBase.sol | 5 + .../ignition/modules/core/HorizonStaking.ts | 33 +- .../test/deployment/HorizonStaking.test.ts | 12 +- .../delegator.test.ts | 143 ----- .../multicall.test.ts | 114 ---- .../during-transition-period/operator.test.ts | 99 ---- .../permissionless.test.ts | 66 --- .../service-provider.test.ts | 521 ------------------ .../during-transition-period/slasher.test.ts | 88 --- packages/horizon/test/unit/GraphBase.t.sol | 2 +- .../horizon/internal/IHorizonStakingBase.sol | 6 + .../src/deployments/horizon/actions.ts | 21 - 13 files changed, 16 insertions(+), 1137 deletions(-) delete mode 100644 packages/horizon/test/integration/during-transition-period/delegator.test.ts delete mode 100644 packages/horizon/test/integration/during-transition-period/multicall.test.ts delete mode 100644 packages/horizon/test/integration/during-transition-period/operator.test.ts delete mode 100644 packages/horizon/test/integration/during-transition-period/permissionless.test.ts delete mode 100644 packages/horizon/test/integration/during-transition-period/service-provider.test.ts delete mode 100644 packages/horizon/test/integration/during-transition-period/slasher.test.ts diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 5384e7698..66aa35b5d 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -38,9 +38,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { /// @dev Maximum number of simultaneous stake thaw requests (per provision) or undelegations (per delegation) uint256 private constant MAX_THAW_REQUESTS = 1_000; - /// @dev Address of the staking extension contract - address private immutable STAKING_EXTENSION_ADDRESS; - /// @dev Minimum amount of delegation. uint256 private constant MIN_DELEGATION = 1e18; @@ -73,50 +70,12 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { /** * @notice The staking contract is upgradeable however we still use the constructor to set a few immutable variables * @param controller The address of the Graph controller contract - * @param stakingExtensionAddress The address of the staking extension contract * @param subgraphDataServiceAddress The address of the subgraph data service */ constructor( address controller, - address stakingExtensionAddress, address subgraphDataServiceAddress - ) HorizonStakingBase(controller, subgraphDataServiceAddress) { - STAKING_EXTENSION_ADDRESS = stakingExtensionAddress; - } - - /** - * @notice Delegates the current call to the StakingExtension implementation. - * @dev This function does not return to its internal call site, it will return directly to the - * external caller. - */ - fallback() external { - // solhint-disable-previous-line payable-fallback, no-complex-fallback - address extensionImpl = STAKING_EXTENSION_ADDRESS; - // solhint-disable-next-line no-inline-assembly - assembly { - // (a) get free memory pointer - let ptr := mload(0x40) - - // (1) copy incoming call data - calldatacopy(ptr, 0, calldatasize()) - - // (2) forward call to logic contract - let result := delegatecall(gas(), extensionImpl, ptr, calldatasize(), 0, 0) - let size := returndatasize() - - // (3) retrieve return data - returndatacopy(ptr, 0, size) - - // (4) forward return data back to caller - switch result - case 0 { - revert(ptr, size) - } - default { - return(ptr, size) - } - } - } + ) HorizonStakingBase(controller, subgraphDataServiceAddress) {} /* * STAKING diff --git a/packages/horizon/contracts/staking/HorizonStakingBase.sol b/packages/horizon/contracts/staking/HorizonStakingBase.sol index 520bd4dd6..75e2cd37c 100644 --- a/packages/horizon/contracts/staking/HorizonStakingBase.sol +++ b/packages/horizon/contracts/staking/HorizonStakingBase.sol @@ -52,6 +52,11 @@ abstract contract HorizonStakingBase is SUBGRAPH_DATA_SERVICE_ADDRESS = subgraphDataServiceAddress; } + /// @inheritdoc IHorizonStakingBase + function getSubgraphService() external view override returns (address) { + return SUBGRAPH_DATA_SERVICE_ADDRESS; + } + /// @inheritdoc IHorizonStakingBase /// @dev Removes deprecated fields from the return value. function getServiceProvider(address serviceProvider) external view override returns (ServiceProvider memory) { diff --git a/packages/horizon/ignition/modules/core/HorizonStaking.ts b/packages/horizon/ignition/modules/core/HorizonStaking.ts index c4044b0af..a7bec9076 100644 --- a/packages/horizon/ignition/modules/core/HorizonStaking.ts +++ b/packages/horizon/ignition/modules/core/HorizonStaking.ts @@ -3,8 +3,6 @@ import GraphProxyAdminArtifact from '@graphprotocol/contracts/artifacts/contract import { buildModule } from '@nomicfoundation/hardhat-ignition/modules' import HorizonStakingArtifact from '../../../build/contracts/contracts/staking/HorizonStaking.sol/HorizonStaking.json' -import HorizonStakingExtensionArtifact from '../../../build/contracts/contracts/staking/HorizonStakingExtension.sol/HorizonStakingExtension.json' -import ExponentialRebatesArtifact from '../../../build/contracts/contracts/staking/libraries/ExponentialRebates.sol/ExponentialRebates.json' import GraphPeripheryModule, { MigratePeripheryModule } from '../periphery/periphery' import { upgradeGraphProxy } from '../proxy/GraphProxy' import { deployImplementation } from '../proxy/implementation' @@ -17,25 +15,11 @@ export default buildModule('HorizonStaking', (m) => { const subgraphServiceAddress = m.getParameter('subgraphServiceAddress') const maxThawingPeriod = m.getParameter('maxThawingPeriod') - // Deploy HorizonStakingExtension - requires periphery and proxies to be registered in the controller - const ExponentialRebates = m.library('ExponentialRebates', ExponentialRebatesArtifact) - const HorizonStakingExtension = m.contract( - 'HorizonStakingExtension', - HorizonStakingExtensionArtifact, - [Controller, subgraphServiceAddress], - { - libraries: { - ExponentialRebates: ExponentialRebates, - }, - after: [GraphPeripheryModule, HorizonProxiesModule], - }, - ) - // Deploy HorizonStaking implementation const HorizonStakingImplementation = deployImplementation(m, { name: 'HorizonStaking', artifact: HorizonStakingArtifact, - constructorArgs: [Controller, HorizonStakingExtension, subgraphServiceAddress], + constructorArgs: [Controller, subgraphServiceAddress], }) // Upgrade proxy to implementation contract @@ -61,24 +45,11 @@ export const MigrateHorizonStakingDeployerModule = buildModule('HorizonStakingDe const HorizonStakingProxy = m.contractAt('HorizonStakingProxy', GraphProxyArtifact, horizonStakingAddress) - // Deploy HorizonStakingExtension - requires periphery and proxies to be registered in the controller - const ExponentialRebates = m.library('ExponentialRebates', ExponentialRebatesArtifact) - const HorizonStakingExtension = m.contract( - 'HorizonStakingExtension', - HorizonStakingExtensionArtifact, - [Controller, subgraphServiceAddress], - { - libraries: { - ExponentialRebates: ExponentialRebates, - }, - }, - ) - // Deploy HorizonStaking implementation const HorizonStakingImplementation = deployImplementation(m, { name: 'HorizonStaking', artifact: HorizonStakingArtifact, - constructorArgs: [Controller, HorizonStakingExtension, subgraphServiceAddress], + constructorArgs: [Controller, subgraphServiceAddress], }) return { HorizonStakingProxy, HorizonStakingImplementation } diff --git a/packages/horizon/test/deployment/HorizonStaking.test.ts b/packages/horizon/test/deployment/HorizonStaking.test.ts index fed2af75f..f60d92b52 100644 --- a/packages/horizon/test/deployment/HorizonStaking.test.ts +++ b/packages/horizon/test/deployment/HorizonStaking.test.ts @@ -1,5 +1,5 @@ import { loadConfig } from '@graphprotocol/toolshed/hardhat' -import { assert, expect } from 'chai' +import { expect } from 'chai' import hre from 'hardhat' import { graphProxyTests } from './lib/GraphProxy.test' @@ -27,16 +27,6 @@ describe('HorizonStaking', function () { expect(delegationSlashingEnabled).to.equal(false) }) - testIf(4)('should set a non zero thawing period', async function () { - if (process.env.IGNITION_DEPLOYMENT_TYPE === 'protocol') { - assert.fail('Deployment type "protocol": no historical state available') - } - const thawingPeriod = await HorizonStaking.__DEPRECATED_getThawingPeriod() - expect(thawingPeriod).to.not.equal(0) - }) - - it.skip('should set the right staking extension address') - testIf(4)('should set the right subgraph data service address', async function () { const subgraphDataServiceAddress = await HorizonStaking.getSubgraphService() expect(subgraphDataServiceAddress).to.equal(config.$global.subgraphServiceAddress) diff --git a/packages/horizon/test/integration/during-transition-period/delegator.test.ts b/packages/horizon/test/integration/during-transition-period/delegator.test.ts deleted file mode 100644 index 352599f18..000000000 --- a/packages/horizon/test/integration/during-transition-period/delegator.test.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { ZERO_ADDRESS } from '@graphprotocol/toolshed' -import { delegators } from '@graphprotocol/toolshed/fixtures' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Delegator', () => { - let snapshotId: string - - const thawingPeriod = 2419200n // 28 days - - // Subgraph service address is not set for integration tests - const subgraphServiceAddress = '0x0000000000000000000000000000000000000000' - - const graph = hre.graph() - const horizonStaking = graph.horizon.contracts.HorizonStaking - const graphToken = graph.horizon.contracts.L2GraphToken - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Existing Protocol Users', () => { - describe('User undelegated before horizon was deployed', () => { - let indexer: HardhatEthersSigner - let delegator: HardhatEthersSigner - let tokens: bigint - - before(async () => { - const delegatorFixture = delegators[2] - const delegationFixture = delegatorFixture.delegations[0] - - // Verify delegator is undelegated - expect(delegatorFixture.undelegate).to.be.true - - // Get signers - indexer = await ethers.getSigner(delegationFixture.indexerAddress) - delegator = await ethers.getSigner(delegatorFixture.address) - - // Get tokens - tokens = delegationFixture.tokens - }) - - it('should be able to withdraw their tokens after the thawing period', async () => { - // Get the thawing period - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Mine remaining blocks to complete thawing period - for (let i = 0; i < Number(thawingPeriod) + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get delegator balance before withdrawing - const balanceBefore = await graphToken.balanceOf(delegator.address) - - // Withdraw tokens - await horizonStaking.connect(delegator)['withdrawDelegated(address,address)'](indexer.address, ZERO_ADDRESS) - - // Get delegator balance after withdrawing - const balanceAfter = await graphToken.balanceOf(delegator.address) - - // Expected balance after is the balance before plus the tokens minus the 0.5% delegation tax - const expectedBalanceAfter = balanceBefore + tokens - (tokens * 5000n) / 1000000n - - // Verify tokens are withdrawn - expect(balanceAfter).to.equal(expectedBalanceAfter) - }) - - it('should revert if the thawing period has not passed', async () => { - // Withdraw tokens - await expect( - horizonStaking.connect(delegator)['withdrawDelegated(address,address)'](indexer.address, ZERO_ADDRESS), - ).to.be.revertedWithCustomError(horizonStaking, 'HorizonStakingNothingToWithdraw') - }) - }) - - describe('Transition period is over', () => { - let governor: HardhatEthersSigner - let indexer: HardhatEthersSigner - let delegator: HardhatEthersSigner - let tokens: bigint - - before(async () => { - const delegatorFixture = delegators[0] - const delegationFixture = delegatorFixture.delegations[0] - - // Get signers - governor = await graph.accounts.getGovernor() - indexer = await ethers.getSigner(delegationFixture.indexerAddress) - delegator = await ethers.getSigner(delegatorFixture.address) - - // Get tokens - tokens = delegationFixture.tokens - }) - - it('should be able to undelegate during transition period and withdraw after transition period', async () => { - // Get delegator's delegation - const delegation = await horizonStaking.getDelegation( - indexer.address, - subgraphServiceAddress, - delegator.address, - ) - - // Undelegate tokens - await horizonStaking - .connect(delegator) - ['undelegate(address,address,uint256)'](indexer.address, subgraphServiceAddress, delegation.shares) - - // Wait for thawing period - await ethers.provider.send('evm_increaseTime', [Number(thawingPeriod) + 1]) - await ethers.provider.send('evm_mine', []) - - // Clear thawing period - await horizonStaking.connect(governor).clearThawingPeriod() - - // Get delegator balance before withdrawing - const balanceBefore = await graphToken.balanceOf(delegator.address) - - // Withdraw tokens - await horizonStaking - .connect(delegator) - ['withdrawDelegated(address,address,uint256)'](indexer.address, ZERO_ADDRESS, BigInt(1)) - - // Get delegator balance after withdrawing - const balanceAfter = await graphToken.balanceOf(delegator.address) - - // Expected balance after is the balance before plus the tokens minus the 0.5% delegation tax - // because the delegation was before the horizon upgrade, after the upgrade there is no tax - const expectedBalanceAfter = balanceBefore + tokens - (tokens * 5000n) / 1000000n - - // Verify tokens are withdrawn - expect(balanceAfter).to.equal(expectedBalanceAfter) - }) - }) - }) -}) diff --git a/packages/horizon/test/integration/during-transition-period/multicall.test.ts b/packages/horizon/test/integration/during-transition-period/multicall.test.ts deleted file mode 100644 index 948cd8f5f..000000000 --- a/packages/horizon/test/integration/during-transition-period/multicall.test.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { ONE_MILLION, PaymentTypes } from '@graphprotocol/toolshed' -import { setGRTBalance } from '@graphprotocol/toolshed/hardhat' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Service Provider', () => { - let snapshotId: string - - const maxVerifierCut = 50_000n - const thawingPeriod = 2419200n - - const graph = hre.graph() - const horizonStaking = graph.horizon.contracts.HorizonStaking - const graphToken = graph.horizon.contracts.L2GraphToken - - const subgraphServiceAddress = '0x0000000000000000000000000000000000000000' - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('New Protocol Users', () => { - let serviceProvider: HardhatEthersSigner - - before(async () => { - ;[, , serviceProvider] = await graph.accounts.getTestAccounts() - await setGRTBalance(graph.provider, graphToken.target, serviceProvider.address, ONE_MILLION) - }) - - it('should allow multicalling stake+provision calls', async () => { - const tokensToStake = ethers.parseEther('1000') - const tokensToProvision = ethers.parseEther('100') - - // check state before - const beforeProvision = await horizonStaking.getProvision(serviceProvider.address, subgraphServiceAddress) - expect(beforeProvision.tokens).to.equal(0) - expect(beforeProvision.maxVerifierCut).to.equal(0) - expect(beforeProvision.thawingPeriod).to.equal(0) - expect(beforeProvision.createdAt).to.equal(0) - - // multicall - await graphToken.connect(serviceProvider).approve(horizonStaking.target, tokensToStake) - const stakeCalldata = horizonStaking.interface.encodeFunctionData('stake', [tokensToStake]) - const provisionCalldata = horizonStaking.interface.encodeFunctionData('provision', [ - serviceProvider.address, - subgraphServiceAddress, - tokensToProvision, - maxVerifierCut, - thawingPeriod, - ]) - await horizonStaking.connect(serviceProvider).multicall([stakeCalldata, provisionCalldata]) - - // check state after - const block = await graph.provider.getBlock('latest') - const afterProvision = await horizonStaking.getProvision(serviceProvider.address, subgraphServiceAddress) - expect(afterProvision.tokens).to.equal(tokensToProvision) - expect(afterProvision.maxVerifierCut).to.equal(maxVerifierCut) - expect(afterProvision.thawingPeriod).to.equal(thawingPeriod) - expect(afterProvision.createdAt).to.equal(block?.timestamp) - }) - - it('should allow multicalling delegation parameter set calls', async () => { - // check state before - const beforeIndexingRewards = await horizonStaking.getDelegationFeeCut( - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.IndexingRewards, - ) - const beforeQueryFee = await horizonStaking.getDelegationFeeCut( - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.QueryFee, - ) - expect(beforeIndexingRewards).to.equal(0) - expect(beforeQueryFee).to.equal(0) - - // multicall - const indexingRewardsCalldata = horizonStaking.interface.encodeFunctionData('setDelegationFeeCut', [ - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.IndexingRewards, - 10_000n, - ]) - const queryFeeCalldata = horizonStaking.interface.encodeFunctionData('setDelegationFeeCut', [ - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.QueryFee, - 12_345n, - ]) - await horizonStaking.connect(serviceProvider).multicall([indexingRewardsCalldata, queryFeeCalldata]) - - // check state after - const afterIndexingRewards = await horizonStaking.getDelegationFeeCut( - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.IndexingRewards, - ) - const afterQueryFee = await horizonStaking.getDelegationFeeCut( - serviceProvider.address, - subgraphServiceAddress, - PaymentTypes.QueryFee, - ) - expect(afterIndexingRewards).to.equal(10_000n) - expect(afterQueryFee).to.equal(12_345n) - }) - }) -}) diff --git a/packages/horizon/test/integration/during-transition-period/operator.test.ts b/packages/horizon/test/integration/during-transition-period/operator.test.ts deleted file mode 100644 index ab5b26ebf..000000000 --- a/packages/horizon/test/integration/during-transition-period/operator.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { generatePOI } from '@graphprotocol/toolshed' -import { indexers } from '@graphprotocol/toolshed/fixtures' -import { getEventData } from '@graphprotocol/toolshed/hardhat' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Operator', () => { - let snapshotId: string - - // Subgraph service address is not set for integration tests - const subgraphServiceAddress = '0x0000000000000000000000000000000000000000' - - const graph = hre.graph() - const horizonStaking = graph.horizon.contracts.HorizonStaking - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Existing Protocol Users', () => { - let indexer: HardhatEthersSigner - let operator: HardhatEthersSigner - let allocationID: string - let allocationTokens: bigint - let delegationIndexingCut: number - - before(async () => { - const indexerFixture = indexers[0] - const allocationFixture = indexerFixture.allocations[0] - - // Get signers - indexer = await ethers.getSigner(indexerFixture.address) - ;[operator] = await graph.accounts.getTestAccounts() - - // Get allocation details - allocationID = allocationFixture.allocationID - allocationTokens = allocationFixture.tokens - delegationIndexingCut = indexerFixture.indexingRewardCut - - // Set the operator - await horizonStaking.connect(indexer).setOperator(subgraphServiceAddress, operator.address, true) - }) - - it('should allow the operator to close an open legacy allocation and collect rewards', async () => { - // Use a non-zero POI - const poi = generatePOI('poi') - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Get delegation pool before closing allocation - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Mine blocks to simulate time passing - const halfThawingPeriod = Number(thawingPeriod) / 2 - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get idle stake before closing allocation - const idleStakeBefore = await horizonStaking.getIdleStake(indexer.address) - - // Close allocation - const tx = await horizonStaking.connect(operator).closeAllocation(allocationID, poi) - const eventData = await getEventData( - tx, - 'event HorizonRewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount)', - ) - const rewards = eventData[2] - - // Verify rewards are not zero - expect(rewards).to.not.equal(0, 'Rewards were not transferred to service provider') - - // Verify rewards minus delegation cut are restaked - const idleStakeAfter = await horizonStaking.getIdleStake(indexer.address) - const idleStakeRewardsTokens = (rewards * BigInt(delegationIndexingCut)) / 1000000n - expect(idleStakeAfter).to.equal( - idleStakeBefore + allocationTokens + idleStakeRewardsTokens, - 'Rewards were not restaked', - ) - - // Verify delegators cut is added to delegation pool - const delegationPool = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPool.tokens - const delegationRewardsTokens = rewards - idleStakeRewardsTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationRewardsTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - }) -}) diff --git a/packages/horizon/test/integration/during-transition-period/permissionless.test.ts b/packages/horizon/test/integration/during-transition-period/permissionless.test.ts deleted file mode 100644 index a7d13e302..000000000 --- a/packages/horizon/test/integration/during-transition-period/permissionless.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { generatePOI } from '@graphprotocol/toolshed' -import { indexers } from '@graphprotocol/toolshed/fixtures' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Permissionless', () => { - let snapshotId: string - - const graph = hre.graph() - const horizonStaking = graph.horizon.contracts.HorizonStaking - const epochManager = graph.horizon.contracts.EpochManager - const subgraphServiceAddress = '0x0000000000000000000000000000000000000000' - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('After max allocation epochs', () => { - let indexer: HardhatEthersSigner - let anySigner: HardhatEthersSigner - let allocationID: string - let allocationTokens: bigint - - before(async () => { - // Get signers - indexer = await ethers.getSigner(indexers[0].address) - ;[anySigner] = await graph.accounts.getTestAccounts() - - // ensure anySigner is not operator for the indexer - await horizonStaking.connect(indexer).setOperator(subgraphServiceAddress, anySigner.address, false) - - // Get allocation details - allocationID = indexers[0].allocations[0].allocationID - allocationTokens = indexers[0].allocations[0].tokens - }) - - it('should allow any user to close an allocation after 28 epochs', async () => { - // Get indexer's idle stake before closing allocation - const idleStakeBefore = await horizonStaking.getIdleStake(indexer.address) - - // Mine blocks to simulate 28 epochs passing - const startingEpoch = await epochManager.currentEpoch() - while ((await epochManager.currentEpoch()) - startingEpoch < 28) { - await ethers.provider.send('evm_mine', []) - } - - // Close allocation - const poi = generatePOI('poi') - await horizonStaking.connect(anySigner).closeAllocation(allocationID, poi) - - // Get indexer's idle stake after closing allocation - const idleStakeAfter = await horizonStaking.getIdleStake(indexer.address) - - // Verify allocation tokens were added to indexer's idle stake but no rewards were collected - expect(idleStakeAfter).to.be.equal(idleStakeBefore + allocationTokens) - }) - }) -}) diff --git a/packages/horizon/test/integration/during-transition-period/service-provider.test.ts b/packages/horizon/test/integration/during-transition-period/service-provider.test.ts deleted file mode 100644 index 0be3c6112..000000000 --- a/packages/horizon/test/integration/during-transition-period/service-provider.test.ts +++ /dev/null @@ -1,521 +0,0 @@ -import { generatePOI, ONE_MILLION } from '@graphprotocol/toolshed' -import { indexers } from '@graphprotocol/toolshed/fixtures' -import { getEventData, setGRTBalance } from '@graphprotocol/toolshed/hardhat' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Service Provider', () => { - let snapshotId: string - - const graph = hre.graph() - const { stake, collect } = graph.horizon.actions - const horizonStaking = graph.horizon.contracts.HorizonStaking - const graphToken = graph.horizon.contracts.L2GraphToken - - // Subgraph service address is not set for integration tests - const subgraphServiceAddress = '0x0000000000000000000000000000000000000000' - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('New Protocol Users', () => { - let serviceProvider: HardhatEthersSigner - let tokensToStake = ethers.parseEther('1000') - - before(async () => { - ;[, , serviceProvider] = await graph.accounts.getTestAccounts() - await setGRTBalance(graph.provider, graphToken.target, serviceProvider.address, ONE_MILLION) - - // Stake tokens to service provider - await stake(serviceProvider, [tokensToStake]) - }) - - it('should allow service provider to unstake and withdraw after thawing period', async () => { - const tokensToUnstake = ethers.parseEther('100') - const balanceBefore = await graphToken.balanceOf(serviceProvider.address) - - // First unstake request - await horizonStaking.connect(serviceProvider).unstake(tokensToUnstake) - - // During transition period, tokens are locked by thawing period - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Mine remaining blocks to complete thawing period - for (let i = 0; i < Number(thawingPeriod) + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Now we can withdraw - await horizonStaking.connect(serviceProvider).withdraw() - const balanceAfter = await graphToken.balanceOf(serviceProvider.address) - - expect(balanceAfter).to.equal( - balanceBefore + tokensToUnstake, - 'Tokens were not transferred back to service provider', - ) - }) - - it('should handle multiple unstake requests correctly', async () => { - // Make multiple unstake requests - const request1 = ethers.parseEther('50') - const request2 = ethers.parseEther('75') - - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // First unstake request - await horizonStaking.connect(serviceProvider).unstake(request1) - - // Mine half of thawing period blocks - const halfThawingPeriod = Number(thawingPeriod) / 2 - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Second unstake request - await horizonStaking.connect(serviceProvider).unstake(request2) - - // Mine remaining blocks to complete first unstake thawing period - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Check that withdraw reverts since thawing period is not complete - await expect(horizonStaking.connect(serviceProvider).withdraw()).to.be.revertedWithCustomError( - horizonStaking, - 'HorizonStakingStillThawing', - ) - - // Mine remaining blocks to complete thawing period - for (let i = 0; i < halfThawingPeriod + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get balance before withdrawing - const balanceBefore = await graphToken.balanceOf(serviceProvider.address) - - // Withdraw all thawed tokens - await horizonStaking.connect(serviceProvider).withdraw() - - // Verify all tokens are withdrawn and transferred back to service provider - const balanceAfter = await graphToken.balanceOf(serviceProvider.address) - expect(balanceAfter).to.equal( - balanceBefore + request1 + request2, - 'Tokens were not transferred back to service provider', - ) - }) - - describe('Transition period is over', () => { - let governor: HardhatEthersSigner - let tokensToUnstake: bigint - - before(async () => { - // Get governor - governor = await graph.accounts.getGovernor() - - // Set tokens - tokensToStake = ethers.parseEther('100000') - tokensToUnstake = ethers.parseEther('10000') - }) - - it('should be able to withdraw tokens that were unstaked during transition period', async () => { - // Stake tokens - await stake(serviceProvider, [tokensToStake]) - - // Unstake tokens - await horizonStaking.connect(serviceProvider).unstake(tokensToUnstake) - - // Get balance before withdrawing - const balanceBefore = await graphToken.balanceOf(serviceProvider.address) - - // Get thawing period - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Clear thawing period - await horizonStaking.connect(governor).clearThawingPeriod() - - // Mine blocks to complete thawing period - for (let i = 0; i < Number(thawingPeriod) + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Withdraw tokens - await horizonStaking.connect(serviceProvider).withdraw() - - // Get balance after withdrawing - const balanceAfter = await graphToken.balanceOf(serviceProvider.address) - expect(balanceAfter).to.equal( - balanceBefore + tokensToUnstake, - 'Tokens were not transferred back to service provider', - ) - }) - - it('should be able to unstake tokens without a thawing period', async () => { - // Stake tokens - await stake(serviceProvider, [tokensToStake]) - - // Clear thawing period - await horizonStaking.connect(governor).clearThawingPeriod() - - // Get balance before withdrawing - const balanceBefore = await graphToken.balanceOf(serviceProvider.address) - - // Unstake tokens - await horizonStaking.connect(serviceProvider).unstake(tokensToUnstake) - - // Get balance after withdrawing - const balanceAfter = await graphToken.balanceOf(serviceProvider.address) - expect(balanceAfter).to.equal( - balanceBefore + tokensToUnstake, - 'Tokens were not transferred back to service provider', - ) - }) - }) - }) - - describe('Existing Protocol Users', () => { - let indexer: HardhatEthersSigner - let tokensUnstaked: bigint - - before(async () => { - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - tokensUnstaked = indexerFixture.tokensToUnstake || 0n - - await setGRTBalance(graph.provider, graphToken.target, indexer.address, ONE_MILLION) - }) - - it('should allow service provider to withdraw their locked tokens after thawing period passes', async () => { - // Get balance before withdrawing - const balanceBefore = await graphToken.balanceOf(indexer.address) - - // Get thawing period - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Mine blocks to complete thawing period - for (let i = 0; i < Number(thawingPeriod) + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Withdraw tokens - await horizonStaking.connect(indexer).withdraw() - - // Verify tokens are transferred back to service provider - const balanceAfter = await graphToken.balanceOf(indexer.address) - expect(balanceAfter).to.equal( - balanceBefore + tokensUnstaked, - 'Tokens were not transferred back to service provider', - ) - }) - - describe('Legacy allocations', () => { - describe('Restaking', () => { - let delegationIndexingCut: number - let delegationQueryFeeCut: number - let allocationID: string - let allocationTokens: bigint - let gateway: HardhatEthersSigner - - beforeEach(async () => { - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - delegationIndexingCut = indexerFixture.indexingRewardCut - delegationQueryFeeCut = indexerFixture.queryFeeCut - allocationID = indexerFixture.allocations[0].allocationID - allocationTokens = indexerFixture.allocations[0].tokens - gateway = await graph.accounts.getGateway() - await setGRTBalance(graph.provider, graphToken.target, gateway.address, ONE_MILLION) - }) - - it('should be able to close an open legacy allocation and collect rewards', async () => { - // Use a non-zero POI - const poi = generatePOI('poi') - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Get delegation pool before closing allocation - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Mine blocks to simulate time passing - const halfThawingPeriod = Number(thawingPeriod) / 2 - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get idle stake before closing allocation - const idleStakeBefore = await horizonStaking.getIdleStake(indexer.address) - - // Close allocation - const tx = await horizonStaking.connect(indexer).closeAllocation(allocationID, poi) - const eventData = await getEventData( - tx, - 'event HorizonRewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount)', - ) - const rewards = eventData[2] - - // Verify rewards are not zero - expect(rewards).to.not.equal(0, 'Rewards were not transferred to service provider') - - // Verify rewards minus delegation cut are restaked - const idleStakeAfter = await horizonStaking.getIdleStake(indexer.address) - const idleStakeRewardsTokens = (rewards * BigInt(delegationIndexingCut)) / 1000000n - expect(idleStakeAfter).to.equal( - idleStakeBefore + allocationTokens + idleStakeRewardsTokens, - 'Rewards were not restaked', - ) - - // Verify delegators cut is added to delegation pool - const delegationPool = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPool.tokens - const delegationRewardsTokens = rewards - idleStakeRewardsTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationRewardsTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - - it('should be able to collect query fees', async () => { - const tokensToCollect = ethers.parseEther('1000') - - // Get idle stake before collecting - const idleStakeBefore = await horizonStaking.getIdleStake(indexer.address) - - // Get delegation pool before collecting - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Collect query fees - await collect(gateway, [tokensToCollect, allocationID]) - - // Get idle stake after collecting - const idleStakeAfter = await horizonStaking.getIdleStake(indexer.address) - - // Subtract protocol tax (1%) and curation fees (10% after the protocol tax deduction) - const protocolTax = (tokensToCollect * 1n) / 100n - const curationFees = (tokensToCollect * 99n) / 1000n - const remainingTokens = tokensToCollect - protocolTax - curationFees - - // Verify tokens minus delegators cut are restaked - const indexerCutTokens = (remainingTokens * BigInt(delegationQueryFeeCut)) / 1000000n - expect(idleStakeAfter).to.equal(idleStakeBefore + indexerCutTokens, 'Indexer cut was not restaked') - - // Verify delegators cut is added to delegation pool - const delegationPool = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPool.tokens - const delegationCutTokens = remainingTokens - indexerCutTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationCutTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - - it('should be able to close an allocation and collect query fees for the closed allocation', async () => { - // Use a non-zero POI - const poi = generatePOI('poi') - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Mine blocks to simulate time passing - const halfThawingPeriod = Number(thawingPeriod) / 2 - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Close allocation - await horizonStaking.connect(indexer).closeAllocation(allocationID, poi) - - // Tokens to collect - const tokensToCollect = ethers.parseEther('1000') - - // Get idle stake before collecting - const idleStakeBefore = await horizonStaking.getIdleStake(indexer.address) - - // Get delegation pool before collecting - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Collect query fees - await collect(gateway, [tokensToCollect, allocationID]) - - // Get idle stake after collecting - const idleStakeAfter = await horizonStaking.getIdleStake(indexer.address) - - // Subtract protocol tax (1%) and curation fees (10% after the protocol tax deduction) - const protocolTax = (tokensToCollect * 1n) / 100n - const curationFees = (tokensToCollect * 99n) / 1000n - const remainingTokens = tokensToCollect - protocolTax - curationFees - - // Verify tokens minus delegators cut are restaked - const indexerCutTokens = (remainingTokens * BigInt(delegationQueryFeeCut)) / 1000000n - expect(idleStakeAfter).to.equal(idleStakeBefore + indexerCutTokens, 'Indexer cut was not restaked') - - // Verify delegators cut is added to delegation pool - const delegationPool = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPool.tokens - const delegationCutTokens = remainingTokens - indexerCutTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationCutTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - }) - - describe('With rewardsDestination set', () => { - let delegationIndexingCut: number - let delegationQueryFeeCut: number - let rewardsDestination: string - let allocationID: string - let gateway: HardhatEthersSigner - - beforeEach(async () => { - const indexerFixture = indexers[1] - indexer = await ethers.getSigner(indexerFixture.address) - delegationIndexingCut = indexerFixture.indexingRewardCut - delegationQueryFeeCut = indexerFixture.queryFeeCut - rewardsDestination = indexerFixture.rewardsDestination! - allocationID = indexerFixture.allocations[0].allocationID - gateway = await graph.accounts.getGateway() - await setGRTBalance(graph.provider, graphToken.target, gateway.address, ONE_MILLION) - }) - - it('should be able to close an open allocation and collect rewards', async () => { - // Use a non-zero POI - const poi = generatePOI('poi') - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Get delegation tokens before - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Mine blocks to simulate time passing - const halfThawingPeriod = Number(thawingPeriod) / 2 - for (let i = 0; i < halfThawingPeriod; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get rewards destination balance before closing allocation - const balanceBefore = await graphToken.balanceOf(rewardsDestination) - - // Close allocation - const tx = await horizonStaking.connect(indexer).closeAllocation(allocationID, poi) - const eventData = await getEventData( - tx, - 'event HorizonRewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount)', - ) - const rewards = eventData[2] - - // Verify rewards are not zero - expect(rewards).to.not.equal(0, 'Rewards were not transferred to rewards destination') - - // Verify indexer rewards cut is transferred to rewards destination - const balanceAfter = await graphToken.balanceOf(rewardsDestination) - const indexerCutTokens = (rewards * BigInt(delegationIndexingCut)) / 1000000n - expect(balanceAfter).to.equal( - balanceBefore + indexerCutTokens, - 'Indexer cut was not transferred to rewards destination', - ) - - // Verify delegators cut is added to delegation pool - const delegationPoolAfter = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPoolAfter.tokens - const delegationCutTokens = rewards - indexerCutTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationCutTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - - it('should be able to collect query fees', async () => { - const tokensToCollect = ethers.parseEther('1000') - - // Get rewards destination balance before collecting - const balanceBefore = await graphToken.balanceOf(rewardsDestination) - - // Get delegation tokens before - const delegationPoolBefore = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensBefore = delegationPoolBefore.tokens - - // Collect query fees - await collect(gateway, [tokensToCollect, allocationID]) - - // Get rewards destination balance after collecting - const balanceAfter = await graphToken.balanceOf(rewardsDestination) - - // Subtract protocol tax (1%) and curation fees (10% after the protocol tax deduction) - const protocolTax = (tokensToCollect * 1n) / 100n - const curationFees = (tokensToCollect * 99n) / 1000n - const remainingTokens = tokensToCollect - protocolTax - curationFees - - // Verify indexer cut is transferred to rewards destination - const indexerCutTokens = (remainingTokens * BigInt(delegationQueryFeeCut)) / 1000000n - expect(balanceAfter).to.equal( - balanceBefore + indexerCutTokens, - 'Indexer cut was not transferred to rewards destination', - ) - - // Verify delegators cut is added to delegation pool - const delegationPoolAfter = await horizonStaking.getDelegationPool(indexer.address, subgraphServiceAddress) - const delegationPoolTokensAfter = delegationPoolAfter.tokens - const delegationCutTokens = remainingTokens - indexerCutTokens - expect(delegationPoolTokensAfter).to.equal( - delegationPoolTokensBefore + delegationCutTokens, - 'Delegators cut was not added to delegation pool', - ) - }) - }) - }) - - describe('Transition period is over', () => { - let governor: HardhatEthersSigner - let tokensToUnstake: bigint - - before(async () => { - // Get governor - governor = await graph.accounts.getGovernor() - - // Get indexer - const indexerFixture = indexers[2] - indexer = await ethers.getSigner(indexerFixture.address) - - // Set tokens - tokensToUnstake = ethers.parseEther('10000') - }) - - it('should be able to withdraw tokens that were unstaked during transition period', async () => { - // Unstake tokens during transition period - await horizonStaking.connect(indexer).unstake(tokensToUnstake) - - // Get thawing period - const thawingPeriod = await horizonStaking.__DEPRECATED_getThawingPeriod() - - // Clear thawing period - await horizonStaking.connect(governor).clearThawingPeriod() - - // Mine blocks to complete thawing period - for (let i = 0; i < Number(thawingPeriod) + 1; i++) { - await ethers.provider.send('evm_mine', []) - } - - // Get balance before withdrawing - const balanceBefore = await graphToken.balanceOf(indexer.address) - - // Withdraw tokens - await horizonStaking.connect(indexer).withdraw() - - // Get balance after withdrawing - const balanceAfter = await graphToken.balanceOf(indexer.address) - expect(balanceAfter).to.equal( - balanceBefore + tokensToUnstake, - 'Tokens were not transferred back to service provider', - ) - }) - }) - }) -}) diff --git a/packages/horizon/test/integration/during-transition-period/slasher.test.ts b/packages/horizon/test/integration/during-transition-period/slasher.test.ts deleted file mode 100644 index 47ced0883..000000000 --- a/packages/horizon/test/integration/during-transition-period/slasher.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { indexers } from '@graphprotocol/toolshed/fixtures' -import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import hre from 'hardhat' -import { ethers } from 'hardhat' - -describe('Slasher', () => { - let snapshotId: string - - let indexer: string - let slasher: HardhatEthersSigner - let tokensToSlash: bigint - - const graph = hre.graph() - const horizonStaking = graph.horizon.contracts.HorizonStaking - const graphToken = graph.horizon.contracts.L2GraphToken - - before(async () => { - slasher = await graph.accounts.getArbitrator() - }) - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Available tokens', () => { - before(() => { - const indexerFixture = indexers[0] - indexer = indexerFixture.address - tokensToSlash = ethers.parseEther('10000') - }) - - it('should be able to slash indexer stake', async () => { - // Before slash state - const idleStakeBeforeSlash = await horizonStaking.getIdleStake(indexer) - const tokensVerifier = tokensToSlash / 2n - const slasherBeforeBalance = await graphToken.balanceOf(slasher.address) - - // Slash tokens - await horizonStaking.connect(slasher).slash(indexer, tokensToSlash, tokensVerifier, slasher.address) - - // Indexer's stake should have decreased - const idleStakeAfterSlash = await horizonStaking.getIdleStake(indexer) - expect(idleStakeAfterSlash).to.equal(idleStakeBeforeSlash - tokensToSlash, 'Indexer stake should have decreased') - - // Slasher should have received the tokens - const slasherAfterBalance = await graphToken.balanceOf(slasher.address) - expect(slasherAfterBalance).to.equal( - slasherBeforeBalance + tokensVerifier, - 'Slasher should have received the tokens', - ) - }) - }) - - describe('Locked tokens', () => { - before(() => { - const indexerFixture = indexers[1] - indexer = indexerFixture.address - tokensToSlash = indexerFixture.stake - }) - - it('should be able to slash locked tokens', async () => { - // Before slash state - const tokensVerifier = tokensToSlash / 2n - const slasherBeforeBalance = await graphToken.balanceOf(slasher.address) - - // Slash tokens - await horizonStaking.connect(slasher).slash(indexer, tokensToSlash, tokensVerifier, slasher.address) - - // Indexer's entire stake should have been slashed - const indexerStakeAfterSlash = await horizonStaking.getServiceProvider(indexer) - expect(indexerStakeAfterSlash.tokensStaked).to.equal(0n, 'Indexer stake should have been slashed') - - // Slasher should have received the tokens - const slasherAfterBalance = await graphToken.balanceOf(slasher.address) - expect(slasherAfterBalance).to.equal( - slasherBeforeBalance + tokensVerifier, - 'Slasher should have received the tokens', - ) - }) - }) -}) diff --git a/packages/horizon/test/unit/GraphBase.t.sol b/packages/horizon/test/unit/GraphBase.t.sol index 1433cc802..9984a2302 100644 --- a/packages/horizon/test/unit/GraphBase.t.sol +++ b/packages/horizon/test/unit/GraphBase.t.sol @@ -191,7 +191,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { escrow = PaymentsEscrow(escrowProxyAddress); } - stakingBase = new HorizonStaking(address(controller), address(0), subgraphDataServiceLegacyAddress); + stakingBase = new HorizonStaking(address(controller), subgraphDataServiceLegacyAddress); graphTallyCollector = new GraphTallyCollector( "GraphTallyCollector", diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol index ccdcc1837..4bc81d44f 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol @@ -25,6 +25,12 @@ interface IHorizonStakingBase { */ error HorizonStakingInvalidThawRequestType(); + /** + * @notice Gets the address of the subgraph data service. + * @return The address of the subgraph data service. + */ + function getSubgraphService() external view returns (address); + /** * @notice Gets the details of a service provider. * @param serviceProvider The address of the service provider. diff --git a/packages/toolshed/src/deployments/horizon/actions.ts b/packages/toolshed/src/deployments/horizon/actions.ts index 8fc9bd4df..144342a82 100644 --- a/packages/toolshed/src/deployments/horizon/actions.ts +++ b/packages/toolshed/src/deployments/horizon/actions.ts @@ -62,15 +62,6 @@ export function loadActions(contracts: GraphHorizonContracts) { */ provision: (signer: HardhatEthersSigner, args: Parameters) => provision(contracts, signer, args), - /** - * [Legacy] Collects query fees from the Horizon staking contract - * Note that it will approve HorizonStaking to spend the tokens - * @param signer - The signer that will execute the collect transaction - * @param args Parameters: - * - `[tokens, allocationID]` - The collect parameters - */ - collect: (signer: HardhatEthersSigner, args: Parameters) => - collect(contracts, signer, args), /** * Delegates tokens in the Horizon staking contract * Note that it will approve HorizonStaking to spend the tokens @@ -157,18 +148,6 @@ async function provision( await HorizonStaking.connect(signer).provision(serviceProvider, verifier, tokens, maxVerifierCut, thawingPeriod) } -async function collect( - contracts: GraphHorizonContracts, - signer: HardhatEthersSigner, - args: Parameters, -) { - const { GraphToken, HorizonStaking } = contracts - const [tokens, allocationID] = args - - await GraphToken.connect(signer).approve(HorizonStaking.target, tokens) - await HorizonStaking.connect(signer).collect(tokens, allocationID) -} - async function delegate( contracts: GraphHorizonContracts, signer: HardhatEthersSigner, From ac103d7fc2f5a9dc623e63a9b663a84b3d37c471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 09:47:00 -0300 Subject: [PATCH 025/157] fix: contracts changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/rewards/RewardsManager.sol | 28 ++++++------------- .../HorizonStakingShared.t.sol | 5 +--- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 767449026..ef2fbfa73 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -21,11 +21,10 @@ import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/r * @title Rewards Manager Contract * @author Edge & Node * @notice Manages rewards distribution for indexers and delegators in the Graph Protocol - * @dev Tracks how inflationary GRT rewards should be handed out. Relies on the Curation contract - * and the Staking contract. Signaled GRT in Curation determine what percentage of the tokens go - * towards each subgraph. Then each Subgraph can have multiple Indexers Staked on it. Thus, the - * total rewards for the Subgraph are split up for each Indexer based on much they have Staked on - * that Subgraph. + * @dev Tracks how inflationary GRT rewards should be handed out. Signaled GRT in Curation determine + * what percentage of the tokens go towards each subgraph. Then each Subgraph can have multiple + * Indexers Staked on it. Thus, the total rewards for the Subgraph are split up for each Indexer based + * on much they have Staked on that Subgraph. * * Note: * The contract provides getter functions to query the state of accrued rewards: @@ -249,11 +248,8 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa subgraph.accRewardsForSubgraphSnapshot ); - // There are two contributors to subgraph allocated tokens: - // - the legacy allocations on the legacy staking contract - // - the new allocations on the subgraph service uint256 subgraphAllocatedTokens = 0; - address[2] memory rewardsIssuers = [address(staking()), address(subgraphService)]; + address[1] memory rewardsIssuers = [address(subgraphService)]; for (uint256 i = 0; i < rewardsIssuers.length; i++) { if (rewardsIssuers[i] != address(0)) { subgraphAllocatedTokens += IRewardsIssuer(rewardsIssuers[i]).getSubgraphAllocatedTokens( @@ -303,7 +299,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa /** * @inheritdoc IRewardsManager - * @dev Hook called from the Staking contract on allocate() and close() + * @dev Hook called from the IRewardsIssuer contract on allocate() and close() */ function onSubgraphAllocationUpdate(bytes32 _subgraphDeploymentID) public override returns (uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; @@ -317,10 +313,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa /// @inheritdoc IRewardsManager function getRewards(address _rewardsIssuer, address _allocationID) external view override returns (uint256) { - require( - _rewardsIssuer == address(staking()) || _rewardsIssuer == address(subgraphService), - "Not a rewards issuer" - ); + require(_rewardsIssuer == address(subgraphService), "Not a rewards issuer"); ( bool isActive, @@ -372,15 +365,12 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa /** * @inheritdoc IRewardsManager * @dev This function can only be called by an authorized rewards issuer which are - * the staking contract (for legacy allocations), and the subgraph service (for new allocations). + * - the subgraph service (for new allocations). * Mints 0 tokens if the allocation is not active. */ function takeRewards(address _allocationID) external override returns (uint256) { address rewardsIssuer = msg.sender; - require( - rewardsIssuer == address(staking()) || rewardsIssuer == address(subgraphService), - "Caller must be a rewards issuer" - ); + require(rewardsIssuer == address(subgraphService), "Caller must be a rewards issuer"); ( bool isActive, diff --git a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol index 85f0bb755..babaaca09 100644 --- a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol @@ -205,10 +205,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { assertEq(afterStakingBalance, beforeStakingBalance - _tokens); assertEq(afterServiceProvider.tokensStaked, beforeServiceProvider.tokensStaked - _tokens); assertEq(afterServiceProvider.tokensProvisioned, beforeServiceProvider.tokensProvisioned); - assertEq( - afterServiceProvider.__DEPRECATED_tokensAllocated, - beforeServiceProvider.__DEPRECATED_tokensAllocated - ); + assertEq(afterServiceProvider.__DEPRECATED_tokensAllocated, beforeServiceProvider.__DEPRECATED_tokensAllocated); assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, beforeServiceProvider.__DEPRECATED_tokensLocked); assertEq( afterServiceProvider.__DEPRECATED_tokensLockedUntil, From c541c8de19574cf7926891de4d6400019c828fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 10:27:08 -0300 Subject: [PATCH 026/157] feat: remove stuff from subgraph service contracts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/horizon/scripts/integration | 6 -- packages/horizon/tasks/test/integration.ts | 11 +-- .../tasks/transitions/thawing-period.ts | 22 ------ .../horizon/internal/IHorizonStakingMain.sol | 3 +- .../internal/ILegacyAllocation.sol | 2 +- .../contracts/DisputeManager.sol | 40 ---------- .../contracts/SubgraphService.sol | 9 --- .../contracts/libraries/LegacyAllocation.sol | 32 +------- .../contracts/utilities/AllocationManager.sol | 27 +------ packages/subgraph-service/scripts/integration | 7 -- .../tasks/test/integration.ts | 11 +-- .../test/unit/SubgraphBaseTest.t.sol | 5 +- .../unit/disputeManager/DisputeManager.t.sol | 75 ------------------- .../unit/disputeManager/disputes/legacy.t.sol | 54 ------------- .../unit/shared/HorizonStakingShared.t.sol | 62 --------------- .../subgraphService/SubgraphService.t.sol | 14 +++- .../subgraphService/allocation/start.t.sol | 4 +- .../subgraphService/governance/legacy.t.sol | 23 ------ 18 files changed, 21 insertions(+), 386 deletions(-) delete mode 100644 packages/horizon/tasks/transitions/thawing-period.ts delete mode 100644 packages/subgraph-service/test/unit/disputeManager/disputes/legacy.t.sol delete mode 100644 packages/subgraph-service/test/unit/subgraphService/governance/legacy.t.sol diff --git a/packages/horizon/scripts/integration b/packages/horizon/scripts/integration index baf48cf5e..c92a85ee8 100755 --- a/packages/horizon/scripts/integration +++ b/packages/horizon/scripts/integration @@ -100,12 +100,6 @@ npx hardhat deploy:migrate --network localhost --horizon-config integration --st # Step 4 - Governor npx hardhat deploy:migrate --network localhost --horizon-config integration --step 4 --patch-config --account-index 1 --hide-banner --standalone -# Run integration tests - During transition period -npx hardhat test:integration --phase during-transition-period --network localhost - -# Clear thawing period -npx hardhat transition:clear-thawing --network localhost - # Run integration tests - After transition period npx hardhat test:integration --phase after-transition-period --network localhost diff --git a/packages/horizon/tasks/test/integration.ts b/packages/horizon/tasks/test/integration.ts index 95b2ea230..bba9fa1c2 100644 --- a/packages/horizon/tasks/test/integration.ts +++ b/packages/horizon/tasks/test/integration.ts @@ -4,13 +4,9 @@ import { TASK_TEST } from 'hardhat/builtin-tasks/task-names' import { task } from 'hardhat/config' task('test:integration', 'Runs all integration tests') - .addParam( - 'phase', - 'Test phase to run: "during-transition-period", "after-transition-period", "after-delegation-slashing-enabled"', - ) + .addParam('phase', 'Test phase to run: "after-transition-period", "after-delegation-slashing-enabled"') .setAction(async (taskArgs, hre) => { // Get test files for each phase - const duringTransitionPeriodFiles = await glob('test/integration/during-transition-period/**/*.{js,ts}') const afterTransitionPeriodFiles = await glob('test/integration/after-transition-period/**/*.{js,ts}') const afterDelegationSlashingEnabledFiles = await glob( 'test/integration/after-delegation-slashing-enabled/**/*.{js,ts}', @@ -20,9 +16,6 @@ task('test:integration', 'Runs all integration tests') printBanner(taskArgs.phase, 'INTEGRATION TESTS: ') switch (taskArgs.phase) { - case 'during-transition-period': - await hre.run(TASK_TEST, { testFiles: duringTransitionPeriodFiles }) - break case 'after-transition-period': await hre.run(TASK_TEST, { testFiles: afterTransitionPeriodFiles }) break @@ -31,7 +24,7 @@ task('test:integration', 'Runs all integration tests') break default: throw new Error( - 'Invalid phase. Must be "during-transition-period", "after-transition-period", "after-delegation-slashing-enabled", or "all"', + 'Invalid phase. Must be "after-transition-period", "after-delegation-slashing-enabled", or "all"', ) } }) diff --git a/packages/horizon/tasks/transitions/thawing-period.ts b/packages/horizon/tasks/transitions/thawing-period.ts deleted file mode 100644 index e21e2bad2..000000000 --- a/packages/horizon/tasks/transitions/thawing-period.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { requireLocalNetwork } from '@graphprotocol/toolshed/hardhat' -import { printBanner } from '@graphprotocol/toolshed/utils' -import { task, types } from 'hardhat/config' - -task('transition:clear-thawing', 'Clears the thawing period in HorizonStaking') - .addOptionalParam('governorIndex', 'Derivation path index for the governor account', 1, types.int) - .addFlag('skipNetworkCheck', 'Skip the network check (use with caution)') - .setAction(async (taskArgs, hre) => { - printBanner('CLEARING THAWING PERIOD') - - if (!taskArgs.skipNetworkCheck) { - requireLocalNetwork(hre) - } - - const graph = hre.graph() - const governor = await graph.accounts.getGovernor(taskArgs.governorIndex) - const horizonStaking = graph.horizon.contracts.HorizonStaking - - console.log('Clearing thawing period...') - await horizonStaking.connect(governor).clearThawingPeriod() - console.log('Thawing period cleared') - }) diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index f4f9499ae..11f7f575f 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -536,8 +536,7 @@ interface IHorizonStakingMain { * Stake is immediately removed from the protocol. * @dev Requirements: * - `_tokens` cannot be zero. - * - `_serviceProvider` must have enough idle stake to cover the staking amount and any - * legacy allocation. + * - `_serviceProvider` must have enough idle stake to cover the staking amount. * * Emits a {HorizonStakeWithdrawn} event. * diff --git a/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol b/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol index c5bf7f8c7..c0497fe3b 100644 --- a/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol +++ b/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol @@ -23,7 +23,7 @@ interface ILegacyAllocation { } /** - * @notice Thrown when attempting to migrate an allocation with an existing id + * @notice Thrown when attempting to create an allocation with an existing legacy id * @param allocationId The allocation id */ error LegacyAllocationAlreadyExists(address allocationId); diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 6f73b2c5d..660f19251 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -204,46 +204,6 @@ contract DisputeManager is return (dId1, dId2); } - /// @inheritdoc IDisputeManager - function createAndAcceptLegacyDispute( - address allocationId, - address fisherman, - uint256 tokensSlash, - uint256 tokensRewards - ) external override onlyArbitrator returns (bytes32) { - // Create a disputeId - bytes32 disputeId = keccak256(abi.encodePacked(allocationId, "legacy")); - - // Get the indexer for the legacy allocation - address indexer = _graphStaking().getAllocation(allocationId).indexer; - require(indexer != address(0), DisputeManagerIndexerNotFound(allocationId)); - - // Store dispute - disputes[disputeId] = Dispute( - indexer, - fisherman, - 0, - 0, - DisputeType.LegacyDispute, - IDisputeManager.DisputeStatus.Accepted, - block.timestamp, - block.timestamp + disputePeriod, - 0 - ); - - // Slash the indexer - ISubgraphService subgraphService_ = _getSubgraphService(); - subgraphService_.slash(indexer, abi.encode(tokensSlash, tokensRewards)); - - // Reward the fisherman - _graphToken().pushTokens(fisherman, tokensRewards); - - emit LegacyDisputeCreated(disputeId, indexer, fisherman, allocationId, tokensSlash, tokensRewards); - emit DisputeAccepted(disputeId, indexer, fisherman, tokensRewards); - - return disputeId; - } - /// @inheritdoc IDisputeManager function acceptDispute( bytes32 disputeId, diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 0ba0b3035..23f1d5a61 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -327,15 +327,6 @@ contract SubgraphService is _resizeAllocation(allocationId, tokens, _delegationRatio); } - /// @inheritdoc ISubgraphService - function migrateLegacyAllocation( - address indexer, - address allocationId, - bytes32 subgraphDeploymentID - ) external override onlyOwner { - _migrateLegacyAllocation(indexer, allocationId, subgraphDeploymentID); - } - /// @inheritdoc ISubgraphService function setPauseGuardian(address pauseGuardian, bool allowed) external override onlyOwner { _setPauseGuardian(pauseGuardian, allowed); diff --git a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol index 4717cefed..af7fc66db 100644 --- a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol +++ b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.27; -import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol"; /** @@ -14,27 +13,6 @@ import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph- library LegacyAllocation { using LegacyAllocation for ILegacyAllocation.State; - /** - * @notice Migrate a legacy allocation - * @dev Requirements: - * - The allocation must not have been previously migrated - * @param self The legacy allocation list mapping - * @param indexer The indexer that owns the allocation - * @param allocationId The allocation id - * @param subgraphDeploymentId The subgraph deployment id the allocation is for - * @custom:error LegacyAllocationAlreadyMigrated if the allocation has already been migrated - */ - function migrate( - mapping(address => ILegacyAllocation.State) storage self, - address indexer, - address allocationId, - bytes32 subgraphDeploymentId - ) internal { - require(!self[allocationId].exists(), ILegacyAllocation.LegacyAllocationAlreadyExists(allocationId)); - - self[allocationId] = ILegacyAllocation.State({ indexer: indexer, subgraphDeploymentId: subgraphDeploymentId }); - } - /** * @notice Get a legacy allocation * @param self The legacy allocation list mapping @@ -50,23 +28,15 @@ library LegacyAllocation { /** * @notice Revert if a legacy allocation exists - * @dev We first check the migrated mapping then the old staking contract. - * @dev TRANSITION PERIOD: after the transition period when all the allocations are migrated we can - * remove the call to the staking contract. + * @dev We check the migrated allocations mapping. * @param self The legacy allocation list mapping - * @param graphStaking The Horizon Staking contract * @param allocationId The allocation id */ function revertIfExists( mapping(address => ILegacyAllocation.State) storage self, - IHorizonStaking graphStaking, address allocationId ) internal view { require(!self[allocationId].exists(), ILegacyAllocation.LegacyAllocationAlreadyExists(allocationId)); - require( - !graphStaking.isAllocation(allocationId), - ILegacyAllocation.LegacyAllocationAlreadyExists(allocationId) - ); } /** diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index 08608d8b4..4c642561c 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -116,18 +116,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca bool forceClosed ); - /** - * @notice Emitted when a legacy allocation is migrated into the subgraph service - * @param indexer The address of the indexer - * @param allocationId The id of the allocation - * @param subgraphDeploymentId The id of the subgraph deployment - */ - event LegacyAllocationMigrated( - address indexed indexer, - address indexed allocationId, - bytes32 indexed subgraphDeploymentId - ); - /** * @notice Emitted when the maximum POI staleness is updated * @param maxPOIStaleness The max POI staleness in seconds @@ -175,19 +163,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca */ function __AllocationManager_init_unchained() internal onlyInitializing {} - /** - * @notice Imports a legacy allocation id into the subgraph service - * This is a governor only action that is required to prevent indexers from re-using allocation ids from the - * legacy staking contract. It will revert with LegacyAllocationAlreadyMigrated if the allocation has already been migrated. - * @param _indexer The address of the indexer - * @param _allocationId The id of the allocation - * @param _subgraphDeploymentId The id of the subgraph deployment - */ - function _migrateLegacyAllocation(address _indexer, address _allocationId, bytes32 _subgraphDeploymentId) internal { - _legacyAllocations.migrate(_indexer, _allocationId, _subgraphDeploymentId); - emit LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentId); - } - /** * @notice Create an allocation * @dev The `_allocationProof` is a 65-bytes Ethereum signed message of `keccak256(indexerAddress,allocationId)` @@ -218,7 +193,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca // Ensure allocation id is not reused // need to check both subgraph service (on allocations.create()) and legacy allocations - _legacyAllocations.revertIfExists(_graphStaking(), _allocationId); + _legacyAllocations.revertIfExists(_allocationId); uint256 currentEpoch = _graphEpochManager().currentEpoch(); IAllocation.State memory allocation = _allocations.create( diff --git a/packages/subgraph-service/scripts/integration b/packages/subgraph-service/scripts/integration index d5d7f1c0d..58a7ba4fe 100755 --- a/packages/subgraph-service/scripts/integration +++ b/packages/subgraph-service/scripts/integration @@ -124,13 +124,6 @@ npx hardhat deploy:migrate --network localhost --horizon-config integration --st cd ../subgraph-service npx hardhat test:seed --network localhost -# Run integration tests - During transition period -npx hardhat test:integration --phase during-transition-period --network localhost - -# Clear thawing period -cd ../horizon -npx hardhat transition:clear-thawing --network localhost --governor-index 1 - # Run integration tests - After transition period cd ../subgraph-service npx hardhat test:integration --phase after-transition-period --network localhost diff --git a/packages/subgraph-service/tasks/test/integration.ts b/packages/subgraph-service/tasks/test/integration.ts index 130058e90..ef63c42f4 100644 --- a/packages/subgraph-service/tasks/test/integration.ts +++ b/packages/subgraph-service/tasks/test/integration.ts @@ -4,13 +4,9 @@ import { TASK_TEST } from 'hardhat/builtin-tasks/task-names' import { task } from 'hardhat/config' task('test:integration', 'Runs all integration tests') - .addParam( - 'phase', - 'Test phase to run: "during-transition-period", "after-transition-period", "after-delegation-slashing-enabled"', - ) + .addParam('phase', 'Test phase to run: "after-transition-period", "after-delegation-slashing-enabled"') .setAction(async (taskArgs, hre) => { // Get test files for each phase - const duringTransitionPeriodFiles = await glob('test/integration/during-transition-period/**/*.{js,ts}') const afterTransitionPeriodFiles = await glob('test/integration/after-transition-period/**/*.{js,ts}') // Display banner for the current test phase @@ -18,15 +14,12 @@ task('test:integration', 'Runs all integration tests') // Run tests for the current phase switch (taskArgs.phase) { - case 'during-transition-period': - await hre.run(TASK_TEST, { testFiles: duringTransitionPeriodFiles }) - break case 'after-transition-period': await hre.run(TASK_TEST, { testFiles: afterTransitionPeriodFiles }) break default: throw new Error( - 'Invalid phase. Must be "during-transition-period", "after-transition-period", "after-delegation-slashing-enabled", or "all"', + 'Invalid phase. Must be "after-transition-period", "after-delegation-slashing-enabled", or "all"', ) } }) diff --git a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol index 0997d1aeb..574f120cb 100644 --- a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol @@ -8,7 +8,6 @@ import { GraphPayments } from "@graphprotocol/horizon/contracts/payments/GraphPa import { GraphProxy } from "@graphprotocol/contracts/contracts/upgrades/GraphProxy.sol"; import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol"; import { HorizonStaking } from "@graphprotocol/horizon/contracts/staking/HorizonStaking.sol"; -import { HorizonStakingExtension } from "@graphprotocol/horizon/contracts/staking/HorizonStakingExtension.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; @@ -45,7 +44,6 @@ abstract contract SubgraphBaseTest is Utils, Constants { GraphTallyCollector graphTallyCollector; HorizonStaking private stakingBase; - HorizonStakingExtension private stakingExtension; MockCuration curation; MockGRTToken token; @@ -174,8 +172,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { ); subgraphService = SubgraphService(subgraphServiceProxy); - stakingExtension = new HorizonStakingExtension(address(controller), address(subgraphService)); - stakingBase = new HorizonStaking(address(controller), address(stakingExtension), address(subgraphService)); + stakingBase = new HorizonStaking(address(controller), address(subgraphService)); graphPayments = new GraphPayments{ salt: saltGraphPayments }(address(controller), protocolPaymentCut); escrow = new PaymentsEscrow{ salt: saltEscrow }(address(controller), withdrawEscrowThawingPeriod); diff --git a/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol b/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol index e6115057e..d49d2b6a7 100644 --- a/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol +++ b/packages/subgraph-service/test/unit/disputeManager/DisputeManager.t.sol @@ -205,81 +205,6 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { return _disputeID; } - struct Balances { - uint256 indexer; - uint256 fisherman; - uint256 arbitrator; - uint256 disputeManager; - uint256 staking; - } - - function _createAndAcceptLegacyDispute( - address _allocationId, - address _fisherman, - uint256 _tokensSlash, - uint256 _tokensRewards - ) internal returns (bytes32) { - (, address arbitrator, ) = vm.readCallers(); - address indexer = staking.getAllocation(_allocationId).indexer; - - Balances memory beforeBalances = Balances({ - indexer: token.balanceOf(indexer), - fisherman: token.balanceOf(_fisherman), - arbitrator: token.balanceOf(arbitrator), - disputeManager: token.balanceOf(address(disputeManager)), - staking: token.balanceOf(address(staking)) - }); - - vm.expectEmit(address(disputeManager)); - emit IDisputeManager.LegacyDisputeCreated( - keccak256(abi.encodePacked(_allocationId, "legacy")), - indexer, - _fisherman, - _allocationId, - _tokensSlash, - _tokensRewards - ); - vm.expectEmit(address(disputeManager)); - emit IDisputeManager.DisputeAccepted( - keccak256(abi.encodePacked(_allocationId, "legacy")), - indexer, - _fisherman, - _tokensRewards - ); - bytes32 _disputeId = disputeManager.createAndAcceptLegacyDispute( - _allocationId, - _fisherman, - _tokensSlash, - _tokensRewards - ); - - Balances memory afterBalances = Balances({ - indexer: token.balanceOf(indexer), - fisherman: token.balanceOf(_fisherman), - arbitrator: token.balanceOf(arbitrator), - disputeManager: token.balanceOf(address(disputeManager)), - staking: token.balanceOf(address(staking)) - }); - - assertEq(afterBalances.indexer, beforeBalances.indexer); - assertEq(afterBalances.fisherman, beforeBalances.fisherman + _tokensRewards); - assertEq(afterBalances.arbitrator, beforeBalances.arbitrator); - assertEq(afterBalances.disputeManager, beforeBalances.disputeManager); - assertEq(afterBalances.staking, beforeBalances.staking - _tokensSlash); - - IDisputeManager.Dispute memory dispute = _getDispute(_disputeId); - assertEq(dispute.indexer, indexer); - assertEq(dispute.fisherman, _fisherman); - assertEq(dispute.deposit, 0); - assertEq(dispute.relatedDisputeId, bytes32(0)); - assertEq(uint8(dispute.disputeType), uint8(IDisputeManager.DisputeType.LegacyDispute)); - assertEq(uint8(dispute.status), uint8(IDisputeManager.DisputeStatus.Accepted)); - assertEq(dispute.createdAt, block.timestamp); - assertEq(dispute.stakeSnapshot, 0); - - return _disputeId; - } - struct BeforeValues_CreateQueryDisputeConflict { IAttestation.State attestation1; IAttestation.State attestation2; diff --git a/packages/subgraph-service/test/unit/disputeManager/disputes/legacy.t.sol b/packages/subgraph-service/test/unit/disputeManager/disputes/legacy.t.sol deleted file mode 100644 index 3bab2eaa6..000000000 --- a/packages/subgraph-service/test/unit/disputeManager/disputes/legacy.t.sol +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { Attestation } from "../../../../contracts/libraries/Attestation.sol"; -import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; -import { IDisputeManager } from "@graphprotocol/interfaces/contracts/subgraph-service/IDisputeManager.sol"; -import { DisputeManagerTest } from "../DisputeManager.t.sol"; - -contract DisputeManagerLegacyDisputeTest is DisputeManagerTest { - using PPMMath for uint256; - - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); - bytes32 private responseCID = keccak256(abi.encodePacked("Response CID")); - bytes32 private subgraphDeploymentId = keccak256(abi.encodePacked("Subgraph Deployment ID")); - - /* - * TESTS - */ - - function test_LegacyDispute( - uint256 tokensStaked, - uint256 tokensProvisioned, - uint256 tokensSlash, - uint256 tokensRewards - ) public { - vm.assume(tokensStaked <= MAX_TOKENS); - vm.assume(tokensStaked >= minimumProvisionTokens); - tokensProvisioned = bound(tokensProvisioned, minimumProvisionTokens, tokensStaked); - tokensSlash = bound(tokensSlash, 2, tokensProvisioned); - tokensRewards = bound(tokensRewards, 1, tokensSlash.mulPPM(fishermanRewardPercentage)); - - // setup indexer state - resetPrank(users.indexer); - _stake(tokensStaked); - _setStorage_allocation_hardcoded(users.indexer, allocationID, tokensStaked - tokensProvisioned); - _provision(users.indexer, tokensProvisioned, fishermanRewardPercentage, disputePeriod); - - resetPrank(users.arbitrator); - _createAndAcceptLegacyDispute(allocationID, users.fisherman, tokensSlash, tokensRewards); - } - - function test_LegacyDispute_RevertIf_NotArbitrator() public useIndexer { - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotArbitrator.selector)); - disputeManager.createAndAcceptLegacyDispute(allocationID, users.fisherman, 0, 0); - } - - function test_LegacyDispute_RevertIf_AllocationNotFound() public useIndexer { - resetPrank(users.arbitrator); - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerIndexerNotFound.selector, address(0))); - disputeManager.createAndAcceptLegacyDispute(address(0), users.fisherman, 0, 0); - } -} diff --git a/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol b/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol index 290644bea..66b67a408 100644 --- a/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol +++ b/packages/subgraph-service/test/unit/shared/HorizonStakingShared.t.sol @@ -5,7 +5,6 @@ import "forge-std/Test.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; -import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; import { SubgraphBaseTest } from "../SubgraphBaseTest.t.sol"; @@ -77,67 +76,6 @@ abstract contract HorizonStakingSharedTest is SubgraphBaseTest { staking.setProvisionParameters(_indexer, _verifier, _maxVerifierCut, _thawingPeriod); } - function _setStorage_allocation_hardcoded(address indexer, address allocationId, uint256 tokens) internal { - IHorizonStakingExtension.Allocation memory allocation = IHorizonStakingExtension.Allocation({ - indexer: indexer, - subgraphDeploymentID: bytes32("0x12344321"), - tokens: tokens, - createdAtEpoch: 1234, - closedAtEpoch: 1235, - collectedFees: 1234, - __DEPRECATED_effectiveAllocation: 1222234, - accRewardsPerAllocatedToken: 1233334, - distributedRebates: 1244434 - }); - - // __DEPRECATED_allocations - uint256 allocationsSlot = 15; - bytes32 allocationBaseSlot = keccak256(abi.encode(allocationId, allocationsSlot)); - vm.store(address(staking), allocationBaseSlot, bytes32(uint256(uint160(allocation.indexer)))); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 1), allocation.subgraphDeploymentID); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 2), bytes32(tokens)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 3), bytes32(allocation.createdAtEpoch)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 4), bytes32(allocation.closedAtEpoch)); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 5), bytes32(allocation.collectedFees)); - vm.store( - address(staking), - bytes32(uint256(allocationBaseSlot) + 6), - bytes32(allocation.__DEPRECATED_effectiveAllocation) - ); - vm.store( - address(staking), - bytes32(uint256(allocationBaseSlot) + 7), - bytes32(allocation.accRewardsPerAllocatedToken) - ); - vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 8), bytes32(allocation.distributedRebates)); - - // _serviceProviders - uint256 serviceProviderSlot = 14; - bytes32 serviceProviderBaseSlot = keccak256(abi.encode(allocation.indexer, serviceProviderSlot)); - uint256 currentTokensStaked = uint256(vm.load(address(staking), serviceProviderBaseSlot)); - uint256 currentTokensProvisioned = uint256( - vm.load(address(staking), bytes32(uint256(serviceProviderBaseSlot) + 1)) - ); - vm.store( - address(staking), - bytes32(uint256(serviceProviderBaseSlot) + 0), - bytes32(currentTokensStaked + tokens) - ); - vm.store( - address(staking), - bytes32(uint256(serviceProviderBaseSlot) + 1), - bytes32(currentTokensProvisioned + tokens) - ); - - // __DEPRECATED_subgraphAllocations - uint256 subgraphsAllocationsSlot = 16; - bytes32 subgraphAllocationsBaseSlot = keccak256( - abi.encode(allocation.subgraphDeploymentID, subgraphsAllocationsSlot) - ); - uint256 currentAllocatedTokens = uint256(vm.load(address(staking), subgraphAllocationsBaseSlot)); - vm.store(address(staking), subgraphAllocationsBaseSlot, bytes32(currentAllocatedTokens + tokens)); - } - function _stakeTo(address _indexer, uint256 _tokens) internal { token.approve(address(staking), _tokens); staking.stakeTo(_indexer, _tokens); diff --git a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol index 74c677504..2fac2595a 100644 --- a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol @@ -383,7 +383,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { CollectPaymentData memory collectPaymentDataBefore, CollectPaymentData memory collectPaymentDataAfter ) private view { - (IGraphTallyCollector.SignedRAV memory signedRav, uint256 tokensToCollect) = abi.decode( + (IGraphTallyCollector.SignedRAV memory signedRav, ) = abi.decode( _data, (IGraphTallyCollector.SignedRAV, uint256) ); @@ -487,10 +487,16 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } function _migrateLegacyAllocation(address _indexer, address _allocationId, bytes32 _subgraphDeploymentID) internal { - vm.expectEmit(address(subgraphService)); - emit AllocationManager.LegacyAllocationMigrated(_indexer, _allocationId, _subgraphDeploymentID); + // migrate fn was removed, we simulate history by manually setting the storage state + uint256 legacyAllocationsSlot = 208; + bytes32 legacyAllocationBaseSlot = keccak256(abi.encode(_allocationId, legacyAllocationsSlot)); - subgraphService.migrateLegacyAllocation(_indexer, _allocationId, _subgraphDeploymentID); + vm.store(address(subgraphService), legacyAllocationBaseSlot, bytes32(uint256(uint160(_indexer)))); + vm.store( + address(subgraphService), + bytes32(uint256(legacyAllocationBaseSlot) + 1), + bytes32(_subgraphDeploymentID) + ); ILegacyAllocation.State memory afterLegacyAllocation = subgraphService.getLegacyAllocation(_allocationId); assertEq(afterLegacyAllocation.indexer, _indexer); diff --git a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol index 4a251f506..c44f5364a 100644 --- a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol @@ -170,8 +170,8 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _createProvision(users.indexer, tokens, fishermanRewardPercentage, disputePeriod); _register(users.indexer, abi.encode("url", "geoHash", address(0))); - // create dummy allo in staking contract - _setStorage_allocation_hardcoded(users.indexer, allocationID, tokens); + // simulate legacy allocation migration + _migrateLegacyAllocation(users.indexer, allocationID, subgraphDeployment); bytes memory data = _generateData(tokens); vm.expectRevert(abi.encodeWithSelector(ILegacyAllocation.LegacyAllocationAlreadyExists.selector, allocationID)); diff --git a/packages/subgraph-service/test/unit/subgraphService/governance/legacy.t.sol b/packages/subgraph-service/test/unit/subgraphService/governance/legacy.t.sol deleted file mode 100644 index d1b5dd124..000000000 --- a/packages/subgraph-service/test/unit/subgraphService/governance/legacy.t.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; - -import { SubgraphServiceTest } from "../SubgraphService.t.sol"; - -contract SubgraphServiceLegacyAllocation is SubgraphServiceTest { - /* - * TESTS - */ - - function test_MigrateAllocation() public useGovernor { - _migrateLegacyAllocation(users.indexer, allocationID, subgraphDeployment); - } - - function test_MigrateAllocation_WhenNotGovernor() public useIndexer { - vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.indexer)); - subgraphService.migrateLegacyAllocation(users.indexer, allocationID, subgraphDeployment); - } -} From abcafaa5d723f4df9c1aa0cad3106cb13e74733a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 10:41:09 -0300 Subject: [PATCH 027/157] chore: remove dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/horizon/test/unit/GraphBase.t.sol | 3 +- packages/horizon/test/unit/utils/Users.sol | 1 - .../internal/ILegacyAllocation.sol | 6 ---- .../contracts/libraries/LegacyAllocation.sol | 28 ------------------- 4 files changed, 1 insertion(+), 37 deletions(-) diff --git a/packages/horizon/test/unit/GraphBase.t.sol b/packages/horizon/test/unit/GraphBase.t.sol index 9984a2302..efd1533d8 100644 --- a/packages/horizon/test/unit/GraphBase.t.sol +++ b/packages/horizon/test/unit/GraphBase.t.sol @@ -69,8 +69,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { operator: createUser("operator"), gateway: createUser("gateway"), verifier: createUser("verifier"), - delegator: createUser("delegator"), - legacySlasher: createUser("legacySlasher") + delegator: createUser("delegator") }); // Deploy protocol contracts diff --git a/packages/horizon/test/unit/utils/Users.sol b/packages/horizon/test/unit/utils/Users.sol index 6213e4e82..c47395a14 100644 --- a/packages/horizon/test/unit/utils/Users.sol +++ b/packages/horizon/test/unit/utils/Users.sol @@ -9,5 +9,4 @@ struct Users { address gateway; address verifier; address delegator; - address legacySlasher; } diff --git a/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol b/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol index c0497fe3b..b6422fad8 100644 --- a/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol +++ b/packages/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol @@ -27,10 +27,4 @@ interface ILegacyAllocation { * @param allocationId The allocation id */ error LegacyAllocationAlreadyExists(address allocationId); - - /** - * @notice Thrown when trying to get a non-existent allocation - * @param allocationId The allocation id - */ - error LegacyAllocationDoesNotExist(address allocationId); } diff --git a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol index af7fc66db..ed9003433 100644 --- a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol +++ b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol @@ -13,19 +13,6 @@ import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph- library LegacyAllocation { using LegacyAllocation for ILegacyAllocation.State; - /** - * @notice Get a legacy allocation - * @param self The legacy allocation list mapping - * @param allocationId The allocation id - * @return The legacy allocation details - */ - function get( - mapping(address => ILegacyAllocation.State) storage self, - address allocationId - ) internal view returns (ILegacyAllocation.State memory) { - return _get(self, allocationId); - } - /** * @notice Revert if a legacy allocation exists * @dev We check the migrated allocations mapping. @@ -47,19 +34,4 @@ library LegacyAllocation { function exists(ILegacyAllocation.State memory self) internal pure returns (bool) { return self.indexer != address(0); } - - /** - * @notice Get a legacy allocation - * @param self The legacy allocation list mapping - * @param allocationId The allocation id - * @return The legacy allocation details - */ - function _get( - mapping(address => ILegacyAllocation.State) storage self, - address allocationId - ) private view returns (ILegacyAllocation.State storage) { - ILegacyAllocation.State storage allocation = self[allocationId]; - require(allocation.exists(), ILegacyAllocation.LegacyAllocationDoesNotExist(allocationId)); - return allocation; - } } From a2abc90cfa0a2dbdc6358c3775cd5f3a48e5d3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 14:12:44 -0300 Subject: [PATCH 028/157] test(contract): hack outdated test suite to pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/contracts/rewards/RewardsManager.sol | 10 +++------- .../contracts/test/tests/unit/disputes/poi.test.ts | 8 +++++++- .../contracts/test/tests/unit/disputes/query.test.ts | 8 +++++++- .../contracts/test/tests/unit/l2/l2Staking.test.ts | 8 +++++++- .../contracts/test/tests/unit/rewards/rewards.test.ts | 4 ++++ .../test/tests/unit/staking/allocation.test.ts | 4 ++++ .../test/tests/unit/staking/delegation.test.ts | 8 +++++++- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index ef2fbfa73..c66c3b7bc 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -249,13 +249,9 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa ); uint256 subgraphAllocatedTokens = 0; - address[1] memory rewardsIssuers = [address(subgraphService)]; - for (uint256 i = 0; i < rewardsIssuers.length; i++) { - if (rewardsIssuers[i] != address(0)) { - subgraphAllocatedTokens += IRewardsIssuer(rewardsIssuers[i]).getSubgraphAllocatedTokens( - _subgraphDeploymentID - ); - } + address rewardsIssuer = address(subgraphService); + if (rewardsIssuer != address(0)) { + subgraphAllocatedTokens += IRewardsIssuer(rewardsIssuer).getSubgraphAllocatedTokens(_subgraphDeploymentID); } if (subgraphAllocatedTokens == 0) { diff --git a/packages/contracts/test/tests/unit/disputes/poi.test.ts b/packages/contracts/test/tests/unit/disputes/poi.test.ts index b465f5986..b391dd0d4 100644 --- a/packages/contracts/test/tests/unit/disputes/poi.test.ts +++ b/packages/contracts/test/tests/unit/disputes/poi.test.ts @@ -1,4 +1,4 @@ -import { DisputeManager } from '@graphprotocol/contracts' +import { DisputeManager, IRewardsManager } from '@graphprotocol/contracts' import { EpochManager } from '@graphprotocol/contracts' import { GraphToken } from '@graphprotocol/contracts' import { IStaking } from '@graphprotocol/contracts' @@ -30,6 +30,7 @@ describe('DisputeManager:POI', () => { let epochManager: EpochManager let grt: GraphToken let staking: IStaking + let rewardsManager: IRewardsManager // Derive some channel keys for each indexer used to sign attestations const indexerChannelKey = deriveChannelKey() @@ -92,10 +93,15 @@ describe('DisputeManager:POI', () => { epochManager = contracts.EpochManager as EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking + rewardsManager = contracts.RewardsManager as IRewardsManager // Give some funds to the fisherman await grt.connect(governor).mint(fisherman.address, fishermanTokens) await grt.connect(fisherman).approve(disputeManager.address, fishermanTokens) + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { diff --git a/packages/contracts/test/tests/unit/disputes/query.test.ts b/packages/contracts/test/tests/unit/disputes/query.test.ts index 73238b4e0..e411bd028 100644 --- a/packages/contracts/test/tests/unit/disputes/query.test.ts +++ b/packages/contracts/test/tests/unit/disputes/query.test.ts @@ -1,5 +1,5 @@ import { createAttestation, Receipt } from '@graphprotocol/common-ts' -import { DisputeManager } from '@graphprotocol/contracts' +import { DisputeManager, IRewardsManager } from '@graphprotocol/contracts' import { EpochManager } from '@graphprotocol/contracts' import { GraphToken } from '@graphprotocol/contracts' import { IStaking } from '@graphprotocol/contracts' @@ -35,6 +35,7 @@ describe('DisputeManager:Query', () => { let epochManager: EpochManager let grt: GraphToken let staking: IStaking + let rewardsManager: IRewardsManager // Derive some channel keys for each indexer used to sign attestations const indexer1ChannelKey = deriveChannelKey() @@ -121,6 +122,7 @@ describe('DisputeManager:Query', () => { epochManager = contracts.EpochManager as EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking + rewardsManager = contracts.RewardsManager as IRewardsManager // Give some funds to the fisherman for (const dst of [fisherman, fisherman2]) { @@ -139,6 +141,10 @@ describe('DisputeManager:Query', () => { indexerAddress: indexer.address, receipt, } + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { diff --git a/packages/contracts/test/tests/unit/l2/l2Staking.test.ts b/packages/contracts/test/tests/unit/l2/l2Staking.test.ts index 39dc75e7a..cf22eaba0 100644 --- a/packages/contracts/test/tests/unit/l2/l2Staking.test.ts +++ b/packages/contracts/test/tests/unit/l2/l2Staking.test.ts @@ -1,4 +1,4 @@ -import { IL2Staking } from '@graphprotocol/contracts' +import { IL2Staking, IRewardsManager } from '@graphprotocol/contracts' import { L2GraphTokenGateway } from '@graphprotocol/contracts' import { GraphToken } from '@graphprotocol/contracts' import { EpochManager, L1GNS, L1GraphTokenGateway, L1Staking } from '@graphprotocol/contracts' @@ -35,6 +35,7 @@ describe('L2Staking', () => { let l2GraphTokenGateway: L2GraphTokenGateway let staking: IL2Staking let grt: GraphToken + let rewardsManager: IRewardsManager const tokens10k = toGRT('10000') const tokens100k = toGRT('100000') @@ -88,6 +89,7 @@ describe('L2Staking', () => { l1StakingMock = l1MockContracts.L1Staking as L1Staking l1GNSMock = l1MockContracts.L1GNS as L1GNS l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway as L1GraphTokenGateway + rewardsManager = fixtureContracts.RewardsManager as IRewardsManager // Deploy L2 arbitrum bridge await fixture.loadL2ArbitrumBridge(governor) @@ -99,6 +101,10 @@ describe('L2Staking', () => { await grt.connect(me).approve(staking.address, tokens1m) await grt.connect(governor).mint(other.address, tokens1m) await grt.connect(other).approve(staking.address, tokens1m) + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { diff --git a/packages/contracts/test/tests/unit/rewards/rewards.test.ts b/packages/contracts/test/tests/unit/rewards/rewards.test.ts index e6171cc13..fbf0912eb 100644 --- a/packages/contracts/test/tests/unit/rewards/rewards.test.ts +++ b/packages/contracts/test/tests/unit/rewards/rewards.test.ts @@ -151,6 +151,10 @@ describe('Rewards', () => { await grt.connect(wallet).approve(staking.address, toGRT('1000000')) await grt.connect(wallet).approve(curation.address, toGRT('1000000')) } + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { diff --git a/packages/contracts/test/tests/unit/staking/allocation.test.ts b/packages/contracts/test/tests/unit/staking/allocation.test.ts index dd28aa73d..76de77a35 100644 --- a/packages/contracts/test/tests/unit/staking/allocation.test.ts +++ b/packages/contracts/test/tests/unit/staking/allocation.test.ts @@ -379,6 +379,10 @@ describe('Staking:Allocation', () => { // Give some funds to the delegator and approve staking contract to use funds on delegator behalf await grt.connect(governor).mint(delegator.address, tokensToDelegate) await grt.connect(delegator).approve(staking.address, tokensToDelegate) + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { diff --git a/packages/contracts/test/tests/unit/staking/delegation.test.ts b/packages/contracts/test/tests/unit/staking/delegation.test.ts index 71f911006..3542e817e 100644 --- a/packages/contracts/test/tests/unit/staking/delegation.test.ts +++ b/packages/contracts/test/tests/unit/staking/delegation.test.ts @@ -1,4 +1,4 @@ -import { EpochManager } from '@graphprotocol/contracts' +import { EpochManager, IRewardsManager } from '@graphprotocol/contracts' import { GraphToken } from '@graphprotocol/contracts' import { IStaking } from '@graphprotocol/contracts' import { deriveChannelKey, GraphNetworkContracts, helpers, randomHexBytes, toBN, toGRT } from '@graphprotocol/sdk' @@ -29,6 +29,7 @@ describe('Staking::Delegation', () => { let epochManager: EpochManager let grt: GraphToken let staking: IStaking + let rewardsManager: IRewardsManager // Test values const poi = randomHexBytes() @@ -159,6 +160,7 @@ describe('Staking::Delegation', () => { epochManager = contracts.EpochManager as EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking + rewardsManager = contracts.RewardsManager as IRewardsManager // Distribute test funds for (const wallet of [delegator, delegator2]) { @@ -173,6 +175,10 @@ describe('Staking::Delegation', () => { } await grt.connect(governor).mint(assetHolder.address, tokensToCollect) await grt.connect(assetHolder).approve(staking.address, tokensToCollect) + + // HACK: we set the staking contract as the subgraph service to make tests pass. + // This is due to the test suite being outdated. + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { From bee3e79ff892a8f38fd2abf4b50d760abf0ea975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 1 Dec 2025 14:41:41 -0300 Subject: [PATCH 029/157] test: fix vm.assume too many rejections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/horizon/test/unit/escrow/getters.t.sol | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/horizon/test/unit/escrow/getters.t.sol b/packages/horizon/test/unit/escrow/getters.t.sol index 262192125..84f5661ac 100644 --- a/packages/horizon/test/unit/escrow/getters.t.sol +++ b/packages/horizon/test/unit/escrow/getters.t.sol @@ -35,11 +35,10 @@ contract GraphEscrowGettersTest is GraphEscrowTest { uint256 amountThawing, uint256 amountCollected ) public useGateway useDeposit(amountDeposit) { - vm.assume(amountThawing > 0); - vm.assume(amountDeposit > 0); - vm.assume(amountDeposit >= amountThawing); - vm.assume(amountDeposit >= amountCollected); - vm.assume(amountDeposit - amountCollected < amountThawing); + // amountCollected must be >= 1 for valid range, and <= amountDeposit + amountCollected = bound(amountCollected, 1, amountDeposit); + // amountThawing must be in (amountDeposit - amountCollected, amountDeposit] + amountThawing = bound(amountThawing, amountDeposit - amountCollected + 1, amountDeposit); // thaw some funds _thawEscrow(users.verifier, users.indexer, amountThawing); From a5bbbf80d4822907b7356cf069f25bd000250e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 2 Dec 2025 13:20:03 -0300 Subject: [PATCH 030/157] chore: address review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/rewards/RewardsManager.sol | 2 +- .../contracts/staking/HorizonStaking.sol | 3 +- .../dispute-manager.test.ts | 157 ----------- .../governance.test.ts | 76 ------ .../during-transition-period/indexer.test.ts | 100 ------- .../legacy-dispute-manager.test.ts | 256 ------------------ 6 files changed, 2 insertions(+), 592 deletions(-) delete mode 100644 packages/subgraph-service/test/integration/during-transition-period/dispute-manager.test.ts delete mode 100644 packages/subgraph-service/test/integration/during-transition-period/governance.test.ts delete mode 100644 packages/subgraph-service/test/integration/during-transition-period/indexer.test.ts delete mode 100644 packages/subgraph-service/test/integration/during-transition-period/legacy-dispute-manager.test.ts diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index c66c3b7bc..5e1908064 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -361,7 +361,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa /** * @inheritdoc IRewardsManager * @dev This function can only be called by an authorized rewards issuer which are - * - the subgraph service (for new allocations). + * - the subgraph service (for allocations). * Mints 0 tokens if the allocation is not active. */ function takeRewards(address _allocationID) external override returns (uint256) { diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 66aa35b5d..fbafbfc67 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -545,9 +545,8 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { require(_tokens <= tokensIdle, HorizonStakingInsufficientIdleStake(_tokens, tokensIdle)); ServiceProviderInternal storage sp = _serviceProviders[serviceProvider]; - uint256 stakedTokens = sp.tokensStaked; + sp.tokensStaked -= _tokens; - sp.tokensStaked = stakedTokens - _tokens; _graphToken().pushTokens(serviceProvider, _tokens); emit HorizonStakeWithdrawn(serviceProvider, _tokens); } diff --git a/packages/subgraph-service/test/integration/during-transition-period/dispute-manager.test.ts b/packages/subgraph-service/test/integration/during-transition-period/dispute-manager.test.ts deleted file mode 100644 index a24f9703a..000000000 --- a/packages/subgraph-service/test/integration/during-transition-period/dispute-manager.test.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { - DisputeManager, - HorizonStaking, - L2GraphToken, - LegacyDisputeManager, - SubgraphService, -} from '@graphprotocol/interfaces' -import { generateLegacyIndexingDisputeId, generateLegacyTypeDisputeId } from '@graphprotocol/toolshed' -import { indexersData as indexers } from '@graphprotocol/toolshed/fixtures' -import { setGRTBalance } from '@graphprotocol/toolshed/hardhat' -import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import { ethers } from 'hardhat' -import hre from 'hardhat' - -describe('Dispute Manager', () => { - let disputeManager: DisputeManager - let legacyDisputeManager: LegacyDisputeManager - let graphToken: L2GraphToken - let staking: HorizonStaking - let subgraphService: SubgraphService - - let snapshotId: string - - // Test addresses - let governor: HardhatEthersSigner - let fisherman: HardhatEthersSigner - let arbitrator: HardhatEthersSigner - let indexer: HardhatEthersSigner - - let disputeDeposit: bigint - - // Allocation variables - let allocationId: string - - before(async () => { - // Get contracts - const graph = hre.graph() - disputeManager = graph.subgraphService.contracts.DisputeManager - legacyDisputeManager = graph.subgraphService.contracts.LegacyDisputeManager - graphToken = graph.horizon.contracts.GraphToken - staking = graph.horizon.contracts.HorizonStaking - subgraphService = graph.subgraphService.contracts.SubgraphService - - // Get signers - governor = await graph.accounts.getGovernor() - arbitrator = await graph.accounts.getArbitrator() - ;[fisherman] = await graph.accounts.getTestAccounts() - - // Get indexer - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - - // Get allocation - const allocation = indexerFixture.legacyAllocations[0] - allocationId = allocation.allocationID - - // Get dispute deposit - disputeDeposit = ethers.parseEther('10000') - - // Set GRT balance for fisherman - await setGRTBalance(graph.provider, graphToken.target, fisherman.address, ethers.parseEther('1000000')) - - // Set arbitrator - await legacyDisputeManager.connect(governor).setArbitrator(arbitrator.address) - }) - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Legacy dispute type', () => { - describe('Arbitrator', () => { - it('should allow arbitrator to create and accept a legacy dispute on the new dispute manager after slashing on the legacy dispute manager', async () => { - // Create an indexing dispute on legacy dispute manager - await graphToken.connect(fisherman).approve(legacyDisputeManager.target, disputeDeposit) - await legacyDisputeManager.connect(fisherman).createIndexingDispute(allocationId, disputeDeposit) - const legacyDisputeId = generateLegacyIndexingDisputeId(allocationId) - - // Accept the dispute on the legacy dispute manager - await legacyDisputeManager.connect(arbitrator).acceptDispute(legacyDisputeId) - - // Get fisherman's balance before creating dispute - const fishermanBalanceBefore = await graphToken.balanceOf(fisherman.address) - - // Get indexer's provision before creating dispute - const provision = await staking.getProviderTokensAvailable(indexer.address, await subgraphService.getAddress()) - - // Create and accept legacy dispute using the same allocation ID - const tokensToSlash = ethers.parseEther('100000') - const tokensToReward = tokensToSlash / 2n - await disputeManager - .connect(arbitrator) - .createAndAcceptLegacyDispute(allocationId, fisherman.address, tokensToSlash, tokensToReward) - - // Get dispute ID from event - const disputeId = generateLegacyTypeDisputeId(allocationId) - - // Verify dispute was created and accepted - const dispute = await disputeManager.disputes(disputeId) - expect(dispute.indexer).to.equal(indexer.address, 'Indexer address mismatch') - expect(dispute.fisherman).to.equal(fisherman.address, 'Fisherman address mismatch') - expect(dispute.disputeType).to.equal(3, 'Dispute type should be legacy') - expect(dispute.status).to.equal(1, 'Dispute status should be accepted') - - // Verify indexer's stake was slashed - const updatedProvision = await staking.getProviderTokensAvailable( - indexer.address, - await subgraphService.getAddress(), - ) - expect(updatedProvision).to.equal(provision - tokensToSlash, 'Indexer stake should be slashed') - - // Verify fisherman got the reward - const fishermanBalance = await graphToken.balanceOf(fisherman.address) - expect(fishermanBalance).to.equal( - fishermanBalanceBefore + tokensToReward, - 'Fisherman balance should be increased by the reward', - ) - }) - - it('should not allow creating a legacy dispute for non-existent allocation', async () => { - const tokensToSlash = ethers.parseEther('1000') - const tokensToReward = tokensToSlash / 2n - - // Attempt to create legacy dispute with non-existent allocation - await expect( - disputeManager - .connect(arbitrator) - .createAndAcceptLegacyDispute( - ethers.Wallet.createRandom().address, - fisherman.address, - tokensToSlash, - tokensToReward, - ), - ).to.be.revertedWithCustomError(disputeManager, 'DisputeManagerIndexerNotFound') - }) - }) - - it('should not allow non-arbitrator to create a legacy dispute', async () => { - const tokensToSlash = ethers.parseEther('1000') - const tokensToReward = tokensToSlash / 2n - - // Attempt to create legacy dispute as fisherman - await expect( - disputeManager - .connect(fisherman) - .createAndAcceptLegacyDispute(allocationId, fisherman.address, tokensToSlash, tokensToReward), - ).to.be.revertedWithCustomError(disputeManager, 'DisputeManagerNotArbitrator') - }) - }) -}) diff --git a/packages/subgraph-service/test/integration/during-transition-period/governance.test.ts b/packages/subgraph-service/test/integration/during-transition-period/governance.test.ts deleted file mode 100644 index ad638b306..000000000 --- a/packages/subgraph-service/test/integration/during-transition-period/governance.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { SubgraphService } from '@graphprotocol/interfaces' -import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import { ethers } from 'hardhat' -import hre from 'hardhat' - -describe('Governance', () => { - let subgraphService: SubgraphService - let snapshotId: string - - // Test addresses - let governor: HardhatEthersSigner - let indexer: HardhatEthersSigner - let nonOwner: HardhatEthersSigner - let allocationId: string - let subgraphDeploymentId: string - - const graph = hre.graph() - - before(() => { - subgraphService = graph.subgraphService.contracts.SubgraphService - }) - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - - // Get signers - governor = await graph.accounts.getGovernor() - ;[indexer, nonOwner] = await graph.accounts.getTestAccounts() - - // Generate test addresses - allocationId = ethers.Wallet.createRandom().address - subgraphDeploymentId = ethers.keccak256(ethers.toUtf8Bytes('test-subgraph-deployment')) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Legacy Allocation Migration', () => { - it('should migrate legacy allocation', async () => { - // Migrate legacy allocation - await subgraphService - .connect(governor) - .migrateLegacyAllocation(indexer.address, allocationId, subgraphDeploymentId) - - // Verify the legacy allocation was migrated - const legacyAllocation = await subgraphService.getLegacyAllocation(allocationId) - expect(legacyAllocation.indexer).to.equal(indexer.address) - expect(legacyAllocation.subgraphDeploymentId).to.equal(subgraphDeploymentId) - }) - - it('should not allow non-owner to migrate legacy allocation', async () => { - // Attempt to migrate legacy allocation as non-owner - await expect( - subgraphService.connect(nonOwner).migrateLegacyAllocation(indexer.address, allocationId, subgraphDeploymentId), - ).to.be.revertedWithCustomError(subgraphService, 'OwnableUnauthorizedAccount') - }) - - it('should not allow migrating a legacy allocation that was already migrated', async () => { - // First migration - await subgraphService - .connect(governor) - .migrateLegacyAllocation(indexer.address, allocationId, subgraphDeploymentId) - - // Attempt to migrate the same allocation again - await expect( - subgraphService.connect(governor).migrateLegacyAllocation(indexer.address, allocationId, subgraphDeploymentId), - ) - .to.be.revertedWithCustomError(subgraphService, 'LegacyAllocationAlreadyExists') - .withArgs(allocationId) - }) - }) -}) diff --git a/packages/subgraph-service/test/integration/during-transition-period/indexer.test.ts b/packages/subgraph-service/test/integration/during-transition-period/indexer.test.ts deleted file mode 100644 index 7fd508c40..000000000 --- a/packages/subgraph-service/test/integration/during-transition-period/indexer.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { SubgraphService } from '@graphprotocol/interfaces' -import { encodeStartServiceData, generateAllocationProof } from '@graphprotocol/toolshed' -import { indexersData as indexers } from '@graphprotocol/toolshed/fixtures' -import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import { ethers } from 'hardhat' -import hre from 'hardhat' - -describe('Indexer', () => { - let subgraphService: SubgraphService - let snapshotId: string - let chainId: number - - // Test addresses - let governor: HardhatEthersSigner - let indexer: HardhatEthersSigner - let allocationId: string - let subgraphDeploymentId: string - let allocationPrivateKey: string - let subgraphServiceAddress: string - - const graph = hre.graph() - - before(async () => { - // Get contracts - subgraphService = graph.subgraphService.contracts.SubgraphService - - // Get governor and non-owner - governor = await graph.accounts.getGovernor() - - // Get chain id - chainId = Number((await hre.ethers.provider.getNetwork()).chainId) - - // Get subgraph service address - subgraphServiceAddress = await subgraphService.getAddress() - }) - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Allocation', () => { - beforeEach(async () => { - // Get indexer - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - - // Generate test addresses - const allocation = indexerFixture.legacyAllocations[0] - allocationId = allocation.allocationID - subgraphDeploymentId = allocation.subgraphDeploymentID - allocationPrivateKey = allocation.allocationPrivateKey - }) - - it('should not be able to create an allocation with an AllocationID that already exists in HorizonStaking contract', async () => { - // Build allocation proof - const signature = await generateAllocationProof( - indexer.address, - allocationPrivateKey, - subgraphServiceAddress, - chainId, - ) - - // Attempt to create an allocation with the same ID - const data = encodeStartServiceData(subgraphDeploymentId, 1000n, allocationId, signature) - - await expect(subgraphService.connect(indexer).startService(indexer.address, data)) - .to.be.revertedWithCustomError(subgraphService, 'LegacyAllocationAlreadyExists') - .withArgs(allocationId) - }) - - it('should not be able to create an allocation that was already migrated by the owner', async () => { - // Migrate legacy allocation - await subgraphService - .connect(governor) - .migrateLegacyAllocation(indexer.address, allocationId, subgraphDeploymentId) - - // Build allocation proof - const signature = await generateAllocationProof( - indexer.address, - allocationPrivateKey, - subgraphServiceAddress, - chainId, - ) - - // Attempt to create the same allocation - const data = encodeStartServiceData(subgraphDeploymentId, 1000n, allocationId, signature) - - await expect(subgraphService.connect(indexer).startService(indexer.address, data)) - .to.be.revertedWithCustomError(subgraphService, 'LegacyAllocationAlreadyExists') - .withArgs(allocationId) - }) - }) -}) diff --git a/packages/subgraph-service/test/integration/during-transition-period/legacy-dispute-manager.test.ts b/packages/subgraph-service/test/integration/during-transition-period/legacy-dispute-manager.test.ts deleted file mode 100644 index 51cfc557c..000000000 --- a/packages/subgraph-service/test/integration/during-transition-period/legacy-dispute-manager.test.ts +++ /dev/null @@ -1,256 +0,0 @@ -import { HorizonStaking, L2GraphToken, LegacyDisputeManager } from '@graphprotocol/interfaces' -import { - generateAttestationData, - generateLegacyIndexingDisputeId, - generateLegacyQueryDisputeId, -} from '@graphprotocol/toolshed' -import { indexersData as indexers } from '@graphprotocol/toolshed/fixtures' -import { setGRTBalance } from '@graphprotocol/toolshed/hardhat' -import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { expect } from 'chai' -import { ethers } from 'hardhat' -import hre from 'hardhat' - -describe('Legacy Dispute Manager', () => { - let legacyDisputeManager: LegacyDisputeManager - let graphToken: L2GraphToken - let staking: HorizonStaking - - let snapshotId: string - - let governor: HardhatEthersSigner - let arbitrator: HardhatEthersSigner - let indexer: HardhatEthersSigner - let fisherman: HardhatEthersSigner - - let disputeDeposit: bigint - - const graph = hre.graph() - - // We have to use Aribtrm Sepolia since we're testing an already deployed contract but running on a hardhat fork - const chainId = 421614 - - before(async () => { - governor = await graph.accounts.getGovernor() - ;[arbitrator, fisherman] = await graph.accounts.getTestAccounts() - - // Get contract instances with correct types - legacyDisputeManager = graph.subgraphService.contracts.LegacyDisputeManager - graphToken = graph.horizon.contracts.GraphToken - staking = graph.horizon.contracts.HorizonStaking - - // Set GRT balances - await setGRTBalance(graph.provider, graphToken.target, fisherman.address, ethers.parseEther('100000')) - }) - - beforeEach(async () => { - // Take a snapshot before each test - snapshotId = await ethers.provider.send('evm_snapshot', []) - - // Legacy dispute manager - disputeDeposit = ethers.parseEther('10000') - - // Set arbitrator - await legacyDisputeManager.connect(governor).setArbitrator(arbitrator.address) - }) - - afterEach(async () => { - // Revert to the snapshot after each test - await ethers.provider.send('evm_revert', [snapshotId]) - }) - - describe('Indexing Disputes', () => { - let allocationId: string - - beforeEach(async () => { - // Get Indexer - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - - // Get allocation - allocationId = indexerFixture.legacyAllocations[0].allocationID - }) - - it('should allow creating and accepting indexing disputes', async () => { - // Create an indexing dispute - await graphToken.connect(fisherman).approve(legacyDisputeManager.target, disputeDeposit) - await legacyDisputeManager.connect(fisherman).createIndexingDispute(allocationId, disputeDeposit) - const disputeId = generateLegacyIndexingDisputeId(allocationId) - - // Verify dispute was created - const disputeExists = await legacyDisputeManager.isDisputeCreated(disputeId) - expect(disputeExists).to.be.true - - // Get state before slashing - const idxSlashingPercentage = 25000n - const indexerStakeBefore = (await staking.getServiceProvider(indexer.address)).tokensStaked - const slashedAmount = (indexerStakeBefore * idxSlashingPercentage) / 1_000_000n - const fishermanBalanceBefore = await graphToken.balanceOf(fisherman.address) - - // Accept the dispute - await legacyDisputeManager.connect(arbitrator).acceptDispute(disputeId) - - // Verify indexer was slashed for 2.5% of their stake - const indexerStake = (await staking.getServiceProvider(indexer.address)).tokensStaked - expect(indexerStake).to.equal(indexerStakeBefore - slashedAmount, 'Indexer stake was not slashed correctly') - - // Verify fisherman received their deposit and 50% of the slashed amount - const fishermanBalance = await graphToken.balanceOf(fisherman.address) - expect(fishermanBalance).to.equal( - fishermanBalanceBefore + slashedAmount / 2n + disputeDeposit, - 'Fisherman balance was not updated correctly', - ) - }) - }) - - describe('Query Disputes', () => { - let allocationPrivateKey: string - let subgraphDeploymentId: string - - beforeEach(async () => { - // Get Indexer - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - - // Get allocation - const allocation = indexerFixture.legacyAllocations[0] - allocationPrivateKey = allocation.allocationPrivateKey - subgraphDeploymentId = allocation.subgraphDeploymentID - }) - - it('should allow creating and accepting query disputes', async () => { - // Create attestation data - const queryHash = ethers.keccak256(ethers.toUtf8Bytes('test-query')) - const responseHash = ethers.keccak256(ethers.toUtf8Bytes('test-response')) - const attestationData = await generateAttestationData( - queryHash, - responseHash, - subgraphDeploymentId, - allocationPrivateKey, - await legacyDisputeManager.getAddress(), - chainId, - ) - - // Create a query dispute - await graphToken.connect(fisherman).approve(legacyDisputeManager.target, disputeDeposit) - await legacyDisputeManager.connect(fisherman).createQueryDispute(attestationData, disputeDeposit) - const disputeId = generateLegacyQueryDisputeId( - queryHash, - responseHash, - subgraphDeploymentId, - indexer.address, - fisherman.address, - ) - - // Verify dispute was created - const disputeExists = await legacyDisputeManager.isDisputeCreated(disputeId) - expect(disputeExists).to.be.true - - // Get state before slashing - const qrySlashingPercentage = 25000n - const indexerStakeBefore = (await staking.getServiceProvider(indexer.address)).tokensStaked - const slashedAmount = (indexerStakeBefore * qrySlashingPercentage) / 1_000_000n - const fishermanBalanceBefore = await graphToken.balanceOf(fisherman.address) - - // Accept the dispute - await legacyDisputeManager.connect(arbitrator).acceptDispute(disputeId) - - // Verify indexer was slashed for 2.5% of their stake - const indexerStake = (await staking.getServiceProvider(indexer.address)).tokensStaked - expect(indexerStake).to.equal(indexerStakeBefore - slashedAmount, 'Indexer stake was not slashed correctly') - - // Verify fisherman received their deposit and 50% of the slashed amount - const fishermanBalance = await graphToken.balanceOf(fisherman.address) - expect(fishermanBalance).to.equal( - fishermanBalanceBefore + slashedAmount / 2n + disputeDeposit, - 'Fisherman balance was not updated correctly', - ) - }) - }) - - describe('Query Dispute Conflict', () => { - let allocationPrivateKey: string - let subgraphDeploymentId: string - - beforeEach(async () => { - // Get Indexer - const indexerFixture = indexers[0] - indexer = await ethers.getSigner(indexerFixture.address) - - // Get allocation - const allocation = indexerFixture.legacyAllocations[0] - allocationPrivateKey = allocation.allocationPrivateKey - subgraphDeploymentId = allocation.subgraphDeploymentID - }) - - it('should allow creating conflicting query disputes', async () => { - // Create first attestation data - const queryHash = ethers.keccak256(ethers.toUtf8Bytes('test-query')) - const responseHash1 = ethers.keccak256(ethers.toUtf8Bytes('test-response-1')) - const attestationData1 = await generateAttestationData( - queryHash, - responseHash1, - subgraphDeploymentId, - allocationPrivateKey, - await legacyDisputeManager.getAddress(), - chainId, - ) - - // Create second attestation data with different query/response - const responseHash2 = ethers.keccak256(ethers.toUtf8Bytes('test-response-2')) - const attestationData2 = await generateAttestationData( - queryHash, - responseHash2, - subgraphDeploymentId, - allocationPrivateKey, - await legacyDisputeManager.getAddress(), - chainId, - ) - - // Create query dispute - await legacyDisputeManager.connect(fisherman).createQueryDisputeConflict(attestationData1, attestationData2) - - // Create dispute IDs - const disputeId1 = generateLegacyQueryDisputeId( - queryHash, - responseHash1, - subgraphDeploymentId, - indexer.address, - fisherman.address, - ) - const disputeId2 = generateLegacyQueryDisputeId( - queryHash, - responseHash2, - subgraphDeploymentId, - indexer.address, - fisherman.address, - ) - - // Verify both disputes were created - const disputeExists1 = await legacyDisputeManager.isDisputeCreated(disputeId1) - const disputeExists2 = await legacyDisputeManager.isDisputeCreated(disputeId2) - expect(disputeExists1).to.be.true - expect(disputeExists2).to.be.true - - // Get state before slashing - const qrySlashingPercentage = 25000n - const indexerStakeBefore = (await staking.getServiceProvider(indexer.address)).tokensStaked - const slashedAmount = (indexerStakeBefore * qrySlashingPercentage) / 1_000_000n - const fishermanBalanceBefore = await graphToken.balanceOf(fisherman.address) - - // Accept one dispute - await legacyDisputeManager.connect(arbitrator).acceptDispute(disputeId1) - - // Verify indexer was slashed for 2.5% of their stake - const indexerStake = (await staking.getServiceProvider(indexer.address)).tokensStaked - expect(indexerStake).to.equal(indexerStakeBefore - slashedAmount, 'Indexer stake was not slashed correctly') - - // Verify fisherman received 50% of the slashed amount - const fishermanBalance = await graphToken.balanceOf(fisherman.address) - expect(fishermanBalance).to.equal( - fishermanBalanceBefore + slashedAmount / 2n, - 'Fisherman balance was not updated correctly', - ) - }) - }) -}) From da2dba755bede6611c00ce08e052b5f1d7e4cd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 3 Dec 2025 11:28:40 -0300 Subject: [PATCH 031/157] feat: add fn to force withdraw legacy stake and delegation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStaking.sol | 75 ++++++---- .../delegation/forceWithdrawDelegated.t.sol | 134 ++++++++++++++++++ .../unit/staking/stake/forceWithdraw.t.sol | 118 +++++++++++++++ .../horizon/internal/IHorizonStakingMain.sol | 26 ++++ 4 files changed, 327 insertions(+), 26 deletions(-) create mode 100644 packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol create mode 100644 packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index fbafbfc67..57ef2453f 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -111,6 +111,11 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { _withdraw(msg.sender); } + /// @inheritdoc IHorizonStakingMain + function forceWithdraw(address serviceProvider) external override notPaused { + _withdraw(serviceProvider); + } + /* * PROVISIONS */ @@ -322,33 +327,15 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { address serviceProvider, address // deprecated - kept for backwards compatibility ) external override notPaused returns (uint256) { - // Get the delegation pool of the indexer - address delegator = msg.sender; - DelegationPoolInternal storage pool = _legacyDelegationPools[serviceProvider]; - DelegationInternal storage delegation = pool.delegators[delegator]; - - // Validation - uint256 tokensToWithdraw = 0; - uint256 currentEpoch = _graphEpochManager().currentEpoch(); - if ( - delegation.__DEPRECATED_tokensLockedUntil > 0 && currentEpoch >= delegation.__DEPRECATED_tokensLockedUntil - ) { - tokensToWithdraw = delegation.__DEPRECATED_tokensLocked; - } - require(tokensToWithdraw > 0, HorizonStakingNothingToWithdraw()); - - // Reset lock - delegation.__DEPRECATED_tokensLocked = 0; - delegation.__DEPRECATED_tokensLockedUntil = 0; - - emit StakeDelegatedWithdrawn(serviceProvider, delegator, tokensToWithdraw); - - // -- Interactions -- - - // Return tokens to the delegator - _graphToken().pushTokens(delegator, tokensToWithdraw); + return _withdrawDelegatedLegacy(serviceProvider, msg.sender); + } - return tokensToWithdraw; + /// @inheritdoc IHorizonStakingMain + function forceWithdrawDelegated( + address serviceProvider, + address delegator + ) external override notPaused returns (uint256) { + return _withdrawDelegatedLegacy(serviceProvider, delegator); } /* @@ -1122,6 +1109,42 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { emit OperatorSet(msg.sender, _verifier, _operator, _allowed); } + /** + * @notice Withdraw legacy undelegated tokens for a delegator. + * @dev This function handles pre-Horizon undelegations where tokens are locked + * in the legacy delegation pool. + * @param _serviceProvider The service provider address + * @param _delegator The delegator address + * @return The amount of tokens withdrawn + */ + function _withdrawDelegatedLegacy(address _serviceProvider, address _delegator) private returns (uint256) { + DelegationPoolInternal storage pool = _legacyDelegationPools[_serviceProvider]; + DelegationInternal storage delegation = pool.delegators[_delegator]; + + // Validation + uint256 tokensToWithdraw = 0; + uint256 currentEpoch = _graphEpochManager().currentEpoch(); + if ( + delegation.__DEPRECATED_tokensLockedUntil > 0 && currentEpoch >= delegation.__DEPRECATED_tokensLockedUntil + ) { + tokensToWithdraw = delegation.__DEPRECATED_tokensLocked; + } + require(tokensToWithdraw > 0, HorizonStakingNothingToWithdraw()); + + // Reset lock + delegation.__DEPRECATED_tokensLocked = 0; + delegation.__DEPRECATED_tokensLockedUntil = 0; + + emit StakeDelegatedWithdrawn(_serviceProvider, _delegator, tokensToWithdraw); + + // -- Interactions -- + + // Return tokens to the delegator + _graphToken().pushTokens(_delegator, tokensToWithdraw); + + return tokensToWithdraw; + } + /** * @notice Check if an operator is authorized for the caller on a specific verifier / data service. * @dev Note that this function handles the special case where the verifier is the subgraph data service, diff --git a/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol b/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol new file mode 100644 index 000000000..d60afe029 --- /dev/null +++ b/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import "forge-std/Test.sol"; + +import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; + +import { HorizonStakingTest } from "../HorizonStaking.t.sol"; + +contract HorizonStakingForceWithdrawDelegatedTest is HorizonStakingTest { + /* + * MODIFIERS + */ + + modifier useDelegator() { + resetPrank(users.delegator); + _; + } + + /* + * HELPERS + */ + + function _setLegacyDelegation( + address _indexer, + address _delegator, + uint256 _shares, + uint256 __DEPRECATED_tokensLocked, + uint256 __DEPRECATED_tokensLockedUntil + ) public { + // Calculate the base storage slot for the serviceProvider in the mapping + bytes32 baseSlot = keccak256(abi.encode(_indexer, uint256(20))); + + // Calculate the slot for the delegator's DelegationInternal struct + bytes32 delegatorSlot = keccak256(abi.encode(_delegator, bytes32(uint256(baseSlot) + 4))); + + // Use vm.store to set each field of the struct + vm.store(address(staking), bytes32(uint256(delegatorSlot)), bytes32(_shares)); + vm.store(address(staking), bytes32(uint256(delegatorSlot) + 1), bytes32(__DEPRECATED_tokensLocked)); + vm.store(address(staking), bytes32(uint256(delegatorSlot) + 2), bytes32(__DEPRECATED_tokensLockedUntil)); + } + + /* + * ACTIONS + */ + + function _forceWithdrawDelegated(address _indexer, address _delegator) internal { + IHorizonStakingTypes.DelegationPool memory pool = staking.getDelegationPool( + _indexer, + subgraphDataServiceLegacyAddress + ); + uint256 beforeStakingBalance = token.balanceOf(address(staking)); + uint256 beforeDelegatorBalance = token.balanceOf(_delegator); + + vm.expectEmit(address(staking)); + emit IHorizonStakingMain.StakeDelegatedWithdrawn(_indexer, _delegator, pool.tokens); + staking.forceWithdrawDelegated(_indexer, _delegator); + + uint256 afterStakingBalance = token.balanceOf(address(staking)); + uint256 afterDelegatorBalance = token.balanceOf(_delegator); + + assertEq(afterStakingBalance, beforeStakingBalance - pool.tokens); + assertEq(afterDelegatorBalance - pool.tokens, beforeDelegatorBalance); + + DelegationInternal memory delegation = _getStorage_Delegation( + _indexer, + subgraphDataServiceLegacyAddress, + _delegator, + true + ); + assertEq(delegation.shares, 0); + assertEq(delegation.__DEPRECATED_tokensLocked, 0); + assertEq(delegation.__DEPRECATED_tokensLockedUntil, 0); + } + + /* + * TESTS + */ + + function testForceWithdrawDelegated_Tokens(uint256 tokensLocked) public useDelegator { + vm.assume(tokensLocked > 0); + + _setStorage_DelegationPool(users.indexer, tokensLocked, 0, 0); + _setLegacyDelegation(users.indexer, users.delegator, 0, tokensLocked, 1); + token.transfer(address(staking), tokensLocked); + + // switch to a third party (not the delegator) + resetPrank(users.operator); + + _forceWithdrawDelegated(users.indexer, users.delegator); + } + + function testForceWithdrawDelegated_CalledByDelegator(uint256 tokensLocked) public useDelegator { + vm.assume(tokensLocked > 0); + + _setStorage_DelegationPool(users.indexer, tokensLocked, 0, 0); + _setLegacyDelegation(users.indexer, users.delegator, 0, tokensLocked, 1); + token.transfer(address(staking), tokensLocked); + + // delegator can also call forceWithdrawDelegated on themselves + _forceWithdrawDelegated(users.indexer, users.delegator); + } + + function testForceWithdrawDelegated_RevertWhen_NoTokens() public useDelegator { + _setStorage_DelegationPool(users.indexer, 0, 0, 0); + _setLegacyDelegation(users.indexer, users.delegator, 0, 0, 0); + + // switch to a third party + resetPrank(users.operator); + + bytes memory expectedError = abi.encodeWithSignature("HorizonStakingNothingToWithdraw()"); + vm.expectRevert(expectedError); + staking.forceWithdrawDelegated(users.indexer, users.delegator); + } + + function testForceWithdrawDelegated_RevertWhen_StillLocked(uint256 tokensLocked) public useDelegator { + vm.assume(tokensLocked > 0); + + // Set a future epoch for tokensLockedUntil + uint256 futureEpoch = 1000; + _setStorage_DelegationPool(users.indexer, tokensLocked, 0, 0); + _setLegacyDelegation(users.indexer, users.delegator, 0, tokensLocked, futureEpoch); + token.transfer(address(staking), tokensLocked); + + // switch to a third party + resetPrank(users.operator); + + // Should revert because tokens are still locked (current epoch < futureEpoch) + bytes memory expectedError = abi.encodeWithSignature("HorizonStakingNothingToWithdraw()"); + vm.expectRevert(expectedError); + staking.forceWithdrawDelegated(users.indexer, users.delegator); + } +} diff --git a/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol b/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol new file mode 100644 index 000000000..bd666d270 --- /dev/null +++ b/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import "forge-std/Test.sol"; + +import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; + +import { HorizonStakingTest } from "../HorizonStaking.t.sol"; + +contract HorizonStakingForceWithdrawTest is HorizonStakingTest { + /* + * HELPERS + */ + + function _forceWithdraw(address _serviceProvider) internal { + (, address msgSender, ) = vm.readCallers(); + + // before + ServiceProviderInternal memory beforeServiceProvider = _getStorage_ServiceProviderInternal(_serviceProvider); + uint256 beforeServiceProviderBalance = token.balanceOf(_serviceProvider); + uint256 beforeCallerBalance = token.balanceOf(msgSender); + uint256 beforeStakingBalance = token.balanceOf(address(staking)); + + // forceWithdraw + vm.expectEmit(address(staking)); + emit IHorizonStakingMain.HorizonStakeWithdrawn(_serviceProvider, beforeServiceProvider.__DEPRECATED_tokensLocked); + staking.forceWithdraw(_serviceProvider); + + // after + ServiceProviderInternal memory afterServiceProvider = _getStorage_ServiceProviderInternal(_serviceProvider); + uint256 afterServiceProviderBalance = token.balanceOf(_serviceProvider); + uint256 afterCallerBalance = token.balanceOf(msgSender); + uint256 afterStakingBalance = token.balanceOf(address(staking)); + + // assert - tokens go to service provider, not caller + assertEq(afterServiceProviderBalance - beforeServiceProviderBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq(afterCallerBalance, beforeCallerBalance); // caller balance unchanged + assertEq(beforeStakingBalance - afterStakingBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + + // assert - service provider state updated + assertEq( + afterServiceProvider.tokensStaked, + beforeServiceProvider.tokensStaked - beforeServiceProvider.__DEPRECATED_tokensLocked + ); + assertEq(afterServiceProvider.tokensProvisioned, beforeServiceProvider.tokensProvisioned); + assertEq(afterServiceProvider.__DEPRECATED_tokensAllocated, beforeServiceProvider.__DEPRECATED_tokensAllocated); + assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, 0); + assertEq(afterServiceProvider.__DEPRECATED_tokensLockedUntil, 0); + } + + /* + * TESTS + */ + + function testForceWithdraw_Tokens(uint256 tokens, uint256 tokensLocked) public useIndexer { + tokens = bound(tokens, 1, MAX_STAKING_TOKENS); + tokensLocked = bound(tokensLocked, 1, tokens); + + // simulate locked tokens ready to withdraw + token.transfer(address(staking), tokens); + _setStorage_ServiceProvider(users.indexer, tokens, 0, tokensLocked, block.number, 0); + + _createProvision(users.indexer, subgraphDataServiceAddress, tokens, 0, MAX_THAWING_PERIOD); + + // switch to a different user (not the service provider) + resetPrank(users.delegator); + + _forceWithdraw(users.indexer); + } + + function testForceWithdraw_CalledByServiceProvider(uint256 tokens, uint256 tokensLocked) public useIndexer { + tokens = bound(tokens, 1, MAX_STAKING_TOKENS); + tokensLocked = bound(tokensLocked, 1, tokens); + + // simulate locked tokens ready to withdraw + token.transfer(address(staking), tokens); + _setStorage_ServiceProvider(users.indexer, tokens, 0, tokensLocked, block.number, 0); + + _createProvision(users.indexer, subgraphDataServiceAddress, tokens, 0, MAX_THAWING_PERIOD); + + // before + ServiceProviderInternal memory beforeServiceProvider = _getStorage_ServiceProviderInternal(users.indexer); + uint256 beforeServiceProviderBalance = token.balanceOf(users.indexer); + uint256 beforeStakingBalance = token.balanceOf(address(staking)); + + // service provider can also call forceWithdraw on themselves + vm.expectEmit(address(staking)); + emit IHorizonStakingMain.HorizonStakeWithdrawn(users.indexer, beforeServiceProvider.__DEPRECATED_tokensLocked); + staking.forceWithdraw(users.indexer); + + // after + ServiceProviderInternal memory afterServiceProvider = _getStorage_ServiceProviderInternal(users.indexer); + uint256 afterServiceProviderBalance = token.balanceOf(users.indexer); + uint256 afterStakingBalance = token.balanceOf(address(staking)); + + // assert + assertEq(afterServiceProviderBalance - beforeServiceProviderBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq(beforeStakingBalance - afterStakingBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, 0); + assertEq(afterServiceProvider.__DEPRECATED_tokensLockedUntil, 0); + } + + function testForceWithdraw_RevertWhen_ZeroTokens(uint256 tokens) public useIndexer { + tokens = bound(tokens, 1, MAX_STAKING_TOKENS); + + // simulate zero locked tokens + token.transfer(address(staking), tokens); + _setStorage_ServiceProvider(users.indexer, tokens, 0, 0, 0, 0); + + _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, MAX_THAWING_PERIOD); + + // switch to a different user + resetPrank(users.delegator); + + vm.expectRevert(abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidZeroTokens.selector)); + staking.forceWithdraw(users.indexer); + } +} diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index 11f7f575f..b5763a8f2 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -952,4 +952,30 @@ interface IHorizonStakingMain { * @return Whether the operator is authorized or not */ function isAuthorized(address serviceProvider, address verifier, address operator) external view returns (bool); + + /** + * @notice Withdraw service provider legacy locked tokens. + * This is a permissionless function that allows anyone to withdraw on behalf of a service provider. + * It only allows withdrawing tokens that were unstaked before the Horizon upgrade. + * @dev Tokens are always sent to the service provider, not the caller. + * + * Emits a {HorizonStakeWithdrawn} event. + * + * @param serviceProvider Address of service provider to withdraw funds from + */ + function forceWithdraw(address serviceProvider) external; + + /** + * @notice Withdraw delegator legacy undelegated tokens. + * This is a permissionless function that allows anyone to withdraw on behalf of a delegator. + * It only allows withdrawing tokens that were undelegated before the Horizon upgrade. + * @dev Tokens are always sent to the delegator, not the caller. + * + * Emits a {StakeDelegatedWithdrawn} event. + * + * @param serviceProvider The service provider address + * @param delegator The delegator address to withdraw funds for + * @return The amount of tokens withdrawn + */ + function forceWithdrawDelegated(address serviceProvider, address delegator) external returns (uint256); } From dd8d62416aed798bc42ea9c8414c132c71bf0ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 3 Dec 2025 11:29:09 -0300 Subject: [PATCH 032/157] chore: lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../test/unit/staking/stake/forceWithdraw.t.sol | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol b/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol index bd666d270..5e75b7d25 100644 --- a/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol +++ b/packages/horizon/test/unit/staking/stake/forceWithdraw.t.sol @@ -23,7 +23,10 @@ contract HorizonStakingForceWithdrawTest is HorizonStakingTest { // forceWithdraw vm.expectEmit(address(staking)); - emit IHorizonStakingMain.HorizonStakeWithdrawn(_serviceProvider, beforeServiceProvider.__DEPRECATED_tokensLocked); + emit IHorizonStakingMain.HorizonStakeWithdrawn( + _serviceProvider, + beforeServiceProvider.__DEPRECATED_tokensLocked + ); staking.forceWithdraw(_serviceProvider); // after @@ -33,7 +36,10 @@ contract HorizonStakingForceWithdrawTest is HorizonStakingTest { uint256 afterStakingBalance = token.balanceOf(address(staking)); // assert - tokens go to service provider, not caller - assertEq(afterServiceProviderBalance - beforeServiceProviderBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq( + afterServiceProviderBalance - beforeServiceProviderBalance, + beforeServiceProvider.__DEPRECATED_tokensLocked + ); assertEq(afterCallerBalance, beforeCallerBalance); // caller balance unchanged assertEq(beforeStakingBalance - afterStakingBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); @@ -94,7 +100,10 @@ contract HorizonStakingForceWithdrawTest is HorizonStakingTest { uint256 afterStakingBalance = token.balanceOf(address(staking)); // assert - assertEq(afterServiceProviderBalance - beforeServiceProviderBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); + assertEq( + afterServiceProviderBalance - beforeServiceProviderBalance, + beforeServiceProvider.__DEPRECATED_tokensLocked + ); assertEq(beforeStakingBalance - afterStakingBalance, beforeServiceProvider.__DEPRECATED_tokensLocked); assertEq(afterServiceProvider.__DEPRECATED_tokensLocked, 0); assertEq(afterServiceProvider.__DEPRECATED_tokensLockedUntil, 0); From 0f71288102508fe2eec830791acf9889aad42759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 19 Dec 2025 11:51:01 -0300 Subject: [PATCH 033/157] fix: re-validate thawingPeriod when accepting provision parameters (OZ L-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStaking.sol | 5 +++ .../unit/staking/provision/parameters.t.sol | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 57ef2453f..9b8f5b817 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -216,6 +216,11 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { require(prov.createdAt != 0, HorizonStakingInvalidProvision(serviceProvider, verifier)); if ((prov.maxVerifierCutPending != prov.maxVerifierCut) || (prov.thawingPeriodPending != prov.thawingPeriod)) { + // Re-validate thawing period in case governor reduced _maxThawingPeriod after staging + require( + prov.thawingPeriodPending <= _maxThawingPeriod, + HorizonStakingInvalidThawingPeriod(prov.thawingPeriodPending, _maxThawingPeriod) + ); prov.maxVerifierCut = prov.maxVerifierCutPending; prov.thawingPeriod = prov.thawingPeriodPending; emit ProvisionParametersSet(serviceProvider, verifier, prov.maxVerifierCut, prov.thawingPeriod); diff --git a/packages/horizon/test/unit/staking/provision/parameters.t.sol b/packages/horizon/test/unit/staking/provision/parameters.t.sol index f7c74f508..f9ab3202a 100644 --- a/packages/horizon/test/unit/staking/provision/parameters.t.sol +++ b/packages/horizon/test/unit/staking/provision/parameters.t.sol @@ -177,4 +177,36 @@ contract HorizonStakingProvisionParametersTest is HorizonStakingTest { ); staking.acceptProvisionParameters(users.indexer); } + + function test_ProvisionParametersAccept_RevertWhen_MaxThawingPeriodReduced( + uint256 amount, + uint32 maxVerifierCut, + uint64 thawingPeriod + ) public useIndexer useValidParameters(maxVerifierCut, thawingPeriod) { + vm.assume(amount > 0); + vm.assume(amount <= MAX_STAKING_TOKENS); + vm.assume(thawingPeriod > 0); + + // Create provision with initial parameters (thawingPeriod = 0) + _createProvision(users.indexer, subgraphDataServiceAddress, amount, 0, 0); + + // Stage new parameters with valid thawing period + _setProvisionParameters(users.indexer, subgraphDataServiceAddress, maxVerifierCut, thawingPeriod); + + // Governor reduces max thawing period to below the staged value + uint64 newMaxThawingPeriod = thawingPeriod - 1; + resetPrank(users.governor); + _setMaxThawingPeriod(newMaxThawingPeriod); + + // Verifier tries to accept the parameters - should revert + resetPrank(subgraphDataServiceAddress); + vm.expectRevert( + abi.encodeWithSelector( + IHorizonStakingMain.HorizonStakingInvalidThawingPeriod.selector, + thawingPeriod, + newMaxThawingPeriod + ) + ); + staking.acceptProvisionParameters(users.indexer); + } } From a91f59ad479aa470b6f892ec1dab7012464087a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 19 Dec 2025 11:59:35 -0300 Subject: [PATCH 034/157] fix: return correct result for getThawedTokens when called for delegations (OZ L-02) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStakingBase.sol | 20 +++++-- .../unit/staking/delegation/withdraw.t.sol | 52 +++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/packages/horizon/contracts/staking/HorizonStakingBase.sol b/packages/horizon/contracts/staking/HorizonStakingBase.sol index 75e2cd37c..ab637d5da 100644 --- a/packages/horizon/contracts/staking/HorizonStakingBase.sol +++ b/packages/horizon/contracts/staking/HorizonStakingBase.sol @@ -182,14 +182,26 @@ abstract contract HorizonStakingBase is } uint256 thawedTokens = 0; - Provision storage prov = _provisions[serviceProvider][verifier]; - uint256 tokensThawing = prov.tokensThawing; - uint256 sharesThawing = prov.sharesThawing; + uint256 tokensThawing; + uint256 sharesThawing; + uint256 thawingNonce; + + if (requestType == ThawRequestType.Provision) { + Provision storage prov = _provisions[serviceProvider][verifier]; + tokensThawing = prov.tokensThawing; + sharesThawing = prov.sharesThawing; + thawingNonce = prov.thawingNonce; + } else { + DelegationPoolInternal storage pool = _getDelegationPool(serviceProvider, verifier); + tokensThawing = pool.tokensThawing; + sharesThawing = pool.sharesThawing; + thawingNonce = pool.thawingNonce; + } bytes32 thawRequestId = thawRequestList.head; while (thawRequestId != bytes32(0)) { ThawRequest storage thawRequest = _getThawRequest(requestType, thawRequestId); - if (thawRequest.thawingNonce == prov.thawingNonce) { + if (thawRequest.thawingNonce == thawingNonce) { if (thawRequest.thawingUntil <= block.timestamp) { // sharesThawing cannot be zero if there is a valid thaw request so the next division is safe uint256 tokens = (thawRequest.shares * tokensThawing) / sharesThawing; diff --git a/packages/horizon/test/unit/staking/delegation/withdraw.t.sol b/packages/horizon/test/unit/staking/delegation/withdraw.t.sol index 948961591..faeb4d78b 100644 --- a/packages/horizon/test/unit/staking/delegation/withdraw.t.sol +++ b/packages/horizon/test/unit/staking/delegation/withdraw.t.sol @@ -162,4 +162,56 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { resetPrank(users.delegator); _withdrawDelegated(users.indexer, subgraphDataServiceAddress, 0); } + + function testWithdrawDelegation_GetThawedTokens( + uint256 delegationAmount, + uint256 withdrawShares + ) + public + useIndexer + useProvision(10_000_000 ether, 0, MAX_THAWING_PERIOD) + useDelegation(delegationAmount) + useUndelegate(withdrawShares) + { + ILinkedList.List memory thawingRequests = staking.getThawRequestList( + IHorizonStakingTypes.ThawRequestType.Delegation, + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + ThawRequest memory thawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Delegation, + thawingRequests.tail + ); + + // Before thawing period passes, thawed tokens should be 0 + uint256 thawedTokensBefore = staking.getThawedTokens( + IHorizonStakingTypes.ThawRequestType.Delegation, + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + assertEq(thawedTokensBefore, 0); + + // Skip past thawing period + skip(thawRequest.thawingUntil + 1); + + // After thawing period, thawed tokens should match expected amount + uint256 thawedTokensAfter = staking.getThawedTokens( + IHorizonStakingTypes.ThawRequestType.Delegation, + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + + // Thawed tokens should be greater than 0 and should match what we can withdraw + assertGt(thawedTokensAfter, 0); + + // Withdraw and verify the amount matches + uint256 balanceBefore = token.balanceOf(users.delegator); + _withdrawDelegated(users.indexer, subgraphDataServiceAddress, 0); + uint256 balanceAfter = token.balanceOf(users.delegator); + + assertEq(balanceAfter - balanceBefore, thawedTokensAfter); + } } From ed356fe40546c2a9fcab1072d815767d657148bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 19 Dec 2025 12:10:15 -0300 Subject: [PATCH 035/157] fix: remove more deprecated code (OZ N-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/l2/curation/L2Curation.sol | 7 ++----- .../test/tests/unit/l2/l2Curation.test.ts | 2 +- .../contracts/staking/HorizonStaking.sol | 5 +---- .../delegation/forceWithdrawDelegated.t.sol | 18 ------------------ 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/packages/contracts/contracts/l2/curation/L2Curation.sol b/packages/contracts/contracts/l2/curation/L2Curation.sol index 56e83c13a..fd26bd2ac 100644 --- a/packages/contracts/contracts/l2/curation/L2Curation.sol +++ b/packages/contracts/contracts/l2/curation/L2Curation.sol @@ -171,11 +171,8 @@ contract L2Curation is CurationV3Storage, GraphUpgradeable, IL2Curation { * @param _tokens Amount of Graph Tokens to add to reserves */ function collect(bytes32 _subgraphDeploymentID, uint256 _tokens) external override { - // Only SubgraphService and Staking contract are authorized as callers - require( - msg.sender == subgraphService || msg.sender == address(staking()), - "Caller must be the subgraph service or staking contract" - ); + // Only SubgraphService is authorized as caller + require(msg.sender == subgraphService, "Caller must be the subgraph service"); // Must be curated to accept tokens require(isCurated(_subgraphDeploymentID), "Subgraph deployment must be curated to collect fees"); diff --git a/packages/contracts/test/tests/unit/l2/l2Curation.test.ts b/packages/contracts/test/tests/unit/l2/l2Curation.test.ts index 6ee8a5cd3..77024b4b0 100644 --- a/packages/contracts/test/tests/unit/l2/l2Curation.test.ts +++ b/packages/contracts/test/tests/unit/l2/l2Curation.test.ts @@ -529,7 +529,7 @@ describe('L2Curation', () => { it('reject collect tokens distributed from invalid address', async function () { const tx = curation.connect(me).collect(subgraphDeploymentID, tokensToCollect) - await expect(tx).revertedWith('Caller must be the subgraph service or staking contract') + await expect(tx).revertedWith('Caller must be the subgraph service') }) it('should collect tokens distributed to the curation pool', async function () { diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 9b8f5b817..6d1de6226 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -1128,10 +1128,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { // Validation uint256 tokensToWithdraw = 0; - uint256 currentEpoch = _graphEpochManager().currentEpoch(); - if ( - delegation.__DEPRECATED_tokensLockedUntil > 0 && currentEpoch >= delegation.__DEPRECATED_tokensLockedUntil - ) { + if (delegation.__DEPRECATED_tokensLockedUntil > 0) { tokensToWithdraw = delegation.__DEPRECATED_tokensLocked; } require(tokensToWithdraw > 0, HorizonStakingNothingToWithdraw()); diff --git a/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol b/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol index d60afe029..af823a8d3 100644 --- a/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol +++ b/packages/horizon/test/unit/staking/delegation/forceWithdrawDelegated.t.sol @@ -113,22 +113,4 @@ contract HorizonStakingForceWithdrawDelegatedTest is HorizonStakingTest { vm.expectRevert(expectedError); staking.forceWithdrawDelegated(users.indexer, users.delegator); } - - function testForceWithdrawDelegated_RevertWhen_StillLocked(uint256 tokensLocked) public useDelegator { - vm.assume(tokensLocked > 0); - - // Set a future epoch for tokensLockedUntil - uint256 futureEpoch = 1000; - _setStorage_DelegationPool(users.indexer, tokensLocked, 0, 0); - _setLegacyDelegation(users.indexer, users.delegator, 0, tokensLocked, futureEpoch); - token.transfer(address(staking), tokensLocked); - - // switch to a third party - resetPrank(users.operator); - - // Should revert because tokens are still locked (current epoch < futureEpoch) - bytes memory expectedError = abi.encodeWithSignature("HorizonStakingNothingToWithdraw()"); - vm.expectRevert(expectedError); - staking.forceWithdrawDelegated(users.indexer, users.delegator); - } } From 1c3e30607f1775886fcfa1f618a2c9b74786f231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 19 Dec 2025 12:14:42 -0300 Subject: [PATCH 036/157] fix: outdated documentation (OZ N-02) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/horizon/contracts/staking/HorizonStaking.sol | 4 ++-- .../contracts/contracts/rewards/IRewardsManager.sol | 2 +- .../contracts/horizon/internal/IHorizonStakingMain.sol | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 6d1de6226..8998728e5 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -842,8 +842,8 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { * @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw * requests in the event that fulfilling all of them results in a gas limit error. Otherwise, the function * will attempt to fulfill all thaw requests until the first one that is not yet expired is found. - * @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill - * the thaw requests with an amount equal to zero. + * @dev If the delegation pool was completely slashed before withdrawing, calling this function will revert + * until the pool state is repaired with {IHorizonStakingMain-addToDelegationPool}. * @param _serviceProvider The service provider address * @param _verifier The verifier address * @param _newServiceProvider The new service provider address diff --git a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol index 72a73e19b..33daf71fe 100644 --- a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol @@ -122,7 +122,7 @@ interface IRewardsManager { /** * @notice Pull rewards from the contract for a particular allocation - * @dev This function can only be called by the Staking contract. + * @dev This function can only be called by the Subgraph Service contract. * This function will mint the necessary tokens to reward based on the inflation calculation. * @param allocationID Allocation * @return Assigned rewards amount diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index b5763a8f2..ddc595409 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -783,7 +783,7 @@ interface IHorizonStakingMain { * - `newServiceProvider` and `newVerifier` must not be the zero address. * - `newServiceProvider` must have previously provisioned stake to `newVerifier`. * - * Emits {ThawRequestFulfilled}, {ThawRequestsFulfilled} and {DelegatedTokensWithdrawn} events. + * Emits {ThawRequestFulfilled} and {ThawRequestsFulfilled} events. * * @param oldServiceProvider The old service provider address * @param oldVerifier The old verifier address From d9f053a7d96a8a4d81415303ae1d537f836f887c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 19 Dec 2025 12:39:26 -0300 Subject: [PATCH 037/157] test: fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../test/tests/unit/l2/l2Curation.test.ts | 25 +++-- .../test/tests/unit/l2/l2GNS.test.ts | 106 +----------------- 2 files changed, 15 insertions(+), 116 deletions(-) diff --git a/packages/contracts/test/tests/unit/l2/l2Curation.test.ts b/packages/contracts/test/tests/unit/l2/l2Curation.test.ts index 77024b4b0..a680ec28c 100644 --- a/packages/contracts/test/tests/unit/l2/l2Curation.test.ts +++ b/packages/contracts/test/tests/unit/l2/l2Curation.test.ts @@ -154,7 +154,7 @@ describe('L2Curation', () => { let me: SignerWithAddress let governor: SignerWithAddress let curator: SignerWithAddress - let stakingMock: SignerWithAddress + let subgraphServiceMock: SignerWithAddress let gnsImpersonator: Signer let fixture: NetworkFixture @@ -310,8 +310,8 @@ describe('L2Curation', () => { const beforeTotalBalance = await grt.balanceOf(curation.address) // Source of tokens must be the staking for this to work - await grt.connect(stakingMock).transfer(curation.address, tokensToCollect) - const tx = curation.connect(stakingMock).collect(subgraphDeploymentID, tokensToCollect) + await grt.connect(subgraphServiceMock).transfer(curation.address, tokensToCollect) + const tx = curation.connect(subgraphServiceMock).collect(subgraphDeploymentID, tokensToCollect) await expect(tx).emit(curation, 'Collected').withArgs(subgraphDeploymentID, tokensToCollect) // After state @@ -325,7 +325,7 @@ describe('L2Curation', () => { before(async function () { // Use stakingMock so we can call collect - ;[me, curator, stakingMock] = await graph.getTestAccounts() + ;[me, curator, subgraphServiceMock] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor, true) @@ -343,8 +343,11 @@ describe('L2Curation', () => { await grt.connect(gnsImpersonator).approve(curation.address, curatorTokens) // Give some funds to the staking contract and approve the curation contract - await grt.connect(governor).mint(stakingMock.address, tokensToCollect) - await grt.connect(stakingMock).approve(curation.address, tokensToCollect) + await grt.connect(governor).mint(subgraphServiceMock.address, tokensToCollect) + await grt.connect(subgraphServiceMock).approve(curation.address, tokensToCollect) + + // Set the subgraph service + await curation.connect(governor).setSubgraphService(subgraphServiceMock.address) }) beforeEach(async function () { @@ -514,10 +517,10 @@ describe('L2Curation', () => { context('> not curated', function () { it('reject collect tokens distributed to the curation pool', async function () { // Source of tokens must be the staking for this to work - await controller.connect(governor).setContractProxy(utils.id('Staking'), stakingMock.address) + await controller.connect(governor).setContractProxy(utils.id('Staking'), subgraphServiceMock.address) await curation.connect(governor).syncAllContracts() // call sync because we change the proxy for staking - const tx = curation.connect(stakingMock).collect(subgraphDeploymentID, tokensToCollect) + const tx = curation.connect(subgraphServiceMock).collect(subgraphDeploymentID, tokensToCollect) await expect(tx).revertedWith('Subgraph deployment must be curated to collect fees') }) }) @@ -533,7 +536,7 @@ describe('L2Curation', () => { }) it('should collect tokens distributed to the curation pool', async function () { - await controller.connect(governor).setContractProxy(utils.id('Staking'), stakingMock.address) + await controller.connect(governor).setContractProxy(utils.id('Staking'), subgraphServiceMock.address) await curation.connect(governor).syncAllContracts() // call sync because we change the proxy for staking await shouldCollect(toGRT('1')) @@ -544,7 +547,7 @@ describe('L2Curation', () => { }) it('should collect tokens and then unsignal all', async function () { - await controller.connect(governor).setContractProxy(utils.id('Staking'), stakingMock.address) + await controller.connect(governor).setContractProxy(utils.id('Staking'), subgraphServiceMock.address) await curation.connect(governor).syncAllContracts() // call sync because we change the proxy for staking // Collect increase the pool reserves @@ -556,7 +559,7 @@ describe('L2Curation', () => { }) it('should collect tokens and then unsignal multiple times', async function () { - await controller.connect(governor).setContractProxy(utils.id('Staking'), stakingMock.address) + await controller.connect(governor).setContractProxy(utils.id('Staking'), subgraphServiceMock.address) await curation.connect(governor).syncAllContracts() // call sync because we change the proxy for staking // Collect increase the pool reserves diff --git a/packages/contracts/test/tests/unit/l2/l2GNS.test.ts b/packages/contracts/test/tests/unit/l2/l2GNS.test.ts index 5b8f1d028..0fd691939 100644 --- a/packages/contracts/test/tests/unit/l2/l2GNS.test.ts +++ b/packages/contracts/test/tests/unit/l2/l2GNS.test.ts @@ -2,12 +2,10 @@ import { L2GNS } from '@graphprotocol/contracts' import { L2GraphTokenGateway } from '@graphprotocol/contracts' import { L2Curation } from '@graphprotocol/contracts' import { GraphToken } from '@graphprotocol/contracts' -import { IL2Staking } from '@graphprotocol/contracts' import { L1GNS, L1GraphTokenGateway } from '@graphprotocol/contracts' import { buildSubgraph, buildSubgraphId, - deriveChannelKey, GraphNetworkContracts, helpers, PublishSubgraph, @@ -44,7 +42,6 @@ interface L1SubgraphParams { describe('L2GNS', () => { const graph = hre.graph() let me: SignerWithAddress - let attacker: SignerWithAddress let other: SignerWithAddress let governor: SignerWithAddress let fixture: NetworkFixture @@ -58,7 +55,6 @@ describe('L2GNS', () => { let gns: L2GNS let curation: L2Curation let grt: GraphToken - let staking: IL2Staking let newSubgraph0: PublishSubgraph let newSubgraph1: PublishSubgraph @@ -109,7 +105,7 @@ describe('L2GNS', () => { before(async function () { newSubgraph0 = buildSubgraph() - ;[me, attacker, other] = await graph.getTestAccounts() + ;[me, other] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) @@ -118,7 +114,6 @@ describe('L2GNS', () => { fixtureContracts = await fixture.load(governor, true) l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway as L2GraphTokenGateway gns = fixtureContracts.L2GNS as L2GNS - staking = fixtureContracts.L2Staking as unknown as IL2Staking curation = fixtureContracts.L2Curation as L2Curation grt = fixtureContracts.GraphToken as GraphToken @@ -354,61 +349,6 @@ describe('L2GNS', () => { .emit(gns, 'SignalMinted') .withArgs(l2SubgraphId, me.address, expectedNSignal, expectedSignal, curatedTokens) }) - it('protects the owner against a rounding attack', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = await defaultL1SubgraphParams() - const collectTokens = curatedTokens.mul(20) - - await staking.connect(governor).setCurationPercentage(100000) - - // Set up an indexer account with some stake - await grt.connect(governor).mint(attacker.address, toGRT('1000000')) - // Curate 1 wei GRT by minting 1 GRT and burning most of it - await grt.connect(attacker).approve(curation.address, toBN(1)) - await curation.connect(attacker).mint(newSubgraph0.subgraphDeploymentID, toBN(1), 0) - - // Check this actually gave us 1 wei signal - expect(await curation.getCurationPoolTokens(newSubgraph0.subgraphDeploymentID)).eq(1) - await grt.connect(attacker).approve(staking.address, toGRT('1000000')) - await staking.connect(attacker).stake(toGRT('100000')) - const channelKey = deriveChannelKey() - // Allocate to the same deployment ID - await staking - .connect(attacker) - .allocateFrom( - attacker.address, - newSubgraph0.subgraphDeploymentID, - toGRT('100000'), - channelKey.address, - randomHexBytes(32), - await channelKey.generateProof(attacker.address), - ) - // Spoof some query fees, 10% of which will go to the Curation pool - await staking.connect(attacker).collect(collectTokens, channelKey.address) - // The curation pool now has 1 wei shares and a lot of tokens, so the rounding attack is prepared - // But L2GNS will protect the owner by sending the tokens - const callhookData = defaultAbiCoder.encode(['uint8', 'uint256', 'address'], [toBN(0), l1SubgraphId, me.address]) - await gatewayFinalizeTransfer(l1GNSMock.address, gns.address, curatedTokens, callhookData) - - const l2SubgraphId = await gns.getAliasedL2SubgraphID(l1SubgraphId) - const tx = gns - .connect(me) - .finishSubgraphTransferFromL1( - l2SubgraphId, - newSubgraph0.subgraphDeploymentID, - subgraphMetadata, - versionMetadata, - ) - await expect(tx) - .emit(gns, 'SubgraphPublished') - .withArgs(l2SubgraphId, newSubgraph0.subgraphDeploymentID, DEFAULT_RESERVE_RATIO) - await expect(tx).emit(gns, 'SubgraphMetadataUpdated').withArgs(l2SubgraphId, subgraphMetadata) - await expect(tx).emit(gns, 'CuratorBalanceReturnedToBeneficiary') - await expect(tx).emit(gns, 'SubgraphUpgraded').withArgs(l2SubgraphId, 0, 0, newSubgraph0.subgraphDeploymentID) - await expect(tx) - .emit(gns, 'SubgraphVersionUpdated') - .withArgs(l2SubgraphId, newSubgraph0.subgraphDeploymentID, versionMetadata) - await expect(tx).emit(gns, 'SubgraphL2TransferFinalized').withArgs(l2SubgraphId) - }) it('cannot be called by someone other than the subgraph owner', async function () { const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = await defaultL1SubgraphParams() const callhookData = defaultAbiCoder.encode(['uint8', 'uint256', 'address'], [toBN(0), l1SubgraphId, me.address]) @@ -654,50 +594,6 @@ describe('L2GNS', () => { expect(gnsBalanceAfter).eq(gnsBalanceBefore) }) - it('protects the curator against a rounding attack', async function () { - // Transfer a subgraph from L1 with only 1 wei GRT of curated signal - const { l1SubgraphId, subgraphMetadata, versionMetadata } = await defaultL1SubgraphParams() - const curatedTokens = toBN('1') - await transferMockSubgraphFromL1(l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata) - // Prepare the rounding attack by setting up an indexer and collecting a lot of query fees - const curatorTokens = toGRT('10000') - const collectTokens = curatorTokens.mul(20) - await staking.connect(governor).setCurationPercentage(100000) - // Set up an indexer account with some stake - await grt.connect(governor).mint(attacker.address, toGRT('1000000')) - - await grt.connect(attacker).approve(staking.address, toGRT('1000000')) - await staking.connect(attacker).stake(toGRT('100000')) - const channelKey = deriveChannelKey() - // Allocate to the same deployment ID - await staking - .connect(attacker) - .allocateFrom( - attacker.address, - newSubgraph0.subgraphDeploymentID, - toGRT('100000'), - channelKey.address, - randomHexBytes(32), - await channelKey.generateProof(attacker.address), - ) - // Spoof some query fees, 10% of which will go to the Curation pool - await staking.connect(attacker).collect(collectTokens, channelKey.address) - - const callhookData = defaultAbiCoder.encode(['uint8', 'uint256', 'address'], [toBN(1), l1SubgraphId, me.address]) - const curatorTokensBefore = await grt.balanceOf(me.address) - const gnsBalanceBefore = await grt.balanceOf(gns.address) - const tx = gatewayFinalizeTransfer(l1GNSMock.address, gns.address, curatorTokens, callhookData) - await expect(tx) - .emit(gns, 'CuratorBalanceReturnedToBeneficiary') - .withArgs(l1SubgraphId, me.address, curatorTokens) - const curatorTokensAfter = await grt.balanceOf(me.address) - expect(curatorTokensAfter).eq(curatorTokensBefore.add(curatorTokens)) - const gnsBalanceAfter = await grt.balanceOf(gns.address) - // gatewayFinalizeTransfer will mint the tokens that are sent to the curator, - // so the GNS balance should be the same - expect(gnsBalanceAfter).eq(gnsBalanceBefore) - }) - it('if a subgraph was deprecated after transfer, it returns the tokens to the beneficiary', async function () { const l1GNSMockL2Alias = await helpers.getL2SignerFromL1(l1GNSMock.address) // Eth for gas: From 5c51f0d6a27d6659dfde9f70a44f27f17517f7ba Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:15:13 +0000 Subject: [PATCH 038/157] chore: use ^0.8.27 caret pragma and bump solc to 0.8.34 Normalize all Solidity pragmas to caret form (^0.8.27) for forward compatibility, and bump the compiler version from 0.8.33 to 0.8.34 for the issuance and subgraph-service packages. Archive the now- obsolete CompilerUpgrade0833.md doc. --- docs/{ => archive}/CompilerUpgrade0833.md | 0 packages/contracts/contracts/governance/Controller.sol | 2 +- packages/contracts/contracts/governance/Governed.sol | 2 +- packages/contracts/contracts/governance/Pausable.sol | 2 +- packages/contracts/contracts/rewards/RewardsManager.sol | 2 +- .../contracts/contracts/rewards/RewardsManagerStorage.sol | 2 +- packages/contracts/contracts/tests/MockERC165.sol | 2 +- packages/contracts/contracts/tests/MockIssuanceAllocator.sol | 2 +- .../contracts/tests/MockRewardsEligibilityOracle.sol | 2 +- packages/contracts/contracts/tests/MockSubgraphService.sol | 2 +- packages/contracts/contracts/upgrades/GraphProxy.sol | 2 +- packages/contracts/contracts/upgrades/GraphProxyAdmin.sol | 2 +- packages/contracts/contracts/upgrades/GraphProxyStorage.sol | 2 +- packages/contracts/contracts/upgrades/GraphUpgradeable.sol | 2 +- packages/contracts/contracts/utils/TokenUtils.sol | 2 +- packages/deployment/lib/issuance-deploy-utils.ts | 4 ++-- packages/horizon/contracts/data-service/DataService.sol | 2 +- .../horizon/contracts/data-service/DataServiceStorage.sol | 2 +- .../contracts/data-service/extensions/DataServiceFees.sol | 2 +- .../data-service/extensions/DataServiceFeesStorage.sol | 2 +- .../contracts/data-service/extensions/DataServicePausable.sol | 2 +- .../extensions/DataServicePausableUpgradeable.sol | 2 +- .../contracts/data-service/libraries/ProvisionTracker.sol | 2 +- .../contracts/data-service/utilities/ProvisionManager.sol | 2 +- .../data-service/utilities/ProvisionManagerStorage.sol | 2 +- packages/horizon/contracts/libraries/LibFixedMath.sol | 2 +- packages/horizon/contracts/libraries/LinkedList.sol | 2 +- packages/horizon/contracts/libraries/MathUtils.sol | 2 +- packages/horizon/contracts/libraries/PPMMath.sol | 2 +- packages/horizon/contracts/libraries/UintRange.sol | 2 +- packages/horizon/contracts/payments/GraphPayments.sol | 2 +- packages/horizon/contracts/payments/PaymentsEscrow.sol | 2 +- .../contracts/payments/collectors/GraphTallyCollector.sol | 2 +- packages/horizon/contracts/staking/HorizonStaking.sol | 2 +- packages/horizon/contracts/staking/HorizonStakingBase.sol | 2 +- .../horizon/contracts/staking/HorizonStakingExtension.sol | 2 +- packages/horizon/contracts/staking/HorizonStakingStorage.sol | 2 +- .../contracts/staking/libraries/ExponentialRebates.sol | 2 +- packages/horizon/contracts/staking/utilities/Managed.sol | 2 +- packages/horizon/contracts/utilities/Authorizable.sol | 2 +- packages/horizon/contracts/utilities/GraphDirectory.sol | 2 +- packages/horizon/test/unit/GraphBase.t.sol | 2 +- packages/horizon/test/unit/data-service/DataService.t.sol | 2 +- .../test/unit/data-service/DataServiceUpgradeable.t.sol | 2 +- .../test/unit/data-service/extensions/DataServiceFees.t.sol | 2 +- .../unit/data-service/extensions/DataServicePausable.t.sol | 2 +- .../extensions/DataServicePausableUpgradeable.t.sol | 2 +- .../unit/data-service/implementations/DataServiceBase.sol | 2 +- .../implementations/DataServiceBaseUpgradeable.sol | 2 +- .../unit/data-service/implementations/DataServiceImpFees.sol | 2 +- .../data-service/implementations/DataServiceImpPausable.sol | 2 +- .../implementations/DataServiceImpPausableUpgradeable.sol | 2 +- .../unit/data-service/implementations/DataServiceOverride.sol | 2 +- .../test/unit/data-service/libraries/ProvisionTracker.t.sol | 2 +- .../data-service/libraries/ProvisionTrackerImplementation.sol | 2 +- packages/horizon/test/unit/escrow/GraphEscrow.t.sol | 2 +- packages/horizon/test/unit/escrow/collect.t.sol | 2 +- packages/horizon/test/unit/escrow/deposit.t.sol | 2 +- packages/horizon/test/unit/escrow/getters.t.sol | 2 +- packages/horizon/test/unit/escrow/paused.t.sol | 2 +- packages/horizon/test/unit/escrow/thaw.t.sol | 2 +- packages/horizon/test/unit/escrow/withdraw.t.sol | 2 +- packages/horizon/test/unit/libraries/LinkedList.t.sol | 2 +- packages/horizon/test/unit/libraries/ListImplementation.sol | 2 +- packages/horizon/test/unit/libraries/PPMMath.t.sol | 2 +- packages/horizon/test/unit/payments/GraphPayments.t.sol | 2 +- .../payments/graph-tally-collector/GraphTallyCollector.t.sol | 2 +- .../unit/payments/graph-tally-collector/collect/collect.t.sol | 2 +- .../graph-tally-collector/signer/authorizeSigner.t.sol | 2 +- .../graph-tally-collector/signer/cancelThawSigner.t.sol | 2 +- .../payments/graph-tally-collector/signer/revokeSigner.t.sol | 2 +- .../payments/graph-tally-collector/signer/thawSigner.t.sol | 2 +- .../unit/shared/horizon-staking/HorizonStakingShared.t.sol | 2 +- .../unit/shared/payments-escrow/PaymentsEscrowShared.t.sol | 2 +- packages/horizon/test/unit/staking/HorizonStaking.t.sol | 2 +- .../horizon/test/unit/staking/allocation/allocation.t.sol | 2 +- packages/horizon/test/unit/staking/allocation/close.t.sol | 2 +- packages/horizon/test/unit/staking/allocation/collect.t.sol | 2 +- packages/horizon/test/unit/staking/delegation/addToPool.t.sol | 2 +- packages/horizon/test/unit/staking/delegation/delegate.t.sol | 2 +- .../horizon/test/unit/staking/delegation/legacyWithdraw.t.sol | 2 +- .../horizon/test/unit/staking/delegation/redelegate.t.sol | 2 +- .../horizon/test/unit/staking/delegation/undelegate.t.sol | 2 +- packages/horizon/test/unit/staking/delegation/withdraw.t.sol | 2 +- .../horizon/test/unit/staking/governance/governance.t.sol | 2 +- packages/horizon/test/unit/staking/operator/locked.t.sol | 2 +- packages/horizon/test/unit/staking/operator/operator.t.sol | 2 +- .../horizon/test/unit/staking/provision/deprovision.t.sol | 2 +- packages/horizon/test/unit/staking/provision/locked.t.sol | 2 +- packages/horizon/test/unit/staking/provision/parameters.t.sol | 2 +- packages/horizon/test/unit/staking/provision/provision.t.sol | 2 +- .../horizon/test/unit/staking/provision/reprovision.t.sol | 2 +- packages/horizon/test/unit/staking/provision/thaw.t.sol | 2 +- .../test/unit/staking/serviceProvider/serviceProvider.t.sol | 2 +- packages/horizon/test/unit/staking/slash/legacySlash.t.sol | 2 +- packages/horizon/test/unit/staking/slash/slash.t.sol | 2 +- packages/horizon/test/unit/staking/stake/stake.t.sol | 2 +- packages/horizon/test/unit/staking/stake/unstake.t.sol | 2 +- packages/horizon/test/unit/staking/stake/withdraw.t.sol | 2 +- packages/horizon/test/unit/utilities/Authorizable.t.sol | 2 +- packages/horizon/test/unit/utilities/GraphDirectory.t.sol | 2 +- .../test/unit/utilities/GraphDirectoryImplementation.sol | 2 +- packages/horizon/test/unit/utils/Bounder.t.sol | 2 +- packages/horizon/test/unit/utils/Constants.sol | 2 +- packages/horizon/test/unit/utils/Users.sol | 2 +- packages/horizon/test/unit/utils/Utils.sol | 2 +- packages/issuance/contracts/allocate/DirectAllocation.sol | 2 +- packages/issuance/contracts/allocate/IssuanceAllocator.sol | 2 +- packages/issuance/contracts/common/BaseUpgradeable.sol | 2 +- .../contracts/eligibility/RewardsEligibilityOracle.sol | 2 +- .../contracts/test/allocate/IssuanceAllocatorTestHarness.sol | 2 +- packages/issuance/foundry.toml | 2 +- packages/issuance/hardhat.base.config.ts | 2 +- packages/subgraph-service/contracts/DisputeManager.sol | 2 +- packages/subgraph-service/contracts/DisputeManagerStorage.sol | 2 +- packages/subgraph-service/contracts/SubgraphService.sol | 2 +- .../subgraph-service/contracts/SubgraphServiceStorage.sol | 2 +- packages/subgraph-service/contracts/libraries/Allocation.sol | 2 +- packages/subgraph-service/contracts/libraries/Attestation.sol | 2 +- .../subgraph-service/contracts/libraries/LegacyAllocation.sol | 2 +- .../contracts/utilities/AllocationManager.sol | 2 +- .../contracts/utilities/AllocationManagerStorage.sol | 2 +- .../contracts/utilities/AttestationManager.sol | 2 +- .../contracts/utilities/AttestationManagerStorage.sol | 2 +- packages/subgraph-service/contracts/utilities/Directory.sol | 2 +- packages/subgraph-service/hardhat.config.ts | 2 +- 126 files changed, 126 insertions(+), 126 deletions(-) rename docs/{ => archive}/CompilerUpgrade0833.md (100%) diff --git a/docs/CompilerUpgrade0833.md b/docs/archive/CompilerUpgrade0833.md similarity index 100% rename from docs/CompilerUpgrade0833.md rename to docs/archive/CompilerUpgrade0833.md diff --git a/packages/contracts/contracts/governance/Controller.sol b/packages/contracts/contracts/governance/Controller.sol index 3f289ca7d..af9c78bd8 100644 --- a/packages/contracts/contracts/governance/Controller.sol +++ b/packages/contracts/contracts/governance/Controller.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-indexed-events, gas-small-strings diff --git a/packages/contracts/contracts/governance/Governed.sol b/packages/contracts/contracts/governance/Governed.sol index d20df43a2..6a31cffea 100644 --- a/packages/contracts/contracts/governance/Governed.sol +++ b/packages/contracts/contracts/governance/Governed.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; /* solhint-disable gas-custom-errors */ // Cannot use custom errors with 0.7.6 diff --git a/packages/contracts/contracts/governance/Pausable.sol b/packages/contracts/contracts/governance/Pausable.sol index d7a1824f2..8f5614231 100644 --- a/packages/contracts/contracts/governance/Pausable.sol +++ b/packages/contracts/contracts/governance/Pausable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-indexed-events diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 0b223429c..ffae7877b 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.7.6; +pragma solidity ^0.7.6; pragma abicoder v2; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; diff --git a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol index 14a8061b0..6e8606b2b 100644 --- a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol +++ b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol @@ -5,7 +5,7 @@ // TODO: Re-enable and fix issues when publishing a new version // solhint-disable named-parameters-mapping -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; diff --git a/packages/contracts/contracts/tests/MockERC165.sol b/packages/contracts/contracts/tests/MockERC165.sol index 056493fd3..446c752a7 100644 --- a/packages/contracts/contracts/tests/MockERC165.sol +++ b/packages/contracts/contracts/tests/MockERC165.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.7.6; +pragma solidity ^0.7.6; import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol"; diff --git a/packages/contracts/contracts/tests/MockIssuanceAllocator.sol b/packages/contracts/contracts/tests/MockIssuanceAllocator.sol index 6113b8bc0..24e482a55 100644 --- a/packages/contracts/contracts/tests/MockIssuanceAllocator.sol +++ b/packages/contracts/contracts/tests/MockIssuanceAllocator.sol @@ -2,7 +2,7 @@ // solhint-disable gas-increment-by-one, gas-indexed-events, named-parameters-mapping, use-natspec -pragma solidity 0.7.6; +pragma solidity ^0.7.6; pragma abicoder v2; import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol"; diff --git a/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol b/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol index 6b13d4d76..03d26d9e6 100644 --- a/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol +++ b/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol @@ -2,7 +2,7 @@ // solhint-disable named-parameters-mapping -pragma solidity 0.7.6; +pragma solidity ^0.7.6; import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol"; diff --git a/packages/contracts/contracts/tests/MockSubgraphService.sol b/packages/contracts/contracts/tests/MockSubgraphService.sol index cdee9ab6a..1e355923b 100644 --- a/packages/contracts/contracts/tests/MockSubgraphService.sol +++ b/packages/contracts/contracts/tests/MockSubgraphService.sol @@ -2,7 +2,7 @@ // solhint-disable named-parameters-mapping -pragma solidity 0.7.6; +pragma solidity ^0.7.6; import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol"; diff --git a/packages/contracts/contracts/upgrades/GraphProxy.sol b/packages/contracts/contracts/upgrades/GraphProxy.sol index 65216a4d7..624c3a650 100644 --- a/packages/contracts/contracts/upgrades/GraphProxy.sol +++ b/packages/contracts/contracts/upgrades/GraphProxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-small-strings diff --git a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol index e72bf3626..e603a6a50 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; /* solhint-disable gas-custom-errors */ // Cannot use custom errors with 0.7.6 diff --git a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol index 4c3d2e4de..d550d18f0 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; /* solhint-disable gas-custom-errors */ // Cannot use custom errors with 0.7.6 diff --git a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol index 466084fba..a6cc7b8c6 100644 --- a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol +++ b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; /* solhint-disable gas-custom-errors */ // Cannot use custom errors with 0.7.6 diff --git a/packages/contracts/contracts/utils/TokenUtils.sol b/packages/contracts/contracts/utils/TokenUtils.sol index 10c244e26..f4c0f58f5 100644 --- a/packages/contracts/contracts/utils/TokenUtils.sol +++ b/packages/contracts/contracts/utils/TokenUtils.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.7.6 || 0.8.27 || 0.8.33; +pragma solidity ^0.7.6 || ^0.8.27; /* solhint-disable gas-custom-errors */ // Cannot use custom errors with 0.7.6 diff --git a/packages/deployment/lib/issuance-deploy-utils.ts b/packages/deployment/lib/issuance-deploy-utils.ts index 4cf41496b..bd1b5f486 100644 --- a/packages/deployment/lib/issuance-deploy-utils.ts +++ b/packages/deployment/lib/issuance-deploy-utils.ts @@ -358,7 +358,7 @@ async function deployProxyWithOwnImpl( // Deploy OZ v5 TransparentUpgradeableProxy // Constructor: (address _logic, address initialOwner, bytes memory _data) // The proxy creates its own ProxyAdmin owned by initialOwner (governor) - // Use issuance-compiled proxy artifact (0.8.33) for consistent verification + // Use issuance-compiled proxy artifact (0.8.34) for consistent verification const proxyArtifact = loadTransparentProxyArtifact() const proxyResult = await deployFn( `${contract.name}_Proxy`, @@ -447,7 +447,7 @@ async function deployProxyWithSharedImpl( // Deploy OZ v5 TransparentUpgradeableProxy // Constructor: (address _logic, address initialOwner, bytes memory _data) - // Use issuance-compiled proxy artifact (0.8.33) for consistent verification + // Use issuance-compiled proxy artifact (0.8.34) for consistent verification const proxyArtifact = loadTransparentProxyArtifact() const proxyResult = await deployFn( `${contract.name}_Proxy`, diff --git a/packages/horizon/contracts/data-service/DataService.sol b/packages/horizon/contracts/data-service/DataService.sol index 8206f4924..ccdec7151 100644 --- a/packages/horizon/contracts/data-service/DataService.sol +++ b/packages/horizon/contracts/data-service/DataService.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IDataService } from "@graphprotocol/interfaces/contracts/data-service/IDataService.sol"; diff --git a/packages/horizon/contracts/data-service/DataServiceStorage.sol b/packages/horizon/contracts/data-service/DataServiceStorage.sol index 3ce552a7f..4ce5a7f20 100644 --- a/packages/horizon/contracts/data-service/DataServiceStorage.sol +++ b/packages/horizon/contracts/data-service/DataServiceStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; /** * @title DataServiceStorage diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol index 0f8cf3653..fd2bbd57f 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IDataServiceFees } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceFees.sol"; import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol"; diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol index 384149201..b9a5253b6 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IDataServiceFees } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceFees.sol"; diff --git a/packages/horizon/contracts/data-service/extensions/DataServicePausable.sol b/packages/horizon/contracts/data-service/extensions/DataServicePausable.sol index 7d0c8c522..8eed40165 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServicePausable.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServicePausable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IDataServicePausable } from "@graphprotocol/interfaces/contracts/data-service/IDataServicePausable.sol"; diff --git a/packages/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol b/packages/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol index 6dc2433ce..4770a9375 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IDataServicePausable } from "@graphprotocol/interfaces/contracts/data-service/IDataServicePausable.sol"; diff --git a/packages/horizon/contracts/data-service/libraries/ProvisionTracker.sol b/packages/horizon/contracts/data-service/libraries/ProvisionTracker.sol index 8f7ddff8d..d52bf13ad 100644 --- a/packages/horizon/contracts/data-service/libraries/ProvisionTracker.sol +++ b/packages/horizon/contracts/data-service/libraries/ProvisionTracker.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol index ec0be49c3..bdfae747a 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-indexed-events diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManagerStorage.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManagerStorage.sol index 02631d866..dbfe94cc8 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManagerStorage.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManagerStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; /** * @title Storage layout for the {ProvisionManager} helper contract. diff --git a/packages/horizon/contracts/libraries/LibFixedMath.sol b/packages/horizon/contracts/libraries/LibFixedMath.sol index f248a513d..4b31d1ef3 100644 --- a/packages/horizon/contracts/libraries/LibFixedMath.sol +++ b/packages/horizon/contracts/libraries/LibFixedMath.sol @@ -18,7 +18,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable function-max-lines, gas-strict-inequalities diff --git a/packages/horizon/contracts/libraries/LinkedList.sol b/packages/horizon/contracts/libraries/LinkedList.sol index 24e5610a0..893ea4a24 100644 --- a/packages/horizon/contracts/libraries/LinkedList.sol +++ b/packages/horizon/contracts/libraries/LinkedList.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-increment-by-one, gas-strict-inequalities diff --git a/packages/horizon/contracts/libraries/MathUtils.sol b/packages/horizon/contracts/libraries/MathUtils.sol index ec8cc8161..a1822df61 100644 --- a/packages/horizon/contracts/libraries/MathUtils.sol +++ b/packages/horizon/contracts/libraries/MathUtils.sol @@ -3,7 +3,7 @@ // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; /** * @title MathUtils Library diff --git a/packages/horizon/contracts/libraries/PPMMath.sol b/packages/horizon/contracts/libraries/PPMMath.sol index a3108d88b..75448a6d0 100644 --- a/packages/horizon/contracts/libraries/PPMMath.sol +++ b/packages/horizon/contracts/libraries/PPMMath.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/horizon/contracts/libraries/UintRange.sol b/packages/horizon/contracts/libraries/UintRange.sol index c96222464..3783b95ea 100644 --- a/packages/horizon/contracts/libraries/UintRange.sol +++ b/packages/horizon/contracts/libraries/UintRange.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/horizon/contracts/payments/GraphPayments.sol b/packages/horizon/contracts/payments/GraphPayments.sol index 276ce2100..ed83d4b3c 100644 --- a/packages/horizon/contracts/payments/GraphPayments.sol +++ b/packages/horizon/contracts/payments/GraphPayments.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable function-max-lines diff --git a/packages/horizon/contracts/payments/PaymentsEscrow.sol b/packages/horizon/contracts/payments/PaymentsEscrow.sol index 6af296e42..edf98627f 100644 --- a/packages/horizon/contracts/payments/PaymentsEscrow.sol +++ b/packages/horizon/contracts/payments/PaymentsEscrow.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol index 9040219fc..8b8a161ee 100644 --- a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol +++ b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-small-strings diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 7040ac343..f77761483 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -5,7 +5,7 @@ // solhint-disable gas-increment-by-one // solhint-disable function-max-lines -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/contracts/staking/HorizonStakingBase.sol b/packages/horizon/contracts/staking/HorizonStakingBase.sol index 615de4994..f8ae1fa18 100644 --- a/packages/horizon/contracts/staking/HorizonStakingBase.sol +++ b/packages/horizon/contracts/staking/HorizonStakingBase.sol @@ -3,7 +3,7 @@ // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { IHorizonStakingBase } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol"; diff --git a/packages/horizon/contracts/staking/HorizonStakingExtension.sol b/packages/horizon/contracts/staking/HorizonStakingExtension.sol index 3258381b2..7046c0473 100644 --- a/packages/horizon/contracts/staking/HorizonStakingExtension.sol +++ b/packages/horizon/contracts/staking/HorizonStakingExtension.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable function-max-lines, gas-strict-inequalities diff --git a/packages/horizon/contracts/staking/HorizonStakingStorage.sol b/packages/horizon/contracts/staking/HorizonStakingStorage.sol index 1469d27a2..92c769a42 100644 --- a/packages/horizon/contracts/staking/HorizonStakingStorage.sol +++ b/packages/horizon/contracts/staking/HorizonStakingStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // forge-lint: disable-start(mixed-case-variable) diff --git a/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol b/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol index 9e2544533..e06706139 100644 --- a/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol +++ b/packages/horizon/contracts/staking/libraries/ExponentialRebates.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // forge-lint: disable-start(unsafe-typecast) diff --git a/packages/horizon/contracts/staking/utilities/Managed.sol b/packages/horizon/contracts/staking/utilities/Managed.sol index 8839912f5..8efec4711 100644 --- a/packages/horizon/contracts/staking/utilities/Managed.sol +++ b/packages/horizon/contracts/staking/utilities/Managed.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { GraphDirectory } from "../../utilities/GraphDirectory.sol"; diff --git a/packages/horizon/contracts/utilities/Authorizable.sol b/packages/horizon/contracts/utilities/Authorizable.sol index 9cbd41672..d48d2e1a3 100644 --- a/packages/horizon/contracts/utilities/Authorizable.sol +++ b/packages/horizon/contracts/utilities/Authorizable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/horizon/contracts/utilities/GraphDirectory.sol b/packages/horizon/contracts/utilities/GraphDirectory.sol index 0534ca3c7..2dd8cdec5 100644 --- a/packages/horizon/contracts/utilities/GraphDirectory.sol +++ b/packages/horizon/contracts/utilities/GraphDirectory.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27 || 0.8.33; +pragma solidity ^0.8.27; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; diff --git a/packages/horizon/test/unit/GraphBase.t.sol b/packages/horizon/test/unit/GraphBase.t.sol index 7fa450295..4aa5b66f1 100644 --- a/packages/horizon/test/unit/GraphBase.t.sol +++ b/packages/horizon/test/unit/GraphBase.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol"; import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol"; diff --git a/packages/horizon/test/unit/data-service/DataService.t.sol b/packages/horizon/test/unit/data-service/DataService.t.sol index 209362767..a7fb52d58 100644 --- a/packages/horizon/test/unit/data-service/DataService.t.sol +++ b/packages/horizon/test/unit/data-service/DataService.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { HorizonStakingSharedTest } from "../shared/horizon-staking/HorizonStakingShared.t.sol"; diff --git a/packages/horizon/test/unit/data-service/DataServiceUpgradeable.t.sol b/packages/horizon/test/unit/data-service/DataServiceUpgradeable.t.sol index a4501242b..ac2be13ea 100644 --- a/packages/horizon/test/unit/data-service/DataServiceUpgradeable.t.sol +++ b/packages/horizon/test/unit/data-service/DataServiceUpgradeable.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphBaseTest } from "../GraphBase.t.sol"; import { DataServiceBaseUpgradeable } from "./implementations/DataServiceBaseUpgradeable.sol"; diff --git a/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol b/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol index a2ae10653..28f74003f 100644 --- a/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol +++ b/packages/horizon/test/unit/data-service/extensions/DataServiceFees.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; import { DataServiceImpFees } from "../implementations/DataServiceImpFees.sol"; diff --git a/packages/horizon/test/unit/data-service/extensions/DataServicePausable.t.sol b/packages/horizon/test/unit/data-service/extensions/DataServicePausable.t.sol index 47912797b..97c6bb100 100644 --- a/packages/horizon/test/unit/data-service/extensions/DataServicePausable.t.sol +++ b/packages/horizon/test/unit/data-service/extensions/DataServicePausable.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; import { DataServiceImpPausable } from "../implementations/DataServiceImpPausable.sol"; diff --git a/packages/horizon/test/unit/data-service/extensions/DataServicePausableUpgradeable.t.sol b/packages/horizon/test/unit/data-service/extensions/DataServicePausableUpgradeable.t.sol index d5413ed5b..f85569151 100644 --- a/packages/horizon/test/unit/data-service/extensions/DataServicePausableUpgradeable.t.sol +++ b/packages/horizon/test/unit/data-service/extensions/DataServicePausableUpgradeable.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphBaseTest } from "../../GraphBase.t.sol"; import { DataServiceImpPausableUpgradeable } from "../implementations/DataServiceImpPausableUpgradeable.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceBase.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceBase.sol index b58bbc5e0..d5286be57 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceBase.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceBase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataService } from "../../../../contracts/data-service/DataService.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceBaseUpgradeable.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceBaseUpgradeable.sol index d328089f9..b0057e941 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceBaseUpgradeable.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceBaseUpgradeable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataService } from "../../../../contracts/data-service/DataService.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceImpFees.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceImpFees.sol index 85c51465f..85fc23b25 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceImpFees.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceImpFees.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataService } from "../../../../contracts/data-service/DataService.sol"; import { DataServiceFees } from "../../../../contracts/data-service/extensions/DataServiceFees.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausable.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausable.sol index bba7de566..9f15584d5 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausable.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataService } from "../../../../contracts/data-service/DataService.sol"; import { DataServicePausable } from "../../../../contracts/data-service/extensions/DataServicePausable.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausableUpgradeable.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausableUpgradeable.sol index 71453fd19..32fb97b22 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausableUpgradeable.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceImpPausableUpgradeable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataService } from "../../../../contracts/data-service/DataService.sol"; import { DataServicePausableUpgradeable } from "../../../../contracts/data-service/extensions/DataServicePausableUpgradeable.sol"; diff --git a/packages/horizon/test/unit/data-service/implementations/DataServiceOverride.sol b/packages/horizon/test/unit/data-service/implementations/DataServiceOverride.sol index c5d50ca74..6af527271 100644 --- a/packages/horizon/test/unit/data-service/implementations/DataServiceOverride.sol +++ b/packages/horizon/test/unit/data-service/implementations/DataServiceOverride.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { DataServiceBase } from "./DataServiceBase.sol"; diff --git a/packages/horizon/test/unit/data-service/libraries/ProvisionTracker.t.sol b/packages/horizon/test/unit/data-service/libraries/ProvisionTracker.t.sol index d3424dfc5..d56d770b0 100644 --- a/packages/horizon/test/unit/data-service/libraries/ProvisionTracker.t.sol +++ b/packages/horizon/test/unit/data-service/libraries/ProvisionTracker.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; import { ProvisionTrackerImplementation } from "./ProvisionTrackerImplementation.sol"; diff --git a/packages/horizon/test/unit/data-service/libraries/ProvisionTrackerImplementation.sol b/packages/horizon/test/unit/data-service/libraries/ProvisionTrackerImplementation.sol index abb525b91..7722df836 100644 --- a/packages/horizon/test/unit/data-service/libraries/ProvisionTrackerImplementation.sol +++ b/packages/horizon/test/unit/data-service/libraries/ProvisionTrackerImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; contract ProvisionTrackerImplementation { mapping(address => uint256) public provisionTracker; diff --git a/packages/horizon/test/unit/escrow/GraphEscrow.t.sol b/packages/horizon/test/unit/escrow/GraphEscrow.t.sol index a0c3fbad1..3f88b468c 100644 --- a/packages/horizon/test/unit/escrow/GraphEscrow.t.sol +++ b/packages/horizon/test/unit/escrow/GraphEscrow.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/escrow/collect.t.sol b/packages/horizon/test/unit/escrow/collect.t.sol index bbd35922c..9d229e1ab 100644 --- a/packages/horizon/test/unit/escrow/collect.t.sol +++ b/packages/horizon/test/unit/escrow/collect.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; diff --git a/packages/horizon/test/unit/escrow/deposit.t.sol b/packages/horizon/test/unit/escrow/deposit.t.sol index 3f7c254c0..0f1fe450e 100644 --- a/packages/horizon/test/unit/escrow/deposit.t.sol +++ b/packages/horizon/test/unit/escrow/deposit.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; diff --git a/packages/horizon/test/unit/escrow/getters.t.sol b/packages/horizon/test/unit/escrow/getters.t.sol index 23f700036..770b8b7c3 100644 --- a/packages/horizon/test/unit/escrow/getters.t.sol +++ b/packages/horizon/test/unit/escrow/getters.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/escrow/paused.t.sol b/packages/horizon/test/unit/escrow/paused.t.sol index ea3fce631..010268c80 100644 --- a/packages/horizon/test/unit/escrow/paused.t.sol +++ b/packages/horizon/test/unit/escrow/paused.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; diff --git a/packages/horizon/test/unit/escrow/thaw.t.sol b/packages/horizon/test/unit/escrow/thaw.t.sol index 0b71e6d1b..ca8569176 100644 --- a/packages/horizon/test/unit/escrow/thaw.t.sol +++ b/packages/horizon/test/unit/escrow/thaw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; diff --git a/packages/horizon/test/unit/escrow/withdraw.t.sol b/packages/horizon/test/unit/escrow/withdraw.t.sol index bcc116fd1..18a000af4 100644 --- a/packages/horizon/test/unit/escrow/withdraw.t.sol +++ b/packages/horizon/test/unit/escrow/withdraw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; diff --git a/packages/horizon/test/unit/libraries/LinkedList.t.sol b/packages/horizon/test/unit/libraries/LinkedList.t.sol index bdf902edf..e55469d25 100644 --- a/packages/horizon/test/unit/libraries/LinkedList.t.sol +++ b/packages/horizon/test/unit/libraries/LinkedList.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { LinkedList } from "../../../contracts/libraries/LinkedList.sol"; diff --git a/packages/horizon/test/unit/libraries/ListImplementation.sol b/packages/horizon/test/unit/libraries/ListImplementation.sol index dad859f59..72577a4d7 100644 --- a/packages/horizon/test/unit/libraries/ListImplementation.sol +++ b/packages/horizon/test/unit/libraries/ListImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol"; import { LinkedList } from "../../../contracts/libraries/LinkedList.sol"; diff --git a/packages/horizon/test/unit/libraries/PPMMath.t.sol b/packages/horizon/test/unit/libraries/PPMMath.t.sol index c760cab06..bed8438a1 100644 --- a/packages/horizon/test/unit/libraries/PPMMath.t.sol +++ b/packages/horizon/test/unit/libraries/PPMMath.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { PPMMath } from "../../../contracts/libraries/PPMMath.sol"; diff --git a/packages/horizon/test/unit/payments/GraphPayments.t.sol b/packages/horizon/test/unit/payments/GraphPayments.t.sol index 62d739ba3..d4bf17153 100644 --- a/packages/horizon/test/unit/payments/GraphPayments.t.sol +++ b/packages/horizon/test/unit/payments/GraphPayments.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol index b8e569574..bd022f1d3 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import { IGraphTallyCollector } from "@graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/collect/collect.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/collect/collect.t.sol index 2c15a930d..e9c25d6cc 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/collect/collect.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/collect/collect.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphTallyCollector } from "@graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/signer/authorizeSigner.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/signer/authorizeSigner.t.sol index cbc3f2960..948a9a1c2 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/signer/authorizeSigner.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/signer/authorizeSigner.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IAuthorizable } from "@graphprotocol/interfaces/contracts/horizon/IAuthorizable.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/signer/cancelThawSigner.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/signer/cancelThawSigner.t.sol index d117cfb95..b3b1cbeb6 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/signer/cancelThawSigner.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/signer/cancelThawSigner.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IAuthorizable } from "@graphprotocol/interfaces/contracts/horizon/IAuthorizable.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/signer/revokeSigner.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/signer/revokeSigner.t.sol index 5d987cb9c..6e6b92dfb 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/signer/revokeSigner.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/signer/revokeSigner.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IAuthorizable } from "@graphprotocol/interfaces/contracts/horizon/IAuthorizable.sol"; diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/signer/thawSigner.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/signer/thawSigner.t.sol index 781551f61..bf6269ee6 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/signer/thawSigner.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/signer/thawSigner.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IAuthorizable } from "@graphprotocol/interfaces/contracts/horizon/IAuthorizable.sol"; diff --git a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol index 27b4aeca9..5861b9f27 100644 --- a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphBaseTest } from "../../GraphBase.t.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/shared/payments-escrow/PaymentsEscrowShared.t.sol b/packages/horizon/test/unit/shared/payments-escrow/PaymentsEscrowShared.t.sol index ca62aa02b..8e51aed9f 100644 --- a/packages/horizon/test/unit/shared/payments-escrow/PaymentsEscrowShared.t.sol +++ b/packages/horizon/test/unit/shared/payments-escrow/PaymentsEscrowShared.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { GraphBaseTest } from "../../GraphBase.t.sol"; diff --git a/packages/horizon/test/unit/staking/HorizonStaking.t.sol b/packages/horizon/test/unit/staking/HorizonStaking.t.sol index 8046723f7..256fce859 100644 --- a/packages/horizon/test/unit/staking/HorizonStaking.t.sol +++ b/packages/horizon/test/unit/staking/HorizonStaking.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { stdStorage, StdStorage } from "forge-std/Test.sol"; diff --git a/packages/horizon/test/unit/staking/allocation/allocation.t.sol b/packages/horizon/test/unit/staking/allocation/allocation.t.sol index 2b7349817..e4b0e22c3 100644 --- a/packages/horizon/test/unit/staking/allocation/allocation.t.sol +++ b/packages/horizon/test/unit/staking/allocation/allocation.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; diff --git a/packages/horizon/test/unit/staking/allocation/close.t.sol b/packages/horizon/test/unit/staking/allocation/close.t.sol index 41eddfe0f..e5d222b59 100644 --- a/packages/horizon/test/unit/staking/allocation/close.t.sol +++ b/packages/horizon/test/unit/staking/allocation/close.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; import { PPMMath } from "../../../../contracts/libraries/PPMMath.sol"; diff --git a/packages/horizon/test/unit/staking/allocation/collect.t.sol b/packages/horizon/test/unit/staking/allocation/collect.t.sol index a05c55220..20fde8e91 100644 --- a/packages/horizon/test/unit/staking/allocation/collect.t.sol +++ b/packages/horizon/test/unit/staking/allocation/collect.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { console } from "forge-std/console.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/addToPool.t.sol b/packages/horizon/test/unit/staking/delegation/addToPool.t.sol index 5c61b1ffc..46a86b096 100644 --- a/packages/horizon/test/unit/staking/delegation/addToPool.t.sol +++ b/packages/horizon/test/unit/staking/delegation/addToPool.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/delegate.t.sol b/packages/horizon/test/unit/staking/delegation/delegate.t.sol index 5395a8464..2209b2dff 100644 --- a/packages/horizon/test/unit/staking/delegation/delegate.t.sol +++ b/packages/horizon/test/unit/staking/delegation/delegate.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol b/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol index 59acde904..0c5db17f5 100644 --- a/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol +++ b/packages/horizon/test/unit/staking/delegation/legacyWithdraw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/redelegate.t.sol b/packages/horizon/test/unit/staking/delegation/redelegate.t.sol index 710586785..a8cd04a59 100644 --- a/packages/horizon/test/unit/staking/delegation/redelegate.t.sol +++ b/packages/horizon/test/unit/staking/delegation/redelegate.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/undelegate.t.sol b/packages/horizon/test/unit/staking/delegation/undelegate.t.sol index 15fa5c4c1..faa8d4f30 100644 --- a/packages/horizon/test/unit/staking/delegation/undelegate.t.sol +++ b/packages/horizon/test/unit/staking/delegation/undelegate.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/staking/delegation/withdraw.t.sol b/packages/horizon/test/unit/staking/delegation/withdraw.t.sol index 31155cec2..e50c2ff66 100644 --- a/packages/horizon/test/unit/staking/delegation/withdraw.t.sol +++ b/packages/horizon/test/unit/staking/delegation/withdraw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; diff --git a/packages/horizon/test/unit/staking/governance/governance.t.sol b/packages/horizon/test/unit/staking/governance/governance.t.sol index cc2a54465..068dbee6b 100644 --- a/packages/horizon/test/unit/staking/governance/governance.t.sol +++ b/packages/horizon/test/unit/staking/governance/governance.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/operator/locked.t.sol b/packages/horizon/test/unit/staking/operator/locked.t.sol index 474407692..83f753348 100644 --- a/packages/horizon/test/unit/staking/operator/locked.t.sol +++ b/packages/horizon/test/unit/staking/operator/locked.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/operator/operator.t.sol b/packages/horizon/test/unit/staking/operator/operator.t.sol index 672269aab..b52b9c6a3 100644 --- a/packages/horizon/test/unit/staking/operator/operator.t.sol +++ b/packages/horizon/test/unit/staking/operator/operator.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/provision/deprovision.t.sol b/packages/horizon/test/unit/staking/provision/deprovision.t.sol index 51725b111..c37410b8c 100644 --- a/packages/horizon/test/unit/staking/provision/deprovision.t.sol +++ b/packages/horizon/test/unit/staking/provision/deprovision.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/provision/locked.t.sol b/packages/horizon/test/unit/staking/provision/locked.t.sol index f7f95c6ac..f48ca384d 100644 --- a/packages/horizon/test/unit/staking/provision/locked.t.sol +++ b/packages/horizon/test/unit/staking/provision/locked.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/provision/parameters.t.sol b/packages/horizon/test/unit/staking/provision/parameters.t.sol index 3c3c745de..9a723e1c3 100644 --- a/packages/horizon/test/unit/staking/provision/parameters.t.sol +++ b/packages/horizon/test/unit/staking/provision/parameters.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/staking/provision/provision.t.sol b/packages/horizon/test/unit/staking/provision/provision.t.sol index 5149e8cf6..7862dd60c 100644 --- a/packages/horizon/test/unit/staking/provision/provision.t.sol +++ b/packages/horizon/test/unit/staking/provision/provision.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/provision/reprovision.t.sol b/packages/horizon/test/unit/staking/provision/reprovision.t.sol index 377dfa35d..f90ae56fa 100644 --- a/packages/horizon/test/unit/staking/provision/reprovision.t.sol +++ b/packages/horizon/test/unit/staking/provision/reprovision.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/provision/thaw.t.sol b/packages/horizon/test/unit/staking/provision/thaw.t.sol index 5669189e9..6703f330c 100644 --- a/packages/horizon/test/unit/staking/provision/thaw.t.sol +++ b/packages/horizon/test/unit/staking/provision/thaw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol b/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol index 651fd662f..84008c01f 100644 --- a/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol +++ b/packages/horizon/test/unit/staking/serviceProvider/serviceProvider.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; diff --git a/packages/horizon/test/unit/staking/slash/legacySlash.t.sol b/packages/horizon/test/unit/staking/slash/legacySlash.t.sol index 4e4a9bdd3..0e1724ecb 100644 --- a/packages/horizon/test/unit/staking/slash/legacySlash.t.sol +++ b/packages/horizon/test/unit/staking/slash/legacySlash.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingExtension } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingExtension.sol"; diff --git a/packages/horizon/test/unit/staking/slash/slash.t.sol b/packages/horizon/test/unit/staking/slash/slash.t.sol index 4572ed93f..cba33ae8a 100644 --- a/packages/horizon/test/unit/staking/slash/slash.t.sol +++ b/packages/horizon/test/unit/staking/slash/slash.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/staking/stake/stake.t.sol b/packages/horizon/test/unit/staking/stake/stake.t.sol index ea1425de0..db00ad7ec 100644 --- a/packages/horizon/test/unit/staking/stake/stake.t.sol +++ b/packages/horizon/test/unit/staking/stake/stake.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/stake/unstake.t.sol b/packages/horizon/test/unit/staking/stake/unstake.t.sol index 54803cc60..98d508e2a 100644 --- a/packages/horizon/test/unit/staking/stake/unstake.t.sol +++ b/packages/horizon/test/unit/staking/stake/unstake.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; diff --git a/packages/horizon/test/unit/staking/stake/withdraw.t.sol b/packages/horizon/test/unit/staking/stake/withdraw.t.sol index 2d7b89382..4cd6666b9 100644 --- a/packages/horizon/test/unit/staking/stake/withdraw.t.sol +++ b/packages/horizon/test/unit/staking/stake/withdraw.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingMain } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol"; diff --git a/packages/horizon/test/unit/utilities/Authorizable.t.sol b/packages/horizon/test/unit/utilities/Authorizable.t.sol index 33713c436..420cd01ff 100644 --- a/packages/horizon/test/unit/utilities/Authorizable.t.sol +++ b/packages/horizon/test/unit/utilities/Authorizable.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; diff --git a/packages/horizon/test/unit/utilities/GraphDirectory.t.sol b/packages/horizon/test/unit/utilities/GraphDirectory.t.sol index 2eea04b73..a0b22f6bb 100644 --- a/packages/horizon/test/unit/utilities/GraphDirectory.t.sol +++ b/packages/horizon/test/unit/utilities/GraphDirectory.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { GraphBaseTest } from "../GraphBase.t.sol"; import { GraphDirectory } from "./../../../contracts/utilities/GraphDirectory.sol"; diff --git a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol index 4a88bf0cd..80c7d231d 100644 --- a/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol +++ b/packages/horizon/test/unit/utilities/GraphDirectoryImplementation.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; diff --git a/packages/horizon/test/unit/utils/Bounder.t.sol b/packages/horizon/test/unit/utils/Bounder.t.sol index 44e977f57..82ba2ff15 100644 --- a/packages/horizon/test/unit/utils/Bounder.t.sol +++ b/packages/horizon/test/unit/utils/Bounder.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; diff --git a/packages/horizon/test/unit/utils/Constants.sol b/packages/horizon/test/unit/utils/Constants.sol index 51b882118..036ca43a2 100644 --- a/packages/horizon/test/unit/utils/Constants.sol +++ b/packages/horizon/test/unit/utils/Constants.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; abstract contract Constants { uint32 internal constant MAX_PPM = 1000000; // 100% in parts per million diff --git a/packages/horizon/test/unit/utils/Users.sol b/packages/horizon/test/unit/utils/Users.sol index 6213e4e82..56f67396f 100644 --- a/packages/horizon/test/unit/utils/Users.sol +++ b/packages/horizon/test/unit/utils/Users.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; struct Users { address governor; diff --git a/packages/horizon/test/unit/utils/Utils.sol b/packages/horizon/test/unit/utils/Utils.sol index 741c7367f..45da9df8c 100644 --- a/packages/horizon/test/unit/utils/Utils.sol +++ b/packages/horizon/test/unit/utils/Utils.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; diff --git a/packages/issuance/contracts/allocate/DirectAllocation.sol b/packages/issuance/contracts/allocate/DirectAllocation.sol index 4c048acf2..799755256 100644 --- a/packages/issuance/contracts/allocate/DirectAllocation.sol +++ b/packages/issuance/contracts/allocate/DirectAllocation.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; diff --git a/packages/issuance/contracts/allocate/IssuanceAllocator.sol b/packages/issuance/contracts/allocate/IssuanceAllocator.sol index 4b8f15291..83456daf6 100644 --- a/packages/issuance/contracts/allocate/IssuanceAllocator.sol +++ b/packages/issuance/contracts/allocate/IssuanceAllocator.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { TargetIssuancePerBlock, diff --git a/packages/issuance/contracts/common/BaseUpgradeable.sol b/packages/issuance/contracts/common/BaseUpgradeable.sol index 771d6f0a1..2141a8e20 100644 --- a/packages/issuance/contracts/common/BaseUpgradeable.sol +++ b/packages/issuance/contracts/common/BaseUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol index bd2591a44..06ed29e8d 100644 --- a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; import { IRewardsEligibilityAdministration } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol"; diff --git a/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol b/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol index 586c6e677..f9b037682 100644 --- a/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol +++ b/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IssuanceAllocator } from "../../allocate/IssuanceAllocator.sol"; diff --git a/packages/issuance/foundry.toml b/packages/issuance/foundry.toml index 38d166efd..cfd6d9c04 100644 --- a/packages/issuance/foundry.toml +++ b/packages/issuance/foundry.toml @@ -13,7 +13,7 @@ fs_permissions = [{ access = "read", path = "./" }] optimizer = true optimizer_runs = 100 via_ir = true -solc_version = '0.8.33' +solc_version = '0.8.34' evm_version = 'cancun' # Exclude test files from coverage reports diff --git a/packages/issuance/hardhat.base.config.ts b/packages/issuance/hardhat.base.config.ts index 5ae490a66..d31b7d48b 100644 --- a/packages/issuance/hardhat.base.config.ts +++ b/packages/issuance/hardhat.base.config.ts @@ -7,7 +7,7 @@ const ARBITRUM_SEPOLIA_RPC = process.env.ARBITRUM_SEPOLIA_RPC || 'https://sepoli // Issuance-specific Solidity configuration with Cancun EVM version export const issuanceSolidityConfig = { - version: '0.8.33', + version: '0.8.34', settings: { optimizer: { enabled: true, diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 130182e4b..6cbd73a22 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable function-max-lines, gas-strict-inequalities diff --git a/packages/subgraph-service/contracts/DisputeManagerStorage.sol b/packages/subgraph-service/contracts/DisputeManagerStorage.sol index cb0766023..5c2295b73 100644 --- a/packages/subgraph-service/contracts/DisputeManagerStorage.sol +++ b/packages/subgraph-service/contracts/DisputeManagerStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IDisputeManager } from "@graphprotocol/interfaces/contracts/subgraph-service/IDisputeManager.sol"; import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 2eb8e0a9f..26e73084f 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; diff --git a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol index 67accbb5a..15fc33acc 100644 --- a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol +++ b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; diff --git a/packages/subgraph-service/contracts/libraries/Allocation.sol b/packages/subgraph-service/contracts/libraries/Allocation.sol index d5018e482..404dc8cec 100644 --- a/packages/subgraph-service/contracts/libraries/Allocation.sol +++ b/packages/subgraph-service/contracts/libraries/Allocation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // forge-lint: disable-start(mixed-case-variable, mixed-case-function) diff --git a/packages/subgraph-service/contracts/libraries/Attestation.sol b/packages/subgraph-service/contracts/libraries/Attestation.sol index 77c3a3fc2..54bd2c2f2 100644 --- a/packages/subgraph-service/contracts/libraries/Attestation.sol +++ b/packages/subgraph-service/contracts/libraries/Attestation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities diff --git a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol index 97b2be1dc..47f04c3a9 100644 --- a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol +++ b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol"; diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index e78fbc6f8..cbfe5e663 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; diff --git a/packages/subgraph-service/contracts/utilities/AllocationManagerStorage.sol b/packages/subgraph-service/contracts/utilities/AllocationManagerStorage.sol index 053b32a70..8f3460876 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManagerStorage.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManagerStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol"; import { IAllocationManager } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocationManager.sol"; diff --git a/packages/subgraph-service/contracts/utilities/AttestationManager.sol b/packages/subgraph-service/contracts/utilities/AttestationManager.sol index 4ba57e639..c050786c0 100644 --- a/packages/subgraph-service/contracts/utilities/AttestationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AttestationManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-small-strings diff --git a/packages/subgraph-service/contracts/utilities/AttestationManagerStorage.sol b/packages/subgraph-service/contracts/utilities/AttestationManagerStorage.sol index 40f4c614c..2b7be6850 100644 --- a/packages/subgraph-service/contracts/utilities/AttestationManagerStorage.sol +++ b/packages/subgraph-service/contracts/utilities/AttestationManagerStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; /** * @title AttestationManagerStorage diff --git a/packages/subgraph-service/contracts/utilities/Directory.sol b/packages/subgraph-service/contracts/utilities/Directory.sol index 09d180a5d..0ba82a5b5 100644 --- a/packages/subgraph-service/contracts/utilities/Directory.sol +++ b/packages/subgraph-service/contracts/utilities/Directory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.33; +pragma solidity ^0.8.27; // TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-indexed-events diff --git a/packages/subgraph-service/hardhat.config.ts b/packages/subgraph-service/hardhat.config.ts index aca08e03c..f6f6b387e 100644 --- a/packages/subgraph-service/hardhat.config.ts +++ b/packages/subgraph-service/hardhat.config.ts @@ -19,7 +19,7 @@ const baseConfig = hardhatBaseConfig(require) const config: HardhatUserConfig = { ...baseConfig, solidity: { - version: '0.8.33', + version: '0.8.34', settings: { optimizer: { enabled: true, runs: 100 }, evmVersion: 'cancun', From f4451f18962a9e6203d70dc37e2f78d82d461edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 23 Feb 2026 17:16:13 -0300 Subject: [PATCH 039/157] feat: add back legacy allocation id collision check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/HorizonStaking.sol | 24 ++++ .../staking/HorizonStakingStorage.sol | 5 +- .../GraphTallyCollector.t.sol | 2 +- .../unit/staking/legacy/isAllocation.t.sol | 107 ++++++++++++++++++ .../horizon/internal/IHorizonStakingMain.sol | 9 ++ .../horizon/internal/IHorizonStakingTypes.sol | 38 +++++++ .../contracts/libraries/AllocationHandler.sol | 2 +- .../contracts/libraries/LegacyAllocation.sol | 9 +- .../subgraphService/SubgraphService.t.sol | 39 +++++++ .../subgraphService/allocation/start.t.sol | 5 +- .../subgraphService/collect/query/query.t.sol | 2 +- 11 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 packages/horizon/test/unit/staking/legacy/isAllocation.t.sol diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 588e06ecd..bd6ccef70 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -1170,6 +1170,30 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { } } + /// @inheritdoc IHorizonStakingMain + function isAllocation(address allocationID) external view override returns (bool) { + return _getLegacyAllocationState(allocationID) != LegacyAllocationState.Null; + } + + /** + * @notice Return the current state of a legacy allocation + * @param _allocationID Allocation identifier + * @return LegacyAllocationState enum with the state of the allocation + */ + function _getLegacyAllocationState(address _allocationID) private view returns (LegacyAllocationState) { + LegacyAllocation storage alloc = __DEPRECATED_allocations[_allocationID]; + + if (alloc.indexer == address(0)) { + return LegacyAllocationState.Null; + } + + if (alloc.createdAtEpoch != 0 && alloc.closedAtEpoch == 0) { + return LegacyAllocationState.Active; + } + + return LegacyAllocationState.Closed; + } + /** * @notice Determines the correct callback function for `deleteItem` based on the request type. * @param _requestType The type of thaw request (Provision or Delegation). diff --git a/packages/horizon/contracts/staking/HorizonStakingStorage.sol b/packages/horizon/contracts/staking/HorizonStakingStorage.sol index 21b8f58d4..c10ac5d29 100644 --- a/packages/horizon/contracts/staking/HorizonStakingStorage.sol +++ b/packages/horizon/contracts/staking/HorizonStakingStorage.sol @@ -63,8 +63,9 @@ abstract contract HorizonStakingV1Storage { mapping(address serviceProvider => IHorizonStakingTypes.ServiceProviderInternal details) internal _serviceProviders; /// @dev Allocation details. - /// Deprecated, now applied on the subgraph data service - mapping(address allocationId => bytes32 __DEPRECATED_allocation) internal __DEPRECATED_allocations; + /// Deprecated, now applied on the subgraph data service. + /// Kept for storage compatibility and to check for allocation id collisions. + mapping(address allocationId => IHorizonStakingTypes.LegacyAllocation allocation) internal __DEPRECATED_allocations; /// @dev Subgraph allocations, tracks the tokens allocated to a subgraph deployment /// Deprecated, now applied on the SubgraphService diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol index bd022f1d3..4b05992f3 100644 --- a/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol +++ b/packages/horizon/test/unit/payments/graph-tally-collector/GraphTallyCollector.t.sol @@ -42,7 +42,7 @@ contract GraphTallyTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { * HELPERS */ - function _getSignerProof(uint256 _proofDeadline, uint256 _signer) internal view returns (bytes memory) { + function _getSignerProof(uint256 _proofDeadline, uint256 _signer) internal returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); bytes32 messageHash = keccak256( abi.encodePacked( diff --git a/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol b/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol new file mode 100644 index 000000000..1f19ccc00 --- /dev/null +++ b/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; +import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; + +contract HorizonStakingIsAllocationTest is HorizonStakingSharedTest { + /* + * TESTS + */ + + function test_IsAllocation_ReturnsFalse_WhenAllocationDoesNotExist() public { + address nonExistentAllocationId = makeAddr("nonExistentAllocation"); + assertFalse(staking.isAllocation(nonExistentAllocationId)); + } + + function test_IsAllocation_ReturnsTrue_WhenActiveAllocationExists() public { + address allocationId = makeAddr("activeAllocation"); + + // Set up an active legacy allocation in storage + _setLegacyAllocationInStaking( + allocationId, + users.indexer, + bytes32("subgraphDeploymentId"), + 1000 ether, // tokens + 1, // createdAtEpoch + 0 // closedAtEpoch (0 = still active) + ); + + assertTrue(staking.isAllocation(allocationId)); + } + + function test_IsAllocation_ReturnsTrue_WhenClosedAllocationExists() public { + address allocationId = makeAddr("closedAllocation"); + + // Set up a closed legacy allocation in storage + _setLegacyAllocationInStaking( + allocationId, + users.indexer, + bytes32("subgraphDeploymentId"), + 1000 ether, // tokens + 1, // createdAtEpoch + 10 // closedAtEpoch (non-zero = closed) + ); + + assertTrue(staking.isAllocation(allocationId)); + } + + function test_IsAllocation_ReturnsFalse_WhenIndexerIsZeroAddress() public { + address allocationId = makeAddr("zeroIndexerAllocation"); + + // Set up an allocation with zero indexer (should be considered Null) + _setLegacyAllocationInStaking( + allocationId, + address(0), // indexer is zero + bytes32("subgraphDeploymentId"), + 1000 ether, + 1, + 0 + ); + + assertFalse(staking.isAllocation(allocationId)); + } + + /* + * HELPERS + */ + + /** + * @notice Sets a legacy allocation directly in HorizonStaking storage + * @dev The __DEPRECATED_allocations mapping is at storage slot 10 in HorizonStakingStorage + * The LegacyAllocation struct has the following layout: + * - slot 0: indexer (address) + * - slot 1: subgraphDeploymentID (bytes32) + * - slot 2: tokens (uint256) + * - slot 3: createdAtEpoch (uint256) + * - slot 4: closedAtEpoch (uint256) + * - slot 5: collectedFees (uint256) + * - slot 6: __DEPRECATED_effectiveAllocation (uint256) + * - slot 7: accRewardsPerAllocatedToken (uint256) + * - slot 8: distributedRebates (uint256) + */ + function _setLegacyAllocationInStaking( + address _allocationId, + address _indexer, + bytes32 _subgraphDeploymentId, + uint256 _tokens, + uint256 _createdAtEpoch, + uint256 _closedAtEpoch + ) internal { + // Storage slot for __DEPRECATED_allocations mapping in HorizonStaking + // Use `forge inspect HorizonStaking storage-layout` to verify + uint256 allocationsSlot = 15; + bytes32 allocationBaseSlot = keccak256(abi.encode(_allocationId, allocationsSlot)); + + // Set indexer (slot 0) + vm.store(address(staking), allocationBaseSlot, bytes32(uint256(uint160(_indexer)))); + // Set subgraphDeploymentID (slot 1) + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 1), _subgraphDeploymentId); + // Set tokens (slot 2) + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 2), bytes32(_tokens)); + // Set createdAtEpoch (slot 3) + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 3), bytes32(_createdAtEpoch)); + // Set closedAtEpoch (slot 4) + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 4), bytes32(_closedAtEpoch)); + } +} diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol index ddc595409..1c87fee1e 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingMain.sol @@ -978,4 +978,13 @@ interface IHorizonStakingMain { * @return The amount of tokens withdrawn */ function forceWithdrawDelegated(address serviceProvider, address delegator) external returns (uint256); + + /** + * @notice Return if allocationID is used. + * @dev This function is used to check for allocation id collisions with legacy allocations + * that were created before the Horizon upgrade. + * @param allocationID Address used as signer by the indexer for an allocation + * @return True if allocationID already used + */ + function isAllocation(address allocationID) external view returns (bool); } diff --git a/packages/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol b/packages/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol index e8fff211b..22cdb5b4b 100644 --- a/packages/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol +++ b/packages/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol @@ -200,4 +200,42 @@ interface IHorizonStakingTypes { uint256 tokensThawing; uint256 sharesThawing; } + + /** + * @notice Legacy allocation representation + * @dev Kept for storage compatibility and to check for allocation id collisions. + * @param indexer The indexer address + * @param subgraphDeploymentID The subgraph deployment ID + * @param tokens The amount of tokens allocated to the subgraph deployment + * @param createdAtEpoch The epoch when the allocation was created + * @param closedAtEpoch The epoch when the allocation was closed + * @param collectedFees The amount of collected fees for the allocation + * @param __DEPRECATED_effectiveAllocation Deprecated field + * @param accRewardsPerAllocatedToken Snapshot used for reward calculation + * @param distributedRebates The amount of collected rebates that have been rebated + */ + struct LegacyAllocation { + address indexer; + bytes32 subgraphDeploymentID; + uint256 tokens; + uint256 createdAtEpoch; + uint256 closedAtEpoch; + uint256 collectedFees; + uint256 __DEPRECATED_effectiveAllocation; + uint256 accRewardsPerAllocatedToken; + uint256 distributedRebates; + } + + /** + * @dev Possible states a legacy allocation can be. + * States: + * - Null = indexer == address(0) + * - Active = not Null && tokens > 0 + * - Closed = Active && closedAtEpoch != 0 + */ + enum LegacyAllocationState { + Null, + Active, + Closed + } } diff --git a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol index 2a15a8350..0519b3e3f 100644 --- a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol +++ b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol @@ -252,7 +252,7 @@ library AllocationHandler { // Ensure allocation id is not reused // need to check both subgraph service (on allocations.create()) and legacy allocations - _legacyAllocations.revertIfExists(params._allocationId); + _legacyAllocations.revertIfExists(params.graphStaking, params._allocationId); IAllocation.State memory allocation = _allocations.create( params._indexer, diff --git a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol index f281bea83..8439ed4fb 100644 --- a/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol +++ b/packages/subgraph-service/contracts/libraries/LegacyAllocation.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.27; +import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol"; /** @@ -15,15 +16,21 @@ library LegacyAllocation { /** * @notice Revert if a legacy allocation exists - * @dev We check the migrated allocations mapping. + * @dev We check both the migrated allocations mapping and the legacy staking contract. * @param self The legacy allocation list mapping + * @param graphStaking The Horizon Staking contract * @param allocationId The allocation id */ function revertIfExists( mapping(address => ILegacyAllocation.State) storage self, + IHorizonStaking graphStaking, address allocationId ) internal view { require(!self[allocationId].exists(), ILegacyAllocation.LegacyAllocationAlreadyExists(allocationId)); + require( + !graphStaking.isAllocation(allocationId), + ILegacyAllocation.LegacyAllocationAlreadyExists(allocationId) + ); } /** diff --git a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol index 74b0718bb..5002900f1 100644 --- a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol @@ -492,6 +492,45 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { assertEq(afterLegacyAllocation.subgraphDeploymentId, _subgraphDeploymentId); } + /** + * @notice Sets a legacy allocation directly in HorizonStaking storage + * @dev The __DEPRECATED_allocations mapping is at storage slot 15 in HorizonStaking + * Use `forge inspect HorizonStaking storage-layout` to verify + * The LegacyAllocation struct has the following layout: + * - slot 0: indexer (address) + * - slot 1: subgraphDeploymentID (bytes32) + * - slot 2: tokens (uint256) + * - slot 3: createdAtEpoch (uint256) + * - slot 4: closedAtEpoch (uint256) + * - slot 5: collectedFees (uint256) + * - slot 6: __DEPRECATED_effectiveAllocation (uint256) + * - slot 7: accRewardsPerAllocatedToken (uint256) + * - slot 8: distributedRebates (uint256) + */ + function _setLegacyAllocationInStaking( + address _allocationId, + address _indexer, + bytes32 _subgraphDeploymentId + ) internal { + // Storage slot for __DEPRECATED_allocations mapping in HorizonStaking + uint256 allocationsSlot = 15; + bytes32 allocationBaseSlot = keccak256(abi.encode(_allocationId, allocationsSlot)); + + // Set indexer (slot 0) + vm.store(address(staking), allocationBaseSlot, bytes32(uint256(uint160(_indexer)))); + // Set subgraphDeploymentID (slot 1) + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 1), _subgraphDeploymentId); + // Set tokens (slot 2) - non-zero to indicate active allocation + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 2), bytes32(uint256(1000 ether))); + // Set createdAtEpoch (slot 3) - non-zero + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 3), bytes32(uint256(1))); + // Set closedAtEpoch (slot 4) - non-zero to indicate closed + vm.store(address(staking), bytes32(uint256(allocationBaseSlot) + 4), bytes32(uint256(10))); + + // Verify the allocation is now visible via isAllocation + assertTrue(staking.isAllocation(_allocationId)); + } + /* * HELPERS */ diff --git a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol index 5617f4d7b..68c3c6674 100644 --- a/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol @@ -165,8 +165,9 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _createProvision(users.indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD); _register(users.indexer, abi.encode("url", "geoHash", address(0))); - // simulate legacy allocation migration - _migrateLegacyAllocation(users.indexer, allocationId, subgraphDeployment); + // Set a legacy allocation directly in HorizonStaking storage + // This simulates an allocation that was created before Horizon and exists in the staking contract + _setLegacyAllocationInStaking(allocationId, users.indexer, subgraphDeployment); bytes memory data = _generateData(tokens); vm.expectRevert(abi.encodeWithSelector(ILegacyAllocation.LegacyAllocationAlreadyExists.selector, allocationId)); diff --git a/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol b/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol index 4915ac17f..76fae1307 100644 --- a/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol @@ -21,7 +21,7 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { * HELPERS */ - function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private view returns (bytes memory) { + function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); bytes32 messageHash = keccak256( abi.encodePacked( From fd962344c1a57649d8bb6755e5cdaa4be9a4779e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:38:02 +0000 Subject: [PATCH 040/157] chore: restore pragma --- packages/horizon/test/unit/staking/legacy/isAllocation.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol b/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol index 1f19ccc00..4e74e29c9 100644 --- a/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol +++ b/packages/horizon/test/unit/staking/legacy/isAllocation.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; From fa9951427d7025d959223aa897f893719b73ede2 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:39:46 +0000 Subject: [PATCH 041/157] fix: cap maxSecondsPerCollection instead of reverting Replace the hard revert (RecurringCollectorCollectionTooLate) with a Math.min cap in _getCollectionInfo. Collections past maxSecondsPerCollection now succeed with tokens capped at maxSecondsPerCollection worth of service, rather than failing entirely. Changes: - _getCollectionInfo caps elapsed seconds at maxSecondsPerCollection - Remove RecurringCollectorCollectionTooLate error from interface - Replace test_Collect_Revert_WhenCollectingTooLate with test_Collect_OK_WhenCollectingPastMaxSeconds - Update maxSecondsPerCollection NatSpec to reflect cap semantics - Fix zero-token test to use correct _sensibleAuthorizeAndAccept API --- .../collectors/MaxSecondsPerCollectionCap.md | 56 +++++++++++++++++++ .../collectors/RecurringCollector.sol | 18 +++--- .../recurring-collector/collect.t.sol | 49 ++++++++-------- .../contracts/horizon/IRecurringCollector.sol | 18 ++---- 4 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md diff --git a/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md b/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md new file mode 100644 index 000000000..c3926b31c --- /dev/null +++ b/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md @@ -0,0 +1,56 @@ +# maxSecondsPerCollection: Cap, Not Deadline + +## Problem + +`_requireValidCollect` treats `maxSecondsPerCollection` as a hard deadline: + +```solidity +require( + _collectionSeconds <= _agreement.maxSecondsPerCollection, + RecurringCollectorCollectionTooLate(...) +); +uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * _collectionSeconds; +``` + +If the indexer collects even 1 second past `maxSecondsPerCollection`, the transaction reverts and the agreement becomes permanently stuck. The only recovery is a zero-token collect that bypasses temporal validation entirely (since `_requireValidCollect` is inside `if (tokens != 0)`), which works but is an unnatural mechanism. + +## Fix + +Cap `collectionSeconds` at `maxSecondsPerCollection` in `_getCollectionInfo`, so all callers (RC's `_collect` and SS's `IndexingAgreement.collect`) receive consistent capped seconds: + +```solidity +uint256 elapsed = collectionEnd - collectionStart; +return (true, Math.min(elapsed, uint256(_agreement.maxSecondsPerCollection)), ...); +``` + +The payer's per-collection exposure is still bounded by `maxOngoingTokensPerSecond * maxSecondsPerCollection`. The indexer can collect after the window closes, but receives no more tokens than if they had collected exactly at the deadline. + +## Why this is correct + +1. **`_getMaxNextClaim` already caps.** The view function (used by escrow to compute worst-case exposure) clamps `windowSeconds` at `maxSecondsPerCollection` rather than returning 0. The mutation function should be consistent. + +2. **`collectionSeconds` is derived from on-chain state**, not caller-supplied. The indexer's only leverage is _when_ they call. Capping means they can't extract more by waiting longer. + +3. **No stuck agreements.** A missed window no longer requires cancellation or a zero-token hack to recover. + +4. **`minSecondsPerCollection` is unaffected.** If elapsed time exceeds `maxSecondsPerCollection`, it trivially exceeds `minSecondsPerCollection` (since `max > min` is enforced at accept time). + +5. **Initial tokens preserved.** `maxInitialTokens` is added on top of the capped ongoing amount on first collection. With a hard deadline, a late first collection reverts and the indexer loses both the initial bonus and the ongoing amount — misaligning incentives. With a cap, the initial bonus is always available. + +6. **Late collection loses unclaimed seconds, not ability to collect.** After a capped collection, `lastCollectionAt` resets to `block.timestamp`, not `lastCollectionAt + maxSecondsPerCollection`. The indexer permanently loses tokens for the gap beyond the cap. This incentivizes timely collection without the cliff-edge of a hard revert. + +## Zero-token temporal validation enforced + +`_requireValidCollect` was previously inside `if (tokens != 0)`, allowing zero-token collections to update `lastCollectionAt` without temporal checks. With the cap in place there is no legitimate bypass scenario, so temporal validation now runs unconditionally. + +This also makes `lastCollectionAt` (publicly readable via `getAgreement`) trustworthy as a liveness signal. Previously it could be advanced to `block.timestamp` without any real collection. Now it can only be updated through a validated collection, making it reliable for external consumers (e.g. payers or SAM operators checking indexer activity to decide whether to cancel). + +## Zero-POI special case removed + +The old code special-cased `entities == 0 && poi == bytes32(0)` to force `tokens = 0`, bypassing `_tokensToCollect` and RC temporal validation. This existed as a reset mechanism for stuck agreements. With the cap, there are no stuck agreements, so the special case is removed. Every collection now goes through `_tokensToCollect` and RC validation uniformly, and every POI is disputable. + +## Contrast with indexing rewards + +Indexing rewards require a zero-POI "heartbeat" to keep allocations alive because reward rates change per epoch and snapshots are influenced by other participants' activity. That reset mechanism exists because the system is inherently snapshot-driven. + +RCA indexing fees have no snapshots. The rate (`tokensPerSecond`, `tokensPerEntityPerSecond`) is fixed at agreement accept/update time. No external state changes the per-second rate between collections. The amount owed for N seconds of service is deterministic regardless of when collection happens, so capping is strictly correct — there is no reason to penalize a late collection beyond limiting it to `maxSecondsPerCollection` worth of tokens. diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 5a4b7876d..ef99d1336 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -459,16 +459,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ) ); } - require( - // solhint-disable-next-line gas-strict-inequalities - _collectionSeconds <= _agreement.maxSecondsPerCollection, - RecurringCollectorCollectionTooLate( - _agreementId, - uint64(_collectionSeconds), - _agreement.maxSecondsPerCollection - ) - ); - + // _collectionSeconds is already capped at maxSecondsPerCollection by _getCollectionInfo uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * _collectionSeconds; maxTokens += _agreement.lastCollectionAt == 0 ? _agreement.maxInitialTokens : 0; @@ -631,7 +622,12 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return (false, 0, AgreementNotCollectableReason.ZeroCollectionSeconds); } - return (true, collectionEnd - collectionStart, AgreementNotCollectableReason.None); + uint256 elapsed = collectionEnd - collectionStart; + return ( + true, + Math.min(elapsed, uint256(_agreement.maxSecondsPerCollection)), + AgreementNotCollectableReason.None + ); } /** diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 818019277..2fa361461 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -168,7 +168,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } - function test_Collect_Revert_WhenCollectingTooLate( + function test_Collect_OK_WhenCollectingPastMaxSeconds( FuzzyTestCollect calldata fuzzy, uint256 unboundedFirstCollectionSeconds, uint256 unboundedSecondCollectionSeconds @@ -177,8 +177,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { fuzzy.fuzzyTestAccept ); - // skip to collectable time - + // First valid collection to establish lastCollectionAt skip( boundSkip( unboundedFirstCollectionSeconds, @@ -186,7 +185,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { accepted.rca.maxSecondsPerCollection ) ); - bytes memory data = _generateCollectData( + bytes memory firstData = _generateCollectData( _generateCollectParams( accepted.rca, agreementId, @@ -195,10 +194,10 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { fuzzy.collectParams.dataServiceCut ) ); - vm.prank(accepted.rca.dataService); - _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + vm.prank(acceptedRca.dataService); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), firstData); - // skip beyond collectable time but still within the agreement endsAt + // Skip PAST maxSecondsPerCollection (but still within agreement endsAt) uint256 collectionSeconds = boundSkip( unboundedSecondCollectionSeconds, accepted.rca.maxSecondsPerCollection + 1, @@ -206,24 +205,30 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ); skip(collectionSeconds); - data = _generateCollectData( - _generateCollectParams( - accepted.rca, - agreementId, - fuzzy.collectParams.collectionId, - bound(fuzzy.collectParams.tokens, 1, type(uint256).max), - fuzzy.collectParams.dataServiceCut - ) + // Request more tokens than the cap allows + uint256 cappedMaxTokens = acceptedRca.maxOngoingTokensPerSecond * acceptedRca.maxSecondsPerCollection; + uint256 requestedTokens = cappedMaxTokens + 1; + + IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( + acceptedRca, + agreementId, + fuzzy.collectParams.collectionId, + requestedTokens, + fuzzy.collectParams.dataServiceCut ); - bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorCollectionTooLate.selector, + bytes memory data = _generateCollectData(collectParams); + + // Collection should SUCCEED with tokens capped at maxSecondsPerCollection worth + _expectCollectCallAndEmit( + acceptedRca, agreementId, - collectionSeconds, - accepted.rca.maxSecondsPerCollection + _paymentType(fuzzy.unboundedPaymentType), + collectParams, + cappedMaxTokens ); - vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); - _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + vm.prank(acceptedRca.dataService); + uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + assertEq(collected, cappedMaxTokens, "Tokens should be capped at maxSecondsPerCollection worth"); } function test_Collect_OK_WhenCollectingTooMuch( diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index e8530cc85..e3ca616a3 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -59,7 +59,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection * @param nonce A unique nonce for preventing collisions (user-chosen) * @param metadata Arbitrary metadata to extend functionality if a data service requires it * @@ -99,7 +99,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection * @param nonce The nonce for preventing replay attacks (must be current nonce + 1) * @param metadata Arbitrary metadata to extend functionality if a data service requires it */ @@ -130,7 +130,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection * @param updateNonce The current nonce for updates (prevents replay attacks) * @param canceledAt The timestamp when the agreement was canceled * @param state The state of the agreement @@ -180,7 +180,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection */ event AgreementAccepted( address indexed dataService, @@ -224,7 +224,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection */ event AgreementUpdated( address indexed dataService, @@ -373,14 +373,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorCollectionTooSoon(bytes16 agreementId, uint32 secondsSinceLast, uint32 minSeconds); - /** - * @notice Thrown when calling collect() too late - * @param agreementId The agreement ID - * @param secondsSinceLast Seconds since last collection - * @param maxSeconds Maximum seconds between collections - */ - error RecurringCollectorCollectionTooLate(bytes16 agreementId, uint64 secondsSinceLast, uint32 maxSeconds); - /** * @notice Thrown when calling update() with an invalid nonce * @param agreementId The agreement ID From c6836a716d7940a9c892cd704316a7a536631223 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:36:08 +0000 Subject: [PATCH 042/157] fix: enforce temporal validation on zero-token collections and remove zero-POI special case Move _requireValidCollect() call outside the tokens != 0 guard so temporal constraints (min/maxSecondsPerCollection) are always enforced, even for zero-token collections. This prevents advancing lastCollectionAt without passing temporal validation. Remove the zero-POI special case in IndexingAgreement that bypassed token calculation when entities == 0 && poi == bytes32(0). The temporal validation now handles this consistently. --- .../collectors/RecurringCollector.sol | 13 ++++-- .../recurring-collector/collect.t.sol | 43 +++++++++++++++++++ .../contracts/libraries/IndexingAgreement.sol | 4 +- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index ef99d1336..5af3bf863 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -343,10 +343,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC require(tokensAvailable > 0, RecurringCollectorUnauthorizedDataService(agreement.dataService)); } - uint256 tokensToCollect = 0; - if (_params.tokens != 0) { - tokensToCollect = _requireValidCollect(agreement, _params.agreementId, _params.tokens, collectionSeconds); + // Always validate temporal constraints (min/maxSecondsPerCollection) even for + // zero-token collections, to prevent bypassing temporal windows while updating + // lastCollectionAt. + uint256 tokensToCollect = _requireValidCollect( + agreement, + _params.agreementId, + _params.tokens, + collectionSeconds + ); + if (_params.tokens != 0) { uint256 slippage = _params.tokens - tokensToCollect; /* solhint-disable gas-strict-inequalities */ require( diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 2fa361461..95530e4b3 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -448,5 +448,48 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); assertEq(collected, maxAllowed); } + function test_Collect_Revert_WhenZeroTokensBypassesTemporalValidation(FuzzyTestCollect calldata fuzzy) public { + (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); + + // First valid collection to establish lastCollectionAt + skip(accepted.rca.minSecondsPerCollection); + bytes memory firstData = _generateCollectData( + _generateCollectParams( + accepted.rca, + agreementId, + fuzzy.collectParams.collectionId, + 1, + fuzzy.collectParams.dataServiceCut + ) + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), firstData); + + // Attempt zero-token collection immediately (before minSecondsPerCollection). + // This MUST revert with CollectionTooSoon — zero tokens should NOT bypass + // the temporal validation that guards minSecondsPerCollection. + skip(1); + IRecurringCollector.CollectParams memory zeroParams = _generateCollectParams( + accepted.rca, + agreementId, + fuzzy.collectParams.collectionId, + 0, // zero tokens + fuzzy.collectParams.dataServiceCut + ); + bytes memory zeroData = _generateCollectData(zeroParams); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorCollectionTooSoon.selector, + agreementId, + uint32(1), // only 1 second elapsed + accepted.rca.minSecondsPerCollection + ) + ); + vm.prank(accepted.rca.dataService); + _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), zeroData); + } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 61ff8a436..19a7eaf4a 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -562,9 +562,7 @@ library IndexingAgreement { CollectIndexingFeeDataV1 memory data = IndexingAgreementDecoder.decodeCollectIndexingFeeDataV1(params.data); - uint256 expectedTokens = (data.entities == 0 && data.poi == bytes32(0)) - ? 0 - : _tokensToCollect(self, params.agreementId, data.entities, collectionSeconds); + uint256 expectedTokens = _tokensToCollect(self, params.agreementId, data.entities, collectionSeconds); // `tokensCollected` <= `expectedTokens` because the recurring collector will further narrow // down the tokens allowed, based on the RCA terms. From 8efaec97d6075dd30aa82cd0d2591a1007ab8f87 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:48:30 +0000 Subject: [PATCH 043/157] feat: add adjustThaw to PaymentsEscrow Add adjustThaw for timer-aware escrow thaw management: caps at balance, preserves timer on decrease, and optionally skips increases that would reset the timer. Expose escrowAccounts mapping in IPaymentsEscrow interface. --- .../contracts/payments/PaymentsEscrow.sol | 40 ++- .../test/unit/escrow/constructor.t.sol | 1 - .../horizon/test/unit/escrow/getters.t.sol | 10 + .../horizon/test/unit/escrow/paused.t.sol | 5 + packages/horizon/test/unit/escrow/thaw.t.sol | 262 ++++++++++++++++++ .../horizon/test/unit/escrow/withdraw.t.sol | 31 ++- .../PaymentsEscrowMock.t.sol | 8 + .../contracts/horizon/IPaymentsEscrow.sol | 34 +++ .../toolshed/IPaymentsEscrowToolshed.sol | 17 +- .../subgraphService/collect/query/query.t.sol | 2 +- 10 files changed, 394 insertions(+), 16 deletions(-) diff --git a/packages/horizon/contracts/payments/PaymentsEscrow.sol b/packages/horizon/contracts/payments/PaymentsEscrow.sol index edf98627f..59c3f771f 100644 --- a/packages/horizon/contracts/payments/PaymentsEscrow.sol +++ b/packages/horizon/contracts/payments/PaymentsEscrow.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.27; -// TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-strict-inequalities import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token/IGraphToken.sol"; @@ -36,7 +35,8 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory, /// @notice Escrow account details for payer-collector-receiver tuples mapping(address payer => mapping(address collector => mapping(address receiver => IPaymentsEscrow.EscrowAccount escrowAccount))) - public escrowAccounts; + public + override escrowAccounts; // forge-lint: disable-next-item(unwrapped-modifier-logic) /** @@ -91,6 +91,42 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory, emit Thaw(msg.sender, collector, receiver, tokens, account.thawEndTimestamp); } + /// @inheritdoc IPaymentsEscrow + function adjustThaw( + address collector, + address receiver, + uint256 tokensToThaw, + bool evenIfTimerReset + ) external override notPaused returns (uint256 tokensThawing) { + EscrowAccount storage account = escrowAccounts[msg.sender][collector][receiver]; + uint256 currentThawing = account.tokensThawing; + + tokensThawing = tokensToThaw < account.balance ? tokensToThaw : account.balance; + + if (tokensThawing == currentThawing) return tokensThawing; + + uint256 thawEndTimestamp; + uint256 previousThawEnd = account.thawEndTimestamp; + if (tokensThawing < currentThawing) { + // Decreasing (or canceling): preserve timer, clear if fully canceled + account.tokensThawing = tokensThawing; + if (tokensThawing == 0) account.thawEndTimestamp = 0; + else thawEndTimestamp = previousThawEnd; + } else { + thawEndTimestamp = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + // Increasing: reset timer (skip if evenIfTimerReset=false and timer would change) + if (!evenIfTimerReset && previousThawEnd != 0 && previousThawEnd != thawEndTimestamp) return currentThawing; + account.tokensThawing = tokensThawing; + account.thawEndTimestamp = thawEndTimestamp; + } + + if (tokensThawing == 0) { + emit CancelThaw(msg.sender, collector, receiver, currentThawing, previousThawEnd); + } else { + emit Thaw(msg.sender, collector, receiver, tokensThawing, thawEndTimestamp); + } + } + /// @inheritdoc IPaymentsEscrow function cancelThaw(address collector, address receiver) external override notPaused { EscrowAccount storage account = escrowAccounts[msg.sender][collector][receiver]; diff --git a/packages/horizon/test/unit/escrow/constructor.t.sol b/packages/horizon/test/unit/escrow/constructor.t.sol index c1b097010..430d9926d 100644 --- a/packages/horizon/test/unit/escrow/constructor.t.sol +++ b/packages/horizon/test/unit/escrow/constructor.t.sol @@ -21,7 +21,6 @@ contract GraphEscrowConstructorTest is Test { controller.setContractProxy(keccak256("RewardsManager"), makeAddr("RewardsManager")); controller.setContractProxy(keccak256("GraphTokenGateway"), makeAddr("GraphTokenGateway")); controller.setContractProxy(keccak256("GraphProxyAdmin"), makeAddr("GraphProxyAdmin")); - controller.setContractProxy(keccak256("Curation"), makeAddr("Curation")); } function testConstructor_MaxWaitPeriodBoundary() public { diff --git a/packages/horizon/test/unit/escrow/getters.t.sol b/packages/horizon/test/unit/escrow/getters.t.sol index 770b8b7c3..01a215f06 100644 --- a/packages/horizon/test/unit/escrow/getters.t.sol +++ b/packages/horizon/test/unit/escrow/getters.t.sol @@ -15,6 +15,16 @@ contract GraphEscrowGettersTest is GraphEscrowTest { assertEq(balance, amount); } + function testEscrowAccounts(uint256 amount) public useGateway useDeposit(amount) { + (uint256 balance, uint256 tokensThawing, ) = escrow.escrowAccounts( + users.gateway, + users.verifier, + users.indexer + ); + assertEq(balance, amount); + assertEq(tokensThawing, 0); + } + function testGetBalance_WhenThawing( uint256 amountDeposit, uint256 amountThawing diff --git a/packages/horizon/test/unit/escrow/paused.t.sol b/packages/horizon/test/unit/escrow/paused.t.sol index 010268c80..2787f5f56 100644 --- a/packages/horizon/test/unit/escrow/paused.t.sol +++ b/packages/horizon/test/unit/escrow/paused.t.sol @@ -50,6 +50,11 @@ contract GraphEscrowPausedTest is GraphEscrowTest { escrow.cancelThaw(users.verifier, users.indexer); } + function testPaused_RevertWhen_AdjustThaw(uint256 tokens) public useGateway useDeposit(tokens) usePaused(true) { + vm.expectRevert(abi.encodeWithSelector(IPaymentsEscrow.PaymentsEscrowIsPaused.selector)); + escrow.adjustThaw(users.verifier, users.indexer, tokens, false); + } + function testPaused_RevertWhen_WithdrawTokens( uint256 tokens, uint256 thawAmount diff --git a/packages/horizon/test/unit/escrow/thaw.t.sol b/packages/horizon/test/unit/escrow/thaw.t.sol index ca8569176..a8284f8b2 100644 --- a/packages/horizon/test/unit/escrow/thaw.t.sol +++ b/packages/horizon/test/unit/escrow/thaw.t.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; contract GraphEscrowThawTest is GraphEscrowTest { @@ -74,4 +75,265 @@ contract GraphEscrowThawTest is GraphEscrowTest { vm.expectRevert(expectedError); escrow.cancelThaw(users.verifier, users.indexer); } + + function testThaw_AlwaysResetsTimerOnSuccessiveCalls(uint256 amount) public useGateway { + amount = bound(amount, 3, type(uint256).max - 10); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 2 - 1) / 2; + uint256 secondAmountToThaw = (amount + 10 - 1) / 10; + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + + // Advance time — simple thaw always resets the timer, even on decrease + vm.warp(block.timestamp + 1 hours); + + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + + (, address msgSender, ) = vm.readCallers(); + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, secondAmountToThaw, expectedThawEnd); + escrow.thaw(users.verifier, users.indexer, secondAmountToThaw); + + (, uint256 amountThawing, uint256 thawEndTimestamp) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawing, secondAmountToThaw); + assertEq(thawEndTimestamp, expectedThawEnd, "Timer should always reset on simple thaw"); + } + + function testThaw_ResetsTimerOnIncrease(uint256 amount) public useGateway { + amount = bound(amount, 10, type(uint256).max - 10); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 10 - 1) / 10; + uint256 secondAmountToThaw = (amount + 2 - 1) / 2; + + (, address msgSender, ) = vm.readCallers(); + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + + // Advance time — second thaw with larger amount should reset the timer + vm.warp(block.timestamp + 1 hours); + + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, secondAmountToThaw, expectedThawEnd); + escrow.thaw(users.verifier, users.indexer, secondAmountToThaw); + + (, uint256 amountThawing, uint256 thawEndTimestamp) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawing, secondAmountToThaw); + assertEq(thawEndTimestamp, expectedThawEnd, "Timer should reset on increase"); + } + + /* + * adjustThaw tests + */ + + function testAdjustThaw_CapsAtBalance(uint256 amount, uint256 overAmount) public useGateway useDeposit(amount) { + overAmount = bound(overAmount, amount + 1, type(uint256).max); + + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, overAmount, true); + assertEq(amountThawing, amount, "Should cap at balance"); + + (, address msgSender, ) = vm.readCallers(); + (, uint256 storedThawing, ) = escrow.escrowAccounts(msgSender, users.verifier, users.indexer); + assertEq(storedThawing, amount); + } + + function testAdjustThaw_ZeroAmountCancelsAll(uint256 amount) public useGateway useDeposit(amount) { + escrow.thaw(users.verifier, users.indexer, amount); + + (, address msgSender, ) = vm.readCallers(); + (, uint256 amountThawingBefore, uint256 thawEndTimestampBefore) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawingBefore, amount); + + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.CancelThaw( + msgSender, + users.verifier, + users.indexer, + amountThawingBefore, + thawEndTimestampBefore + ); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, 0, true); + assertEq(amountThawing, 0); + + (, uint256 amountThawingAfter, uint256 thawEndTimestampAfter) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawingAfter, 0); + assertEq(thawEndTimestampAfter, 0); + } + + function testAdjustThaw_NoopWhenRequestedEqualsCurrentThawing(uint256 amount) public useGateway useDeposit(amount) { + escrow.thaw(users.verifier, users.indexer, amount); + + (, address msgSender, ) = vm.readCallers(); + (, uint256 amountThawingBefore, uint256 thawEndTimestampBefore) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, amount, true); + assertEq(amountThawing, amount); + + (, uint256 amountThawingAfter, uint256 thawEndTimestampAfter) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawingAfter, amountThawingBefore); + assertEq(thawEndTimestampAfter, thawEndTimestampBefore); + } + + function testAdjustThaw_PreservesTimerOnDecrease(uint256 amount) public useGateway { + amount = bound(amount, 3, type(uint256).max - 10); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 2 - 1) / 2; + uint256 secondAmountToThaw = (amount + 10 - 1) / 10; + + (, address msgSender, ) = vm.readCallers(); + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + + vm.warp(block.timestamp + 1 hours); + + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, secondAmountToThaw, expectedThawEnd); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, secondAmountToThaw, true); + assertEq(amountThawing, secondAmountToThaw); + + (, uint256 storedThawing, uint256 thawEndTimestamp) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(storedThawing, secondAmountToThaw); + assertEq(thawEndTimestamp, expectedThawEnd, "Timer should be preserved on decrease"); + } + + /* + * adjustThaw evenIfTimerReset = false tests + */ + + function testAdjustThaw_EvenIfTimerResetFalse_ProceedsWithNewThaw( + uint256 amount + ) public useGateway useDeposit(amount) { + (, address msgSender, ) = vm.readCallers(); + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, amount, expectedThawEnd); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, amount, false); + assertEq(amountThawing, amount); + } + + function testAdjustThaw_EvenIfTimerResetFalse_ProceedsWithDecrease(uint256 amount) public useGateway { + amount = bound(amount, 10, MAX_STAKING_TOKENS); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 2 - 1) / 2; + uint256 secondAmountToThaw = (amount + 10 - 1) / 10; + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + + vm.warp(block.timestamp + 1 hours); + + (, address msgSender, ) = vm.readCallers(); + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, secondAmountToThaw, expectedThawEnd); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, secondAmountToThaw, false); + assertEq(amountThawing, secondAmountToThaw); + + (, , uint256 thawEndTimestamp) = escrow.escrowAccounts(msgSender, users.verifier, users.indexer); + assertEq(thawEndTimestamp, expectedThawEnd, "Timer should be preserved on decrease"); + } + + function testAdjustThaw_EvenIfTimerResetFalse_SkipsIncreaseWhenTimerWouldReset(uint256 amount) public useGateway { + amount = bound(amount, 10, MAX_STAKING_TOKENS); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 10 - 1) / 10; + uint256 secondAmountToThaw = (amount + 2 - 1) / 2; + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + uint256 originalThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + + vm.warp(block.timestamp + 1 hours); + + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, secondAmountToThaw, false); + assertEq(amountThawing, firstAmountToThaw, "Should return current thawing, not new amount"); + + (, address msgSender, ) = vm.readCallers(); + (, uint256 storedThawing, uint256 thawEndTimestamp) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(storedThawing, firstAmountToThaw); + assertEq(thawEndTimestamp, originalThawEnd, "Timer should remain unchanged"); + } + + function testAdjustThaw_EvenIfTimerResetFalse_ProceedsWhenTimerUnchanged(uint256 amount) public useGateway { + amount = bound(amount, 10, MAX_STAKING_TOKENS); + _depositTokens(users.verifier, users.indexer, amount); + + uint256 firstAmountToThaw = (amount + 10 - 1) / 10; + uint256 secondAmountToThaw = (amount + 2 - 1) / 2; + + escrow.thaw(users.verifier, users.indexer, firstAmountToThaw); + + (, address msgSender, ) = vm.readCallers(); + uint256 expectedThawEnd = block.timestamp + WITHDRAW_ESCROW_THAWING_PERIOD; + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.Thaw(msgSender, users.verifier, users.indexer, secondAmountToThaw, expectedThawEnd); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, secondAmountToThaw, false); + assertEq(amountThawing, secondAmountToThaw, "Should proceed when timer unchanged"); + } + + function testAdjustThaw_EvenIfTimerResetFalse_CancelsThawing(uint256 amount) public useGateway useDeposit(amount) { + escrow.thaw(users.verifier, users.indexer, amount); + + (, address msgSender, ) = vm.readCallers(); + (, uint256 amountThawingBefore, uint256 thawEndTimestampBefore) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + vm.expectEmit(address(escrow)); + emit IPaymentsEscrow.CancelThaw( + msgSender, + users.verifier, + users.indexer, + amountThawingBefore, + thawEndTimestampBefore + ); + uint256 amountThawing = escrow.adjustThaw(users.verifier, users.indexer, 0, false); + assertEq(amountThawing, 0); + + (, uint256 amountThawingAfter, uint256 thawEndTimestampAfter) = escrow.escrowAccounts( + msgSender, + users.verifier, + users.indexer + ); + assertEq(amountThawingAfter, 0); + assertEq(thawEndTimestampAfter, 0); + } } diff --git a/packages/horizon/test/unit/escrow/withdraw.t.sol b/packages/horizon/test/unit/escrow/withdraw.t.sol index 18a000af4..5f33c11f6 100644 --- a/packages/horizon/test/unit/escrow/withdraw.t.sol +++ b/packages/horizon/test/unit/escrow/withdraw.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; contract GraphEscrowWithdrawTest is GraphEscrowTest { @@ -39,6 +40,23 @@ contract GraphEscrowWithdrawTest is GraphEscrowTest { escrow.withdraw(users.verifier, users.indexer); } + function testWithdraw_RevertWhen_AtExactThawEndTimestamp( + uint256 amount, + uint256 thawAmount + ) public useGateway depositAndThawTokens(amount, thawAmount) { + // Advance time to exactly the thaw end timestamp (boundary: thawEndTimestamp < block.timestamp required) + skip(WITHDRAW_ESCROW_THAWING_PERIOD); + + (, , uint256 thawEndTimestamp) = escrow.escrowAccounts(users.gateway, users.verifier, users.indexer); + bytes memory expectedError = abi.encodeWithSignature( + "PaymentsEscrowStillThawing(uint256,uint256)", + block.timestamp, + thawEndTimestamp + ); + vm.expectRevert(expectedError); + escrow.withdraw(users.verifier, users.indexer); + } + function testWithdraw_SucceedsOneSecondAfterThawEnd( uint256 amount, uint256 thawAmount @@ -55,7 +73,7 @@ contract GraphEscrowWithdrawTest is GraphEscrowTest { uint256 amountCollected ) public useGateway depositAndThawTokens(amountDeposited, amountThawed) { vm.assume(amountCollected > 0); - vm.assume(amountCollected < amountDeposited); + vm.assume(amountCollected <= amountDeposited); // burn some tokens to prevent overflow resetPrank(users.indexer); @@ -76,8 +94,15 @@ contract GraphEscrowWithdrawTest is GraphEscrowTest { // Advance time to simulate the thawing period skip(WITHDRAW_ESCROW_THAWING_PERIOD + 1); - // withdraw the remaining thawed balance + // After collect, tokensThawing is capped at remaining balance. + // Withdraw succeeds if tokens remain, otherwise reverts. resetPrank(users.gateway); - _withdrawEscrow(users.verifier, users.indexer); + (, uint256 tokensThawing, ) = escrow.escrowAccounts(users.gateway, users.verifier, users.indexer); + if (tokensThawing != 0) { + _withdrawEscrow(users.verifier, users.indexer); + } else { + vm.expectRevert(abi.encodeWithSelector(IPaymentsEscrow.PaymentsEscrowNotThawing.selector)); + escrow.withdraw(users.verifier, users.indexer); + } } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol b/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol index 99d4d47a4..96a1f217f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/PaymentsEscrowMock.t.sol @@ -15,6 +15,10 @@ contract PaymentsEscrowMock is IPaymentsEscrow { function thaw(address, address, uint256) external {} + function adjustThaw(address, address, uint256, bool /* evenIfTimerReset */) external pure returns (uint256) { + return 0; + } + function cancelThaw(address, address) external {} function withdraw(address, address) external {} @@ -23,6 +27,10 @@ contract PaymentsEscrowMock is IPaymentsEscrow { return 0; } + function escrowAccounts(address, address, address) external pure returns (uint256, uint256, uint256) { + return (0, 0, 0); + } + function MAX_WAIT_PERIOD() external pure returns (uint256) { return 0; } diff --git a/packages/interfaces/contracts/horizon/IPaymentsEscrow.sol b/packages/interfaces/contracts/horizon/IPaymentsEscrow.sol index 9dbe9906a..a73866273 100644 --- a/packages/interfaces/contracts/horizon/IPaymentsEscrow.sol +++ b/packages/interfaces/contracts/horizon/IPaymentsEscrow.sol @@ -198,6 +198,25 @@ interface IPaymentsEscrow { */ function thaw(address collector, address receiver, uint256 tokens) external; + /** + * @notice Adjusts the thawing amount with a guard against timer reset. + * Caps the requested amount to the current balance. When decreasing, the timer is preserved. + * When increasing, the timer resets; if `evenIfTimerReset` is false and the timer would + * change, the call is a no-op and returns the current tokensThawing. + * Setting tokens to 0 cancels the thaw entirely. + * @param collector The address of the collector + * @param receiver The address of the receiver + * @param tokensToThaw The desired amount of tokens to thaw + * @param evenIfTimerReset If true, always proceed. If false, skip increases that would reset the timer. + * @return tokensThawing The resulting amount of tokens thawing after the operation + */ + function adjustThaw( + address collector, + address receiver, + uint256 tokensToThaw, + bool evenIfTimerReset + ) external returns (uint256 tokensThawing); + /** * @notice Cancels the thawing of escrow from a payer-collector-receiver's escrow account. * @param collector The address of the collector @@ -257,4 +276,19 @@ interface IPaymentsEscrow { * @return The balance of the payer-collector-receiver tuple */ function getBalance(address payer, address collector, address receiver) external view returns (uint256); + + /** + * @notice Escrow account details for a payer-collector-receiver tuple + * @param payer The address of the payer + * @param collector The address of the collector + * @param receiver The address of the receiver + * @return balance The total token balance + * @return tokensThawing The amount of tokens currently being thawed + * @return thawEndTimestamp The timestamp at which thawing period ends (zero if not thawing) + */ + function escrowAccounts( + address payer, + address collector, + address receiver + ) external view returns (uint256 balance, uint256 tokensThawing, uint256 thawEndTimestamp); } diff --git a/packages/interfaces/contracts/toolshed/IPaymentsEscrowToolshed.sol b/packages/interfaces/contracts/toolshed/IPaymentsEscrowToolshed.sol index c7b9b81f2..c62b16173 100644 --- a/packages/interfaces/contracts/toolshed/IPaymentsEscrowToolshed.sol +++ b/packages/interfaces/contracts/toolshed/IPaymentsEscrowToolshed.sol @@ -1,14 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; -// solhint-disable use-natspec - import { IPaymentsEscrow } from "../horizon/IPaymentsEscrow.sol"; -interface IPaymentsEscrowToolshed is IPaymentsEscrow { - function escrowAccounts( - address payer, - address collector, - address receiver - ) external view returns (EscrowAccount memory); -} +/** + * @title IPaymentsEscrowToolshed + * @author Edge & Node + * @notice Aggregate interface for PaymentsEscrow TypeScript type generation. + * @dev Combines all PaymentsEscrow interfaces into a single artifact for Wagmi and ethers + * type generation. Not intended for use in Solidity code. + */ +interface IPaymentsEscrowToolshed is IPaymentsEscrow {} diff --git a/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol b/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol index 76fae1307..4915ac17f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/collect/query/query.t.sol @@ -21,7 +21,7 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { * HELPERS */ - function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private returns (bytes memory) { + function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private view returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); bytes32 messageHash = keccak256( abi.encodePacked( From 3f1578cdc188eae68b635464b62f3e911e806239 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:09:13 +0000 Subject: [PATCH 044/157] refactor: rename IRewardsEligibility to IProviderEligibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generalise the provider eligibility interface so it is not rewards-specific: - IRewardsEligibility → IProviderEligibility (same isEligible selector) - New IProviderEligibilityManagement with shared setter/getter/event - RewardsManager implements IProviderEligibilityManagement; remove bespoke setter/getter/event from IRewardsManager - Update RewardsEligibilityOracle, mocks, tests, deployment scripts and docs accordingly --- .../rewards-eligibility-oracle.test.ts | 50 +++++++++---------- .../unit/rewards/rewards-interface.test.ts | 4 +- .../unit/rewards/rewards-reclaim.test.ts | 16 +++--- .../rewards/rewards-subgraph-service.test.ts | 2 +- .../tests/unit/rewards/rewards.test.ts | 2 +- .../contracts/rewards/RewardsManager.sol | 45 +++++++++-------- .../rewards/RewardsManagerStorage.sol | 4 +- .../tests/MockRewardsEligibilityOracle.sol | 8 +-- .../rewards/eligibility/06_integrate.ts | 2 +- packages/deployment/docs/Design.md | 2 +- .../RewardsEligibilityOracleDeployment.md | 2 +- packages/deployment/lib/contract-checks.ts | 8 +-- .../deployment/tasks/deployment-status.ts | 4 +- .../contracts/rewards/IRewardsManager.sol | 23 --------- .../eligibility/IProviderEligibility.sol | 20 ++++++++ .../IProviderEligibilityManagement.sol | 38 ++++++++++++++ .../eligibility/IRewardsEligibility.sol | 19 ------- packages/interfaces/src/types/issuance.ts | 4 +- .../eligibility/RewardsEligibilityOracle.md | 2 +- .../eligibility/RewardsEligibilityOracle.sol | 8 +-- .../eligibility/interfaceCompliance.t.sol | 10 ++-- .../test/unit/mocks/MockRewardsManager.sol | 9 ---- 22 files changed, 146 insertions(+), 136 deletions(-) create mode 100644 packages/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol create mode 100644 packages/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol delete mode 100644 packages/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol diff --git a/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts index f26d5dded..4db522378 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts @@ -111,13 +111,13 @@ describe('Rewards - Eligibility Oracle', () => { }) describe('rewards eligibility oracle', function () { - it('should reject setRewardsEligibilityOracle if unauthorized', async function () { + it('should reject setProviderEligibilityOracle if unauthorized', async function () { const MockRewardsEligibilityOracleFactory = await hre.ethers.getContractFactory( 'contracts/tests/MockRewardsEligibilityOracle.sol:MockRewardsEligibilityOracle', ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) await mockOracle.deployed() - const tx = rewardsManager.connect(indexer1).setRewardsEligibilityOracle(mockOracle.address) + const tx = rewardsManager.connect(indexer1).setProviderEligibilityOracle(mockOracle.address) await expect(tx).revertedWith('Only Controller governor') }) @@ -128,12 +128,12 @@ describe('Rewards - Eligibility Oracle', () => { const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) await mockOracle.deployed() - const tx = rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + const tx = rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) await expect(tx) - .emit(rewardsManager, 'RewardsEligibilityOracleSet') + .emit(rewardsManager, 'ProviderEligibilityOracleSet') .withArgs(constants.AddressZero, mockOracle.address) - expect(await rewardsManager.getRewardsEligibilityOracle()).eq(mockOracle.address) + expect(await rewardsManager.getProviderEligibilityOracle()).eq(mockOracle.address) }) it('should allow setting rewards eligibility oracle to zero address', async function () { @@ -143,32 +143,32 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Then set to zero address to disable - const tx = rewardsManager.connect(governor).setRewardsEligibilityOracle(constants.AddressZero) + const tx = rewardsManager.connect(governor).setProviderEligibilityOracle(constants.AddressZero) await expect(tx) - .emit(rewardsManager, 'RewardsEligibilityOracleSet') + .emit(rewardsManager, 'ProviderEligibilityOracleSet') .withArgs(mockOracle.address, constants.AddressZero) - expect(await rewardsManager.getRewardsEligibilityOracle()).eq(constants.AddressZero) + expect(await rewardsManager.getProviderEligibilityOracle()).eq(constants.AddressZero) }) it('should reject setting oracle that does not support interface', async function () { // Try to set an EOA (externally owned account) as the rewards eligibility oracle - const tx = rewardsManager.connect(governor).setRewardsEligibilityOracle(indexer1.address) + const tx = rewardsManager.connect(governor).setProviderEligibilityOracle(indexer1.address) // EOA doesn't have code, so the call will revert (error message may vary by ethers version) await expect(tx).to.be.reverted }) - it('should reject setting oracle that does not support IRewardsEligibility interface', async function () { - // Deploy a contract that supports ERC165 but not IRewardsEligibility + it('should reject setting oracle that does not support IProviderEligibility interface', async function () { + // Deploy a contract that supports ERC165 but not IProviderEligibility const MockERC165Factory = await hre.ethers.getContractFactory('contracts/tests/MockERC165.sol:MockERC165') const mockERC165 = await MockERC165Factory.deploy() await mockERC165.deployed() - const tx = rewardsManager.connect(governor).setRewardsEligibilityOracle(mockERC165.address) - await expect(tx).revertedWith('Contract does not support IRewardsEligibility interface') + const tx = rewardsManager.connect(governor).setProviderEligibilityOracle(mockERC165.address) + await expect(tx).revertedWith('Contract does not support IProviderEligibility interface') }) it('should not emit event when setting same oracle address', async function () { @@ -177,11 +177,11 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Setting the same oracle again should not emit an event - const tx = rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) - await expect(tx).to.not.emit(rewardsManager, 'RewardsEligibilityOracleSet') + const tx = rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) + await expect(tx).to.not.emit(rewardsManager, 'ProviderEligibilityOracleSet') }) }) @@ -195,7 +195,7 @@ describe('Rewards - Eligibility Oracle', () => { await mockOracle.deployed() // Set the rewards eligibility oracle - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -240,7 +240,7 @@ describe('Rewards - Eligibility Oracle', () => { await mockOracle.deployed() // Set the rewards eligibility oracle - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -295,7 +295,7 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -323,7 +323,7 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny indexer await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -365,7 +365,7 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) // Start eligible await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -410,7 +410,7 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Start ineligible await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -498,7 +498,7 @@ describe('Rewards - Eligibility Oracle', () => { it('should allow rewards when REO is zero address (disabled)', async function () { // Ensure REO is not set (zero address = disabled) - expect(await rewardsManager.getRewardsEligibilityOracle()).eq(constants.AddressZero) + expect(await rewardsManager.getProviderEligibilityOracle()).eq(constants.AddressZero) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -577,7 +577,7 @@ describe('Rewards - Eligibility Oracle', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) await helpers.mineEpoch(epochManager) await setupIndexerAllocation() diff --git a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts index 132790e51..3fdd15ee6 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts @@ -58,7 +58,7 @@ describe('RewardsManager interfaces', () => { }) it('IRewardsManager should have stable interface ID', () => { - expect(IRewardsManager__factory.interfaceId).to.equal('0x36b70adb') + expect(IRewardsManager__factory.interfaceId).to.equal('0x7e0447a1') }) }) @@ -93,7 +93,7 @@ describe('RewardsManager interfaces', () => { }) it('should return zero address for rewards eligibility oracle when not set', async function () { - const oracle = await rewardsManager.getRewardsEligibilityOracle() + const oracle = await rewardsManager.getProviderEligibilityOracle() expect(oracle).to.equal(constants.AddressZero) }) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-reclaim.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-reclaim.test.ts index ff8d8cb55..a1a17269a 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-reclaim.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-reclaim.test.ts @@ -306,7 +306,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -370,7 +370,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -431,7 +431,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -482,7 +482,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -524,7 +524,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -573,7 +573,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -604,7 +604,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) // Allow await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) @@ -1075,7 +1075,7 @@ describe('Rewards - Reclaim Addresses', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-subgraph-service.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-subgraph-service.test.ts index d92b20298..58338cac8 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-subgraph-service.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-subgraph-service.test.ts @@ -436,7 +436,7 @@ describe('Rewards - SubgraphService', () => { ) const mockREO = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny by default await mockREO.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockREO.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockREO.address) // Setup: Create signal const signalled1 = toGRT('1500') diff --git a/packages/contracts-test/tests/unit/rewards/rewards.test.ts b/packages/contracts-test/tests/unit/rewards/rewards.test.ts index 3d4139a34..240d78178 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards.test.ts @@ -1035,7 +1035,7 @@ describe('Rewards', () => { ) const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny await mockOracle.deployed() - await rewardsManager.connect(governor).setRewardsEligibilityOracle(mockOracle.address) + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) // Align with the epoch boundary await helpers.mineEpoch(epochManager) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 7323bede0..846767799 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -16,7 +16,8 @@ import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/r import { IRewardsManagerDeprecated } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManagerDeprecated.sol"; import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; import { RewardsCondition } from "@graphprotocol/interfaces/contracts/contracts/rewards/RewardsCondition.sol"; /** @@ -44,6 +45,7 @@ contract RewardsManager is IERC165, IRewardsManager, IIssuanceTarget, + IProviderEligibilityManagement, IRewardsManagerDeprecated, RewardsManagerV6Storage { @@ -81,7 +83,8 @@ contract RewardsManager is return interfaceId == type(IERC165).interfaceId || interfaceId == type(IIssuanceTarget).interfaceId || - interfaceId == type(IRewardsManager).interfaceId; + interfaceId == type(IRewardsManager).interfaceId || + interfaceId == type(IProviderEligibilityManagement).interfaceId; } // -- Config -- @@ -207,26 +210,26 @@ contract RewardsManager is } /** - * @inheritdoc IRewardsManager - * @dev Note that the rewards eligibility oracle can be set to the zero address to disable use of an oracle, in + * @inheritdoc IProviderEligibilityManagement + * @dev Note that the eligibility oracle can be set to the zero address to disable use of an oracle, in * which case no indexers will be denied rewards due to eligibility. */ - function setRewardsEligibilityOracle(address newRewardsEligibilityOracle) external override onlyGovernor { - if (address(rewardsEligibilityOracle) != newRewardsEligibilityOracle) { - // Check that the contract supports the IRewardsEligibility interface - // Allow zero address to disable the oracle - if (newRewardsEligibilityOracle != address(0)) { - // solhint-disable-next-line gas-small-strings - require( - IERC165(newRewardsEligibilityOracle).supportsInterface(type(IRewardsEligibility).interfaceId), - "Contract does not support IRewardsEligibility interface" - ); - } - - address oldRewardsEligibilityOracle = address(rewardsEligibilityOracle); - rewardsEligibilityOracle = IRewardsEligibility(newRewardsEligibilityOracle); - emit RewardsEligibilityOracleSet(oldRewardsEligibilityOracle, newRewardsEligibilityOracle); + function setProviderEligibilityOracle(IProviderEligibility oracle) external override onlyGovernor { + IProviderEligibility oldOracle = rewardsEligibilityOracle; + if (address(oldOracle) == address(oracle)) return; + + // Check that the contract supports the IProviderEligibility interface + // Allow zero address to disable the oracle + if (address(oracle) != address(0)) { + // solhint-disable-next-line gas-small-strings + require( + IERC165(address(oracle)).supportsInterface(type(IProviderEligibility).interfaceId), + "Contract does not support IProviderEligibility interface" + ); } + + rewardsEligibilityOracle = oracle; + emit ProviderEligibilityOracleSet(oldOracle, oracle); } /** @@ -335,9 +338,9 @@ contract RewardsManager is } /** - * @inheritdoc IRewardsManager + * @inheritdoc IProviderEligibilityManagement */ - function getRewardsEligibilityOracle() external view override returns (IRewardsEligibility) { + function getProviderEligibilityOracle() external view override returns (IProviderEligibility) { return rewardsEligibilityOracle; } diff --git a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol index 6e8606b2b..5969d11c6 100644 --- a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol +++ b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol @@ -8,7 +8,7 @@ pragma solidity ^0.7.6 || ^0.8.27; import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol"; import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManager.sol"; import { IRewardsManagerDeprecated } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManagerDeprecated.sol"; @@ -102,7 +102,7 @@ abstract contract RewardsManagerV6Storage is RewardsManagerV5Storage { /// @dev Address of the rewards eligibility oracle contract /// When set, indexers must pass eligibility check to claim rewards. /// Zero address disables eligibility checks. - IRewardsEligibility internal rewardsEligibilityOracle; + IProviderEligibility internal rewardsEligibilityOracle; /// @dev Address of the issuance allocator /// When set, determines GRT issued per block. Zero address uses issuancePerBlock storage value. diff --git a/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol b/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol index 03d26d9e6..b0ac05a19 100644 --- a/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol +++ b/packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol @@ -4,7 +4,7 @@ pragma solidity ^0.7.6; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol"; /** @@ -13,7 +13,7 @@ import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol"; * @notice A simple mock contract for the RewardsEligibilityOracle interface * @dev A simple mock contract for the RewardsEligibilityOracle interface */ -contract MockRewardsEligibilityOracle is IRewardsEligibility, IERC165 { +contract MockRewardsEligibilityOracle is IProviderEligibility, IERC165 { /// @dev Mapping to store eligibility status for each indexer mapping(address => bool) private eligible; @@ -50,7 +50,7 @@ contract MockRewardsEligibilityOracle is IRewardsEligibility, IERC165 { } /** - * @inheritdoc IRewardsEligibility + * @inheritdoc IProviderEligibility */ function isEligible(address indexer) external view override returns (bool) { // If the indexer has been explicitly set, return that value @@ -66,6 +66,6 @@ contract MockRewardsEligibilityOracle is IRewardsEligibility, IERC165 { * @inheritdoc IERC165 */ function supportsInterface(bytes4 interfaceId) public pure override returns (bool) { - return interfaceId == type(IRewardsEligibility).interfaceId || interfaceId == type(IERC165).interfaceId; + return interfaceId == type(IProviderEligibility).interfaceId || interfaceId == type(IERC165).interfaceId; } } diff --git a/packages/deployment/deploy/rewards/eligibility/06_integrate.ts b/packages/deployment/deploy/rewards/eligibility/06_integrate.ts index b7670f7e3..3773c6982 100644 --- a/packages/deployment/deploy/rewards/eligibility/06_integrate.ts +++ b/packages/deployment/deploy/rewards/eligibility/06_integrate.ts @@ -19,7 +19,7 @@ const func: DeployScriptModule = async (env) => { ]) const client = graph.getPublicClient(env) as PublicClient - // Apply: RM.rewardsEligibilityOracle = REO (always governance TX) + // Apply: RM.providerEligibilityOracle = REO (always governance TX) await applyConfiguration(env, client, [createRMIntegrationCondition(reo.address)], { contractName: `${Contracts.horizon.RewardsManager.name}-REO`, contractAddress: rm.address, diff --git a/packages/deployment/docs/Design.md b/packages/deployment/docs/Design.md index c6f972507..d53d22125 100644 --- a/packages/deployment/docs/Design.md +++ b/packages/deployment/docs/Design.md @@ -110,7 +110,7 @@ graph LR RM -->|check eligibility| REO ``` -**Integration:** `RewardsManager.setRewardsEligibilityOracle(REO)` via governance +**Integration:** `RewardsManager.setProviderEligibilityOracle(REO)` via governance ### IssuanceAllocator Integration diff --git a/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md b/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md index 6d05be2e4..9a5c1bfde 100644 --- a/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md +++ b/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md @@ -60,7 +60,7 @@ pnpm hardhat deploy --tags rewards-eligibility-integrate --network ### Integration -- [ ] `RewardsManager.getRewardsEligibilityOracle()` returns REO address +- [ ] `RewardsManager.getProviderEligibilityOracle()` returns REO address ## Configuration Parameters diff --git a/packages/deployment/lib/contract-checks.ts b/packages/deployment/lib/contract-checks.ts index c12b324cd..412b5243e 100644 --- a/packages/deployment/lib/contract-checks.ts +++ b/packages/deployment/lib/contract-checks.ts @@ -746,15 +746,15 @@ export function formatAddress(address: string): string { /** * Create RewardsManager integration condition for REO * - * Checks that RewardsManager.getRewardsEligibilityOracle() == reoAddress + * Checks that RewardsManager.getProviderEligibilityOracle() == reoAddress */ export function createRMIntegrationCondition(reoAddress: string): ParamCondition { return { - name: 'rewardsEligibilityOracle', + name: 'providerEligibilityOracle', description: 'RewardsEligibilityOracle', abi: REWARDS_MANAGER_ABI, - getter: 'getRewardsEligibilityOracle', - setter: 'setRewardsEligibilityOracle', + getter: 'getProviderEligibilityOracle', + setter: 'setProviderEligibilityOracle', target: reoAddress, compare: addressEquals, format: formatAddress, diff --git a/packages/deployment/tasks/deployment-status.ts b/packages/deployment/tasks/deployment-status.ts index 7bf9061c0..8b5994f0d 100644 --- a/packages/deployment/tasks/deployment-status.ts +++ b/packages/deployment/tasks/deployment-status.ts @@ -340,10 +340,10 @@ async function getRewardsEligibilityOracleChecks( const currentREO = (await client.readContract({ address: rmAddress as `0x${string}`, abi: REWARDS_MANAGER_ABI, - functionName: 'getRewardsEligibilityOracle', + functionName: 'getProviderEligibilityOracle', })) as string const configured = currentREO.toLowerCase() === reoAddress.toLowerCase() - checks.push({ ok: configured, label: 'RM.rewardsEligibilityOracle == this' }) + checks.push({ ok: configured, label: 'RM.providerEligibilityOracle == this' }) } catch { // Function not available on old RM } diff --git a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol index 05d609101..43a13d791 100644 --- a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol @@ -3,7 +3,6 @@ pragma solidity ^0.7.6 || ^0.8.0; import { IIssuanceAllocationDistribution } from "../../issuance/allocate/IIssuanceAllocationDistribution.sol"; -import { IRewardsEligibility } from "../../issuance/eligibility/IRewardsEligibility.sol"; import { IRewardsIssuer } from "./IRewardsIssuer.sol"; /** @@ -53,16 +52,6 @@ interface IRewardsManager { event RewardsDeniedDueToEligibility(address indexed indexer, address indexed allocationID, uint256 amount); // solhint-disable-previous-line gas-indexed-events - /** - * @notice Emitted when the rewards eligibility oracle contract is set - * @param oldRewardsEligibilityOracle Previous rewards eligibility oracle address - * @param newRewardsEligibilityOracle New rewards eligibility oracle address - */ - event RewardsEligibilityOracleSet( - address indexed oldRewardsEligibilityOracle, - address indexed newRewardsEligibilityOracle - ); - /** * @notice New reclaim address set * @param reason The reclaim reason (or condition) identifier (see RewardsCondition library for canonical reasons) @@ -124,12 +113,6 @@ interface IRewardsManager { */ function setSubgraphService(address newSubgraphService) external; - /** - * @notice Set the rewards eligibility oracle address - * @param newRewardsEligibilityOracle The address of the rewards eligibility oracle - */ - function setRewardsEligibilityOracle(address newRewardsEligibilityOracle) external; - /** * @notice Set the reclaim address for a specific reason * @dev Address to mint tokens for denied/reclaimed rewards. Set to zero to disable. @@ -201,12 +184,6 @@ interface IRewardsManager { */ function getDefaultReclaimAddress() external view returns (address); - /** - * @notice Get the rewards eligibility oracle address - * @return The rewards eligibility oracle contract - */ - function getRewardsEligibilityOracle() external view returns (IRewardsEligibility); - /** * @notice Gets the effective issuance per block, accounting for the issuance allocator * @dev When an issuance allocator is set, returns the allocated rate for this contract. diff --git a/packages/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol b/packages/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol new file mode 100644 index 000000000..3e8dc3cfe --- /dev/null +++ b/packages/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.7.6 || ^0.8.0; + +/** + * @title IProviderEligibility + * @author Edge & Node + * @notice Minimal interface for checking service provider eligibility to receive rewards or payments. + * Particularly relevant when paid by the protocol from issuance. + * @dev This is the interface that consumers (e.g., RewardsManager, RecurringAgreementManager) need to check + * if a provider is eligible to receive rewards. + */ +interface IProviderEligibility { + /** + * @notice Check if a service provider is eligible to receive rewards or other payments. + * @param provider Address of the service provider + * @return eligible True if the provider is eligible, false otherwise + */ + function isEligible(address provider) external view returns (bool eligible); +} diff --git a/packages/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol b/packages/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol new file mode 100644 index 000000000..69d450f54 --- /dev/null +++ b/packages/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.7.6 || ^0.8.0; + +import { IProviderEligibility } from "./IProviderEligibility.sol"; + +/** + * @title Interface for provider eligibility oracle configuration + * @author Edge & Node + * @notice Configures the provider eligibility oracle that determines which providers + * are eligible for rewards or payments. + */ +interface IProviderEligibilityManagement { + // -- Events -- + + /** + * @notice Emitted when the provider eligibility oracle is changed + * @param oldOracle The previous oracle (IProviderEligibility(address(0)) means none) + * @param newOracle The new oracle (IProviderEligibility(address(0)) means disabled) + */ + event ProviderEligibilityOracleSet(IProviderEligibility indexed oldOracle, IProviderEligibility indexed newOracle); + + // -- Functions -- + + /** + * @notice Set the provider eligibility oracle. + * @dev When set, {isEligible} delegates to this oracle. + * When set to IProviderEligibility(address(0)), all providers are considered eligible (passthrough). + * @param oracle The eligibility oracle (or IProviderEligibility(address(0)) to disable) + */ + function setProviderEligibilityOracle(IProviderEligibility oracle) external; + + /** + * @notice Get the current provider eligibility oracle + * @return oracle The eligibility oracle (IProviderEligibility(address(0)) means disabled) + */ + function getProviderEligibilityOracle() external view returns (IProviderEligibility oracle); +} diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol deleted file mode 100644 index 53c8acf85..000000000 --- a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -pragma solidity ^0.7.6 || ^0.8.0; - -/** - * @title IRewardsEligibility - * @author Edge & Node - * @notice Minimal interface for checking indexer rewards eligibility - * @dev This is the interface that consumers (e.g., RewardsManager) need to check - * if an indexer is eligible to receive rewards - */ -interface IRewardsEligibility { - /** - * @notice Check if an indexer is eligible to receive rewards - * @param indexer Address of the indexer - * @return True if the indexer is eligible to receive rewards, false otherwise - */ - function isEligible(address indexer) external view returns (bool); -} diff --git a/packages/interfaces/src/types/issuance.ts b/packages/interfaces/src/types/issuance.ts index 812b1853b..71902a19b 100644 --- a/packages/interfaces/src/types/issuance.ts +++ b/packages/interfaces/src/types/issuance.ts @@ -5,7 +5,7 @@ import type { IIssuanceAllocationStatus, IIssuanceTarget, IPausableControl, - IRewardsEligibility, + IProviderEligibility, IRewardsEligibilityAdministration, IRewardsEligibilityEvents, IRewardsEligibilityReporting, @@ -20,7 +20,7 @@ export { IIssuanceAllocationStatus as IssuanceAllocationStatus, IIssuanceTarget as IssuanceTarget, IPausableControl as PausableControl, - IRewardsEligibility as RewardsEligibility, + IProviderEligibility as ProviderEligibility, IRewardsEligibilityAdministration as RewardsEligibilityAdministration, IRewardsEligibilityEvents as RewardsEligibilityEvents, IRewardsEligibilityReporting as RewardsEligibilityReporting, diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md index 60449c6d4..26c9123fe 100644 --- a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md @@ -307,4 +307,4 @@ The system is deployed with reasonable defaults but can be adjusted as required. ## Integration -The contract implements four focused interfaces (`IRewardsEligibility`, `IRewardsEligibilityAdministration`, `IRewardsEligibilityReporting`, and `IRewardsEligibilityStatus`) and can be integrated with any system that needs to verify indexer eligibility status. The primary integration point is the `isEligible(address)` function which returns a simple boolean indicating eligibility. +The contract implements four focused interfaces (`IProviderEligibility`, `IRewardsEligibilityAdministration`, `IRewardsEligibilityReporting`, and `IRewardsEligibilityStatus`) and can be integrated with any system that needs to verify provider eligibility status. The primary integration point is the `isEligible(address)` function which returns a simple boolean indicating eligibility. diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol index 06ed29e8d..7ddc1efbd 100644 --- a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.27; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IRewardsEligibilityAdministration } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol"; import { IRewardsEligibilityReporting } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityReporting.sol"; import { IRewardsEligibilityStatus } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol"; @@ -27,7 +27,7 @@ import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; */ contract RewardsEligibilityOracle is BaseUpgradeable, - IRewardsEligibility, + IProviderEligibility, IRewardsEligibilityAdministration, IRewardsEligibilityReporting, IRewardsEligibilityStatus @@ -124,7 +124,7 @@ contract RewardsEligibilityOracle is */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return - interfaceId == type(IRewardsEligibility).interfaceId || + interfaceId == type(IProviderEligibility).interfaceId || interfaceId == type(IRewardsEligibilityAdministration).interfaceId || interfaceId == type(IRewardsEligibilityReporting).interfaceId || interfaceId == type(IRewardsEligibilityStatus).interfaceId || @@ -231,7 +231,7 @@ contract RewardsEligibilityOracle is // -- View Functions -- /** - * @inheritdoc IRewardsEligibility + * @inheritdoc IProviderEligibility * @dev Returns true if any of the following conditions are met: * 1. Eligibility validation is disabled globally * 2. Oracle timeout has been exceeded (fail-safe to allow all indexers) diff --git a/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol b/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol index 45668b582..6a1ff7d75 100644 --- a/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol +++ b/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.33; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IRewardsEligibilityAdministration } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol"; import { IRewardsEligibilityReporting } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityReporting.sol"; import { IRewardsEligibilityStatus } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol"; @@ -22,8 +22,8 @@ contract RewardsEligibilityOracleInterfaceTest is RewardsEligibilityOracleShared assertTrue(oracle.supportsInterface(type(IERC165).interfaceId)); } - function test_SupportsIRewardsEligibility() public view { - assertTrue(oracle.supportsInterface(type(IRewardsEligibility).interfaceId)); + function test_SupportsIProviderEligibility() public view { + assertTrue(oracle.supportsInterface(type(IProviderEligibility).interfaceId)); } function test_SupportsIRewardsEligibilityAdministration() public view { @@ -53,8 +53,8 @@ contract RewardsEligibilityOracleInterfaceTest is RewardsEligibilityOracleShared // ==================== Interface ID Stability ==================== // These guard against accidental interface changes that would break compatibility. - function test_InterfaceId_IRewardsEligibility() public pure { - assertEq(type(IRewardsEligibility).interfaceId, bytes4(0x66e305fd)); + function test_InterfaceId_IProviderEligibility() public pure { + assertEq(type(IProviderEligibility).interfaceId, bytes4(0x66e305fd)); } function test_InterfaceId_IRewardsEligibilityAdministration() public pure { diff --git a/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol b/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol index 7ae75636f..b6da3bb75 100644 --- a/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol +++ b/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.27; import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManager.sol"; import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; -import { IRewardsEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibility.sol"; import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; @@ -94,10 +93,6 @@ contract MockRewardsManager is IRewardsManager { return address(0); } - function getRewardsEligibilityOracle() external pure returns (IRewardsEligibility) { - return IRewardsEligibility(address(0)); - } - function getNewRewardsPerSignal() external view returns (uint256) {} function getAccRewardsPerSignal() external view returns (uint256) {} @@ -116,10 +111,6 @@ contract MockRewardsManager is IRewardsManager { function getRawIssuancePerBlock() external view returns (uint256) {} - // -- Setters -- - - function setRewardsEligibilityOracle(address newRewardsEligibilityOracle) external {} - // -- Updates -- function updateAccRewardsPerSignal() external returns (uint256) {} From d20bc844d16094fc923b91d34818c5c7bd00365c Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:48:46 +0000 Subject: [PATCH 045/157] feat: contract approver model for RecurringCollector accept/update Add IAgreementOwner interface enabling contracts to approve RCA accept/update by implementing an on-chain callback. When the signature parameter is empty, accept() and update() fall back to calling IAgreementOwner.approveAgreement() on the payer contract instead of verifying an ECDSA signature. Also adds getMaxNextClaim() view and removes the SignedRCA/SignedRCAU wrapper structs in favor of separate (struct, bytes) parameters. --- .../collectors/RecurringCollector.sol | 338 ++++++++++++------ .../MockAgreementOwner.t.sol | 107 ++++++ .../RecurringCollectorHelper.t.sol | 29 +- .../payments/recurring-collector/accept.t.sol | 36 +- .../recurring-collector/acceptUnsigned.t.sol | 189 ++++++++++ .../payments/recurring-collector/base.t.sol | 20 +- .../payments/recurring-collector/cancel.t.sol | 13 +- .../recurring-collector/collect.t.sol | 151 ++++---- .../payments/recurring-collector/shared.t.sol | 67 ++-- .../payments/recurring-collector/update.t.sol | 185 +++++----- .../recurring-collector/updateUnsigned.t.sol | 274 ++++++++++++++ .../contracts/horizon/IAgreementOwner.sol | 32 ++ .../contracts/horizon/IRecurringCollector.sol | 77 ++-- 13 files changed, 1147 insertions(+), 371 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol create mode 100644 packages/interfaces/contracts/horizon/IAgreementOwner.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 5af3bf863..452822a05 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -9,8 +9,11 @@ import { Authorizable } from "../../utilities/Authorizable.sol"; import { GraphDirectory } from "../../utilities/GraphDirectory.sol"; // solhint-disable-next-line no-unused-import import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol"; // for @inheritdoc +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { PPMMath } from "../../libraries/PPMMath.sol"; /** @@ -72,49 +75,58 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } } - /* solhint-disable function-max-lines */ /** * @inheritdoc IRecurringCollector * @notice Accept a Recurring Collection Agreement. - * See {IRecurringCollector.accept}. * @dev Caller must be the data service the RCA was issued to. */ - function accept(SignedRCA calldata signedRCA) external returns (bytes16) { - bytes16 agreementId = _generateAgreementId( - signedRCA.rca.payer, - signedRCA.rca.dataService, - signedRCA.rca.serviceProvider, - signedRCA.rca.deadline, - signedRCA.rca.nonce - ); - - require(agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); - require( - msg.sender == signedRCA.rca.dataService, - RecurringCollectorUnauthorizedCaller(msg.sender, signedRCA.rca.dataService) - ); + function accept(RecurringCollectionAgreement calldata rca, bytes calldata signature) external returns (bytes16) { /* solhint-disable gas-strict-inequalities */ require( - signedRCA.rca.deadline >= block.timestamp, - RecurringCollectorAgreementDeadlineElapsed(block.timestamp, signedRCA.rca.deadline) + rca.deadline >= block.timestamp, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) ); /* solhint-enable gas-strict-inequalities */ - // check that the voucher is signed by the payer (or proxy) - _requireAuthorizedRCASigner(signedRCA); + if (0 < signature.length) { + // ECDSA-signed path: verify signature + _requireAuthorizedRCASigner(rca, signature); + } else { + // Contract-approved path: verify payer is a contract and confirms the agreement + require(0 < rca.payer.code.length, RecurringCollectorApproverNotContract(rca.payer)); + bytes32 agreementHash = _hashRCA(rca); + require( + IAgreementOwner(rca.payer).approveAgreement(agreementHash) == IAgreementOwner.approveAgreement.selector, + RecurringCollectorInvalidSigner() + ); + } + return _validateAndStoreAgreement(rca); + } + + /** + * @notice Validates RCA fields and stores the agreement. + * @param _rca The Recurring Collection Agreement to validate and store + * @return agreementId The deterministically generated agreement ID + */ + /* solhint-disable function-max-lines */ + function _validateAndStoreAgreement(RecurringCollectionAgreement memory _rca) private returns (bytes16) { + bytes16 agreementId = _generateAgreementId( + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.deadline, + _rca.nonce + ); + + require(agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); + require(msg.sender == _rca.dataService, RecurringCollectorUnauthorizedCaller(msg.sender, _rca.dataService)); require( - signedRCA.rca.dataService != address(0) && - signedRCA.rca.payer != address(0) && - signedRCA.rca.serviceProvider != address(0), + _rca.dataService != address(0) && _rca.payer != address(0) && _rca.serviceProvider != address(0), RecurringCollectorAgreementAddressNotSet() ); - _requireValidCollectionWindowParams( - signedRCA.rca.endsAt, - signedRCA.rca.minSecondsPerCollection, - signedRCA.rca.maxSecondsPerCollection - ); + _requireValidCollectionWindowParams(_rca.endsAt, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection); AgreementData storage agreement = _getAgreementStorage(agreementId); // check that the agreement is not already accepted @@ -126,14 +138,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC // accept the agreement agreement.acceptedAt = uint64(block.timestamp); agreement.state = AgreementState.Accepted; - agreement.dataService = signedRCA.rca.dataService; - agreement.payer = signedRCA.rca.payer; - agreement.serviceProvider = signedRCA.rca.serviceProvider; - agreement.endsAt = signedRCA.rca.endsAt; - agreement.maxInitialTokens = signedRCA.rca.maxInitialTokens; - agreement.maxOngoingTokensPerSecond = signedRCA.rca.maxOngoingTokensPerSecond; - agreement.minSecondsPerCollection = signedRCA.rca.minSecondsPerCollection; - agreement.maxSecondsPerCollection = signedRCA.rca.maxSecondsPerCollection; + agreement.dataService = _rca.dataService; + agreement.payer = _rca.payer; + agreement.serviceProvider = _rca.serviceProvider; + agreement.endsAt = _rca.endsAt; + agreement.maxInitialTokens = _rca.maxInitialTokens; + agreement.maxOngoingTokensPerSecond = _rca.maxOngoingTokensPerSecond; + agreement.minSecondsPerCollection = _rca.minSecondsPerCollection; + agreement.maxSecondsPerCollection = _rca.maxSecondsPerCollection; agreement.updateNonce = 0; emit AgreementAccepted( @@ -186,80 +198,54 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ); } - /* solhint-disable function-max-lines */ /** * @inheritdoc IRecurringCollector * @notice Update a Recurring Collection Agreement. - * See {IRecurringCollector.update}. * @dev Caller must be the data service for the agreement. * @dev Note: Updated pricing terms apply immediately and will affect the next collection * for the entire period since lastCollectionAt. */ - function update(SignedRCAU calldata signedRCAU) external { + function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external { + AgreementData storage agreement = _requireValidUpdateTarget(rcau.agreementId); + /* solhint-disable gas-strict-inequalities */ require( - signedRCAU.rcau.deadline >= block.timestamp, - RecurringCollectorAgreementDeadlineElapsed(block.timestamp, signedRCAU.rcau.deadline) + rcau.deadline >= block.timestamp, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rcau.deadline) ); /* solhint-enable gas-strict-inequalities */ - AgreementData storage agreement = _getAgreementStorage(signedRCAU.rcau.agreementId); - require( - agreement.state == AgreementState.Accepted, - RecurringCollectorAgreementIncorrectState(signedRCAU.rcau.agreementId, agreement.state) - ); - require( - agreement.dataService == msg.sender, - RecurringCollectorDataServiceNotAuthorized(signedRCAU.rcau.agreementId, msg.sender) - ); - - // check that the voucher is signed by the payer (or proxy) - _requireAuthorizedRCAUSigner(signedRCAU, agreement.payer); - - // validate nonce to prevent replay attacks - uint32 expectedNonce = agreement.updateNonce + 1; - require( - signedRCAU.rcau.nonce == expectedNonce, - RecurringCollectorInvalidUpdateNonce(signedRCAU.rcau.agreementId, expectedNonce, signedRCAU.rcau.nonce) - ); - - _requireValidCollectionWindowParams( - signedRCAU.rcau.endsAt, - signedRCAU.rcau.minSecondsPerCollection, - signedRCAU.rcau.maxSecondsPerCollection - ); - - // update the agreement - agreement.endsAt = signedRCAU.rcau.endsAt; - agreement.maxInitialTokens = signedRCAU.rcau.maxInitialTokens; - agreement.maxOngoingTokensPerSecond = signedRCAU.rcau.maxOngoingTokensPerSecond; - agreement.minSecondsPerCollection = signedRCAU.rcau.minSecondsPerCollection; - agreement.maxSecondsPerCollection = signedRCAU.rcau.maxSecondsPerCollection; - agreement.updateNonce = signedRCAU.rcau.nonce; + if (0 < signature.length) { + // ECDSA-signed path: verify signature + _requireAuthorizedRCAUSigner(rcau, signature, agreement.payer); + } else { + // Contract-approved path: verify payer is a contract and confirms the update + require(0 < agreement.payer.code.length, RecurringCollectorApproverNotContract(agreement.payer)); + bytes32 updateHash = _hashRCAU(rcau); + require( + IAgreementOwner(agreement.payer).approveAgreement(updateHash) == + IAgreementOwner.approveAgreement.selector, + RecurringCollectorInvalidSigner() + ); + } - emit AgreementUpdated( - agreement.dataService, - agreement.payer, - agreement.serviceProvider, - signedRCAU.rcau.agreementId, - uint64(block.timestamp), - agreement.endsAt, - agreement.maxInitialTokens, - agreement.maxOngoingTokensPerSecond, - agreement.minSecondsPerCollection, - agreement.maxSecondsPerCollection - ); + _validateAndStoreUpdate(agreement, rcau); } - /* solhint-enable function-max-lines */ /// @inheritdoc IRecurringCollector - function recoverRCASigner(SignedRCA calldata signedRCA) external view returns (address) { - return _recoverRCASigner(signedRCA); + function recoverRCASigner( + RecurringCollectionAgreement calldata rca, + bytes calldata signature + ) external view returns (address) { + return _recoverRCASigner(rca, signature); } /// @inheritdoc IRecurringCollector - function recoverRCAUSigner(SignedRCAU calldata signedRCAU) external view returns (address) { - return _recoverRCAUSigner(signedRCAU); + function recoverRCAUSigner( + RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata signature + ) external view returns (address) { + return _recoverRCAUSigner(rcau, signature); } /// @inheritdoc IRecurringCollector @@ -284,6 +270,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return _getCollectionInfo(agreement); } + /// @inheritdoc IRecurringCollector + function getMaxNextClaim(bytes16 agreementId) external view returns (uint256) { + return _getMaxNextClaim(agreements[agreementId]); + } + /// @inheritdoc IRecurringCollector function generateAgreementId( address payer, @@ -364,7 +355,23 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } agreement.lastCollectionAt = uint64(block.timestamp); - if (tokensToCollect > 0) { + // Hard eligibility gate for contract payers that opt in via ERC165 + if (0 < tokensToCollect && 0 < agreement.payer.code.length) { + try IERC165(agreement.payer).supportsInterface(type(IProviderEligibility).interfaceId) returns ( + bool supported + ) { + if (supported) { + require( + IProviderEligibility(agreement.payer).isEligible(agreement.serviceProvider), + RecurringCollectorCollectionNotEligible(_params.agreementId, agreement.serviceProvider) + ); + } + } catch {} + // Let contract payers top up escrow if short + try IAgreementOwner(agreement.payer).beforeCollection(_params.agreementId, tokensToCollect) {} catch {} + } + + if (0 < tokensToCollect) { _graphPaymentsEscrow().collect( _paymentType, agreement.payer, @@ -395,6 +402,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _params.dataServiceCut ); + // Notify contract payers so they can reconcile escrow in the same transaction + if (0 < agreement.payer.code.length) { + try IAgreementOwner(agreement.payer).afterCollection(_params.agreementId, tokensToCollect) {} catch {} + } + return tokensToCollect; } /* solhint-enable function-max-lines */ @@ -475,22 +487,30 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @notice See {recoverRCASigner} - * @param _signedRCA The signed RCA to recover the signer from + * @param _rca The RCA whose hash was signed + * @param _signature The ECDSA signature bytes * @return The address of the signer */ - function _recoverRCASigner(SignedRCA memory _signedRCA) private view returns (address) { - bytes32 messageHash = _hashRCA(_signedRCA.rca); - return ECDSA.recover(messageHash, _signedRCA.signature); + function _recoverRCASigner( + RecurringCollectionAgreement memory _rca, + bytes memory _signature + ) private view returns (address) { + bytes32 messageHash = _hashRCA(_rca); + return ECDSA.recover(messageHash, _signature); } /** * @notice See {recoverRCAUSigner} - * @param _signedRCAU The signed RCAU to recover the signer from + * @param _rcau The RCAU whose hash was signed + * @param _signature The ECDSA signature bytes * @return The address of the signer */ - function _recoverRCAUSigner(SignedRCAU memory _signedRCAU) private view returns (address) { - bytes32 messageHash = _hashRCAU(_signedRCAU.rcau); - return ECDSA.recover(messageHash, _signedRCAU.signature); + function _recoverRCAUSigner( + RecurringCollectionAgreementUpdate memory _rcau, + bytes memory _signature + ) private view returns (address) { + bytes32 messageHash = _hashRCAU(_rcau); + return ECDSA.recover(messageHash, _signature); } /** @@ -548,12 +568,16 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @notice Requires that the signer for the RCA is authorized * by the payer of the RCA. - * @param _signedRCA The signed RCA to verify + * @param _rca The RCA whose hash was signed + * @param _signature The ECDSA signature bytes * @return The address of the authorized signer */ - function _requireAuthorizedRCASigner(SignedRCA memory _signedRCA) private view returns (address) { - address signer = _recoverRCASigner(_signedRCA); - require(_isAuthorized(_signedRCA.rca.payer, signer), RecurringCollectorInvalidSigner()); + function _requireAuthorizedRCASigner( + RecurringCollectionAgreement memory _rca, + bytes memory _signature + ) private view returns (address) { + address signer = _recoverRCASigner(_rca, _signature); + require(_isAuthorized(_rca.payer, signer), RecurringCollectorInvalidSigner()); return signer; } @@ -561,20 +585,81 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /** * @notice Requires that the signer for the RCAU is authorized * by the payer. - * @param _signedRCAU The signed RCAU to verify + * @param _rcau The RCAU whose hash was signed + * @param _signature The ECDSA signature bytes * @param _payer The address of the payer * @return The address of the authorized signer */ function _requireAuthorizedRCAUSigner( - SignedRCAU memory _signedRCAU, + RecurringCollectionAgreementUpdate memory _rcau, + bytes memory _signature, address _payer ) private view returns (address) { - address signer = _recoverRCAUSigner(_signedRCAU); + address signer = _recoverRCAUSigner(_rcau, _signature); require(_isAuthorized(_payer, signer), RecurringCollectorInvalidSigner()); return signer; } + /** + * @notice Validates that an agreement is in a valid state for updating and that the caller is authorized. + * @param _agreementId The ID of the agreement to validate + * @return The storage reference to the agreement data + */ + function _requireValidUpdateTarget(bytes16 _agreementId) private view returns (AgreementData storage) { + AgreementData storage agreement = _getAgreementStorage(_agreementId); + require( + agreement.state == AgreementState.Accepted, + RecurringCollectorAgreementIncorrectState(_agreementId, agreement.state) + ); + require( + agreement.dataService == msg.sender, + RecurringCollectorDataServiceNotAuthorized(_agreementId, msg.sender) + ); + return agreement; + } + + /** + * @notice Validates and stores an update to a Recurring Collection Agreement. + * Shared validation/storage/emit logic for the update function. + * @param _agreement The storage reference to the agreement data + * @param _rcau The Recurring Collection Agreement Update to apply + */ + function _validateAndStoreUpdate( + AgreementData storage _agreement, + RecurringCollectionAgreementUpdate calldata _rcau + ) private { + // validate nonce to prevent replay attacks + uint32 expectedNonce = _agreement.updateNonce + 1; + require( + _rcau.nonce == expectedNonce, + RecurringCollectorInvalidUpdateNonce(_rcau.agreementId, expectedNonce, _rcau.nonce) + ); + + _requireValidCollectionWindowParams(_rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection); + + // update the agreement + _agreement.endsAt = _rcau.endsAt; + _agreement.maxInitialTokens = _rcau.maxInitialTokens; + _agreement.maxOngoingTokensPerSecond = _rcau.maxOngoingTokensPerSecond; + _agreement.minSecondsPerCollection = _rcau.minSecondsPerCollection; + _agreement.maxSecondsPerCollection = _rcau.maxSecondsPerCollection; + _agreement.updateNonce = _rcau.nonce; + + emit AgreementUpdated( + _agreement.dataService, + _agreement.payer, + _agreement.serviceProvider, + _rcau.agreementId, + uint64(block.timestamp), + _agreement.endsAt, + _agreement.maxInitialTokens, + _agreement.maxOngoingTokensPerSecond, + _agreement.minSecondsPerCollection, + _agreement.maxSecondsPerCollection + ); + } + /** * @notice Gets an agreement to be updated. * @param _agreementId The ID of the agreement to get @@ -646,6 +731,45 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; } + /** + * @notice Compute the maximum tokens collectable in the next collection (worst case). + * @dev For active agreements uses endsAt as the collection end (worst case), + * not block.timestamp (current). Returns 0 for non-collectable states. + * @param _a The agreement data + * @return The maximum tokens that could be collected + */ + function _getMaxNextClaim(AgreementData memory _a) private pure returns (uint256) { + // CanceledByServiceProvider = immediately non-collectable + if (_a.state == AgreementState.CanceledByServiceProvider) return 0; + // Only Accepted and CanceledByPayer are collectable + if (_a.state != AgreementState.Accepted && _a.state != AgreementState.CanceledByPayer) return 0; + + // Collection starts from last collection (or acceptance if never collected) + uint256 collectionStart = 0 < _a.lastCollectionAt ? _a.lastCollectionAt : _a.acceptedAt; + + // Determine the latest possible collection end + uint256 collectionEnd; + if (_a.state == AgreementState.CanceledByPayer) { + // Payer cancel freezes the window at min(canceledAt, endsAt) + collectionEnd = _a.canceledAt < _a.endsAt ? _a.canceledAt : _a.endsAt; + } else { + // Active: collection window capped at endsAt + collectionEnd = _a.endsAt; + } + + // No collection possible if window is empty + // solhint-disable-next-line gas-strict-inequalities + if (collectionEnd <= collectionStart) return 0; + + // Max seconds is capped by maxSecondsPerCollection (enforced by _requireValidCollect) + uint256 windowSeconds = collectionEnd - collectionStart; + uint256 maxSeconds = windowSeconds < _a.maxSecondsPerCollection ? windowSeconds : _a.maxSecondsPerCollection; + + uint256 maxClaim = _a.maxOngoingTokensPerSecond * maxSeconds; + if (_a.lastCollectionAt == 0) maxClaim += _a.maxInitialTokens; + return maxClaim; + } + /** * @notice Internal function to generate deterministic agreement ID * @param _payer The address of the payer diff --git a/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol new file mode 100644 index 000000000..614dab81a --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; + +/// @notice Mock contract approver for testing acceptUnsigned and updateUnsigned. +/// Can be configured to return valid selector, wrong value, or revert. +/// Optionally supports IERC165 + IProviderEligibility for eligibility gate testing. +contract MockAgreementOwner is IAgreementOwner, IERC165, IProviderEligibility { + mapping(bytes32 => bool) public authorizedHashes; + bool public shouldRevert; + bytes4 public overrideReturnValue; + bool public useOverride; + + // -- Eligibility configuration -- + bool public eligibilityEnabled; + mapping(address => bool) public eligibleProviders; + bool public defaultEligible; + + function authorize(bytes32 agreementHash) external { + authorizedHashes[agreementHash] = true; + } + + function setShouldRevert(bool _shouldRevert) external { + shouldRevert = _shouldRevert; + } + + function setOverrideReturnValue(bytes4 _value) external { + overrideReturnValue = _value; + useOverride = true; + } + + function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { + if (shouldRevert) { + revert("MockAgreementOwner: forced revert"); + } + if (useOverride) { + return overrideReturnValue; + } + if (!authorizedHashes[agreementHash]) { + return bytes4(0); + } + return IAgreementOwner.approveAgreement.selector; + } + + bytes16 public lastBeforeCollectionAgreementId; + uint256 public lastBeforeCollectionTokens; + bool public shouldRevertOnBeforeCollection; + + function setShouldRevertOnBeforeCollection(bool _shouldRevert) external { + shouldRevertOnBeforeCollection = _shouldRevert; + } + + function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external override { + if (shouldRevertOnBeforeCollection) { + revert("MockAgreementOwner: forced revert on beforeCollection"); + } + lastBeforeCollectionAgreementId = agreementId; + lastBeforeCollectionTokens = tokensToCollect; + } + + bytes16 public lastCollectedAgreementId; + uint256 public lastCollectedTokens; + bool public shouldRevertOnCollected; + + function setShouldRevertOnCollected(bool _shouldRevert) external { + shouldRevertOnCollected = _shouldRevert; + } + + function afterCollection(bytes16 agreementId, uint256 tokensCollected) external override { + if (shouldRevertOnCollected) { + revert("MockAgreementOwner: forced revert on afterCollection"); + } + lastCollectedAgreementId = agreementId; + lastCollectedTokens = tokensCollected; + } + + // -- ERC165 + IProviderEligibility -- + + /// @notice Enable ERC165 reporting of IProviderEligibility support + function setEligibilityEnabled(bool _enabled) external { + eligibilityEnabled = _enabled; + } + + /// @notice Set whether a specific provider is eligible + function setProviderEligible(address provider, bool _eligible) external { + eligibleProviders[provider] = _eligible; + } + + /// @notice Set default eligibility for providers not explicitly configured + function setDefaultEligible(bool _eligible) external { + defaultEligible = _eligible; + } + + function supportsInterface(bytes4 interfaceId) external view override returns (bool) { + if (interfaceId == type(IERC165).interfaceId) return true; + if (interfaceId == type(IProviderEligibility).interfaceId) return eligibilityEnabled; + return false; + } + + function isEligible(address indexer) external view override returns (bool) { + if (eligibleProviders[indexer]) return true; + return defaultEligible; + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index b483413ae..9a01754aa 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -18,38 +18,30 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { function generateSignedRCA( IRecurringCollector.RecurringCollectionAgreement memory rca, uint256 signerPrivateKey - ) public view returns (IRecurringCollector.SignedRCA memory) { + ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes memory) { bytes32 messageHash = collector.hashRCA(rca); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); - IRecurringCollector.SignedRCA memory signedRCA = IRecurringCollector.SignedRCA({ - rca: rca, - signature: signature - }); - return signedRCA; + return (rca, signature); } function generateSignedRCAU( IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, uint256 signerPrivateKey - ) public view returns (IRecurringCollector.SignedRCAU memory) { + ) public view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory, bytes memory) { bytes32 messageHash = collector.hashRCAU(rcau); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); - IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ - rcau: rcau, - signature: signature - }); - return signedRCAU; + return (rcau, signature); } function generateSignedRCAUForAgreement( bytes16 agreementId, IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, uint256 signerPrivateKey - ) public view returns (IRecurringCollector.SignedRCAU memory) { + ) public view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory, bytes memory) { // Automatically set the correct nonce based on current agreement state IRecurringCollector.AgreementData memory agreement = collector.getAgreement(agreementId); rcau.nonce = agreement.updateNonce + 1; @@ -60,7 +52,7 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { function generateSignedRCAUWithCorrectNonce( IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, uint256 signerPrivateKey - ) public view returns (IRecurringCollector.SignedRCAU memory) { + ) public view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory, bytes memory) { // This is kept for backwards compatibility but should not be used with new interface // since we can't determine agreementId without it being passed separately return generateSignedRCAU(rcau, signerPrivateKey); @@ -69,7 +61,7 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { function generateSignedRCAWithCalculatedId( IRecurringCollector.RecurringCollectionAgreement memory rca, uint256 signerPrivateKey - ) public view returns (IRecurringCollector.SignedRCA memory, bytes16) { + ) public view returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes memory, bytes16) { // Ensure we have sensible values rca = sensibleRCA(rca); @@ -82,8 +74,11 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { rca.nonce ); - IRecurringCollector.SignedRCA memory signedRCA = generateSignedRCA(rca, signerPrivateKey); - return (signedRCA, agreementId); + (IRecurringCollector.RecurringCollectionAgreement memory signedRca, bytes memory signature) = generateSignedRCA( + rca, + signerPrivateKey + ); + return (signedRca, signature, agreementId); } function withElapsedAcceptDeadline( diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index 345d1a4f7..8404db85e 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -17,35 +17,41 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { } function test_Accept_Revert_WhenAcceptanceDeadlineElapsed( - IRecurringCollector.SignedRCA memory fuzzySignedRCA, + IRecurringCollector.RecurringCollectionAgreement memory fuzzyRCA, + bytes memory fuzzySignature, uint256 unboundedSkip ) public { + // Ensure non-empty signature so the signed path is taken (which checks deadline first) + vm.assume(fuzzySignature.length > 0); // Generate deterministic agreement ID for validation bytes16 agreementId = _recurringCollector.generateAgreementId( - fuzzySignedRCA.rca.payer, - fuzzySignedRCA.rca.dataService, - fuzzySignedRCA.rca.serviceProvider, - fuzzySignedRCA.rca.deadline, - fuzzySignedRCA.rca.nonce + fuzzyRCA.payer, + fuzzyRCA.dataService, + fuzzyRCA.serviceProvider, + fuzzyRCA.deadline, + fuzzyRCA.nonce ); vm.assume(agreementId != bytes16(0)); skip(boundSkip(unboundedSkip, 1, type(uint64).max - block.timestamp)); - fuzzySignedRCA.rca = _recurringCollectorHelper.withElapsedAcceptDeadline(fuzzySignedRCA.rca); + fuzzyRCA = _recurringCollectorHelper.withElapsedAcceptDeadline(fuzzyRCA); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, block.timestamp, - fuzzySignedRCA.rca.deadline + fuzzyRCA.deadline ); vm.expectRevert(expectedErr); - vm.prank(fuzzySignedRCA.rca.dataService); - _recurringCollector.accept(fuzzySignedRCA); + vm.prank(fuzzyRCA.dataService); + _recurringCollector.accept(fuzzyRCA, fuzzySignature); } function test_Accept_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes memory signature, + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, @@ -53,8 +59,8 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { IRecurringCollector.AgreementState.Accepted ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); - _recurringCollector.accept(accepted); + vm.prank(acceptedRca.dataService); + _recurringCollector.accept(acceptedRca, signature); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol new file mode 100644 index 000000000..153b69141 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { + function _newApprover() internal returns (MockAgreementOwner) { + return new MockAgreementOwner(); + } + + function _makeSimpleRCA(address payer) internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + } + + /* solhint-disable graph/func-name-mixedcase */ + + function test_AcceptUnsigned(FuzzyTestAccept calldata fuzzyTestAccept) public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + rca.payer = address(approver); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + + _setupValidProvision(rca.serviceProvider, rca.dataService); + + bytes16 expectedId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementAccepted( + rca.dataService, + rca.payer, + rca.serviceProvider, + expectedId, + uint64(block.timestamp), + rca.endsAt, + rca.maxInitialTokens, + rca.maxOngoingTokensPerSecond, + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection + ); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + assertEq(agreementId, expectedId); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(agreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + assertEq(agreement.payer, address(approver)); + assertEq(agreement.serviceProvider, rca.serviceProvider); + assertEq(agreement.dataService, rca.dataService); + } + + function test_AcceptUnsigned_Revert_WhenPayerNotContract() public { + address eoa = makeAddr("eoa"); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(eoa); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, eoa) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenHashNotAuthorized() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + // Don't authorize the hash + vm.expectRevert(); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenWrongMagicValue() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + approver.setOverrideReturnValue(bytes4(0xdeadbeef)); + + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenNotDataService() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + + address notDataService = makeAddr("notDataService"); + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorUnauthorizedCaller.selector, + notDataService, + rca.dataService + ) + ); + vm.prank(notDataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + rca.payer = address(approver); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.Accepted + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenApproverReverts() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + approver.setShouldRevert(true); + + vm.expectRevert("MockAgreementOwner: forced revert"); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + function test_AcceptUnsigned_Revert_WhenDeadlineElapsed() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + + // Advance time past the deadline + vm.warp(rca.deadline + 1); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + rca.deadline + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/base.t.sol b/packages/horizon/test/unit/payments/recurring-collector/base.t.sol index d1837837a..c37ced83f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/base.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/base.t.sol @@ -14,13 +14,13 @@ contract RecurringCollectorBaseTest is RecurringCollectorSharedTest { function test_RecoverRCASigner(FuzzyTestAccept memory fuzzyTestAccept) public view { uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); - IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA( - fuzzyTestAccept.rca, - signerKey - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(fuzzyTestAccept.rca, signerKey); assertEq( - _recurringCollector.recoverRCASigner(signedRCA), + _recurringCollector.recoverRCASigner(rca, signature), vm.addr(signerKey), "Recovered RCA signer does not match" ); @@ -28,13 +28,13 @@ contract RecurringCollectorBaseTest is RecurringCollectorSharedTest { function test_RecoverRCAUSigner(FuzzyTestUpdate memory fuzzyTestUpdate) public view { uint256 signerKey = boundKey(fuzzyTestUpdate.fuzzyTestAccept.unboundedSignerKey); - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( - fuzzyTestUpdate.rcau, - signerKey - ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCAU(fuzzyTestUpdate.rcau, signerKey); assertEq( - _recurringCollector.recoverRCAUSigner(signedRCAU), + _recurringCollector.recoverRCAUSigner(rcau, signature), vm.addr(signerKey), "Recovered RCAU signer does not match" ); diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol index a6128a7b5..1ccb0ccc1 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol @@ -13,11 +13,14 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ function test_Cancel(FuzzyTestAccept calldata fuzzyTestAccept, uint8 unboundedCanceler) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); - _cancel(accepted.rca, agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); + _cancel(acceptedRca, agreementId, _fuzzyCancelAgreementBy(unboundedCanceler)); } function test_Cancel_Revert_WhenNotAccepted( @@ -50,7 +53,7 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { ) public { vm.assume(fuzzyTestAccept.rca.dataService != notDataService); - (, , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index 95530e4b3..d19f5caed 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -30,7 +30,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { ) public { vm.assume(fuzzy.fuzzyTestAccept.rca.dataService != notDataService); - (, , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; skip(1); @@ -48,9 +48,12 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { } function test_Collect_Revert_WhenUnauthorizedDataService(FuzzyTestCollect calldata fuzzy) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; collectParams.agreementId = agreementId; collectParams.tokens = bound(collectParams.tokens, 1, type(uint256).max); @@ -61,8 +64,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { // Set up the scenario where service provider has no tokens staked with data service // This simulates an unauthorized data service attack _horizonStaking.setProvision( - accepted.rca.serviceProvider, - accepted.rca.dataService, + acceptedRca.serviceProvider, + acceptedRca.dataService, IHorizonStakingTypes.Provision({ tokens: 0, // No tokens staked - this triggers the vulnerability tokensThawing: 0, @@ -79,10 +82,10 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorUnauthorizedDataService.selector, - accepted.rca.dataService + acceptedRca.dataService ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } @@ -100,14 +103,17 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { } function test_Collect_Revert_WhenCanceledAgreementByServiceProvider(FuzzyTestCollect calldata fuzzy) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); - _cancel(accepted.rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + _cancel(acceptedRca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); IRecurringCollector.CollectParams memory collectData = fuzzy.collectParams; collectData.tokens = bound(collectData.tokens, 1, type(uint256).max); IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, collectData.collectionId, collectData.tokens, @@ -121,7 +127,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { IRecurringCollector.AgreementNotCollectableReason.InvalidAgreementState ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } @@ -129,28 +135,31 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { FuzzyTestCollect calldata fuzzy, uint256 unboundedCollectionSeconds ) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); - - skip(accepted.rca.minSecondsPerCollection); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + skip(acceptedRca.minSecondsPerCollection); bytes memory data = _generateCollectData( _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut ) ); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); - uint256 collectionSeconds = boundSkip(unboundedCollectionSeconds, 1, accepted.rca.minSecondsPerCollection - 1); + uint256 collectionSeconds = boundSkip(unboundedCollectionSeconds, 1, acceptedRca.minSecondsPerCollection - 1); skip(collectionSeconds); IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, bound(fuzzy.collectParams.tokens, 1, type(uint256).max), @@ -161,10 +170,10 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectorCollectionTooSoon.selector, collectParams.agreementId, collectionSeconds, - accepted.rca.minSecondsPerCollection + acceptedRca.minSecondsPerCollection ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); } @@ -173,21 +182,24 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedFirstCollectionSeconds, uint256 unboundedSecondCollectionSeconds ) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); // First valid collection to establish lastCollectionAt skip( boundSkip( unboundedFirstCollectionSeconds, - accepted.rca.minSecondsPerCollection, - accepted.rca.maxSecondsPerCollection + acceptedRca.minSecondsPerCollection, + acceptedRca.maxSecondsPerCollection ) ); bytes memory firstData = _generateCollectData( _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, 1, @@ -200,8 +212,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { // Skip PAST maxSecondsPerCollection (but still within agreement endsAt) uint256 collectionSeconds = boundSkip( unboundedSecondCollectionSeconds, - accepted.rca.maxSecondsPerCollection + 1, - accepted.rca.endsAt - block.timestamp + acceptedRca.maxSecondsPerCollection + 1, + acceptedRca.endsAt - block.timestamp ); skip(collectionSeconds); @@ -238,51 +250,54 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedTokens, bool testInitialCollection ) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); if (!testInitialCollection) { // skip to collectable time skip( boundSkip( unboundedInitialCollectionSeconds, - accepted.rca.minSecondsPerCollection, - accepted.rca.maxSecondsPerCollection + acceptedRca.minSecondsPerCollection, + acceptedRca.maxSecondsPerCollection ) ); bytes memory initialData = _generateCollectData( _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut ) ); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), initialData); } // skip to collectable time uint256 collectionSeconds = boundSkip( unboundedCollectionSeconds, - accepted.rca.minSecondsPerCollection, - accepted.rca.maxSecondsPerCollection + acceptedRca.minSecondsPerCollection, + acceptedRca.maxSecondsPerCollection ); skip(collectionSeconds); - uint256 maxTokens = accepted.rca.maxOngoingTokensPerSecond * collectionSeconds; - maxTokens += testInitialCollection ? accepted.rca.maxInitialTokens : 0; + uint256 maxTokens = acceptedRca.maxOngoingTokensPerSecond * collectionSeconds; + maxTokens += testInitialCollection ? acceptedRca.maxInitialTokens : 0; uint256 tokens = bound(unboundedTokens, maxTokens + 1, type(uint256).max); IRecurringCollector.CollectParams memory collectParams = _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, tokens, fuzzy.collectParams.dataServiceCut ); bytes memory data = _generateCollectData(collectParams); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, maxTokens); } @@ -292,12 +307,15 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { uint256 unboundedCollectionSeconds, uint256 unboundedTokens ) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); (bytes memory data, uint256 collectionSeconds, uint256 tokens) = _generateValidCollection( - accepted.rca, + acceptedRca, fuzzy.collectParams, unboundedCollectionSeconds, unboundedTokens @@ -305,13 +323,13 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { skip(collectionSeconds); _expectCollectCallAndEmit( - accepted.rca, + acceptedRca, agreementId, _paymentType(fuzzy.unboundedPaymentType), fuzzy.collectParams, tokens ); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); assertEq(collected, tokens); } @@ -333,8 +351,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { // Accept the agreement _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, 1); - IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(rca, 1); - bytes16 agreementId = _accept(signedRCA); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, 1); + bytes16 agreementId = _accept(rca, signature); // Do a first collection to use up initial tokens allowance skip(rca.minSecondsPerCollection); @@ -400,8 +418,8 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { // Accept the agreement _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, 1); - IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(rca, 1); - bytes16 agreementId = _accept(signedRCA); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, 1); + bytes16 agreementId = _accept(rca, signature); // Do a first collection to use up initial tokens allowance skip(rca.minSecondsPerCollection); @@ -449,22 +467,25 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { assertEq(collected, maxAllowed); } function test_Collect_Revert_WhenZeroTokensBypassesTemporalValidation(FuzzyTestCollect calldata fuzzy) public { - (IRecurringCollector.SignedRCA memory accepted, , bytes16 agreementId) = _sensibleAuthorizeAndAccept( - fuzzy.fuzzyTestAccept - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); // First valid collection to establish lastCollectionAt - skip(accepted.rca.minSecondsPerCollection); + skip(acceptedRca.minSecondsPerCollection); bytes memory firstData = _generateCollectData( _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, 1, fuzzy.collectParams.dataServiceCut ) ); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), firstData); // Attempt zero-token collection immediately (before minSecondsPerCollection). @@ -472,7 +493,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { // the temporal validation that guards minSecondsPerCollection. skip(1); IRecurringCollector.CollectParams memory zeroParams = _generateCollectParams( - accepted.rca, + acceptedRca, agreementId, fuzzy.collectParams.collectionId, 0, // zero tokens @@ -485,10 +506,10 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectorCollectionTooSoon.selector, agreementId, uint32(1), // only 1 second elapsed - accepted.rca.minSecondsPerCollection + acceptedRca.minSecondsPerCollection ) ); - vm.prank(accepted.rca.dataService); + vm.prank(acceptedRca.dataService); _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), zeroData); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 54ebae9a7..0c20ccf7f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -54,56 +54,73 @@ contract RecurringCollectorSharedTest is Test, Bounder { function _sensibleAuthorizeAndAccept( FuzzyTestAccept calldata _fuzzyTestAccept - ) internal returns (IRecurringCollector.SignedRCA memory, uint256 key, bytes16 agreementId) { + ) + internal + returns ( + IRecurringCollector.RecurringCollectionAgreement memory, + bytes memory signature, + uint256 key, + bytes16 agreementId + ) + { IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( _fuzzyTestAccept.rca ); key = boundKey(_fuzzyTestAccept.unboundedSignerKey); - IRecurringCollector.SignedRCA memory signedRCA; - (signedRCA, agreementId) = _authorizeAndAccept(rca, key); - return (signedRCA, key, agreementId); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes memory sig, + bytes16 id + ) = _authorizeAndAccept(rca, key); + return (acceptedRca, sig, key, id); } // authorizes signer, signs the RCA, and accepts it function _authorizeAndAccept( IRecurringCollector.RecurringCollectionAgreement memory _rca, uint256 _signerKey - ) internal returns (IRecurringCollector.SignedRCA memory, bytes16 agreementId) { + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes memory, bytes16 agreementId) { _recurringCollectorHelper.authorizeSignerWithChecks(_rca.payer, _signerKey); - IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA(_rca, _signerKey); + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(_rca, _signerKey); - agreementId = _accept(signedRCA); - return (signedRCA, agreementId); + agreementId = _accept(rca, signature); + return (rca, signature, agreementId); } - function _accept(IRecurringCollector.SignedRCA memory _signedRCA) internal returns (bytes16) { + function _accept( + IRecurringCollector.RecurringCollectionAgreement memory _rca, + bytes memory _signature + ) internal returns (bytes16) { // Set up valid staking provision by default to allow collections to succeed - _setupValidProvision(_signedRCA.rca.serviceProvider, _signedRCA.rca.dataService); + _setupValidProvision(_rca.serviceProvider, _rca.dataService); // Calculate the expected agreement ID for verification bytes16 expectedAgreementId = _recurringCollector.generateAgreementId( - _signedRCA.rca.payer, - _signedRCA.rca.dataService, - _signedRCA.rca.serviceProvider, - _signedRCA.rca.deadline, - _signedRCA.rca.nonce + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.deadline, + _rca.nonce ); vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementAccepted( - _signedRCA.rca.dataService, - _signedRCA.rca.payer, - _signedRCA.rca.serviceProvider, + _rca.dataService, + _rca.payer, + _rca.serviceProvider, expectedAgreementId, uint64(block.timestamp), - _signedRCA.rca.endsAt, - _signedRCA.rca.maxInitialTokens, - _signedRCA.rca.maxOngoingTokensPerSecond, - _signedRCA.rca.minSecondsPerCollection, - _signedRCA.rca.maxSecondsPerCollection + _rca.endsAt, + _rca.maxInitialTokens, + _rca.maxOngoingTokensPerSecond, + _rca.minSecondsPerCollection, + _rca.maxSecondsPerCollection ); - vm.prank(_signedRCA.rca.dataService); - bytes16 actualAgreementId = _recurringCollector.accept(_signedRCA); + vm.prank(_rca.dataService); + bytes16 actualAgreementId = _recurringCollector.accept(_rca, _signature); // Verify the agreement ID matches expectation assertEq(actualAgreementId, expectedAgreementId); diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index 70f42af8a..d466f3c49 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -13,28 +13,25 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ function test_Update_Revert_WhenUpdateElapsed( - IRecurringCollector.RecurringCollectionAgreement memory rca, - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + FuzzyTestUpdate calldata fuzzyTestUpdate, uint256 unboundedUpdateSkip ) public { - rca = _recurringCollectorHelper.sensibleRCA(rca); - rcau = _recurringCollectorHelper.sensibleRCAU(rcau); - // Generate deterministic agreement ID - bytes16 agreementId = _recurringCollector.generateAgreementId( - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.deadline, - rca.nonce + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau ); rcau.agreementId = agreementId; boundSkipCeil(unboundedUpdateSkip, type(uint64).max); rcau.deadline = uint64(bound(rcau.deadline, 0, block.timestamp - 1)); - IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ - rcau: rcau, - signature: "" - }); + + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, @@ -42,8 +39,8 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.deadline ); vm.expectRevert(expectedErr); - vm.prank(rca.dataService); - _recurringCollector.update(signedRCAU); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); } function test_Update_Revert_WhenNeverAccepted( @@ -63,10 +60,6 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.agreementId = agreementId; rcau.deadline = uint64(block.timestamp); - IRecurringCollector.SignedRCAU memory signedRCAU = IRecurringCollector.SignedRCAU({ - rcau: rcau, - signature: "" - }); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, @@ -75,7 +68,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { ); vm.expectRevert(expectedErr); vm.prank(rca.dataService); - _recurringCollector.update(signedRCAU); + _recurringCollector.update(rcau, ""); } function test_Update_Revert_WhenDataServiceNotAuthorized( @@ -83,26 +76,23 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { address notDataService ) public { vm.assume(fuzzyTestUpdate.fuzzyTestAccept.rca.dataService != notDataService); - (, uint256 signerKey, bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + (, , uint256 signerKey, bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( fuzzyTestUpdate.rcau ); rcau.agreementId = agreementId; - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAUWithCorrectNonce( - rcau, - signerKey - ); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAUWithCorrectNonce(rcau, signerKey); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, - signedRCAU.rcau.agreementId, + rcau.agreementId, notDataService ); vm.expectRevert(expectedErr); vm.prank(notDataService); - _recurringCollector.update(signedRCAU); + _recurringCollector.update(rcau, signature); } function test_Update_Revert_WhenInvalidSigner( @@ -110,10 +100,12 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { uint256 unboundedInvalidSignerKey ) public { ( - IRecurringCollector.SignedRCA memory accepted, - uint256 signerKey, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + uint256 signerKey = boundKey(fuzzyTestUpdate.fuzzyTestAccept.unboundedSignerKey); uint256 invalidSignerKey = boundKey(unboundedInvalidSignerKey); vm.assume(signerKey != invalidSignerKey); @@ -122,19 +114,17 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { ); rcau.agreementId = agreementId; - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( - rcau, - invalidSignerKey - ); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, invalidSignerKey); vm.expectRevert(IRecurringCollector.RecurringCollectorInvalidSigner.selector); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); } function test_Update_OK(FuzzyTestUpdate calldata fuzzyTestUpdate) public { ( - IRecurringCollector.SignedRCA memory accepted, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , uint256 signerKey, bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); @@ -144,16 +134,13 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.agreementId = agreementId; // Don't use fuzzed nonce - use correct nonce for first update rcau.nonce = 1; - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( - rcau, - signerKey - ); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementUpdated( - accepted.rca.dataService, - accepted.rca.payer, - accepted.rca.serviceProvider, + acceptedRca.dataService, + acceptedRca.payer, + acceptedRca.serviceProvider, rcau.agreementId, uint64(block.timestamp), rcau.endsAt, @@ -162,8 +149,8 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.minSecondsPerCollection, rcau.maxSecondsPerCollection ); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(rcau.endsAt, agreement.endsAt); @@ -176,7 +163,8 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { function test_Update_Revert_WhenInvalidNonce_TooLow(FuzzyTestUpdate calldata fuzzyTestUpdate) public { ( - IRecurringCollector.SignedRCA memory accepted, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , uint256 signerKey, bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); @@ -186,10 +174,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.agreementId = agreementId; rcau.nonce = 0; // Invalid: should be 1 for first update - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( - rcau, - signerKey - ); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, @@ -198,13 +183,14 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { 0 // provided ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); } function test_Update_Revert_WhenInvalidNonce_TooHigh(FuzzyTestUpdate calldata fuzzyTestUpdate) public { ( - IRecurringCollector.SignedRCA memory accepted, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , uint256 signerKey, bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); @@ -214,10 +200,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau.agreementId = agreementId; rcau.nonce = 5; // Invalid: should be 1 for first update - IRecurringCollector.SignedRCAU memory signedRCAU = _recurringCollectorHelper.generateSignedRCAU( - rcau, - signerKey - ); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, @@ -226,13 +209,14 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { 5 // provided ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); } function test_Update_Revert_WhenReplayAttack(FuzzyTestUpdate calldata fuzzyTestUpdate) public { ( - IRecurringCollector.SignedRCA memory accepted, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , uint256 signerKey, bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); @@ -243,24 +227,27 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau1.nonce = 1; // First update succeeds - IRecurringCollector.SignedRCAU memory signedRCAU1 = _recurringCollectorHelper.generateSignedRCAU( - rcau1, - signerKey - ); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU1); + (, bytes memory signature1) = _recurringCollectorHelper.generateSignedRCAU(rcau1, signerKey); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau1, signature1); // Second update with different terms and nonce 2 succeeds - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = rcau1; - rcau2.nonce = 2; - rcau2.maxOngoingTokensPerSecond = rcau1.maxOngoingTokensPerSecond * 2; // Different terms - - IRecurringCollector.SignedRCAU memory signedRCAU2 = _recurringCollectorHelper.generateSignedRCAU( - rcau2, - signerKey - ); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU2); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: rcau1.agreementId, + deadline: rcau1.deadline, + endsAt: rcau1.endsAt, + maxInitialTokens: rcau1.maxInitialTokens, + maxOngoingTokensPerSecond: rcau1.maxOngoingTokensPerSecond * 2, // Different terms + minSecondsPerCollection: rcau1.minSecondsPerCollection, + maxSecondsPerCollection: rcau1.maxSecondsPerCollection, + nonce: 2, + metadata: rcau1.metadata + }); + + (, bytes memory signature2) = _recurringCollectorHelper.generateSignedRCAU(rcau2, signerKey); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau2, signature2); // Attempting to replay first update should fail bytes memory expectedErr = abi.encodeWithSelector( @@ -270,13 +257,14 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { 1 // provided (old nonce) ); vm.expectRevert(expectedErr); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU1); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau1, signature1); } function test_Update_OK_NonceIncrementsCorrectly(FuzzyTestUpdate calldata fuzzyTestUpdate) public { ( - IRecurringCollector.SignedRCA memory accepted, + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , uint256 signerKey, bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); @@ -292,28 +280,31 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { rcau1.agreementId = agreementId; rcau1.nonce = 1; - IRecurringCollector.SignedRCAU memory signedRCAU1 = _recurringCollectorHelper.generateSignedRCAU( - rcau1, - signerKey - ); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU1); + (, bytes memory signature1) = _recurringCollectorHelper.generateSignedRCAU(rcau1, signerKey); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau1, signature1); // Verify nonce incremented to 1 IRecurringCollector.AgreementData memory updatedAgreement1 = _recurringCollector.getAgreement(agreementId); assertEq(updatedAgreement1.updateNonce, 1); // Second update with nonce 2 - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = rcau1; - rcau2.nonce = 2; - rcau2.maxOngoingTokensPerSecond = rcau1.maxOngoingTokensPerSecond * 2; // Different terms - - IRecurringCollector.SignedRCAU memory signedRCAU2 = _recurringCollectorHelper.generateSignedRCAU( - rcau2, - signerKey - ); - vm.prank(accepted.rca.dataService); - _recurringCollector.update(signedRCAU2); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: rcau1.agreementId, + deadline: rcau1.deadline, + endsAt: rcau1.endsAt, + maxInitialTokens: rcau1.maxInitialTokens, + maxOngoingTokensPerSecond: rcau1.maxOngoingTokensPerSecond * 2, // Different terms + minSecondsPerCollection: rcau1.minSecondsPerCollection, + maxSecondsPerCollection: rcau1.maxSecondsPerCollection, + nonce: 2, + metadata: rcau1.metadata + }); + + (, bytes memory signature2) = _recurringCollectorHelper.generateSignedRCAU(rcau2, signerKey); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau2, signature2); // Verify nonce incremented to 2 IRecurringCollector.AgreementData memory updatedAgreement2 = _recurringCollector.getAgreement(agreementId); diff --git a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol new file mode 100644 index 000000000..22016075a --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { + function _newApprover() internal returns (MockAgreementOwner) { + return new MockAgreementOwner(); + } + + /// @notice Helper to accept an agreement via the unsigned path and return the ID + function _acceptUnsigned( + MockAgreementOwner approver, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + return _recurringCollector.accept(rca, ""); + } + + function _makeSimpleRCA(address payer) internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + } + + function _makeSimpleRCAU( + bytes16 agreementId, + uint32 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + nonce: nonce, + metadata: "" + }) + ); + } + + /* solhint-disable graph/func-name-mixedcase */ + + function test_UpdateUnsigned() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + // Authorize the update hash + bytes32 updateHash = _recurringCollector.hashRCAU(rcau); + approver.authorize(updateHash); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementUpdated( + rca.dataService, + rca.payer, + rca.serviceProvider, + agreementId, + uint64(block.timestamp), + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection + ); + + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(rcau.endsAt, agreement.endsAt); + assertEq(rcau.maxInitialTokens, agreement.maxInitialTokens); + assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); + assertEq(rcau.minSecondsPerCollection, agreement.minSecondsPerCollection); + assertEq(rcau.maxSecondsPerCollection, agreement.maxSecondsPerCollection); + assertEq(rcau.nonce, agreement.updateNonce); + } + + function test_UpdateUnsigned_Revert_WhenPayerNotContract() public { + // Use the signed accept path to create an agreement with an EOA payer, + // then attempt updateUnsigned which should fail because payer isn't a contract + uint256 signerKey = 0xA11CE; + address payer = vm.addr(signerKey); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + // Accept via signed path + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, signature); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, payer) + ); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenHashNotAuthorized() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + // Don't authorize the update hash — approver returns bytes4(0), caller rejects + vm.expectRevert(IRecurringCollector.RecurringCollectorInvalidSigner.selector); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenWrongMagicValue() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + approver.setOverrideReturnValue(bytes4(0xdeadbeef)); + + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenNotDataService() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + bytes32 updateHash = _recurringCollector.hashRCAU(rcau); + approver.authorize(updateHash); + + address notDataService = makeAddr("notDataService"); + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorDataServiceNotAuthorized.selector, + agreementId, + notDataService + ) + ); + vm.prank(notDataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenNotAccepted() public { + // Don't accept — just try to update a non-existent agreement + bytes16 fakeId = bytes16(keccak256("fake")); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(fakeId, 1); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + fakeId, + IRecurringCollector.AgreementState.NotAccepted + ); + vm.expectRevert(expectedErr); + vm.prank(makeAddr("ds")); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenInvalidNonce() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + // Use wrong nonce (0 instead of 1) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 0); + + bytes32 updateHash = _recurringCollector.hashRCAU(rcau); + approver.authorize(updateHash); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, + agreementId, + 1, // expected + 0 // provided + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenApproverReverts() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + approver.setShouldRevert(true); + + vm.expectRevert("MockAgreementOwner: forced revert"); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + function test_UpdateUnsigned_Revert_WhenDeadlineElapsed() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); + + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); + + // Set the update deadline in the past + rcau.deadline = uint64(block.timestamp - 1); + + bytes32 updateHash = _recurringCollector.hashRCAU(rcau); + approver.authorize(updateHash); + + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + rcau.deadline + ); + vm.expectRevert(expectedErr); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/interfaces/contracts/horizon/IAgreementOwner.sol b/packages/interfaces/contracts/horizon/IAgreementOwner.sol new file mode 100644 index 000000000..5e329d2e1 --- /dev/null +++ b/packages/interfaces/contracts/horizon/IAgreementOwner.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +/** + * @title Interface for contracts that can act as authorized agreement approvers + * @author Edge & Node + * @notice Enables contracts to authorize RCA agreements and updates on-chain via + * {RecurringCollector.accept} and {RecurringCollector.update} (with empty authData), + * replacing ECDSA signatures with a callback. + * + * Uses the magic-value pattern: return the function selector on success. + * + * The same callback is used for both accept (RCA hash) and update (RCAU hash). + * Hash namespaces do not collide because RCA and RCAU use different EIP712 type hashes. + * + * No per-payer authorization step is needed — the contract's code is the authorization. + * The trust chain is: governance grants operator role → operator registers + * (validates and pre-funds) → approveAgreement confirms → RC accepts/updates. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IAgreementOwner { + /** + * @notice Confirms this contract authorized the given agreement or update + * @dev Called by {RecurringCollector.accept} with an RCA hash or by + * {RecurringCollector.update} with an RCAU hash to verify authorization (empty authData path). + * @param agreementHash The EIP712 hash of the RCA or RCAU struct + * @return magic `IAgreementOwner.approveAgreement.selector` if authorized + */ + function approveAgreement(bytes32 agreementHash) external view returns (bytes4); +} diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index e3ca616a3..91276f06d 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -37,16 +37,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { InvalidTemporalWindow } - /** - * @notice A representation of a signed Recurring Collection Agreement (RCA) - * @param rca The Recurring Collection Agreement to be signed - * @param signature The signature of the RCA - 65 bytes: r (32 Bytes) || s (32 Bytes) || v (1 Byte) - */ - struct SignedRCA { - RecurringCollectionAgreement rca; - bytes signature; - } - /** * @notice The Recurring Collection Agreement (RCA) * @param deadline The deadline for accepting the RCA @@ -79,16 +69,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { bytes metadata; } - /** - * @notice A representation of a signed Recurring Collection Agreement Update (RCAU) - * @param rcau The Recurring Collection Agreement Update to be signed - * @param signature The signature of the RCAU - 65 bytes: r (32 Bytes) || s (32 Bytes) || v (1 Byte) - */ - struct SignedRCAU { - RecurringCollectionAgreementUpdate rcau; - bytes signature; - } - /** * @notice The Recurring Collection Agreement Update (RCAU) * @param agreementId The agreement ID of the RCAU @@ -390,11 +370,25 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { error RecurringCollectorExcessiveSlippage(uint256 requested, uint256 actual, uint256 maxSlippage); /** - * @notice Accept an indexing agreement. - * @param signedRCA The signed Recurring Collection Agreement which is to be accepted. + * @notice Thrown when the contract approver is not a contract + * @param approver The address that is not a contract + */ + error RecurringCollectorApproverNotContract(address approver); + + /** + * @notice Accept a Recurring Collection Agreement. + * @dev Caller must be the data service the RCA was issued to. + * If `signature` is non-empty: checks `rca.deadline >= block.timestamp` and verifies the ECDSA signature. + * If `signature` is empty: the payer must be a contract implementing {IAgreementOwner.approveAgreement} + * and must return the magic value for the RCA's EIP712 hash. + * @param rca The Recurring Collection Agreement to accept + * @param signature ECDSA signature bytes, or empty for contract-approved agreements * @return agreementId The deterministically generated agreement ID */ - function accept(SignedRCA calldata signedRCA) external returns (bytes16 agreementId); + function accept( + RecurringCollectionAgreement calldata rca, + bytes calldata signature + ) external returns (bytes16 agreementId); /** * @notice Cancel an indexing agreement. @@ -404,10 +398,15 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { function cancel(bytes16 agreementId, CancelAgreementBy by) external; /** - * @notice Update an indexing agreement. - * @param signedRCAU The signed Recurring Collection Agreement Update which is to be applied. + * @notice Update a Recurring Collection Agreement. + * @dev Caller must be the data service for the agreement. + * If `signature` is non-empty: checks `rcau.deadline >= block.timestamp` and verifies the ECDSA signature. + * If `signature` is empty: the payer (stored in the agreement) must be a contract implementing + * {IAgreementOwner.approveAgreement} and must return the magic value for the RCAU's EIP712 hash. + * @param rcau The Recurring Collection Agreement Update to apply + * @param signature ECDSA signature bytes, or empty for contract-approved updates */ - function update(SignedRCAU calldata signedRCAU) external; + function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external; /** * @notice Computes the hash of a RecurringCollectionAgreement (RCA). @@ -425,17 +424,25 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { /** * @notice Recovers the signer address of a signed RecurringCollectionAgreement (RCA). - * @param signedRCA The SignedRCA containing the RCA and its signature. + * @param rca The RCA whose hash was signed. + * @param signature The ECDSA signature bytes. * @return The address of the signer. */ - function recoverRCASigner(SignedRCA calldata signedRCA) external view returns (address); + function recoverRCASigner( + RecurringCollectionAgreement calldata rca, + bytes calldata signature + ) external view returns (address); /** * @notice Recovers the signer address of a signed RecurringCollectionAgreementUpdate (RCAU). - * @param signedRCAU The SignedRCAU containing the RCAU and its signature. + * @param rcau The RCAU whose hash was signed. + * @param signature The ECDSA signature bytes. * @return The address of the signer. */ - function recoverRCAUSigner(SignedRCAU calldata signedRCAU) external view returns (address); + function recoverRCAUSigner( + RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata signature + ) external view returns (address); /** * @notice Gets an agreement. @@ -444,6 +451,16 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ function getAgreement(bytes16 agreementId) external view returns (AgreementData memory); + /** + * @notice Get the maximum tokens collectable in the next collection for an agreement. + * @dev Computes the worst-case (maximum possible) claim amount based on current on-chain + * agreement state. For active agreements, uses `endsAt` as the upper bound (not block.timestamp). + * Returns 0 for NotAccepted, CanceledByServiceProvider, or fully expired agreements. + * @param agreementId The ID of the agreement + * @return The maximum tokens that could be collected in the next collection + */ + function getMaxNextClaim(bytes16 agreementId) external view returns (uint256); + /** * @notice Get collection info for an agreement * @param agreement The agreement data From ec72360867e38279acc84b8ce1ab5cbd984095ca Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:54:59 +0000 Subject: [PATCH 046/157] feat: IDataServiceAgreements interface and SubgraphService integration Extract IDataServiceAgreements from ISubgraphService with cancelIndexingAgreementByPayer and bitmask-dispatched enforce pattern. Add ProvisionManager support for data-service callback verification. --- .../utilities/ProvisionManager.sol | 23 +- .../utilities/ProvisionManager.t.sol | 8 +- .../utilities/ProvisionManagerImpl.t.sol | 10 +- .../data-service/IDataServiceAgreements.sol | 19 ++ .../issuance/allocate/IIssuanceTarget.sol | 3 + .../subgraph-service/ISubgraphService.sol | 29 ++- .../contracts/SubgraphService.sol | 153 ++++++-------- .../contracts/libraries/IndexingAgreement.sol | 80 ++++--- .../disputes/indexingFee/create.t.sol | 199 ++++++++++++++++++ .../test/unit/subgraphService/getters.t.sol | 5 + .../governance/indexingFeesCut.t.sol | 37 ++++ .../indexing-agreement/accept.t.sol | 174 ++++++++------- .../indexing-agreement/base.t.sol | 10 +- .../indexing-agreement/cancel.t.sol | 56 ++--- .../indexing-agreement/collect.t.sol | 14 +- .../indexing-agreement/integration.t.sol | 16 +- .../indexing-agreement/shared.t.sol | 23 +- .../indexing-agreement/update.t.sol | 89 ++++---- 18 files changed, 620 insertions(+), 328 deletions(-) create mode 100644 packages/interfaces/contracts/data-service/IDataServiceAgreements.sol create mode 100644 packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/governance/indexingFeesCut.t.sol diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol index 77f495ed8..202f4693c 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.27; -// TODO: Re-enable and fix issues when publishing a new version // solhint-disable gas-indexed-events // solhint-disable gas-strict-inequalities @@ -111,29 +110,15 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa */ error ProvisionManagerProvisionNotFound(address serviceProvider); - // forge-lint: disable-next-item(unwrapped-modifier-logic) /** * @notice Checks if the caller is authorized to manage the provision of a service provider. - * @param serviceProvider The address of the service provider. + * @param _serviceProvider The address of the service provider. */ - modifier onlyAuthorizedForProvision(address serviceProvider) { + function _requireAuthorizedForProvision(address _serviceProvider) internal view { require( - _graphStaking().isAuthorized(serviceProvider, address(this), msg.sender), - ProvisionManagerNotAuthorized(serviceProvider, msg.sender) + _graphStaking().isAuthorized(_serviceProvider, address(this), msg.sender), + ProvisionManagerNotAuthorized(_serviceProvider, msg.sender) ); - _; - } - - // Warning: Virtual modifiers are deprecated and scheduled for removal. - // forge-lint: disable-next-item(unwrapped-modifier-logic) - /** - * @notice Checks if a provision of a service provider is valid according - * to the parameter ranges established. - * @param serviceProvider The address of the service provider. - */ - modifier onlyValidProvision(address serviceProvider) virtual { - _requireValidProvision(serviceProvider); - _; } // forge-lint: disable-next-item(mixed-case-function) diff --git a/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol b/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol index 476a98105..4993b7f57 100644 --- a/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol +++ b/packages/horizon/test/unit/data-service/utilities/ProvisionManager.t.sol @@ -27,14 +27,14 @@ contract ProvisionManagerTest is Test { vm.expectRevert( abi.encodeWithSelector(ProvisionManager.ProvisionManagerProvisionNotFound.selector, serviceProvider) ); - _provisionManager.onlyValidProvision_(serviceProvider); + _provisionManager.requireValidProvision_(serviceProvider); IHorizonStakingTypes.Provision memory provision; provision.createdAt = 1; _horizonStakingMock.setProvision(serviceProvider, address(_provisionManager), provision); - _provisionManager.onlyValidProvision_(serviceProvider); + _provisionManager.requireValidProvision_(serviceProvider); } function test_OnlyAuthorizedForProvision(address serviceProvider, address sender) public { @@ -42,11 +42,11 @@ contract ProvisionManagerTest is Test { abi.encodeWithSelector(ProvisionManager.ProvisionManagerNotAuthorized.selector, serviceProvider, sender) ); vm.prank(sender); - _provisionManager.onlyAuthorizedForProvision_(serviceProvider); + _provisionManager.requireAuthorizedForProvision_(serviceProvider); _horizonStakingMock.setIsAuthorized(serviceProvider, address(_provisionManager), sender, true); vm.prank(sender); - _provisionManager.onlyAuthorizedForProvision_(serviceProvider); + _provisionManager.requireAuthorizedForProvision_(serviceProvider); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol b/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol index 8f469a169..1cbfe2cd2 100644 --- a/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol +++ b/packages/horizon/test/unit/data-service/utilities/ProvisionManagerImpl.t.sol @@ -7,9 +7,11 @@ import { GraphDirectory } from "../../../../contracts/utilities/GraphDirectory.s contract ProvisionManagerImpl is GraphDirectory, ProvisionManager { constructor(address controller) GraphDirectory(controller) {} - function onlyValidProvision_(address serviceProvider) public view onlyValidProvision(serviceProvider) {} + function requireValidProvision_(address serviceProvider) public view { + _requireValidProvision(serviceProvider); + } - function onlyAuthorizedForProvision_( - address serviceProvider - ) public view onlyAuthorizedForProvision(serviceProvider) {} + function requireAuthorizedForProvision_(address serviceProvider) public view { + _requireAuthorizedForProvision(serviceProvider); + } } diff --git a/packages/interfaces/contracts/data-service/IDataServiceAgreements.sol b/packages/interfaces/contracts/data-service/IDataServiceAgreements.sol new file mode 100644 index 000000000..ea5b0dd54 --- /dev/null +++ b/packages/interfaces/contracts/data-service/IDataServiceAgreements.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +/** + * @title Interface for data services that manage indexing agreements. + * @author Edge & Node + * @notice Interface to support payer-initiated cancellation of indexing agreements. + * Any data service that participates in agreement lifecycle management via + * {RecurringAgreementManager} should implement this interface. + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IDataServiceAgreements { + /** + * @notice Cancel an indexing agreement by payer / signer. + * @param agreementId The id of the indexing agreement + */ + function cancelIndexingAgreementByPayer(bytes16 agreementId) external; +} diff --git a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol index b43bc948a..90a311556 100644 --- a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol +++ b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol @@ -15,6 +15,9 @@ interface IIssuanceTarget { */ event IssuanceAllocatorSet(address indexed oldIssuanceAllocator, address indexed newIssuanceAllocator); + /// @notice Emitted before the issuance allocation changes + event BeforeIssuanceAllocationChange(); + /** * @notice Called by the issuance allocator before the target's issuance allocation changes * @dev The target should ensure that all issuance related calculations are up-to-date diff --git a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol index f169dce42..be0bf05d2 100644 --- a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol +++ b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol @@ -1,8 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; +import { IDataServiceAgreements } from "../data-service/IDataServiceAgreements.sol"; import { IDataServiceFees } from "../data-service/IDataServiceFees.sol"; import { IGraphPayments } from "../horizon/IGraphPayments.sol"; + import { IRecurringCollector } from "../horizon/IRecurringCollector.sol"; import { IAllocation } from "./internal/IAllocation.sol"; @@ -20,7 +22,7 @@ import { ILegacyAllocation } from "./internal/ILegacyAllocation.sol"; * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ -interface ISubgraphService is IDataServiceFees { +interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { /** * @notice Indexer details * @param url The URL where the indexer can be reached at for queries @@ -267,21 +269,32 @@ interface ISubgraphService is IDataServiceFees { /** * @notice Accept an indexing agreement. + * @dev If `signature` is non-empty it is treated as an ECDSA signature; if empty the payer + * must be a contract implementing {IAgreementOwner}. * @param allocationId The id of the allocation - * @param signedRCA The signed recurring collector agreement (RCA) that the indexer accepts + * @param rca The recurring collection agreement parameters + * @param signature ECDSA signature bytes, or empty for contract-approved agreements * @return agreementId The ID of the accepted indexing agreement */ function acceptIndexingAgreement( address allocationId, - IRecurringCollector.SignedRCA calldata signedRCA + IRecurringCollector.RecurringCollectionAgreement calldata rca, + bytes calldata signature ) external returns (bytes16); /** * @notice Update an indexing agreement. + * @dev If `signature` is non-empty it is treated as an ECDSA signature; if empty the payer + * must be a contract implementing {IAgreementOwner}. * @param indexer The address of the indexer - * @param signedRCAU The signed recurring collector agreement update (RCAU) that the indexer accepts + * @param rcau The recurring collector agreement update to apply + * @param signature ECDSA signature bytes, or empty for contract-approved updates */ - function updateIndexingAgreement(address indexer, IRecurringCollector.SignedRCAU calldata signedRCAU) external; + function updateIndexingAgreement( + address indexer, + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata signature + ) external; /** * @notice Cancel an indexing agreement by indexer / operator. @@ -290,12 +303,6 @@ interface ISubgraphService is IDataServiceFees { */ function cancelIndexingAgreement(address indexer, bytes16 agreementId) external; - /** - * @notice Cancel an indexing agreement by payer / signer. - * @param agreementId The id of the indexing agreement - */ - function cancelIndexingAgreementByPayer(bytes16 agreementId) external; - /** * @notice Get the indexing agreement for a given agreement ID. * @param agreementId The id of the indexing agreement diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 1993d2e5e..b0b4b5944 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -6,6 +6,7 @@ import { IGraphToken } from "@graphprotocol/interfaces/contracts/contracts/token import { IGraphTallyCollector } from "@graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol"; import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol"; import { IDataService } from "@graphprotocol/interfaces/contracts/data-service/IDataService.sol"; +import { IDataServiceAgreements } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceAgreements.sol"; import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; @@ -54,12 +55,21 @@ contract SubgraphService is using TokenUtils for IGraphToken; using IndexingAgreement for IndexingAgreement.StorageManager; + uint256 private constant DEFAULT = 0; + uint256 private constant VALID_PROVISION = 1 << 0; + uint256 private constant REGISTERED = 1 << 1; + /** - * @notice Checks that an indexer is registered - * @param indexer The address of the indexer + * @notice Modifier that enforces service provider requirements. + * @dev Always checks pause state and caller authorization. Additional checks + * (provision validity, indexer registration) are selected via a bitmask. + * Delegates to {_enforceServiceRequirements} which is emitted once in bytecode + * and JUMPed to from each call site, avoiding repeated modifier inlining. + * @param serviceProvider The address of the service provider. + * @param requirements Bitmask of additional requirement flags. */ - modifier onlyRegisteredIndexer(address indexer) { - _checkRegisteredIndexer(indexer); + modifier enforceService(address serviceProvider, uint256 requirements) { + _enforceServiceRequirements(serviceProvider, requirements); _; } @@ -121,10 +131,7 @@ contract SubgraphService is * Use zero address for automatically restaking payments. */ /// @inheritdoc IDataService - function register( - address indexer, - bytes calldata data - ) external override onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) whenNotPaused { + function register(address indexer, bytes calldata data) external override enforceService(indexer, VALID_PROVISION) { (string memory url, string memory geohash, address paymentsDestination_) = abi.decode( data, (string, string, address) @@ -157,7 +164,7 @@ contract SubgraphService is function acceptProvisionPendingParameters( address indexer, bytes calldata - ) external override onlyAuthorizedForProvision(indexer) whenNotPaused { + ) external override enforceService(indexer, DEFAULT) { _acceptProvisionParameters(indexer); emit ProvisionPendingParametersAccepted(indexer); } @@ -190,14 +197,7 @@ contract SubgraphService is function startService( address indexer, bytes calldata data - ) - external - override - onlyAuthorizedForProvision(indexer) - onlyValidProvision(indexer) - onlyRegisteredIndexer(indexer) - whenNotPaused - { + ) external override enforceService(indexer, VALID_PROVISION | REGISTERED) { (bytes32 subgraphDeploymentId, uint256 tokens, address allocationId, bytes memory allocationProof) = abi.decode( data, (bytes32, uint256, address, bytes) @@ -226,15 +226,9 @@ contract SubgraphService is * - address `allocationId`: The id of the allocation */ /// @inheritdoc IDataService - function stopService( - address indexer, - bytes calldata data - ) external override onlyAuthorizedForProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { + function stopService(address indexer, bytes calldata data) external override enforceService(indexer, REGISTERED) { address allocationId = abi.decode(data, (address)); - require( - _allocations.get(allocationId).indexer == indexer, - SubgraphServiceAllocationNotAuthorized(indexer, allocationId) - ); + _checkAllocationOwnership(indexer, allocationId); _onCloseAllocation(allocationId, false); _closeAllocation(allocationId, false); emit ServiceStopped(indexer, data); @@ -281,15 +275,7 @@ contract SubgraphService is address indexer, IGraphPayments.PaymentTypes paymentType, bytes calldata data - ) - external - override - whenNotPaused - onlyAuthorizedForProvision(indexer) - onlyValidProvision(indexer) - onlyRegisteredIndexer(indexer) - returns (uint256) - { + ) external override enforceService(indexer, VALID_PROVISION | REGISTERED) returns (uint256) { uint256 paymentCollected = 0; if (paymentType == IGraphPayments.PaymentTypes.QueryFee) { @@ -338,17 +324,8 @@ contract SubgraphService is address indexer, address allocationId, uint256 tokens - ) - external - onlyAuthorizedForProvision(indexer) - onlyValidProvision(indexer) - onlyRegisteredIndexer(indexer) - whenNotPaused - { - require( - _allocations.get(allocationId).indexer == indexer, - SubgraphServiceAllocationNotAuthorized(indexer, allocationId) - ); + ) external enforceService(indexer, VALID_PROVISION | REGISTERED) { + _checkAllocationOwnership(indexer, allocationId); _resizeAllocation(allocationId, tokens, _delegationRatio); } @@ -412,27 +389,21 @@ contract SubgraphService is * - Agreement must not have been accepted before * - Allocation must not have an agreement already * - * @dev signedRCA.rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata} + * @dev rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata} * * Emits {IndexingAgreement.IndexingAgreementAccepted} event * * @param allocationId The id of the allocation - * @param signedRCA The signed Recurring Collection Agreement + * @param rca The Recurring Collection Agreement + * @param signature ECDSA signature bytes, or empty for contract-approved agreements * @return agreementId The ID of the accepted indexing agreement */ function acceptIndexingAgreement( address allocationId, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA calldata signedRCA - ) - external - whenNotPaused - onlyAuthorizedForProvision(signedRCA.rca.serviceProvider) - onlyValidProvision(signedRCA.rca.serviceProvider) - onlyRegisteredIndexer(signedRCA.rca.serviceProvider) - returns (bytes16) - { - return IndexingAgreement._getStorageManager().accept(_allocations, allocationId, signedRCA); + IRecurringCollector.RecurringCollectionAgreement calldata rca, + bytes calldata signature + ) external enforceService(rca.serviceProvider, VALID_PROVISION | REGISTERED) returns (bytes16) { + return IndexingAgreement._getStorageManager().accept(_allocations, allocationId, rca, signature); } /** @@ -446,20 +417,15 @@ contract SubgraphService is * - The indexer must be valid * * @param indexer The indexer address - * @param signedRCAU The signed Recurring Collection Agreement Update + * @param rcau The Recurring Collection Agreement Update + * @param signature ECDSA signature bytes, or empty for contract-approved updates */ function updateIndexingAgreement( address indexer, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCAU calldata signedRCAU - ) - external - whenNotPaused - onlyAuthorizedForProvision(indexer) - onlyValidProvision(indexer) - onlyRegisteredIndexer(indexer) - { - IndexingAgreement._getStorageManager().update(indexer, signedRCAU); + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata signature + ) external enforceService(indexer, VALID_PROVISION | REGISTERED) { + IndexingAgreement._getStorageManager().update(indexer, rcau, signature); } /** @@ -480,21 +446,15 @@ contract SubgraphService is function cancelIndexingAgreement( address indexer, bytes16 agreementId - ) - external - whenNotPaused - onlyAuthorizedForProvision(indexer) - onlyValidProvision(indexer) - onlyRegisteredIndexer(indexer) - { + ) external enforceService(indexer, VALID_PROVISION | REGISTERED) { IndexingAgreement._getStorageManager().cancel(indexer, agreementId); } /** - * @inheritdoc ISubgraphService + * @inheritdoc IDataServiceAgreements * @notice Cancel an indexing agreement by payer / signer. * - * See {ISubgraphService.cancelIndexingAgreementByPayer}. + * See {IDataServiceAgreements.cancelIndexingAgreementByPayer}. * * Requirements: * - The caller must be authorized by the payer @@ -614,11 +574,35 @@ contract SubgraphService is } /** - * @notice Checks that an indexer is registered - * @param indexer The address of the indexer + * @notice Enforces service provider requirements. + * @dev Always checks pause state and caller authorization. Additional checks + * (provision validity, indexer registration) are selected via bitmask flags. + * Single dispatch point emitted once in bytecode, JUMPed to from each call site + * via the {enforceService} modifier. + * @param _serviceProvider The address of the service provider. + * @param _checks Bitmask of additional requirement flags (VALID_PROVISION, REGISTERED). + */ + function _enforceServiceRequirements(address _serviceProvider, uint256 _checks) private view { + _requireNotPaused(); + _requireAuthorizedForProvision(_serviceProvider); + if (_checks & VALID_PROVISION != 0) _requireValidProvision(_serviceProvider); + if (_checks & REGISTERED != 0) + require( + bytes(indexers[_serviceProvider].url).length > 0, + SubgraphServiceIndexerNotRegistered(_serviceProvider) + ); + } + + /** + * @notice Checks that the allocation belongs to the given indexer. + * @param _indexer The address of the indexer. + * @param _allocationId The id of the allocation. */ - function _checkRegisteredIndexer(address indexer) private view { - require(bytes(indexers[indexer].url).length > 0, SubgraphServiceIndexerNotRegistered(indexer)); + function _checkAllocationOwnership(address _indexer, address _allocationId) internal view { + require( + _allocations.get(_allocationId).indexer == _indexer, + SubgraphServiceAllocationNotAuthorized(_indexer, _allocationId) + ); } /** @@ -736,10 +720,7 @@ contract SubgraphService is */ function _collectIndexingRewards(address _indexer, bytes calldata _data) private returns (uint256) { (address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(_data, (address, bytes32, bytes)); - require( - _allocations.get(allocationId).indexer == _indexer, - SubgraphServiceAllocationNotAuthorized(_indexer, allocationId) - ); + _checkAllocationOwnership(_indexer, allocationId); (uint256 paymentCollected, bool allocationForceClosed) = _presentPoi( allocationId, diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 19a7eaf4a..abe148e5e 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -274,43 +274,38 @@ library IndexingAgreement { * - Agreement must not have been accepted before * - Allocation must not have an agreement already * - * @dev signedRCA.rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata} + * @dev rca.metadata is an encoding of {IndexingAgreement.AcceptIndexingAgreementMetadata}. + * If `authData` is non-empty it is treated as an ECDSA signature; if empty the payer + * must be a contract implementing {IAgreementOwner}. * * Emits {IndexingAgreementAccepted} event * * @param self The indexing agreement storage manager * @param allocations The mapping of allocation IDs to their states * @param allocationId The id of the allocation - * @param signedRCA The signed Recurring Collection Agreement + * @param rca The Recurring Collection Agreement + * @param authData ECDSA signature bytes, or empty for contract-approved agreements * @return The agreement ID assigned to the accepted indexing agreement */ function accept( StorageManager storage self, mapping(address allocationId => IAllocation.State allocation) storage allocations, address allocationId, - IRecurringCollector.SignedRCA calldata signedRCA + IRecurringCollector.RecurringCollectionAgreement calldata rca, + bytes calldata authData ) external returns (bytes16) { - IAllocation.State memory allocation = _requireValidAllocation( - allocations, - allocationId, - signedRCA.rca.serviceProvider - ); + IAllocation.State memory allocation = _requireValidAllocation(allocations, allocationId, rca.serviceProvider); - require( - signedRCA.rca.dataService == address(this), - IndexingAgreementWrongDataService(address(this), signedRCA.rca.dataService) - ); + require(rca.dataService == address(this), IndexingAgreementWrongDataService(address(this), rca.dataService)); - AcceptIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAMetadata( - signedRCA.rca.metadata - ); + AcceptIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAMetadata(rca.metadata); bytes16 agreementId = _directory().recurringCollector().generateAgreementId( - signedRCA.rca.payer, - signedRCA.rca.dataService, - signedRCA.rca.serviceProvider, - signedRCA.rca.deadline, - signedRCA.rca.nonce + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce ); IIndexingAgreement.State storage agreement = self.agreements[agreementId]; @@ -340,11 +335,11 @@ library IndexingAgreement { metadata.version == IIndexingAgreement.IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version) ); - _setTermsV1(self, agreementId, metadata.terms, signedRCA.rca.maxOngoingTokensPerSecond); + _setTermsV1(self, agreementId, metadata.terms, rca.maxOngoingTokensPerSecond); emit IndexingAgreementAccepted( - signedRCA.rca.serviceProvider, - signedRCA.rca.payer, + rca.serviceProvider, + rca.payer, agreementId, allocationId, metadata.subgraphDeploymentId, @@ -352,7 +347,10 @@ library IndexingAgreement { metadata.terms ); - require(_directory().recurringCollector().accept(signedRCA) == agreementId, "internal: agreement ID mismatch"); + require( + _directory().recurringCollector().accept(rca, authData) == agreementId, + "internal: agreement ID mismatch" + ); return agreementId; } /* solhint-enable function-max-lines */ @@ -364,29 +362,31 @@ library IndexingAgreement { * - Agreement must be active * - The indexer must be the service provider of the agreement * - * @dev signedRCA.rcau.metadata is an encoding of {IndexingAgreement.UpdateIndexingAgreementMetadata} + * @dev rcau.metadata is an encoding of {IndexingAgreement.UpdateIndexingAgreementMetadata}. + * If `authData` is non-empty it is treated as an ECDSA signature; if empty the payer + * must be a contract implementing {IAgreementOwner}. * * Emits {IndexingAgreementUpdated} event * * @param self The indexing agreement storage manager * @param indexer The indexer address - * @param signedRCAU The signed Recurring Collection Agreement Update + * @param rcau The Recurring Collection Agreement Update + * @param authData ECDSA signature bytes, or empty for contract-approved updates */ function update( StorageManager storage self, address indexer, - IRecurringCollector.SignedRCAU calldata signedRCAU + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata authData ) external { - IIndexingAgreement.AgreementWrapper memory wrapper = _get(self, signedRCAU.rcau.agreementId); - require(_isActive(wrapper), IndexingAgreementNotActive(signedRCAU.rcau.agreementId)); + IIndexingAgreement.AgreementWrapper memory wrapper = _get(self, rcau.agreementId); + require(_isActive(wrapper), IndexingAgreementNotActive(rcau.agreementId)); require( wrapper.collectorAgreement.serviceProvider == indexer, - IndexingAgreementNotAuthorized(signedRCAU.rcau.agreementId, indexer) + IndexingAgreementNotAuthorized(rcau.agreementId, indexer) ); - UpdateIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAUMetadata( - signedRCAU.rcau.metadata - ); + UpdateIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAUMetadata(rcau.metadata); require( wrapper.agreement.version == IIndexingAgreement.IndexingAgreementVersion.V1, @@ -396,23 +396,18 @@ library IndexingAgreement { metadata.version == IIndexingAgreement.IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version) ); - _setTermsV1( - self, - signedRCAU.rcau.agreementId, - metadata.terms, - wrapper.collectorAgreement.maxOngoingTokensPerSecond - ); + _setTermsV1(self, rcau.agreementId, metadata.terms, wrapper.collectorAgreement.maxOngoingTokensPerSecond); emit IndexingAgreementUpdated({ indexer: wrapper.collectorAgreement.serviceProvider, payer: wrapper.collectorAgreement.payer, - agreementId: signedRCAU.rcau.agreementId, + agreementId: rcau.agreementId, allocationId: wrapper.agreement.allocationId, version: metadata.version, versionTerms: metadata.terms }); - _directory().recurringCollector().update(signedRCAU); + _directory().recurringCollector().update(rcau, authData); } /** @@ -502,7 +497,8 @@ library IndexingAgreement { IIndexingAgreement.AgreementWrapper memory wrapper = _get(self, agreementId); require(_isActive(wrapper), IndexingAgreementNotActive(agreementId)); require( - _directory().recurringCollector().isAuthorized(wrapper.collectorAgreement.payer, msg.sender), + msg.sender == wrapper.collectorAgreement.payer || + _directory().recurringCollector().isAuthorized(wrapper.collectorAgreement.payer, msg.sender), IndexingAgreementNonCancelableBy(wrapper.collectorAgreement.payer, msg.sender) ); _cancel( diff --git a/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol b/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol new file mode 100644 index 000000000..73ca400bf --- /dev/null +++ b/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IDisputeManager } from "@graphprotocol/interfaces/contracts/subgraph-service/IDisputeManager.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { SubgraphServiceIndexingAgreementSharedTest } from "../../../subgraphService/indexing-agreement/shared.t.sol"; + +contract DisputeManagerIndexingFeeCreateDisputeTest is SubgraphServiceIndexingAgreementSharedTest { + /* + * HELPERS + */ + + /// @dev Sets up an indexer with an accepted indexing agreement that has been collected on. + /// Returns the agreement ID and indexer state needed to create a dispute. + function _setupCollectedAgreement( + Seed memory seed, + uint256 unboundedTokensCollected + ) internal returns (bytes16 agreementId, IndexerState memory indexerState) { + Context storage ctx = _newCtx(seed); + indexerState = _withIndexer(ctx); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); + agreementId = acceptedAgreementId; + + // Set payments destination + resetPrank(indexerState.addr); + subgraphService.setPaymentsDestination(indexerState.addr); + + // Mock the collect call to succeed with some tokens + uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / STAKE_TO_FEES_RATIO); + bytes memory data = abi.encode( + IRecurringCollector.CollectParams({ + agreementId: acceptedAgreementId, + collectionId: bytes32(uint256(uint160(indexerState.allocationId))), + tokens: 0, + dataServiceCut: 0, + receiverDestination: indexerState.addr, + maxSlippage: type(uint256).max + }) + ); + vm.mockCall( + address(recurringCollector), + abi.encodeWithSelector(IPaymentsCollector.collect.selector, IGraphPayments.PaymentTypes.IndexingFee, data), + abi.encode(tokensCollected) + ); + + skip(1); // Make agreement collectable + + // Collect to set lastCollectionAt > 0 + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1( + acceptedAgreementId, + 100, // entities + // forge-lint: disable-next-line(unsafe-typecast) + bytes32("POI1"), + epochManager.currentEpochBlock(), + bytes("") + ) + ); + + // The collect mock prevented the real RecurringCollector from updating lastCollectionAt. + // Mock getAgreement to return lastCollectionAt > 0 so the dispute can be created. + IRecurringCollector.AgreementData memory agreementData = recurringCollector.getAgreement(acceptedAgreementId); + agreementData.lastCollectionAt = uint64(block.timestamp); + vm.mockCall( + address(recurringCollector), + abi.encodeWithSelector(recurringCollector.getAgreement.selector, acceptedAgreementId), + abi.encode(agreementData) + ); + } + + /* + * TESTS + */ + + function test_IndexingFee_Create_Dispute(Seed memory seed, uint256 unboundedTokensCollected) public { + (bytes16 agreementId, IndexerState memory indexerState) = _setupCollectedAgreement( + seed, + unboundedTokensCollected + ); + + // Create dispute as fisherman + resetPrank(users.fisherman); + token.approve(address(disputeManager), disputeManager.disputeDeposit()); + + bytes32 disputeId = disputeManager.createIndexingFeeDisputeV1( + agreementId, + // forge-lint: disable-next-line(unsafe-typecast) + bytes32("disputePOI"), + 200, + block.number + ); + + assertTrue(disputeManager.isDisputeCreated(disputeId)); + + // Verify dispute fields + ( + address indexer, + address fisherman, + uint256 deposit, + , + IDisputeManager.DisputeType disputeType, + IDisputeManager.DisputeStatus status, + , + , + uint256 stakeSnapshot + ) = disputeManager.disputes(disputeId); + + assertEq(indexer, indexerState.addr); + assertEq(fisherman, users.fisherman); + assertEq(deposit, disputeManager.disputeDeposit()); + assertEq(uint8(disputeType), uint8(IDisputeManager.DisputeType.IndexingFeeDispute)); + assertEq(uint8(status), uint8(IDisputeManager.DisputeStatus.Pending)); + assertTrue(stakeSnapshot > 0); + } + + function test_IndexingFee_Create_Dispute_RevertWhen_NotCollected(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Attempt to create dispute without collecting first (lastCollectionAt == 0) + resetPrank(users.fisherman); + token.approve(address(disputeManager), disputeManager.disputeDeposit()); + + vm.expectRevert( + abi.encodeWithSelector( + IDisputeManager.DisputeManagerIndexingAgreementNotDisputable.selector, + acceptedAgreementId + ) + ); + // forge-lint: disable-next-line(unsafe-typecast) + disputeManager.createIndexingFeeDisputeV1(acceptedAgreementId, bytes32("POI"), 100, block.number); + } + + function test_IndexingFee_Create_Dispute_EmitsEvent(Seed memory seed, uint256 unboundedTokensCollected) public { + (bytes16 agreementId, IndexerState memory indexerState) = _setupCollectedAgreement( + seed, + unboundedTokensCollected + ); + + // Read the payer from the (mocked) agreement data + IRecurringCollector.AgreementData memory agreementData = recurringCollector.getAgreement(agreementId); + + resetPrank(users.fisherman); + uint256 deposit = disputeManager.disputeDeposit(); + token.approve(address(disputeManager), deposit); + + // forge-lint: disable-next-line(unsafe-typecast) + bytes32 poi = bytes32("disputePOI"); + uint256 entities = 200; + uint256 blockNumber = block.number; + + bytes32 expectedDisputeId = keccak256( + abi.encodePacked("IndexingFeeDisputeWithAgreement", agreementId, poi, entities, blockNumber) + ); + + vm.expectEmit(address(disputeManager)); + emit IDisputeManager.IndexingFeeDisputeCreated( + expectedDisputeId, + indexerState.addr, + users.fisherman, + deposit, + agreementData.payer, + agreementId, + poi, + entities, + indexerState.tokens // stakeSnapshot + ); + + bytes32 disputeId = disputeManager.createIndexingFeeDisputeV1(agreementId, poi, entities, blockNumber); + assertEq(disputeId, expectedDisputeId); + } + + function test_IndexingFee_Create_Dispute_RevertWhen_AlreadyCreated( + Seed memory seed, + uint256 unboundedTokensCollected + ) public { + (bytes16 agreementId, ) = _setupCollectedAgreement(seed, unboundedTokensCollected); + + // Create first dispute + resetPrank(users.fisherman); + token.approve(address(disputeManager), disputeManager.disputeDeposit() * 2); + + // forge-lint: disable-next-line(unsafe-typecast) + bytes32 disputeId = disputeManager.createIndexingFeeDisputeV1(agreementId, bytes32("POI"), 100, block.number); + + // Attempt to create a duplicate dispute + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputeAlreadyCreated.selector, disputeId) + ); + // forge-lint: disable-next-line(unsafe-typecast) + disputeManager.createIndexingFeeDisputeV1(agreementId, bytes32("POI"), 100, block.number); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/getters.t.sol b/packages/subgraph-service/test/unit/subgraphService/getters.t.sol index 27c9aafbb..5f884cfcb 100644 --- a/packages/subgraph-service/test/unit/subgraphService/getters.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/getters.t.sol @@ -23,6 +23,11 @@ contract SubgraphServiceGettersTest is SubgraphServiceTest { assertEq(result, address(curation)); } + function test_GetRecurringCollector() public view { + address result = address(subgraphService.recurringCollector()); + assertEq(result, address(recurringCollector)); + } + function test_GetAllocationData(uint256 tokens) public useIndexer useAllocation(tokens) { ( bool isOpen, diff --git a/packages/subgraph-service/test/unit/subgraphService/governance/indexingFeesCut.t.sol b/packages/subgraph-service/test/unit/subgraphService/governance/indexingFeesCut.t.sol new file mode 100644 index 000000000..8bd374c01 --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/governance/indexingFeesCut.t.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; +import { SubgraphServiceTest } from "../SubgraphService.t.sol"; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; + +contract SubgraphServiceGovernanceIndexingFeesCutTest is SubgraphServiceTest { + /* + * TESTS + */ + + function test_Governance_SetIndexingFeesCut(uint256 indexingFeesCut) public useGovernor { + vm.assume(indexingFeesCut <= MAX_PPM); + + vm.expectEmit(address(subgraphService)); + emit ISubgraphService.IndexingFeesCutSet(indexingFeesCut); + subgraphService.setIndexingFeesCut(indexingFeesCut); + + assertEq(subgraphService.indexingFeesCut(), indexingFeesCut); + } + + function test_Governance_SetIndexingFeesCut_RevertWhen_InvalidPPM(uint256 indexingFeesCut) public useGovernor { + vm.assume(indexingFeesCut > MAX_PPM); + + vm.expectRevert( + abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidIndexingFeesCut.selector, indexingFeesCut) + ); + subgraphService.setIndexingFeesCut(indexingFeesCut); + } + + function test_Governance_SetIndexingFeesCut_RevertWhen_NotGovernor() public useIndexer { + uint256 indexingFeesCut = 100_000; // 10% + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.indexer)); + subgraphService.setIndexingFeesCut(indexingFeesCut); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index 6b14848ff..4296c8415 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -22,47 +22,47 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenPaused( address allocationId, address operator, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA calldata signedRCA + IRecurringCollector.RecurringCollectionAgreement calldata rca, + bytes calldata authData ) public withSafeIndexerOrOperator(operator) { resetPrank(users.pauseGuardian); subgraphService.pause(); resetPrank(operator); vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); - subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + subgraphService.acceptIndexingAgreement(allocationId, rca, authData); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenNotAuthorized( address allocationId, address operator, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA calldata signedRCA + IRecurringCollector.RecurringCollectionAgreement calldata rca, + bytes calldata authData ) public withSafeIndexerOrOperator(operator) { - vm.assume(operator != signedRCA.rca.serviceProvider); + vm.assume(operator != rca.serviceProvider); resetPrank(operator); bytes memory expectedErr = abi.encodeWithSelector( ProvisionManager.ProvisionManagerNotAuthorized.selector, - signedRCA.rca.serviceProvider, + rca.serviceProvider, operator ); vm.expectRevert(expectedErr); - subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + subgraphService.acceptIndexingAgreement(allocationId, rca, authData); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidProvision( address indexer, uint256 unboundedTokens, address allocationId, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA memory signedRCA + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes memory authData ) public withSafeIndexerOrOperator(indexer) { uint256 tokens = bound(unboundedTokens, 1, MINIMUM_PROVISION_TOKENS - 1); mint(indexer, tokens); resetPrank(indexer); _createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD); - signedRCA.rca.serviceProvider = indexer; + rca.serviceProvider = indexer; bytes memory expectedErr = abi.encodeWithSelector( ProvisionManager.ProvisionManagerInvalidValue.selector, "tokens", @@ -71,27 +71,27 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg MAXIMUM_PROVISION_TOKENS ); vm.expectRevert(expectedErr); - subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + subgraphService.acceptIndexingAgreement(allocationId, rca, authData); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenIndexerNotRegistered( address indexer, uint256 unboundedTokens, address allocationId, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA memory signedRCA + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes memory authData ) public withSafeIndexerOrOperator(indexer) { uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS); mint(indexer, tokens); resetPrank(indexer); _createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD); - signedRCA.rca.serviceProvider = indexer; + rca.serviceProvider = indexer; bytes memory expectedErr = abi.encodeWithSelector( ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, indexer ); vm.expectRevert(expectedErr); - subgraphService.acceptIndexingAgreement(allocationId, signedRCA); + subgraphService.acceptIndexingAgreement(allocationId, rca, authData); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenNotDataService( @@ -102,41 +102,47 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); - acceptable.rca.dataService = incorrectDataService; - IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( - acceptable.rca, - ctx.payer.signerPrivateKey + (IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, ) = _generateAcceptableSignedRCA( + ctx, + indexerState.addr ); + acceptableRca.dataService = incorrectDataService; + ( + IRecurringCollector.RecurringCollectionAgreement memory unacceptableRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(acceptableRca, ctx.payer.signerPrivateKey); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementWrongDataService.selector, address(subgraphService), - unacceptable.rca.dataService + unacceptableRca.dataService ); vm.expectRevert(expectedErr); vm.prank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptableRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); - acceptable.rca.metadata = bytes("invalid"); - IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( - acceptable.rca, - ctx.payer.signerPrivateKey + (IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, ) = _generateAcceptableSignedRCA( + ctx, + indexerState.addr ); + acceptableRca.metadata = bytes("invalid"); + ( + IRecurringCollector.RecurringCollectionAgreement memory unacceptableRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(acceptableRca, ctx.payer.signerPrivateKey); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, "decodeRCAMetadata", - unacceptable.rca.metadata + unacceptableRca.metadata ); vm.expectRevert(expectedErr); vm.prank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptableRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidAllocation( @@ -145,7 +151,10 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, + bytes memory signature + ) = _generateAcceptableSignedRCA(ctx, indexerState.addr); bytes memory expectedErr = abi.encodeWithSelector( IAllocation.AllocationDoesNotExist.selector, @@ -153,14 +162,17 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); vm.prank(indexerState.addr); - subgraphService.acceptIndexingAgreement(invalidAllocationId, acceptable); + subgraphService.acceptIndexingAgreement(invalidAllocationId, acceptableRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAllocationNotAuthorized(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerStateA = _withIndexer(ctx); IndexerState memory indexerStateB = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptableA = _generateAcceptableSignedRCA(ctx, indexerStateA.addr); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptableRcaA, + bytes memory signatureA + ) = _generateAcceptableSignedRCA(ctx, indexerStateA.addr); bytes memory expectedErr = abi.encodeWithSelector( ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, @@ -169,13 +181,16 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); vm.prank(indexerStateA.addr); - subgraphService.acceptIndexingAgreement(indexerStateB.allocationId, acceptableA); + subgraphService.acceptIndexingAgreement(indexerStateB.allocationId, acceptableRcaA, signatureA); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAllocationClosed(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, + bytes memory signature + ) = _generateAcceptableSignedRCA(ctx, indexerState.addr); resetPrank(indexerState.addr); subgraphService.stopService(indexerState.addr, abi.encode(indexerState.allocationId)); @@ -185,7 +200,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg indexerState.allocationId ); vm.expectRevert(expectedErr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptableRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenDeploymentIdMismatch( @@ -195,12 +210,15 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); vm.assume(indexerState.subgraphDeploymentId != wrongSubgraphDeploymentId); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); - acceptable.rca.metadata = abi.encode(_newAcceptIndexingAgreementMetadataV1(wrongSubgraphDeploymentId)); - IRecurringCollector.SignedRCA memory unacceptable = _recurringCollectorHelper.generateSignedRCA( - acceptable.rca, - ctx.payer.signerPrivateKey + (IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, ) = _generateAcceptableSignedRCA( + ctx, + indexerState.addr ); + acceptableRca.metadata = abi.encode(_newAcceptIndexingAgreementMetadataV1(wrongSubgraphDeploymentId)); + ( + IRecurringCollector.RecurringCollectionAgreement memory unacceptableRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(acceptableRca, ctx.payer.signerPrivateKey); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementDeploymentIdMismatch.selector, @@ -210,15 +228,21 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); vm.prank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptableRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAccepted(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( - ctx, - indexerState + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Re-sign for the re-accept attempt (the original signature was consumed) + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA( + acceptedRca, + ctx.payer.signerPrivateKey ); bytes memory expectedErr = abi.encodeWithSelector( @@ -227,7 +251,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); resetPrank(ctx.indexers[0].addr); - subgraphService.acceptIndexingAgreement(ctx.indexers[0].allocationId, accepted); + subgraphService.acceptIndexingAgreement(ctx.indexers[0].allocationId, acceptedRca, signature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated( @@ -238,8 +262,11 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg IndexerState memory indexerState = _withIndexer(ctx); // First, accept an indexing agreement on the allocation - (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); - vm.assume(accepted.rca.nonce != alternativeNonce); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); + vm.assume(acceptedRca.nonce != alternativeNonce); // Now try to accept a different agreement on the same allocation // Create a new agreement with different nonce to ensure different agreement ID @@ -248,11 +275,10 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg newRCA.nonce = alternativeNonce; // Different nonce to ensure different agreement ID // Sign the new agreement - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA memory newSignedRCA = _recurringCollectorHelper.generateSignedRCA( - newRCA, - ctx.payer.signerPrivateKey - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory newSignedRca, + bytes memory newSignature + ) = _recurringCollectorHelper.generateSignedRCA(newRCA, ctx.payer.signerPrivateKey); // Expect the error when trying to accept a second agreement on the same allocation bytes memory expectedErr = abi.encodeWithSelector( @@ -261,23 +287,26 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, newSignedRCA); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, newSignedRca, newSignature); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidTermsData(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + (IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, ) = _generateAcceptableSignedRCA( + ctx, + indexerState.addr + ); // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.RecurringCollectionAgreement memory notAcceptableRCA = acceptable.rca; + IRecurringCollector.RecurringCollectionAgreement memory notAcceptableRCA = acceptableRca; bytes memory invalidTermsData = bytes("invalid terms data"); notAcceptableRCA.metadata = abi.encode( _newAcceptIndexingAgreementMetadataV1Terms(indexerState.subgraphDeploymentId, invalidTermsData) ); - IRecurringCollector.SignedRCA memory notAcceptable = _recurringCollectorHelper.generateSignedRCA( - notAcceptableRCA, - ctx.payer.signerPrivateKey - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory notAcceptableRcaSigned, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(notAcceptableRCA, ctx.payer.signerPrivateKey); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, @@ -286,30 +315,33 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, notAcceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, notAcceptableRcaSigned, signature); } function test_SubgraphService_AcceptIndexingAgreement(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, + bytes memory signature + ) = _generateAcceptableSignedRCA(ctx, indexerState.addr); IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = abi.decode( - acceptable.rca.metadata, + acceptableRca.metadata, (IndexingAgreement.AcceptIndexingAgreementMetadata) ); // Generate deterministic agreement ID for event expectation bytes16 expectedAgreementId = recurringCollector.generateAgreementId( - acceptable.rca.payer, - acceptable.rca.dataService, - acceptable.rca.serviceProvider, - acceptable.rca.deadline, - acceptable.rca.nonce + acceptableRca.payer, + acceptableRca.dataService, + acceptableRca.serviceProvider, + acceptableRca.deadline, + acceptableRca.nonce ); vm.expectEmit(address(subgraphService)); emit IndexingAgreement.IndexingAgreementAccepted( - acceptable.rca.serviceProvider, - acceptable.rca.payer, + acceptableRca.serviceProvider, + acceptableRca.payer, expectedAgreementId, indexerState.allocationId, metadata.subgraphDeploymentId, @@ -318,7 +350,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); resetPrank(indexerState.addr); - subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptable); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptableRca, signature); } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol index 4a8f020c7..e01d157c0 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol @@ -32,12 +32,12 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre // Accept an indexing agreement Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( - ctx, - indexerState - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); IIndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId); - _assertEqualAgreement(accepted.rca, agreement); + _assertEqualAgreement(acceptedRca, agreement); } function test_SubgraphService_Revert_WhenUnsafeAddress_WhenProxyAdmin(address indexer, bytes16 agreementId) public { diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index 4ca5b56fc..a0d4ed2d1 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -33,14 +33,16 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg address rando ) public withSafeIndexerOrOperator(rando) { Context storage ctx = _newCtx(seed); - (IRecurringCollector.SignedRCA memory accepted, bytes16 agreementId) = _withAcceptedIndexingAgreement( - ctx, - _withIndexer(ctx) - ); + vm.assume(rando != seed.rca.payer); + vm.assume(rando != ctx.payer.signer); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNonCancelableBy.selector, - accepted.rca.payer, + acceptedRca.payer, rando ); vm.expectRevert(expectedErr); @@ -70,14 +72,14 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( - ctx, - indexerState - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); IRecurringCollector.CancelAgreementBy by = cancelSource ? IRecurringCollector.CancelAgreementBy.ServiceProvider : IRecurringCollector.CancelAgreementBy.Payer; - _cancelAgreement(ctx, acceptedAgreementId, indexerState.addr, accepted.rca.payer, by); + _cancelAgreement(ctx, acceptedAgreementId, indexerState.addr, acceptedRca.payer, by); resetPrank(indexerState.addr); bytes memory expectedErr = abi.encodeWithSelector( @@ -90,16 +92,16 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg function test_SubgraphService_CancelIndexingAgreementByPayer(Seed memory seed) public { Context storage ctx = _newCtx(seed); - (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( - ctx, - _withIndexer(ctx) - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); _cancelAgreement( ctx, acceptedAgreementId, - accepted.rca.serviceProvider, - accepted.rca.payer, + acceptedRca.serviceProvider, + acceptedRca.payer, IRecurringCollector.CancelAgreementBy.Payer ); } @@ -193,14 +195,14 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( - ctx, - indexerState - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca2, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); IRecurringCollector.CancelAgreementBy by = cancelSource ? IRecurringCollector.CancelAgreementBy.ServiceProvider : IRecurringCollector.CancelAgreementBy.Payer; - _cancelAgreement(ctx, acceptedAgreementId, accepted.rca.serviceProvider, accepted.rca.payer, by); + _cancelAgreement(ctx, acceptedAgreementId, acceptedRca2.serviceProvider, acceptedRca2.payer, by); resetPrank(indexerState.addr); bytes memory expectedErr = abi.encodeWithSelector( @@ -213,16 +215,16 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg function test_SubgraphService_CancelIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); - (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( - ctx, - _withIndexer(ctx) - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, _withIndexer(ctx)); _cancelAgreement( ctx, acceptedAgreementId, - accepted.rca.serviceProvider, - accepted.rca.payer, + acceptedRca.serviceProvider, + acceptedRca.payer, IRecurringCollector.CancelAgreementBy.ServiceProvider ); } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 447f54f3d..5818a1d63 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -29,10 +29,10 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement( - ctx, - indexerState - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); assertEq(subgraphService.feesProvisionTracker(indexerState.addr), 0, "Should be 0 before collect"); @@ -56,7 +56,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA abi.encodeWithSelector(IPaymentsCollector.collect.selector, IGraphPayments.PaymentTypes.IndexingFee, data), abi.encode(tokensCollected) ); - _expectCollectCallAndEmit(data, indexerState, accepted, acceptedAgreementId, tokensCollected, entities, poi); + _expectCollectCallAndEmit(data, indexerState, acceptedRca, acceptedAgreementId, tokensCollected, entities, poi); skip(1); // To make agreement collectable @@ -313,7 +313,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA function _expectCollectCallAndEmit( bytes memory _data, IndexerState memory _indexerState, - IRecurringCollector.SignedRCA memory _accepted, + IRecurringCollector.RecurringCollectionAgreement memory _acceptedRca, bytes16 _acceptedAgreementId, uint256 _tokensCollected, uint256 _entities, @@ -326,7 +326,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA vm.expectEmit(address(subgraphService)); emit IndexingAgreement.IndexingFeesCollectedV1( _indexerState.addr, - _accepted.rca.payer, + _acceptedRca.payer, _acceptedAgreementId, _indexerState.allocationId, _indexerState.subgraphDeploymentId, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 2eb409f03..d6f69414f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -172,10 +172,11 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex subgraphService.setPaymentsDestination(_indexerState.addr); // Accept the Indexing Agreement - bytes16 agreementId = subgraphService.acceptIndexingAgreement( - _indexerState.allocationId, - _recurringCollectorHelper.generateSignedRCA(_rca, _ctx.payer.signerPrivateKey) - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory signedRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(_rca, _ctx.payer.signerPrivateKey); + bytes16 agreementId = subgraphService.acceptIndexingAgreement(_indexerState.allocationId, signedRca, signature); // Skip ahead to collection point skip(_expectedTokens.expectedTotalTokensCollected / terms.tokensPerSecond); @@ -265,10 +266,15 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex function _getState(address _payer, address _indexer) private view returns (TestState memory) { CollectPaymentData memory collect = _collectPaymentData(_indexer); + (uint256 escrowBal, uint256 escrowThawing, ) = escrow.escrowAccounts( + _payer, + address(recurringCollector), + _indexer + ); return TestState({ - escrowBalance: escrow.getBalance(_payer, address(recurringCollector), _indexer), + escrowBalance: escrowBal - escrowThawing, indexerBalance: collect.indexerBalance, indexerTokensLocked: collect.lockedTokens }); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index 08b8d4ac3..ea371e237 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -170,7 +170,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _withAcceptedIndexingAgreement( Context storage _ctx, IndexerState memory _indexerState - ) internal returns (IRecurringCollector.SignedRCA memory, bytes16 agreementId) { + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes16 agreementId) { IRecurringCollector.RecurringCollectionAgreement memory rca = _ctx.ctxInternal.seed.rca; IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = _newAcceptIndexingAgreementMetadataV1( @@ -182,11 +182,10 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun rca = _recurringCollectorHelper.sensibleRCA(rca); - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCA memory signedRCA = _recurringCollectorHelper.generateSignedRCA( - rca, - _ctx.payer.signerPrivateKey - ); + ( + IRecurringCollector.RecurringCollectionAgreement memory signedRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(rca, _ctx.payer.signerPrivateKey); _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, _ctx.payer.signerPrivateKey); // Generate deterministic agreement ID for event expectation @@ -209,11 +208,15 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun metadata.terms ); _subgraphServiceSafePrank(_indexerState.addr); - bytes16 actualAgreementId = subgraphService.acceptIndexingAgreement(_indexerState.allocationId, signedRCA); + bytes16 actualAgreementId = subgraphService.acceptIndexingAgreement( + _indexerState.allocationId, + signedRca, + signature + ); // Verify the agreement ID matches expectation assertEq(actualAgreementId, agreementId); - return (signedRCA, agreementId); + return (signedRca, agreementId); } function _newCtx(Seed memory _seed) internal returns (Context storage) { @@ -238,7 +241,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _generateAcceptableSignedRCA( Context storage _ctx, address _indexerAddress - ) internal returns (IRecurringCollector.SignedRCA memory) { + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes memory) { IRecurringCollector.RecurringCollectionAgreement memory rca = _generateAcceptableRecurringCollectionAgreement( _ctx, _indexerAddress @@ -267,7 +270,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _generateAcceptableSignedRCAU( Context storage _ctx, IRecurringCollector.RecurringCollectionAgreement memory _rca - ) internal view returns (IRecurringCollector.SignedRCAU memory) { + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory, bytes memory) { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _generateAcceptableRecurringCollectionAgreementUpdate(_ctx, _rca); // Set correct nonce for first update (should be 1) diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index d968ba178..b77d91644 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -19,22 +19,22 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA /* solhint-disable graph/func-name-mixedcase */ function test_SubgraphService_UpdateIndexingAgreementIndexingAgreement_Revert_WhenPaused( address operator, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCAU calldata signedRCAU + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata authData ) public withSafeIndexerOrOperator(operator) { resetPrank(users.pauseGuardian); subgraphService.pause(); resetPrank(operator); vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); - subgraphService.updateIndexingAgreement(operator, signedRCAU); + subgraphService.updateIndexingAgreement(operator, rcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorized( address indexer, address notAuthorized, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCAU calldata signedRCAU + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau, + bytes calldata authData ) public withSafeIndexerOrOperator(notAuthorized) { vm.assume(notAuthorized != indexer); resetPrank(notAuthorized); @@ -44,14 +44,14 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA notAuthorized ); vm.expectRevert(expectedErr); - subgraphService.updateIndexingAgreement(indexer, signedRCAU); + subgraphService.updateIndexingAgreement(indexer, rcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidProvision( address indexer, uint256 unboundedTokens, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCAU memory signedRCAU + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + bytes memory authData ) public withSafeIndexerOrOperator(indexer) { uint256 tokens = bound(unboundedTokens, 1, MINIMUM_PROVISION_TOKENS - 1); mint(indexer, tokens); @@ -66,14 +66,14 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA MAXIMUM_PROVISION_TOKENS ); vm.expectRevert(expectedErr); - subgraphService.updateIndexingAgreement(indexer, signedRCAU); + subgraphService.updateIndexingAgreement(indexer, rcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenIndexerNotRegistered( address indexer, uint256 unboundedTokens, - // forge-lint: disable-next-line(mixed-case-variable) - IRecurringCollector.SignedRCAU memory signedRCAU + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau, + bytes memory authData ) public withSafeIndexerOrOperator(indexer) { uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS); mint(indexer, tokens); @@ -85,24 +85,24 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA indexer ); vm.expectRevert(expectedErr); - subgraphService.updateIndexingAgreement(indexer, signedRCAU); + subgraphService.updateIndexingAgreement(indexer, rcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAccepted(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU( - ctx, - _generateAcceptableRecurringCollectionAgreement(ctx, indexerState.addr) - ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableRcau, + bytes memory authData + ) = _generateAcceptableSignedRCAU(ctx, _generateAcceptableRecurringCollectionAgreement(ctx, indexerState.addr)); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNotActive.selector, - acceptableUpdate.rcau.agreementId + acceptableRcau.agreementId ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); - subgraphService.updateIndexingAgreement(indexerState.addr, acceptableUpdate); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableRcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorizedForAgreement( @@ -111,66 +111,81 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA Context storage ctx = _newCtx(seed); IndexerState memory indexerStateA = _withIndexer(ctx); IndexerState memory indexerStateB = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerStateA); - IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerStateA + ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableRcau, + bytes memory authData + ) = _generateAcceptableSignedRCAU(ctx, acceptedRca); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementNotAuthorized.selector, - acceptableUpdate.rcau.agreementId, + acceptableRcau.agreementId, indexerStateB.addr ); vm.expectRevert(expectedErr); resetPrank(indexerStateB.addr); - subgraphService.updateIndexingAgreement(indexerStateB.addr, acceptableUpdate); + subgraphService.updateIndexingAgreement(indexerStateB.addr, acceptableRcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); IRecurringCollector.RecurringCollectionAgreementUpdate - memory acceptableUpdate = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, accepted.rca); + memory acceptableUpdate = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, acceptedRca); acceptableUpdate.metadata = bytes("invalid"); // Set correct nonce for first update (should be 1) acceptableUpdate.nonce = 1; - IRecurringCollector.SignedRCAU memory unacceptableUpdate = _recurringCollectorHelper.generateSignedRCAU( - acceptableUpdate, - ctx.payer.signerPrivateKey - ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory unacceptableRcau, + bytes memory authData + ) = _recurringCollectorHelper.generateSignedRCAU(acceptableUpdate, ctx.payer.signerPrivateKey); bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector, "decodeRCAUMetadata", - unacceptableUpdate.rcau.metadata + unacceptableRcau.metadata ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); - subgraphService.updateIndexingAgreement(indexerState.addr, unacceptableUpdate); + subgraphService.updateIndexingAgreement(indexerState.addr, unacceptableRcau, authData); } function test_SubgraphService_UpdateIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); - (IRecurringCollector.SignedRCA memory accepted, ) = _withAcceptedIndexingAgreement(ctx, indexerState); - IRecurringCollector.SignedRCAU memory acceptableUpdate = _generateAcceptableSignedRCAU(ctx, accepted.rca); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableRcau, + bytes memory authData + ) = _generateAcceptableSignedRCAU(ctx, acceptedRca); IndexingAgreement.UpdateIndexingAgreementMetadata memory metadata = abi.decode( - acceptableUpdate.rcau.metadata, + acceptableRcau.metadata, (IndexingAgreement.UpdateIndexingAgreementMetadata) ); vm.expectEmit(address(subgraphService)); emit IndexingAgreement.IndexingAgreementUpdated( - accepted.rca.serviceProvider, - accepted.rca.payer, - acceptableUpdate.rcau.agreementId, + acceptedRca.serviceProvider, + acceptedRca.payer, + acceptableRcau.agreementId, indexerState.allocationId, metadata.version, metadata.terms ); resetPrank(indexerState.addr); - subgraphService.updateIndexingAgreement(indexerState.addr, acceptableUpdate); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableRcau, authData); } /* solhint-enable graph/func-name-mixedcase */ } From 89def3d34f7a123913793677272a9ecf5c681997 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:44:18 +0000 Subject: [PATCH 047/157] feat: enumerable indexer tracking for REO and issuance constructor cleanup Add EnumerableSet-based indexer tracking to RewardsEligibilityOracle with a helper contract for paginated queries. Introduce retention-based cleanup that removes indexers only after a configurable idle period. Split REO interface into focused sub-interfaces for administration, status, events, maintenance, and helper operations. Also refactor issuance constructors from address to IGraphToken type and normalise pragma to ^0.8.27 across issuance test files. --- .../IRewardsEligibilityAdministration.sol | 10 + .../eligibility/IRewardsEligibilityEvents.sol | 10 + .../eligibility/IRewardsEligibilityHelper.sol | 44 ++++ .../IRewardsEligibilityMaintenance.sol | 26 ++ .../eligibility/IRewardsEligibilityStatus.sol | 27 +++ .../contracts/allocate/DirectAllocation.sol | 12 +- .../contracts/allocate/IssuanceAllocator.sol | 5 +- .../contracts/common/BaseUpgradeable.sol | 8 +- .../contracts/common/EnumerableSetUtil.sol | 61 +++++ .../eligibility/RewardsEligibilityHelper.sol | 54 +++++ .../eligibility/RewardsEligibilityOracle.md | 70 +++++- .../eligibility/RewardsEligibilityOracle.sol | 83 ++++++- .../allocate/IssuanceAllocatorTestHarness.sol | 5 +- .../test/unit/allocator/construction.t.sol | 7 +- .../test/unit/allocator/defensiveChecks.t.sol | 5 +- .../test/unit/allocator/distribution.t.sol | 2 +- .../allocator/distributionAccounting.t.sol | 2 +- .../unit/allocator/interfaceIdStability.t.sol | 2 +- .../issuance/test/unit/allocator/shared.t.sol | 5 +- .../unit/allocator/targetManagement.t.sol | 2 +- .../direct-allocation/DirectAllocation.t.sol | 11 +- .../test/unit/eligibility/accessControl.t.sol | 2 +- .../test/unit/eligibility/construction.t.sol | 7 +- .../test/unit/eligibility/eligibility.t.sol | 2 +- .../test/unit/eligibility/helper.t.sol | 165 +++++++++++++ .../unit/eligibility/indexerManagement.t.sol | 2 +- .../unit/eligibility/indexerTracking.t.sol | 222 ++++++++++++++++++ .../eligibility/interfaceCompliance.t.sol | 15 +- .../unit/eligibility/operatorFunctions.t.sol | 2 +- .../test/unit/eligibility/shared.t.sol | 6 +- .../test/unit/mocks/MockGraphToken.sol | 2 +- 31 files changed, 825 insertions(+), 51 deletions(-) create mode 100644 packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityHelper.sol create mode 100644 packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol create mode 100644 packages/issuance/contracts/common/EnumerableSetUtil.sol create mode 100644 packages/issuance/contracts/eligibility/RewardsEligibilityHelper.sol create mode 100644 packages/issuance/test/unit/eligibility/helper.t.sol create mode 100644 packages/issuance/test/unit/eligibility/indexerTracking.t.sol diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol index e8fc2423f..2bc5e0498 100644 --- a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol +++ b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol @@ -34,4 +34,14 @@ interface IRewardsEligibilityAdministration is IRewardsEligibilityEvents { * @return True if successfully set (always the case for current code) */ function setEligibilityValidation(bool enabled) external returns (bool); + + /** + * @notice Set the indexer retention period for tracked indexer cleanup + * @dev Only callable by accounts with the OPERATOR_ROLE. Indexers whose last + * renewal timestamp is older than this period can be permissionlessly removed + * from the tracked set via {IRewardsEligibilityMaintenance-removeStaleIndexer}. + * @param indexerRetentionPeriod New retention period in seconds + * @return True if the state is as requested (retention period is set to the specified value) + */ + function setIndexerRetentionPeriod(uint256 indexerRetentionPeriod) external returns (bool); } diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol index f2214ecb3..b26d9e2be 100644 --- a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol +++ b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol @@ -31,4 +31,14 @@ interface IRewardsEligibilityEvents { /// @param oldTimeout The previous timeout period in seconds /// @param newTimeout The new timeout period in seconds event OracleUpdateTimeoutUpdated(uint256 indexed oldTimeout, uint256 indexed newTimeout); + + /// @notice Emitted when an indexer is added to or removed from the tracked set + /// @param indexer The indexer address + /// @param tracked True when added (first renewal), false when removed (stale cleanup) + event IndexerTrackingUpdated(address indexed indexer, bool indexed tracked); + + /// @notice Emitted when the indexer retention period is updated + /// @param oldPeriod The previous retention period in seconds + /// @param newPeriod The new retention period in seconds + event IndexerRetentionPeriodSet(uint256 indexed oldPeriod, uint256 indexed newPeriod); } diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityHelper.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityHelper.sol new file mode 100644 index 000000000..6a7894218 --- /dev/null +++ b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityHelper.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.7.6 || ^0.8.0; + +/** + * @title Interface for the {RewardsEligibilityHelper} contract + * @author Edge & Node + * @notice Stateless, permissionless convenience contract for {RewardsEligibilityOracle}. + * Provides batch removal of expired indexers from the tracked set. + * Independently deployable — better versions can be deployed without protocol changes. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IRewardsEligibilityHelper { + /** + * @notice Remove expired indexers from the tracked set by explicit address list + * @dev Calls {IRewardsEligibilityMaintenance-removeExpiredIndexer} for each address. + * @param indexers Array of indexer addresses to check and remove + * @return gone Number of indexers now absent from the tracked set + */ + function removeExpiredIndexers(address[] calldata indexers) external returns (uint256 gone); + + /** + * @notice Remove all expired indexers from the tracked set + * @dev Snapshots the full tracked set then calls + * {IRewardsEligibilityMaintenance-removeExpiredIndexer} for each. + * May be expensive for large sets; prefer the paginated overload for gas-bounded calls. + * @return gone Number of indexers now absent from the tracked set + */ + function removeExpiredIndexers() external returns (uint256 gone); + + /** + * @notice Remove expired indexers from the tracked set by paginated scan + * @dev Reads a slice of the tracked set via {IRewardsEligibilityStatus-getIndexers} + * and calls {IRewardsEligibilityMaintenance-removeExpiredIndexer} for each. + * Note: removals shift set indices between pages, so some indexers may be skipped + * across consecutive paginated calls. Use the parameterless overload to process all. + * @param offset Start index into the tracked indexer set + * @param count Maximum number of indexers to process + * @return gone Number of indexers now absent from the tracked set + */ + function removeExpiredIndexers(uint256 offset, uint256 count) external returns (uint256 gone); +} diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol new file mode 100644 index 000000000..039fd0339 --- /dev/null +++ b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.7.6 || ^0.8.0; + +import { IRewardsEligibilityEvents } from "./IRewardsEligibilityEvents.sol"; + +/** + * @title IRewardsEligibilityMaintenance + * @author Edge & Node + * @notice Interface for permissionless maintenance of the tracked indexer set. + * Allows anyone to remove indexers whose last renewal is older than the + * configured indexer retention period. + */ +interface IRewardsEligibilityMaintenance is IRewardsEligibilityEvents { + /** + * @notice Remove an expired indexer from the tracked set + * @dev Permissionless. An indexer is expired when + * `block.timestamp >= renewalTimestamp + indexerRetentionPeriod`. + * Removes the indexer from the enumerable set and deletes its renewal timestamp. + * No-op (returns true) if the indexer is not in the tracked set. + * @param indexer The indexer address to remove + * @return gone True if the indexer is absent from the tracked set (whether removed + * by this call or already not tracked); false if the indexer is still tracked (not expired) + */ + function removeExpiredIndexer(address indexer) external returns (bool gone); +} diff --git a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol index d088e8168..b3ca7652c 100644 --- a/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol +++ b/packages/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol @@ -39,4 +39,31 @@ interface IRewardsEligibilityStatus { * @return True if eligibility validation is enabled, false otherwise */ function getEligibilityValidation() external view returns (bool); + + /** + * @notice Get the indexer retention period for tracked indexer cleanup + * @return The current indexer retention period in seconds + */ + function getIndexerRetentionPeriod() external view returns (uint256); + + /** + * @notice Get the number of tracked indexers + * @return count The number of indexers in the tracked set + */ + function getIndexerCount() external view returns (uint256 count); + + /** + * @notice Get all tracked indexer addresses + * @dev May be expensive for large sets — prefer the paginated overload for on-chain use. + * @return result Array of tracked indexer addresses + */ + function getIndexers() external view returns (address[] memory result); + + /** + * @notice Get a paginated slice of tracked indexer addresses + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return result Array of tracked indexer addresses + */ + function getIndexers(uint256 offset, uint256 count) external view returns (address[] memory result); } diff --git a/packages/issuance/contracts/allocate/DirectAllocation.sol b/packages/issuance/contracts/allocate/DirectAllocation.sol index 799755256..91f153b5e 100644 --- a/packages/issuance/contracts/allocate/DirectAllocation.sol +++ b/packages/issuance/contracts/allocate/DirectAllocation.sol @@ -5,6 +5,7 @@ pragma solidity ^0.8.27; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; +import { IGraphToken } from "../common/IGraphToken.sol"; // solhint-disable-next-line no-unused-import import { ERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; // Used by @inheritdoc @@ -38,19 +39,16 @@ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { event TokensSent(address indexed to, uint256 indexed amount); // Do not need to index amount, ignoring gas-indexed-events warning. - /// @notice Emitted before the issuance allocation changes - event BeforeIssuanceAllocationChange(); - // -- Constructor -- /** * @notice Constructor for the DirectAllocation contract * @dev This contract is upgradeable, but we use the constructor to pass the Graph Token address * to the base contract. - * @param graphToken Address of the Graph Token contract + * @param graphToken The Graph Token contract * @custom:oz-upgrades-unsafe-allow constructor */ - constructor(address graphToken) BaseUpgradeable(graphToken) {} + constructor(IGraphToken graphToken) BaseUpgradeable(graphToken) {} // -- Initialization -- @@ -89,9 +87,7 @@ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { * before an allocation change. We simply receive tokens from the IssuanceAllocator. * @inheritdoc IIssuanceTarget */ - function beforeIssuanceAllocationChange() external virtual override { - emit BeforeIssuanceAllocationChange(); - } + function beforeIssuanceAllocationChange() external virtual override {} /** * @dev No-op for DirectAllocation; issuanceAllocator is not stored. diff --git a/packages/issuance/contracts/allocate/IssuanceAllocator.sol b/packages/issuance/contracts/allocate/IssuanceAllocator.sol index 83456daf6..76ecf8792 100644 --- a/packages/issuance/contracts/allocate/IssuanceAllocator.sol +++ b/packages/issuance/contracts/allocate/IssuanceAllocator.sol @@ -15,6 +15,7 @@ import { IIssuanceAllocationStatus } from "@graphprotocol/interfaces/contracts/i import { IIssuanceAllocationData } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationData.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; +import { IGraphToken } from "../common/IGraphToken.sol"; import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; @@ -324,10 +325,10 @@ contract IssuanceAllocator is * @notice Constructor for the IssuanceAllocator contract * @dev This contract is upgradeable, but we use the constructor to pass the Graph Token address * to the base contract. - * @param _graphToken Address of the Graph Token contract + * @param _graphToken The Graph Token contract * @custom:oz-upgrades-unsafe-allow constructor */ - constructor(address _graphToken) BaseUpgradeable(_graphToken) {} + constructor(IGraphToken _graphToken) BaseUpgradeable(_graphToken) {} // -- Initialization -- diff --git a/packages/issuance/contracts/common/BaseUpgradeable.sol b/packages/issuance/contracts/common/BaseUpgradeable.sol index 2141a8e20..28a8f8966 100644 --- a/packages/issuance/contracts/common/BaseUpgradeable.sol +++ b/packages/issuance/contracts/common/BaseUpgradeable.sol @@ -87,12 +87,12 @@ abstract contract BaseUpgradeable is * @notice Constructor for the BaseUpgradeable contract * @dev This contract is upgradeable, but we use the constructor to set immutable variables * and disable initializers to prevent the implementation contract from being initialized. - * @param graphToken Address of the Graph Token contract + * @param graphToken The Graph Token contract * @custom:oz-upgrades-unsafe-allow constructor */ - constructor(address graphToken) { - require(graphToken != address(0), GraphTokenCannotBeZeroAddress()); - GRAPH_TOKEN = IGraphToken(graphToken); + constructor(IGraphToken graphToken) { + require(address(graphToken) != address(0), GraphTokenCannotBeZeroAddress()); + GRAPH_TOKEN = graphToken; _disableInitializers(); } diff --git a/packages/issuance/contracts/common/EnumerableSetUtil.sol b/packages/issuance/contracts/common/EnumerableSetUtil.sol new file mode 100644 index 000000000..65a09c41c --- /dev/null +++ b/packages/issuance/contracts/common/EnumerableSetUtil.sol @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.8.27; + +import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; + +/** + * @title EnumerableSetUtil + * @author Edge & Node + * @notice Pagination helpers for OpenZeppelin EnumerableSet types. + */ +library EnumerableSetUtil { + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSet for EnumerableSet.Bytes32Set; + + /** + * @notice Return a page of addresses from an AddressSet. + * @param set The enumerable address set to paginate + * @param offset Number of entries to skip + * @param count Maximum number of entries to return + * @return result Array of addresses (may be shorter than count) + */ + function getPage( + EnumerableSet.AddressSet storage set, + uint256 offset, + uint256 count + ) internal view returns (address[] memory result) { + uint256 total = set.length(); + // solhint-disable-next-line gas-strict-inequalities + if (total <= offset) return new address[](0); + + uint256 remaining = total - offset; + if (remaining < count) count = remaining; + + result = new address[](count); + for (uint256 i = 0; i < count; ++i) result[i] = set.at(offset + i); + } + + /** + * @notice Return a page of bytes16 ids from a Bytes32Set (truncating each entry). + * @param set The enumerable bytes32 set to paginate + * @param offset Number of entries to skip + * @param count Maximum number of entries to return + * @return result Array of bytes16 values (may be shorter than count) + */ + function getPageBytes16( + EnumerableSet.Bytes32Set storage set, + uint256 offset, + uint256 count + ) internal view returns (bytes16[] memory result) { + uint256 total = set.length(); + // solhint-disable-next-line gas-strict-inequalities + if (total <= offset) return new bytes16[](0); + + uint256 remaining = total - offset; + if (remaining < count) count = remaining; + + result = new bytes16[](count); + for (uint256 i = 0; i < count; ++i) result[i] = bytes16(set.at(offset + i)); + } +} diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityHelper.sol b/packages/issuance/contracts/eligibility/RewardsEligibilityHelper.sol new file mode 100644 index 000000000..f72e86e22 --- /dev/null +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityHelper.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.8.27; + +import { IRewardsEligibilityHelper } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityHelper.sol"; +import { IRewardsEligibilityMaintenance } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol"; +import { IRewardsEligibilityStatus } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol"; + +/** + * @title RewardsEligibilityHelper + * @author Edge & Node + * @notice Stateless, permissionless convenience contract for {RewardsEligibilityOracle}. + * Provides batch removal of expired indexers from the tracked set. + * Independently deployable — better versions can be deployed without protocol changes. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +contract RewardsEligibilityHelper is IRewardsEligibilityHelper { + /// @notice The RewardsEligibilityOracle contract address + address public immutable ORACLE; + + /// @notice Thrown when an address parameter is the zero address + error ZeroAddress(); + + /** + * @notice Constructor for the RewardsEligibilityHelper contract + * @param oracle Address of the RewardsEligibilityOracle contract + */ + constructor(address oracle) { + require(oracle != address(0), ZeroAddress()); + ORACLE = oracle; + } + + /// @inheritdoc IRewardsEligibilityHelper + function removeExpiredIndexers(address[] calldata indexers) external returns (uint256 gone) { + for (uint256 i = 0; i < indexers.length; ++i) + if (IRewardsEligibilityMaintenance(ORACLE).removeExpiredIndexer(indexers[i])) ++gone; + } + + /// @inheritdoc IRewardsEligibilityHelper + function removeExpiredIndexers() external returns (uint256 gone) { + address[] memory indexers = IRewardsEligibilityStatus(ORACLE).getIndexers(); + for (uint256 i = 0; i < indexers.length; ++i) + if (IRewardsEligibilityMaintenance(ORACLE).removeExpiredIndexer(indexers[i])) ++gone; + } + + /// @inheritdoc IRewardsEligibilityHelper + function removeExpiredIndexers(uint256 offset, uint256 count) external returns (uint256 gone) { + address[] memory indexers = IRewardsEligibilityStatus(ORACLE).getIndexers(offset, count); + for (uint256 i = 0; i < indexers.length; ++i) + if (IRewardsEligibilityMaintenance(ORACLE).removeExpiredIndexer(indexers[i])) ++gone; + } +} diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md index 26c9123fe..c928cbc7c 100644 --- a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md @@ -14,6 +14,8 @@ The contract operates on a "deny by default" principle - indexers are not eligib - **Oracle-based Renewal**: Only authorized oracles can renew indexer eligibility - **Global Toggle**: Eligibility validation can be globally enabled/disabled - **Timeout Mechanism**: If oracles don't update for too long, all indexers are automatically eligible +- **Enumerable Indexer Tracking**: On-chain discovery of all renewed indexers via `EnumerableSet` +- **Retention-based Cleanup**: Permissionless removal of indexers not renewed within a configurable threshold (default: 365 days) - **Role-based Access Control**: Uses hierarchical roles for governance and operations ## Architecture @@ -36,6 +38,8 @@ The contract uses ERC-7201 namespaced storage to prevent storage collisions in u - `eligibilityValidationEnabled`: Global flag to enable/disable eligibility validation (default: false, to be enabled by operator when ready) - `oracleUpdateTimeout`: Timeout after which all indexers are automatically eligible (default: 7 days) - `lastOracleUpdateTime`: Timestamp of the last oracle update +- `trackedIndexers`: Enumerable set of all indexer addresses renewed by the oracle +- `indexerRetentionPeriod`: Duration after which an un-renewed indexer can be permissionlessly removed from tracking (default: 365 days) ## Core Functions @@ -75,6 +79,14 @@ The `ORACLE_ROLE` constant can be used as the role parameter for these functions - **Returns**: Always true for current implementation - **Events**: Emits `EligibilityValidationUpdated` if state changes +#### `setIndexerRetentionPeriod(uint256 indexerRetentionPeriod) → bool` + +- **Access**: OPERATOR_ROLE only +- **Purpose**: Set how long after last renewal an indexer can be removed from the tracked set +- **Parameters**: `indexerRetentionPeriod` - Duration in seconds +- **Returns**: Always true for current implementation +- **Events**: Emits `IndexerRetentionPeriodSet` if value changes + ### Indexer Management #### `renewIndexerEligibility(address[] calldata indexers, bytes calldata data) → uint256` @@ -87,11 +99,25 @@ The `ORACLE_ROLE` constant can be used as the role parameter for these functions - **Returns**: Number of indexers whose eligibility renewal timestamp was updated - **Events**: - Emits `IndexerEligibilityData` with oracle and data + - Emits `IndexerTrackingUpdated(indexer, true)` when an indexer is first added to the tracked set - Emits `IndexerEligibilityRenewed` for each indexer whose eligibility was renewed - **Notes**: - Updates `lastOracleUpdateTime` to current block timestamp - Only updates timestamp if less than current block timestamp - Ignores zero addresses and duplicate updates within same block + - Adds each renewed indexer to the enumerable tracked set (idempotent for existing members) + +### Maintenance Functions + +#### `removeExpiredIndexer(address indexer) → bool` + +- **Access**: Permissionless +- **Purpose**: Remove an indexer from the tracked set if expired (`block.timestamp >= renewalTimestamp + indexerRetentionPeriod`) +- **Parameters**: `indexer` - The indexer address to check and remove +- **Returns**: True if the indexer is absent from the tracked set (removed or was never there); false if still tracked (not yet expired) +- **Effects**: Removes from the enumerable set and deletes the renewal timestamp mapping entry +- **Events**: Emits `IndexerTrackingUpdated(indexer, false)` when an indexer is actually removed +- **Notes**: A removed indexer can be re-added if the oracle renews it again ### View Functions @@ -129,6 +155,28 @@ The `ORACLE_ROLE` constant can be used as the role parameter for these functions - **Purpose**: Get eligibility validation state - **Returns**: True if enabled, false if disabled +#### `getIndexerRetentionPeriod() → uint256` + +- **Purpose**: Get the indexer retention period for tracked indexer cleanup +- **Returns**: Duration in seconds + +#### `getIndexerCount() → uint256` + +- **Purpose**: Get the number of indexers in the tracked set +- **Returns**: Count of tracked indexers + +#### `getIndexers() → address[]` + +- **Purpose**: Get all tracked indexer addresses +- **Returns**: Array of addresses +- **Note**: May be expensive for large sets; prefer paginated overload for on-chain use + +#### `getIndexers(uint256 offset, uint256 count) → address[]` + +- **Purpose**: Get a paginated slice of tracked indexer addresses +- **Parameters**: `offset` - Start index, `count` - Maximum number to return (clamped) +- **Returns**: Array of addresses + ## Eligibility Logic An indexer is considered eligible if ANY of the following conditions are met: @@ -270,6 +318,8 @@ event IndexerEligibilityRenewed(address indexed indexer, address indexed oracle) event EligibilityPeriodUpdated(uint256 indexed oldPeriod, uint256 indexed newPeriod); event EligibilityValidationUpdated(bool indexed enabled); event OracleUpdateTimeoutUpdated(uint256 indexed oldTimeout, uint256 indexed newTimeout); +event IndexerTrackingUpdated(address indexed indexer, bool indexed tracked); +event IndexerRetentionPeriodSet(uint256 indexed oldThreshold, uint256 indexed newThreshold); ``` ## Default Configuration @@ -277,6 +327,7 @@ event OracleUpdateTimeoutUpdated(uint256 indexed oldTimeout, uint256 indexed new - **Eligibility Period**: 14 days (1,209,600 seconds) - **Oracle Update Timeout**: 7 days (604,800 seconds) - **Eligibility Validation**: Disabled (false) +- **Indexer Retention Period**: 365 days (31,536,000 seconds) - **Last Oracle Update Time**: 0 (never updated) The system is deployed with reasonable defaults but can be adjusted as required. Eligibility validation is disabled by default as the expectation is to first see oracles successfully marking indexers as eligible and having suitably established eligible indexers before enabling. @@ -307,4 +358,21 @@ The system is deployed with reasonable defaults but can be adjusted as required. ## Integration -The contract implements four focused interfaces (`IProviderEligibility`, `IRewardsEligibilityAdministration`, `IRewardsEligibilityReporting`, and `IRewardsEligibilityStatus`) and can be integrated with any system that needs to verify provider eligibility status. The primary integration point is the `isEligible(address)` function which returns a simple boolean indicating eligibility. +The contract implements five focused interfaces (`IProviderEligibility`, `IRewardsEligibilityAdministration`, `IRewardsEligibilityMaintenance`, `IRewardsEligibilityReporting`, and `IRewardsEligibilityStatus`) and can be integrated with any system that needs to verify provider eligibility status. The primary integration point is the `isEligible(address)` function which returns a simple boolean indicating eligibility. The `getIndexers()` function enables on-chain discovery of all tracked indexers without requiring event indexing. + +## RewardsEligibilityHelper + +A stateless, permissionless companion contract that provides batch convenience operations on the oracle. Independently deployable — better versions can be deployed without protocol changes. + +### `removeExpiredIndexers(address[] calldata indexers) → uint256` + +- **Purpose**: Batch removal of expired indexers by explicit address list +- **Parameters**: `indexers` - Array of indexer addresses to process +- **Returns**: Number of indexers now absent from the tracked set (`gone` count) + +### `removeExpiredIndexers(uint256 offset, uint256 count) → uint256` + +- **Purpose**: Batch removal by paginated scan of the tracked set +- **Parameters**: `offset` - Start index, `count` - Maximum number of indexers to process +- **Returns**: Number of indexers now absent from the tracked set (`gone` count) +- **Notes**: Useful for keeper-driven sweeps without requiring an off-chain indexer list diff --git a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol index 7ddc1efbd..935b1619b 100644 --- a/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol +++ b/packages/issuance/contracts/eligibility/RewardsEligibilityOracle.sol @@ -2,11 +2,16 @@ pragma solidity ^0.8.27; +import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; + import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IRewardsEligibilityAdministration } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol"; +import { IRewardsEligibilityMaintenance } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol"; import { IRewardsEligibilityReporting } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityReporting.sol"; import { IRewardsEligibilityStatus } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol"; +import { EnumerableSetUtil } from "../common/EnumerableSetUtil.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; +import { IGraphToken } from "../common/IGraphToken.sol"; /** * @title RewardsEligibilityOracle @@ -29,9 +34,13 @@ contract RewardsEligibilityOracle is BaseUpgradeable, IProviderEligibility, IRewardsEligibilityAdministration, + IRewardsEligibilityMaintenance, IRewardsEligibilityReporting, IRewardsEligibilityStatus { + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSetUtil for EnumerableSet.AddressSet; + // -- Role Constants -- /** @@ -54,21 +63,27 @@ contract RewardsEligibilityOracle is /// @notice Main storage structure for RewardsEligibilityOracle using ERC-7201 namespaced storage /// @param indexerEligibilityTimestamps Mapping of indexers to their eligibility renewal timestamps /// @param eligibilityPeriod Period in seconds for which indexer eligibility status lasts - /// @param eligibilityValidationEnabled Flag to enable/disable eligibility validation /// @param oracleUpdateTimeout Timeout period in seconds after which isEligible returns true if no oracle updates /// @param lastOracleUpdateTime Timestamp of the last oracle update + /// @param trackedIndexers Enumerable set of all indexers ever renewed by the oracle + /// @param indexerRetentionPeriod Duration after which an un-renewed indexer can be removed from tracking + /// @param eligibilityValidationEnabled Flag to enable/disable eligibility validation /// @custom:storage-location erc7201:graphprotocol.storage.RewardsEligibilityOracle struct RewardsEligibilityOracleData { /// @dev Mapping of indexers to their eligibility renewal timestamps mapping(address => uint256) indexerEligibilityTimestamps; /// @dev Period in seconds for which indexer eligibility status lasts uint256 eligibilityPeriod; - /// @dev Flag to enable/disable eligibility validation - bool eligibilityValidationEnabled; /// @dev Timeout period in seconds after which isEligible returns true if no oracle updates uint256 oracleUpdateTimeout; /// @dev Timestamp of the last oracle update uint256 lastOracleUpdateTime; + /// @dev Enumerable set of all indexers renewed by the oracle + EnumerableSet.AddressSet trackedIndexers; + /// @dev Duration in seconds after which an un-renewed indexer can be permissionlessly removed + uint256 indexerRetentionPeriod; + /// @dev Flag to enable/disable eligibility validation + bool eligibilityValidationEnabled; } /** @@ -91,10 +106,10 @@ contract RewardsEligibilityOracle is * @notice Constructor for the RewardsEligibilityOracle contract * @dev This contract is upgradeable, but we use the constructor to pass the Graph Token address * to the base contract. - * @param graphToken Address of the Graph Token contract + * @param graphToken The Graph Token contract * @custom:oz-upgrades-unsafe-allow constructor */ - constructor(address graphToken) BaseUpgradeable(graphToken) {} + constructor(IGraphToken graphToken) BaseUpgradeable(graphToken) {} // -- Initialization -- @@ -114,6 +129,7 @@ contract RewardsEligibilityOracle is $.eligibilityPeriod = 14 days; $.oracleUpdateTimeout = 7 days; $.eligibilityValidationEnabled = false; // Start with eligibility validation disabled, to be enabled later when the oracle is ready + $.indexerRetentionPeriod = 365 days; } /** @@ -126,6 +142,7 @@ contract RewardsEligibilityOracle is return interfaceId == type(IProviderEligibility).interfaceId || interfaceId == type(IRewardsEligibilityAdministration).interfaceId || + interfaceId == type(IRewardsEligibilityMaintenance).interfaceId || interfaceId == type(IRewardsEligibilityReporting).interfaceId || interfaceId == type(IRewardsEligibilityStatus).interfaceId || super.supportsInterface(interfaceId); @@ -196,6 +213,23 @@ contract RewardsEligibilityOracle is return true; } + /// @inheritdoc IRewardsEligibilityAdministration + function setIndexerRetentionPeriod( + uint256 indexerRetentionPeriod + ) external override onlyRole(OPERATOR_ROLE) returns (bool) { + RewardsEligibilityOracleData storage $ = _getRewardsEligibilityOracleStorage(); + uint256 oldPeriod = $.indexerRetentionPeriod; + + if (indexerRetentionPeriod != oldPeriod) { + $.indexerRetentionPeriod = indexerRetentionPeriod; + emit IndexerRetentionPeriodSet(oldPeriod, indexerRetentionPeriod); + } + + return true; + } + + // -- Oracle Functions -- + /** * @notice Renew eligibility for provided indexers to receive rewards * @param indexers Array of indexer addresses. Zero addresses are ignored. @@ -220,6 +254,7 @@ contract RewardsEligibilityOracle is if (indexer != address(0) && $.indexerEligibilityTimestamps[indexer] < blockTimestamp) { $.indexerEligibilityTimestamps[indexer] = blockTimestamp; + if ($.trackedIndexers.add(indexer)) emit IndexerTrackingUpdated(indexer, true); emit IndexerEligibilityRenewed(indexer, msg.sender); ++updatedCount; } @@ -228,6 +263,24 @@ contract RewardsEligibilityOracle is return updatedCount; } + // -- Maintenance Functions -- + + /// @inheritdoc IRewardsEligibilityMaintenance + function removeExpiredIndexer(address indexer) external override returns (bool gone) { + RewardsEligibilityOracleData storage $ = _getRewardsEligibilityOracleStorage(); + + if (!$.trackedIndexers.contains(indexer)) return true; + + uint256 renewalTime = $.indexerEligibilityTimestamps[indexer]; + if (block.timestamp < renewalTime + $.indexerRetentionPeriod) return false; + + $.trackedIndexers.remove(indexer); + delete $.indexerEligibilityTimestamps[indexer]; + emit IndexerTrackingUpdated(indexer, false); + + return true; + } + // -- View Functions -- /** @@ -293,4 +346,24 @@ contract RewardsEligibilityOracle is function getEligibilityValidation() external view override returns (bool) { return _getRewardsEligibilityOracleStorage().eligibilityValidationEnabled; } + + /// @inheritdoc IRewardsEligibilityStatus + function getIndexerRetentionPeriod() external view override returns (uint256) { + return _getRewardsEligibilityOracleStorage().indexerRetentionPeriod; + } + + /// @inheritdoc IRewardsEligibilityStatus + function getIndexerCount() external view override returns (uint256) { + return _getRewardsEligibilityOracleStorage().trackedIndexers.length(); + } + + /// @inheritdoc IRewardsEligibilityStatus + function getIndexers() external view override returns (address[] memory) { + return _getRewardsEligibilityOracleStorage().trackedIndexers.getPage(0, type(uint256).max); + } + + /// @inheritdoc IRewardsEligibilityStatus + function getIndexers(uint256 offset, uint256 count) external view override returns (address[] memory) { + return _getRewardsEligibilityOracleStorage().trackedIndexers.getPage(offset, count); + } } diff --git a/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol b/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol index f9b037682..e4aeb5fab 100644 --- a/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol +++ b/packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { IssuanceAllocator } from "../../allocate/IssuanceAllocator.sol"; +import { IGraphToken } from "../../common/IGraphToken.sol"; /** * @title IssuanceAllocatorTestHarness @@ -13,10 +14,10 @@ import { IssuanceAllocator } from "../../allocate/IssuanceAllocator.sol"; contract IssuanceAllocatorTestHarness is IssuanceAllocator { /** * @notice Constructor for the test harness - * @param _graphToken Address of the Graph Token contract + * @param _graphToken The Graph Token contract * @custom:oz-upgrades-unsafe-allow constructor */ - constructor(address _graphToken) IssuanceAllocator(_graphToken) {} + constructor(IGraphToken _graphToken) IssuanceAllocator(_graphToken) {} /** * @notice Exposes _distributePendingProportionally for testing diff --git a/packages/issuance/test/unit/allocator/construction.t.sol b/packages/issuance/test/unit/allocator/construction.t.sol index 7df34bc42..552863397 100644 --- a/packages/issuance/test/unit/allocator/construction.t.sol +++ b/packages/issuance/test/unit/allocator/construction.t.sol @@ -1,10 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { BaseUpgradeable } from "../../../contracts/common/BaseUpgradeable.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { IssuanceAllocator } from "../../../contracts/allocate/IssuanceAllocator.sol"; import { IssuanceAllocatorSharedTest } from "./shared.t.sol"; @@ -14,11 +15,11 @@ contract IssuanceAllocatorConstructionTest is IssuanceAllocatorSharedTest { function test_Revert_ZeroGraphTokenAddress() public { vm.expectRevert(BaseUpgradeable.GraphTokenCannotBeZeroAddress.selector); - new IssuanceAllocator(address(0)); + new IssuanceAllocator(IGraphToken(address(0))); } function test_Revert_ZeroGovernorAddress() public { - IssuanceAllocator impl = new IssuanceAllocator(address(token)); + IssuanceAllocator impl = new IssuanceAllocator(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(IssuanceAllocator.initialize, (address(0))); vm.expectRevert(BaseUpgradeable.GovernorCannotBeZeroAddress.selector); new TransparentUpgradeableProxy(address(impl), address(this), initData); diff --git a/packages/issuance/test/unit/allocator/defensiveChecks.t.sol b/packages/issuance/test/unit/allocator/defensiveChecks.t.sol index 2ba79fc21..f8f3f0a41 100644 --- a/packages/issuance/test/unit/allocator/defensiveChecks.t.sol +++ b/packages/issuance/test/unit/allocator/defensiveChecks.t.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { IssuanceAllocator } from "../../../contracts/allocate/IssuanceAllocator.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { IssuanceAllocatorTestHarness } from "../../../contracts/test/allocate/IssuanceAllocatorTestHarness.sol"; import { MockGraphToken } from "../mocks/MockGraphToken.sol"; @@ -17,7 +18,7 @@ contract IssuanceAllocatorDefensiveChecksTest is Test { function setUp() public { MockGraphToken token = new MockGraphToken(); - IssuanceAllocatorTestHarness impl = new IssuanceAllocatorTestHarness(address(token)); + IssuanceAllocatorTestHarness impl = new IssuanceAllocatorTestHarness(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(IssuanceAllocator.initialize, (address(this))); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(this), initData); harness = IssuanceAllocatorTestHarness(address(proxy)); diff --git a/packages/issuance/test/unit/allocator/distribution.t.sol b/packages/issuance/test/unit/allocator/distribution.t.sol index 466f013d5..fb94737de 100644 --- a/packages/issuance/test/unit/allocator/distribution.t.sol +++ b/packages/issuance/test/unit/allocator/distribution.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; diff --git a/packages/issuance/test/unit/allocator/distributionAccounting.t.sol b/packages/issuance/test/unit/allocator/distributionAccounting.t.sol index 30638a0e4..ae40b10f7 100644 --- a/packages/issuance/test/unit/allocator/distributionAccounting.t.sol +++ b/packages/issuance/test/unit/allocator/distributionAccounting.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { Allocation } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocatorTypes.sol"; diff --git a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol index b7b8a4d42..463416bbd 100644 --- a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol +++ b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; diff --git a/packages/issuance/test/unit/allocator/shared.t.sol b/packages/issuance/test/unit/allocator/shared.t.sol index e1cc41100..5be20cc33 100644 --- a/packages/issuance/test/unit/allocator/shared.t.sol +++ b/packages/issuance/test/unit/allocator/shared.t.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { IssuanceAllocator } from "../../../contracts/allocate/IssuanceAllocator.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { MockGraphToken } from "../mocks/MockGraphToken.sol"; import { MockSimpleTarget } from "../../../contracts/test/allocate/MockSimpleTarget.sol"; import { MockNotificationTracker } from "../../../contracts/test/allocate/MockNotificationTracker.sol"; @@ -51,7 +52,7 @@ contract IssuanceAllocatorSharedTest is Test { token = new MockGraphToken(); // Deploy IssuanceAllocator behind proxy - IssuanceAllocator impl = new IssuanceAllocator(address(token)); + IssuanceAllocator impl = new IssuanceAllocator(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(IssuanceAllocator.initialize, (governor)); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(this), initData); allocator = IssuanceAllocator(address(proxy)); diff --git a/packages/issuance/test/unit/allocator/targetManagement.t.sol b/packages/issuance/test/unit/allocator/targetManagement.t.sol index bf1229c93..111621715 100644 --- a/packages/issuance/test/unit/allocator/targetManagement.t.sol +++ b/packages/issuance/test/unit/allocator/targetManagement.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { diff --git a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol index dab61dc44..112126a38 100644 --- a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol +++ b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; @@ -12,6 +12,7 @@ import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/al import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; import { BaseUpgradeable } from "../../../contracts/common/BaseUpgradeable.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { DirectAllocation } from "../../../contracts/allocate/DirectAllocation.sol"; import { MockGraphToken } from "../mocks/MockGraphToken.sol"; @@ -39,7 +40,7 @@ contract DirectAllocationTest is Test { token = new MockGraphToken(); - DirectAllocation impl = new DirectAllocation(address(token)); + DirectAllocation impl = new DirectAllocation(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(DirectAllocation.initialize, (governor)); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(this), initData); directAlloc = DirectAllocation(address(proxy)); @@ -52,11 +53,11 @@ contract DirectAllocationTest is Test { function test_Revert_ZeroGraphTokenAddress() public { vm.expectRevert(BaseUpgradeable.GraphTokenCannotBeZeroAddress.selector); - new DirectAllocation(address(0)); + new DirectAllocation(IGraphToken(address(0))); } function test_Revert_ZeroGovernorAddress() public { - DirectAllocation impl = new DirectAllocation(address(token)); + DirectAllocation impl = new DirectAllocation(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(DirectAllocation.initialize, (address(0))); vm.expectRevert(BaseUpgradeable.GovernorCannotBeZeroAddress.selector); new TransparentUpgradeableProxy(address(impl), address(this), initData); @@ -178,7 +179,7 @@ contract DirectAllocationTest is Test { function test_Revert_SendTokens_TransferReturnsFalse() public { // Deploy DirectAllocation with a mock token that returns false on transfer MockFalseTransferToken falseToken = new MockFalseTransferToken(); - DirectAllocation impl2 = new DirectAllocation(address(falseToken)); + DirectAllocation impl2 = new DirectAllocation(IGraphToken(address(falseToken))); bytes memory initData2 = abi.encodeCall(DirectAllocation.initialize, (governor)); TransparentUpgradeableProxy proxy2 = new TransparentUpgradeableProxy(address(impl2), address(this), initData2); DirectAllocation da2 = DirectAllocation(address(proxy2)); diff --git a/packages/issuance/test/unit/eligibility/accessControl.t.sol b/packages/issuance/test/unit/eligibility/accessControl.t.sol index f1e9d15db..3f0a3dd56 100644 --- a/packages/issuance/test/unit/eligibility/accessControl.t.sol +++ b/packages/issuance/test/unit/eligibility/accessControl.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { RewardsEligibilityOracleSharedTest } from "./shared.t.sol"; diff --git a/packages/issuance/test/unit/eligibility/construction.t.sol b/packages/issuance/test/unit/eligibility/construction.t.sol index f623baee2..d63964c5b 100644 --- a/packages/issuance/test/unit/eligibility/construction.t.sol +++ b/packages/issuance/test/unit/eligibility/construction.t.sol @@ -1,10 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { BaseUpgradeable } from "../../../contracts/common/BaseUpgradeable.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { RewardsEligibilityOracle } from "../../../contracts/eligibility/RewardsEligibilityOracle.sol"; import { RewardsEligibilityOracleSharedTest } from "./shared.t.sol"; @@ -16,11 +17,11 @@ contract RewardsEligibilityOracleConstructionTest is RewardsEligibilityOracleSha function test_Revert_ZeroGraphTokenAddress() public { vm.expectRevert(BaseUpgradeable.GraphTokenCannotBeZeroAddress.selector); - new RewardsEligibilityOracle(address(0)); + new RewardsEligibilityOracle(IGraphToken(address(0))); } function test_Revert_ZeroGovernorAddress() public { - RewardsEligibilityOracle impl = new RewardsEligibilityOracle(address(token)); + RewardsEligibilityOracle impl = new RewardsEligibilityOracle(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(RewardsEligibilityOracle.initialize, (address(0))); vm.expectRevert(BaseUpgradeable.GovernorCannotBeZeroAddress.selector); diff --git a/packages/issuance/test/unit/eligibility/eligibility.t.sol b/packages/issuance/test/unit/eligibility/eligibility.t.sol index 5ceb13fbe..aaa74e0c6 100644 --- a/packages/issuance/test/unit/eligibility/eligibility.t.sol +++ b/packages/issuance/test/unit/eligibility/eligibility.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { RewardsEligibilityOracleSharedTest } from "./shared.t.sol"; diff --git a/packages/issuance/test/unit/eligibility/helper.t.sol b/packages/issuance/test/unit/eligibility/helper.t.sol new file mode 100644 index 000000000..51d40980f --- /dev/null +++ b/packages/issuance/test/unit/eligibility/helper.t.sol @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { RewardsEligibilityHelper } from "../../../contracts/eligibility/RewardsEligibilityHelper.sol"; + +import { RewardsEligibilityOracleSharedTest } from "./shared.t.sol"; + +/// @notice Tests for the stateless RewardsEligibilityHelper contract. +contract RewardsEligibilityHelperTest is RewardsEligibilityOracleSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + RewardsEligibilityHelper internal helper; + + function setUp() public override { + super.setUp(); + _setupOracleRole(); + helper = new RewardsEligibilityHelper(address(oracle)); + vm.label(address(helper), "RewardsEligibilityHelper"); + } + + // ==================== Constructor ==================== + + function test_Constructor_SetsOracle() public view { + assertEq(helper.ORACLE(), address(oracle)); + } + + function test_Constructor_Revert_ZeroAddress() public { + vm.expectRevert(RewardsEligibilityHelper.ZeroAddress.selector); + new RewardsEligibilityHelper(address(0)); + } + + // ==================== Batch by Address List ==================== + + function test_RemoveExpiredIndexers_List_AllExpired() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + address[] memory indexers = new address[](2); + indexers[0] = indexer1; + indexers[1] = indexer2; + + uint256 gone = helper.removeExpiredIndexers(indexers); + assertEq(gone, 2); + assertEq(oracle.getIndexerCount(), 0); + } + + function test_RemoveExpiredIndexers_List_MixedExpiry() public { + _renewEligibility(indexer1); + + // Advance time, then renew indexer2 (so only indexer1 is expired) + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + _renewEligibility(indexer2); + + address[] memory indexers = new address[](2); + indexers[0] = indexer1; + indexers[1] = indexer2; + + uint256 gone = helper.removeExpiredIndexers(indexers); + // indexer1 removed (gone), indexer2 still tracked (not expired) + assertEq(gone, 1); + assertEq(oracle.getIndexerCount(), 1); + } + + function test_RemoveExpiredIndexers_List_IncludesUntracked() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + address untracked = makeAddr("untracked"); + address[] memory indexers = new address[](2); + indexers[0] = indexer1; + indexers[1] = untracked; + + // Both are now absent — indexer1 removed, untracked was never there + uint256 gone = helper.removeExpiredIndexers(indexers); + assertEq(gone, 2); + } + + function test_RemoveExpiredIndexers_List_Empty() public { + address[] memory indexers = new address[](0); + uint256 gone = helper.removeExpiredIndexers(indexers); + assertEq(gone, 0); + } + + // ==================== Batch All ==================== + + function test_RemoveExpiredIndexers_All_AllExpired() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + uint256 gone = helper.removeExpiredIndexers(); + assertEq(gone, 2); + assertEq(oracle.getIndexerCount(), 0); + } + + function test_RemoveExpiredIndexers_All_MixedExpiry() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + _renewEligibility(indexer2); + + uint256 gone = helper.removeExpiredIndexers(); + assertEq(gone, 1); + assertEq(oracle.getIndexerCount(), 1); + } + + function test_RemoveExpiredIndexers_All_NoneTracked() public { + uint256 gone = helper.removeExpiredIndexers(); + assertEq(gone, 0); + } + + // ==================== Batch by Paginated Scan ==================== + + function test_RemoveExpiredIndexers_Scan_AllExpired() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + uint256 gone = helper.removeExpiredIndexers(0, 10); + assertEq(gone, 2); + assertEq(oracle.getIndexerCount(), 0); + } + + function test_RemoveExpiredIndexers_Scan_MixedExpiry() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + _renewEligibility(indexer2); + + // Both are tracked, but only indexer1 is expired + uint256 gone = helper.removeExpiredIndexers(0, 10); + assertEq(gone, 1); + assertEq(oracle.getIndexerCount(), 1); + } + + function test_RemoveExpiredIndexers_Scan_OffsetPastEnd() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + uint256 gone = helper.removeExpiredIndexers(100, 10); + assertEq(gone, 0); + // indexer1 still tracked — scan didn't reach it + assertEq(oracle.getIndexerCount(), 1); + } + + function test_RemoveExpiredIndexers_Scan_PartialPage() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + // Only process first indexer + uint256 gone = helper.removeExpiredIndexers(0, 1); + assertEq(gone, 1); + assertEq(oracle.getIndexerCount(), 1); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/eligibility/indexerManagement.t.sol b/packages/issuance/test/unit/eligibility/indexerManagement.t.sol index 1411d97c9..bffb14e60 100644 --- a/packages/issuance/test/unit/eligibility/indexerManagement.t.sol +++ b/packages/issuance/test/unit/eligibility/indexerManagement.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IRewardsEligibilityEvents } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol"; diff --git a/packages/issuance/test/unit/eligibility/indexerTracking.t.sol b/packages/issuance/test/unit/eligibility/indexerTracking.t.sol new file mode 100644 index 000000000..2599310ad --- /dev/null +++ b/packages/issuance/test/unit/eligibility/indexerTracking.t.sol @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IRewardsEligibilityEvents } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityEvents.sol"; + +import { RewardsEligibilityOracleSharedTest } from "./shared.t.sol"; + +/// @notice Tests for enumerable indexer tracking and staleness-based cleanup. +contract RewardsEligibilityOracleIndexerTrackingTest is RewardsEligibilityOracleSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function setUp() public override { + super.setUp(); + _setupOracleRole(); + } + + // ==================== Tracking on Renewal ==================== + + function test_Renewal_AddsToTrackedSet() public { + assertEq(oracle.getIndexerCount(), 0); + + _renewEligibility(indexer1); + + assertEq(oracle.getIndexerCount(), 1); + address[] memory indexers = oracle.getIndexers(); + assertEq(indexers.length, 1); + assertEq(indexers[0], indexer1); + } + + function test_Renewal_SecondIndexerIncreasesCount() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + assertEq(oracle.getIndexerCount(), 2); + address[] memory indexers = oracle.getIndexers(); + assertEq(indexers.length, 2); + } + + function test_Renewal_SameIndexerNoDuplicate() public { + _renewEligibility(indexer1); + assertEq(oracle.getIndexerCount(), 1); + + // Advance time so renewal actually updates timestamp + vm.warp(block.timestamp + 1); + _renewEligibility(indexer1); + + assertEq(oracle.getIndexerCount(), 1); + } + + function test_Renewal_EmitsTrackingEvent_OnlyFirstTime() public { + // First renewal — expect tracking event + address[] memory indexers = new address[](1); + indexers[0] = indexer1; + + vm.expectEmit(address(oracle)); + emit IRewardsEligibilityEvents.IndexerTrackingUpdated(indexer1, true); + + vm.prank(oracleAccount); + oracle.renewIndexerEligibility(indexers, ""); + + // Second renewal (new block) — no tracking event, only renewal event + vm.warp(block.timestamp + 1); + + vm.recordLogs(); + vm.prank(oracleAccount); + oracle.renewIndexerEligibility(indexers, ""); + + // Check that no IndexerTrackingUpdated was emitted + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 trackingSig = keccak256("IndexerTrackingUpdated(address,bool)"); + for (uint256 i = 0; i < logs.length; ++i) { + assertTrue(logs[i].topics[0] != trackingSig, "unexpected IndexerTrackingUpdated event"); + } + } + + // ==================== Pagination ==================== + + function test_GetIndexers_Paginated() public { + _renewEligibility(indexer1); + _renewEligibility(indexer2); + + address[] memory all = oracle.getIndexers(); + assertEq(all.length, 2); + + address[] memory first = oracle.getIndexers(0, 1); + assertEq(first.length, 1); + assertEq(first[0], all[0]); + + address[] memory second = oracle.getIndexers(1, 1); + assertEq(second.length, 1); + assertEq(second[0], all[1]); + } + + function test_GetIndexers_OffsetPastEnd_ReturnsEmpty() public { + _renewEligibility(indexer1); + + address[] memory result = oracle.getIndexers(5, 10); + assertEq(result.length, 0); + } + + function test_GetIndexers_CountClamped() public { + _renewEligibility(indexer1); + + address[] memory result = oracle.getIndexers(0, 100); + assertEq(result.length, 1); + assertEq(result[0], indexer1); + } + + // ==================== Indexer Retention Period Configuration ==================== + + function test_DefaultIndexerRetentionPeriod() public view { + assertEq(oracle.getIndexerRetentionPeriod(), DEFAULT_INDEXER_RETENTION_PERIOD); + } + + function test_SetIndexerRetentionPeriod() public { + _setupOperatorRole(); + + vm.expectEmit(address(oracle)); + emit IRewardsEligibilityEvents.IndexerRetentionPeriodSet(DEFAULT_INDEXER_RETENTION_PERIOD, 90 days); + + vm.prank(operator); + bool result = oracle.setIndexerRetentionPeriod(90 days); + assertTrue(result); + + assertEq(oracle.getIndexerRetentionPeriod(), 90 days); + } + + function test_SetIndexerRetentionPeriod_SameValue_NoEvent() public { + _setupOperatorRole(); + + vm.recordLogs(); + vm.prank(operator); + oracle.setIndexerRetentionPeriod(DEFAULT_INDEXER_RETENTION_PERIOD); + + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 sig = keccak256("IndexerRetentionPeriodSet(uint256,uint256)"); + for (uint256 i = 0; i < logs.length; ++i) { + assertTrue(logs[i].topics[0] != sig, "unexpected IndexerRetentionPeriodSet event"); + } + } + + function test_Revert_SetIndexerRetentionPeriod_Unauthorized() public { + vm.expectRevert(); + vm.prank(unauthorized); + oracle.setIndexerRetentionPeriod(90 days); + } + + // ==================== Expired Indexer Removal ==================== + + function test_RemoveExpiredIndexer_ReturnsFalse_WhenNotExpired() public { + _renewEligibility(indexer1); + + bool gone = oracle.removeExpiredIndexer(indexer1); + assertFalse(gone); + assertEq(oracle.getIndexerCount(), 1); + } + + function test_RemoveExpiredIndexer_ReturnsTrue_WhenExpired() public { + _renewEligibility(indexer1); + + // Warp past retention period + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + bool gone = oracle.removeExpiredIndexer(indexer1); + assertTrue(gone); + assertEq(oracle.getIndexerCount(), 0); + } + + function test_RemoveExpiredIndexer_ReturnsTrue_WhenNotTracked() public { + bool gone = oracle.removeExpiredIndexer(indexer1); + assertTrue(gone); + } + + function test_RemoveExpiredIndexer_DeletesTimestamp() public { + _renewEligibility(indexer1); + assertGt(oracle.getEligibilityRenewalTime(indexer1), 0); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + oracle.removeExpiredIndexer(indexer1); + + assertEq(oracle.getEligibilityRenewalTime(indexer1), 0); + } + + function test_RemoveExpiredIndexer_EmitsEvent() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + vm.expectEmit(address(oracle)); + emit IRewardsEligibilityEvents.IndexerTrackingUpdated(indexer1, false); + + oracle.removeExpiredIndexer(indexer1); + } + + function test_RemoveExpiredIndexer_ReAddAfterRemoval() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + oracle.removeExpiredIndexer(indexer1); + assertEq(oracle.getIndexerCount(), 0); + + // Oracle renews the removed indexer — should re-add + _renewEligibility(indexer1); + assertEq(oracle.getIndexerCount(), 1); + assertGt(oracle.getEligibilityRenewalTime(indexer1), 0); + } + + function test_RemoveExpiredIndexer_Permissionless() public { + _renewEligibility(indexer1); + + vm.warp(block.timestamp + DEFAULT_INDEXER_RETENTION_PERIOD); + + address anyone = makeAddr("anyone"); + vm.prank(anyone); + bool gone = oracle.removeExpiredIndexer(indexer1); + assertTrue(gone); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol b/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol index 6a1ff7d75..d6e14ef81 100644 --- a/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol +++ b/packages/issuance/test/unit/eligibility/interfaceCompliance.t.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; import { IRewardsEligibilityAdministration } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityAdministration.sol"; +import { IRewardsEligibilityMaintenance } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityMaintenance.sol"; import { IRewardsEligibilityReporting } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityReporting.sol"; import { IRewardsEligibilityStatus } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityStatus.sol"; import { IPausableControl } from "@graphprotocol/interfaces/contracts/issuance/common/IPausableControl.sol"; @@ -30,6 +31,10 @@ contract RewardsEligibilityOracleInterfaceTest is RewardsEligibilityOracleShared assertTrue(oracle.supportsInterface(type(IRewardsEligibilityAdministration).interfaceId)); } + function test_SupportsIRewardsEligibilityMaintenance() public view { + assertTrue(oracle.supportsInterface(type(IRewardsEligibilityMaintenance).interfaceId)); + } + function test_SupportsIRewardsEligibilityReporting() public view { assertTrue(oracle.supportsInterface(type(IRewardsEligibilityReporting).interfaceId)); } @@ -58,7 +63,11 @@ contract RewardsEligibilityOracleInterfaceTest is RewardsEligibilityOracleShared } function test_InterfaceId_IRewardsEligibilityAdministration() public pure { - assertEq(type(IRewardsEligibilityAdministration).interfaceId, bytes4(0x9a69f6aa)); + assertEq(type(IRewardsEligibilityAdministration).interfaceId, bytes4(0x428f54e5)); + } + + function test_InterfaceId_IRewardsEligibilityMaintenance() public pure { + assertEq(type(IRewardsEligibilityMaintenance).interfaceId, bytes4(0x6f001113)); } function test_InterfaceId_IRewardsEligibilityReporting() public pure { @@ -66,7 +75,7 @@ contract RewardsEligibilityOracleInterfaceTest is RewardsEligibilityOracleShared } function test_InterfaceId_IRewardsEligibilityStatus() public pure { - assertEq(type(IRewardsEligibilityStatus).interfaceId, bytes4(0x53740f19)); + assertEq(type(IRewardsEligibilityStatus).interfaceId, bytes4(0x054cdbc2)); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/eligibility/operatorFunctions.t.sol b/packages/issuance/test/unit/eligibility/operatorFunctions.t.sol index 07a3eedad..3d7fa4a1d 100644 --- a/packages/issuance/test/unit/eligibility/operatorFunctions.t.sol +++ b/packages/issuance/test/unit/eligibility/operatorFunctions.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; diff --git a/packages/issuance/test/unit/eligibility/shared.t.sol b/packages/issuance/test/unit/eligibility/shared.t.sol index 5c564d857..40d790f77 100644 --- a/packages/issuance/test/unit/eligibility/shared.t.sol +++ b/packages/issuance/test/unit/eligibility/shared.t.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.33; +pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { RewardsEligibilityOracle } from "../../../contracts/eligibility/RewardsEligibilityOracle.sol"; +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { MockGraphToken } from "../mocks/MockGraphToken.sol"; /// @notice Shared test setup for RewardsEligibilityOracle tests. @@ -30,6 +31,7 @@ contract RewardsEligibilityOracleSharedTest is Test { uint256 internal constant DEFAULT_ELIGIBILITY_PERIOD = 14 days; uint256 internal constant DEFAULT_ORACLE_TIMEOUT = 7 days; + uint256 internal constant DEFAULT_INDEXER_RETENTION_PERIOD = 365 days; function setUp() public virtual { // Use a realistic timestamp so eligibility period math works correctly @@ -46,7 +48,7 @@ contract RewardsEligibilityOracleSharedTest is Test { token = new MockGraphToken(); // Deploy RewardsEligibilityOracle behind proxy - RewardsEligibilityOracle impl = new RewardsEligibilityOracle(address(token)); + RewardsEligibilityOracle impl = new RewardsEligibilityOracle(IGraphToken(address(token))); bytes memory initData = abi.encodeCall(RewardsEligibilityOracle.initialize, (governor)); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(this), initData); oracle = RewardsEligibilityOracle(address(proxy)); diff --git a/packages/issuance/test/unit/mocks/MockGraphToken.sol b/packages/issuance/test/unit/mocks/MockGraphToken.sol index f4478cd7a..dd07fab6e 100644 --- a/packages/issuance/test/unit/mocks/MockGraphToken.sol +++ b/packages/issuance/test/unit/mocks/MockGraphToken.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.33; +pragma solidity ^0.8.27; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; From a23ad681eaa1188b5f0b807629ea22eccba7a3f9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:29:28 +0000 Subject: [PATCH 048/157] feat: RecurringAgreementManager with lifecycle, escrow funding, and agreement updates Add RecurringAgreementManager with configurable escrow funding modes, enumerable agreement tracking, lifecycle management, and escrow reconciliation. Extends IAgreementOwner with beforeCollection/ afterCollection callbacks. Includes revokeAgreementUpdate and pending update escrow cleanup on cancel. --- .../BareAgreementOwner.t.sol | 24 + .../recurring-collector/afterCollection.t.sol | 148 ++ .../recurring-collector/eligibility.t.sol | 190 ++ .../recurring-collector/getMaxNextClaim.t.sol | 308 ++++ .../recurring-collector/mixedPath.t.sol | 179 ++ .../contracts/horizon/IAgreementOwner.sol | 37 +- .../contracts/horizon/IRecurringCollector.sol | 7 + .../agreement/IRecurringAgreementHelper.sol | 137 ++ .../IRecurringAgreementManagement.sol | 248 +++ .../agreement/IRecurringAgreements.sol | 216 +++ .../agreement/IRecurringEscrowManagement.sol | 87 + packages/issuance/README.md | 1 + .../agreement/RecurringAgreementHelper.sol | 170 ++ .../agreement/RecurringAgreementManager.md | 168 ++ .../agreement/RecurringAgreementManager.sol | 956 ++++++++++ packages/issuance/foundry.toml | 3 +- .../agreement-manager/afterCollection.t.sol | 174 ++ .../unit/agreement-manager/approver.t.sol | 174 ++ .../agreement-manager/cancelAgreement.t.sol | 202 +++ .../cancelWithPendingUpdate.t.sol | 136 ++ .../agreement-manager/cascadeCleanup.t.sol | 433 +++++ .../unit/agreement-manager/edgeCases.t.sol | 1261 ++++++++++++++ .../unit/agreement-manager/eligibility.t.sol | 120 ++ .../unit/agreement-manager/fundingModes.t.sol | 1544 +++++++++++++++++ .../test/unit/agreement-manager/fuzz.t.sol | 305 ++++ .../test/unit/agreement-manager/helper.t.sol | 362 ++++ .../unit/agreement-manager/helperAudit.t.sol | 239 +++ .../agreement-manager/helperCleanup.t.sol | 368 ++++ .../unit/agreement-manager/lifecycle.t.sol | 476 +++++ .../mocks/MockEligibilityOracle.sol | 23 + .../mocks/MockGraphToken.sol | 15 + .../mocks/MockPaymentsEscrow.sol | 127 ++ .../mocks/MockRecurringCollector.sol | 97 ++ .../mocks/MockSubgraphService.sol | 27 + .../agreement-manager/multiCollector.t.sol | 220 +++ .../unit/agreement-manager/multiIndexer.t.sol | 455 +++++ .../unit/agreement-manager/offerUpdate.t.sol | 455 +++++ .../unit/agreement-manager/reconcile.t.sol | 494 ++++++ .../unit/agreement-manager/register.t.sol | 254 +++ .../test/unit/agreement-manager/remove.t.sol | 4 + .../revokeAgreementUpdate.t.sol | 260 +++ .../unit/agreement-manager/revokeOffer.t.sol | 174 ++ .../test/unit/agreement-manager/shared.t.sol | 283 +++ .../unit/agreement-manager/updateEscrow.t.sol | 742 ++++++++ 44 files changed, 12294 insertions(+), 9 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol create mode 100644 packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol create mode 100644 packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol create mode 100644 packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol create mode 100644 packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol create mode 100644 packages/issuance/contracts/agreement/RecurringAgreementHelper.sol create mode 100644 packages/issuance/contracts/agreement/RecurringAgreementManager.md create mode 100644 packages/issuance/contracts/agreement/RecurringAgreementManager.sol create mode 100644 packages/issuance/test/unit/agreement-manager/afterCollection.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/approver.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/edgeCases.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/eligibility.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/fundingModes.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/fuzz.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/helper.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/helperAudit.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/lifecycle.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockEligibilityOracle.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockGraphToken.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockSubgraphService.sol create mode 100644 packages/issuance/test/unit/agreement-manager/multiCollector.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/reconcile.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/register.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/remove.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/shared.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol diff --git a/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol b/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol new file mode 100644 index 000000000..2f6324957 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; + +/// @notice Minimal contract payer that implements IAgreementOwner but NOT IERC165. +/// Calling supportsInterface on this contract will revert (no such function), +/// exercising the catch {} fallthrough in RecurringCollector's eligibility gate. +contract BareAgreementOwner is IAgreementOwner { + mapping(bytes32 => bool) public authorizedHashes; + + function authorize(bytes32 agreementHash) external { + authorizedHashes[agreementHash] = true; + } + + function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { + if (!authorizedHashes[agreementHash]) return bytes4(0); + return IAgreementOwner.approveAgreement.selector; + } + + function beforeCollection(bytes16, uint256) external override {} + + function afterCollection(bytes16, uint256) external override {} +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol new file mode 100644 index 000000000..c84958daf --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Tests for IAgreementOwner.beforeCollection and .afterCollection in RecurringCollector._collect() +contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { + function _newApprover() internal returns (MockAgreementOwner) { + return new MockAgreementOwner(); + } + + function _acceptUnsignedAgreement( + MockAgreementOwner approver + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + agreementId = _recurringCollector.accept(rca, ""); + } + + /* solhint-disable graph/func-name-mixedcase */ + + function test_BeforeCollection_CallbackInvoked() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + + // beforeCollection should have been called with the tokens about to be collected + assertEq(approver.lastBeforeCollectionAgreementId(), agreementId); + assertEq(approver.lastBeforeCollectionTokens(), tokens); + } + + function test_BeforeCollection_CollectionSucceedsWhenCallbackReverts() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + approver.setShouldRevertOnBeforeCollection(true); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + // Collection should still succeed despite beforeCollection reverting + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + + // beforeCollection state not updated (it reverted), but afterCollection still runs + assertEq(approver.lastBeforeCollectionAgreementId(), bytes16(0)); + assertEq(approver.lastCollectedAgreementId(), agreementId); + } + + function test_AfterCollection_CallbackInvoked() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Skip past minSecondsPerCollection and collect + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + + // Verify callback was invoked with correct parameters + assertEq(approver.lastCollectedAgreementId(), agreementId); + assertEq(approver.lastCollectedTokens(), tokens); + } + + function test_AfterCollection_CollectionSucceedsWhenCallbackReverts() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Configure callback to revert + approver.setShouldRevertOnCollected(true); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + // Collection should still succeed despite callback reverting + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + + // Callback state should not have been updated (it reverted) + assertEq(approver.lastCollectedAgreementId(), bytes16(0)); + assertEq(approver.lastCollectedTokens(), 0); + } + + function test_AfterCollection_NotCalledForEOAPayer(FuzzyTestCollect calldata fuzzy) public { + // Use standard ECDSA-signed path (EOA payer, no contract) + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, , , ) = _sensibleAuthorizeAndAccept( + fuzzy.fuzzyTestAccept + ); + + (bytes memory data, uint256 collectionSeconds, uint256 tokens) = _generateValidCollection( + acceptedRca, + fuzzy.collectParams, + fuzzy.collectParams.tokens, // reuse as skip seed + fuzzy.collectParams.tokens + ); + + skip(collectionSeconds); + // Should succeed without any callback issues (EOA has no code) + vm.prank(acceptedRca.dataService); + uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + assertEq(collected, tokens); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol b/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol new file mode 100644 index 000000000..310e1a88f --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; +import { BareAgreementOwner } from "./BareAgreementOwner.t.sol"; + +/// @notice Tests for the IProviderEligibility gate in RecurringCollector._collect() +contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { + function _newApprover() internal returns (MockAgreementOwner) { + return new MockAgreementOwner(); + } + + function _acceptUnsignedAgreement( + MockAgreementOwner approver + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + agreementId = _recurringCollector.accept(rca, ""); + } + + /* solhint-disable graph/func-name-mixedcase */ + + function test_Collect_OK_WhenEligible() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Enable eligibility check and mark provider as eligible + approver.setEligibilityEnabled(true); + approver.setProviderEligible(rca.serviceProvider, true); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + } + + function test_Collect_Revert_WhenNotEligible() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Enable eligibility check but provider is NOT eligible + approver.setEligibilityEnabled(true); + // defaultEligible is false, and provider not explicitly set + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorCollectionNotEligible.selector, + agreementId, + rca.serviceProvider + ) + ); + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Collect_OK_WhenPayerDoesNotSupportInterface() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // eligibilityEnabled is false by default — supportsInterface returns false for IProviderEligibility + // Collection should proceed normally (backward compatible) + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + } + + function test_Collect_OK_WhenEOAPayer(FuzzyTestCollect calldata fuzzy) public { + // Use standard ECDSA-signed path (EOA payer) + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); + + (bytes memory data, uint256 collectionSeconds, uint256 tokens) = _generateValidCollection( + acceptedRca, + fuzzy.collectParams, + fuzzy.collectParams.tokens, + fuzzy.collectParams.tokens + ); + + skip(collectionSeconds); + // EOA payer has no code — eligibility check is skipped entirely + vm.prank(acceptedRca.dataService); + uint256 collected = _recurringCollector.collect(_paymentType(fuzzy.unboundedPaymentType), data); + assertEq(collected, tokens); + } + + function test_Collect_OK_WhenPayerHasNoERC165() public { + // BareAgreementOwner implements IAgreementOwner but NOT IERC165. + // The supportsInterface call will revert, hitting the catch {} branch. + BareAgreementOwner bare = new BareAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(bare), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + bare.authorize(agreementHash); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + // Collection succeeds — the catch {} swallows the revert from supportsInterface + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + } + + function test_Collect_OK_ZeroTokensSkipsEligibilityCheck() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Enable eligibility check, provider is NOT eligible + approver.setEligibilityEnabled(true); + // defaultEligible = false + + // Zero-token collection should NOT trigger the eligibility gate + // (the guard is inside `if (0 < tokensToCollect && ...)`) + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), 0, 0)); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol new file mode 100644 index 000000000..801beef6d --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol @@ -0,0 +1,308 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- Test 1: NotAccepted agreement returns 0 -- + + function test_GetMaxNextClaim_NotAccepted() public view { + bytes16 fakeId = bytes16(keccak256("nonexistent")); + assertEq(_recurringCollector.getMaxNextClaim(fakeId), 0, "NotAccepted agreement should return 0"); + } + + // -- Test 2: CanceledByServiceProvider agreement returns 0 -- + + function test_GetMaxNextClaim_CanceledByServiceProvider(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + assertEq(_recurringCollector.getMaxNextClaim(agreementId), 0, "CanceledByServiceProvider should return 0"); + } + + // -- Test 3: Active agreement, never collected -- + // Returns maxOngoingTokensPerSecond * min(windowSeconds, maxSecondsPerCollection) + maxInitialTokens + + function test_GetMaxNextClaim_Accepted_NeverCollected(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // Never collected: window = endsAt - acceptedAt, capped at maxSecondsPerCollection + // Also includes maxInitialTokens + uint256 windowSeconds = rca.endsAt - block.timestamp; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds + rca.maxInitialTokens; + assertEq(maxClaim, expected, "Never-collected active agreement mismatch"); + } + + // -- Test 4: Active agreement, already collected once -- + // Returns maxOngoingTokensPerSecond * min(windowSeconds, maxSecondsPerCollection) (no initial bonus) + + function test_GetMaxNextClaim_Accepted_AfterCollection(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Perform a first collection so lastCollectionAt is set + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, keccak256("col"), 1, 0)); + vm.prank(rca.dataService); + _recurringCollector.collect(_paymentType(0), data); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // After collection: no initial tokens, window from lastCollectionAt to endsAt + uint256 windowSeconds = rca.endsAt - block.timestamp; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds; + assertEq(maxClaim, expected, "Post-collection active agreement should exclude initial tokens"); + } + + // -- Test 5: CanceledByPayer agreement -- + + // 5a: Canceled in the same block as accepted (window = 0) + function test_GetMaxNextClaim_CanceledByPayer_SameBlock(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // canceledAt == acceptedAt (same block), so window = 0, maxClaim = 0 + assertEq(maxClaim, 0, "CanceledByPayer in same block should return 0"); + } + + // 5b: Canceled after time has elapsed (canceledAt < endsAt) + function test_GetMaxNextClaim_CanceledByPayer_WithWindow(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Advance time, then cancel (still before endsAt due to sensible bounds) + skip(rca.minSecondsPerCollection + 100); + + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // collectionEnd = min(canceledAt, endsAt) = canceledAt (since canceledAt < endsAt) + // collectionStart = acceptedAt (never collected) + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + uint256 windowSeconds = agreement.canceledAt - agreement.acceptedAt; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds + rca.maxInitialTokens; + assertEq(maxClaim, expected, "CanceledByPayer with elapsed time mismatch"); + } + + // 5c: CanceledByPayer after a collection (no initial tokens) + function test_GetMaxNextClaim_CanceledByPayer_AfterCollection(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Perform a first collection + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, keccak256("col"), 1, 0)); + vm.prank(rca.dataService); + _recurringCollector.collect(_paymentType(0), data); + + // Advance more time, then cancel + skip(rca.minSecondsPerCollection + 100); + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // lastCollectionAt is set, so no initial bonus + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + uint256 windowSeconds = agreement.canceledAt - agreement.lastCollectionAt; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds; + assertEq(maxClaim, expected, "CanceledByPayer post-collection should exclude initial tokens"); + } + + // -- Test 6: Agreement past endsAt -- + // For an active (Accepted) agreement that has gone past endsAt, the window + // is capped at endsAt, so returns maxOngoingTokensPerSecond * min(remaining, maxSecondsPerCollection) + + function test_GetMaxNextClaim_Accepted_PastEndsAt(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Perform a first collection so we have a lastCollectionAt + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, keccak256("col"), 1, 0)); + vm.prank(rca.dataService); + _recurringCollector.collect(_paymentType(0), data); + + uint256 lastCollectionAt = block.timestamp; + + // Warp past endsAt + vm.warp(rca.endsAt + 1000); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // collectionEnd = endsAt (active, capped), collectionStart = lastCollectionAt + // remaining = endsAt - lastCollectionAt, capped by maxSecondsPerCollection + uint256 remaining = rca.endsAt - lastCollectionAt; + uint256 maxSeconds = remaining < rca.maxSecondsPerCollection ? remaining : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds; + assertEq(maxClaim, expected, "Past-endsAt active agreement should cap at endsAt"); + } + + // Also test past endsAt when never collected (includes initial tokens) + function test_GetMaxNextClaim_Accepted_PastEndsAt_NeverCollected(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + uint256 acceptedAt = block.timestamp; + + // Warp past endsAt without ever collecting + vm.warp(rca.endsAt + 1000); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // collectionEnd = endsAt, collectionStart = acceptedAt + // window = endsAt - acceptedAt, capped by maxSecondsPerCollection + // Never collected so includes maxInitialTokens + uint256 windowSeconds = rca.endsAt - acceptedAt; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds + rca.maxInitialTokens; + assertEq(maxClaim, expected, "Past-endsAt never-collected should include initial tokens"); + } + + // -- Test 7: maxSecondsPerCollection caps the window -- + + function test_GetMaxNextClaim_MaxSecondsPerCollectionCaps() public { + // Use deterministic values to precisely verify the cap behavior + uint256 signerKey = 0xBEEF; + address payer = address(0x1111); + address dataService = address(0x2222); + address serviceProvider = address(0x3333); + + uint32 minSecondsPerCollection = 1000; + uint32 maxSecondsPerCollection = 3600; // 1 hour cap + uint256 maxOngoingTokensPerSecond = 100; + uint256 maxInitialTokens = 5000; + + // Accept the agreement + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1000), + endsAt: uint64(block.timestamp + 100_000), // much larger than maxSecondsPerCollection + payer: payer, + dataService: dataService, + serviceProvider: serviceProvider, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: minSecondsPerCollection, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: 1, + metadata: "" + }); + + // Authorize signer and accept + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + _setupValidProvision(serviceProvider, dataService); + vm.prank(dataService); + bytes16 agreementId = _recurringCollector.accept(rca, signature); + + // Window = endsAt - acceptedAt = 100_000 seconds, which is > maxSecondsPerCollection (3600) + // So the window should be capped at maxSecondsPerCollection + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // maxSeconds = min(100_000, 3600) = 3600 + uint256 expectedCapped = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens; + assertEq(maxClaim, expectedCapped, "Window should be capped at maxSecondsPerCollection"); + + // Verify the cap actually applies by checking it is less than the uncapped value + uint256 uncappedWindow = rca.endsAt - block.timestamp; + uint256 expectedUncapped = maxOngoingTokensPerSecond * uncappedWindow + maxInitialTokens; + assertLt(expectedCapped, expectedUncapped, "Capped value should be less than uncapped value"); + } + + function test_GetMaxNextClaim_WindowSmallerThanMaxSecondsPerCollection() public { + // Test the case where the window is smaller than maxSecondsPerCollection (no cap) + uint256 signerKey = 0xBEEF; + address payer = address(0x1111); + address dataService = address(0x2222); + address serviceProvider = address(0x3333); + + uint32 minSecondsPerCollection = 1000; + uint32 maxSecondsPerCollection = 100_000; // very large cap + uint256 maxOngoingTokensPerSecond = 100; + uint256 maxInitialTokens = 5000; + + // endsAt is set so window (endsAt - acceptedAt) < maxSecondsPerCollection + uint64 endsAt = uint64(block.timestamp + 10_000); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1000), + endsAt: endsAt, + payer: payer, + dataService: dataService, + serviceProvider: serviceProvider, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: minSecondsPerCollection, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: 1, + metadata: "" + }); + + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + _setupValidProvision(serviceProvider, dataService); + vm.prank(dataService); + bytes16 agreementId = _recurringCollector.accept(rca, signature); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // Window = 10_000, maxSecondsPerCollection = 100_000 + // min(10_000, 100_000) = 10_000 (window is the limiting factor, not the cap) + uint256 windowSeconds = endsAt - block.timestamp; + uint256 expected = maxOngoingTokensPerSecond * windowSeconds + maxInitialTokens; + assertEq(maxClaim, expected, "When window < maxSecondsPerCollection, window should be used directly"); + // Confirm that the window was indeed smaller + assertLt(windowSeconds, maxSecondsPerCollection, "Window should be smaller than maxSecondsPerCollection"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol new file mode 100644 index 000000000..10d6ee5e0 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Tests that ECDSA and contract-approved paths can be mixed for accept and update. +contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice ECDSA accept, then contract-approved update should fail (payer is EOA) + function test_MixedPath_ECDSAAccept_UnsignedUpdate_RevertsForEOA() public { + uint256 signerKey = 0xA11CE; + address payer = vm.addr(signerKey); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + // Accept via ECDSA + (, , bytes16 agreementId) = _authorizeAndAccept(rca, signerKey); + + // Try unsigned update — should revert because payer is an EOA + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + nonce: 1, + metadata: "" + }) + ); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, payer) + ); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + } + + /// @notice Contract-approved accept, then ECDSA update should fail (no authorized signer) + function test_MixedPath_UnsignedAccept_ECDSAUpdate_RevertsForUnauthorizedSigner() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + // Accept via contract-approved path + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Try ECDSA update with an unauthorized signer + uint256 wrongKey = 0xDEAD; + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + nonce: 1, + metadata: "" + }) + ); + + (, bytes memory sig) = _recurringCollectorHelper.generateSignedRCAU(rcau, wrongKey); + + vm.expectRevert(IRecurringCollector.RecurringCollectorInvalidSigner.selector); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, sig); + } + + /// @notice Contract-approved accept, then contract-approved update works + function test_MixedPath_UnsignedAccept_UnsignedUpdate_OK() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }) + ); + + // Accept via contract-approved path + bytes32 agreementHash = _recurringCollector.hashRCA(rca); + approver.authorize(agreementHash); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Update via contract-approved path (use sensibleRCAU to stay in valid ranges) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 50 ether, + maxOngoingTokensPerSecond: 0.5 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + nonce: 1, + metadata: "" + }) + ); + + bytes32 updateHash = _recurringCollector.hashRCAU(rcau); + approver.authorize(updateHash); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementUpdated( + rca.dataService, + address(approver), + rca.serviceProvider, + agreementId, + uint64(block.timestamp), + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection + ); + + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + // Verify updated terms + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.maxOngoingTokensPerSecond, rcau.maxOngoingTokensPerSecond); + assertEq(agreement.maxSecondsPerCollection, rcau.maxSecondsPerCollection); + assertEq(agreement.updateNonce, 1); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/interfaces/contracts/horizon/IAgreementOwner.sol b/packages/interfaces/contracts/horizon/IAgreementOwner.sol index 5e329d2e1..00de00f9e 100644 --- a/packages/interfaces/contracts/horizon/IAgreementOwner.sol +++ b/packages/interfaces/contracts/horizon/IAgreementOwner.sol @@ -2,16 +2,19 @@ pragma solidity ^0.8.22; /** - * @title Interface for contracts that can act as authorized agreement approvers + * @title Interface for contract payer callbacks from RecurringCollector * @author Edge & Node - * @notice Enables contracts to authorize RCA agreements and updates on-chain via - * {RecurringCollector.accept} and {RecurringCollector.update} (with empty authData), - * replacing ECDSA signatures with a callback. + * @notice Callbacks that RecurringCollector invokes on contract payers (payers with + * deployed code, as opposed to EOA payers that use ECDSA signatures). * - * Uses the magic-value pattern: return the function selector on success. - * - * The same callback is used for both accept (RCA hash) and update (RCAU hash). - * Hash namespaces do not collide because RCA and RCAU use different EIP712 type hashes. + * Three callbacks: + * - {approveAgreement}: gate — called during accept/update to verify authorization. + * Uses the magic-value pattern (return selector on success). Called with RCA hash + * on accept, RCAU hash on update; namespaces don't collide (different EIP712 type hashes). + * - {beforeCollection}: called before PaymentsEscrow.collect() so the payer can top up + * escrow if needed. Only acts when the escrow balance is short for the collection. + * - {afterCollection}: called after collection so the payer can reconcile escrow state. + * Both collection callbacks are wrapped in try/catch — reverts do not block collection. * * No per-payer authorization step is needed — the contract's code is the authorization. * The trust chain is: governance grants operator role → operator registers @@ -29,4 +32,22 @@ interface IAgreementOwner { * @return magic `IAgreementOwner.approveAgreement.selector` if authorized */ function approveAgreement(bytes32 agreementHash) external view returns (bytes4); + + /** + * @notice Called by RecurringCollector before PaymentsEscrow.collect() + * @dev Allows contract payers to top up escrow if the balance is insufficient + * for the upcoming collection. Wrapped in try/catch — reverts do not block collection. + * @param agreementId The agreement being collected + * @param tokensToCollect Amount of tokens about to be collected + */ + function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external; + + /** + * @notice Called by RecurringCollector after a successful collection + * @dev Allows contract payers to reconcile escrow state in the same transaction + * as the collection. Wrapped in try/catch — reverts do not block collection. + * @param agreementId The collected agreement + * @param tokensCollected Amount of tokens collected + */ + function afterCollection(bytes16 agreementId, uint256 tokensCollected) external; } diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 91276f06d..ef34f11bd 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -369,6 +369,13 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ error RecurringCollectorExcessiveSlippage(uint256 requested, uint256 actual, uint256 maxSlippage); + /** + * @notice Thrown when a contract payer's eligibility oracle denies the service provider + * @param agreementId The agreement ID + * @param serviceProvider The service provider that is not eligible + */ + error RecurringCollectorCollectionNotEligible(bytes16 agreementId, address serviceProvider); + /** * @notice Thrown when the contract approver is not a contract * @param approver The address that is not a contract diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol new file mode 100644 index 000000000..3e37e50e8 --- /dev/null +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +import { IPaymentsEscrow } from "../../horizon/IPaymentsEscrow.sol"; +import { IRecurringEscrowManagement } from "./IRecurringEscrowManagement.sol"; + +/** + * @title Interface for the {RecurringAgreementHelper} contract + * @author Edge & Node + * @notice Stateless, permissionless convenience contract for {RecurringAgreementManager}. + * Provides batch reconciliation (including cleanup of settled agreements) and + * read-only audit views. Independently deployable — better versions can be + * deployed without protocol changes. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IRecurringAgreementHelper { + // -- Audit Structs -- + + /** + * @notice Global financial summary of the RecurringAgreementManager + * @param tokenBalance GRT balance available to the manager + * @param sumMaxNextClaimAll Global sum of maxNextClaim across all (collector, provider) pairs + * @param totalEscrowDeficit Total unfunded escrow across all pairs + * @param totalAgreementCount Total number of tracked agreements + * @param escrowBasis Configured escrow level (Full / OnDemand / JustInTime) + * @param tempJit Whether the temporary JIT breaker is active + * @param collectorCount Number of collectors with active agreements + */ + struct GlobalAudit { + uint256 tokenBalance; + uint256 sumMaxNextClaimAll; + uint256 totalEscrowDeficit; + uint256 totalAgreementCount; + IRecurringEscrowManagement.EscrowBasis escrowBasis; + bool tempJit; + uint256 collectorCount; + } + + /** + * @notice Per-(collector, provider) pair financial summary + * @param collector The collector address + * @param provider The provider address + * @param agreementCount Number of agreements for this pair + * @param sumMaxNextClaim Sum of maxNextClaim for this pair + * @param escrow Escrow account state (balance, tokensThawing, thawEndTimestamp) + */ + struct PairAudit { + address collector; + address provider; + uint256 agreementCount; + uint256 sumMaxNextClaim; + IPaymentsEscrow.EscrowAccount escrow; + } + + // -- Audit Views -- + + /** + * @notice Global financial snapshot of the manager + * @return audit The global audit struct + */ + function auditGlobal() external view returns (GlobalAudit memory audit); + + /** + * @notice All pair summaries for a specific collector + * @param collector The collector address + * @return pairs Array of pair audit structs + */ + function auditPairs(address collector) external view returns (PairAudit[] memory pairs); + + /** + * @notice Paginated pair summaries for a collector + * @param collector The collector address + * @param offset Index to start from + * @param count Maximum number to return + * @return pairs Array of pair audit structs + */ + function auditPairs( + address collector, + uint256 offset, + uint256 count + ) external view returns (PairAudit[] memory pairs); + + /** + * @notice Single pair summary + * @param collector The collector address + * @param provider The provider address + * @return pair The pair audit struct + */ + function auditPair(address collector, address provider) external view returns (PairAudit memory pair); + + // -- Reconciliation -- + + /** + * @notice Reconcile all agreements for a provider, cleaning up fully settled ones. + * @dev Permissionless. O(n) gas — may hit gas limits with many agreements. + * @param provider The provider to reconcile + * @return removed Number of agreements removed during reconciliation + */ + function reconcile(address provider) external returns (uint256 removed); + + /** + * @notice Reconcile a batch of specific agreement IDs, cleaning up fully settled ones. + * @dev Permissionless. Skips non-existent agreements. + * @param agreementIds The agreement IDs to reconcile + * @return removed Number of agreements removed during reconciliation + */ + function reconcileBatch(bytes16[] calldata agreementIds) external returns (uint256 removed); + + /** + * @notice Reconcile all agreements for a (collector, provider) pair, then + * attempt to remove pair tracking if fully drained. + * @dev Permissionless. May require multiple calls if escrow is still thawing. + * @param collector The collector address + * @param provider The provider address + * @return removed Number of agreements removed + * @return pairExists True if the pair is still tracked + */ + function reconcilePair(address collector, address provider) external returns (uint256 removed, bool pairExists); + + /** + * @notice Reconcile all pairs for a collector, then attempt collector removal. + * @dev Permissionless. O(providers * agreements) gas. + * @param collector The collector address + * @return removed Total agreements removed + * @return collectorExists True if the collector is still tracked + */ + function reconcileCollector(address collector) external returns (uint256 removed, bool collectorExists); + + /** + * @notice Reconcile all agreements across all collectors and providers. + * @dev Permissionless. May hit gas limits with many agreements. + * @return removed Total agreements removed + */ + function reconcileAll() external returns (uint256 removed); +} diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol new file mode 100644 index 000000000..43f72057a --- /dev/null +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +import { IRecurringCollector } from "../../horizon/IRecurringCollector.sol"; + +/** + * @title Interface for agreement lifecycle operations on {RecurringAgreementManager} + * @author Edge & Node + * @notice Functions for offering, updating, revoking, canceling, and + * reconciling managed RCAs (Recurring Collection Agreements). + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IRecurringAgreementManagement { + // -- Events -- + // solhint-disable gas-indexed-events + + /** + * @notice Emitted when an agreement is offered for escrow management + * @param agreementId The deterministic agreement ID + * @param provider The service provider for this agreement + * @param maxNextClaim The calculated maximum next claim amount + */ + event AgreementOffered(bytes16 indexed agreementId, address indexed provider, uint256 maxNextClaim); + + /** + * @notice Emitted when an agreement offer is revoked before acceptance + * @param agreementId The agreement ID + * @param provider The provider whose sumMaxNextClaim was reduced + */ + event OfferRevoked(bytes16 indexed agreementId, address indexed provider); + + /** + * @notice Emitted when an agreement is canceled via the data service + * @param agreementId The agreement ID + * @param provider The provider for this agreement + */ + event AgreementCanceled(bytes16 indexed agreementId, address indexed provider); + + /** + * @notice Emitted when an agreement is removed from escrow management + * @param agreementId The agreement ID being removed + * @param provider The provider whose sumMaxNextClaim was reduced + */ + event AgreementRemoved(bytes16 indexed agreementId, address indexed provider); + + /** + * @notice Emitted when an agreement's max next claim is recalculated + * @param agreementId The agreement ID + * @param oldMaxNextClaim The previous max next claim + * @param newMaxNextClaim The updated max next claim + */ + event AgreementReconciled(bytes16 indexed agreementId, uint256 oldMaxNextClaim, uint256 newMaxNextClaim); + + /** + * @notice Emitted when a pending agreement update is offered + * @param agreementId The agreement ID + * @param pendingMaxNextClaim The max next claim for the pending update + * @param updateNonce The RCAU nonce for the pending update + */ + event AgreementUpdateOffered(bytes16 indexed agreementId, uint256 pendingMaxNextClaim, uint32 updateNonce); + + /** + * @notice Emitted when a pending agreement update is revoked + * @param agreementId The agreement ID + * @param pendingMaxNextClaim The escrow that was freed + * @param updateNonce The RCAU nonce that was revoked + */ + event AgreementUpdateRevoked(bytes16 indexed agreementId, uint256 pendingMaxNextClaim, uint32 updateNonce); + + /** + * @notice Emitted when a (collector, provider) pair is removed from tracking + * @dev Emitted when the pair has no agreements AND escrow is fully recovered (balance zero). + * May cascade inline from agreement deletion or be triggered by {reconcileCollectorProvider}. + * @param collector The collector address + * @param provider The provider address + */ + event CollectorProviderRemoved(address indexed collector, address indexed provider); + + /** + * @notice Emitted when a collector is removed from the global tracking set + * @dev Emitted when the collector's last provider is removed, cascading from pair removal. + * @param collector The collector address + */ + event CollectorRemoved(address indexed collector); + + // solhint-enable gas-indexed-events + + // -- Errors -- + + /** + * @notice Thrown when trying to offer an agreement that is already offered + * @param agreementId The agreement ID + */ + error AgreementAlreadyOffered(bytes16 agreementId); + + /** + * @notice Thrown when trying to operate on an agreement that is not offered + * @param agreementId The agreement ID + */ + error AgreementNotOffered(bytes16 agreementId); + + /** + * @notice Thrown when the RCA payer is not this contract + * @param payer The payer address in the RCA + * @param expected The expected payer (this contract) + */ + error PayerMustBeManager(address payer, address expected); + + /** + * @notice Thrown when trying to revoke an agreement that is already accepted + * @param agreementId The agreement ID + */ + error AgreementAlreadyAccepted(bytes16 agreementId); + + /** + * @notice Thrown when trying to cancel an agreement that has not been accepted yet + * @param agreementId The agreement ID + */ + error AgreementNotAccepted(bytes16 agreementId); + + /** + * @notice Thrown when the data service address has no deployed code + * @param dataService The address that was expected to be a contract + */ + error InvalidDataService(address dataService); + + /// @notice Thrown when the RCA service provider is the zero address + error ServiceProviderZeroAddress(); + + /** + * @notice Thrown when the data service address does not have DATA_SERVICE_ROLE + * @param dataService The unauthorized data service address + */ + error UnauthorizedDataService(address dataService); + + /// @notice Thrown when a collection callback is called by an address other than the agreement's collector + error OnlyAgreementCollector(); + + /** + * @notice Thrown when the RCAU nonce does not match the expected next update nonce + * @param agreementId The agreement ID + * @param expectedNonce The expected nonce (collector's updateNonce + 1) + * @param actualNonce The nonce provided in the RCAU + */ + error InvalidUpdateNonce(bytes16 agreementId, uint32 expectedNonce, uint32 actualNonce); + + /** + * @notice Thrown when the collector address does not have COLLECTOR_ROLE + * @param collector The unauthorized collector address + */ + error UnauthorizedCollector(address collector); + + // -- Functions -- + + /** + * @notice Offer an RCA for escrow management. Must be called before + * the data service accepts the agreement (with empty authData). + * @dev Calculates max next claim from RCA parameters, stores the authorized hash + * for the {IAgreementOwner} callback, and deposits into escrow. + * Requires AGREEMENT_MANAGER_ROLE. + * @param rca The Recurring Collection Agreement parameters + * @param collector The RecurringCollector contract to use for this agreement + * @return agreementId The deterministic agreement ID + */ + function offerAgreement( + IRecurringCollector.RecurringCollectionAgreement calldata rca, + IRecurringCollector collector + ) external returns (bytes16 agreementId); + + /** + * @notice Offer a pending agreement update for escrow management. Must be called + * before the data service applies the update (with empty authData). + * @dev Stores the authorized RCAU hash for the {IAgreementOwner} callback and + * adds the pending update's max next claim to sumMaxNextClaim. Treats the + * pending update as a separate escrow entry alongside the current agreement. + * If a previous pending update exists, it is replaced. + * Requires AGREEMENT_MANAGER_ROLE. + * @param rcau The Recurring Collection Agreement Update parameters + * @return agreementId The agreement ID from the RCAU + */ + function offerAgreementUpdate( + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau + ) external returns (bytes16 agreementId); + + /** + * @notice Revoke a pending agreement update, freeing its reserved escrow. + * @dev Requires AGREEMENT_MANAGER_ROLE. Reconciles the agreement first to + * detect if the update was already applied. If the pending update is still + * outstanding after reconciliation, clears it and frees the escrow. + * No-op (returns false) if no pending update exists after reconciliation. + * @param agreementId The agreement ID whose pending update to revoke + * @return revoked True if a pending update was cleared by this call + */ + function revokeAgreementUpdate(bytes16 agreementId) external returns (bool revoked); + + /** + * @notice Revoke an un-accepted agreement offer. Only for agreements not yet + * accepted in RecurringCollector. + * @dev Requires AGREEMENT_MANAGER_ROLE. Clears the agreement tracking and authorized hashes, + * freeing the reserved escrow. Any pending update is also cleared. + * No-op (returns true) if the agreement is not tracked. + * @param agreementId The agreement ID to revoke + * @return gone True if the agreement is not tracked (whether revoked by this call or already absent) + */ + function revokeOffer(bytes16 agreementId) external returns (bool gone); + + /** + * @notice Cancel an accepted agreement by routing through the data service. + * @dev Requires AGREEMENT_MANAGER_ROLE. Reads agreement state from RecurringCollector: + * - NotAccepted: reverts (use {revokeOffer} instead) + * - Accepted: cancels via the data service, then reconciles and updates escrow + * - Already canceled: idempotent — reconciles and updates escrow without re-canceling + * After cancellation, call {reconcileAgreement} once the collection window closes. + * @param agreementId The agreement ID to cancel + * @return gone True if the agreement is not tracked (already absent); false when + * the agreement is still tracked (caller should eventually call {reconcileAgreement}) + */ + function cancelAgreement(bytes16 agreementId) external returns (bool gone); + + /** + * @notice Reconcile a single agreement: re-read on-chain state, recalculate + * max next claim, update escrow, and delete the agreement if fully settled. + * @dev Permissionless. Handles all agreement states: + * - NotAccepted before deadline: keeps pre-offer estimate (returns true) + * - NotAccepted past deadline: zeroes and deletes (returns false) + * - Accepted/Canceled: reconciles maxNextClaim, deletes if zero + * Should be called after collections, cancellations, or agreement updates. + * @param agreementId The agreement ID to reconcile + * @return exists True if the agreement is still tracked after this call + */ + function reconcileAgreement(bytes16 agreementId) external returns (bool exists); + + /** + * @notice Reconcile a (collector, provider) pair: rebalance escrow, withdraw + * completed thaws, and remove tracking if fully drained. + * @dev Permissionless. First updates escrow state (deposit deficit, thaw excess, + * withdraw completed thaws), then removes pair tracking when both pairAgreementCount + * and escrow balance are zero. Also serves as the permissionless "poke" to rebalance + * escrow after {IRecurringEscrowManagement-setEscrowBasis} or {IRecurringEscrowManagement-setTempJit} + * changes. Returns true if the pair still has agreements or escrow is still thawing. + * @param collector The collector address + * @param provider The provider address + * @return exists True if the pair is still tracked after this call + */ + function reconcileCollectorProvider(address collector, address provider) external returns (bool exists); +} diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol new file mode 100644 index 000000000..9d6223ad0 --- /dev/null +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +import { IDataServiceAgreements } from "../../data-service/IDataServiceAgreements.sol"; +import { IPaymentsEscrow } from "../../horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "../../horizon/IRecurringCollector.sol"; +import { IRecurringEscrowManagement } from "./IRecurringEscrowManagement.sol"; + +/** + * @title Interface for querying {RecurringAgreementManager} state + * @author Edge & Node + * @notice Read-only functions for inspecting managed agreements, escrow balances, + * and global tracking state. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IRecurringAgreements { + // -- Structs -- + + /** + * @notice Tracked state for a managed agreement + * @dev An agreement is considered tracked when `provider != address(0)`. + * + * Storage layout (7 slots): + * slot 0: provider (20) + deadline (8) + pendingUpdateNonce (4) = 32 (packed) + * slot 1: maxNextClaim (32) + * slot 2: pendingUpdateMaxNextClaim (32) + * slot 3: agreementHash (32) + * slot 4: pendingUpdateHash (32) + * slot 5: dataService (20) (12 bytes free) + * slot 6: collector (20) (12 bytes free) + * + * @param provider The service provider for this agreement + * @param deadline The RCA deadline for acceptance (used to detect expired offers) + * @param pendingUpdateNonce The RCAU nonce for the pending update (0 means no pending) + * @param maxNextClaim The current maximum tokens claimable in the next collection + * @param pendingUpdateMaxNextClaim Max next claim for an offered-but-not-yet-applied update + * @param agreementHash The RCA hash stored for cleanup of authorizedHashes on deletion + * @param pendingUpdateHash The RCAU hash stored for cleanup of authorizedHashes on deletion + * @param dataService The data service contract for this agreement + * @param collector The RecurringCollector contract for this agreement + */ + struct AgreementInfo { + address provider; + uint64 deadline; + uint32 pendingUpdateNonce; + uint256 maxNextClaim; + uint256 pendingUpdateMaxNextClaim; + bytes32 agreementHash; + bytes32 pendingUpdateHash; + IDataServiceAgreements dataService; + IRecurringCollector collector; + } + + // -- View Functions -- + + /** + * @notice Get the sum of maxNextClaim for all managed agreements for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @return tokens The sum of max next claims + */ + function getSumMaxNextClaim(IRecurringCollector collector, address provider) external view returns (uint256 tokens); + + /** + * @notice Get the escrow account for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @return account The escrow account data + */ + function getEscrowAccount( + IRecurringCollector collector, + address provider + ) external view returns (IPaymentsEscrow.EscrowAccount memory account); + + /** + * @notice Get the max next claim for a specific agreement + * @param agreementId The agreement ID + * @return tokens The current max next claim stored for this agreement + */ + function getAgreementMaxNextClaim(bytes16 agreementId) external view returns (uint256 tokens); + + /** + * @notice Get the full tracked state for a specific agreement + * @param agreementId The agreement ID + * @return info The agreement info struct (all fields zero if not tracked) + */ + function getAgreementInfo(bytes16 agreementId) external view returns (AgreementInfo memory info); + + /** + * @notice Get the number of managed agreements for a provider + * @param provider The provider address + * @return count The count of tracked agreements + */ + function getProviderAgreementCount(address provider) external view returns (uint256 count); + + /** + * @notice Get all managed agreement IDs for a provider + * @dev Returns the full set of tracked agreement IDs. May be expensive for providers + * with many agreements — prefer the paginated overload or {getProviderAgreementCount} + * for on-chain use. + * @param provider The provider address + * @return agreementIds The array of agreement IDs + */ + function getProviderAgreements(address provider) external view returns (bytes16[] memory agreementIds); + + /** + * @notice Get a paginated slice of managed agreement IDs for a provider + * @param provider The provider address + * @param offset The index to start from + * @param count Maximum number of IDs to return (clamped to available) + * @return agreementIds The array of agreement IDs + */ + function getProviderAgreements( + address provider, + uint256 offset, + uint256 count + ) external view returns (bytes16[] memory agreementIds); + + /** + * @notice Get the current escrow basis setting + * @return basis The configured escrow basis + */ + function getEscrowBasis() external view returns (IRecurringEscrowManagement.EscrowBasis basis); + + /** + * @notice Get the sum of maxNextClaim across all (collector, provider) pairs + * @dev Populated lazily through normal operations. May be stale if agreements were + * offered before this feature was deployed — run reconciliation to populate. + * @return tokens The global sum of max next claims + */ + function getSumMaxNextClaimAll() external view returns (uint256 tokens); + + /** + * @notice Get the total undeposited escrow across all providers + * @dev Maintained incrementally: sum of max(0, sumMaxNextClaim[p] - deposited[p]) + * for each provider p. Correctly accounts for per-provider deficits without + * allowing over-deposited providers to mask under-deposited ones. + * @return tokens The total unfunded amount + */ + function getTotalEscrowDeficit() external view returns (uint256 tokens); + + /** + * @notice Get the total number of tracked agreements across all providers + * @dev Populated lazily through normal operations. + * @return count The total agreement count + */ + function getTotalAgreementCount() external view returns (uint256 count); + + /** + * @notice Check whether temporary JIT mode is currently active + * @dev When active, the system operates in JIT-only mode regardless of the configured + * escrow basis. The configured basis is preserved and takes effect again when + * temp JIT recovers (totalEscrowDeficit < available) or operator calls {setTempJit}. + * @return active True if temporary JIT mode is active + */ + function isTempJit() external view returns (bool active); + + /** + * @notice Get the number of collectors with active agreements + * @return count The number of tracked collectors + */ + function getCollectorCount() external view returns (uint256 count); + + /** + * @notice Get all collector addresses with active agreements + * @dev May be expensive for large sets — prefer the paginated overload for on-chain use. + * @return result Array of collector addresses + */ + function getCollectors() external view returns (address[] memory result); + + /** + * @notice Get a paginated slice of collector addresses + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return result Array of collector addresses + */ + function getCollectors(uint256 offset, uint256 count) external view returns (address[] memory result); + + /** + * @notice Get the number of providers with active agreements for a collector + * @param collector The collector address + * @return count The number of tracked providers + */ + function getCollectorProviderCount(address collector) external view returns (uint256 count); + + /** + * @notice Get all provider addresses with active agreements for a collector + * @dev May be expensive for large sets — prefer the paginated overload for on-chain use. + * @param collector The collector address + * @return result Array of provider addresses + */ + function getCollectorProviders(address collector) external view returns (address[] memory result); + + /** + * @notice Get a paginated slice of provider addresses for a collector + * @param collector The collector address + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return result Array of provider addresses + */ + function getCollectorProviders( + address collector, + uint256 offset, + uint256 count + ) external view returns (address[] memory result); + + /** + * @notice Get the number of managed agreements for a (collector, provider) pair + * @param collector The collector address + * @param provider The provider address + * @return count The pair agreement count + */ + function getPairAgreementCount(address collector, address provider) external view returns (uint256 count); +} diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol new file mode 100644 index 000000000..ee4d3d35b --- /dev/null +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +/** + * @title Interface for escrow management operations on {RecurringAgreementManager} + * @author Edge & Node + * @notice Functions for configuring escrow deposits that back + * managed RCAs. Controls how aggressively escrow is pre-deposited. + * Escrow rebalancing is performed by {IRecurringAgreementManagement-reconcileCollectorProvider}. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +interface IRecurringEscrowManagement { + // -- Enums -- + + /** + * @notice Escrow level — controls how aggressively escrow is pre-deposited. + * Ordered low-to-high. The configured level is the maximum aspiration; the system + * automatically degrades when balance is insufficient. `beforeCollection` (JIT top-up) + * is always active regardless of setting. + * + * @dev JustInTime=0 (thaw everything, pure JIT), OnDemand=1 (no deposits, hold at + * sumMaxNextClaim level), Full=2 (deposit sum of all maxNextClaim — current default). + */ + enum EscrowBasis { + JustInTime, + OnDemand, + Full + } + + // -- Events -- + // solhint-disable gas-indexed-events + + /** + * @notice Emitted when escrow is deposited for a provider + * @param provider The provider whose escrow was deposited into + * @param collector The collector address for the escrow account + * @param deposited The amount deposited + */ + event EscrowFunded(address indexed provider, address indexed collector, uint256 deposited); + + /** + * @notice Emitted when thawed escrow tokens are withdrawn + * @param provider The provider whose escrow was withdrawn + * @param collector The collector address for the escrow account + * @param tokens The amount of tokens withdrawn + */ + event EscrowWithdrawn(address indexed provider, address indexed collector, uint256 tokens); + + /** + * @notice Emitted when the escrow basis is changed + * @param oldBasis The previous escrow basis + * @param newBasis The new escrow basis + */ + event EscrowBasisSet(EscrowBasis indexed oldBasis, EscrowBasis indexed newBasis); + + /** + * @notice Emitted when temporary JIT mode is activated or deactivated + * @param active True when entering temp JIT, false when recovering + * @param automatic True when triggered by the system (beforeCollection/reconcileCollectorProvider), + * false when triggered by operator (setTempJit/setEscrowBasis) + */ + event TempJitSet(bool indexed active, bool indexed automatic); + + // solhint-enable gas-indexed-events + + // -- Functions -- + + /** + * @notice Set the escrow basis (maximum aspiration level). + * @dev Requires OPERATOR_ROLE. The system automatically degrades below the configured + * level when balance is insufficient. Changing the basis does not immediately rebalance + * escrow — call {IRecurringAgreementManagement-reconcileCollectorProvider} per pair to apply. + * @param basis The new escrow basis + */ + function setEscrowBasis(EscrowBasis basis) external; + + /** + * @notice Manually activate or deactivate temporary JIT mode + * @dev Requires OPERATOR_ROLE. When activated, the system operates in JIT-only mode + * regardless of the configured escrow basis. When deactivated, the configured basis + * takes effect again. Emits {TempJitSet}. + * @param active True to activate temp JIT, false to deactivate + */ + function setTempJit(bool active) external; +} diff --git a/packages/issuance/README.md b/packages/issuance/README.md index 0209e2d97..c6def2743 100644 --- a/packages/issuance/README.md +++ b/packages/issuance/README.md @@ -11,6 +11,7 @@ The issuance contracts handle token issuance mechanisms for The Graph protocol. - **[IssuanceAllocator](contracts/allocate/IssuanceAllocator.md)** - Central distribution hub for token issuance, allocating tokens to different protocol components based on configured rates - **[RewardsEligibilityOracle](contracts/eligibility/RewardsEligibilityOracle.md)** - Oracle-based eligibility system for indexer rewards with time-based expiration - **DirectAllocation** - Simple target contract implementation for receiving and distributing allocated tokens (deployed as PilotAllocation and other instances) +- **[RecurringAgreementManager](contracts/agreement/RecurringAgreementManager.md)** - Funds PaymentsEscrow deposits for RCAs using issuance tokens, tracking max-next-claim per agreement per indexer ## Development diff --git a/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol new file mode 100644 index 000000000..250ca600d --- /dev/null +++ b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.8.27; + +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +/** + * @title RecurringAgreementHelper + * @author Edge & Node + * @notice Stateless, permissionless convenience contract for {RecurringAgreementManager}. + * Provides batch reconciliation (including cleanup of settled agreements) and + * read-only audit views. Independently deployable — better versions can be + * deployed without protocol changes. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +contract RecurringAgreementHelper is IRecurringAgreementHelper { + /// @notice The RecurringAgreementManager contract address + address public immutable MANAGER; + + /// @notice The GRT token contract + IERC20 public immutable GRAPH_TOKEN; + + /// @notice Thrown when an address parameter is the zero address + error ZeroAddress(); + + /** + * @notice Constructor for the RecurringAgreementHelper contract + * @param manager Address of the RecurringAgreementManager contract + * @param graphToken Address of the GRT token contract + */ + constructor(address manager, IERC20 graphToken) { + require(manager != address(0), ZeroAddress()); + require(address(graphToken) != address(0), ZeroAddress()); + MANAGER = manager; + GRAPH_TOKEN = graphToken; + } + + // -- Audit Views -- + + /// @inheritdoc IRecurringAgreementHelper + function auditGlobal() external view returns (GlobalAudit memory audit) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + audit = GlobalAudit({ + tokenBalance: GRAPH_TOKEN.balanceOf(MANAGER), + sumMaxNextClaimAll: mgr.getSumMaxNextClaimAll(), + totalEscrowDeficit: mgr.getTotalEscrowDeficit(), + totalAgreementCount: mgr.getTotalAgreementCount(), + escrowBasis: mgr.getEscrowBasis(), + tempJit: mgr.isTempJit(), + collectorCount: mgr.getCollectorCount() + }); + } + + /// @inheritdoc IRecurringAgreementHelper + function auditPairs(address collector) external view returns (PairAudit[] memory pairs) { + return _auditPairs(collector, 0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreementHelper + function auditPairs( + address collector, + uint256 offset, + uint256 count + ) external view returns (PairAudit[] memory pairs) { + return _auditPairs(collector, offset, count); + } + + /// @inheritdoc IRecurringAgreementHelper + function auditPair(address collector, address provider) external view returns (PairAudit memory pair) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + pair = PairAudit({ + collector: collector, + provider: provider, + agreementCount: mgr.getPairAgreementCount(collector, provider), + sumMaxNextClaim: mgr.getSumMaxNextClaim(IRecurringCollector(collector), provider), + escrow: mgr.getEscrowAccount(IRecurringCollector(collector), provider) + }); + } + + // -- Reconciliation -- + + /// @inheritdoc IRecurringAgreementHelper + function reconcile(address provider) external returns (uint256 removed) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + bytes16[] memory ids = mgr.getProviderAgreements(provider); + for (uint256 i = 0; i < ids.length; ++i) if (!mgt.reconcileAgreement(ids[i])) ++removed; + } + + /// @inheritdoc IRecurringAgreementHelper + function reconcileBatch(bytes16[] calldata agreementIds) external returns (uint256 removed) { + IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + for (uint256 i = 0; i < agreementIds.length; ++i) { + if (!mgt.reconcileAgreement(agreementIds[i])) ++removed; + } + } + + /// @inheritdoc IRecurringAgreementHelper + function reconcilePair(address collector, address provider) external returns (uint256 removed, bool pairExists) { + removed = _reconcilePair(collector, provider); + pairExists = IRecurringAgreementManagement(MANAGER).reconcileCollectorProvider(collector, provider); + } + + /// @inheritdoc IRecurringAgreementHelper + function reconcileCollector(address collector) external returns (uint256 removed, bool collectorExists) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + // Snapshot providers before iterating (removal modifies the set) + address[] memory providers = mgr.getCollectorProviders(collector); + for (uint256 p = 0; p < providers.length; ++p) { + removed += _reconcilePair(collector, providers[p]); + mgt.reconcileCollectorProvider(collector, providers[p]); + } + collectorExists = mgr.getCollectorProviders(collector).length != 0; + } + + /// @inheritdoc IRecurringAgreementHelper + function reconcileAll() external returns (uint256 removed) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + // Snapshot collectors before iterating + address[] memory collectors = mgr.getCollectors(); + for (uint256 c = 0; c < collectors.length; ++c) { + address[] memory providers = mgr.getCollectorProviders(collectors[c]); + for (uint256 p = 0; p < providers.length; ++p) { + removed += _reconcilePair(collectors[c], providers[p]); + mgt.reconcileCollectorProvider(collectors[c], providers[p]); + } + } + } + + // -- Private Helpers -- + + function _auditPairs( + address collector, + uint256 offset, + uint256 count + ) private view returns (PairAudit[] memory pairs) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + address[] memory providers = mgr.getCollectorProviders(collector, offset, count); + pairs = new PairAudit[](providers.length); + for (uint256 i = 0; i < providers.length; ++i) { + pairs[i] = PairAudit({ + collector: collector, + provider: providers[i], + agreementCount: mgr.getPairAgreementCount(collector, providers[i]), + sumMaxNextClaim: mgr.getSumMaxNextClaim(IRecurringCollector(collector), providers[i]), + escrow: mgr.getEscrowAccount(IRecurringCollector(collector), providers[i]) + }); + } + } + + function _reconcilePair(address collector, address provider) private returns (uint256 removed) { + IRecurringAgreements mgr = IRecurringAgreements(MANAGER); + IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + bytes16[] memory ids = mgr.getProviderAgreements(provider); + for (uint256 i = 0; i < ids.length; ++i) { + if (address(mgr.getAgreementInfo(ids[i]).collector) == collector) { + if (!mgt.reconcileAgreement(ids[i])) ++removed; + } + } + } +} diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.md b/packages/issuance/contracts/agreement/RecurringAgreementManager.md new file mode 100644 index 000000000..b112e5037 --- /dev/null +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.md @@ -0,0 +1,168 @@ +# RecurringAgreementManager + +RCA-based payments require escrow pre-deposits — the payer must deposit enough tokens to cover the maximum that could be collected in the next collection window. RecurringAgreementManager automates this for protocol-escrowed agreements by receiving minted GRT from IssuanceAllocator and maintaining escrow balances sufficient to cover worst-case collection amounts. + +It implements seven interfaces: + +- **`IIssuanceTarget`** — receives minted GRT from IssuanceAllocator +- **`IAgreementOwner`** — authorizes RCA acceptance and updates via callback (replaces ECDSA signature) +- **`IRecurringAgreementManagement`** — agreement lifecycle: offer, update, revoke, cancel, remove, reconcile +- **`IRecurringEscrowManagement`** — escrow configuration: setEscrowBasis, setTempJit +- **`IProviderEligibilityManagement`** — eligibility oracle configuration: setProviderEligibilityOracle +- **`IRecurringAgreements`** — read-only queries: agreement info, escrow state, global tracking +- **`IProviderEligibility`** — delegates payment eligibility checks to an optional oracle + +## Escrow Structure + +One escrow account per (RecurringAgreementManager, collector, provider) tuple covers **all** managed RCAs for that (collector, provider) pair. Multiple agreements for the same pair share a single escrow balance: + +``` +sum(maxNextClaim + pendingUpdateMaxNextClaim for all active agreements for that provider) <= PaymentsEscrow.escrowAccounts[RecurringAgreementManager][RecurringCollector][provider] +``` + +Deposits never revert — `_escrowMinMax` degrades the mode when balance is insufficient, ensuring the deposit amount is always affordable. The `getEscrowAccount` view exposes the underlying escrow account for monitoring. + +## Hash Authorization + +The `authorizedHashes` mapping stores `hash → agreementId` rather than `hash → bool`. Hashes are automatically invalidated when agreements are deleted, preventing reuse without explicit cleanup. + +## Max Next Claim + +For accepted agreements, delegated to `RecurringCollector.getMaxNextClaim(agreementId)` as the single source of truth. For pre-accepted offers, a conservative estimate calculated at offer time: + +``` +maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens +``` + +| Agreement State | maxNextClaim | +| --------------------------- | -------------------------------------------------------------- | +| NotAccepted (pre-offered) | Stored estimate from `offerAgreement` | +| NotAccepted (past deadline) | 0 (expired offer, removable) | +| Accepted, never collected | Calculated by RecurringCollector (includes initial + ongoing) | +| Accepted, after collect | Calculated by RecurringCollector (ongoing only) | +| CanceledByPayer | Calculated by RecurringCollector (window frozen at canceledAt) | +| CanceledByServiceProvider | 0 | +| Fully expired | 0 | + +## Lifecycle + +### Offer → Accept (two-step) + +1. **Agreement manager** calls `offerAgreement(rca, collector)` — stores hash, calculates conservative maxNextClaim, deposits into escrow +2. **Service provider operator** calls `SubgraphService.acceptUnsignedIndexingAgreement(allocationId, rca)` — SubgraphService → RecurringCollector → `approveAgreement(hash)` callback to RecurringAgreementManager + +During the pending update window, both current and pending maxNextClaim are escrowed simultaneously (conservative). + +### Collect → Reconcile + +Collection flows through `SubgraphService → RecurringCollector → PaymentsEscrow`. RecurringCollector then calls `IAgreementOwner.afterCollection` on the payer, which triggers automatic reconciliation and escrow top-up in the same transaction. Manual reconcile is still available as a fallback. + +The manager exposes `reconcileAgreement` (gas-predictable, per-agreement). Batch convenience functions `reconcileBatch` (caller-selected list) and `reconcile(provider)` (iterates all agreements) are in the stateless `RecurringAgreementHelper` contract, which delegates each reconciliation back to the manager. + +### Revoke / Cancel / Remove + +- **`revokeOffer`** — withdraws an un-accepted offer +- **`cancelAgreement`** — for accepted agreements, routes cancellation through the data service then reconciles; idempotent for already-canceled agreements +- **`removeAgreement`** (permissionless) — cleans up agreements with maxNextClaim = 0 + +| State | Removable when | +| ------------------------- | ------------------------------------- | +| CanceledByServiceProvider | Immediately (maxNextClaim = 0) | +| CanceledByPayer | After collection window expires | +| Accepted past endsAt | After final collection window expires | +| NotAccepted (expired) | After `rca.deadline` passes | + +## Escrow Modes + +The configured `EscrowBasis` controls how aggressively escrow is pre-deposited. The setting is a **maximum aspiration** — the system automatically degrades when balance is insufficient. `beforeCollection` (JIT top-up) is always active regardless of setting, providing a safety net for any gap. + +### Levels + +``` +enum EscrowBasis { JustInTime, OnDemand, Full } +``` + +Ordered low-to-high: + +| Level | min (deposit floor) | max (thaw ceiling) | Behavior | +| -------------- | ------------------- | ------------------ | -------------------------------------------------- | +| Full (2) | `sumMaxNextClaim` | `sumMaxNextClaim` | Current default. Deposits worst-case for all RCAs. | +| OnDemand (1) | 0 | `sumMaxNextClaim` | No deposits, holds at sumMaxNextClaim level. | +| JustInTime (0) | 0 | 0 | Thaws everything, pure JIT. | + +`sumMaxNextClaim` here means the per-(collector, provider) sum from storage. + +**Stability guarantee**: `min <= max` at every level. Deposit-then-immediate-reconcile at the same level never triggers a thaw. + +### Min/Max Model + +`_updateEscrow` uses two numbers from `_escrowMinMax` instead of a single `sumMaxNextClaim`: + +- **min**: deposit floor — deposit if effective balance is below this +- **max**: thaw ceiling — thaw effective balance above this (never resetting an active thaw timer) + +The split ensures smooth transitions between levels. When degradation occurs, min drops to 0 but max holds at `sumMaxNextClaim`, preventing oscillation. + +### Automatic Degradation + +The setting is a ceiling, not a mandate. **Full → OnDemand** when `available <= totalEscrowDeficit` (RAM's balance can't close the system-wide gap): min drops to 0, max stays at `sumMaxNextClaim`. Degradation never reaches JustInTime automatically — only explicit operator setting or temp JIT. + +### `_updateEscrow` Flow + +`_updateEscrow(collector, provider)` normalizes escrow state in four steps using (min, max) from `_escrowMinMax`. Steps 3 and 4 are mutually exclusive (min <= max); the thaw timer is never reset. + +1. **Adjust thaw target** — cancel/reduce thawing to keep min <= effective balance, or increase toward max (without timer reset) +2. **Withdraw completed thaw** — always withdrawn, even if within [min, max] +3. **Thaw excess** — if no thaw active, start new thaw for balance above max +4. **Deposit deficit** — if no thaw active, deposit to reach min + +### Reconciliation + +Per-agreement reconciliation (`reconcileAgreement`) re-reads agreement state from RecurringCollector and updates `sumMaxNextClaim`. Pair-level escrow rebalancing and cleanup is O(1) via `reconcileCollectorProvider(collector, provider)`. Batch helpers `reconcileBatch` and `reconcile(provider)` live in the separate `RecurringAgreementHelper` contract — they are stateless wrappers that call `reconcileAgreement` in a loop. + +### Global Tracking + +| Storage field | Type | Updated at | +| --------------------- | ------- | --------------------------------------------------------------------------- | +| `escrowBasis` | enum | `setEscrowBasis()` | +| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | +| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | +| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `removeAgreement` (-1) | +| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | +| `tempJit` | bool | `beforeCollection` (trip), `_updateEscrow` (recover), `setTempJit` (manual) | + +**`totalEscrowDeficit`** is maintained incrementally as `Σ max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p])` per (collector, provider). Over-deposited pairs cannot mask another pair's deficit. At each mutation point, the pair's deficit is recomputed before and after. + +### Temp JIT + +If `beforeCollection` can't fully deposit for a collection (`available <= deficit`), it deposits nothing and activates temporary JIT mode. While active, `_escrowMinMax` returns `(0, 0)` — JIT-only behavior — regardless of the configured `escrowBasis`. The configured basis is preserved and takes effect again on recovery. + +**Trigger**: `beforeCollection` activates temp JIT when `available <= deficit` (all-or-nothing: no partial deposits). + +**Recovery**: `_updateEscrow` clears temp JIT when `totalEscrowDeficit < available`. Recovery uses `totalEscrowDeficit` (sum of per-(collector, provider) deficits) rather than total sumMaxNextClaim, correctly accounting for already-deposited escrow. During JIT mode, thaws complete and tokens return to RAM, naturally building toward recovery. + +**Operator override**: `setTempJit(bool)` allows direct control. `setEscrowBasis` does not affect `tempJit` — the two settings are independent. + +### Upgrade Safety + +Default storage value 0 maps to `JustInTime`, so `initialize()` sets `escrowBasis = Full` as the default. Future upgrades must set it explicitly via a reinitializer. `tempJit` defaults to `false` (0), which is correct — no temp JIT on fresh deployment. + +## Roles + +- **GOVERNOR_ROLE**: Sets issuance allocator, eligibility oracle; grants `DATA_SERVICE_ROLE`, `COLLECTOR_ROLE`, and other roles; admin of `OPERATOR_ROLE` +- **OPERATOR_ROLE**: Sets escrow basis and temp JIT; admin of `AGREEMENT_MANAGER_ROLE` + - **AGREEMENT_MANAGER_ROLE**: Offers agreements/updates, revokes offers, cancels agreements +- **PAUSE_ROLE**: Pauses contract (reconcile/remove remain available) +- **Permissionless**: `reconcileAgreement`, `removeAgreement`, `reconcileCollectorProvider` +- **RecurringAgreementHelper** (permissionless): `reconcile(provider)`, `reconcileBatch(ids[])` + +## Deployment + +Prerequisites: GraphToken, PaymentsEscrow, RecurringCollector, IssuanceAllocator deployed. + +1. Deploy RecurringAgreementManager implementation (graphToken, paymentsEscrow) +2. Deploy TransparentUpgradeableProxy with implementation and initialization data +3. Initialize with governor address +4. Grant `OPERATOR_ROLE` to the operator account +5. Operator grants `AGREEMENT_MANAGER_ROLE` to the agreement manager account +6. Configure IssuanceAllocator to allocate tokens to RecurringAgreementManager diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol new file mode 100644 index 000000000..0581e2f8d --- /dev/null +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -0,0 +1,956 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.8.27; + +// solhint-disable gas-strict-inequalities + +import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; + +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IDataServiceAgreements } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceAgreements.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; + +import { EnumerableSetUtil } from "../common/EnumerableSetUtil.sol"; +import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; +import { IGraphToken } from "../common/IGraphToken.sol"; + +// solhint-disable-next-line no-unused-import +import { ERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; // Used by @inheritdoc +import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; + +/** + * @title RecurringAgreementManager + * @author Edge & Node + * @notice Manages escrow for RCAs (Recurring Collection Agreements) using + * issuance-allocated tokens. This contract: + * + * 1. Receives minted GRT from IssuanceAllocator (implements IIssuanceTarget) + * 2. Authorizes RCA acceptance via contract callback (implements IAgreementOwner) + * 3. Tracks max-next-claim per agreement, deposits into PaymentsEscrow to cover maximums + * + * One escrow per (this contract, collector, provider) covers all managed + * RCAs for that (collector, provider) pair. Each agreement stores its own collector + * address. Other participants can independently use RCAs via the standard ECDSA-signed flow. + * + * @custom:security CEI — All external calls target trusted protocol contracts (PaymentsEscrow, + * GRT, RecurringCollector) except {cancelAgreement}'s call to the data service, which is + * governance-gated. {nonReentrant} on {cancelAgreement} provides defence-in-depth. + * + * @custom:security-contact Please email security+contracts@thegraph.com if you find any + * bugs. We may have an active bug bounty program. + */ +contract RecurringAgreementManager is + BaseUpgradeable, + ReentrancyGuardTransient, + IIssuanceTarget, + IAgreementOwner, + IRecurringAgreementManagement, + IRecurringEscrowManagement, + IProviderEligibilityManagement, + IRecurringAgreements, + IProviderEligibility +{ + using EnumerableSet for EnumerableSet.Bytes32Set; + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSetUtil for EnumerableSet.AddressSet; + using EnumerableSetUtil for EnumerableSet.Bytes32Set; + + // -- Role Constants -- + + /** + * @notice Role identifier for approved data service contracts + * @dev Addresses with this role can be used as data services in offered agreements. + * Admin: GOVERNOR_ROLE + */ + bytes32 public constant DATA_SERVICE_ROLE = keccak256("DATA_SERVICE_ROLE"); + + /** + * @notice Role identifier for approved collector contracts + * @dev Addresses with this role can be used as collectors in offered agreements. + * Admin: GOVERNOR_ROLE + */ + bytes32 public constant COLLECTOR_ROLE = keccak256("COLLECTOR_ROLE"); + + /** + * @notice Role identifier for agreement lifecycle operations + * @dev Addresses with this role can offer, update, revoke, and cancel agreements. + * Admin: OPERATOR_ROLE + */ + bytes32 public constant AGREEMENT_MANAGER_ROLE = keccak256("AGREEMENT_MANAGER_ROLE"); + + // -- Immutables -- + + /// @notice The PaymentsEscrow contract + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable + IPaymentsEscrow public immutable PAYMENTS_ESCROW; + + // -- Storage (ERC-7201) -- + + /// @custom:storage-location erc7201:graphprotocol.issuance.storage.RecurringAgreementManager + struct RecurringAgreementManagerStorage { + /// @notice Authorized agreement hashes — maps hash to agreementId (bytes16(0) = not authorized) + mapping(bytes32 agreementHash => bytes16) authorizedHashes; + /// @notice Per-agreement tracking data + mapping(bytes16 agreementId => AgreementInfo) agreements; + /// @notice Sum of maxNextClaim for all agreements per (collector, provider) pair + mapping(address collector => mapping(address provider => uint256)) sumMaxNextClaim; + /// @notice Set of agreement IDs per service provider (stored as bytes32 for EnumerableSet) + mapping(address provider => EnumerableSet.Bytes32Set) providerAgreementIds; + /// @notice Sum of sumMaxNextClaim across all (collector, provider) pairs + uint256 sumMaxNextClaimAll; + /// @notice Total unfunded escrow: sum of max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p]) + uint256 totalEscrowDeficit; + /// @notice Total number of tracked agreements across all providers + uint256 totalAgreementCount; + /// @notice Last known escrow balance per (collector, provider) pair (for snapshot diff) + mapping(address collector => mapping(address provider => uint256)) escrowSnap; + /// @notice Optional oracle for checking payment eligibility of service providers + IProviderEligibility providerEligibilityOracle; + /// @notice Set of all collector addresses with active agreements + EnumerableSet.AddressSet collectors; + /// @notice Set of provider addresses per collector + mapping(address collector => EnumerableSet.AddressSet) collectorProviders; + /// @notice Number of agreements per (collector, provider) pair + mapping(address collector => mapping(address provider => uint256)) pairAgreementCount; + /// @notice Governance-configured escrow level (not modified by temp JIT) + EscrowBasis escrowBasis; + /// @notice Whether temporary JIT mode is active (beforeCollection couldn't deposit) + bool tempJit; + } + + // keccak256(abi.encode(uint256(keccak256("graphprotocol.issuance.storage.RecurringAgreementManager")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant RECURRING_AGREEMENT_MANAGER_STORAGE_LOCATION = + 0x13814b254ec9c757012be47b3445539ef5e5e946eb9d2ef31ea6d4423bf88b00; + + // -- Constructor -- + + /** + * @notice Constructor for the RecurringAgreementManager contract + * @param graphToken The Graph Token contract + * @param paymentsEscrow The PaymentsEscrow contract + * @custom:oz-upgrades-unsafe-allow constructor + */ + constructor(IGraphToken graphToken, IPaymentsEscrow paymentsEscrow) BaseUpgradeable(graphToken) { + PAYMENTS_ESCROW = paymentsEscrow; + } + + // -- Initialization -- + + /** + * @notice Initialize the RecurringAgreementManager contract + * @param governor Address that will have the GOVERNOR_ROLE + */ + function initialize(address governor) external virtual initializer { + __BaseUpgradeable_init(governor); + _setRoleAdmin(DATA_SERVICE_ROLE, GOVERNOR_ROLE); + _setRoleAdmin(COLLECTOR_ROLE, GOVERNOR_ROLE); + _setRoleAdmin(AGREEMENT_MANAGER_ROLE, OPERATOR_ROLE); + _getStorage().escrowBasis = EscrowBasis.Full; + } + + // -- ERC165 -- + + /// @inheritdoc ERC165Upgradeable + function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { + return + interfaceId == type(IIssuanceTarget).interfaceId || + interfaceId == type(IAgreementOwner).interfaceId || + interfaceId == type(IRecurringAgreementManagement).interfaceId || + interfaceId == type(IRecurringEscrowManagement).interfaceId || + interfaceId == type(IProviderEligibilityManagement).interfaceId || + interfaceId == type(IRecurringAgreements).interfaceId || + interfaceId == type(IProviderEligibility).interfaceId || + super.supportsInterface(interfaceId); + } + + // -- IIssuanceTarget -- + + /// @inheritdoc IIssuanceTarget + function beforeIssuanceAllocationChange() external virtual override {} + + /// @inheritdoc IIssuanceTarget + /// @dev No-op: RecurringAgreementManager receives tokens via transfer, does not need the allocator address. + function setIssuanceAllocator(address /* issuanceAllocator */) external virtual override onlyRole(GOVERNOR_ROLE) {} + + // -- IAgreementOwner -- + + /// @inheritdoc IAgreementOwner + function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + bytes16 agreementId = $.authorizedHashes[agreementHash]; + + if (agreementId == bytes16(0) || $.agreements[agreementId].provider == address(0)) return bytes4(0); + + return IAgreementOwner.approveAgreement.selector; + } + + /// @inheritdoc IAgreementOwner + function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external override { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + address provider = agreement.provider; + if (provider == address(0)) return; + _requireCollector(agreement); + + // JIT top-up: deposit only when escrow balance cannot cover this collection + uint256 escrowBalance = _fetchEscrowAccount(msg.sender, provider).balance; + if (tokensToCollect <= escrowBalance) return; + + // Strict <: when deficit == available, enter tempJit rather than depleting entire balance + uint256 deficit = tokensToCollect - escrowBalance; + if (deficit < GRAPH_TOKEN.balanceOf(address(this))) { + GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deficit); + PAYMENTS_ESCROW.deposit(msg.sender, provider, deficit); + } else if (!$.tempJit) { + $.tempJit = true; + emit TempJitSet(true, true); + } + } + + /// @inheritdoc IAgreementOwner + function afterCollection(bytes16 agreementId, uint256 /* tokensCollected */) external override { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + if (agreement.provider == address(0)) return; + _requireCollector(agreement); + + _reconcileAndUpdateEscrow($, agreementId); + } + + // -- IRecurringAgreementManagement -- + + /// @inheritdoc IRecurringAgreementManagement + function offerAgreement( + IRecurringCollector.RecurringCollectionAgreement calldata rca, + IRecurringCollector collector + ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bytes16 agreementId) { + require(rca.payer == address(this), PayerMustBeManager(rca.payer, address(this))); + require(rca.serviceProvider != address(0), ServiceProviderZeroAddress()); + require(hasRole(DATA_SERVICE_ROLE, rca.dataService), UnauthorizedDataService(rca.dataService)); + require(hasRole(COLLECTOR_ROLE, address(collector)), UnauthorizedCollector(address(collector))); + + RecurringAgreementManagerStorage storage $ = _getStorage(); + + agreementId = collector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + require($.agreements[agreementId].provider == address(0), AgreementAlreadyOffered(agreementId)); + + bytes32 agreementHash = collector.hashRCA(rca); + uint256 maxNextClaim = _createAgreement($, agreementId, rca, collector, agreementHash); + _updateEscrow($, address(collector), rca.serviceProvider); + + emit AgreementOffered(agreementId, rca.serviceProvider, maxNextClaim); + } + + /// @inheritdoc IRecurringAgreementManagement + function offerAgreementUpdate( + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau + ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bytes16 agreementId) { + agreementId = rcau.agreementId; + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + require(agreement.provider != address(0), AgreementNotOffered(agreementId)); + + // Reconcile against on-chain state before layering a new pending update, + // so escrow accounting is current and we can validate the nonce. + _reconcileAgreement($, agreementId); + + // Validate nonce: must be the next expected nonce on the collector + IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); + uint32 expectedNonce = rca.updateNonce + 1; + require(rcau.nonce == expectedNonce, InvalidUpdateNonce(agreementId, expectedNonce, rcau.nonce)); + + // Clean up old pending hash if replacing + if (agreement.pendingUpdateHash != bytes32(0)) delete $.authorizedHashes[agreement.pendingUpdateHash]; + + // Authorize the RCAU hash for the IAgreementOwner callback + bytes32 updateHash = agreement.collector.hashRCAU(rcau); + $.authorizedHashes[updateHash] = agreementId; + agreement.pendingUpdateNonce = rcau.nonce; + agreement.pendingUpdateHash = updateHash; + + uint256 pendingMaxNextClaim = _computeMaxFirstClaim( + rcau.maxOngoingTokensPerSecond, + rcau.maxSecondsPerCollection, + rcau.maxInitialTokens + ); + _setAgreementMaxNextClaim($, agreementId, pendingMaxNextClaim, true); + _updateEscrow($, address(agreement.collector), agreement.provider); + + emit AgreementUpdateOffered(agreementId, pendingMaxNextClaim, rcau.nonce); + } + + /// @inheritdoc IRecurringAgreementManagement + function revokeAgreementUpdate( + bytes16 agreementId + ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bool revoked) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + require(agreement.provider != address(0), AgreementNotOffered(agreementId)); + + // Reconcile first — the update may have been accepted since the offer was made + _reconcileAgreement($, agreementId); + + if (agreement.pendingUpdateHash == bytes32(0)) return false; + + uint256 pendingMaxClaim = agreement.pendingUpdateMaxNextClaim; + uint32 nonce = agreement.pendingUpdateNonce; + + _setAgreementMaxNextClaim($, agreementId, 0, true); + delete $.authorizedHashes[agreement.pendingUpdateHash]; + agreement.pendingUpdateNonce = 0; + agreement.pendingUpdateHash = bytes32(0); + + _updateEscrow($, address(agreement.collector), agreement.provider); + + emit AgreementUpdateRevoked(agreementId, pendingMaxClaim, nonce); + return true; + } + + /// @inheritdoc IRecurringAgreementManagement + function revokeOffer( + bytes16 agreementId + ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bool gone) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + if (agreement.provider == address(0)) return true; + + // Only revoke un-accepted agreements — accepted ones must be canceled via cancelAgreement + IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); + require(rca.state == IRecurringCollector.AgreementState.NotAccepted, AgreementAlreadyAccepted(agreementId)); + + address provider = _deleteAgreement($, agreementId, agreement); + emit OfferRevoked(agreementId, provider); + return true; + } + + /// @inheritdoc IRecurringAgreementManagement + function cancelAgreement( + bytes16 agreementId + ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused nonReentrant returns (bool gone) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + if (agreement.provider == address(0)) return true; + + IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); + + // Not accepted — use revokeOffer instead + require(rca.state != IRecurringCollector.AgreementState.NotAccepted, AgreementNotAccepted(agreementId)); + + // If still active, route cancellation through the data service. + // Note: external call before state update — safe because caller must hold + // AGREEMENT_MANAGER_ROLE and data service is governance-gated. nonReentrant + // provides defence-in-depth (see CEI note in contract header). + if (rca.state == IRecurringCollector.AgreementState.Accepted) { + IDataServiceAgreements ds = agreement.dataService; + require(address(ds).code.length != 0, InvalidDataService(address(ds))); + ds.cancelIndexingAgreementByPayer(agreementId); + emit AgreementCanceled(agreementId, agreement.provider); + } + // else: already canceled (CanceledByPayer or CanceledByServiceProvider) — skip cancel call, just reconcile + + return _reconcileAndCleanup($, agreementId, agreement); + } + + /// @inheritdoc IRecurringAgreementManagement + function reconcileAgreement(bytes16 agreementId) external returns (bool exists) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + AgreementInfo storage agreement = $.agreements[agreementId]; + if (agreement.provider == address(0)) return false; + + return !_reconcileAndCleanup($, agreementId, agreement); + } + + /// @inheritdoc IRecurringAgreementManagement + function reconcileCollectorProvider(address collector, address provider) external returns (bool exists) { + return !_reconcilePairTracking(_getStorage(), collector, provider); + } + + // -- IRecurringEscrowManagement -- + + /// @inheritdoc IRecurringEscrowManagement + function setEscrowBasis(EscrowBasis basis) external onlyRole(OPERATOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if ($.escrowBasis == basis) return; + EscrowBasis oldBasis = $.escrowBasis; + $.escrowBasis = basis; + emit EscrowBasisSet(oldBasis, basis); + } + + /// @inheritdoc IRecurringEscrowManagement + function setTempJit(bool active) external onlyRole(OPERATOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if ($.tempJit != active) { + $.tempJit = active; + emit TempJitSet(active, false); + } + } + + // -- IProviderEligibilityManagement -- + + /// @inheritdoc IProviderEligibilityManagement + function setProviderEligibilityOracle(IProviderEligibility oracle) external onlyRole(GOVERNOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if (address($.providerEligibilityOracle) == address(oracle)) return; + IProviderEligibility oldOracle = $.providerEligibilityOracle; + $.providerEligibilityOracle = oracle; + emit ProviderEligibilityOracleSet(oldOracle, oracle); + } + + /// @inheritdoc IProviderEligibilityManagement + function getProviderEligibilityOracle() external view returns (IProviderEligibility) { + return _getStorage().providerEligibilityOracle; + } + + // -- IProviderEligibility -- + + /// @inheritdoc IProviderEligibility + /// @dev When no oracle is configured (address(0)), all providers are eligible. + /// When an oracle is set, delegates to the oracle's isEligible check. + function isEligible(address serviceProvider) external view override returns (bool eligible) { + IProviderEligibility oracle = _getStorage().providerEligibilityOracle; + eligible = (address(oracle) == address(0)) || oracle.isEligible(serviceProvider); + } + + // -- IRecurringAgreements -- + + /// @inheritdoc IRecurringAgreements + function getSumMaxNextClaim(IRecurringCollector collector, address provider) external view returns (uint256) { + return _getStorage().sumMaxNextClaim[address(collector)][provider]; + } + + /// @inheritdoc IRecurringAgreements + function getEscrowAccount( + IRecurringCollector collector, + address provider + ) external view returns (IPaymentsEscrow.EscrowAccount memory account) { + return _fetchEscrowAccount(address(collector), provider); + } + + /// @inheritdoc IRecurringAgreements + function getAgreementMaxNextClaim(bytes16 agreementId) external view returns (uint256) { + return _getStorage().agreements[agreementId].maxNextClaim; + } + + /// @inheritdoc IRecurringAgreements + function getAgreementInfo(bytes16 agreementId) external view returns (AgreementInfo memory) { + return _getStorage().agreements[agreementId]; + } + + /// @inheritdoc IRecurringAgreements + function getProviderAgreementCount(address provider) external view returns (uint256) { + return _getStorage().providerAgreementIds[provider].length(); + } + + /// @inheritdoc IRecurringAgreements + function getProviderAgreements(address provider) external view returns (bytes16[] memory) { + return _getStorage().providerAgreementIds[provider].getPageBytes16(0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreements + function getProviderAgreements( + address provider, + uint256 offset, + uint256 count + ) external view returns (bytes16[] memory) { + return _getStorage().providerAgreementIds[provider].getPageBytes16(offset, count); + } + + /// @inheritdoc IRecurringAgreements + function getEscrowBasis() external view returns (EscrowBasis) { + return _getStorage().escrowBasis; + } + + /// @inheritdoc IRecurringAgreements + function getSumMaxNextClaimAll() external view returns (uint256) { + return _getStorage().sumMaxNextClaimAll; + } + + /// @inheritdoc IRecurringAgreements + function getTotalEscrowDeficit() external view returns (uint256) { + return _getStorage().totalEscrowDeficit; + } + + /// @inheritdoc IRecurringAgreements + function getTotalAgreementCount() external view returns (uint256) { + return _getStorage().totalAgreementCount; + } + + /// @inheritdoc IRecurringAgreements + function isTempJit() external view returns (bool) { + return _getStorage().tempJit; + } + + /// @inheritdoc IRecurringAgreements + function getCollectorCount() external view returns (uint256) { + return _getStorage().collectors.length(); + } + + /// @inheritdoc IRecurringAgreements + function getCollectors() external view returns (address[] memory) { + return _getStorage().collectors.getPage(0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreements + function getCollectors(uint256 offset, uint256 count) external view returns (address[] memory) { + return _getStorage().collectors.getPage(offset, count); + } + + /// @inheritdoc IRecurringAgreements + function getCollectorProviderCount(address collector) external view returns (uint256) { + return _getStorage().collectorProviders[collector].length(); + } + + /// @inheritdoc IRecurringAgreements + function getCollectorProviders(address collector) external view returns (address[] memory) { + return _getStorage().collectorProviders[collector].getPage(0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreements + function getCollectorProviders( + address collector, + uint256 offset, + uint256 count + ) external view returns (address[] memory) { + return _getStorage().collectorProviders[collector].getPage(offset, count); + } + + /// @inheritdoc IRecurringAgreements + function getPairAgreementCount(address collector, address provider) external view returns (uint256) { + return _getStorage().pairAgreementCount[collector][provider]; + } + + // -- Internal Functions -- + + /** + * @notice Require that msg.sender is the agreement's collector. + * @param agreement The agreement info to check against + */ + function _requireCollector(AgreementInfo storage agreement) private view { + require(msg.sender == address(agreement.collector), OnlyAgreementCollector()); + } + + /** + * @notice Create agreement storage, authorize its hash, update pair tracking, and set max-next-claim. + * @param agreementId The generated agreement ID + * @param rca The recurring collection agreement parameters + * @param collector The collector contract + * @param agreementHash The hash of the RCA to authorize + * @return maxNextClaim The computed max-next-claim for the new agreement + */ + // solhint-disable-next-line use-natspec + function _createAgreement( + RecurringAgreementManagerStorage storage $, + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement calldata rca, + IRecurringCollector collector, + bytes32 agreementHash + ) private returns (uint256 maxNextClaim) { + $.authorizedHashes[agreementHash] = agreementId; + + $.agreements[agreementId] = AgreementInfo({ + provider: rca.serviceProvider, + deadline: rca.deadline, + pendingUpdateNonce: 0, + maxNextClaim: 0, + pendingUpdateMaxNextClaim: 0, + agreementHash: agreementHash, + pendingUpdateHash: bytes32(0), + dataService: IDataServiceAgreements(rca.dataService), + collector: collector + }); + $.providerAgreementIds[rca.serviceProvider].add(bytes32(agreementId)); + ++$.totalAgreementCount; + if (++$.pairAgreementCount[address(collector)][rca.serviceProvider] == 1) { + $.collectorProviders[address(collector)].add(rca.serviceProvider); + $.collectors.add(address(collector)); + } + + maxNextClaim = _computeMaxFirstClaim( + rca.maxOngoingTokensPerSecond, + rca.maxSecondsPerCollection, + rca.maxInitialTokens + ); + _setAgreementMaxNextClaim($, agreementId, maxNextClaim, false); + } + + /** + * @notice Compute maximum first claim from agreement rate parameters. + * @param maxOngoingTokensPerSecond Maximum ongoing tokens per second + * @param maxSecondsPerCollection Maximum seconds per collection period + * @param maxInitialTokens Maximum initial tokens + * @return Maximum possible claim amount + */ + function _computeMaxFirstClaim( + uint256 maxOngoingTokensPerSecond, + uint256 maxSecondsPerCollection, + uint256 maxInitialTokens + ) private pure returns (uint256) { + return maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens; + } + + /** + * @notice Reconcile an agreement and update escrow for its (collector, provider) pair. + * @param agreementId The agreement ID to reconcile + */ + // solhint-disable-next-line use-natspec + function _reconcileAndUpdateEscrow(RecurringAgreementManagerStorage storage $, bytes16 agreementId) private { + _reconcileAgreement($, agreementId); + AgreementInfo storage info = $.agreements[agreementId]; + _updateEscrow($, address(info.collector), info.provider); + } + + /** + * @notice Reconcile an agreement, update escrow, and delete if nothing left to claim. + * @param agreementId The agreement ID to reconcile + * @param agreement Storage pointer to the agreement info + * @return deleted True if the agreement was removed + */ + // solhint-disable-next-line use-natspec + function _reconcileAndCleanup( + RecurringAgreementManagerStorage storage $, + bytes16 agreementId, + AgreementInfo storage agreement + ) private returns (bool deleted) { + _reconcileAndUpdateEscrow($, agreementId); + if (agreement.maxNextClaim == 0) { + address provider = _deleteAgreement($, agreementId, agreement); + emit AgreementRemoved(agreementId, provider); + return true; + } + } + + /** + * @notice Reconcile a single agreement's max next claim against on-chain state + * @param agreementId The agreement ID to reconcile + */ + // solhint-disable-next-line use-natspec + function _reconcileAgreement(RecurringAgreementManagerStorage storage $, bytes16 agreementId) private { + AgreementInfo storage agreement = $.agreements[agreementId]; + + IRecurringCollector rc = agreement.collector; + IRecurringCollector.AgreementData memory rca = rc.getAgreement(agreementId); + + // Not yet accepted — keep the pre-offer estimate unless the deadline has passed + if (rca.state == IRecurringCollector.AgreementState.NotAccepted) { + if (block.timestamp <= agreement.deadline) return; + // Deadline passed: zero out so the caller can delete the expired offer + uint256 prev = agreement.maxNextClaim; + if (prev != 0) { + _setAgreementMaxNextClaim($, agreementId, 0, false); + emit AgreementReconciled(agreementId, prev, 0); + } + return; + } + + // Clear pending update if applied (updateNonce advanced) or unreachable (agreement canceled) + if ( + agreement.pendingUpdateHash != bytes32(0) && + (agreement.pendingUpdateNonce <= rca.updateNonce || + rca.state != IRecurringCollector.AgreementState.Accepted) + ) { + _setAgreementMaxNextClaim($, agreementId, 0, true); + delete $.authorizedHashes[agreement.pendingUpdateHash]; + agreement.pendingUpdateNonce = 0; + agreement.pendingUpdateHash = bytes32(0); + } + + uint256 oldMaxClaim = agreement.maxNextClaim; + uint256 newMaxClaim = rc.getMaxNextClaim(agreementId); + + if (oldMaxClaim != newMaxClaim) { + _setAgreementMaxNextClaim($, agreementId, newMaxClaim, false); + emit AgreementReconciled(agreementId, oldMaxClaim, newMaxClaim); + } + } + + /** + * @notice Delete an agreement: clean up hashes, zero escrow obligations, remove from provider set, and update escrow. + * @param agreementId The agreement ID to delete + * @param agreement Storage pointer to the agreement info + * @return provider The provider address (captured before deletion) + */ + // solhint-disable-next-line use-natspec + function _deleteAgreement( + RecurringAgreementManagerStorage storage $, + bytes16 agreementId, + AgreementInfo storage agreement + ) private returns (address provider) { + provider = agreement.provider; + IRecurringCollector collector = agreement.collector; + + // Clean up authorized hashes + delete $.authorizedHashes[agreement.agreementHash]; + if (agreement.pendingUpdateHash != bytes32(0)) delete $.authorizedHashes[agreement.pendingUpdateHash]; + + // Zero out escrow requirements before deleting + _setAgreementMaxNextClaim($, agreementId, 0, false); + _setAgreementMaxNextClaim($, agreementId, 0, true); + --$.totalAgreementCount; + $.providerAgreementIds[provider].remove(bytes32(agreementId)); + + --$.pairAgreementCount[address(collector)][provider]; + delete $.agreements[agreementId]; + + _reconcilePairTracking($, address(collector), provider); + } + + /** + * @notice Reconcile escrow then remove (collector, provider) tracking if fully drained. + * @dev Calls {_updateEscrow} to withdraw completed thaws, then removes the pair from + * tracking only when both pairAgreementCount and escrowSnap are zero. + * Cascades to remove the collector when it has no remaining providers. + * @return gone True if the pair is not tracked after this call + */ + // solhint-disable-next-line use-natspec + function _reconcilePairTracking( + RecurringAgreementManagerStorage storage $, + address collector, + address provider + ) private returns (bool gone) { + _updateEscrow($, collector, provider); + if ($.pairAgreementCount[collector][provider] != 0) return false; + if ($.escrowSnap[collector][provider] != 0) return false; + if ($.collectorProviders[collector].remove(provider)) { + emit CollectorProviderRemoved(collector, provider); + if ($.collectorProviders[collector].length() == 0) { + $.collectors.remove(collector); + emit CollectorRemoved(collector); + } + } + return true; + } + + /** + * @notice Atomically set one escrow obligation slot of an agreement and cascade to provider/global totals. + * @dev This and {_setEscrowSnap} are the only two functions that mutate totalEscrowDeficit. + * @param agreementId The agreement to update + * @param newValue The new obligation value + * @param pending If true, updates pendingUpdateMaxNextClaim; otherwise updates maxNextClaim + */ + // solhint-disable-next-line use-natspec + function _setAgreementMaxNextClaim( + RecurringAgreementManagerStorage storage $, + bytes16 agreementId, + uint256 newValue, + bool pending + ) private { + AgreementInfo storage agreement = $.agreements[agreementId]; + + uint256 oldValue = pending ? agreement.pendingUpdateMaxNextClaim : agreement.maxNextClaim; + if (oldValue == newValue) return; + + address collector = address(agreement.collector); + address provider = agreement.provider; + uint256 oldDeficit = _providerEscrowDeficit($, collector, provider); + + if (pending) agreement.pendingUpdateMaxNextClaim = newValue; + else agreement.maxNextClaim = newValue; + + $.sumMaxNextClaim[collector][provider] = $.sumMaxNextClaim[collector][provider] - oldValue + newValue; + $.sumMaxNextClaimAll = $.sumMaxNextClaimAll - oldValue + newValue; + $.totalEscrowDeficit = $.totalEscrowDeficit - oldDeficit + _providerEscrowDeficit($, collector, provider); + } + + /** + * @notice Compute escrow levels (min, max) based on escrow basis. + * @dev Escrow ladder: + * + * | Level | min (deposit floor) | max (thaw ceiling) | + * |------------|---------------------|--------------------| + * | Full | sumMaxNext | sumMaxNext | + * | OnDemand | 0 | sumMaxNext | + * | JustInTime | 0 | 0 | + * + * When tempJit, behaves as JustInTime regardless of configured basis. + * Full degrades to OnDemand when available balance <= totalEscrowDeficit. + * Full requires strictly more tokens on hand than the global deficit. + * + * @param collector The collector address + * @param provider The service provider + * @return min Deposit floor — deposit if balance is below this + * @return max Thaw ceiling — thaw if balance is above this + */ + // solhint-disable-next-line use-natspec + function _escrowMinMax( + RecurringAgreementManagerStorage storage $, + address collector, + address provider + ) private view returns (uint256 min, uint256 max) { + EscrowBasis basis = $.tempJit ? EscrowBasis.JustInTime : $.escrowBasis; + + max = basis == EscrowBasis.JustInTime ? 0 : $.sumMaxNextClaim[collector][provider]; + min = (basis == EscrowBasis.Full && $.totalEscrowDeficit < GRAPH_TOKEN.balanceOf(address(this))) ? max : 0; + } + + /** + * @notice Compute a (collector, provider) pair's escrow deficit: max(0, sumMaxNext - snapshot). + * @param collector The collector address + * @param provider The service provider + * @return deficit The amount not in escrow for this (collector, provider) + */ + // solhint-disable-next-line use-natspec + function _providerEscrowDeficit( + RecurringAgreementManagerStorage storage $, + address collector, + address provider + ) private view returns (uint256 deficit) { + uint256 sumMaxNext = $.sumMaxNextClaim[collector][provider]; + uint256 snapshot = $.escrowSnap[collector][provider]; + + deficit = (snapshot < sumMaxNext) ? sumMaxNext - snapshot : 0; + } + + /** + * @notice Update escrow state for a (collector, provider) pair: adjust thaw targets, + * withdraw completed thaws, thaw excess, or deposit deficit. + * @dev Sequential state normalization using (min, max) from {_escrowMinMax}: + * - min: deposit floor — deposit if effective balance (balance - tokensThawing) is below this + * - max: thaw ceiling — thaw effective balance above this, unless it would reset the thaw timer + * + * Steps: + * 1. Adjust thaw target — cancel/reduce unrealised thawing to keep min <= effective balance, + * or increase thawing to bring effective balance toward max (without resetting timer). + * 2. Withdraw completed thaw — realised thawing is always withdrawn, even if within [min, max]. + * 3. Thaw excess — if no thaw is active (possibly after a withdraw), start a new thaw for + * any balance above max. + * 4. Deposit deficit — if no thaw is active, deposit to reach min. + * + * Steps 3 and 4 are mutually exclusive (min <= max). Only one runs per call. + * The thaw timer is never reset: step 1 passes evenIfTimerReset=false, and steps 3/4 + * only run when tokensThawing == 0. + * + * Uses per-call approve (not infinite allowance). Safe because PaymentsEscrow + * is a trusted protocol contract that transfers exactly the approved amount. + * + * Updates escrow snapshot at the end for global tracking. + * + * @param collector The collector contract address + * @param provider The service provider to update escrow for + */ + // solhint-disable-next-line use-natspec + function _updateEscrow(RecurringAgreementManagerStorage storage $, address collector, address provider) private { + // Auto-recover from tempJit when balance exceeds deficit (same strict < as beforeCollection/escrowMinMax) + if ($.tempJit && $.totalEscrowDeficit < GRAPH_TOKEN.balanceOf(address(this))) { + $.tempJit = false; + emit TempJitSet(false, true); + } + + IPaymentsEscrow.EscrowAccount memory account = _fetchEscrowAccount(collector, provider); + (uint256 min, uint256 max) = _escrowMinMax($, collector, provider); + + // Defensive: PaymentsEscrow maintains tokensThawing <= balance, guard against external invariant breach + uint256 escrowed = account.tokensThawing < account.balance ? account.balance - account.tokensThawing : 0; + // Objectives in order of priority: + // We want to end with escrowed of at least min, and seek to thaw down to no more than max. + // 1. Do not reset thaw timer if a thaw is in progress. + // (This is to avoid thrash of restarting thaws resulting in never withdrawing excess.) + // 2. Make minimal adjustment to thawing tokens to get as close to min/max as possible. + // (First cancel unrealised thawing before depositing.) + uint256 thawTarget = (escrowed < min) + ? (min < account.balance ? account.balance - min : 0) + : (max < escrowed ? account.balance - max : account.tokensThawing); + if (thawTarget != account.tokensThawing) { + PAYMENTS_ESCROW.adjustThaw(collector, provider, thawTarget, false); + account = _fetchEscrowAccount(collector, provider); + } + + _withdrawAndRebalance(collector, provider, account, min, max); + _setEscrowSnap($, collector, provider); + } + + /** + * @notice Withdraw completed thaws and rebalance: thaw excess above max or deposit deficit below min. + * @dev Realised thawing is always withdrawn, even if within [min, max]. + * Then if no thaw is active: thaw any balance above max, or deposit to reach min. + * These last two steps are mutually exclusive (min <= max). Only one runs per call. + * @param collector The collector contract address + * @param provider Service provider address + * @param account Current escrow account state + * @param min Deposit floor + * @param max Thaw ceiling + */ + function _withdrawAndRebalance( + address collector, + address provider, + IPaymentsEscrow.EscrowAccount memory account, + uint256 min, + uint256 max + ) private { + // Withdraw any remaining thawed tokens (realised thawing is withdrawn even if within [min, max]) + if (0 < account.tokensThawing && account.thawEndTimestamp < block.timestamp) { + uint256 withdrawn = account.tokensThawing < account.balance ? account.tokensThawing : account.balance; + PAYMENTS_ESCROW.withdraw(collector, provider); + emit EscrowWithdrawn(provider, collector, withdrawn); + account = _fetchEscrowAccount(collector, provider); + } + + if (account.tokensThawing == 0) { + if (max < account.balance) + // Thaw excess above max (might have withdrawn allowing a new thaw to start) + PAYMENTS_ESCROW.adjustThaw(collector, provider, account.balance - max, false); + else { + // Deposit any deficit below min (deposit exactly the missing amount, no more) + uint256 deposit = (min < account.balance) ? 0 : min - account.balance; + if (0 < deposit) { + GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deposit); + PAYMENTS_ESCROW.deposit(collector, provider, deposit); + emit EscrowFunded(provider, collector, deposit); + } + } + } + } + + /** + * @notice Atomically sync the escrow snapshot for a (collector, provider) pair after escrow mutations. + * @dev This and {_setAgreementMaxNextClaim} are the only two functions that mutate totalEscrowDeficit. + * @param collector The collector address + * @param provider The service provider + */ + // solhint-disable-next-line use-natspec + function _setEscrowSnap(RecurringAgreementManagerStorage storage $, address collector, address provider) private { + uint256 oldEscrow = $.escrowSnap[collector][provider]; + uint256 newEscrow = _fetchEscrowAccount(collector, provider).balance; + if (oldEscrow == newEscrow) return; + + uint256 oldDeficit = _providerEscrowDeficit($, collector, provider); + $.escrowSnap[collector][provider] = newEscrow; + uint256 newDeficit = _providerEscrowDeficit($, collector, provider); + $.totalEscrowDeficit = $.totalEscrowDeficit - oldDeficit + newDeficit; + } + + // solhint-disable-next-line use-natspec + function _fetchEscrowAccount( + address collector, + address provider + ) private view returns (IPaymentsEscrow.EscrowAccount memory account) { + (account.balance, account.tokensThawing, account.thawEndTimestamp) = PAYMENTS_ESCROW.escrowAccounts( + address(this), + collector, + provider + ); + } + + /** + * @notice Get the ERC-7201 namespaced storage + */ + // solhint-disable-next-line use-natspec + function _getStorage() private pure returns (RecurringAgreementManagerStorage storage $) { + // solhint-disable-next-line no-inline-assembly + assembly { + $.slot := RECURRING_AGREEMENT_MANAGER_STORAGE_LOCATION + } + } +} diff --git a/packages/issuance/foundry.toml b/packages/issuance/foundry.toml index cfd6d9c04..9251965b5 100644 --- a/packages/issuance/foundry.toml +++ b/packages/issuance/foundry.toml @@ -3,6 +3,7 @@ src = 'contracts' out = 'forge-artifacts' libs = ["node_modules"] auto_detect_remappings = false +test = 'test' remappings = [ "@openzeppelin/=node_modules/@openzeppelin/", "@graphprotocol/=node_modules/@graphprotocol/", @@ -17,7 +18,7 @@ solc_version = '0.8.34' evm_version = 'cancun' # Exclude test files from coverage reports -no_match_coverage = "(^test/|/mocks/)" +no_match_coverage = "(^test/|^contracts/test/|/mocks/)" [lint] exclude_lints = ["mixed-case-function", "mixed-case-variable"] diff --git a/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol b/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol new file mode 100644 index 000000000..6e0eae7c3 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- beforeCollection -- + + function test_BeforeCollection_TopsUpWhenEscrowShort() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Simulate: escrow was partially drained (e.g. by a previous collection) + // The mock escrow has the full balance from offerAgreement, so we need to + // set up a scenario where balance < tokensToCollect. + // We'll just call beforeCollection with a large tokensToCollect. + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Mint more tokens so SAM has available balance to deposit + token.mint(address(agreementManager), 1000 ether); + + // Request more than current escrow balance + uint256 tokensToCollect = escrowBalance + 500 ether; + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, tokensToCollect); + + // Escrow should now have enough + (uint256 newBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(newBalance, tokensToCollect); + } + + function test_BeforeCollection_NoOpWhenEscrowSufficient() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + (uint256 escrowBefore, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Request less than current escrow — should be a no-op + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1 ether); + + (uint256 escrowAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(escrowAfter, escrowBefore); + } + + function test_BeforeCollection_Revert_WhenCallerNotRecurringCollector() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + agreementManager.beforeCollection(agreementId, 100 ether); + } + + function test_BeforeCollection_IgnoresUnknownAgreement() public { + bytes16 unknownId = bytes16(keccak256("unknown")); + + // Should not revert + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(unknownId, 100 ether); + } + + // -- afterCollection -- + + function test_AfterCollection_ReconcileAndFundEscrow() public { + // Offer: maxNextClaim = 1e18 * 3600 + 100e18 = 3700e18 + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3700 ether); + + // Simulate: agreement accepted and first collection happened + uint64 acceptedAt = uint64(block.timestamp); + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(agreementId, rca, acceptedAt, lastCollectionAt); + + vm.warp(lastCollectionAt); + + // Call afterCollection as RecurringCollector (simulates post-collect callback) + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 500 ether); + + // After first collection, maxInitialTokens no longer applies + // New max = 1e18 * 3600 = 3600e18 + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 3600 ether); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3600 ether); + } + + function test_AfterCollection_Revert_WhenCallerNotRecurringCollector() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + agreementManager.afterCollection(agreementId, 100 ether); + } + + function test_AfterCollection_IgnoresUnknownAgreement() public { + bytes16 unknownId = bytes16(keccak256("unknown")); + + // Should not revert — just silently return + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(unknownId, 100 ether); + } + + function test_AfterCollection_CanceledByServiceProvider() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + _setAgreementCanceledBySP(agreementId, rca); + + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol new file mode 100644 index 000000000..df6f44bc0 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/approver.t.sol @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- IAgreementOwner Tests -- + + function test_ApproveAgreement_ReturnsSelector() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + + bytes32 agreementHash = recurringCollector.hashRCA(rca); + bytes4 result = agreementManager.approveAgreement(agreementHash); + assertEq(result, IAgreementOwner.approveAgreement.selector); + } + + function test_ApproveAgreement_ReturnsZero_WhenNotAuthorized() public { + bytes32 fakeHash = keccak256("fake agreement"); + assertEq(agreementManager.approveAgreement(fakeHash), bytes4(0)); + } + + function test_ApproveAgreement_DifferentHashesAreIndependent() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + // Only offer rca1 + _offerAgreement(rca1); + + // rca1 hash should be authorized + bytes32 hash1 = recurringCollector.hashRCA(rca1); + assertEq(agreementManager.approveAgreement(hash1), IAgreementOwner.approveAgreement.selector); + + // rca2 hash should NOT be authorized + bytes32 hash2 = recurringCollector.hashRCA(rca2); + assertEq(agreementManager.approveAgreement(hash2), bytes4(0)); + } + + // -- ERC165 Tests -- + + function test_SupportsInterface_IIssuanceTarget() public view { + assertTrue(agreementManager.supportsInterface(type(IIssuanceTarget).interfaceId)); + } + + function test_SupportsInterface_IAgreementOwner() public view { + assertTrue(agreementManager.supportsInterface(type(IAgreementOwner).interfaceId)); + } + + function test_SupportsInterface_IRecurringAgreementManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringAgreementManagement).interfaceId)); + } + + function test_SupportsInterface_IRecurringEscrowManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringEscrowManagement).interfaceId)); + } + + function test_SupportsInterface_IProviderEligibilityManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IProviderEligibilityManagement).interfaceId)); + } + + function test_SupportsInterface_IRecurringAgreements() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringAgreements).interfaceId)); + } + + // -- IIssuanceTarget Tests -- + + function test_BeforeIssuanceAllocationChange_DoesNotRevert() public { + agreementManager.beforeIssuanceAllocationChange(); + } + + function test_SetIssuanceAllocator_OnlyGovernor() public { + address nonGovernor = makeAddr("nonGovernor"); + vm.expectRevert(); + vm.prank(nonGovernor); + agreementManager.setIssuanceAllocator(makeAddr("allocator")); + } + + function test_SetIssuanceAllocator_Governor() public { + vm.prank(governor); + agreementManager.setIssuanceAllocator(makeAddr("allocator")); + } + + // -- View Function Tests -- + + function test_GetDeficit_ZeroWhenFullyFunded() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + + // Fully funded (offerAgreement mints enough tokens) + IPaymentsEscrow.EscrowAccount memory account = agreementManager.getEscrowAccount(_collector(), indexer); + assertEq(account.balance - account.tokensThawing, agreementManager.getSumMaxNextClaim(_collector(), indexer)); + } + + function test_GetEscrowAccount_MatchesUnderlying() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + uint256 available = 500 ether; + + token.mint(address(agreementManager), available); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + + IPaymentsEscrow.EscrowAccount memory expected; + (expected.balance, expected.tokensThawing, expected.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + IPaymentsEscrow.EscrowAccount memory actual = agreementManager.getEscrowAccount(_collector(), indexer); + assertEq(actual.balance, expected.balance); + assertEq(actual.tokensThawing, expected.tokensThawing); + assertEq(actual.thawEndTimestamp, expected.thawEndTimestamp); + } + + function test_GetRequiredEscrow_ZeroForUnknownIndexer() public { + assertEq(agreementManager.getSumMaxNextClaim(_collector(), makeAddr("unknown")), 0); + } + + function test_GetAgreementMaxNextClaim_ZeroForUnknown() public view { + assertEq(agreementManager.getAgreementMaxNextClaim(bytes16(keccak256("unknown"))), 0); + } + + function test_GetIndexerAgreementCount_ZeroForUnknown() public { + assertEq(agreementManager.getProviderAgreementCount(makeAddr("unknown")), 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol new file mode 100644 index 000000000..1c91210ec --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_CancelAgreement_Accepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Simulate acceptance + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); + + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(agreementId); + assertFalse(gone); // still tracked after cancel + + // Verify the mock was called + assertTrue(mockSubgraphService.canceled(agreementId)); + assertEq(mockSubgraphService.cancelCallCount(agreementId), 1); + } + + function test_CancelAgreement_ReconcileAfterCancel() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint256 originalRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(originalRequired, maxClaim); + + // Accept, then cancel by SP (maxNextClaim -> 0) + _setAgreementCanceledBySP(agreementId, rca); + + // CanceledBySP has maxNextClaim=0 so agreement is deleted inline + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(agreementId); + assertTrue(gone); // deleted inline — nothing left to claim + + // After cancelAgreement (which now reconciles), required escrow should decrease + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_CancelAgreement_Idempotent_CanceledByPayer() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as CanceledByPayer (already canceled) + _setAgreementCanceledByPayer(agreementId, rca, uint64(block.timestamp), uint64(block.timestamp + 1 hours), 0); + + // Should succeed — idempotent, skips the external cancel call + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(agreementId); + assertFalse(gone); // still tracked after cancel + + // Should NOT have called SubgraphService + assertEq(mockSubgraphService.cancelCallCount(agreementId), 0); + } + + function test_CancelAgreement_Idempotent_CanceledByServiceProvider() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as CanceledByServiceProvider + _setAgreementCanceledBySP(agreementId, rca); + + // Should succeed — idempotent, reconciles to update escrow + // CanceledBySP has maxNextClaim=0 so agreement is deleted inline + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(agreementId); + assertTrue(gone); // deleted inline — nothing left to claim + + // Should NOT have called SubgraphService + assertEq(mockSubgraphService.cancelCallCount(agreementId), 0); + + // Required escrow should drop to 0 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_CancelAgreement_Revert_WhenNotAccepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Agreement is NotAccepted — should revert + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotAccepted.selector, agreementId)); + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + function test_CancelAgreement_ReturnsTrue_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); + + // Returns true (gone) when agreement not found + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(fakeId); + assertTrue(gone); + } + + function test_CancelAgreement_Revert_WhenNotOperator() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + bytes16 agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + address nonOperator = makeAddr("nonOperator"); + vm.expectRevert( + abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + ); + vm.prank(nonOperator); + agreementManager.cancelAgreement(agreementId); + } + + function test_CancelAgreement_Revert_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + function test_CancelAgreement_EmitsEvent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); + + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol new file mode 100644 index 000000000..33f9e5a16 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +/// @notice Tests that canceling an agreement correctly clears pending update escrow. +contract RecurringAgreementManagerCancelWithPendingUpdateTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice Demonstrates the bug: when an accepted agreement with a pending (unapplied) + /// update is canceled, the pendingUpdateMaxNextClaim escrow is NOT freed during + /// cancelAgreement. The escrow remains locked until the agreement is fully drained + /// and deleted, even though the update can never be accepted (collector rejects + /// updates on non-Accepted agreements). + function test_CancelAgreement_PendingUpdateEscrowNotFreed() public { + // 1. Offer and accept an agreement + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + uint64 acceptedAt = uint64(block.timestamp); + _setAgreementAccepted(agreementId, rca, acceptedAt); + + // 2. Offer an update (nonce=1) — reserves additional escrow + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq( + agreementManager.getSumMaxNextClaim(_collector(), indexer), + originalMaxClaim + pendingMaxClaim, + "both original and pending escrow should be reserved" + ); + + // 3. Cancel the agreement — simulate CanceledByPayer with remaining collection window. + // The collector still has a non-zero maxNextClaim (remaining window to collect). + // updateNonce is still 0 — the pending update was never applied. + uint64 canceledAt = uint64(block.timestamp + 1 hours); + vm.warp(canceledAt); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); + + // Call cancelAgreement — state is already CanceledByPayer so it skips the DS call + // and goes straight to reconcile-and-cleanup. + vm.prank(operator); + bool gone = agreementManager.cancelAgreement(agreementId); + assertFalse(gone, "agreement should still exist (has remaining claims)"); + + // 4. BUG: The pending update can never be accepted (collector rejects updates on + // canceled agreements), yet pendingUpdateMaxNextClaim is still reserved. + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + uint256 sumAfterCancel = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // The pending escrow should have been freed (zeroed) since the update is dead. + // This assertion demonstrates the bug — it will FAIL because the pending escrow + // is still included in sumMaxNextClaim. + assertEq( + info.pendingUpdateMaxNextClaim, + 0, + "BUG: pending update escrow should be zero after cancel (update can never be applied)" + ); + assertEq( + sumAfterCancel, + agreementManager.getAgreementMaxNextClaim(agreementId), + "BUG: sumMaxNextClaim should only include the base claim, not the dead pending update" + ); + } + + /// @notice After cancel + reconcile, pending update escrow and hash are fully cleared. + function test_CancelAgreement_PendingClearedAfterReconcile() public { + // 1. Offer and accept + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint64 acceptedAt = uint64(block.timestamp); + _setAgreementAccepted(agreementId, rca, acceptedAt); + + // 2. Offer update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + // 3. Cancel (CanceledByPayer, remaining window) + uint64 canceledAt = uint64(block.timestamp + 1 hours); + vm.warp(canceledAt); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); + + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + + // 4. Explicit reconcile — pending should already be cleared + agreementManager.reconcileAgreement(agreementId); + + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.pendingUpdateMaxNextClaim, 0, "pending escrow should be zero after cancel"); + assertEq(info.pendingUpdateNonce, 0, "pending nonce should be zero after cancel"); + assertEq(info.pendingUpdateHash, bytes32(0), "pending hash should be zero after cancel"); + + // 5. The dead update hash should no longer be authorized + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + bytes4 result = agreementManager.approveAgreement(updateHash); + assertTrue(result != agreementManager.approveAgreement.selector, "dead hash should not be authorized"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol new file mode 100644 index 000000000..e8d6c579e --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol @@ -0,0 +1,433 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockRecurringCollector internal collector2; + + function setUp() public override { + super.setUp(); + collector2 = new MockRecurringCollector(); + vm.label(address(collector2), "RecurringCollector2"); + + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(collector2)); + } + + // -- Helpers -- + + function _collector2() internal view returns (IRecurringCollector) { + return IRecurringCollector(address(collector2)); + } + + function _makeRCAForCollector( + MockRecurringCollector collector, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(agreementManager), + dataService: dataService, + serviceProvider: indexer, + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 3600, + nonce: nonce, + metadata: "" + }); + agreementId = collector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + } + + function _makeRCAForProvider( + address provider, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(agreementManager), + dataService: dataService, + serviceProvider: provider, + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 3600, + nonce: nonce, + metadata: "" + }); + agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + } + + function _offerForCollector( + MockRecurringCollector collector, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + } + + // -- Tests: Enumeration after offer -- + + function test_Cascade_SingleAgreement_PopulatesSets() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + _offerAgreement(rca); + + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectors()[0], address(recurringCollector)); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getCollectorProviders(address(recurringCollector))[0], indexer); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + } + + function test_Cascade_TwoAgreements_SamePair_CountIncrements() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); + _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(recurringCollector, 2); + _offerAgreement(rca2); + + // Sets still have one entry each, but pair count is 2 + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 2); + } + + function test_Cascade_MultiCollector_BothTracked() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); + _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(collector2, 2); + _offerForCollector(collector2, rca2); + + assertEq(agreementManager.getCollectorCount(), 2); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getCollectorProviderCount(address(collector2)), 1); + } + + function test_Cascade_MultiProvider_BothTracked() public { + address indexer2 = makeAddr("indexer2"); + + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForProvider(indexer, 1); + _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForProvider(indexer2, 2); + _offerAgreement(rca2); + + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 2); + } + + // -- Tests: Cascade on reconciliation -- + + function test_Cascade_ReconcileOneOfTwo_PairStaysTracked() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id1 = _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(recurringCollector, 2); + _offerAgreement(rca2); + + // Reconcile first (SP canceled → deleted) + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + // Pair still tracked + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + } + + function test_Cascade_ReconcileLast_PairStaysWhileEscrowThawing() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + + _setAgreementCanceledBySP(id, rca); + agreementManager.reconcileAgreement(id); + + // Agreement removed, but pair stays tracked while escrow is thawing + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); + assertEq(agreementManager.getCollectorCount(), 1, "collector stays tracked during thaw"); + assertEq( + agreementManager.getCollectorProviderCount(address(recurringCollector)), + 1, + "provider stays tracked during thaw" + ); + + // After thaw period, reconcileCollectorProvider reconciles escrow and removes + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.CollectorProviderRemoved(address(recurringCollector), indexer); + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.CollectorRemoved(address(recurringCollector)); + + assertFalse(agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer)); + + assertEq(agreementManager.getCollectorCount(), 0); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + } + + function test_Cascade_ReconcileLastProvider_CollectorCleanedUp_OtherCollectorRemains() public { + // Set up: collector1 with indexer, collector2 with indexer + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id1 = _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(collector2, 2); + _offerForCollector(collector2, rca2); + + // Reconcile collector1's agreement — pair stays tracked during thaw + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + assertEq(agreementManager.getCollectorCount(), 2, "both collectors tracked during thaw"); + assertEq( + agreementManager.getCollectorProviderCount(address(recurringCollector)), + 1, + "provider stays during thaw" + ); + + // After thaw period, reconcileCollectorProvider reconciles escrow and removes + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + + // collector1 cleaned up, collector2 remains + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectors()[0], address(collector2)); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + assertEq(agreementManager.getCollectorProviderCount(address(collector2)), 1); + } + + function test_Cascade_ReconcileProvider_CollectorRetainsOtherProvider() public { + address indexer2 = makeAddr("indexer2"); + + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForProvider(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForProvider(indexer2, 2); + _offerAgreement(rca2); + + // Reconcile indexer's agreement — pair stays tracked during thaw + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + assertEq(agreementManager.getCollectorCount(), 1); + assertEq( + agreementManager.getCollectorProviderCount(address(recurringCollector)), + 2, + "both providers tracked during thaw" + ); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer2), 1); + + // After thaw period, reconcileCollectorProvider reconciles escrow and removes + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + + // Now only indexer2 remains + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getCollectorProviders(address(recurringCollector))[0], indexer2); + } + + // -- Tests: Re-addition after cleanup -- + + function test_Cascade_ReaddAfterFullCleanup() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + + // Reconcile agreement — pair stays tracked during escrow thaw + _setAgreementCanceledBySP(id, rca); + agreementManager.reconcileAgreement(id); + assertEq(agreementManager.getCollectorCount(), 1, "stays tracked during thaw"); + + // After thaw period, full cleanup via reconcileCollectorProvider + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertEq(agreementManager.getCollectorCount(), 0); + + // Re-add — sets repopulate + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(recurringCollector, 2); + _offerAgreement(rca2); + + assertEq(agreementManager.getCollectorCount(), 1); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + } + + // -- Tests: Revoke also cascades -- + + function test_Cascade_RevokeOffer_DeferredCleanup() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + + assertEq(agreementManager.getCollectorCount(), 1); + + vm.prank(operator); + agreementManager.revokeOffer(id); + + // Agreement gone, but pair stays tracked during escrow thaw + assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); + assertEq(agreementManager.getCollectorCount(), 1, "stays tracked during thaw"); + + // After thaw period, reconcileCollectorProvider reconciles escrow and removes + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + + assertEq(agreementManager.getCollectorCount(), 0); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + } + + // -- Tests: Permissionless safety valve functions -- + + function test_ReconcileCollectorProvider_ReturnsTrue_WhenAgreementsExist() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + _offerAgreement(rca); + + // Exists: pair has agreements + bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertTrue(exists); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + } + + function test_ReconcileCollectorProvider_ReturnsFalse_WhenNotTracked() public { + // Not exists: pair was never added + bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertFalse(exists); + } + + function test_ReconcileCollectorProvider_ReturnsTrue_WhenEscrowThawing() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + + _setAgreementCanceledBySP(id, rca); + agreementManager.reconcileAgreement(id); + + // Exists: escrow still has pending thaw + bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertTrue(exists); + } + + function test_ReconcileCollectorProvider_ReturnsFalse_AfterThawPeriod() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + + _setAgreementCanceledBySP(id, rca); + agreementManager.reconcileAgreement(id); + + // After thaw period, reconcileCollectorProvider reconciles escrow internally + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertFalse(exists); + } + + function test_ReconcileCollectorProvider_Permissionless() public { + address anyone = makeAddr("anyone"); + vm.prank(anyone); + bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + assertFalse(exists); + } + + // -- Tests: Helper two-phase cleanup -- + + function test_Helper_ReconcilePair_FirstCallStartsThaw_SecondCallCompletes() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + // First call: reconciles agreement (deletes it), starts thaw, but pair stays + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists, "pair stays during thaw"); + + // Second call after thaw period: completes withdrawal and removes pair + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + (removed, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 0, "no agreements left to reconcile"); + assertFalse(pairExists, "pair gone after escrow recovered"); + } + + function test_Helper_ReconcileCollector_TwoPhase() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + // First call: reconciles agreement (deletes it), starts thaw + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + assertEq(removed, 1); + assertTrue(collectorExists, "collector stays during thaw"); + + // Second call after thaw: completes + vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); + (removed, collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + assertEq(removed, 0); + assertFalse(collectorExists, "collector gone after escrow recovered"); + } + + // -- Tests: Pagination -- + + function test_GetCollectors_Pagination() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); + _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(collector2, 2); + _offerForCollector(collector2, rca2); + + // Full list + address[] memory all = agreementManager.getCollectors(); + assertEq(all.length, 2); + + // Paginated + address[] memory first = agreementManager.getCollectors(0, 1); + assertEq(first.length, 1); + assertEq(first[0], all[0]); + + address[] memory second = agreementManager.getCollectors(1, 1); + assertEq(second.length, 1); + assertEq(second[0], all[1]); + + // Past end + address[] memory empty = agreementManager.getCollectors(2, 1); + assertEq(empty.length, 0); + } + + function test_GetCollectorProviders_Pagination() public { + address indexer2 = makeAddr("indexer2"); + + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForProvider(indexer, 1); + _offerAgreement(rca1); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForProvider(indexer2, 2); + _offerAgreement(rca2); + + // Full list + address[] memory all = agreementManager.getCollectorProviders(address(recurringCollector)); + assertEq(all.length, 2); + + // Paginated + address[] memory first = agreementManager.getCollectorProviders(address(recurringCollector), 0, 1); + assertEq(first.length, 1); + assertEq(first[0], all[0]); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol new file mode 100644 index 000000000..f492297da --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol @@ -0,0 +1,1261 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +/// @notice Edge case and boundary condition tests for RecurringAgreementManager. +contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ==================== supportsInterface Fallback ==================== + + function test_SupportsInterface_UnknownInterfaceReturnsFalse() public view { + // Use a random interfaceId that doesn't match any supported interface + // This exercises the super.supportsInterface() fallback (line 100) + assertFalse(agreementManager.supportsInterface(bytes4(0xdeadbeef))); + } + + function test_SupportsInterface_ERC165() public view { + // ERC165 itself (0x01ffc9a7) is supported via super.supportsInterface() + assertTrue(agreementManager.supportsInterface(type(IERC165).interfaceId)); + } + + // ==================== Cancel with Invalid Data Service ==================== + + function test_CancelAgreement_Revert_WhenDataServiceHasNoCode() public { + // Use an EOA as dataService so ds.code.length == 0 (line 255) + address eoa = makeAddr("eoa-data-service"); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.dataService = eoa; + + // Grant DATA_SERVICE_ROLE so the offer goes through + vm.prank(governor); + agreementManager.grantRole(DATA_SERVICE_ROLE, eoa); + + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + + // Set as Accepted so it takes the cancel-via-dataService path + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: eoa, + payer: address(agreementManager), + serviceProvider: indexer, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.InvalidDataService.selector, eoa)); + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + // ==================== Hash Cleanup Tests ==================== + + function test_RevokeOffer_CleansUpAgreementHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + bytes32 rcaHash = recurringCollector.hashRCA(rca); + + // Hash is authorized + assertEq(agreementManager.approveAgreement(rcaHash), IAgreementOwner.approveAgreement.selector); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + // Hash is cleaned up (not just stale — actually deleted) + assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); + } + + function test_RevokeOffer_CleansUpPendingUpdateHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + // Update hash is authorized + assertEq(agreementManager.approveAgreement(updateHash), IAgreementOwner.approveAgreement.selector); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + // Both hashes cleaned up + assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); + } + + function test_Remove_CleansUpAgreementHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + bytes32 rcaHash = recurringCollector.hashRCA(rca); + + // SP cancels — removable + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + // Hash is cleaned up + assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); + } + + function test_Remove_CleansUpPendingUpdateHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + + // SP cancels — removable + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + // Pending update hash also cleaned up + assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); + } + + function test_Reconcile_CleansUpAppliedPendingUpdateHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + assertEq(agreementManager.approveAgreement(updateHash), IAgreementOwner.approveAgreement.selector); + + // Simulate: agreement accepted with pending <= updateNonce (update was applied) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 7200, + updateNonce: 1, // (pending <=) + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + agreementManager.reconcileAgreement(agreementId); + + // Pending update hash should be cleaned up after reconcile clears the applied update + assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); + } + + function test_OfferUpdate_CleansUpReplacedPendingHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // First pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + bytes32 hash1 = recurringCollector.hashRCAU(rcau1); + assertEq(agreementManager.approveAgreement(hash1), IAgreementOwner.approveAgreement.selector); + + // Second pending update replaces first (same nonce — collector hasn't accepted either) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 180 days), + 1 + ); + _offerAgreementUpdate(rcau2); + + // First update hash should be cleaned up + assertEq(agreementManager.approveAgreement(hash1), bytes4(0)); + + // Second update hash should be authorized + bytes32 hash2 = recurringCollector.hashRCAU(rcau2); + assertEq(agreementManager.approveAgreement(hash2), IAgreementOwner.approveAgreement.selector); + } + + function test_GetAgreementInfo_IncludesHashes() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + bytes32 rcaHash = recurringCollector.hashRCA(rca); + + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.agreementHash, rcaHash); + assertEq(info.pendingUpdateHash, bytes32(0)); + + // Offer an update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.agreementHash, rcaHash); + assertEq(info.pendingUpdateHash, updateHash); + } + + // ==================== Zero-Value Parameter Tests ==================== + + function test_Offer_ZeroMaxInitialTokens() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 0, // zero initial tokens + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // maxNextClaim = 1e18 * 3600 + 0 = 3600e18 + uint256 expectedMaxClaim = 1 ether * 3600; + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); + } + + function test_Offer_ZeroOngoingTokensPerSecond() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 0, // zero ongoing rate + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // maxNextClaim = 0 * 3600 + 100e18 = 100e18 + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 100 ether); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 100 ether); + } + + function test_Offer_AllZeroValues() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 0, // zero initial + 0, // zero ongoing + 0, // zero min seconds + 0, // zero max seconds + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // maxNextClaim = 0 * 0 + 0 = 0 + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + // ==================== Deadline Boundary Tests ==================== + + function test_Remove_AtExactDeadline_NotAccepted() public { + uint64 deadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + // Override deadline (default from _makeRCA is block.timestamp + 1 hours, same as this) + + bytes16 agreementId = _offerAgreement(rca); + + // Warp to exactly the deadline + vm.warp(deadline); + + // At deadline (block.timestamp == deadline), the condition is `block.timestamp <= info.deadline` + // so this should still be claimable + bool exists = agreementManager.reconcileAgreement(agreementId); + assertTrue(exists); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_Remove_OneSecondAfterDeadline_NotAccepted() public { + uint64 deadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Warp to one second past deadline + vm.warp(deadline + 1); + + // Now removable (deadline < block.timestamp) + agreementManager.reconcileAgreement(agreementId); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + // ==================== Reconcile Edge Cases ==================== + + function test_Reconcile_WhenCollectionEndEqualsCollectionStart() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint64 now_ = uint64(block.timestamp); + // Set as accepted with lastCollectionAt == endsAt (fully consumed) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: now_, + lastCollectionAt: rca.endsAt, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + agreementManager.reconcileAgreement(agreementId); + + // getMaxNextClaim returns 0 when collectionEnd <= collectionStart + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + // ==================== Cancel Edge Cases ==================== + + function test_CancelAgreement_Revert_WhenDataServiceReverts() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as accepted + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // Configure the mock SubgraphService to revert + mockSubgraphService.setRevert(true, "SubgraphService: cannot cancel"); + + vm.expectRevert("SubgraphService: cannot cancel"); + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + // ==================== Offer With Zero Balance Tests ==================== + + function test_Offer_ZeroTokenBalance_PartialFunding() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + // Don't fund the contract — zero token balance + vm.prank(operator); + bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Agreement is tracked even though escrow couldn't be funded + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + + // Escrow has zero balance + (uint256 escrowBal,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + escrowBal, + 0 + ); + + // Escrow balance is 0 + assertEq(agreementManager.getEscrowAccount(_collector(), indexer).balance, 0); + } + + // ==================== ReconcileBatch Edge Cases ==================== + + function test_ReconcileBatch_InterleavedDuplicateIndexers() public { + // Create agreements for two different indexers, interleaved + address indexer2 = makeAddr("indexer2"); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCA( + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 365 days) + ); + rca3.nonce = 3; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + bytes16 id3 = _offerAgreement(rca3); + + // Accept all, then SP-cancel all + _setAgreementCanceledBySP(id1, rca1); + _setAgreementCanceledBySP(id2, rca2); + _setAgreementCanceledBySP(id3, rca3); + + // Interleaved order: indexer, indexer2, indexer + // The lastFunded optimization won't catch the second indexer occurrence + bytes16[] memory ids = new bytes16[](3); + ids[0] = id1; + ids[1] = id2; + ids[2] = id3; + + // Should succeed without error — _fundEscrow is idempotent + agreementHelper.reconcileBatch(ids); + + // All reconciled to 0 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), 0); + } + + function test_ReconcileBatch_EmptyArray() public { + // Empty batch should succeed with no effect + bytes16[] memory ids = new bytes16[](0); + agreementHelper.reconcileBatch(ids); + } + + function test_ReconcileBatch_NonExistentAgreements() public { + // Batch with non-existent IDs should skip silently + bytes16[] memory ids = new bytes16[](2); + ids[0] = bytes16(keccak256("nonexistent1")); + ids[1] = bytes16(keccak256("nonexistent2")); + + agreementHelper.reconcileBatch(ids); + } + + // ==================== UpdateEscrow Edge Cases ==================== + + function test_UpdateEscrow_FullThawWithdrawCycle() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Remove the agreement + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + // First reconcileCollectorProvider: initiates thaw + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Warp past mock's thawing period (1 day) + vm.warp(block.timestamp + 1 days + 1); + + // Second reconcileCollectorProvider: withdraws thawed tokens, then no more to thaw + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Third reconcileCollectorProvider: should be a no-op (nothing to thaw or withdraw) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + } + + // ==================== Multiple Pending Update Replacements ==================== + + // ==================== Zero-Value Pending Update Hash Cleanup ==================== + + function test_OfferUpdate_ZeroValuePendingUpdate_HashCleanedOnReplace() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Offer a zero-value pending update (both initial and ongoing are 0) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 0, // zero initial + 0, // zero ongoing + 60, + 3600, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + bytes32 zeroHash = recurringCollector.hashRCAU(rcau1); + // Zero-value hash should still be authorized + assertEq(agreementManager.approveAgreement(zeroHash), IAgreementOwner.approveAgreement.selector); + // sumMaxNextClaim should be unchanged (original + 0) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + + // Replace with a non-zero update (same nonce — collector hasn't accepted either) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau2); + + // Old zero-value hash should be cleaned up + assertEq(agreementManager.approveAgreement(zeroHash), bytes4(0)); + + // New hash should be authorized + bytes32 newHash = recurringCollector.hashRCAU(rcau2); + assertEq(agreementManager.approveAgreement(newHash), IAgreementOwner.approveAgreement.selector); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + } + + function test_Reconcile_ZeroValuePendingUpdate_ClearedWhenApplied() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer a zero-value pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 0, + 0, + 60, + 3600, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + bytes32 zeroHash = recurringCollector.hashRCAU(rcau); + assertEq(agreementManager.approveAgreement(zeroHash), IAgreementOwner.approveAgreement.selector); + + // Simulate: agreement accepted with update applied (pending nonce <= updateNonce) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 0, + maxOngoingTokensPerSecond: 0, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 3600, + updateNonce: 1, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + agreementManager.reconcileAgreement(agreementId); + + // Zero-value pending hash should be cleaned up + assertEq(agreementManager.approveAgreement(zeroHash), bytes4(0)); + + // Pending fields should be cleared + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.pendingUpdateMaxNextClaim, 0); + assertEq(info.pendingUpdateNonce, 0); + assertEq(info.pendingUpdateHash, bytes32(0)); + } + + // ==================== Re-offer After Remove ==================== + + function test_ReofferAfterRemove_FullLifecycle() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + // 1. Offer + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + + // 2. SP cancels and remove + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + + // 3. Re-offer the same agreement (same parameters, same agreementId) + bytes16 reofferedId = _offerAgreement(rca); + assertEq(reofferedId, agreementId); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + + // 4. Verify the re-offered agreement is fully functional + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(reofferedId); + assertTrue(info.provider != address(0)); + assertEq(info.provider, indexer); + assertEq(info.maxNextClaim, maxClaim); + + // Hash is authorized again + bytes32 rcaHash = recurringCollector.hashRCA(rca); + assertEq(agreementManager.approveAgreement(rcaHash), IAgreementOwner.approveAgreement.selector); + } + + function test_ReofferAfterRemove_WithDifferentNonce() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + bytes16 id1 = _offerAgreement(rca1); + + // Remove + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + // Re-offer with different nonce (different agreementId) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id2 = _offerAgreement(rca2); + assertTrue(id1 != id2); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + // ==================== Input Validation ==================== + + function test_Offer_Revert_ZeroServiceProvider() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.serviceProvider = address(0); + + token.mint(address(agreementManager), 1_000_000 ether); + vm.expectRevert(IRecurringAgreementManagement.ServiceProviderZeroAddress.selector); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + function test_Offer_Revert_ZeroDataService() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.dataService = address(0); + + token.mint(address(agreementManager), 1_000_000 ether); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0)) + ); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + // ==================== getProviderAgreements ==================== + + function test_GetIndexerAgreements_Empty() public { + bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + assertEq(ids.length, 0); + } + + function test_GetIndexerAgreements_SingleAgreement() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + assertEq(ids.length, 1); + assertEq(ids[0], agreementId); + } + + function test_GetIndexerAgreements_MultipleAgreements() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + assertEq(ids.length, 2); + // EnumerableSet maintains insertion order + assertEq(ids[0], id1); + assertEq(ids[1], id2); + } + + function test_GetIndexerAgreements_AfterRemoval() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + // Remove first agreement + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + assertEq(ids.length, 1); + assertEq(ids[0], id2); + } + + function test_GetIndexerAgreements_CrossIndexerIsolation() public { + address indexer2 = makeAddr("indexer2"); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + bytes16[] memory indexer1Ids = agreementManager.getProviderAgreements(indexer); + bytes16[] memory indexer2Ids = agreementManager.getProviderAgreements(indexer2); + + assertEq(indexer1Ids.length, 1); + assertEq(indexer1Ids[0], id1); + assertEq(indexer2Ids.length, 1); + assertEq(indexer2Ids[0], id2); + } + + function test_GetIndexerAgreements_Paginated() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + // Full range returns both + bytes16[] memory all = agreementManager.getProviderAgreements(indexer, 0, 10); + assertEq(all.length, 2); + assertEq(all[0], id1); + assertEq(all[1], id2); + + // Offset skips first + bytes16[] memory fromOne = agreementManager.getProviderAgreements(indexer, 1, 10); + assertEq(fromOne.length, 1); + assertEq(fromOne[0], id2); + + // Count limits result + bytes16[] memory firstOnly = agreementManager.getProviderAgreements(indexer, 0, 1); + assertEq(firstOnly.length, 1); + assertEq(firstOnly[0], id1); + } + + // ==================== Withdraw Timing Boundary (Issue 1) ==================== + + function test_UpdateEscrow_NoWithdrawAtExactThawEnd() public { + // At exactly thawEndTimestamp, PaymentsEscrow does NOT allow withdrawal + // (real contract: `block.timestamp <= thawEnd` returns 0). + // RecurringAgreementManager must not enter the withdraw branch at the boundary. + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // SP cancels — reconcile triggers thaw + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + IPaymentsEscrow.EscrowAccount memory accountBeforeWarp; + (accountBeforeWarp.balance, accountBeforeWarp.tokensThawing, accountBeforeWarp.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(accountBeforeWarp.tokensThawing, maxClaim, "All tokens should be thawing"); + uint256 thawEnd = accountBeforeWarp.thawEndTimestamp; + assertTrue(0 < thawEnd, "Thaw should be active"); + + // Warp to EXACTLY thawEndTimestamp (boundary) + vm.warp(thawEnd); + + // Record logs to verify no EscrowWithdrawn event + vm.recordLogs(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + Vm.Log[] memory entries = vm.getRecordedLogs(); + bytes32 withdrawSig = keccak256("EscrowWithdrawn(address,address,uint256)"); + for (uint256 i = 0; i < entries.length; i++) { + assertTrue( + entries[i].topics[0] != withdrawSig, + "EscrowWithdrawn must not be emitted at exact thawEndTimestamp" + ); + } + + // Escrow balance should be unchanged (still thawing) + IPaymentsEscrow.EscrowAccount memory accountAfter; + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(accountAfter.balance, maxClaim, "Balance unchanged at boundary"); + assertEq(accountAfter.tokensThawing, maxClaim, "Still thawing at boundary"); + } + + function test_UpdateEscrow_WithdrawsOneSecondAfterThawEnd() public { + // One second past thawEndTimestamp, withdrawal should succeed. + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + (,, uint256 thawEnd) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + + // Warp to thawEndTimestamp + 1 + vm.warp(thawEnd + 1); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Escrow should be empty + (uint256 finalBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + finalBalance, + 0 + ); + } + + // ==================== BeforeCollection Boundary (Issue 2) ==================== + + function test_BeforeCollection_NoOpWhenTokensToCollectEqualsBalance() public { + // When tokensToCollect == escrow balance, beforeCollection should be a no-op. + // Bug: current code uses strict '<', falling through when equal. + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + (uint256 escrowBalance,,) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertTrue(0 < escrowBalance, "Escrow should be funded"); + + // Drain manager's free token balance + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + assertEq(token.balanceOf(address(agreementManager)), 0, "Manager has no free tokens"); + + // Request exactly the escrow balance — no deficit exists + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance); + + // tempJit must NOT be set — there is no deficit + assertFalse(agreementManager.isTempJit(), "No tempJit when escrow exactly covers collection"); + } + + // ==================== Cancel Event Behavior ==================== + + function test_CancelAgreement_NoEvent_WhenAlreadyCanceled() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as already CanceledByServiceProvider + _setAgreementCanceledBySP(agreementId, rca); + + // Record logs to verify no AgreementCanceled event + vm.recordLogs(); + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + + // Check that no AgreementCanceled event was emitted + Vm.Log[] memory entries = vm.getRecordedLogs(); + bytes32 cancelEventSig = keccak256("AgreementCanceled(bytes16,address)"); + for (uint256 i = 0; i < entries.length; i++) { + assertTrue( + entries[i].topics[0] != cancelEventSig, + "AgreementCanceled should not be emitted on idempotent path" + ); + } + } + + function test_CancelAgreement_EmitsEvent_WhenAccepted() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); + + vm.prank(operator); + agreementManager.cancelAgreement(agreementId); + } + + // ==================== Multiple Pending Update Replacements ==================== + + function test_OfferUpdate_ThreeConsecutiveReplacements() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Update 1 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + uint256 pending1 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending1); + + // Update 2 replaces 1 (same nonce — collector hasn't accepted either) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 180 days), + 1 + ); + _offerAgreementUpdate(rcau2); + uint256 pending2 = 0.5 ether * 1800 + 50 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending2); + + // Update 3 replaces 2 (same nonce — collector still hasn't accepted) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau3 = _makeRCAU( + agreementId, + 300 ether, + 3 ether, + 60, + 3600, + uint64(block.timestamp + 1095 days), + 1 + ); + _offerAgreementUpdate(rcau3); + uint256 pending3 = 3 ether * 3600 + 300 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending3); + + // Only hash for update 3 should be authorized + bytes32 hash1 = recurringCollector.hashRCAU(rcau1); + bytes32 hash2 = recurringCollector.hashRCAU(rcau2); + bytes32 hash3 = recurringCollector.hashRCAU(rcau3); + + assertEq(agreementManager.approveAgreement(hash1), bytes4(0)); + assertEq(agreementManager.approveAgreement(hash2), bytes4(0)); + assertEq(agreementManager.approveAgreement(hash3), IAgreementOwner.approveAgreement.selector); + } + + // ==================== setTempJit No-Op ==================== + + function test_SetTempJit_NoopWhenAlreadyFalse() public { + // Default tempJit is false; setting false again should early-return with no event + vm.recordLogs(); + vm.prank(operator); + agreementManager.setTempJit(false); + + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue( + logs[i].topics[0] != IRecurringEscrowManagement.TempJitSet.selector, + "TempJitSet should not be emitted" + ); + } + assertFalse(agreementManager.isTempJit()); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/eligibility.t.sol b/packages/issuance/test/unit/agreement-manager/eligibility.t.sol new file mode 100644 index 000000000..ffc2f6fb5 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/eligibility.t.sol @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockEligibilityOracle } from "./mocks/MockEligibilityOracle.sol"; + +/// @notice Tests for payment eligibility oracle in RecurringAgreementManager +contract RecurringAgreementManagerEligibilityTest is RecurringAgreementManagerSharedTest { + MockEligibilityOracle internal oracle; + IProviderEligibility internal constant NO_ORACLE = IProviderEligibility(address(0)); + + function setUp() public override { + super.setUp(); + oracle = new MockEligibilityOracle(); + vm.label(address(oracle), "EligibilityOracle"); + } + + /* solhint-disable graph/func-name-mixedcase */ + + // -- setProviderEligibilityOracle tests -- + + function test_SetPaymentEligibilityOracle() public { + vm.expectEmit(address(agreementManager)); + emit IProviderEligibilityManagement.ProviderEligibilityOracleSet(NO_ORACLE, oracle); + + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + } + + function test_SetPaymentEligibilityOracle_DisableWithZeroAddress() public { + // First set an oracle + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + + // Then disable it + vm.expectEmit(address(agreementManager)); + emit IProviderEligibilityManagement.ProviderEligibilityOracleSet(oracle, NO_ORACLE); + + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(NO_ORACLE); + } + + function test_SetPaymentEligibilityOracle_NoopWhenSameOracle() public { + // Set oracle + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + + // Set same oracle again — early return, no event + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + + // Oracle still works (confirms state unchanged) + oracle.setEligible(indexer, true); + assertTrue(agreementManager.isEligible(indexer)); + } + + function test_SetPaymentEligibilityOracle_Revert_WhenNotGovernor() public { + vm.expectRevert(); + vm.prank(operator); + agreementManager.setProviderEligibilityOracle(oracle); + } + + function test_GetProviderEligibilityOracle_ReturnsZeroByDefault() public view { + assertEq(address(agreementManager.getProviderEligibilityOracle()), address(0)); + } + + function test_GetProviderEligibilityOracle_ReturnsSetOracle() public { + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + assertEq(address(agreementManager.getProviderEligibilityOracle()), address(oracle)); + } + + // -- isEligible passthrough tests -- + + function test_IsEligible_TrueWhenNoOracle() public view { + // No oracle set — all providers are eligible + assertTrue(agreementManager.isEligible(indexer)); + } + + function test_IsEligible_DelegatesToOracle_WhenEligible() public { + oracle.setEligible(indexer, true); + + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + + assertTrue(agreementManager.isEligible(indexer)); + } + + function test_IsEligible_DelegatesToOracle_WhenNotEligible() public { + // indexer not set as eligible, default is false + + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + + assertFalse(agreementManager.isEligible(indexer)); + } + + function test_IsEligible_TrueAfterOracleDisabled() public { + // Set oracle that denies indexer + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(oracle); + assertFalse(agreementManager.isEligible(indexer)); + + // Disable oracle + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(NO_ORACLE); + assertTrue(agreementManager.isEligible(indexer)); + } + + // -- ERC165 tests -- + + function test_SupportsInterface_IProviderEligibility() public view { + assertTrue(agreementManager.supportsInterface(type(IProviderEligibility).interfaceId)); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol new file mode 100644 index 000000000..960825dc6 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol @@ -0,0 +1,1544 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + address internal indexer2; + + function setUp() public virtual override { + super.setUp(); + indexer2 = makeAddr("indexer2"); + } + + // -- Helper -- + + function _makeRCAForIndexer( + address sp, + uint256 maxInitial, + uint256 maxOngoing, + uint32 maxSec, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + rca.serviceProvider = sp; + rca.nonce = nonce; + return rca; + } + + // ==================== setEscrowBasis ==================== + + function test_SetEscrowBasis_DefaultIsFull() public view { + assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); + } + + function test_SetEscrowBasis_OperatorCanSet() public { + vm.prank(operator); + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.EscrowBasisSet( + IRecurringEscrowManagement.EscrowBasis.Full, + IRecurringEscrowManagement.EscrowBasis.OnDemand + ); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand)); + } + + function test_SetEscrowBasis_Revert_WhenNotOperator() public { + vm.prank(governor); + vm.expectRevert(); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + } + + // ==================== Global Tracking ==================== + + function test_GlobalTracking_TotalRequired() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + _offerAgreement(rca1); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim1); + assertEq(agreementManager.getTotalAgreementCount(), 1); + + _offerAgreement(rca2); + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim1 + maxClaim2); + assertEq(agreementManager.getTotalAgreementCount(), 2); + } + + function test_GlobalTracking_TotalUndeposited() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + + // In Full mode, escrow is fully deposited — totalEscrowDeficit should be 0 + assertEq(agreementManager.getTotalEscrowDeficit(), 0, "Fully escrowed: totalEscrowDeficit = 0"); + } + + function test_GlobalTracking_TotalUndeposited_WhenPartiallyFunded() public { + // Offer in JIT mode (no deposits) — totalEscrowDeficit = sumMaxNextClaim + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + assertEq(agreementManager.getTotalEscrowDeficit(), maxClaim, "JIT: totalEscrowDeficit = sumMaxNextClaim"); + } + + function test_GlobalTracking_RevokeDecrementsCountAndRequired() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); + assertEq(agreementManager.getTotalAgreementCount(), 1); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + assertEq(agreementManager.getSumMaxNextClaimAll(), 0); + assertEq(agreementManager.getTotalAgreementCount(), 0); + } + + function test_GlobalTracking_RemoveDecrementsCountAndRequired() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + assertEq(agreementManager.getTotalAgreementCount(), 1); + + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + assertEq(agreementManager.getSumMaxNextClaimAll(), 0); + assertEq(agreementManager.getTotalAgreementCount(), 0); + } + + function test_GlobalTracking_ReconcileUpdatesRequired() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); + + // SP cancels — reconcile sets maxNextClaim to 0 + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + assertEq(agreementManager.getSumMaxNextClaimAll(), 0); + // Reconcile now deletes settled agreements inline + assertEq(agreementManager.getTotalAgreementCount(), 0); + } + + function test_GlobalTracking_TotalUndeposited_MultiProvider() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + _offerAgreement(rca1); + _offerAgreement(rca2); + + // In Full mode, both are fully deposited — totalEscrowDeficit should be 0 + assertEq(agreementManager.getTotalEscrowDeficit(), 0, "Both deposited: totalEscrowDeficit = 0"); + } + + function test_GlobalTracking_TotalUndeposited_OverdepositedProviderDoesNotMaskDeficit() public { + // Regression test: over-deposited provider must NOT mask another provider's deficit. + // Offer rca1 for indexer (gets fully deposited) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca1); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + + // Drain SAM so indexer2's agreement can't be deposited + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + // Offer rca2 for indexer2 (can't be deposited) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // indexer is fully deposited (undeposited = 0), indexer2 has full deficit (undeposited = maxClaim2) + // totalEscrowDeficit must be maxClaim2, NOT 0 (the old buggy sumMaxNextClaim - totalInEscrow approach + // would compute sumMaxNextClaim = maxClaim1 + maxClaim2, totalInEscrow = maxClaim1, + // deficit = maxClaim2 — which happens to be correct here, but would be wrong if indexer + // were over-deposited and the excess masked indexer2's deficit) + assertEq(agreementManager.getTotalEscrowDeficit(), maxClaim2, "Undeposited = indexer2's full deficit"); + + // Verify per-provider escrow state + assertEq( + paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), + maxClaim1, + "indexer: fully deposited" + ); + assertEq( + paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer2), + 0, + "indexer2: undeposited" + ); + } + + // ==================== Full Mode (default — existing behavior) ==================== + + function test_FullMode_DepositsFullRequired() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + assertEq(paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), maxClaim); + } + + function test_FullMode_ThawsExcess() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + + // SP cancels, remove (triggers thaw of all excess) + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance - account.tokensThawing, 0, "Full mode: all excess should be thawing"); + } + + // ==================== JustInTime Mode ==================== + + function test_JustInTime_ThawsEverything() public { + // Start in Full mode, offer agreement (gets deposited) + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Switch to JustInTime + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + // Update escrow — should thaw everything + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, maxClaim, "JustInTime: all balance should be thawing"); + } + + function test_JustInTime_NoProactiveDeposit() public { + // Switch to JustInTime before offering + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + + // No deposit should have been made + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance, 0, "JustInTime: no proactive deposit"); + } + + function test_JustInTime_JITStillWorks() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Escrow is 0, but beforeCollection should top up + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 500 ether); + + (uint256 newBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(newBalance, 500 ether, "JustInTime: JIT should deposit requested amount"); + } + + // ==================== OnDemand Mode ==================== + + function test_OnDemand_NoProactiveDeposit() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + + // No deposit — same as JustInTime for deposits + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance, 0, "OnDemand: no proactive deposit"); + } + + function test_OnDemand_HoldsAtRequiredLevel() public { + // Fund with Full mode first, then switch to OnDemand + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // OnDemand thaw ceiling = required — no thaw expected (balance == thawCeiling) + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, 0, "OnDemand: no thaw (balance == required == thawCeiling)"); + assertEq(account.balance, maxClaim, "OnDemand: balance held at required level"); + } + + function test_OnDemand_PreservesThawFromJIT() public { + // Fund 6 agreements at Full level, then switch JIT -> OnDemand + for (uint256 i = 1; i <= 6; i++) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + i + ); + _offerAgreement(rca); + } + + uint256 maxClaimEach = 1 ether * 3600 + 100 ether; + uint256 sumMaxNextClaim = maxClaimEach * 6; + + // JustInTime would thaw everything + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory jitAccount; + (jitAccount.balance, jitAccount.tokensThawing, jitAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(jitAccount.tokensThawing, sumMaxNextClaim, "JustInTime: thaws everything"); + + // Switch to OnDemand — min=0, min <= liquid=0, so thaw is left alone + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory odAccount; + (odAccount.balance, odAccount.tokensThawing, odAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + // OnDemand: min=0, min(0) <= liquid(0) — existing thaw preserved, no unnecessary cancellation + assertEq(odAccount.tokensThawing, jitAccount.tokensThawing, "OnDemand preserves thaw when min <= liquid"); + } + + function test_OnDemand_JITStillWorks() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // No deposit, but JIT works + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 500 ether); + + (uint256 newBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(newBalance, 500 ether, "OnDemand: JIT should work"); + } + + // ==================== Degradation: Full -> OnDemand ==================== + + function test_Degradation_FullToOnDemand_WhenInsufficientBalance() public { + // Offer agreement for indexer1 that consumes most available funds + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca1); + + // Offer 6 agreements for indexer2, each with large maxClaim + // SAM won't have enough for all of them at Full level + for (uint256 i = 1; i <= 6; i++) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer2, + 100_000 ether, + 100 ether, + 7200, + i + 10 + ); + token.mint(address(agreementManager), 100_000 ether); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + // sumMaxNextClaim should be larger than totalEscrowDeficit (degradation occurred: Full -> OnDemand) + assertTrue(0 < agreementManager.getTotalEscrowDeficit(), "Degradation: some undeposited deficit exists"); + } + + function test_Degradation_NeverReachesJustInTime() public { + // Even with severe underfunding, degradation stops at OnDemand (thaw ceiling = required) + // and never reaches JustInTime (thaw ceiling = 0) + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Balance should still be at maxClaim (thaw ceiling = required) + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance, maxClaim, "Balance preserved - degradation doesn't go to JustInTime"); + assertEq(account.tokensThawing, 0, "No thaw - not at JustInTime"); + } + + // ==================== Mode Switch Doesn't Break State ==================== + + function test_ModeSwitch_PreservesAgreements() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Switch through all modes — agreement data preserved + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_ModeSwitch_UpdateEscrowAppliesNewMode() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + assertEq(paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), maxClaim); + + // Switch to JustInTime and update escrow + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, maxClaim, "JustInTime should thaw all"); + } + + // ==================== JIT (beforeCollection) Works in All Modes ==================== + + function test_JIT_WorksInFullMode() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + token.mint(address(agreementManager), 10000 ether); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + uint256 tokensToCollect = escrowBalance + 500 ether; + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, tokensToCollect); + + (uint256 newBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(newBalance, tokensToCollect, "JIT top-up should cover collection in Full mode"); + } + + // ==================== afterCollection Reconciles in All Modes ==================== + + function test_AfterCollection_ReconcileInOnDemandMode() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + uint64 acceptedAt = uint64(block.timestamp); + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(agreementId, rca, acceptedAt, lastCollectionAt); + vm.warp(lastCollectionAt); + + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 500 ether); + + uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + assertEq(newMaxClaim, 1 ether * 3600, "maxNextClaim = ongoing only after first collection"); + } + + // ==================== PendingUpdate with sumMaxNextClaim tracking ==================== + + function test_GlobalTracking_PendingUpdate() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim); + } + + function test_GlobalTracking_ReplacePendingUpdate() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + uint256 pendingMaxClaim1 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim1); + + // Replace with different terms (same nonce — collector hasn't accepted either) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 180 days), + 1 + ); + _offerAgreementUpdate(rcau2); + + uint256 pendingMaxClaim2 = 0.5 ether * 1800 + 50 ether; + assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim2); + } + + // ==================== Upward Transitions ==================== + + function test_Transition_JustInTimeToFull() public { + // Start in JIT (no deposits), switch to Full (deposits required) + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Verify no deposit in JIT mode + assertEq( + paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), + 0, + "JIT: no deposit" + ); + + // Switch to Full + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + assertEq( + paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), + maxClaim, + "Full: deposits required" + ); + } + + function test_Transition_OnDemandToFull() public { + // Fund at Full, switch to OnDemand (holds at required), switch back to Full + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Switch to OnDemand — holds at required (no thaw for 1 agreement) + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory odAccount; + (odAccount.balance, odAccount.tokensThawing, odAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(odAccount.balance, maxClaim, "OnDemand: balance held at required"); + + // Switch back to Full — no change needed (already at required) + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory fullAccount; + (fullAccount.balance, fullAccount.tokensThawing, fullAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(fullAccount.balance, maxClaim, "Full: at required"); + } + + // ==================== Thaw-In-Progress Transitions ==================== + + function test_Transition_FullToJustInTime_WhileThawActive() public { + // Create agreements, cancel one to start a thaw, then switch to JIT + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaimEach = 1 ether * 3600 + 100 ether; + + // Cancel and remove rca1 — this triggers a thaw for excess + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + IPaymentsEscrow.EscrowAccount memory beforeSwitch; + (beforeSwitch.balance, beforeSwitch.tokensThawing, beforeSwitch.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertTrue(0 < beforeSwitch.tokensThawing, "Thaw in progress before switch"); + assertEq(beforeSwitch.tokensThawing, maxClaimEach, "Thawing excess from removed agreement"); + + // Switch to JustInTime while thaw is active — existing thaw continues, + // remaining balance thaws after current thaw completes and is withdrawn + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory midCycle; + (midCycle.balance, midCycle.tokensThawing, midCycle.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + // Same-block increase is fine (no timer reset) — thaws everything + assertEq(midCycle.tokensThawing, 2 * maxClaimEach, "Same-block: thaw increased to full balance"); + + // Complete thaw, withdraw all + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory afterWithdraw; + (afterWithdraw.balance, afterWithdraw.tokensThawing, afterWithdraw.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + // Everything withdrawn in one cycle + assertEq(afterWithdraw.balance, 0, "JIT: all withdrawn"); + assertEq(afterWithdraw.tokensThawing, 0, "JIT: nothing left to thaw"); + } + + // ==================== Temp JIT ==================== + + function test_TempJit_TripsOnPartialBeforeCollection() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain SAM's token balance so beforeCollection can't fully fund + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + // Request collection exceeding escrow balance + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(true, true); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + + // Verify state + assertTrue(agreementManager.isTempJit(), "Temp JIT should be tripped"); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis unchanged (temp JIT overrides behavior, not escrowBasis)" + ); + } + + function test_BeforeCollection_TripsWhenAvailableEqualsDeficit() public { + // Boundary: available == deficit — strict '<' means trip, not deposit + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Set manager balance to exactly the escrow shortfall + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 tokensToCollect = escrowBalance + 500 ether; + uint256 deficit = tokensToCollect - escrowBalance; // 500 ether + + // Drain SAM then mint exactly the deficit + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + token.mint(address(agreementManager), deficit); + assertEq(token.balanceOf(address(agreementManager)), deficit, "Balance == deficit"); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(true, true); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, tokensToCollect); + + assertTrue(agreementManager.isTempJit(), "Trips when available == deficit"); + } + + function test_BeforeCollection_DepositsWhenAvailableExceedsDeficit() public { + // Boundary: available == deficit + 1 — deposits instead of tripping + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 tokensToCollect = escrowBalance + 500 ether; + uint256 deficit = tokensToCollect - escrowBalance; // 500 ether + + // Drain SAM then mint deficit + 1 + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + token.mint(address(agreementManager), deficit + 1); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, tokensToCollect); + + assertFalse(agreementManager.isTempJit(), "No trip when deficit < available"); + (uint256 newEscrow, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(newEscrow, tokensToCollect, "Escrow topped up to tokensToCollect"); + } + + function test_TempJit_PreservesBasisOnTrip() public { + // Set OnDemand, trip — escrowBasis should NOT change + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain SAM + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(true, true); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + + // Basis stays OnDemand (not switched to JIT) + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), + "Basis unchanged during trip" + ); + assertTrue(agreementManager.isTempJit()); + } + + function test_TempJit_DoesNotTripWhenFullyCovered() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Ensure SAM has plenty of tokens + token.mint(address(agreementManager), 1_000_000 ether); + + // Request less than escrow balance — no trip + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, maxClaim); + + assertFalse(agreementManager.isTempJit(), "No trip when fully covered"); + } + + function test_TempJit_DoesNotTripWhenAlreadyActive() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain SAM + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + // First trip + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Second partial collection — should NOT emit event again + vm.recordLogs(); + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + + // Check no TempJitSet event was emitted + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 tripSig = keccak256("TempJitSet(bool,bool)"); + bool found = false; + for (uint256 i = 0; i < logs.length; i++) { + if (logs[i].topics[0] == tripSig) found = true; + } + assertFalse(found, "No second trip event"); + } + + function test_TempJit_TripsEvenWhenAlreadyJustInTime() public { + // Governor explicitly sets JIT + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain SAM so beforeCollection can't cover + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + + assertTrue(agreementManager.isTempJit(), "Trips even in JIT mode"); + } + + function test_TempJit_JitStillWorksWhileActive() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain SAM to trip the breaker + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Now fund SAM and do a JIT top-up while temp JIT is active + token.mint(address(agreementManager), 500 ether); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 500 ether); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertTrue(maxClaim <= escrowBalance, "JIT still works during temp JIT"); + } + + function test_TempJit_RecoveryOnUpdateEscrow() public { + // Offer rca1 (fully deposited), drain SAM, offer rca2 (creates undeposited deficit) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca1); + + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + + // Trip temp JIT + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Mint more than totalEscrowDeficit — recovery requires strict deficit < available + uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); + assertTrue(0 < totalEscrowDeficit, "Deficit exists"); + token.mint(address(agreementManager), totalEscrowDeficit + 1); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(false, true); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + assertFalse(agreementManager.isTempJit(), "Temp JIT recovered"); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis still Full" + ); + } + + function test_TempJit_NoRecoveryWhenPartiallyFunded() public { + // Offer rca1 (fully deposited), drain, offer rca2 (undeposited — creates deficit) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca1); + + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + + // Trip + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); + assertTrue(0 < totalEscrowDeficit, "0 < totalEscrowDeficit"); + + // Mint less than totalEscrowDeficit — no recovery + token.mint(address(agreementManager), totalEscrowDeficit / 2); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + assertTrue(agreementManager.isTempJit(), "Still tripped (insufficient balance)"); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis unchanged" + ); + } + + function test_TempJit_NoRecoveryWhenExactlyFunded() public { + // Boundary: available == totalEscrowDeficit — strict '<' means no recovery + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca1); + + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + + // Trip + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Mint exactly totalEscrowDeficit — recovery requires strict deficit < available + uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); + assertTrue(0 < totalEscrowDeficit, "Deficit exists"); + token.mint(address(agreementManager), totalEscrowDeficit); + assertEq(token.balanceOf(address(agreementManager)), totalEscrowDeficit, "Balance == deficit"); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + assertTrue(agreementManager.isTempJit(), "Still tripped (available == deficit, not >)"); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis unchanged" + ); + } + + function test_TempJit_EscrowBasisPreservedDuringTrip() public { + // Set OnDemand, trip, recover — escrowBasis stays OnDemand throughout + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain and trip + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), + "Basis preserved during trip" + ); + + // Recovery — mint more than deficit (recovery requires strict deficit < available) + token.mint(address(agreementManager), agreementManager.getSumMaxNextClaimAll() + 1); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(false, true); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertFalse(agreementManager.isTempJit()); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), + "Basis still OnDemand after recovery" + ); + } + + function test_TempJit_SetTempJitClearsBreaker() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain and trip + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Operator clears tempJit directly + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.TempJitSet(false, false); + + vm.prank(operator); + agreementManager.setTempJit(false); + + assertFalse(agreementManager.isTempJit(), "Operator cleared breaker"); + } + + function test_TempJit_SetEscrowBasisDoesNotClearBreaker() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Drain and trip + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Operator changes basis — tempJit stays active + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + assertTrue(agreementManager.isTempJit(), "setEscrowBasis does not clear tempJit"); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), + "Basis changed independently" + ); + } + + function test_TempJit_MultipleTripRecoverCycles() public { + // Offer rca1 (deposited), drain SAM, offer rca2 (undeposited — creates deficit) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca1); + + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + + uint256 undeposited = agreementManager.getTotalEscrowDeficit(); + assertTrue(0 < undeposited, "Has undeposited deficit"); + + // --- Cycle 1: Trip --- + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // --- Cycle 1: Recover (mint more than deficit — recovery requires strict deficit < available) --- + token.mint(address(agreementManager), undeposited + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertFalse(agreementManager.isTempJit()); + assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); + + // After recovery, reconcileCollectorProvider deposited into escrow. Drain again and create new deficit. + samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 3 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca3, _collector()); + + undeposited = agreementManager.getTotalEscrowDeficit(); + assertTrue(0 < undeposited, "New undeposited deficit"); + + // --- Cycle 2: Trip --- + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // --- Cycle 2: Recover (mint more than deficit) --- + token.mint(address(agreementManager), undeposited + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertFalse(agreementManager.isTempJit()); + assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); + } + + function test_TempJit_MultiProvider() public { + // Offer rca1 (deposited), drain SAM, offer rca2 (creates deficit → 0 < totalEscrowDeficit) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 id1 = _offerAgreement(rca1); + + // Drain SAM so rca2 can't be deposited + uint256 samBalance = token.balanceOf(address(agreementManager)); + if (0 < samBalance) { + vm.prank(address(agreementManager)); + token.transfer(address(1), samBalance); + } + + // Offer rca2 directly (no mint) — escrow stays undeposited, creates deficit + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 100 ether, + 1 ether, + 3600, + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, _collector()); + assertTrue(0 < agreementManager.getTotalEscrowDeficit(), "should have undeposited escrow"); + + // Trip via indexer's agreement + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(id1, 1_000_000 ether); + assertTrue(agreementManager.isTempJit()); + + // Both providers should see JIT behavior (thaw everything) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + + IPaymentsEscrow.EscrowAccount memory acc1; + (acc1.balance, acc1.tokensThawing, acc1.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + IPaymentsEscrow.EscrowAccount memory acc2; + (acc2.balance, acc2.tokensThawing, acc2.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 + ); + + // Both providers should be thawing (JIT mode via temp JIT) + assertEq(acc1.tokensThawing, acc1.balance, "indexer: JIT thaws all"); + assertEq(acc2.tokensThawing, acc2.balance, "indexer2: JIT thaws all"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol new file mode 100644 index 000000000..7825282fc --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- offerAgreement -- + + function testFuzz_Offer_MaxNextClaimCalculation( + uint128 maxInitialTokens, + uint128 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection + ) public { + // Bound to avoid overflow: uint128 * uint32 fits in uint256 + vm.assume(0 < maxSecondsPerCollection); + + uint64 endsAt = uint64(block.timestamp + 365 days); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitialTokens, + maxOngoingTokensPerSecond, + 60, + maxSecondsPerCollection, + endsAt + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint256 expectedMaxClaim = uint256(maxOngoingTokensPerSecond) * uint256(maxSecondsPerCollection) + + uint256(maxInitialTokens); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); + } + + function testFuzz_Offer_EscrowFundedUpToAvailable( + uint128 maxInitialTokens, + uint128 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + uint256 availableTokens + ) public { + vm.assume(0 < maxSecondsPerCollection); + availableTokens = bound(availableTokens, 0, 10_000_000 ether); + + uint64 endsAt = uint64(block.timestamp + 365 days); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitialTokens, + maxOngoingTokensPerSecond, + 60, + maxSecondsPerCollection, + endsAt + ); + + // Fund with a specific amount instead of the default 1M ether + token.mint(address(agreementManager), availableTokens); + vm.prank(operator); + bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + + uint256 maxNextClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + (uint256 escrowBalance,,) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + + // In Full mode (default): + // If totalEscrowDeficit < available: Full deposits required (there is buffer). + // Otherwise (available <= totalEscrowDeficit): degrades to OnDemand (no buffer, deposit target = 0). + // JIT beforeCollection is the safety net for underfunded escrow. + if (maxNextClaim < availableTokens) { + assertEq(escrowBalance, maxNextClaim); + } else { + // Degraded to OnDemand: no deposit (no buffer or insufficient) + assertEq(escrowBalance, 0); + } + } + + function testFuzz_Offer_RequiredEscrowIncrements( + uint64 maxInitial1, + uint64 maxOngoing1, + uint32 maxSec1, + uint64 maxInitial2, + uint64 maxOngoing2, + uint32 maxSec2 + ) public { + vm.assume(0 < maxSec1 && 0 < maxSec2); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + maxInitial1, + maxOngoing1, + 60, + maxSec1, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + maxInitial2, + maxOngoing2, + 60, + maxSec2, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + _offerAgreement(rca1); + uint256 required1 = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + _offerAgreement(rca2); + uint256 required2 = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + uint256 maxClaim1 = uint256(maxOngoing1) * uint256(maxSec1) + uint256(maxInitial1); + uint256 maxClaim2 = uint256(maxOngoing2) * uint256(maxSec2) + uint256(maxInitial2); + + assertEq(required1, maxClaim1); + assertEq(required2, maxClaim1 + maxClaim2); + } + + // -- revokeOffer / reconcileAgreement -- + + function testFuzz_RevokeOffer_RequiredEscrowDecrements(uint64 maxInitial, uint64 maxOngoing, uint32 maxSec) public { + vm.assume(0 < maxSec); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 requiredBefore = agreementManager.getSumMaxNextClaim(_collector(), indexer); + assertTrue(0 < requiredBefore || (maxInitial == 0 && maxOngoing == 0)); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function testFuzz_Remove_AfterSPCancel_ClearsState(uint64 maxInitial, uint64 maxOngoing, uint32 maxSec) public { + vm.assume(0 < maxSec); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + _setAgreementCanceledBySP(agreementId, rca); + + agreementManager.reconcileAgreement(agreementId); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + } + + // -- reconcile -- + + function testFuzz_Reconcile_AfterCollection_UpdatesRequired( + uint64 maxInitial, + uint64 maxOngoing, + uint32 maxSec, + uint32 timeElapsed + ) public { + vm.assume(0 < maxSec); + vm.assume(0 < maxOngoing); + timeElapsed = uint32(bound(timeElapsed, 1, maxSec)); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 preAcceptRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // Simulate acceptance and a collection at block.timestamp + timeElapsed + uint64 acceptedAt = uint64(block.timestamp); + uint64 collectionAt = uint64(block.timestamp + timeElapsed); + _setAgreementCollected(agreementId, rca, acceptedAt, collectionAt); + + // Warp to collection time + vm.warp(collectionAt); + + agreementManager.reconcileAgreement(agreementId); + + uint256 postReconcileRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // After collection, the maxNextClaim should reflect remaining window (no initial tokens) + // and should be <= the pre-acceptance estimate + assertTrue(postReconcileRequired <= preAcceptRequired); + } + + // -- offerAgreementUpdate -- + + function testFuzz_OfferUpdate_DoubleFunding( + uint64 maxInitial, + uint64 maxOngoing, + uint32 maxSec, + uint64 updateMaxInitial, + uint64 updateMaxOngoing, + uint32 updateMaxSec + ) public { + vm.assume(0 < maxSec && 0 < updateMaxSec); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint256 originalMaxClaim = uint256(maxOngoing) * uint256(maxSec) + uint256(maxInitial); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + updateMaxInitial, + updateMaxOngoing, + 60, + updateMaxSec, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = uint256(updateMaxOngoing) * uint256(updateMaxSec) + uint256(updateMaxInitial); + + // Both original and pending are funded simultaneously + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + } + + // -- reconcileAgreement deadline -- + + function testFuzz_Remove_ExpiredOffer_DeadlineBoundary(uint32 extraTime) public { + extraTime = uint32(bound(extraTime, 1, 365 days)); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Before deadline: should return true (still claimable) + bool exists = agreementManager.reconcileAgreement(agreementId); + assertTrue(exists); + + // Warp past deadline + vm.warp(rca.deadline + extraTime); + + // After deadline: should succeed + agreementManager.reconcileAgreement(agreementId); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + // -- getEscrowAccount -- + + function testFuzz_GetEscrowAccount_MatchesUnderlying(uint128 maxOngoing, uint32 maxSec, uint128 available) public { + vm.assume(0 < maxSec); + vm.assume(0 < maxOngoing); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 0, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + + token.mint(address(agreementManager), available); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + + IPaymentsEscrow.EscrowAccount memory expected; + (expected.balance, expected.tokensThawing, expected.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + IPaymentsEscrow.EscrowAccount memory actual = agreementManager.getEscrowAccount(_collector(), indexer); + + assertEq(actual.balance, expected.balance); + assertEq(actual.tokensThawing, expected.tokensThawing); + assertEq(actual.thawEndTimestamp, expected.thawEndTimestamp); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/helper.t.sol b/packages/issuance/test/unit/agreement-manager/helper.t.sol new file mode 100644 index 000000000..29f83ec55 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/helper.t.sol @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementHelper } from "../../../contracts/agreement/RecurringAgreementHelper.sol"; +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- Constructor tests -- + + function test_Constructor_SetsManager() public view { + assertEq(address(agreementHelper.MANAGER()), address(agreementManager)); + } + + function test_Constructor_Revert_ZeroAddress() public { + vm.expectRevert(RecurringAgreementHelper.ZeroAddress.selector); + new RecurringAgreementHelper(address(0), token); + } + + // -- reconcile(provider) tests -- + + function test_Reconcile_AllAgreementsForIndexer() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + // Cancel agreement 1 by SP + _setAgreementCanceledBySP(id1, rca1); + + // Accept agreement 2 (collected once) + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(id2, rca2, uint64(block.timestamp), lastCollectionAt); + vm.warp(lastCollectionAt); + + // Fund for reconcile + token.mint(address(agreementManager), 1_000_000 ether); + + agreementHelper.reconcile(indexer); + + // Agreement 1: CanceledBySP -> maxClaim = 0 + assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); + // Agreement 2: collected, remaining window large, capped at maxSecondsPerCollection = 7200 + // maxClaim = 2e18 * 7200 = 14400e18 (no initial since collected) + assertEq(agreementManager.getAgreementMaxNextClaim(id2), 14400 ether); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14400 ether); + } + + function test_Reconcile_EmptyProvider() public { + // reconcile for a provider with no agreements — should be a no-op + address unknown = makeAddr("unknown"); + agreementHelper.reconcile(unknown); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), unknown), 0); + } + + function test_Reconcile_IdempotentWhenUnchanged() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as accepted + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // First reconcile + agreementHelper.reconcile(indexer); + uint256 escrowAfterFirst = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 maxClaimAfterFirst = agreementManager.getAgreementMaxNextClaim(agreementId); + + // Second reconcile should produce identical results (idempotent) + vm.recordLogs(); + agreementHelper.reconcile(indexer); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), escrowAfterFirst); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaimAfterFirst); + + // No reconcile event on the second call since nothing changed + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 reconciledTopic = keccak256("AgreementReconciled(bytes16,uint256,uint256)"); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue(logs[i].topics[0] != reconciledTopic, "Unexpected AgreementReconciled event on idempotent call"); + } + } + + function test_Reconcile_MultipleAgreements_MixedStates() public { + // Three agreements for the same indexer, each in a different state + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCA( + 0, + 3 ether, + 60, + 1800, + uint64(block.timestamp + 365 days) + ); + rca3.nonce = 3; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + bytes16 id3 = _offerAgreement(rca3); + + // id1: Canceled by SP -> maxClaim = 0 + _setAgreementCanceledBySP(id1, rca1); + + // id2: Accepted, collected -> no initial tokens + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(id2, rca2, uint64(block.timestamp), lastCollectionAt); + + // id3: Not yet accepted -> keep pre-offer estimate + // (default mock returns NotAccepted) + + vm.warp(lastCollectionAt); + token.mint(address(agreementManager), 1_000_000 ether); + + agreementHelper.reconcile(indexer); + + assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); + assertEq(agreementManager.getAgreementMaxNextClaim(id2), 14400 ether); // 2e18 * 7200 + // id3 unchanged: 3e18 * 1800 = 5400e18 (pre-offer estimate) + assertEq(agreementManager.getAgreementMaxNextClaim(id3), 5400 ether); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14400 ether + 5400 ether); + } + + // -- reconcileBatch tests -- + + function test_ReconcileBatch_BasicBatch() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1 + maxClaim2); + + // Accept both and simulate CanceledBySP on agreement 1 + _setAgreementCanceledBySP(id1, rca1); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + // Reconcile both in batch + bytes16[] memory ids = new bytes16[](2); + ids[0] = id1; + ids[1] = id2; + agreementHelper.reconcileBatch(ids); + + // Agreement 1 canceled by SP -> maxNextClaim = 0 + assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); + // Agreement 2 accepted, never collected -> maxNextClaim = initial + ongoing + assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + // Required should be just agreement 2 now + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); + } + + function test_ReconcileBatch_SkipsNonExistent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 realId = _offerAgreement(rca); + bytes16 fakeId = bytes16(keccak256("nonexistent")); + + // Accept to enable reconciliation + _setAgreementAccepted(realId, rca, uint64(block.timestamp)); + + // Batch with a nonexistent id — should not revert + bytes16[] memory ids = new bytes16[](2); + ids[0] = fakeId; + ids[1] = realId; + agreementHelper.reconcileBatch(ids); + + // Real agreement should still be tracked + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getAgreementMaxNextClaim(realId), maxClaim); + } + + function test_ReconcileBatch_Empty() public { + // Empty array — should succeed silently + bytes16[] memory ids = new bytes16[](0); + agreementHelper.reconcileBatch(ids); + } + + function test_ReconcileBatch_CrossIndexer() public { + address indexer2 = makeAddr("indexer2"); + + // Agreement 1 for default indexer + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + // Agreement 2 for indexer2 + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + + // Cancel both by SP + _setAgreementCanceledBySP(id1, rca1); + _setAgreementCanceledBySP(id2, rca2); + + bytes16[] memory ids = new bytes16[](2); + ids[0] = id1; + ids[1] = id2; + agreementHelper.reconcileBatch(ids); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), 0); + } + + function test_ReconcileBatch_Permissionless() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // Anyone can call + address anyone = makeAddr("anyone"); + bytes16[] memory ids = new bytes16[](1); + ids[0] = agreementId; + vm.prank(anyone); + agreementHelper.reconcileBatch(ids); + } + + function test_ReconcileBatch_ClearsPendingUpdate() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer a pending update (nonce 1) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + + // Simulate: accepted with the update already applied (pending <= updateNonce) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rcau.endsAt, + maxInitialTokens: rcau.maxInitialTokens, + maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, + minSecondsPerCollection: rcau.minSecondsPerCollection, + maxSecondsPerCollection: rcau.maxSecondsPerCollection, + updateNonce: 1, // matches pending nonce, so update was applied + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + bytes16[] memory ids = new bytes16[](1); + ids[0] = agreementId; + agreementHelper.reconcileBatch(ids); + + // Pending should be cleared; required escrow should be based on new terms + uint256 newMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), newMaxClaim); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol new file mode 100644 index 000000000..f957eee9f --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockRecurringCollector internal collector2; + address internal indexer2; + + function setUp() public override { + super.setUp(); + collector2 = new MockRecurringCollector(); + vm.label(address(collector2), "RecurringCollector2"); + indexer2 = makeAddr("indexer2"); + + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(collector2)); + } + + // -- Helpers -- + + function _makeRCAForCollector( + MockRecurringCollector collector, + address provider, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(agreementManager), + dataService: dataService, + serviceProvider: provider, + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 3600, + nonce: nonce, + metadata: "" + }); + } + + function _offerForCollector( + MockRecurringCollector collector, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + } + + // -- Tests: auditGlobal -- + + function test_AuditGlobal_EmptyState() public view { + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(g.tokenBalance, 0); + assertEq(g.sumMaxNextClaimAll, 0); + assertEq(g.totalEscrowDeficit, 0); + assertEq(g.totalAgreementCount, 0); + assertEq(uint256(g.escrowBasis), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); + assertFalse(g.tempJit); + assertEq(g.collectorCount, 0); + } + + function test_AuditGlobal_WithAgreements() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(g.sumMaxNextClaimAll, maxClaim); + assertEq(g.totalAgreementCount, 1); + assertEq(g.collectorCount, 1); + // Token balance is the minted amount minus what was deposited to escrow + assertTrue(0 < g.tokenBalance); + } + + function test_AuditGlobal_MultiCollector() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector(collector2, indexer, 2); + _offerForCollector(collector2, rca2); + + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 2); + assertEq(g.collectorCount, 2); + } + + // -- Tests: auditPair -- + + function test_AuditPair_NonExistent() public view { + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.collector, address(recurringCollector)); + assertEq(p.provider, indexer); + assertEq(p.agreementCount, 0); + assertEq(p.sumMaxNextClaim, 0); + assertEq(p.escrow.balance, 0); + } + + function test_AuditPair_WithAgreement() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.agreementCount, 1); + assertEq(p.sumMaxNextClaim, maxClaim); + assertEq(p.escrow.balance, maxClaim); // Full mode deposits all + } + + function test_AuditPair_EscrowThawing() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + + // Cancel by SP to make maxNextClaim = 0, then reconcile (thaw starts) + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + // sumMaxNextClaim should be 0 after reconcile + assertEq(p.sumMaxNextClaim, 0); + // Escrow should be thawing + assertTrue(0 < p.escrow.tokensThawing); + } + + // -- Tests: auditPairs -- + + function test_AuditPairs_EmptyCollector() public view { + IRecurringAgreementHelper.PairAudit[] memory pairs = agreementHelper.auditPairs(address(recurringCollector)); + assertEq(pairs.length, 0); + } + + function test_AuditPairs_MultiplePairs() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector( + recurringCollector, + indexer2, + 2 + ); + _offerAgreement(rca2); + + IRecurringAgreementHelper.PairAudit[] memory pairs = agreementHelper.auditPairs(address(recurringCollector)); + assertEq(pairs.length, 2); + // Both should have agreementCount = 1 + assertEq(pairs[0].agreementCount, 1); + assertEq(pairs[1].agreementCount, 1); + } + + function test_AuditPairs_Paginated() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector( + recurringCollector, + indexer2, + 2 + ); + _offerAgreement(rca2); + + // First page + IRecurringAgreementHelper.PairAudit[] memory first = agreementHelper.auditPairs( + address(recurringCollector), + 0, + 1 + ); + assertEq(first.length, 1); + + // Second page + IRecurringAgreementHelper.PairAudit[] memory second = agreementHelper.auditPairs( + address(recurringCollector), + 1, + 1 + ); + assertEq(second.length, 1); + + // Past end + IRecurringAgreementHelper.PairAudit[] memory empty = agreementHelper.auditPairs( + address(recurringCollector), + 2, + 1 + ); + assertEq(empty.length, 0); + } + + function test_AuditPairs_IsolatesCollectors() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector(collector2, indexer, 2); + _offerForCollector(collector2, rca2); + + IRecurringAgreementHelper.PairAudit[] memory c1Pairs = agreementHelper.auditPairs(address(recurringCollector)); + assertEq(c1Pairs.length, 1); + + IRecurringAgreementHelper.PairAudit[] memory c2Pairs = agreementHelper.auditPairs(address(collector2)); + assertEq(c2Pairs.length, 1); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol new file mode 100644 index 000000000..8a56264f2 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol @@ -0,0 +1,368 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockRecurringCollector internal collector2; + address internal indexer2; + + function setUp() public override { + super.setUp(); + collector2 = new MockRecurringCollector(); + vm.label(address(collector2), "RecurringCollector2"); + indexer2 = makeAddr("indexer2"); + + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(collector2)); + } + + // -- Helpers -- + + function _makeRCAFor( + address provider, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca) { + rca = _makeRCA(100 ether, 1 ether, 60, 3600, uint64(block.timestamp + 365 days)); + rca.serviceProvider = provider; + rca.nonce = nonce; + } + + function _offerForCollector( + MockRecurringCollector collector, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + } + + function _setCanceledBySPOnCollector( + MockRecurringCollector collector, + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal { + collector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: uint64(block.timestamp), + state: IRecurringCollector.AgreementState.CanceledByServiceProvider + }) + ); + } + + // -- Tests: reconcile (provider) -- + + function test_Reconcile_RemovesCanceledBySP() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_Reconcile_SkipsStillClaimable() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementAccepted(id, rca, uint64(block.timestamp)); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_Reconcile_MixedStates() public { + // Agreement 1: canceled by SP (removable) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Agreement 2: still active (not removable) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + bytes16 id2 = _offerAgreement(rca2); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_Reconcile_EmptyProvider() public { + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 0); + } + + function test_Reconcile_ExpiredOffer() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + _offerAgreement(rca); + + // Warp past deadline + vm.warp(rca.deadline + 1); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_Reconcile_Permissionless() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + address anyone = makeAddr("anyone"); + vm.prank(anyone); + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + } + + // -- Tests: reconcilePair -- + + function test_ReconcilePair_RemovesAgreementButPairStaysWhileThawing() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); // escrow still thawing — pair stays tracked + + // Drain escrow, then pair can be removed + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertFalse(pairExists); + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + } + + function test_ReconcilePair_PairExistsWhenAgreementsRemain() public { + // Two agreements, only one removable + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + bytes16 id2 = _offerAgreement(rca2); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); + } + + function test_ReconcilePair_IsolatesCollectors() public { + // Collector1 + indexer: canceled (removable) + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Collector2 + indexer: active (not removable) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + rca2.dataService = dataService; + _offerForCollector(collector2, rca2); + + // Reconcile only collector1's pair — escrow still thawing + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); // escrow still thawing + + // Collector2's agreement untouched + assertEq(agreementManager.getPairAgreementCount(address(collector2), indexer), 1); + } + + // -- Tests: reconcileCollector -- + + function test_ReconcileCollector_AllPairs() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer2, 2); + bytes16 id2 = _offerAgreement(rca2); + _setAgreementCanceledBySP(id2, rca2); + + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + assertEq(removed, 2); + assertTrue(collectorExists); // escrow still thawing for both pairs + + // Drain escrows, then collector can be removed + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + + (, collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + assertFalse(collectorExists); + assertEq(agreementManager.getCollectorCount(), 0); + } + + function test_ReconcileCollector_PartialCleanup() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Active agreement — not removable + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer2, 2); + bytes16 id2 = _offerAgreement(rca2); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + assertEq(removed, 1); + assertTrue(collectorExists); // indexer2 still has an active agreement + } + + // -- Tests: reconcileAll -- + + function test_ReconcileAll_FullSweep() public { + // Collector1 + indexer + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Collector2 + indexer + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + bytes16 id2 = _offerForCollector(collector2, rca2); + _setCanceledBySPOnCollector(collector2, id2, rca2); + + uint256 removed = agreementHelper.reconcileAll(); + assertEq(removed, 2); + assertEq(agreementManager.getTotalAgreementCount(), 0); + assertEq(agreementManager.getCollectorCount(), 2); // escrow still thawing + + // Drain escrows, then collectors can be removed + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(collector2), indexer); + + agreementHelper.reconcileAll(); + assertEq(agreementManager.getCollectorCount(), 0); + } + + function test_ReconcileAll_EmptyState() public { + uint256 removed = agreementHelper.reconcileAll(); + assertEq(removed, 0); + } + + function test_ReconcileAll_PartialCleanup() public { + // Removable + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Not removable + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer2, 2); + bytes16 id2 = _offerAgreement(rca2); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + uint256 removed = agreementHelper.reconcileAll(); + assertEq(removed, 1); + assertEq(agreementManager.getTotalAgreementCount(), 1); + } + + // -- Tests: reconcilePair (value reconciliation + cleanup) -- + + function test_ReconcilePair_OnlyReconcilesPairAgreements() public { + // Collector1 + indexer: cancel by SP + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + // Collector2 + indexer: still active (same provider, different collector) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + _offerForCollector(collector2, rca2); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Before reconcile, collector1's pair still has the old maxNextClaim + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + + // Reconcile only collector1's pair + (uint256 removed, ) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + + // Collector1's pair reconciled to 0 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + + // Collector2's pair untouched + assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), maxClaim); + } + + // -- Tests: reconcileAll (value reconciliation + cleanup) -- + + function test_ReconcileAll_AllCollectorsAllProviders() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor(indexer, 1); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor(indexer, 2); + bytes16 id2 = _offerForCollector(collector2, rca2); + _setCanceledBySPOnCollector(collector2, id2, rca2); + + uint256 removed = agreementHelper.reconcileAll(); + assertEq(removed, 2); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), 0); + } + + // -- Tests: reconcile does reconcile+cleanup in single pass -- + + function test_Reconcile_ReconcilesThenRemoves() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + // Set as CanceledBySP — after reconcile, maxNextClaim=0, then removable + _setAgreementCanceledBySP(id, rca); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_Reconcile_NoopWhenAllActive() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementAccepted(id, rca, uint64(block.timestamp)); + + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + // -- Tests: reconcilePair does reconcile+cleanup+pair removal -- + + function test_ReconcilePair_RemovesAgreementAndPairAfterThaw() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); + bytes16 id = _offerAgreement(rca); + _setAgreementCanceledBySP(id, rca); + + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); // escrow still thawing + + // Drain escrow, then pair can be removed + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertFalse(pairExists); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol new file mode 100644 index 000000000..843d929ea --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol @@ -0,0 +1,476 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + uint256 internal constant THAW_PERIOD = 1 days; + + MockRecurringCollector internal collector2; + address internal indexer2; + + function setUp() public override { + super.setUp(); + collector2 = new MockRecurringCollector(); + vm.label(address(collector2), "RecurringCollector2"); + indexer2 = makeAddr("indexer2"); + + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(collector2)); + } + + // -- Helpers -- + + function _makeRCAFor( + MockRecurringCollector, + address provider, + uint256 maxInitial, + uint256 maxOngoing, + uint32 maxSec, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(agreementManager), + dataService: dataService, + serviceProvider: provider, + maxInitialTokens: maxInitial, + maxOngoingTokensPerSecond: maxOngoing, + minSecondsPerCollection: 60, + maxSecondsPerCollection: maxSec, + nonce: nonce, + metadata: "" + }); + } + + function _offerForCollector( + MockRecurringCollector collector, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + } + + function _setCanceledBySPOnCollector( + MockRecurringCollector collector, + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal { + collector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: uint64(block.timestamp), + state: IRecurringCollector.AgreementState.CanceledByServiceProvider + }) + ); + } + + // -- Tests: Single Agreement Full Lifecycle -- + + function test_Lifecycle_OfferAcceptCancelReconcileCleanup() public { + // 1. Start empty + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 0); + + // 2. Offer + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // 3. Audit: agreement tracked, escrow deposited + g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 1); + assertEq(g.sumMaxNextClaimAll, maxClaim); + assertEq(g.collectorCount, 1); + + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.agreementCount, 1); + assertEq(p.sumMaxNextClaim, maxClaim); + assertEq(p.escrow.balance, maxClaim); // Full mode + + // 4. Accept + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // 5. Simulate first collection + vm.warp(block.timestamp + 1800); + _setAgreementCollected(agreementId, rca, uint64(block.timestamp - 1800), uint64(block.timestamp)); + + // 6. Reconcile — maxInitialTokens drops out after first collection + agreementHelper.reconcile(indexer); + uint256 reducedMaxClaim = 1 ether * 3600; // no more initial + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), reducedMaxClaim); + + // 7. Cancel by SP + _setAgreementCanceledBySP(agreementId, rca); + + // 8. Reconcile + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + + // 9. Agreements gone, but escrow still thawing — collector stays tracked + g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 0); + assertEq(g.sumMaxNextClaimAll, 0); + assertEq(g.collectorCount, 1); // still tracked — escrow not yet drained + + // 10. Escrow is thawing + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertTrue(0 < p.escrow.tokensThawing); + + // 11. Wait for thaw and withdraw + vm.warp(block.timestamp + THAW_PERIOD + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, 0); + assertEq(p.escrow.tokensThawing, 0); + + // 12. Now that escrow is drained, reconcilePair removes tracking + agreementHelper.reconcilePair(address(recurringCollector), indexer); + + g = agreementHelper.auditGlobal(); + assertEq(g.collectorCount, 0); // fully cleaned up + } + + // -- Tests: Escrow Basis Changes -- + + function test_Lifecycle_EscrowBasisChange_FullToOnDemand() public { + // Offer in Full mode — escrow deposited + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, maxClaim); + assertEq(p.escrow.tokensThawing, 0); + + // Switch to OnDemand + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(uint256(g.escrowBasis), uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand)); + + // reconcileCollectorProvider — OnDemand has min=0, max=sumMaxNextClaim. + // Balance == max so no thaw needed (balanced) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + // In OnDemand with balance == max, no thaw + assertEq(p.escrow.balance, maxClaim); + + // Switch to JustInTime — should start thawing everything + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.tokensThawing, maxClaim); // thawing everything + + // Wait for thaw and withdraw + vm.warp(block.timestamp + THAW_PERIOD + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, 0); + + // Switch back to Full — should deposit again + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, maxClaim); + assertEq(p.escrow.tokensThawing, 0); + } + + // -- Tests: Multi-Collector Multi-Provider -- + + function test_Lifecycle_MultiCollectorMultiProvider() public { + // Offer: collector1+indexer, collector1+indexer2, collector2+indexer + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 id1 = _offerAgreement(rca1); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor( + recurringCollector, + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + bytes16 id2 = _offerAgreement(rca2); + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCAFor( + collector2, + indexer, + 50 ether, + 0.5 ether, + 1800, + 3 + ); + bytes16 id3 = _offerForCollector(collector2, rca3); + uint256 maxClaim3 = 0.5 ether * 1800 + 50 ether; + + // Audit global + IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 3); + assertEq(g.sumMaxNextClaimAll, maxClaim1 + maxClaim2 + maxClaim3); + assertEq(g.collectorCount, 2); + + // Audit pairs per collector + IRecurringAgreementHelper.PairAudit[] memory c1Pairs = agreementHelper.auditPairs(address(recurringCollector)); + assertEq(c1Pairs.length, 2); + + IRecurringAgreementHelper.PairAudit[] memory c2Pairs = agreementHelper.auditPairs(address(collector2)); + assertEq(c2Pairs.length, 1); + assertEq(c2Pairs[0].sumMaxNextClaim, maxClaim3); + + // Accept all, cancel collector1+indexer by SP + _setAgreementAccepted(id1, rca1, uint64(block.timestamp)); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + _setAgreementCanceledBySP(id1, rca1); + + // Selective reconcile: only collector1+indexer — escrow still thawing + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); // escrow still thawing + + // collector1 still has indexer2 (+ c1+indexer pair tracked due to thawing escrow) + assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 2); + + // Global state updated + g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 2); + assertEq(g.sumMaxNextClaimAll, maxClaim2 + maxClaim3); + + // Cancel remaining and full reconcile + _setAgreementCanceledBySP(id2, rca2); + _setCanceledBySPOnCollector(collector2, id3, rca3); + + // Reconcile all (reconcile + cleanup in single pass) + uint256 totalRemoved = agreementHelper.reconcileAll(); + assertEq(totalRemoved, 2); + + // Agreements gone, but escrows still thawing — collectors stay tracked + g = agreementHelper.auditGlobal(); + assertEq(g.totalAgreementCount, 0); + assertEq(g.sumMaxNextClaimAll, 0); + assertEq(g.collectorCount, 2); // still tracked — escrow not yet drained + + // Escrows should be thawing for all pairs + IRecurringAgreementHelper.PairAudit memory p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + assertTrue(0 < p1.escrow.tokensThawing, "c1+indexer should be thawing"); + + IRecurringAgreementHelper.PairAudit memory p2 = agreementHelper.auditPair( + address(recurringCollector), + indexer2 + ); + assertTrue(0 < p2.escrow.tokensThawing, "c1+indexer2 should be thawing"); + + IRecurringAgreementHelper.PairAudit memory p3 = agreementHelper.auditPair(address(collector2), indexer); + assertTrue(0 < p3.escrow.tokensThawing, "c2+indexer should be thawing"); + + // Wait for thaw, withdraw all + vm.warp(block.timestamp + THAW_PERIOD + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileCollectorProvider(address(collector2), indexer); + + // All escrows drained + p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p1.escrow.balance, 0); + assertEq(p1.escrow.tokensThawing, 0); + + p2 = agreementHelper.auditPair(address(recurringCollector), indexer2); + assertEq(p2.escrow.balance, 0); + assertEq(p2.escrow.tokensThawing, 0); + + p3 = agreementHelper.auditPair(address(collector2), indexer); + assertEq(p3.escrow.balance, 0); + assertEq(p3.escrow.tokensThawing, 0); + + // Now reconcile tracking (escrow drained, so reconcileCollectorProvider succeeds) + agreementHelper.reconcileAll(); + + g = agreementHelper.auditGlobal(); + assertEq(g.collectorCount, 0); // fully cleaned up + } + + // -- Tests: Expired Offer Cleanup -- + + function test_Lifecycle_ExpiredOffer_CleanupRemoves() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + + // Before deadline: not removable + uint256 removed = agreementHelper.reconcile(indexer); + assertEq(removed, 0); + + // Warp past deadline + vm.warp(rca.deadline + 1); + + // Now removable + removed = agreementHelper.reconcile(indexer); + assertEq(removed, 1); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + + // Escrow deposited in Full mode should now be thawing + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertTrue(0 < p.escrow.tokensThawing, "escrow should be thawing after expired offer removal"); + + // Wait for thaw and withdraw + vm.warp(block.timestamp + THAW_PERIOD + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, 0); + assertEq(p.escrow.tokensThawing, 0); + } + + // -- Tests: reconcilePair Isolation -- + + function test_Lifecycle_ReconcilePair_IsolatesCollectors() public { + // Both collectors have agreements with the same indexer + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + bytes16 id1 = _offerAgreement(rca1); + _setAgreementCanceledBySP(id1, rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAFor( + collector2, + indexer, + 200 ether, + 2 ether, + 7200, + 2 + ); + _offerForCollector(collector2, rca2); + + // Reconcile only collector1's pair — escrow still thawing so pair still exists + (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertEq(removed, 1); + assertTrue(pairExists); // escrow still thawing, pair stays tracked + + // Collector2's agreement untouched + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), maxClaim2); + assertEq(agreementManager.getPairAgreementCount(address(collector2), indexer), 1); + + // Collector1's escrow should be thawing after reconcile + IRecurringAgreementHelper.PairAudit memory p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + assertTrue(0 < p1.escrow.tokensThawing, "c1 escrow should be thawing after reconcile"); + + // Collector2's escrow should still be fully deposited (not thawing) + IRecurringAgreementHelper.PairAudit memory p2 = agreementHelper.auditPair(address(collector2), indexer); + assertEq(p2.escrow.balance, maxClaim2); + assertEq(p2.escrow.tokensThawing, 0); + + // Wait for thaw, then drain collector1's escrow + vm.warp(block.timestamp + THAW_PERIOD + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p1.escrow.balance, 0); + assertEq(p1.escrow.tokensThawing, 0); + + // Now pair can be fully removed + (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + assertFalse(pairExists); // escrow drained, pair removed + } + + // -- Tests: Escrow Basis Mid-Lifecycle with Audit Verification -- + + function test_Lifecycle_EscrowBasisChange_OnDemandToFull() public { + // Start in OnDemand mode + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + // Offer — OnDemand: min=0, max=sumMaxNextClaim. No deposit (min=0). + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor( + recurringCollector, + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.sumMaxNextClaim, maxClaim); + // OnDemand: no deposit, but _updateEscrow in offerAgreement may have deposited + // Actually in OnDemand min=0 so no deposit happens + assertEq(p.escrow.balance, 0); + + // Switch to Full + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + p = agreementHelper.auditPair(address(recurringCollector), indexer); + assertEq(p.escrow.balance, maxClaim); // Full deposits everything + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockEligibilityOracle.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockEligibilityOracle.sol new file mode 100644 index 000000000..746c95de1 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockEligibilityOracle.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; + +/// @notice Simple mock eligibility oracle for testing SAM passthrough +contract MockEligibilityOracle is IProviderEligibility { + mapping(address => bool) public eligible; + bool public defaultEligible; + + function setEligible(address indexer, bool _eligible) external { + eligible[indexer] = _eligible; + } + + function setDefaultEligible(bool _default) external { + defaultEligible = _default; + } + + function isEligible(address indexer) external view override returns (bool) { + if (eligible[indexer]) return true; + return defaultEligible; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockGraphToken.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockGraphToken.sol new file mode 100644 index 000000000..dd07fab6e --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockGraphToken.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +/// @notice Minimal ERC20 token for testing. Mints initial supply to deployer. +contract MockGraphToken is ERC20 { + constructor() ERC20("Graph Token", "GRT") { + _mint(msg.sender, 1_000_000_000 ether); + } + + function mint(address to, uint256 amount) external { + _mint(to, amount); + } +} diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol new file mode 100644 index 000000000..7cab89243 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; + +/// @notice Stateful mock of PaymentsEscrow for RecurringAgreementManager testing. +/// Tracks deposits per (payer, collector, receiver) and transfers tokens on deposit. +/// Supports thaw/withdraw lifecycle for escrow rebalancing testing. +contract MockPaymentsEscrow is IPaymentsEscrow { + IERC20 public token; + + struct Account { + uint256 balance; + uint256 tokensThawing; + uint256 thawEndTimestamp; + } + + // accounts[payer][collector][receiver] + mapping(address => mapping(address => mapping(address => Account))) public accounts; + + /// @notice Thawing period for testing (set to 1 day by default) + uint256 public constant THAWING_PERIOD = 1 days; + + constructor(address _token) { + token = IERC20(_token); + } + + function deposit(address collector, address receiver, uint256 tokens) external { + token.transferFrom(msg.sender, address(this), tokens); + accounts[msg.sender][collector][receiver].balance += tokens; + } + + function thaw(address collector, address receiver, uint256 tokens) external { + _thaw(collector, receiver, tokens, true); + } + + function adjustThaw( + address collector, + address receiver, + uint256 tokens, + bool evenIfTimerReset + ) external returns (uint256) { + return _thaw(collector, receiver, tokens, evenIfTimerReset); + } + + function cancelThaw(address collector, address receiver) external { + _thaw(collector, receiver, 0, true); + } + + function _thaw( + address collector, + address receiver, + uint256 tokens, + bool evenIfTimerReset + ) private returns (uint256 tokensThawing) { + Account storage account = accounts[msg.sender][collector][receiver]; + tokensThawing = tokens < account.balance ? tokens : account.balance; + if (tokensThawing == account.tokensThawing) { + return tokensThawing; + } + uint256 newThawEndTimestamp = block.timestamp + THAWING_PERIOD; + if (tokensThawing < account.tokensThawing) { + account.tokensThawing = tokensThawing; + if (tokensThawing == 0) account.thawEndTimestamp = 0; + } else { + if (!evenIfTimerReset && account.thawEndTimestamp != 0 && account.thawEndTimestamp != newThawEndTimestamp) + return account.tokensThawing; + account.tokensThawing = tokensThawing; + account.thawEndTimestamp = newThawEndTimestamp; + } + } + + function withdraw(address collector, address receiver) external { + Account storage account = accounts[msg.sender][collector][receiver]; + if (account.thawEndTimestamp == 0 || block.timestamp <= account.thawEndTimestamp) { + return; + } + uint256 tokens = account.tokensThawing; + account.balance -= tokens; + account.tokensThawing = 0; + account.thawEndTimestamp = 0; + token.transfer(msg.sender, tokens); + } + + function escrowAccounts( + address payer, + address collector, + address receiver + ) external view returns (uint256, uint256, uint256) { + Account storage account = accounts[payer][collector][receiver]; + return (account.balance, account.tokensThawing, account.thawEndTimestamp); + } + + function getBalance(address payer, address collector, address receiver) external view returns (uint256) { + Account storage account = accounts[payer][collector][receiver]; + return account.tokensThawing < account.balance ? account.balance - account.tokensThawing : 0; + } + + /// @notice Test helper: set arbitrary account state for data-driven tests + function setAccount( + address payer, + address collector, + address receiver, + uint256 balance_, + uint256 tokensThawing_, + uint256 thawEndTimestamp_ + ) external { + Account storage account = accounts[payer][collector][receiver]; + account.balance = balance_; + account.tokensThawing = tokensThawing_; + account.thawEndTimestamp = thawEndTimestamp_; + } + + // -- Stubs (not used by RecurringAgreementManager) -- + + function initialize() external {} + function depositTo(address, address, address, uint256) external {} + function collect(IGraphPayments.PaymentTypes, address, address, uint256, address, uint256, address) external {} + function MAX_WAIT_PERIOD() external pure returns (uint256) { + return 0; + } + function WITHDRAW_ESCROW_THAWING_PERIOD() external pure returns (uint256) { + return THAWING_PERIOD; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol new file mode 100644 index 000000000..36275f404 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +/// @notice Minimal mock of RecurringCollector for RecurringAgreementManager testing. +/// Stores agreement data set by tests, computes agreementId and hashRCA deterministically. +contract MockRecurringCollector { + mapping(bytes16 => IRecurringCollector.AgreementData) private _agreements; + mapping(bytes16 => bool) private _agreementExists; + + // -- Test helpers -- + + function setAgreement(bytes16 agreementId, IRecurringCollector.AgreementData memory data) external { + _agreements[agreementId] = data; + _agreementExists[agreementId] = true; + } + + // -- IRecurringCollector subset -- + + function getAgreement(bytes16 agreementId) external view returns (IRecurringCollector.AgreementData memory) { + return _agreements[agreementId]; + } + + function getMaxNextClaim(bytes16 agreementId) external view returns (uint256) { + IRecurringCollector.AgreementData memory a = _agreements[agreementId]; + // Mirror RecurringCollector._getMaxNextClaim logic + if (a.state == IRecurringCollector.AgreementState.CanceledByServiceProvider) return 0; + if ( + a.state != IRecurringCollector.AgreementState.Accepted && + a.state != IRecurringCollector.AgreementState.CanceledByPayer + ) return 0; + + uint256 collectionStart = 0 < a.lastCollectionAt ? a.lastCollectionAt : a.acceptedAt; + uint256 collectionEnd; + if (a.state == IRecurringCollector.AgreementState.CanceledByPayer) { + collectionEnd = a.canceledAt < a.endsAt ? a.canceledAt : a.endsAt; + } else { + collectionEnd = a.endsAt; + } + if (collectionEnd <= collectionStart) return 0; + + uint256 windowSeconds = collectionEnd - collectionStart; + uint256 maxSeconds = windowSeconds < a.maxSecondsPerCollection ? windowSeconds : a.maxSecondsPerCollection; + uint256 maxClaim = a.maxOngoingTokensPerSecond * maxSeconds; + if (a.lastCollectionAt == 0) maxClaim += a.maxInitialTokens; + return maxClaim; + } + + function generateAgreementId( + address payer, + address dataService, + address serviceProvider, + uint64 deadline, + uint256 nonce + ) external pure returns (bytes16) { + return bytes16(keccak256(abi.encode(payer, dataService, serviceProvider, deadline, nonce))); + } + + function hashRCA(IRecurringCollector.RecurringCollectionAgreement calldata rca) external pure returns (bytes32) { + return + keccak256( + abi.encode( + rca.deadline, + rca.endsAt, + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.maxInitialTokens, + rca.maxOngoingTokensPerSecond, + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection, + rca.nonce, + rca.metadata + ) + ); + } + + function hashRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau + ) external pure returns (bytes32) { + return + keccak256( + abi.encode( + rcau.agreementId, + rcau.deadline, + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection, + rcau.nonce, + rcau.metadata + ) + ); + } +} diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockSubgraphService.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockSubgraphService.sol new file mode 100644 index 000000000..c74bf72cb --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockSubgraphService.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +/// @notice Minimal mock of SubgraphService for RecurringAgreementManager cancelAgreement testing. +/// Records cancel calls and can be configured to revert. +contract MockSubgraphService { + mapping(bytes16 => bool) public canceled; + mapping(bytes16 => uint256) public cancelCallCount; + + bool public shouldRevert; + string public revertMessage; + + function cancelIndexingAgreementByPayer(bytes16 agreementId) external { + if (shouldRevert) { + revert(revertMessage); + } + canceled[agreementId] = true; + cancelCallCount[agreementId]++; + } + + // -- Test helpers -- + + function setRevert(bool _shouldRevert, string memory _message) external { + shouldRevert = _shouldRevert; + revertMessage = _message; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol new file mode 100644 index 000000000..f5785dcbd --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockRecurringCollector internal collector2; + + function setUp() public override { + super.setUp(); + collector2 = new MockRecurringCollector(); + vm.label(address(collector2), "RecurringCollector2"); + + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(collector2)); + } + + // -- Helpers -- + + function _makeRCAForCollector( + MockRecurringCollector collector, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + uint64 endsAt, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: endsAt, + payer: address(agreementManager), + dataService: dataService, + serviceProvider: indexer, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: 60, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: nonce, + metadata: "" + }); + agreementId = collector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + } + + // -- Tests -- + + function test_MultiCollector_RequiredEscrowIsolation() public { + // Offer agreement via collector1 (the default recurringCollector) + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector( + recurringCollector, + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + + // Offer agreement via collector2 with different terms + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector( + collector2, + 200 ether, + 2 ether, + 7200, + uint64(block.timestamp + 365 days), + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Required escrow is independent per collector + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1); + assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), maxClaim2); + } + + function test_MultiCollector_BeforeCollectionOnlyOwnAgreements() public { + // Offer agreement via collector1 + (IRecurringCollector.RecurringCollectionAgreement memory rca1, bytes16 agreementId1) = _makeRCAForCollector( + recurringCollector, + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + + // collector2 cannot call beforeCollection on collector1's agreement + vm.prank(address(collector2)); + vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + agreementManager.beforeCollection(agreementId1, 100 ether); + + // collector1 can call beforeCollection on its own agreement + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId1, 100 ether); + } + + function test_MultiCollector_AfterCollectionOnlyOwnAgreements() public { + // Offer agreement via collector1 + (IRecurringCollector.RecurringCollectionAgreement memory rca1, bytes16 agreementId1) = _makeRCAForCollector( + recurringCollector, + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + + // collector2 cannot call afterCollection on collector1's agreement + vm.prank(address(collector2)); + vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + agreementManager.afterCollection(agreementId1, 100 ether); + } + + function test_MultiCollector_SeparateEscrowAccounts() public { + // Offer via collector1 + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector( + recurringCollector, + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + // Fund with surplus so Full mode stays active (deficit < balance required) + token.mint(address(agreementManager), maxClaim1 + 1); + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + + // Offer via collector2 + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector( + collector2, + 200 ether, + 2 ether, + 7200, + uint64(block.timestamp + 365 days), + 2 + ); + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + // Fund with surplus so Full mode stays active (deficit < balance required) + token.mint(address(agreementManager), maxClaim2 + 1); + vm.prank(operator); + agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + + // Escrow accounts are separate per (collector, provider) + (uint256 collector1Balance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(collector1Balance, maxClaim1); + (uint256 collector2Balance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(collector2), + indexer + ); + assertEq(collector2Balance, maxClaim2); + } + + function test_MultiCollector_RevokeOnlyAffectsOwnCollectorEscrow() public { + // Offer via both collectors + (IRecurringCollector.RecurringCollectionAgreement memory rca1, bytes16 agreementId1) = _makeRCAForCollector( + recurringCollector, + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + + (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector( + collector2, + 200 ether, + 2 ether, + 7200, + uint64(block.timestamp + 365 days), + 2 + ); + vm.prank(operator); + agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Revoke collector1's agreement + vm.prank(operator); + agreementManager.revokeOffer(agreementId1); + + // Collector1 escrow cleared, collector2 unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), maxClaim2); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol new file mode 100644 index 000000000..168f8208b --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol @@ -0,0 +1,455 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + address internal indexer2; + address internal indexer3; + + function setUp() public virtual override { + super.setUp(); + indexer2 = makeAddr("indexer2"); + indexer3 = makeAddr("indexer3"); + } + + // -- Helpers -- + + function _makeRCAForIndexer( + address sp, + uint256 maxInitial, + uint256 maxOngoing, + uint32 maxSec, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + rca.serviceProvider = sp; + rca.nonce = nonce; + return rca; + } + + // -- Isolation: offer/sumMaxNextClaim -- + + function test_MultiIndexer_OfferIsolation() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCAForIndexer( + indexer3, + 50 ether, + 0.5 ether, + 1800, + 3 + ); + + _offerAgreement(rca1); + _offerAgreement(rca2); + _offerAgreement(rca3); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + uint256 maxClaim3 = 0.5 ether * 1800 + 50 ether; + + // Each indexer has independent sumMaxNextClaim + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer3), maxClaim3); + + // Each has exactly 1 agreement + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + assertEq(agreementManager.getProviderAgreementCount(indexer3), 1); + + // Each has independent escrow balance + (uint256 indexerBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + indexerBalance, + maxClaim1 + ); + (uint256 indexer2Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); + assertEq( + indexer2Balance, + maxClaim2 + ); + (uint256 indexer3Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer3); + assertEq( + indexer3Balance, + maxClaim3 + ); + } + + // -- Isolation: revoke one indexer doesn't affect others -- + + function test_MultiIndexer_RevokeIsolation() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Revoke indexer1's agreement + vm.prank(operator); + agreementManager.revokeOffer(id1); + + // Indexer1 cleared + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + + // Indexer2 unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + } + + // -- Isolation: reconcile one indexer doesn't affect others -- + + function test_MultiIndexer_RemoveIsolation() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // SP cancels indexer1, reconcile it + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + // Indexer1 cleared + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + + // Indexer2 unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + } + + // -- Isolation: reconcile one indexer doesn't affect others -- + + function test_MultiIndexer_ReconcileIsolation() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Accept and cancel indexer1's agreement by SP + _setAgreementCanceledBySP(id1, rca1); + + // Reconcile only indexer1 + agreementManager.reconcileAgreement(id1); + + // Indexer1 required escrow drops to 0 (CanceledBySP -> maxNextClaim=0) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + + // Indexer2 completely unaffected (still pre-offered estimate) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + } + + // -- Multiple agreements per indexer -- + + function test_MultiIndexer_MultipleAgreementsPerIndexer() public { + // Two agreements for indexer, one for indexer2 + IRecurringCollector.RecurringCollectionAgreement memory rca1a = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca1b = _makeRCAForIndexer( + indexer, + 50 ether, + 0.5 ether, + 1800, + 2 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 3 + ); + + bytes16 id1a = _offerAgreement(rca1a); + _offerAgreement(rca1b); + _offerAgreement(rca2); + + uint256 maxClaim1a = 1 ether * 3600 + 100 ether; + uint256 maxClaim1b = 0.5 ether * 1800 + 50 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + assertEq(agreementManager.getProviderAgreementCount(indexer), 2); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1a + maxClaim1b); + assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + + // Reconcile one of indexer's agreements + _setAgreementCanceledBySP(id1a, rca1a); + agreementManager.reconcileAgreement(id1a); + + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1b); + + // Indexer2 still unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + } + + // -- Cancel one indexer, reconcile another -- + + function test_MultiIndexer_CancelAndReconcileIndependently() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + // Accept both + _setAgreementAccepted(id1, rca1, uint64(block.timestamp)); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + // Cancel indexer1's agreement via operator + vm.prank(operator); + agreementManager.cancelAgreement(id1); + + // Indexer1's required escrow updated by cancelAgreement's inline reconcile + // (still has maxNextClaim from RC since it's CanceledByPayer not CanceledBySP) + // But the mock just calls SubgraphService — the RC state doesn't change automatically. + // The cancelAgreement reconciles against whatever the mock RC says. + + // Reconcile indexer2 independently + agreementManager.reconcileAgreement(id2); + + // Both indexers tracked independently + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + } + + // -- Maintain isolation -- + + function test_MultiIndexer_MaintainOnlyAffectsTargetIndexer() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Reconcile indexer1's agreement + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + // Update escrow for indexer1 — should thaw excess + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Indexer1 escrow thawing (excess = maxClaim1, required = 0) + IPaymentsEscrow.EscrowAccount memory acct1; + (acct1.balance, acct1.tokensThawing, acct1.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(acct1.balance - acct1.tokensThawing, 0); + + // Indexer2 escrow completely unaffected + (uint256 indexer2Bal,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); + assertEq( + indexer2Bal, + maxClaim2 + ); + + // reconcileCollectorProvider on indexer2 is a no-op (balance == required, no excess) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + } + + // -- Full lifecycle across multiple indexers -- + + function test_MultiIndexer_FullLifecycle() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // 1. Offer both + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + + // 2. Accept both + _setAgreementAccepted(id1, rca1, uint64(block.timestamp)); + _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); + + // 3. Simulate collection on indexer1 (reduce remaining window) + uint64 collectionTime = uint64(block.timestamp + 1800); + _setAgreementCollected(id1, rca1, uint64(block.timestamp), collectionTime); + vm.warp(collectionTime); + + // 4. Reconcile indexer1 — required should decrease (no more initial tokens) + agreementManager.reconcileAgreement(id1); + assertTrue(agreementManager.getSumMaxNextClaim(_collector(), indexer) < maxClaim1); + + // Indexer2 unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); + + // 5. Cancel indexer2 by SP + _setAgreementCanceledBySP(id2, rca2); + agreementManager.reconcileAgreement(id2); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), 0); + + // 6. Reconcile indexer2's agreement + agreementManager.reconcileAgreement(id2); + assertEq(agreementManager.getProviderAgreementCount(indexer2), 0); + + // 7. Update escrow for indexer2 (thaw excess) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + IPaymentsEscrow.EscrowAccount memory acct2; + (acct2.balance, acct2.tokensThawing, acct2.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 + ); + assertEq(acct2.balance - acct2.tokensThawing, 0); + + // 8. Indexer1 still active + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertTrue(0 < agreementManager.getSumMaxNextClaim(_collector(), indexer)); + } + + // -- getAgreementInfo across indexers -- + + function test_MultiIndexer_GetAgreementInfo() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + IRecurringAgreements.AgreementInfo memory info1 = agreementManager.getAgreementInfo(id1); + IRecurringAgreements.AgreementInfo memory info2 = agreementManager.getAgreementInfo(id2); + + assertEq(info1.provider, indexer); + assertEq(info2.provider, indexer2); + assertTrue(info1.provider != address(0)); + assertTrue(info2.provider != address(0)); + assertEq(info1.maxNextClaim, 1 ether * 3600 + 100 ether); + assertEq(info2.maxNextClaim, 2 ether * 7200 + 200 ether); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol new file mode 100644 index 000000000..9267c549d --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -0,0 +1,455 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_OfferUpdate_SetsState() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + _offerAgreementUpdate(rcau); + + // pendingMaxNextClaim = 2e18 * 7200 + 200e18 = 14600e18 + uint256 expectedPendingMaxClaim = 2 ether * 7200 + 200 ether; + // Original maxNextClaim = 1e18 * 3600 + 100e18 = 3700e18 + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Required escrow should include both + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + expectedPendingMaxClaim); + // Original maxNextClaim unchanged + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); + } + + function test_OfferUpdate_AuthorizesHash() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + _offerAgreementUpdate(rcau); + + // The update hash should be authorized for the IAgreementOwner callback + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + bytes4 result = agreementManager.approveAgreement(updateHash); + assertEq(result, agreementManager.approveAgreement.selector); + } + + function test_OfferUpdate_FundsEscrow() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + uint256 sumMaxNextClaim = originalMaxClaim + pendingMaxClaim; + + // Fund and offer agreement + token.mint(address(agreementManager), sumMaxNextClaim); + vm.prank(operator); + bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + + // Offer update (should fund the deficit) + token.mint(address(agreementManager), pendingMaxClaim); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau); + + // Verify escrow was funded for both + (uint256 escrowBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + escrowBalance, + sumMaxNextClaim + ); + } + + function test_OfferUpdate_ReplacesExistingPending() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // First pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + uint256 pendingMaxClaim1 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim1); + + // Second pending update (replaces first — same nonce since first was never accepted) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 180 days), + 1 + ); + _offerAgreementUpdate(rcau2); + + uint256 pendingMaxClaim2 = 0.5 ether * 1800 + 50 ether; + // Old pending removed, new pending added + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim2); + } + + function test_OfferUpdate_EmitsEvent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementUpdateOffered(agreementId, pendingMaxClaim, 1); + + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau); + } + + function test_OfferUpdate_Revert_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + fakeId, + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days), + 1 + ); + + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotOffered.selector, fakeId)); + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau); + } + + function test_OfferUpdate_Revert_WhenNotOperator() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + address nonOperator = makeAddr("nonOperator"); + vm.expectRevert( + abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + ); + vm.prank(nonOperator); + agreementManager.offerAgreementUpdate(rcau); + } + + function test_OfferUpdate_Revert_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + // Grant pause role and pause + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau); + } + + function test_OfferUpdate_Revert_WhenNonceWrong() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Try nonce=2 when collector expects nonce=1 (updateNonce=0) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 2 + ); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.InvalidUpdateNonce.selector, agreementId, 1, 2) + ); + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau); + } + + function test_OfferUpdate_Nonce2_AfterFirstAccepted() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer first update (nonce=1) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + // Simulate: agreement accepted with update nonce=1 applied + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 7200, + updateNonce: 1, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + // Offer second update (nonce=2) — should succeed because collector's updateNonce=1 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 300 ether, + 3 ether, + 60, + 3600, + uint64(block.timestamp + 1095 days), + 2 + ); + _offerAgreementUpdate(rcau2); + + // Verify pending state was set + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2Check = rcau2; + bytes32 updateHash = recurringCollector.hashRCAU(rcau2Check); + assertEq(agreementManager.approveAgreement(updateHash), agreementManager.approveAgreement.selector); + } + + function test_OfferUpdate_Revert_Nonce1_AfterFirstAccepted() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer first update (nonce=1) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + // Simulate: agreement accepted with update nonce=1 applied + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 7200, + updateNonce: 1, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + // Try nonce=1 again — should fail because collector already at updateNonce=1 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 300 ether, + 3 ether, + 60, + 3600, + uint64(block.timestamp + 1095 days), + 1 + ); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.InvalidUpdateNonce.selector, agreementId, 2, 1) + ); + vm.prank(operator); + agreementManager.offerAgreementUpdate(rcau2); + } + + function test_OfferUpdate_ReconcilesDuringOffer() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 preOfferMax = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // Simulate acceptance with a collection (maxNextClaim should change) + uint64 acceptedAt = uint64(block.timestamp); + uint64 collectionAt = uint64(block.timestamp + 1800); + vm.warp(collectionAt); + _setAgreementCollected(agreementId, rca, acceptedAt, collectionAt); + + // Offer an update — this should reconcile first, updating maxNextClaim + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 365 days), + 1 + ); + _offerAgreementUpdate(rcau); + + // The base maxNextClaim should have been reconciled (reduced from pre-offer estimate) + // and the pending update added on top + uint256 pendingMaxClaim = 0.5 ether * 1800 + 50 ether; + uint256 postOfferMax = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // Post-reconcile base should be less than the pre-offer estimate + // (collection happened, so remaining window is smaller) + assertTrue(postOfferMax < preOfferMax + pendingMaxClaim); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/reconcile.t.sol b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol new file mode 100644 index 000000000..b2d45f413 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol @@ -0,0 +1,494 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_ReconcileAgreement_AfterFirstCollection() public { + // Offer: maxNextClaim = 1e18 * 3600 + 100e18 = 3700e18 + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 initialMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + assertEq(initialMaxClaim, 3700 ether); + + // Simulate: agreement accepted and first collection happened + uint64 acceptedAt = uint64(block.timestamp); + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(agreementId, rca, acceptedAt, lastCollectionAt); + + // After first collection, maxInitialTokens no longer applies + // New max = maxOngoingTokensPerSecond * min(remaining, maxSecondsPerCollection) + // remaining = endsAt - lastCollectionAt (large), capped by maxSecondsPerCollection = 3600 + // New max = 1e18 * 3600 = 3600e18 + vm.warp(lastCollectionAt); + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertTrue(exists); + uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + assertEq(newMaxClaim, 3600 ether); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3600 ether); + } + + function test_ReconcileAgreement_CanceledByServiceProvider() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 3700 ether); + + // SP cancels - immediately non-collectable → reconcile deletes + _setAgreementCanceledBySP(agreementId, rca); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertFalse(exists); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_ReconcileAgreement_CanceledByPayer_WindowOpen() public { + uint64 startTime = uint64(block.timestamp); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(startTime + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Payer cancels 2 hours from now, never collected + uint64 acceptedAt = startTime; + uint64 canceledAt = uint64(startTime + 2 hours); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertTrue(exists); + // Window = canceledAt - acceptedAt = 7200s, capped by maxSecondsPerCollection = 3600s + // maxClaim = 1e18 * 3600 + 100e18 (never collected, so includes initial) + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + } + + function test_ReconcileAgreement_CanceledByPayer_WindowExpired() public { + uint64 startTime = uint64(block.timestamp); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(startTime + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Payer cancels, and the collection already happened covering the full window + uint64 acceptedAt = startTime; + uint64 canceledAt = uint64(startTime + 2 hours); + // lastCollectionAt == canceledAt means window is empty + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, canceledAt); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + // collectionEnd = canceledAt, collectionStart = lastCollectionAt = canceledAt + // window is empty -> maxClaim = 0 → deleted + assertFalse(exists); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_ReconcileAgreement_SkipsNotAccepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + + // Mock returns NotAccepted (default state in mock - zero struct) + // reconcile should skip recalculation and preserve the original estimate + + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertTrue(exists); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); + } + + function test_ReconcileAgreement_EmitsEvent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // SP cancels + _setAgreementCanceledBySP(agreementId, rca); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementReconciled(agreementId, 3700 ether, 0); + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId, indexer); + + agreementManager.reconcileAgreement(agreementId); + } + + function test_ReconcileAgreement_NoEmitWhenUnchanged() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as accepted with same parameters - should produce same maxNextClaim + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // maxClaim should remain 3700e18 (never collected, maxSecondsPerCollection < window) + // No event should be emitted + vm.recordLogs(); + agreementManager.reconcileAgreement(agreementId); + + // Check no AgreementReconciled or AgreementRemoved events were emitted + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 reconciledTopic = keccak256("AgreementReconciled(bytes16,uint256,uint256)"); + bytes32 removedTopic = keccak256("AgreementRemoved(bytes16,address)"); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue(logs[i].topics[0] != reconciledTopic, "Unexpected AgreementReconciled event"); + assertTrue(logs[i].topics[0] != removedTopic, "Unexpected AgreementRemoved event"); + } + } + + function test_ReconcileAgreement_ReturnsFalse_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); + + // Returns false (not exists) when agreement not found (idempotent) + bool exists = agreementManager.reconcileAgreement(fakeId); + assertFalse(exists); + } + + function test_ReconcileAgreement_ExpiredAgreement() public { + uint64 endsAt = uint64(block.timestamp + 1 hours); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + endsAt + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as accepted, collected at endsAt (fully expired) + _setAgreementCollected(agreementId, rca, uint64(block.timestamp), endsAt); + vm.warp(endsAt); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + // collectionEnd = endsAt, collectionStart = lastCollectionAt = endsAt + // window empty -> maxClaim = 0 → deleted + assertFalse(exists); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_ReconcileAgreement_ClearsPendingUpdate() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Offer a pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + + // Simulate: agreement accepted and update applied on-chain (updateNonce = 1) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rcau.endsAt, + maxInitialTokens: rcau.maxInitialTokens, + maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, + minSecondsPerCollection: rcau.minSecondsPerCollection, + maxSecondsPerCollection: rcau.maxSecondsPerCollection, + updateNonce: 1, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertTrue(exists); + // Pending should be cleared, maxNextClaim recalculated from new terms + // newMaxClaim = 2e18 * 7200 + 200e18 = 14600e18 (never collected, maxSecondsPerCollection < window) + uint256 newMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), newMaxClaim); + // Required = only new maxClaim (pending cleared) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), newMaxClaim); + } + + function test_ReconcileAgreement_KeepsPendingUpdate_WhenNotYetApplied() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Offer a pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + + // Simulate: agreement accepted but update NOT yet applied (updateNonce = 0) + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertTrue(exists); + // maxNextClaim recalculated from original terms (same value since never collected) + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); + // Pending still present + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + } + + // -- Tests merged from remove (cleanup behavior) -- + + function test_ReconcileAgreement_ReturnsTrue_WhenStillClaimable_Accepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Set as accepted but never collected - still claimable + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + bool exists = agreementManager.reconcileAgreement(agreementId); + assertTrue(exists); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_ReconcileAgreement_DeletesExpiredOffer() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Warp past the RCA deadline (default: block.timestamp + 1 hours in _makeRCA) + vm.warp(block.timestamp + 2 hours); + + // Agreement not accepted + past deadline — should be deleted + bool exists = agreementManager.reconcileAgreement(agreementId); + + assertFalse(exists); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_ReconcileAgreement_ReturnsTrue_WhenStillClaimable_NotAccepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Not accepted yet, before deadline - still potentially claimable + bool exists = agreementManager.reconcileAgreement(agreementId); + assertTrue(exists); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_ReconcileAgreement_ReturnsTrue_WhenCanceledByPayer_WindowStillOpen() public { + uint64 startTime = uint64(block.timestamp); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(startTime + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Payer canceled but window is still open (not yet collected) + uint64 canceledAt = uint64(startTime + 2 hours); + _setAgreementCanceledByPayer(agreementId, rca, startTime, canceledAt, 0); + + // Still claimable: window = canceledAt - acceptedAt = 7200s, capped at 3600s + bool exists = agreementManager.reconcileAgreement(agreementId); + assertTrue(exists); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_ReconcileAgreement_ReducesRequiredEscrow_WithMultipleAgreements() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; // 3700e18 + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; // 14600e18 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1 + maxClaim2); + + // Cancel agreement 1 by SP and reconcile it (deletes) + _setAgreementCanceledBySP(id1, rca1); + bool exists = agreementManager.reconcileAgreement(id1); + assertFalse(exists); + + // Only agreement 2's original maxClaim remains + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + + // Agreement 2 still tracked + assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + } + + function test_ReconcileAgreement_Permissionless() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // SP cancels + _setAgreementCanceledBySP(agreementId, rca); + + // Anyone can reconcile + address anyone = makeAddr("anyone"); + vm.prank(anyone); + bool exists = agreementManager.reconcileAgreement(agreementId); + assertFalse(exists); + + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + function test_ReconcileAgreement_ClearsPendingUpdate_WhenCanceled() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer a pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + + // SP cancels - immediately removable + _setAgreementCanceledBySP(agreementId, rca); + + bool exists = agreementManager.reconcileAgreement(agreementId); + assertFalse(exists); + + // Both original and pending should be cleared from sumMaxNextClaim + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/register.t.sol b/packages/issuance/test/unit/agreement-manager/register.t.sol new file mode 100644 index 000000000..2f97d25ea --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/register.t.sol @@ -0,0 +1,254 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_Offer_SetsAgreementState() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 expectedId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + assertEq(agreementId, expectedId); + // maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens + // = 1e18 * 3600 + 100e18 = 3700e18 + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + } + + function test_Offer_FundsEscrow() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + + // Fund with surplus so Full mode stays active (deficit < balance required) + token.mint(address(agreementManager), expectedMaxClaim + 1); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + + // Verify escrow was funded + (uint256 escrowBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + escrowBalance, + expectedMaxClaim + ); + } + + function test_Offer_PartialFunding_WhenInsufficientBalance() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + uint256 available = 500 ether; // Less than expectedMaxClaim + + // Fund with less than needed + token.mint(address(agreementManager), available); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + + // Since available < required, Full degrades to OnDemand (deposit target = 0). + // No proactive deposit; JIT beforeCollection is the safety net. + (uint256 escrowBalanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + escrowBalanceAfter, + 0 + ); + // Escrow balance is 0 since no deposit was made + assertEq(agreementManager.getEscrowAccount(_collector(), indexer).balance, 0); + } + + function test_Offer_EmitsEvent() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 expectedId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + + token.mint(address(agreementManager), expectedMaxClaim); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementOffered(expectedId, indexer, expectedMaxClaim); + + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + function test_Offer_AuthorizesHash() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + + // The agreement hash should be authorized for the IAgreementOwner callback + bytes32 agreementHash = recurringCollector.hashRCA(rca); + bytes4 result = agreementManager.approveAgreement(agreementHash); + assertEq(result, agreementManager.approveAgreement.selector); + } + + function test_Offer_MultipleAgreements_SameIndexer() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + assertTrue(id1 != id2); + assertEq(agreementManager.getProviderAgreementCount(indexer), 2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1 + maxClaim2); + } + + function test_Offer_Revert_WhenPayerMismatch() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.payer = address(0xdead); // Wrong payer + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringAgreementManagement.PayerMustBeManager.selector, + address(0xdead), + address(agreementManager) + ) + ); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + function test_Offer_Revert_WhenAlreadyOffered() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.AgreementAlreadyOffered.selector, agreementId) + ); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + function test_Offer_Revert_WhenNotOperator() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + address nonOperator = makeAddr("nonOperator"); + vm.expectRevert( + abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + ); + vm.prank(nonOperator); + agreementManager.offerAgreement(rca, _collector()); + } + + function test_Offer_Revert_WhenUnauthorizedCollector() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + address fakeCollector = makeAddr("fakeCollector"); + token.mint(address(agreementManager), 10_000 ether); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedCollector.selector, fakeCollector) + ); + vm.prank(operator); + agreementManager.offerAgreement(rca, IRecurringCollector(fakeCollector)); + } + + function test_Offer_Revert_WhenPaused() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + // Grant pause role and pause + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + vm.prank(operator); + agreementManager.offerAgreement(rca, _collector()); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/remove.t.sol b/packages/issuance/test/unit/agreement-manager/remove.t.sol new file mode 100644 index 000000000..e21010bfb --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/remove.t.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +// Tests merged into reconcile.t.sol — reconcileAgreement now handles cleanup inline. diff --git a/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol new file mode 100644 index 000000000..2ad9d1bca --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_RevokeAgreementUpdate_ClearsPendingState() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + + // Offer a pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + + // Revoke the pending update + vm.prank(operator); + bool revoked = agreementManager.revokeAgreementUpdate(agreementId); + assertTrue(revoked); + + // Pending state should be fully cleared + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.pendingUpdateMaxNextClaim, 0, "pending escrow should be zero"); + assertEq(info.pendingUpdateNonce, 0, "pending nonce should be zero"); + assertEq(info.pendingUpdateHash, bytes32(0), "pending hash should be zero"); + + // sumMaxNextClaim should only include the base claim + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + + // The update hash should no longer be authorized + bytes32 updateHash = recurringCollector.hashRCAU(rcau); + bytes4 result = agreementManager.approveAgreement(updateHash); + assertTrue(result != agreementManager.approveAgreement.selector, "hash should not be authorized"); + } + + function test_RevokeAgreementUpdate_EmitsEvent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementUpdateRevoked(agreementId, pendingMaxClaim, 1); + + vm.prank(operator); + agreementManager.revokeAgreementUpdate(agreementId); + } + + function test_RevokeAgreementUpdate_ReturnsFalse_WhenNoPending() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // No pending update — should return false + vm.prank(operator); + bool revoked = agreementManager.revokeAgreementUpdate(agreementId); + assertFalse(revoked); + } + + function test_RevokeAgreementUpdate_ReturnsFalse_WhenAlreadyApplied() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + // Simulate: accepted with update already applied (updateNonce=1) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rcau.endsAt, + maxInitialTokens: rcau.maxInitialTokens, + maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, + minSecondsPerCollection: rcau.minSecondsPerCollection, + maxSecondsPerCollection: rcau.maxSecondsPerCollection, + updateNonce: 1, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + + // Reconcile inside revokeAgreementUpdate detects the update was applied + // and clears it — returns false (nothing left to revoke) + vm.prank(operator); + bool revoked = agreementManager.revokeAgreementUpdate(agreementId); + assertFalse(revoked); + } + + function test_RevokeAgreementUpdate_CanOfferNewUpdateAfterRevoke() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer update nonce=1 + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau1); + + // Revoke it + vm.prank(operator); + agreementManager.revokeAgreementUpdate(agreementId); + + // Offer a new update with the same nonce (1) — should succeed since the + // collector's updateNonce is still 0 and the pending was cleared + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( + agreementId, + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 180 days), + 1 + ); + _offerAgreementUpdate(rcau2); + + // New pending should be set + uint256 newPendingMaxClaim = 0.5 ether * 1800 + 50 ether; + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); + assertEq(info.pendingUpdateMaxNextClaim, newPendingMaxClaim); + assertEq(info.pendingUpdateNonce, 1); + } + + function test_RevokeAgreementUpdate_Revert_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); + + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotOffered.selector, fakeId)); + vm.prank(operator); + agreementManager.revokeAgreementUpdate(fakeId); + } + + function test_RevokeAgreementUpdate_Revert_WhenNotOperator() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + address nonOperator = makeAddr("nonOperator"); + vm.expectRevert( + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, + nonOperator, + AGREEMENT_MANAGER_ROLE + ) + ); + vm.prank(nonOperator); + agreementManager.revokeAgreementUpdate(agreementId); + } + + function test_RevokeAgreementUpdate_Revert_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + bytes16 agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + vm.prank(operator); + agreementManager.revokeAgreementUpdate(agreementId); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol new file mode 100644 index 000000000..71efb325e --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function test_RevokeOffer_ClearsAgreement() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); + + vm.prank(operator); + bool gone = agreementManager.revokeOffer(agreementId); + assertTrue(gone); + + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + } + + function test_RevokeOffer_InvalidatesHash() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Hash is authorized before revoke + bytes32 rcaHash = recurringCollector.hashRCA(rca); + agreementManager.approveAgreement(rcaHash); // should not revert + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + // Hash should be rejected after revoke (agreement no longer exists) + assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); + } + + function test_RevokeOffer_ClearsPendingUpdate() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Offer a pending update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + _offerAgreementUpdate(rcau); + + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + + // Both original and pending should be cleared + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_RevokeOffer_EmitsEvent() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.OfferRevoked(agreementId, indexer); + + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + } + + function test_RevokeOffer_Revert_WhenAlreadyAccepted() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Simulate acceptance in RC + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.AgreementAlreadyAccepted.selector, agreementId) + ); + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + } + + function test_RevokeOffer_ReturnsTrue_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); + vm.prank(operator); + bool gone = agreementManager.revokeOffer(fakeId); + assertTrue(gone); + } + + function test_RevokeOffer_Revert_WhenNotOperator() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + address nonOperator = makeAddr("nonOperator"); + vm.expectRevert( + abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + ); + vm.prank(nonOperator); + agreementManager.revokeOffer(agreementId); + } + + function test_RevokeOffer_Revert_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + vm.prank(operator); + agreementManager.revokeOffer(agreementId); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/shared.t.sol b/packages/issuance/test/unit/agreement-manager/shared.t.sol new file mode 100644 index 000000000..97056e564 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/shared.t.sol @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; +import { RecurringAgreementManager } from "../../../contracts/agreement/RecurringAgreementManager.sol"; +import { RecurringAgreementHelper } from "../../../contracts/agreement/RecurringAgreementHelper.sol"; +import { MockGraphToken } from "./mocks/MockGraphToken.sol"; +import { MockPaymentsEscrow } from "./mocks/MockPaymentsEscrow.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; +import { MockSubgraphService } from "./mocks/MockSubgraphService.sol"; + +/// @notice Shared test setup for RecurringAgreementManager tests. +contract RecurringAgreementManagerSharedTest is Test { + // -- Contracts -- + MockGraphToken internal token; + MockPaymentsEscrow internal paymentsEscrow; + MockRecurringCollector internal recurringCollector; + MockSubgraphService internal mockSubgraphService; + RecurringAgreementManager internal agreementManager; + RecurringAgreementHelper internal agreementHelper; + + // -- Accounts -- + address internal governor; + address internal operator; + address internal indexer; + address internal dataService; + + // -- Constants -- + bytes32 internal constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE"); + bytes32 internal constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); + bytes32 internal constant DATA_SERVICE_ROLE = keccak256("DATA_SERVICE_ROLE"); + bytes32 internal constant COLLECTOR_ROLE = keccak256("COLLECTOR_ROLE"); + bytes32 internal constant AGREEMENT_MANAGER_ROLE = keccak256("AGREEMENT_MANAGER_ROLE"); + + function setUp() public virtual { + governor = makeAddr("governor"); + operator = makeAddr("operator"); + indexer = makeAddr("indexer"); + + // Deploy mocks + token = new MockGraphToken(); + paymentsEscrow = new MockPaymentsEscrow(address(token)); + recurringCollector = new MockRecurringCollector(); + mockSubgraphService = new MockSubgraphService(); + dataService = address(mockSubgraphService); + + // Deploy RecurringAgreementManager behind proxy + RecurringAgreementManager impl = new RecurringAgreementManager( + IGraphToken(address(token)), + IPaymentsEscrow(address(paymentsEscrow)) + ); + bytes memory initData = abi.encodeCall(RecurringAgreementManager.initialize, (governor)); + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(impl), + address(this), // proxy admin + initData + ); + agreementManager = RecurringAgreementManager(address(proxy)); + + // Deploy RecurringAgreementHelper pointing at the manager + agreementHelper = new RecurringAgreementHelper(address(agreementManager), token); + + // Grant roles + vm.startPrank(governor); + agreementManager.grantRole(OPERATOR_ROLE, operator); + agreementManager.grantRole(DATA_SERVICE_ROLE, dataService); + agreementManager.grantRole(COLLECTOR_ROLE, address(recurringCollector)); + vm.stopPrank(); + + // Operator grants AGREEMENT_MANAGER_ROLE to itself (OPERATOR_ROLE is its admin) + vm.prank(operator); + agreementManager.grantRole(AGREEMENT_MANAGER_ROLE, operator); + + // Label addresses for trace output + vm.label(address(token), "GraphToken"); + vm.label(address(paymentsEscrow), "PaymentsEscrow"); + vm.label(address(recurringCollector), "RecurringCollector"); + vm.label(address(agreementManager), "RecurringAgreementManager"); + vm.label(address(agreementHelper), "RecurringAgreementHelper"); + vm.label(address(mockSubgraphService), "SubgraphService"); + } + + // -- Helpers -- + + /// @notice Get the default recurring collector as a typed IRecurringCollector + function _collector() internal view returns (IRecurringCollector) { + return IRecurringCollector(address(recurringCollector)); + } + + /// @notice Create a standard RCA with RecurringAgreementManager as payer + function _makeRCA( + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 minSecondsPerCollection, + uint32 maxSecondsPerCollection, + uint64 endsAt + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: endsAt, + payer: address(agreementManager), + dataService: dataService, + serviceProvider: indexer, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: minSecondsPerCollection, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: 1, + metadata: "" + }); + } + + /// @notice Create a standard RCA and compute its agreementId + function _makeRCAWithId( + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + uint64 endsAt + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = _makeRCA(maxInitialTokens, maxOngoingTokensPerSecond, 60, maxSecondsPerCollection, endsAt); + agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + } + + /// @notice Offer an RCA via the operator and return the agreementId + function _offerAgreement(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + // Fund RecurringAgreementManager with enough tokens + token.mint(address(agreementManager), 1_000_000 ether); + + vm.prank(operator); + return agreementManager.offerAgreement(rca, _collector()); + } + + /// @notice Create a standard RCAU for an existing agreement + function _makeRCAU( + bytes16 agreementId, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 minSecondsPerCollection, + uint32 maxSecondsPerCollection, + uint64 endsAt, + uint32 nonce + ) internal pure returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, // Not used for unsigned path + endsAt: endsAt, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: minSecondsPerCollection, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: nonce, + metadata: "" + }); + } + + /// @notice Offer an RCAU via the operator + function _offerAgreementUpdate( + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau + ) internal returns (bytes16) { + vm.prank(operator); + return agreementManager.offerAgreementUpdate(rcau); + } + + /// @notice Set up a mock agreement in RecurringCollector as Accepted + function _setAgreementAccepted( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint64 acceptedAt + ) internal { + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: acceptedAt, + lastCollectionAt: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + } + + /// @notice Set up a mock agreement as CanceledByServiceProvider + function _setAgreementCanceledBySP( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal { + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: uint64(block.timestamp), + lastCollectionAt: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: uint64(block.timestamp), + state: IRecurringCollector.AgreementState.CanceledByServiceProvider + }) + ); + } + + /// @notice Set up a mock agreement as CanceledByPayer + function _setAgreementCanceledByPayer( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint64 acceptedAt, + uint64 canceledAt, + uint64 lastCollectionAt + ) internal { + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: acceptedAt, + lastCollectionAt: lastCollectionAt, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: canceledAt, + state: IRecurringCollector.AgreementState.CanceledByPayer + }) + ); + } + + /// @notice Set up a mock agreement as having been collected + function _setAgreementCollected( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint64 acceptedAt, + uint64 lastCollectionAt + ) internal { + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: acceptedAt, + lastCollectionAt: lastCollectionAt, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + } +} diff --git a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol new file mode 100644 index 000000000..f454f0080 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol @@ -0,0 +1,742 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ==================== Basic Thaw / Withdraw ==================== + + function test_UpdateEscrow_ThawsExcessWhenNoAgreements() public { + // Create agreement, fund escrow, then reconcile it + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Verify escrow was funded + (uint256 fundedBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + fundedBalance, + maxClaim + ); + + // SP cancels — reconcileAgreement triggers escrow update, thawing the full balance + _setAgreementCanceledBySP(agreementId, rca); + + agreementManager.reconcileAgreement(agreementId); + + assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + + // balance should now be fully thawing + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance - account.tokensThawing, 0); + } + + function test_UpdateEscrow_WithdrawsCompletedThaw() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // SP cancels and reconcile (triggers thaw) + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + // Fast forward past thawing period (1 day in mock) + vm.warp(block.timestamp + 1 days + 1); + + uint256 agreementManagerBalanceBefore = token.balanceOf(address(agreementManager)); + + // reconcileCollectorProvider: withdraw + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Tokens should be back in RecurringAgreementManager + uint256 agreementManagerBalanceAfter = token.balanceOf(address(agreementManager)); + assertEq(agreementManagerBalanceAfter - agreementManagerBalanceBefore, maxClaim); + } + + function test_UpdateEscrow_NoopWhenNoBalance() public { + // No agreements, no balance — should succeed silently + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + } + + function test_UpdateEscrow_NoopWhenStillThawing() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // SP cancels and reconcile (triggers thaw) + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(agreementId); + + // Subsequent call before thaw complete: no-op (thaw in progress, amount is correct) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Balance should still be fully thawing + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.balance - account.tokensThawing, 0); + } + + function test_UpdateEscrow_Permissionless() public { + // Anyone can call reconcileCollectorProvider + address anyone = makeAddr("anyone"); + vm.prank(anyone); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + } + + // ==================== Excess Thawing With Active Agreements ==================== + + function test_UpdateEscrow_ThawsExcessWithActiveAgreements() public { + // Offer agreement, accept, then reconcile down — excess should be thawed + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Accept and simulate a collection (reduces maxNextClaim) + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + uint64 collectionTime = uint64(block.timestamp + 1800); + _setAgreementCollected(agreementId, rca, uint64(block.timestamp), collectionTime); + vm.warp(collectionTime); + + // Reconcile — should reduce required escrow + agreementManager.reconcileAgreement(agreementId); + uint256 newRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + assertTrue(newRequired < maxClaim, "Required should have decreased"); + + // Escrow balance is still maxClaim — excess exists + // The reconcileAgreement call already invoked _updateEscrow which thawed the excess + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 expectedExcess = maxClaim - newRequired; + assertEq(account.tokensThawing, expectedExcess, "Excess should be thawing"); + + // Liquid balance should equal required + uint256 liquid = account.balance - account.tokensThawing; + assertEq(liquid, newRequired, "Liquid balance should equal required"); + } + + // ==================== Partial Cancel ==================== + + function test_OfferAgreement_PartialCancelPreservesThawTimer() public { + // Setup: two agreements, reconcile one down to create excess, thaw it + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaimEach = 1 ether * 3600 + 100 ether; + + // SP cancels agreement 1, reconcile to 0 (triggers thaw of excess) + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(id1); + + // Verify excess is thawing + IPaymentsEscrow.EscrowAccount memory accountBefore; + (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(accountBefore.tokensThawing, maxClaimEach, "Excess should be thawing"); + uint256 thawEndBefore = accountBefore.thawEndTimestamp; + assertTrue(0 < thawEndBefore, "Thaw should be in progress"); + + // Now offer a small new agreement — should partial-cancel, NOT restart timer + IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCA( + 10 ether, + 0.1 ether, + 60, + 1800, + uint64(block.timestamp + 180 days) + ); + rca3.nonce = 3; + _offerAgreement(rca3); + + uint256 maxClaim3 = 0.1 ether * 1800 + 10 ether; + + // Check that thaw was partially canceled (not fully canceled) + IPaymentsEscrow.EscrowAccount memory accountAfter; + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // New required = maxClaimEach + maxClaim3 + // Excess = 2*maxClaimEach - (maxClaimEach + maxClaim3) = maxClaimEach - maxClaim3 + uint256 expectedThawing = maxClaimEach - maxClaim3; + assertEq(accountAfter.tokensThawing, expectedThawing, "Thaw should be partially canceled"); + + // Timer should be preserved (not reset) + assertEq(accountAfter.thawEndTimestamp, thawEndBefore, "Thaw timer should be preserved"); + + // Liquid balance should cover new required + uint256 newRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 liquid = accountAfter.balance - accountAfter.tokensThawing; + assertEq(liquid, newRequired, "Liquid should cover required"); + } + + function test_UpdateEscrow_FullCancelWhenDeficit() public { + // Setup: agreement funded, then increase required beyond balance + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 id1 = _offerAgreement(rca1); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + + // SP cancels, reconcile to 0 (triggers thaw of all excess) + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(id1); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, maxClaim1, "All should be thawing"); + + // Now offer a new agreement larger than what's in escrow + // This will make balance < required, so all thawing should be canceled + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 500 ether, + 5 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + _offerAgreement(rca2); + + // Thaw should have been fully canceled + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq(account.tokensThawing, 0, "Thaw should be fully canceled for deficit"); + } + + function test_UpdateEscrow_SkipsThawIncreaseToPreserveTimer() public { + // Setup: two agreements, thaw excess from removing first + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + uint256 maxClaimEach = 1 ether * 3600 + 100 ether; + + // Reconcile agreement 1 to create excess (triggers thaw) + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(id1); + + IPaymentsEscrow.EscrowAccount memory accountBefore; + (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(accountBefore.tokensThawing, maxClaimEach); + uint256 thawEndBefore = accountBefore.thawEndTimestamp; + + // Advance time halfway through thawing + vm.warp(block.timestamp + 12 hours); + + // Reconcile agreement 2 — excess grows to 2*maxClaimEach + // Uses evenIfTimerReset=false internally, so thaw increase is skipped + bytes16 id2 = bytes16( + recurringCollector.generateAgreementId( + rca2.payer, + rca2.dataService, + rca2.serviceProvider, + rca2.deadline, + rca2.nonce + ) + ); + _setAgreementCanceledBySP(id2, rca2); + agreementManager.reconcileAgreement(id2); + agreementManager.reconcileAgreement(id2); + + IPaymentsEscrow.EscrowAccount memory accountAfter; + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Timer preserved — thaw increase was skipped to avoid resetting it + assertEq(accountAfter.thawEndTimestamp, thawEndBefore, "Thaw timer should be preserved"); + // Thaw amount stays at original (increase skipped) + assertEq(accountAfter.tokensThawing, maxClaimEach, "Thaw should stay at original amount"); + } + + // ==================== Data-driven: _updateEscrow combinations ==================== + // + // Tests all (escrowBasis, accountState) combinations via a helper that: + // 1. Sets escrowBasis (controls min/max) + // 2. Overrides mock escrow to desired (balance, tokensThawing, thawReady) + // 3. Calls reconcileCollectorProvider + // 4. Asserts expected (balance, tokensThawing) + // + // Desired behavior (the 4 objectives): + // Obj 1: liquid stays in [min, max] + // Obj 2: withdraw excess above min if thaw completed + // Obj 3: never increase thaw amount (would reset timer) + // Obj 4: minimize transactions — no needless deposit/thaw/cancel + + function _check( + IRecurringEscrowManagement.EscrowBasis basis, + uint256 bal, + uint256 thawing, + bool ready, + uint256 expBal, + uint256 expThaw, + string memory label + ) internal { + uint256 snap = vm.snapshot(); + + vm.prank(operator); + agreementManager.setEscrowBasis(basis); + + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + bal, + thawing, + ready ? block.timestamp - 1 : (0 < thawing ? block.timestamp + 1 days : 0) + ); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory r; + (r.balance, r.tokensThawing, r.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(r.balance, expBal, string.concat(label, ": balance")); + assertEq(r.tokensThawing, expThaw, string.concat(label, ": thawing")); + + assertTrue(vm.revertTo(snap)); + } + + /// @dev Like _check but sets thawEndTimestamp to an exact value (for boundary testing) + function _checkAtTimestamp( + IRecurringEscrowManagement.EscrowBasis basis, + uint256 bal, + uint256 thawing, + uint256 thawEndTimestamp, + uint256 expBal, + uint256 expThaw, + string memory label + ) internal { + uint256 snap = vm.snapshot(); + + vm.prank(operator); + agreementManager.setEscrowBasis(basis); + + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + bal, + thawing, + thawEndTimestamp + ); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + IPaymentsEscrow.EscrowAccount memory r; + (r.balance, r.tokensThawing, r.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(r.balance, expBal, string.concat(label, ": balance")); + assertEq(r.tokensThawing, expThaw, string.concat(label, ": thawing")); + + assertTrue(vm.revertTo(snap)); + } + + function test_UpdateEscrow_Combinations() public { + // S = sumMaxNextClaim, established by offering one agreement in Full mode. + // After offer: escrow balance = S, manager minted 1M in setUp. + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + uint256 S = 1 ether * 3600 + 100 ether; // 3700 ether + + // Ensure mock has enough ERC20 for large-balance test cases + token.mint(address(paymentsEscrow), 10 * S); + // Ensure 1 < block.timestamp so "thawReady" timestamps are non-zero + vm.warp(100); + + // ── Full mode: min = S, max = S ───────────────────────────────── + IRecurringEscrowManagement.EscrowBasis F = IRecurringEscrowManagement.EscrowBasis.Full; + + // basis bal thaw ready expBal expThaw + _check(F, S, 0, false, S, 0, "F1:balanced"); + _check(F, 2 * S, 0, false, 2 * S, S, "F2:excess->thaw"); + _check(F, S / 2, 0, false, S, 0, "F3:deficit->deposit"); + _check(F, 0, 0, false, S, 0, "F4:empty->deposit"); + _check(F, 2 * S, S, false, 2 * S, S, "F5:thaw,liquid=min->leave"); + _check(F, 2 * S, (S * 3) / 2, false, 2 * S, S, "F6:thaw,liquidcancel-to-min"); + _check(F, 2 * S, S, true, S, 0, "F7:ready,liquid=min->withdraw"); + _check(F, S, S, true, S, 0, "F8:ready,liquid=0->cancel-all"); + _check(F, S, S, false, S, 0, "F9:thaw,liquid=0->cancel-all"); + + // ── OnDemand mode: min = 0, max = S ───────────────────────────── + IRecurringEscrowManagement.EscrowBasis O = IRecurringEscrowManagement.EscrowBasis.OnDemand; + + _check(O, S, 0, false, S, 0, "O1:balanced"); + _check(O, 2 * S, 0, false, 2 * S, S, "O2:excess->thaw"); + _check(O, S / 2, 0, false, S / 2, 0, "O3:no-deposit(min=0)"); + _check(O, 0, 0, false, 0, 0, "O4:empty,no-op"); + _check(O, 2 * S, S, false, 2 * S, S, "O5:thaw,liquid>=min->leave"); + _check(O, 2 * S, (S * 3) / 2, false, 2 * S, (S * 3) / 2, "O6:thaw,liquid>=min->LEAVE(key)"); + _check(O, 2 * S, S, true, S, 0, "O7:ready->withdraw"); + _check(O, S, S, true, 0, 0, "O8:ready,all-thaw->withdraw-all"); + _check(O, S, S, false, S, S, "O9:thaw,liquid=0>=min->leave"); + + // ── JIT mode: min = 0, max = 0 ────────────────────────────────── + IRecurringEscrowManagement.EscrowBasis J = IRecurringEscrowManagement.EscrowBasis.JustInTime; + + _check(J, S, 0, false, S, S, "J1:thaw-all(max=0)"); + _check(J, 0, 0, false, 0, 0, "J2:empty,no-op"); + _check(J, 2 * S, S, false, 2 * S, 2 * S, "J3:same-block->increase-ok"); + _check(J, S, S, true, 0, 0, "J4:ready->withdraw-all"); + _check(J, 2 * S, S, true, S, S, "J5:ready->withdraw,thaw-rest"); + + // ── Boundary: thawEndTimestamp == block.timestamp should NOT withdraw ── + // PaymentsEscrow requires block.timestamp > thawEnd (strict); at the + // exact boundary the thaw has not yet completed. + _checkAtTimestamp(F, 2 * S, S, block.timestamp, 2 * S, S, "B1:boundary-full->no-withdraw"); + _checkAtTimestamp(O, 2 * S, S, block.timestamp, 2 * S, S, "B2:boundary-ondemand->no-withdraw"); + _checkAtTimestamp(J, S, S, block.timestamp, S, S, "B3:boundary-jit->no-withdraw"); + } + + // ==================== Cross-Indexer Isolation ==================== + + function test_UpdateEscrow_CrossIndexerIsolation() public { + address indexer2 = makeAddr("indexer2"); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Reconcile indexer1's agreement (triggers thaw) + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + IPaymentsEscrow.EscrowAccount memory acct1; + (acct1.balance, acct1.tokensThawing, acct1.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(acct1.balance - acct1.tokensThawing, 0); + + // Indexer2 escrow should be unaffected + (uint256 indexer2Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); + assertEq( + indexer2Balance, + maxClaim2 + ); + + // reconcileCollectorProvider on indexer2 should be a no-op (balance == required) + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + (uint256 indexer2BalanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); + assertEq( + indexer2BalanceAfter, + maxClaim2 + ); + } + + // ==================== NoopWhenBalanced ==================== + + function test_UpdateEscrow_NoopWhenBalanced() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Balance should exactly match required — no excess, no deficit + (uint256 balanceBefore,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + balanceBefore, + maxClaim + ); + + // reconcileCollectorProvider should be a no-op + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // Nothing changed + (uint256 balanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq( + balanceAfter, + maxClaim + ); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, 0, "No thawing should occur"); + } + + // ==================== Automatic Thaw on Reconcile ==================== + + function test_Reconcile_AutomaticallyThawsExcess() public { + // Reconcile calls _updateEscrow, which should thaw excess automatically + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Accept and simulate a collection + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + uint64 collectionTime = uint64(block.timestamp + 1800); + _setAgreementCollected(agreementId, rca, uint64(block.timestamp), collectionTime); + vm.warp(collectionTime); + + // Reconcile — triggers _updateEscrow internally + agreementManager.reconcileAgreement(agreementId); + + // Excess should already be thawing + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 newRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 expectedExcess = maxClaim - newRequired; + assertEq(account.tokensThawing, expectedExcess, "Excess should auto-thaw after reconcile"); + } + + // ==================== Withdraw guard: compare against liquid, not total ==================== + + function test_UpdateEscrow_WithdrawsPartialWhenLiquidCoversMin() public { + // Two agreements: keep the big one, reconcile the small one. + // After thaw completes, min <= liquid (= big max claim) -> withdraw proceeds. + // Only the small agreement's tokens leave escrow; min stays behind. + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca1.nonce = 1; + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + + _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; // 3700 ether + uint256 maxClaim2 = 0.5 ether * 1800 + 50 ether; // 950 ether + + // Cancel and reconcile rca2 -> excess (950) thawed, rca1 remains + _setAgreementCanceledBySP(id2, rca2); + agreementManager.reconcileAgreement(id2); + + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, maxClaim2, "Excess from rca2 should be thawing"); + assertEq(account.balance - account.tokensThawing, maxClaim1, "Liquid should cover rca1"); + + // Wait for thaw to complete + vm.warp(block.timestamp + 1 days + 1); + + // Expect the withdraw event for the thawed amount + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim2); + + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // After withdraw: only rca1's required amount remains, nothing thawing + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq(account.balance, maxClaim1, "Balance should equal remaining min"); + assertEq(account.tokensThawing, 0, "Nothing should be thawing after withdraw"); + } + + function test_UpdateEscrow_PartialCancelAndWithdrawInOneCall() public { + // Scenario: all tokens thawing and ready, offer a smaller replacement. + // _updateEscrow partial-cancels thaw (to balance - min), then withdraws the + // reduced amount in a single call. No round-trip: balance ends at min, no redeposit. + + (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 id1 = _offerAgreement(rca1); + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; // 3700 ether + + // Reconcile -> full thaw + _setAgreementCanceledBySP(id1, rca1); + agreementManager.reconcileAgreement(id1); + + // Verify: entire balance is thawing, liquid = 0 + IPaymentsEscrow.EscrowAccount memory account; + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(account.tokensThawing, maxClaim1, "All should be thawing"); + assertEq(account.balance - account.tokensThawing, 0, "Liquid should be zero"); + + // Wait for thaw to complete + vm.warp(block.timestamp + 1 days + 1); + + // Offer smaller replacement -> _updateEscrow fires + // Partial-cancels thaw (3700 -> 2750), then withdraws 2750. Balance = 950 = min. + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 50 ether, + 0.5 ether, + 60, + 1800, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + uint256 maxClaim2 = 0.5 ether * 1800 + 50 ether; // 950 ether + + _offerAgreement(rca2); + + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + assertEq(account.balance, maxClaim2, "Balance should equal min after partial-cancel + withdraw"); + assertEq(account.tokensThawing, 0, "Nothing thawing after withdraw"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} From 8673c34c0c04817e74b166c03500fdcac4d08c1a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:47:23 +0000 Subject: [PATCH 049/157] fix(rewards): reorder subtraction in _updateSubgraphRewards to avoid underflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code's two hooks wrote to different fields with inverted semantics: - onSubgraphSignalUpdate set accRewardsForSubgraph (A) from storage - onSubgraphAllocationUpdate set accRewardsForSubgraphSnapshot (S) from a view (storage + pending), so S leads and A lags after allocation updates After the proxy upgrade, _updateSubgraphRewards computed A.sub(S).add(P) which underflows on the intermediate A - S when A < S. Rearranging to A.add(P).sub(S) adds pending rewards first, avoiding the intermediate underflow. S <= A + P always holds because P covers T1→now (a superset of the T1→T2 gap S - A). Observed on Arbitrum Sepolia: A < S by ~7,235 GRT for subgraphs whose last pre-upgrade interaction was onSubgraphAllocationUpdate. All reward operations (signal, allocation, claim) reverted permanently. --- .../rewards-snapshot-inversion.test.ts | 436 ++++++++++++++++++ .../contracts/rewards/RewardsManager.sol | 15 +- 2 files changed, 444 insertions(+), 7 deletions(-) create mode 100644 packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts diff --git a/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts new file mode 100644 index 000000000..a17427fa8 --- /dev/null +++ b/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts @@ -0,0 +1,436 @@ +import { Curation } from '@graphprotocol/contracts' +import { GraphToken } from '@graphprotocol/contracts' +import { IStaking } from '@graphprotocol/contracts' +import { RewardsManager } from '@graphprotocol/contracts' +import { deriveChannelKey, GraphNetworkContracts, helpers, randomHexBytes, toGRT } from '@graphprotocol/sdk' +import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' +import { expect } from 'chai' +import { BigNumber, constants, utils } from 'ethers' +import hre from 'hardhat' + +import { NetworkFixture } from '../lib/fixtures' + +const { HashZero } = constants + +/** + * Tests for snapshot inversion on upgrade. + * + * Terminology: + * A = accRewardsForSubgraph (stored accumulator, set at signal updates) + * S = accRewardsForSubgraphSnapshot (stored snapshot, set at allocation updates) + * P = rewardsSinceSignalSnapshot (pending rewards since last signal snapshot) + * + * After a proxy upgrade, subgraphs whose last pre-upgrade interaction was + * `onSubgraphAllocationUpdate` have A < S. The old code set S from a view function + * (storage + pending) while leaving A at its stored value, so S leads and A lags. + * The original code's `A.sub(S).add(P)` reverts on the intermediate `A - S`. + * + * The fix: Rearrange to `A.add(P).sub(S)` — add P first, then subtract S. + * Since P covers T1→now and the gap S - A covers T1→T2, and now >= T2, + * we have S - A <= P, so S <= A + P always holds. No clamping needed. + * + * These tests use `hardhat_setStorageAt` to directly create the inverted storage state + * that exists on-chain for affected subgraphs. + */ +describe('Rewards: Snapshot Inversion', () => { + const graph = hre.graph() + let governor: SignerWithAddress + let curator: SignerWithAddress + let indexer: SignerWithAddress + + let fixture: NetworkFixture + let contracts: GraphNetworkContracts + let grt: GraphToken + let curation: Curation + let staking: IStaking + let rewardsManager: RewardsManager + + const channelKey = deriveChannelKey() + const subgraphDeploymentID = randomHexBytes() + const allocationID = channelKey.address + const metadata = HashZero + + const tokensToSignal = toGRT('1000') + const tokensToStake = toGRT('100000') + const tokensToAllocate = toGRT('10000') + + // Storage slot for the `subgraphs` mapping in RewardsManagerV1Storage. + // Computed by counting all inherited storage variables: + // Managed: controller(0), _addressCache(1), __gap[10](2-11) = 12 slots + // V1Storage: __DEPRECATED_issuanceRate(12), accRewardsPerSignal(13), + // accRewardsPerSignalLastBlockUpdated(14), subgraphAvailabilityOracle(15), + // subgraphs(16) + const SUBGRAPHS_MAPPING_SLOT = 16 + + /** + * Compute the storage slot for a field within a Subgraph struct in the subgraphs mapping. + * + * For `mapping(bytes32 => Subgraph)` at slot S, key K: + * base = keccak256(abi.encode(K, S)) + * field 0 (accRewardsForSubgraph) = base + 0 + * field 1 (accRewardsForSubgraphSnapshot) = base + 1 + * field 2 (accRewardsPerSignalSnapshot) = base + 2 + * field 3 (accRewardsPerAllocatedToken) = base + 3 + */ + function subgraphStorageSlot(subgraphId: string, fieldOffset: number): string { + const baseSlot = utils.keccak256( + utils.defaultAbiCoder.encode(['bytes32', 'uint256'], [subgraphId, SUBGRAPHS_MAPPING_SLOT]), + ) + return utils.hexZeroPad(BigNumber.from(baseSlot).add(fieldOffset).toHexString(), 32) + } + + /** + * Set a uint256 value at a specific storage slot of the RewardsManager proxy. + */ + async function setStorage(slot: string, value: BigNumber): Promise { + await hre.network.provider.send('hardhat_setStorageAt', [ + rewardsManager.address, + slot, + utils.hexZeroPad(value.toHexString(), 32), + ]) + } + + /** + * Create the inverted snapshot state that exists on-chain for affected subgraphs. + * + * Sets: accRewardsForSubgraphSnapshot = accRewardsForSubgraph + gap + * This is the state left by the old `onSubgraphAllocationUpdate` which wrote + * the snapshot from a view function (storage + pending), while leaving + * accRewardsForSubgraph at its stored value. + */ + async function createInvertedState(subgraphId: string, gap: BigNumber): Promise { + const subgraph = await rewardsManager.subgraphs(subgraphId) + const currentAccRewards = subgraph.accRewardsForSubgraph + const invertedSnapshot = currentAccRewards.add(gap) + + // Write accRewardsForSubgraphSnapshot = currentAccRewards + gap (field offset 1) + const snapshotSlot = subgraphStorageSlot(subgraphId, 1) + await setStorage(snapshotSlot, invertedSnapshot) + + // Verify the inversion was written correctly + const after = await rewardsManager.subgraphs(subgraphId) + expect(after.accRewardsForSubgraphSnapshot).to.equal(invertedSnapshot) + expect(after.accRewardsForSubgraph).to.be.lt(after.accRewardsForSubgraphSnapshot) + } + + before(async function () { + ;[curator, indexer] = await graph.getTestAccounts() + ;({ governor } = await graph.getNamedAccounts()) + + fixture = new NetworkFixture(graph.provider) + contracts = await fixture.load(governor) + grt = contracts.GraphToken as GraphToken + curation = contracts.Curation as Curation + staking = contracts.Staking as IStaking + rewardsManager = contracts.RewardsManager as RewardsManager + }) + + beforeEach(async function () { + await fixture.setUp() + }) + + afterEach(async function () { + await fixture.tearDown() + }) + + async function setupSubgraphWithAllocation() { + // Set issuance rate (200 GRT/block) — the fixture defaults to 0 + await rewardsManager.connect(governor).setIssuancePerBlock(toGRT('200')) + + // Curator signals on subgraph + await grt.connect(governor).mint(curator.address, tokensToSignal) + await grt.connect(curator).approve(curation.address, tokensToSignal) + await curation.connect(curator).mint(subgraphDeploymentID, tokensToSignal, 0) + + // Indexer stakes and allocates + await grt.connect(governor).mint(indexer.address, tokensToStake) + await grt.connect(indexer).approve(staking.address, tokensToStake) + await staking.connect(indexer).stake(tokensToStake) + await staking + .connect(indexer) + .allocateFrom( + indexer.address, + subgraphDeploymentID, + tokensToAllocate, + allocationID, + metadata, + await channelKey.generateProof(indexer.address), + ) + + // Accumulate some rewards + await helpers.mine(50) + + // Sync subgraph state so we have non-zero accRewardsForSubgraph + await rewardsManager.connect(governor).onSubgraphSignalUpdate(subgraphDeploymentID) + } + + describe('storage slot verification', function () { + it('should correctly compute and write to subgraph storage slots', async function () { + await setupSubgraphWithAllocation() + + // Read current state + const before = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(before.accRewardsForSubgraph).to.not.equal(0, 'precondition: should have accumulated rewards') + + // Write a known value to accRewardsForSubgraphSnapshot (field 1) + const testValue = BigNumber.from('12345678901234567890') + const snapshotSlot = subgraphStorageSlot(subgraphDeploymentID, 1) + await setStorage(snapshotSlot, testValue) + + // Read back and verify + const after = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(after.accRewardsForSubgraphSnapshot).to.equal(testValue) + // Other fields should be unchanged + expect(after.accRewardsForSubgraph).to.equal(before.accRewardsForSubgraph) + expect(after.accRewardsPerSignalSnapshot).to.equal(before.accRewardsPerSignalSnapshot) + expect(after.accRewardsPerAllocatedToken).to.equal(before.accRewardsPerAllocatedToken) + }) + }) + + describe('inverted state: accumulated < snapshot', function () { + it('should not revert on onSubgraphSignalUpdate with inverted state', async function () { + await setupSubgraphWithAllocation() + + // Create the pre-upgrade inverted state (snapshot > accumulated by ~7000 GRT) + const gap = toGRT('7000') + await createInvertedState(subgraphDeploymentID, gap) + + // Advance enough blocks so P > gap. At ~200 GRT/block, 50 blocks ≈ 10,000 GRT > 7,000. + await helpers.mine(50) + + // Old code: A.sub(S).add(P) reverts on intermediate A - S when A < S. + // Fix: A.add(P).sub(S) adds P first, so A + P >= S always holds. + await expect(rewardsManager.connect(governor).onSubgraphSignalUpdate(subgraphDeploymentID)).to.not.be.reverted + }) + + it('should not revert on onSubgraphAllocationUpdate with inverted state', async function () { + await setupSubgraphWithAllocation() + + const gap = toGRT('7000') + await createInvertedState(subgraphDeploymentID, gap) + + await helpers.mine(50) + + await expect(rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID)).to.not.be.reverted + }) + + it('should sync snapshots after first successful call', async function () { + await setupSubgraphWithAllocation() + + const gap = toGRT('7000') + await createInvertedState(subgraphDeploymentID, gap) + + await helpers.mine(50) + + // First call with inverted state + await rewardsManager.connect(governor).onSubgraphSignalUpdate(subgraphDeploymentID) + + // After the fix processes the inverted state, snapshots should be synced + const after = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(after.accRewardsForSubgraphSnapshot).to.equal( + after.accRewardsForSubgraph, + 'snapshot should equal accumulated after fix processes inverted state', + ) + + // Subsequent calls should work normally + await helpers.mine(10) + await expect(rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID)).to.not.be.reverted + + const afterSecond = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(afterSecond.accRewardsForSubgraphSnapshot).to.equal(afterSecond.accRewardsForSubgraph) + }) + }) + + describe('accounting correctness with inverted state', function () { + it('should correctly compute undistributed rewards: (A+P).sub(S)', async function () { + await setupSubgraphWithAllocation() + + // Record state before inversion + const before = await rewardsManager.subgraphs(subgraphDeploymentID) + const perAllocBefore = before.accRewardsPerAllocatedToken + + // Create inversion with a small gap (smaller than rewards that will accrue) + const gap = toGRT('500') + await createInvertedState(subgraphDeploymentID, gap) + + // Advance enough blocks that S < A + P (i.e., new rewards exceed the gap) + // With 200 GRT/block and only one subgraph signalled, each block adds ~200 GRT of P + // 10 blocks ≈ 2000 GRT of P, gap = 500 GRT + // So (A + P) - S = A + 2000 - (A + 500) = 1500 GRT undistributed + await helpers.mine(10) + + // Call allocation update to distribute rewards + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + + const after = await rewardsManager.subgraphs(subgraphDeploymentID) + + // accRewardsPerAllocatedToken should increase (rewards were distributed) + expect(perAllocBefore).to.be.lt(after.accRewardsPerAllocatedToken, 'should distribute rewards: 0 < (A + P) - S') + + // The distributed amount should be less than total new rewards (P) + // because the gap represents already-distributed rewards from the old code + // Undistributed = (A + P) - S = P - gap (since S = A + gap) + // If P ≈ 2000 GRT and gap = 500 GRT, undistributed ≈ 1500 GRT + // Without the gap subtraction, it would have been P ≈ 2000 GRT (double-counting) + + // Verify snapshots are synced + expect(after.accRewardsForSubgraphSnapshot).to.equal(after.accRewardsForSubgraph) + }) + + it('should not double-count: distributed rewards account for the gap', async function () { + await setupSubgraphWithAllocation() + + // Get a reference: how many rewards are distributed in normal operation + const stateBefore = await rewardsManager.subgraphs(subgraphDeploymentID) + + // Create a scenario where gap = 500 GRT + const gap = toGRT('500') + await createInvertedState(subgraphDeploymentID, gap) + + await helpers.mine(20) + + // Process the inverted state + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const afterInverted = await rewardsManager.subgraphs(subgraphDeploymentID) + const perAllocAfterInverted = afterInverted.accRewardsPerAllocatedToken + + // Now do a SECOND allocation update with normal state (snapshots are synced) + await helpers.mine(20) + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const afterNormal = await rewardsManager.subgraphs(subgraphDeploymentID) + + // The second update should distribute ~20 blocks worth of rewards + // The first update distributed less (because gap was subtracted) + // This proves no double-counting: the gap was properly deducted + const firstDelta = perAllocAfterInverted.sub(stateBefore.accRewardsPerAllocatedToken) + const secondDelta = afterNormal.accRewardsPerAllocatedToken.sub(perAllocAfterInverted) + + // First delta < second delta because the gap was subtracted + // (both periods have ~20 blocks, but first period deducts the 500 GRT gap) + expect(firstDelta).to.be.lt(secondDelta, 'first update should distribute less due to gap deduction') + }) + + it('should distribute exactly P - gap rewards (gap deducted from pending)', async function () { + await setupSubgraphWithAllocation() + + // Sync state so we have a clean baseline + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const baseline = await rewardsManager.subgraphs(subgraphDeploymentID) + const perAllocBaseline = baseline.accRewardsPerAllocatedToken + + // Create inversion with a known gap + const gap = toGRT('500') + await createInvertedState(subgraphDeploymentID, gap) + + // Mine blocks, then do a normal (non-inverted) reference run in a parallel universe + // We can't do that, but we CAN check that the gap is properly deducted by + // comparing inverted vs non-inverted runs over the same block count. + + // First: process the inverted state + await helpers.mine(20) + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const afterInverted = await rewardsManager.subgraphs(subgraphDeploymentID) + const invertedDelta = afterInverted.accRewardsPerAllocatedToken.sub(perAllocBaseline) + + // Second: run the same block count with synced state (no gap) + await helpers.mine(20) + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const afterNormal = await rewardsManager.subgraphs(subgraphDeploymentID) + const normalDelta = afterNormal.accRewardsPerAllocatedToken.sub(afterInverted.accRewardsPerAllocatedToken) + + // The inverted run should distribute LESS because the gap was subtracted. + // Both periods have ~20 blocks of rewards, but the inverted period deducts 500 GRT. + expect(invertedDelta).to.be.lt(normalDelta, 'inverted period should distribute less due to gap deduction') + expect(invertedDelta).to.not.equal(0, 'should still distribute some rewards (gap < P)') + }) + }) + + describe('normal operation (no inversion)', function () { + it('should produce identical results when A == S (post-fix steady state)', async function () { + await setupSubgraphWithAllocation() + + // Ensure snapshots are synced (normal state) + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + const synced = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(synced.accRewardsForSubgraphSnapshot).to.equal(synced.accRewardsForSubgraph) + + const perAllocBefore = synced.accRewardsPerAllocatedToken + + // Advance and update - this is the normal steady-state path + await helpers.mine(20) + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + + const after = await rewardsManager.subgraphs(subgraphDeploymentID) + + // Rewards should be distributed normally + expect(perAllocBefore).to.be.lt(after.accRewardsPerAllocatedToken) + expect(after.accRewardsForSubgraphSnapshot).to.equal(after.accRewardsForSubgraph) + }) + + it('should handle zero rewards gracefully (same block, no new rewards)', async function () { + await setupSubgraphWithAllocation() + + // Sync state + await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + + // Call again immediately (same block via automine off) + await hre.network.provider.send('evm_setAutomine', [false]) + try { + const tx = await rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID) + await hre.network.provider.send('evm_mine') + await tx.wait() + } finally { + await hre.network.provider.send('evm_setAutomine', [true]) + } + + const after = await rewardsManager.subgraphs(subgraphDeploymentID) + + // Per-alloc-token should be unchanged (zero rewards in same block) + // Note: the transaction itself mines a block, so there may be minimal reward + expect(after.accRewardsForSubgraphSnapshot).to.equal(after.accRewardsForSubgraph) + }) + }) + + describe('realistic pre-upgrade scenario', function () { + it('should handle the exact Arbitrum Sepolia state pattern', async function () { + await setupSubgraphWithAllocation() + + // Simulate: + // 1. Old onSubgraphSignalUpdate wrote accRewardsForSubgraph = X (signal-level view value) + // 2. Old onSubgraphAllocationUpdate wrote accRewardsForSubgraphSnapshot = X + delta + // (via getAccRewardsForSubgraph view which returns storage + pending) + // 3. Proxy upgrade preserves this state + // 4. New code calls _updateSubgraphRewards: A.sub(S) underflows + + // Read current A value + const state = await rewardsManager.subgraphs(subgraphDeploymentID) + const A = state.accRewardsForSubgraph + + // Set S = A + 7235 GRT (matching the ~7235 GRT gap observed on Arbitrum Sepolia) + const observedGap = toGRT('7235') + const accSlot = subgraphStorageSlot(subgraphDeploymentID, 1) + await setStorage(accSlot, A.add(observedGap)) + + // Verify the inversion + const inverted = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(inverted.accRewardsForSubgraph).to.be.lt(inverted.accRewardsForSubgraphSnapshot) + + // Advance blocks (some time passes after upgrade before first interaction) + await helpers.mine(50) + + // First interaction after "upgrade": should NOT revert + await expect(rewardsManager.connect(governor).onSubgraphSignalUpdate(subgraphDeploymentID)).to.not.be.reverted + + // State should be healed + const healed = await rewardsManager.subgraphs(subgraphDeploymentID) + expect(healed.accRewardsForSubgraphSnapshot).to.equal(healed.accRewardsForSubgraph) + + // All subsequent operations should work + await helpers.mine(10) + await expect(rewardsManager.connect(governor).onSubgraphAllocationUpdate(subgraphDeploymentID)).to.not.be.reverted + + await helpers.mine(10) + await expect(rewardsManager.connect(governor).onSubgraphSignalUpdate(subgraphDeploymentID)).to.not.be.reverted + }) + }) +}) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 846767799..9a9218093 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -520,13 +520,14 @@ contract RewardsManager is ) = _getSubgraphRewardsState(_subgraphDeploymentID); subgraph.accRewardsPerSignalSnapshot = accRewardsPerSignal; - // Calculate undistributed: rewards accumulated but not yet distributed to allocations. - // Will be just rewards since last snapshot for subgraphs that have had onSubgraphSignalUpdate or - // onSubgraphAllocationUpdate called since upgrade; - // can include non-zero (original) accRewardsForSubgraph - accRewardsForSubgraphSnapshot for - // subgraphs that have not had either hook called since upgrade. - uint256 undistributedRewards = accRewardsForSubgraph.sub(subgraph.accRewardsForSubgraphSnapshot).add( - rewardsSinceSignalSnapshot + // undistributed = (accRewardsForSubgraph + rewardsSinceSignalSnapshot) - accRewardsForSubgraphSnapshot + // We add rewardsSinceSignalSnapshot before subtracting accRewardsForSubgraphSnapshot to avoid + // an intermediate underflow: pre-upgrade state can have accRewardsForSubgraph < + // accRewardsForSubgraphSnapshot (the old alloc hook set the snapshot from a view that included + // pending rewards, while the old signal hook only wrote the stored value). The full expression + // is always non-negative because rewardsSinceSignalSnapshot covers a superset of the gap. + uint256 undistributedRewards = accRewardsForSubgraph.add(rewardsSinceSignalSnapshot).sub( + subgraph.accRewardsForSubgraphSnapshot ); if (condition != RewardsCondition.NONE) { From 506601ff81e0c1c6f3e04b9420c495244d732750 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:08:47 +0000 Subject: [PATCH 050/157] fix(test): set subgraphService in snapshot inversion tests RewardsManager._getSubgraphAllocatedTokens() only queries subgraphService, not the staking contract directly. Without setSubgraphService(staking.address), allocated tokens were 0 and rewards were dropped via NO_ALLOCATED_TOKENS condition instead of accumulated. --- .../tests/unit/rewards/rewards-snapshot-inversion.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts index a17427fa8..af22ea210 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-snapshot-inversion.test.ts @@ -123,6 +123,10 @@ describe('Rewards: Snapshot Inversion', () => { curation = contracts.Curation as Curation staking = contracts.Staking as IStaking rewardsManager = contracts.RewardsManager as RewardsManager + + // Set the staking contract as the subgraph service so RewardsManager + // can see allocations via _getSubgraphAllocatedTokens() + await rewardsManager.connect(governor).setSubgraphService(staking.address) }) beforeEach(async function () { From 32bd36134304b37849fe361480a97447732f85e3 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:07:13 +0000 Subject: [PATCH 051/157] fix(test): exclude named test users from fuzz-generated indexer addresses Foundry's dictionary-based fuzzer tries known addresses (e.g. makeAddr("fisherman")) as fuzz inputs. When a fuzz-generated indexer address collides with a named test user, mint() (which uses deal()) overwrites the user's pre-funded balance, then staking drains it to 0, causing ERC20InsufficientBalance on subsequent operations. --- .../indexing-agreement/shared.t.sol | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index ea371e237..32e7ff1e7 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -130,6 +130,9 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function _setupIndexer(Context storage _ctx, IndexerSeed memory _seed) internal returns (IndexerState memory) { vm.assume(_getIndexer(_ctx, _seed.addr).addr == address(0)); + // Exclude named test users: mint() uses deal() which SETS (not adds) token balances, + // so a collision would overwrite the user's initial balance, then staking drains it to 0. + vm.assume(!_isTestUser(_seed.addr)); (uint256 allocationKey, address allocationId) = boundKeyAndAddr(_seed.unboundedAllocationPrivateKey); vm.assume(_ctx.allocations[allocationId] == address(0)); @@ -317,6 +320,21 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun return zero; } + function _isTestUser(address _addr) internal view returns (bool) { + return + _addr == users.governor || + _addr == users.deployer || + _addr == users.indexer || + _addr == users.operator || + _addr == users.gateway || + _addr == users.verifier || + _addr == users.delegator || + _addr == users.arbitrator || + _addr == users.fisherman || + _addr == users.rewardsDestination || + _addr == users.pauseGuardian; + } + function _isSafeSubgraphServiceCaller(address _candidate) internal view returns (bool) { return _candidate != address(0) && From 0f4f48693cd6b934af924bde34a1bfcd5e7b2777 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 10 Mar 2026 09:23:15 +0000 Subject: [PATCH 052/157] feat: add issuance distribution integration to RAM - Add _ensureIncomingDistributionToCurrentBlock: calls distributeIssuance on the allocator before balance-dependent decisions, with per-block dedup via ensuredIncomingDistributedToBlock - Implement setIssuanceAllocator with ERC165 validation - Reorder struct: providerEligibilityOracle moved to end for cleaner slot packing - Add nonReentrant to beforeCollection and afterCollection as defence-in-depth against reentrancy through allocator external call - Add ensureDistributed test suite and MockIssuanceAllocator --- .../agreement/RecurringAgreementManager.md | 28 +- .../agreement/RecurringAgreementManager.sol | 85 +++- .../unit/agreement-manager/approver.t.sol | 7 +- .../agreement-manager/cancelAgreement.t.sol | 10 +- .../unit/agreement-manager/edgeCases.t.sol | 49 ++- .../agreement-manager/ensureDistributed.t.sol | 410 ++++++++++++++++++ .../test/unit/agreement-manager/fuzz.t.sol | 7 +- .../test/unit/agreement-manager/helper.t.sol | 8 +- .../mocks/MockIssuanceAllocator.sol | 54 +++ .../unit/agreement-manager/multiIndexer.t.sol | 36 +- .../unit/agreement-manager/offerUpdate.t.sol | 20 +- .../unit/agreement-manager/register.t.sol | 24 +- .../unit/agreement-manager/revokeOffer.t.sol | 6 +- .../unit/agreement-manager/updateEscrow.t.sol | 91 ++-- 14 files changed, 716 insertions(+), 119 deletions(-) create mode 100644 packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.md b/packages/issuance/contracts/agreement/RecurringAgreementManager.md index b112e5037..92b7c14de 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.md +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.md @@ -12,6 +12,16 @@ It implements seven interfaces: - **`IRecurringAgreements`** — read-only queries: agreement info, escrow state, global tracking - **`IProviderEligibility`** — delegates payment eligibility checks to an optional oracle +## Issuance Distribution + +RAM pulls minted GRT from IssuanceAllocator via `_ensureIncomingDistributionToCurrentBlock()` before any balance-dependent decision. This ensures `balanceOf(address(this))` reflects all available tokens before escrow deposits or JIT calculations. + +**Trigger points**: `beforeCollection` (JIT path, when escrow is insufficient) and `_updateEscrow` (all escrow rebalancing). Both may fire in the same transaction, so a per-block deduplication guard (`ensuredIncomingDistributedToBlock`) skips redundant allocator calls. + +**Failure tolerance**: Allocator reverts are caught via try-catch — collection continues and a `DistributeIssuanceFailed` event is emitted for monitoring. This prevents a malfunctioning allocator from blocking payments. + +**Configuration**: `setIssuanceAllocator(address)` (governor-gated) validates ERC165 support for `IIssuanceAllocationDistribution`. Setting to `address(0)` disables distribution, making the function a no-op. Both `beforeCollection` and `afterCollection` carry `nonReentrant` as defense-in-depth against the external allocator call. + ## Escrow Structure One escrow account per (RecurringAgreementManager, collector, provider) tuple covers **all** managed RCAs for that (collector, provider) pair. Multiple agreements for the same pair share a single escrow balance: @@ -122,14 +132,16 @@ Per-agreement reconciliation (`reconcileAgreement`) re-reads agreement state fro ### Global Tracking -| Storage field | Type | Updated at | -| --------------------- | ------- | --------------------------------------------------------------------------- | -| `escrowBasis` | enum | `setEscrowBasis()` | -| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | -| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | -| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `removeAgreement` (-1) | -| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | -| `tempJit` | bool | `beforeCollection` (trip), `_updateEscrow` (recover), `setTempJit` (manual) | +| Storage field | Type | Updated at | +| ----------------------------------- | ------- | --------------------------------------------------------------------------- | +| `escrowBasis` | enum | `setEscrowBasis()` | +| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | +| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | +| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `removeAgreement` (-1) | +| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | +| `tempJit` | bool | `beforeCollection` (trip), `_updateEscrow` (recover), `setTempJit` (manual) | +| `issuanceAllocator` | address | `setIssuanceAllocator()` (governor) | +| `ensuredIncomingDistributedToBlock` | uint64 | `_ensureIncomingDistributionToCurrentBlock()` (per-block dedup) | **`totalEscrowDeficit`** is maintained incrementally as `Σ max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p])` per (collector, provider). Over-deposited pairs cannot mask another pair's deficit. At each mutation point, the pair's deficit is recomputed before and after. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 0581e2f8d..309c81f21 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -5,8 +5,10 @@ pragma solidity ^0.8.27; // solhint-disable gas-strict-inequalities import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; +import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; @@ -41,7 +43,10 @@ import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/Reentran * * @custom:security CEI — All external calls target trusted protocol contracts (PaymentsEscrow, * GRT, RecurringCollector) except {cancelAgreement}'s call to the data service, which is - * governance-gated. {nonReentrant} on {cancelAgreement} provides defence-in-depth. + * governance-gated, and {_ensureIncomingDistributionToCurrentBlock}'s call to the issuance + * allocator, which is also governance-gated. {nonReentrant} on {beforeCollection}, + * {afterCollection}, and {cancelAgreement} guards against reentrancy through these external + * calls as defence-in-depth. * * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. @@ -60,6 +65,14 @@ contract RecurringAgreementManager is using EnumerableSet for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSetUtil for EnumerableSet.AddressSet; + + /// @notice Emitted when distributeIssuance() reverts (collection continues without fresh issuance) + /// @param allocator The allocator that reverted + event DistributeIssuanceFailed(address indexed allocator); + + /// @notice Thrown when the issuance allocator does not support IIssuanceAllocationDistribution + error InvalidIssuanceAllocator(address allocator); + using EnumerableSetUtil for EnumerableSet.Bytes32Set; // -- Role Constants -- @@ -94,6 +107,7 @@ contract RecurringAgreementManager is // -- Storage (ERC-7201) -- /// @custom:storage-location erc7201:graphprotocol.issuance.storage.RecurringAgreementManager + // solhint-disable-next-line gas-struct-packing struct RecurringAgreementManagerStorage { /// @notice Authorized agreement hashes — maps hash to agreementId (bytes16(0) = not authorized) mapping(bytes32 agreementHash => bytes16) authorizedHashes; @@ -111,18 +125,24 @@ contract RecurringAgreementManager is uint256 totalAgreementCount; /// @notice Last known escrow balance per (collector, provider) pair (for snapshot diff) mapping(address collector => mapping(address provider => uint256)) escrowSnap; - /// @notice Optional oracle for checking payment eligibility of service providers - IProviderEligibility providerEligibilityOracle; /// @notice Set of all collector addresses with active agreements EnumerableSet.AddressSet collectors; /// @notice Set of provider addresses per collector mapping(address collector => EnumerableSet.AddressSet) collectorProviders; /// @notice Number of agreements per (collector, provider) pair mapping(address collector => mapping(address provider => uint256)) pairAgreementCount; + /// @notice The issuance allocator that mints GRT to this contract (20 bytes) + /// @dev Packed slot (30/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + + /// escrowBasis (1) + tempJit (1). All read together in _updateEscrow / beforeCollection. + IIssuanceAllocationDistribution issuanceAllocator; + /// @notice Block number when _ensureIncomingDistributionToCurrentBlock last ran + uint64 ensuredIncomingDistributedToBlock; /// @notice Governance-configured escrow level (not modified by temp JIT) EscrowBasis escrowBasis; /// @notice Whether temporary JIT mode is active (beforeCollection couldn't deposit) bool tempJit; + /// @notice Optional oracle for checking payment eligibility of service providers (20/32 bytes in slot) + IProviderEligibility providerEligibilityOracle; } // keccak256(abi.encode(uint256(keccak256("graphprotocol.issuance.storage.RecurringAgreementManager")) - 1)) & ~bytes32(uint256(0xff)) @@ -176,8 +196,29 @@ contract RecurringAgreementManager is function beforeIssuanceAllocationChange() external virtual override {} /// @inheritdoc IIssuanceTarget - /// @dev No-op: RecurringAgreementManager receives tokens via transfer, does not need the allocator address. - function setIssuanceAllocator(address /* issuanceAllocator */) external virtual override onlyRole(GOVERNOR_ROLE) {} + /// @dev The allocator is expected to call distributeIssuance() (bringing distribution up to + /// the current block) before any configuration change. As a result, the same-block dedup in + /// {_ensureIncomingDistributionToCurrentBlock} is harmless: if a prior call already set the + /// block marker, the allocator has already distributed. Governance should set the allocator + /// in a standalone transaction to avoid interleaving with collection in the same block. + /// Even if interleaved, the only effect is a one-block lag before the new allocator's + /// distribution is picked up — corrected automatically on the next block. + function setIssuanceAllocator(address newIssuanceAllocator) external virtual override onlyRole(GOVERNOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if (address($.issuanceAllocator) == newIssuanceAllocator) return; + + if (newIssuanceAllocator != address(0)) + require( + ERC165Checker.supportsInterface( + newIssuanceAllocator, + type(IIssuanceAllocationDistribution).interfaceId + ), + InvalidIssuanceAllocator(newIssuanceAllocator) + ); + + emit IssuanceAllocatorSet(address($.issuanceAllocator), newIssuanceAllocator); + $.issuanceAllocator = IIssuanceAllocationDistribution(newIssuanceAllocator); + } // -- IAgreementOwner -- @@ -192,7 +233,7 @@ contract RecurringAgreementManager is } /// @inheritdoc IAgreementOwner - function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external override { + function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external override nonReentrant { RecurringAgreementManagerStorage storage $ = _getStorage(); AgreementInfo storage agreement = $.agreements[agreementId]; address provider = agreement.provider; @@ -203,6 +244,9 @@ contract RecurringAgreementManager is uint256 escrowBalance = _fetchEscrowAccount(msg.sender, provider).balance; if (tokensToCollect <= escrowBalance) return; + // Ensure issuance is distributed so balanceOf reflects all available tokens + _ensureIncomingDistributionToCurrentBlock($); + // Strict <: when deficit == available, enter tempJit rather than depleting entire balance uint256 deficit = tokensToCollect - escrowBalance; if (deficit < GRAPH_TOKEN.balanceOf(address(this))) { @@ -215,7 +259,7 @@ contract RecurringAgreementManager is } /// @inheritdoc IAgreementOwner - function afterCollection(bytes16 agreementId, uint256 /* tokensCollected */) external override { + function afterCollection(bytes16 agreementId, uint256 /* tokensCollected */) external override nonReentrant { RecurringAgreementManagerStorage storage $ = _getStorage(); AgreementInfo storage agreement = $.agreements[agreementId]; if (agreement.provider == address(0)) return; @@ -842,6 +886,7 @@ contract RecurringAgreementManager is */ // solhint-disable-next-line use-natspec function _updateEscrow(RecurringAgreementManagerStorage storage $, address collector, address provider) private { + _ensureIncomingDistributionToCurrentBlock($); // Auto-recover from tempJit when balance exceeds deficit (same strict < as beforeCollection/escrowMinMax) if ($.tempJit && $.totalEscrowDeficit < GRAPH_TOKEN.balanceOf(address(this))) { $.tempJit = false; @@ -943,6 +988,32 @@ contract RecurringAgreementManager is ); } + /** + * @notice Trigger issuance distribution so that balanceOf(this) reflects all available tokens. + * @dev No-op if allocator is not set or already ensured this block. The local ensuredIncomingDistributedToBlock + * check avoids the external call overhead (~2800 gas) on redundant same-block invocations + * (e.g. beforeCollection + afterCollection in the same collection tx). + */ + // solhint-disable-next-line use-natspec + function _ensureIncomingDistributionToCurrentBlock(RecurringAgreementManagerStorage storage $) private { + // Uses low 8 bytes of block.number; consecutive blocks always differ so same-block + // dedup works correctly even past uint64 wrap. A false match requires the previous + // last call to have been exactly 2^64 blocks ago (~584 billion years at 1 block/s). + uint64 blockNum; + unchecked { + blockNum = uint64(block.number); + } + if ($.ensuredIncomingDistributedToBlock == blockNum) return; + $.ensuredIncomingDistributedToBlock = blockNum; + + IIssuanceAllocationDistribution allocator = $.issuanceAllocator; + if (address(allocator) == address(0)) return; + + try allocator.distributeIssuance() {} catch { + emit DistributeIssuanceFailed(address(allocator)); + } + } + /** * @notice Get the ERC-7201 namespaced storage */ diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol index df6f44bc0..1bf635a1f 100644 --- a/packages/issuance/test/unit/agreement-manager/approver.t.sol +++ b/packages/issuance/test/unit/agreement-manager/approver.t.sol @@ -11,6 +11,7 @@ import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/al import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ @@ -103,14 +104,16 @@ contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerShare function test_SetIssuanceAllocator_OnlyGovernor() public { address nonGovernor = makeAddr("nonGovernor"); + MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.expectRevert(); vm.prank(nonGovernor); - agreementManager.setIssuanceAllocator(makeAddr("allocator")); + agreementManager.setIssuanceAllocator(address(alloc)); } function test_SetIssuanceAllocator_Governor() public { + MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.prank(governor); - agreementManager.setIssuanceAllocator(makeAddr("allocator")); + agreementManager.setIssuanceAllocator(address(alloc)); } // -- View Function Tests -- diff --git a/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol index 1c91210ec..2eae0a66e 100644 --- a/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol @@ -121,7 +121,9 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag bytes16 agreementId = _offerAgreement(rca); // Agreement is NotAccepted — should revert - vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotAccepted.selector, agreementId)); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotAccepted.selector, agreementId) + ); vm.prank(operator); agreementManager.cancelAgreement(agreementId); } @@ -154,7 +156,11 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag address nonOperator = makeAddr("nonOperator"); vm.expectRevert( - abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, + nonOperator, + AGREEMENT_MANAGER_ROLE + ) ); vm.prank(nonOperator); agreementManager.cancelAgreement(agreementId); diff --git a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol index f492297da..c08476ff9 100644 --- a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol +++ b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol @@ -503,11 +503,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); // Escrow has zero balance - (uint256 escrowBal,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - escrowBal, - 0 + (uint256 escrowBal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(escrowBal, 0); // Escrow balance is 0 assertEq(agreementManager.getEscrowAccount(_collector(), indexer).balance, 0); @@ -1018,11 +1019,11 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileAgreement(agreementId); IPaymentsEscrow.EscrowAccount memory accountBeforeWarp; - (accountBeforeWarp.balance, accountBeforeWarp.tokensThawing, accountBeforeWarp.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + ( + accountBeforeWarp.balance, + accountBeforeWarp.tokensThawing, + accountBeforeWarp.thawEndTimestamp + ) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); assertEq(accountBeforeWarp.tokensThawing, maxClaim, "All tokens should be thawing"); uint256 thawEnd = accountBeforeWarp.thawEndTimestamp; assertTrue(0 < thawEnd, "Thaw should be active"); @@ -1045,11 +1046,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Escrow balance should be unchanged (still thawing) IPaymentsEscrow.EscrowAccount memory accountAfter; - (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); assertEq(accountAfter.balance, maxClaim, "Balance unchanged at boundary"); assertEq(accountAfter.tokensThawing, maxClaim, "Still thawing at boundary"); } @@ -1069,8 +1067,11 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _setAgreementCanceledBySP(agreementId, rca); agreementManager.reconcileAgreement(agreementId); - (,, uint256 thawEnd) = paymentsEscrow - .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (, , uint256 thawEnd) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); // Warp to thawEndTimestamp + 1 vm.warp(thawEnd + 1); @@ -1081,11 +1082,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileCollectorProvider(address(_collector()), indexer); // Escrow should be empty - (uint256 finalBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - finalBalance, - 0 + (uint256 finalBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(finalBalance, 0); } // ==================== BeforeCollection Boundary (Issue 2) ==================== @@ -1102,8 +1104,11 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); - (uint256 escrowBalance,,) = paymentsEscrow - .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); assertTrue(0 < escrowBalance, "Escrow should be funded"); // Drain manager's free token balance diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol new file mode 100644 index 000000000..042deb976 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -0,0 +1,410 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { RecurringAgreementManager } from "contracts/agreement/RecurringAgreementManager.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; + +/// @notice Tests for _ensureIncomingDistributionToCurrentBlock integration: RAM calls distributeIssuance on the +/// allocator before making balance-dependent decisions in beforeCollection and _updateEscrow. +contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockIssuanceAllocator internal mockAllocator; + + function setUp() public virtual override { + super.setUp(); + mockAllocator = new MockIssuanceAllocator(token, address(agreementManager)); + vm.label(address(mockAllocator), "MockIssuanceAllocator"); + + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(mockAllocator)); + } + + // ==================== setIssuanceAllocator ==================== + + function test_SetIssuanceAllocator_StoresAddress() public { + MockIssuanceAllocator newAllocator = new MockIssuanceAllocator(token, address(agreementManager)); + + vm.prank(governor); + vm.expectEmit(address(agreementManager)); + emit IIssuanceTarget.IssuanceAllocatorSet(address(mockAllocator), address(newAllocator)); + agreementManager.setIssuanceAllocator(address(newAllocator)); + } + + function test_SetIssuanceAllocator_Revert_WhenNotGovernor() public { + vm.prank(operator); + vm.expectRevert(); + agreementManager.setIssuanceAllocator(address(mockAllocator)); + } + + function test_SetIssuanceAllocator_CanSetToZero() public { + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(0)); + // Should not revert — _ensureIncomingDistributionToCurrentBlock is a no-op with zero address + } + + function test_SetIssuanceAllocator_NoopWhenUnchanged() public { + vm.prank(governor); + vm.recordLogs(); + agreementManager.setIssuanceAllocator(address(mockAllocator)); + Vm.Log[] memory logs = vm.getRecordedLogs(); + assertEq(logs.length, 0, "should not emit when address unchanged"); + } + + // ==================== beforeCollection triggers distribution ==================== + + function test_BeforeCollection_CallsDistributeWhenEscrowShort() public { + // Set up: offer agreement so escrow is funded + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Get current escrow balance + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Configure allocator to mint tokens on distribute + mockAllocator.setMintPerDistribution(1000 ether); + + // Advance block so distribution will actually mint + vm.roll(block.number + 1); + + // Request more than escrow — triggers JIT path which calls _ensureIncomingDistributionToCurrentBlock + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 500 ether); + + // Verify distributeIssuance was called + assertGe(mockAllocator.distributeCallCount(), 1, "distributeIssuance should have been called"); + } + + function test_BeforeCollection_DistributionPreventsUnnecessaryTempJit() public { + // Set up: offer agreement, drain RAM's free balance + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Burn RAM's free balance so it can't cover a JIT deposit without distribution + uint256 freeBalance = token.balanceOf(address(agreementManager)); + vm.prank(address(agreementManager)); + token.transfer(address(1), freeBalance); + assertEq(token.balanceOf(address(agreementManager)), 0); + + // Configure allocator to mint enough to cover the deficit + uint256 deficit = 500 ether; + mockAllocator.setMintPerDistribution(deficit + 1 ether); + + // Advance block so distribution actually mints + vm.roll(block.number + 1); + + // Without distribution, this would trigger tempJit (balance=0, deficit=500). + // With distribution, the allocator mints tokens first, so JIT deposit succeeds. + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + deficit); + + // tempJit should NOT be active — distribution provided funds + assertFalse(agreementManager.isTempJit(), "tempJit should not be set when distribution provides funds"); + } + + function test_BeforeCollection_SkipsDistributeWhenEscrowSufficient() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Record count after offer (offerAgreement calls _updateEscrow which calls _ensureIncomingDistributionToCurrentBlock) + uint256 countAfterOffer = mockAllocator.distributeCallCount(); + + // Advance block so same-block dedup doesn't mask the early-return path + vm.roll(block.number + 1); + + // Request less than escrow — early return before _ensureIncomingDistributionToCurrentBlock + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1 ether); + + assertEq( + mockAllocator.distributeCallCount(), + countAfterOffer, + "should not call distribute when escrow sufficient" + ); + } + + // ==================== _updateEscrow triggers distribution ==================== + + function test_UpdateEscrow_CallsDistributeViaAfterCollection() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Simulate: agreement accepted and collected + uint64 acceptedAt = uint64(block.timestamp); + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(agreementId, rca, acceptedAt, lastCollectionAt); + vm.warp(lastCollectionAt); + + vm.roll(block.number + 1); + + // afterCollection → _reconcileAndUpdateEscrow → _updateEscrow → _ensureIncomingDistributionToCurrentBlock + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 500 ether); + + assertGe(mockAllocator.distributeCallCount(), 1, "distributeIssuance should be called via _updateEscrow"); + } + + function test_UpdateEscrow_CallsDistributeViaOfferAgreement() public { + mockAllocator.setMintPerDistribution(100 ether); + vm.roll(block.number + 1); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + // offerAgreement → _updateEscrow → _ensureIncomingDistributionToCurrentBlock + _offerAgreement(rca); + + assertGe(mockAllocator.distributeCallCount(), 1, "distributeIssuance should be called via offerAgreement"); + } + + // ==================== No allocator set ==================== + + function test_EnsureDistributed_NoopWhenAllocatorNotSet() public { + // Clear allocator + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(0)); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Mint extra tokens so JIT works without allocator + token.mint(address(agreementManager), 1000 ether); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Should not revert even without allocator + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 500 ether); + } + + // ==================== uint64 wrap ==================== + + function test_EnsureDistributed_WorksAcrossUint64Boundary() public { + // Use afterCollection path which always reaches _updateEscrow → _ensureIncomingDistributionToCurrentBlock, + // regardless of escrow balance (unlike beforeCollection which has an early return). + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Set agreement as accepted so afterCollection reconciles + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + uint256 countBefore = mockAllocator.distributeCallCount(); + + // Jump to uint64 max + vm.roll(type(uint64).max); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + assertGt(mockAllocator.distributeCallCount(), countBefore, "should distribute at uint64.max"); + + uint256 countAtMax = mockAllocator.distributeCallCount(); + + // Cross the boundary: uint64.max + 1 wraps to 0 in uint64. + // ensuredIncomingDistributedToBlock is uint64.max from the previous call, so no false match. + vm.roll(uint256(type(uint64).max) + 1); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + assertGt(mockAllocator.distributeCallCount(), countAtMax, "should distribute after uint64 wrap to 0"); + + uint256 countAfterWrap = mockAllocator.distributeCallCount(); + + // Next block after wrap (wraps to 1) also works + vm.roll(uint256(type(uint64).max) + 2); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + assertGt(mockAllocator.distributeCallCount(), countAfterWrap, "should distribute on block after wrap"); + } + + function test_EnsureDistributed_SameBlockDedup_AtUint64Boundary() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + token.mint(address(agreementManager), 10_000 ether); + + // Jump past the boundary + vm.roll(uint256(type(uint64).max) + 3); + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // First call distributes + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 1 ether); + uint256 countAfterFirst = mockAllocator.distributeCallCount(); + + // Second call same block — should NOT call distribute again + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 1 ether); + assertEq( + mockAllocator.distributeCallCount(), + countAfterFirst, + "should not distribute twice in same block after wrap" + ); + } + + // ==================== setIssuanceAllocator ERC165 validation ==================== + + function test_SetIssuanceAllocator_Revert_WhenNotERC165() public { + // Deploy a contract that doesn't support ERC165 + address notAllocator = address(new NoERC165Contract()); + vm.prank(governor); + vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, notAllocator)); + agreementManager.setIssuanceAllocator(notAllocator); + } + + function test_SetIssuanceAllocator_Revert_WhenEOA() public { + address eoa = makeAddr("eoa"); + vm.prank(governor); + vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); + agreementManager.setIssuanceAllocator(eoa); + } + + // ==================== setIssuanceAllocator switches allocator ==================== + + function test_SetIssuanceAllocator_NewAllocatorCalledNextBlock() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // Switch allocator + MockIssuanceAllocator newAllocator = new MockIssuanceAllocator(token, address(agreementManager)); + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(newAllocator)); + + // Next block: new allocator should be called via _updateEscrow + vm.roll(block.number + 1); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + + assertGe(newAllocator.distributeCallCount(), 1, "new allocator should be called on next block"); + } + + // ==================== distributeIssuance revert is caught ==================== + + function test_EnsureDistributed_CatchesAllocatorRevert() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Mint tokens so JIT can still work even without distribution + token.mint(address(agreementManager), 1000 ether); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Make allocator revert + mockAllocator.setShouldRevert(true); + vm.roll(block.number + 1); + + // beforeCollection should NOT revert — the distribution failure is caught + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 500 ether); + } + + function test_EnsureDistributed_EmitsEventOnAllocatorRevert() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + token.mint(address(agreementManager), 1000 ether); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + mockAllocator.setShouldRevert(true); + vm.roll(block.number + 1); + + vm.expectEmit(address(agreementManager)); + emit RecurringAgreementManager.DistributeIssuanceFailed(address(mockAllocator)); + + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, escrowBalance + 500 ether); + } + + /* solhint-enable graph/func-name-mixedcase */ +} + +/// @notice Helper contract with no ERC165 support for testing validation +contract NoERC165Contract { + function doSomething() external pure returns (uint256) { + return 42; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol index 7825282fc..26912be11 100644 --- a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol @@ -61,8 +61,11 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); uint256 maxNextClaim = agreementManager.getAgreementMaxNextClaim(agreementId); - (uint256 escrowBalance,,) = paymentsEscrow - .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); // In Full mode (default): // If totalEscrowDeficit < available: Full deposits required (there is buffer). diff --git a/packages/issuance/test/unit/agreement-manager/helper.t.sol b/packages/issuance/test/unit/agreement-manager/helper.t.sol index 29f83ec55..5a8c95722 100644 --- a/packages/issuance/test/unit/agreement-manager/helper.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helper.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementHelper } from "../../../contracts/agreement/RecurringAgreementHelper.sol"; @@ -17,11 +18,16 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { assertEq(address(agreementHelper.MANAGER()), address(agreementManager)); } - function test_Constructor_Revert_ZeroAddress() public { + function test_Constructor_Revert_ZeroManager() public { vm.expectRevert(RecurringAgreementHelper.ZeroAddress.selector); new RecurringAgreementHelper(address(0), token); } + function test_Constructor_Revert_ZeroGraphToken() public { + vm.expectRevert(RecurringAgreementHelper.ZeroAddress.selector); + new RecurringAgreementHelper(address(agreementManager), IERC20(address(0))); + } + // -- reconcile(provider) tests -- function test_Reconcile_AllAgreementsForIndexer() public { diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol new file mode 100644 index 000000000..3b3e1528e --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; +import { TargetIssuancePerBlock } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocatorTypes.sol"; +import { MockGraphToken } from "./MockGraphToken.sol"; + +/// @notice Mock IssuanceAllocator that tracks distribution calls and optionally mints tokens. +contract MockIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { + uint256 public distributeCallCount; + uint256 public lastDistributedBlock; + + MockGraphToken public immutable graphToken; + address public immutable target; + uint256 public mintPerDistribution; + bool public shouldRevert; + + constructor(MockGraphToken _graphToken, address _target) { + graphToken = _graphToken; + target = _target; + } + + /// @notice Set how many tokens to mint to the target on each distribution call + function setMintPerDistribution(uint256 amount) external { + mintPerDistribution = amount; + } + + /// @notice Toggle whether distributeIssuance reverts + function setShouldRevert(bool _shouldRevert) external { + shouldRevert = _shouldRevert; + } + + function distributeIssuance() external override returns (uint256) { + require(!shouldRevert, "MockIssuanceAllocator: forced revert"); + distributeCallCount++; + if (lastDistributedBlock == block.number) return block.number; + lastDistributedBlock = block.number; + if (mintPerDistribution > 0) { + graphToken.mint(target, mintPerDistribution); + } + return block.number; + } + + function getTargetIssuancePerBlock(address) external pure override returns (TargetIssuancePerBlock memory) { + return TargetIssuancePerBlock(0, 0, 0, 0); + } + + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return + interfaceId == type(IIssuanceAllocationDistribution).interfaceId || + interfaceId == type(IERC165).interfaceId; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol index 168f8208b..0a07ecef1 100644 --- a/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol +++ b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol @@ -84,21 +84,24 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS assertEq(agreementManager.getProviderAgreementCount(indexer3), 1); // Each has independent escrow balance - (uint256 indexerBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - indexerBalance, - maxClaim1 + (uint256 indexerBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); - (uint256 indexer2Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); - assertEq( - indexer2Balance, - maxClaim2 + assertEq(indexerBalance, maxClaim1); + (uint256 indexer2Balance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 ); - (uint256 indexer3Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer3); - assertEq( - indexer3Balance, - maxClaim3 + assertEq(indexer2Balance, maxClaim2); + (uint256 indexer3Balance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer3 ); + assertEq(indexer3Balance, maxClaim3); } // -- Isolation: revoke one indexer doesn't affect others -- @@ -341,11 +344,12 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS assertEq(acct1.balance - acct1.tokensThawing, 0); // Indexer2 escrow completely unaffected - (uint256 indexer2Bal,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); - assertEq( - indexer2Bal, - maxClaim2 + (uint256 indexer2Bal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 ); + assertEq(indexer2Bal, maxClaim2); // reconcileCollectorProvider on indexer2 is a no-op (balance == required, no excess) agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index 9267c549d..6049ea270 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -39,7 +39,10 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; // Required escrow should include both - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + expectedPendingMaxClaim); + assertEq( + agreementManager.getSumMaxNextClaim(_collector(), indexer), + originalMaxClaim + expectedPendingMaxClaim + ); // Original maxNextClaim unchanged assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); } @@ -105,11 +108,12 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh agreementManager.offerAgreementUpdate(rcau); // Verify escrow was funded for both - (uint256 escrowBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - escrowBalance, - sumMaxNextClaim + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(escrowBalance, sumMaxNextClaim); } function test_OfferUpdate_ReplacesExistingPending() public { @@ -224,7 +228,11 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh address nonOperator = makeAddr("nonOperator"); vm.expectRevert( - abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, + nonOperator, + AGREEMENT_MANAGER_ROLE + ) ); vm.prank(nonOperator); agreementManager.offerAgreementUpdate(rcau); diff --git a/packages/issuance/test/unit/agreement-manager/register.t.sol b/packages/issuance/test/unit/agreement-manager/register.t.sol index 2f97d25ea..23e1516a1 100644 --- a/packages/issuance/test/unit/agreement-manager/register.t.sol +++ b/packages/issuance/test/unit/agreement-manager/register.t.sol @@ -47,11 +47,12 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe agreementManager.offerAgreement(rca, _collector()); // Verify escrow was funded - (uint256 escrowBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - escrowBalance, - expectedMaxClaim + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(escrowBalance, expectedMaxClaim); } function test_Offer_PartialFunding_WhenInsufficientBalance() public { @@ -73,11 +74,12 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe // Since available < required, Full degrades to OnDemand (deposit target = 0). // No proactive deposit; JIT beforeCollection is the safety net. - (uint256 escrowBalanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - escrowBalanceAfter, - 0 + (uint256 escrowBalanceAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(escrowBalanceAfter, 0); // Escrow balance is 0 since no deposit was made assertEq(agreementManager.getEscrowAccount(_collector(), indexer).balance, 0); } @@ -206,7 +208,11 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe address nonOperator = makeAddr("nonOperator"); vm.expectRevert( - abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, + nonOperator, + AGREEMENT_MANAGER_ROLE + ) ); vm.prank(nonOperator); agreementManager.offerAgreement(rca, _collector()); diff --git a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol index 71efb325e..8f69e20d0 100644 --- a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol +++ b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol @@ -144,7 +144,11 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh address nonOperator = makeAddr("nonOperator"); vm.expectRevert( - abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, nonOperator, AGREEMENT_MANAGER_ROLE) + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, + nonOperator, + AGREEMENT_MANAGER_ROLE + ) ); vm.prank(nonOperator); agreementManager.revokeOffer(agreementId); diff --git a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol index f454f0080..9fb9b6462 100644 --- a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol +++ b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol @@ -25,11 +25,12 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS uint256 maxClaim = 1 ether * 3600 + 100 ether; // Verify escrow was funded - (uint256 fundedBalance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - fundedBalance, - maxClaim + (uint256 fundedBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(fundedBalance, maxClaim); // SP cancels — reconcileAgreement triggers escrow update, thawing the full balance _setAgreementCanceledBySP(agreementId, rca); @@ -193,11 +194,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Verify excess is thawing IPaymentsEscrow.EscrowAccount memory accountBefore; - (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); assertEq(accountBefore.tokensThawing, maxClaimEach, "Excess should be thawing"); uint256 thawEndBefore = accountBefore.thawEndTimestamp; assertTrue(0 < thawEndBefore, "Thaw should be in progress"); @@ -217,11 +215,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Check that thaw was partially canceled (not fully canceled) IPaymentsEscrow.EscrowAccount memory accountAfter; - (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); // New required = maxClaimEach + maxClaim3 // Excess = 2*maxClaimEach - (maxClaimEach + maxClaim3) = maxClaimEach - maxClaim3 @@ -275,7 +270,11 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS _offerAgreement(rca2); // Thaw should have been fully canceled - (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); assertEq(account.tokensThawing, 0, "Thaw should be fully canceled for deficit"); } @@ -308,11 +307,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS agreementManager.reconcileAgreement(id1); IPaymentsEscrow.EscrowAccount memory accountBefore; - (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); assertEq(accountBefore.tokensThawing, maxClaimEach); uint256 thawEndBefore = accountBefore.thawEndTimestamp; @@ -335,11 +331,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS agreementManager.reconcileAgreement(id2); IPaymentsEscrow.EscrowAccount memory accountAfter; - (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); + (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow + .escrowAccounts(address(agreementManager), address(recurringCollector), indexer); // Timer preserved — thaw increase was skipped to avoid resetting it assertEq(accountAfter.thawEndTimestamp, thawEndBefore, "Thaw timer should be preserved"); @@ -540,19 +533,21 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS assertEq(acct1.balance - acct1.tokensThawing, 0); // Indexer2 escrow should be unaffected - (uint256 indexer2Balance,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); - assertEq( - indexer2Balance, - maxClaim2 + (uint256 indexer2Balance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 ); + assertEq(indexer2Balance, maxClaim2); // reconcileCollectorProvider on indexer2 should be a no-op (balance == required) agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); - (uint256 indexer2BalanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer2); - assertEq( - indexer2BalanceAfter, - maxClaim2 + (uint256 indexer2BalanceAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 ); + assertEq(indexer2BalanceAfter, maxClaim2); } // ==================== NoopWhenBalanced ==================== @@ -569,21 +564,23 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS uint256 maxClaim = 1 ether * 3600 + 100 ether; // Balance should exactly match required — no excess, no deficit - (uint256 balanceBefore,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - balanceBefore, - maxClaim + (uint256 balanceBefore, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(balanceBefore, maxClaim); // reconcileCollectorProvider should be a no-op agreementManager.reconcileCollectorProvider(address(_collector()), indexer); // Nothing changed - (uint256 balanceAfter,,) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); - assertEq( - balanceAfter, - maxClaim + (uint256 balanceAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer ); + assertEq(balanceAfter, maxClaim); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -682,7 +679,11 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS agreementManager.reconcileCollectorProvider(address(_collector()), indexer); // After withdraw: only rca1's required amount remains, nothing thawing - (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); assertEq(account.balance, maxClaim1, "Balance should equal remaining min"); assertEq(account.tokensThawing, 0, "Nothing should be thawing after withdraw"); } @@ -733,7 +734,11 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS _offerAgreement(rca2); - (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); assertEq(account.balance, maxClaim2, "Balance should equal min after partial-cancel + withdraw"); assertEq(account.tokensThawing, 0, "Nothing thawing after withdraw"); } From 86a5d6e2bcc345c28a4257be0e912dc412f10aa9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 10 Mar 2026 10:25:30 +0000 Subject: [PATCH 053/157] docs: clarify two-layer token capping semantics in collection flow Update MaxSecondsPerCollectionCap.md to explicitly document that both the data service rate and the RCA payer rate are upper bounds (caps), not guaranteed payouts. Add section on two-layer capping and note DM consistency with zero-POI disputability. Update natspec on _collect, _requireValidCollect, _getCollectionInfo (RecurringCollector) and collect, _tokensToCollect (IndexingAgreement) to accurately describe each function's role in the capping chain. --- .../collectors/MaxSecondsPerCollectionCap.md | 26 ++++++++++++----- .../collectors/RecurringCollector.sol | 29 ++++++++++++++----- .../contracts/libraries/IndexingAgreement.sol | 16 ++++++---- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md b/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md index c3926b31c..10c9b53e7 100644 --- a/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md +++ b/packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md @@ -2,7 +2,7 @@ ## Problem -`_requireValidCollect` treats `maxSecondsPerCollection` as a hard deadline: +`_requireValidCollect` treated `maxSecondsPerCollection` as a hard deadline: ```solidity require( @@ -12,18 +12,28 @@ require( uint256 maxTokens = _agreement.maxOngoingTokensPerSecond * _collectionSeconds; ``` -If the indexer collects even 1 second past `maxSecondsPerCollection`, the transaction reverts and the agreement becomes permanently stuck. The only recovery is a zero-token collect that bypasses temporal validation entirely (since `_requireValidCollect` is inside `if (tokens != 0)`), which works but is an unnatural mechanism. +If the indexer collects even 1 second past `maxSecondsPerCollection`, the transaction reverts and the agreement becomes permanently stuck. The only recovery was a zero-token collect that bypasses temporal validation entirely (since `_requireValidCollect` was inside `if (tokens != 0)`). ## Fix -Cap `collectionSeconds` at `maxSecondsPerCollection` in `_getCollectionInfo`, so all callers (RC's `_collect` and SS's `IndexingAgreement.collect`) receive consistent capped seconds: +Cap `collectionSeconds` at `maxSecondsPerCollection` in `_getCollectionInfo`, so all callers receive consistent capped seconds: ```solidity uint256 elapsed = collectionEnd - collectionStart; return (true, Math.min(elapsed, uint256(_agreement.maxSecondsPerCollection)), ...); ``` -The payer's per-collection exposure is still bounded by `maxOngoingTokensPerSecond * maxSecondsPerCollection`. The indexer can collect after the window closes, but receives no more tokens than if they had collected exactly at the deadline. +The payer's per-collection exposure is still bounded by `maxOngoingTokensPerSecond * maxSecondsPerCollection`. The indexer can collect after the window closes, but the token cap is the same as if they had collected exactly at the deadline. + +## Token calculation is two-layer capping + +Tokens collected are the minimum of two independent upper bounds: + +1. **Data service request** — `IndexingAgreement._tokensToCollect` computes `collectionSeconds * (tokensPerSecond + tokensPerEntityPerSecond * entities)`. This is the data service's claim of what is owed, not a guaranteed payout. + +2. **RCA payer cap** — `RecurringCollector._requireValidCollect` computes `maxOngoingTokensPerSecond * collectionSeconds` (plus `maxInitialTokens` on first collection) and returns `min(requested, cap)`. + +Neither layer guarantees the amount — both are upper bounds. The actual payout is the minimum of the two, and may be further limited by available escrow balance. ## Why this is correct @@ -43,14 +53,16 @@ The payer's per-collection exposure is still bounded by `maxOngoingTokensPerSeco `_requireValidCollect` was previously inside `if (tokens != 0)`, allowing zero-token collections to update `lastCollectionAt` without temporal checks. With the cap in place there is no legitimate bypass scenario, so temporal validation now runs unconditionally. -This also makes `lastCollectionAt` (publicly readable via `getAgreement`) trustworthy as a liveness signal. Previously it could be advanced to `block.timestamp` without any real collection. Now it can only be updated through a validated collection, making it reliable for external consumers (e.g. payers or SAM operators checking indexer activity to decide whether to cancel). +This makes `lastCollectionAt` trustworthy as a liveness signal — it can only advance through temporally validated collections. ## Zero-POI special case removed -The old code special-cased `entities == 0 && poi == bytes32(0)` to force `tokens = 0`, bypassing `_tokensToCollect` and RC temporal validation. This existed as a reset mechanism for stuck agreements. With the cap, there are no stuck agreements, so the special case is removed. Every collection now goes through `_tokensToCollect` and RC validation uniformly, and every POI is disputable. +The old code special-cased `entities == 0 && poi == bytes32(0)` to force `tokens = 0`, bypassing `_tokensToCollect` and RC temporal validation. This existed as a reset mechanism for stuck agreements. With the cap fix, there are no stuck agreements, so the special case is removed. + +Every collection now goes through `_tokensToCollect` and RC validation uniformly. Every POI is disputable — no exception is made for zero POI. (The Dispute Manager does not reject disputes for zero POI, so this is consistent end-to-end.) ## Contrast with indexing rewards Indexing rewards require a zero-POI "heartbeat" to keep allocations alive because reward rates change per epoch and snapshots are influenced by other participants' activity. That reset mechanism exists because the system is inherently snapshot-driven. -RCA indexing fees have no snapshots. The rate (`tokensPerSecond`, `tokensPerEntityPerSecond`) is fixed at agreement accept/update time. No external state changes the per-second rate between collections. The amount owed for N seconds of service is deterministic regardless of when collection happens, so capping is strictly correct — there is no reason to penalize a late collection beyond limiting it to `maxSecondsPerCollection` worth of tokens. +RCA indexing fees have no snapshots. The rate (`tokensPerSecond`, `tokensPerEntityPerSecond`) is fixed at agreement accept/update time. No external state changes the per-second rate between collections. Capping is strictly correct — there is no reason to penalize a late collection beyond limiting it to `maxSecondsPerCollection` worth of tokens. diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 452822a05..c03e739a4 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -300,6 +300,15 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @notice Collect payment through the payments protocol. * @dev Caller must be the data service the RCA was issued to. * + * `_params.tokens` is the data service's requested amount — an upper bound, not a guarantee. + * The actual payout is `min(_params.tokens, maxOngoingTokensPerSecond * collectionSeconds + * [+ maxInitialTokens on first collection])`, where `collectionSeconds` is already capped at + * `maxSecondsPerCollection` by `_getCollectionInfo`. + * + * Temporal validation (`minSecondsPerCollection`) is enforced unconditionally, even when + * `_params.tokens` is zero, to prevent bypassing collection windows while updating + * `lastCollectionAt`. + * * Emits {PaymentCollected} and {RCACollected} events. * * @param _paymentType The type of payment to collect @@ -450,12 +459,15 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } /** - * @notice Requires that the collection params are valid. + * @notice Validates temporal constraints and caps the requested token amount. + * @dev Enforces `minSecondsPerCollection` (unless canceled/elapsed) and returns the lesser of + * the requested amount and the RCA payer's per-collection cap + * (`maxOngoingTokensPerSecond * collectionSeconds`, plus `maxInitialTokens` on first collection). * @param _agreement The agreement data * @param _agreementId The ID of the agreement - * @param _tokens The number of tokens to collect - * @param _collectionSeconds Collection duration from _getCollectionInfo() - * @return The number of tokens that can be collected + * @param _tokens The requested token amount (upper bound from data service) + * @param _collectionSeconds Collection duration, already capped at maxSecondsPerCollection + * @return The capped token amount: min(_tokens, payer's max for this collection) */ function _requireValidCollect( AgreementData memory _agreement, @@ -679,11 +691,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } /** - * @notice Internal function to get collection info for an agreement - * @dev This is the single source of truth for collection window logic + * @notice Internal function to get collection info for an agreement. + * @dev Single source of truth for collection window logic. The returned `collectionSeconds` + * is capped at `maxSecondsPerCollection` — this is a cap on tokens, not a deadline; late + * collections succeed but receive at most `maxSecondsPerCollection` worth of tokens. * @param _agreement The agreement data * @return isCollectable Whether the agreement can be collected from - * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) + * @return collectionSeconds The valid collection duration in seconds, capped at + * maxSecondsPerCollection (0 if not collectable) * @return reason The reason why the agreement is not collectable (None if collectable) */ function _getCollectionInfo( diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index abe148e5e..d94e1401c 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -512,9 +512,11 @@ library IndexingAgreement { /* solhint-disable function-max-lines */ /** - * @notice Collect Indexing fees - * @dev Uses the {RecurringCollector} to collect payment from Graph Horizon payments protocol. - * Fees are distributed to service provider and delegators by {GraphPayments} + * @notice Collect indexing fees for an agreement. + * @dev Computes a requested token amount from indexing agreement terms + * (`collectionSeconds * (tokensPerSecond + tokensPerEntityPerSecond * entities)`) and passes + * it to {RecurringCollector}, which caps it against the RCA payer's limits. The actual payout + * is the minimum of the two. Every POI submitted is disputable — no exception for zero POI. * * Requirements: * - Allocation must be open @@ -707,12 +709,14 @@ library IndexingAgreement { } /** - * @notice Calculate tokens to collect based on pre-validated duration + * @notice Calculate the data service's requested token amount for a collection. + * @dev This is an upper bound based on indexing agreement terms, not a guaranteed payout. + * The RecurringCollector further caps the actual payout against the RCA payer's limits. * @param _manager The storage manager * @param _agreementId The agreement ID * @param _entities The number of entities indexed - * @param _collectionSeconds Pre-calculated valid collection duration - * @return The number of tokens to collect + * @param _collectionSeconds Collection duration, already capped at maxSecondsPerCollection + * @return The requested token amount (may be narrowed by RecurringCollector) */ function _tokensToCollect( StorageManager storage _manager, From 7405c9d5f73bce04734efb3f609b76d95ffb520e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:11:19 +0000 Subject: [PATCH 054/157] docs: add payments trust model Articulates trust assumptions between the five core actors (payer, collector, data service, receiver, escrow) in the Graph Horizon payments protocol, with implementation-specific details for RecurringCollector, SubgraphService, and RAM. --- docs/PaymentsTrustModel.md | 176 +++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 docs/PaymentsTrustModel.md diff --git a/docs/PaymentsTrustModel.md b/docs/PaymentsTrustModel.md new file mode 100644 index 000000000..a79c5f24e --- /dev/null +++ b/docs/PaymentsTrustModel.md @@ -0,0 +1,176 @@ +# Payments Trust Model + +This document describes the trust assumptions between the five core actors in the Graph Horizon payments protocol: **payer**, **collector**, **data service**, **receiver**, and **escrow**. The general model is described first, followed by specifics of the current implementation (RecurringCollector, SubgraphService, RAM). + +## Trust Summary + +| Relationship | Trust | Mitigation | +| --------------------------- | ----------------------------------------- | ------------------------------------------------ | +| Payer → Collector | Enforces agreed caps | Protocol-deployed; escrow caps absolute exposure | +| Payer → Receiver | Claimed work is honest | Post-hoc disputes + stake locking | +| Receiver → Payer (EOA) | Escrow stays funded | Thaw period; on-chain visibility | +| Receiver → Payer (contract) | Escrow stays funded; not block collection | RecurringAgreementManager: protocol-deployed | +| Receiver → Collector | Correctly caps and forwards payment | Protocol-deployed; code is transparent | +| Receiver → Data Service | Correct computation; not paused | Protocol-deployed; code is transparent | +| Receiver → Escrow | Releases funds on valid collection | Stateless; no discretionary logic | +| Data Service ↔ Collector | Each trusts the other's domain | Two-layer capping; independent validation | + +## Actors + +| Actor | Role | Examples | +| ---------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| **Payer** | Funds escrow; authorizes collector contracts | RecurringAgreementManager (protocol-managed), external payer (ECDSA-signed) | +| **Collector** | Validates payment requests; enforces per-agreement caps | RecurringCollector | +| **Data service** | Entry point for collection; computes amounts earned | SubgraphService | +| **Receiver** | Service provider receiving payment | Indexer | +| **Escrow** | Holds GRT per (payer, collector, receiver) tuple; enforces thaw periods | PaymentsEscrow | + +## Payment Flow (General Model) + +``` +│ Receiver +└─> Data Service.collect(work done) + └─> Collector.collect(tokens earned) + │ validates payment terms, caps amount + └─> PaymentsEscrow.collect(tokens to collect) + └─> GraphPayments.collect(tokens collected) + │ distributes to: protocol (burned), data service, delegation pool, receiver + <───┘ + <───┘ + <───┘ +<───┘ +``` + +Any data service and collector can plug into this flow. The PaymentsEscrow and GraphPayments layers are fixed protocol infrastructure. The data service computes its own token amount; the collector independently caps it; the actual payment is `min(tokens earned, agreement cap)`, and escrow reverts if balance is insufficient. + +### RecurringCollector Extensions + +RecurringCollector adds payer callbacks when the payer is a contract: + +``` +│ Receiver +└─> Data Service.collect(work done) + └─> RecurringCollector.collect(tokens earned) + │ validates agreement terms, caps amount + │ validates receiver has active provision with data service + │ if 0 < tokensToCollect AND payer is contract: + │ if implements IProviderEligibility: + │ require payer.isEligible(receiver) ← can BLOCK + │ try payer.beforeCollection(id, tokens) (can't block) + └─> PaymentsEscrow.collect(tokens to collect) + └─> GraphPayments.collect(tokens collected) + │ distributes to: protocol (burned), data service, delegation pool, receiver + <───┘ + <───┘ + │ if payer is contract: (even if tokensToCollect == 0) + │ try payer.afterCollection(id, tokens) (can't block) + <───┘ +<───┘ +``` + +- **`isEligible`**: hard `require` — contract payer can block collection for ineligible receivers. Only called when `0 < tokensToCollect`. +- **`beforeCollection`**: try-catch — allows payer to top up escrow (RAM uses this for JIT deposits), but cannot block (though a malicious contract payer could consume excessive gas). Only called when `0 < tokensToCollect`. +- **`afterCollection`**: try-catch — allows payer to reconcile state post-collection, cannot block (same gas exhaustion caveat). Called even when `tokensToCollect == 0` (zero-token collections still trigger reconciliation). + +## Trust Relationships + +### Payer → Collector + +**Trust required**: The payer authorizes the collector contract and trusts it to enforce payment terms; that it will not collect more than the agreed-upon amounts per collection period. + +**Mitigation**: The collector is a protocol-deployed contract with fixed logic. The escrow balance provides an absolute ceiling — the collector cannot extract more than the deposited balance. + +> _RecurringCollector_: enforces per-agreement caps of `maxOngoingTokensPerSecond × maxSecondsPerCollection` (plus `maxInitialTokens` on first collection) per collection window. The payer's exposure is bounded by the agreement terms they signed or authorized. + +### Payer → Receiver + +**Trust required**: The receiver is paid immediately when collecting based on claimed work done. The payer relies on post-hoc enforcement rather than on-chain validation of the receiver's claims. + +**Mitigation**: The payment protocol itself is agnostic to what evidence the receiver provides — that is the data service's domain. + +> _SubgraphService_: the receiver submits a POI (Proof of Indexing) which is emitted in events but not validated on-chain. Payment proceeds regardless of POI correctness. The dispute system provides post-hoc enforcement: fishermen can challenge invalid POIs, and the indexer's locked stake (`tokensCollected × stakeToFeesRatio`) serves as economic collateral during the dispute period. +> +> _RAM as payer_: the payer is the protocol itself, and if configured, an eligibility oracle gates the receiver's ability to collect (checked by RecurringCollector via `IProviderEligibility`). + +### Receiver → Payer + +**Trust minimised by escrow**: The escrow is the primary trust-minimisation mechanism — to avoid trust in the payer, the receiver should bound uncollected work to what the escrow guarantees rather than relying on the payer to top up. + +Caveats on effective escrow (contract payers introduce additional trust requirements — see caveat 3): + +1. **Thawing reduces effective balance** — a payer can initiate a thaw; once the thaw period completes, those tokens are withdrawable. The receiver should account for the thawing period and any in-progress thaws when assessing available escrow. +2. **Cancellation freezes the collection window** at `canceledAt` — the receiver can still collect for the period up to cancellation (with `minSecondsPerCollection` bypassed), but no further. +3. **Contract payers can block** — if the payer is a contract that implements `IProviderEligibility`, it can deny collection via `isEligible` (see [RecurringCollector Extensions](#recurringcollector-extensions)). + +**Mitigation**: The thawing period provides a window for the receiver to collect before funds are withdrawn. The escrow balance and thaw state are publicly visible on-chain. + +> _RAM as payer_: RAM automates escrow maintenance (Full/OnDemand/JIT modes). When not operating in Full escrow mode, the receiver also depends on RAM's ability to fund at collection time. Mitigation: RAM is a protocol-deployed contract — its funding logic is transparent and predictable, with no adversarial incentive to deny payment. + +### Receiver → Data Service + +**Trust required**: The receiver (or their operator) calls the data service's `collect()` directly. The receiver trusts it to: + +1. **Compute amounts correctly** — the data service determines its claim of what is earned +2. **Not be paused** — the data service may have a pause mechanism that would block collection + +**Mitigation**: The data service is a protocol-deployed contract. Token amounts are capped by the collector independently, so data service overstatement is bounded. + +> _SubgraphService_: `_tokensToCollect` computes the amount earned. The `enforceService` modifier requires the caller to be authorized by the receiver (indexer) for their provision. + +### Receiver → Escrow + +**Trust required**: The receiver trusts escrow to release funds when a valid collection is presented. The receiver has no direct access to escrow — funds can only flow through the authorized collection path (data service → collector → escrow → GraphPayments → receiver). + +**Mitigation**: Escrow is a stateless intermediary — it debits the payer's balance and forwards to GraphPayments. No discretionary logic. The failure modes are insufficient balance or protocol-wide pause (escrow's `collect` has a `notPaused` modifier). + +### Data Service → Collector + +**Trust required**: The data service trusts the collector to faithfully enforce temporal and amount-based caps. The data service provides its own token calculation, but the collector applies `min(requested, cap)` — the data service relies on this capping being correct. + +**Mitigation**: Both are protocol-deployed contracts. The two-layer capping model means neither layer alone determines the payout — the minimum of both applies. + +### Collector → Data Service + +**Trust required**: The collector trusts the data service to call `collect()` only with valid, legitimate payment requests. The collector validates payment terms but relies on the data service to verify service delivery. + +**Mitigation**: The collector validates its own domain (agreement existence, temporal bounds, amount caps) independently. + +> _RecurringCollector + SubgraphService_: the collector validates RCA terms; the data service verifies allocation status and emits POIs for dispute. + +## Who Can Block Collection? + +Which actors can prevent a collection from succeeding, and how: + +| Actor | Can block? | How (general model) | +| ------------ | ---------- | ---------------------------------------------- | +| Payer | Yes | Contract payer only, via `isEligible` | +| Collector | Yes | Reject payment request based on its own rules | +| Data service | Yes | Pause mechanism; code-level revert conditions | +| Receiver | No | Can only initiate, not block | +| Escrow | Yes | Insufficient balance; also protocol-wide pause | + +### Implementation-Specific Notes + +**ECDSA-signed agreements** (external payer): the payer is an EOA and has no on-chain blocking mechanism. The receiver's trust is bounded by the current escrow balance (minus any thawing amount). + +**RAM-managed agreements** (protocol payer): the payer (RAM) has no adversarial incentive to block. If an eligibility oracle is configured, blocking trust effectively transfers to the oracle (see [RecurringCollector Extensions](#recurringcollector-extensions)). + +## Trust Reduction Mechanisms + +| Mechanism | What it bounds | Actor protected | Scope | +| --------------------------------------------------------------- | ------------------------------------------------------------------ | --------------- | ------------------------ | +| Escrow deposit + thaw period | Payer can't instantly withdraw | Receiver | General | +| Two-layer token capping | Neither data service nor collector alone sets amount | Payer | General | +| Collector-enforced agreement terms | Per-collection exposure | Payer | General | +| Cancellation still allows final collection | Receiver collects accrued amount | Receiver | General | +| Dispute system + stake locking | Invalid POIs are challengeable | Payer / network | SubgraphService | +| Eligibility oracle | Ineligible receivers denied | Payer | RecurringCollector + RAM | +| `lastCollectionAt` advancing only through validated collections | No fake liveness signals (advances even on zero-token collections) | All | RecurringCollector | + +## Related Documents + +- [MaxSecondsPerCollectionCap.md](../packages/horizon/contracts/payments/collectors/MaxSecondsPerCollectionCap.md) — Two-layer capping semantics +- [RecurringAgreementManager.md](../packages/issuance/contracts/agreement/RecurringAgreementManager.md) — RAM escrow management +- [RewardsEligibilityOracle.md](../packages/issuance/contracts/eligibility/RewardsEligibilityOracle.md) — Oracle trust model and failsafe +- [RewardAccountingSafety.md](./RewardAccountingSafety.md) — Reward accounting invariants +- [RewardConditions.md](./RewardConditions.md) — Reclaim conditions From 9ae7643eb7deb0d0b304b1bede664f8943f44316 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 20 Mar 2026 13:57:02 +0000 Subject: [PATCH 055/157] test: add cross-package testing harness with callback gas measurements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add packages/testing with real PaymentsEscrow, RecurringCollector, IssuanceAllocator, and RecurringAgreementManager deployed together. Gas results confirm 21-27x headroom on callback budgets. Improve test coverage across all packages: - horizon: RecurringCollector 86%→100% lines, 76%→100% functions - subgraph-service: 92.86%→94.76% branches - issuance: restore 100% coverage, remove dead getPageBytes16 Fix coverage scripts to print summary tables to stdout. --- packages/horizon/package.json | 2 +- .../acceptValidation.t.sol | 188 +++++++++++++++ .../HorizonStakingShared.t.sol | 2 +- packages/issuance/package.json | 3 +- .../unit/agreement-manager/callbackGas.t.sol | 150 ++++++++++++ .../agreement-manager/ensureDistributed.t.sol | 4 +- .../unit/agreement-manager/lifecycle.t.sol | 1 - .../test/unit/common/enumerableSetUtil.t.sol | 192 ++++++++++++++++ .../test/unit/eligibility/eligibility.t.sol | 2 +- .../unit/mocks/EnumerableSetUtilHarness.sol | 44 ++++ packages/subgraph-service/package.json | 2 +- .../disputes/indexingFee/create.t.sol | 80 +++++++ .../indexing-agreement/accept.t.sol | 32 +++ .../indexing-agreement/cancel.t.sol | 17 ++ .../indexing-agreement/collect.t.sol | 31 +++ .../indexing-agreement/update.t.sol | 40 ++++ packages/testing/foundry.toml | 24 ++ packages/testing/package.json | 22 ++ packages/testing/test/gas/CallbackGas.t.sol | 209 +++++++++++++++++ .../test/harness/RealStackHarness.t.sol | 216 ++++++++++++++++++ .../testing/test/mocks/ControllerStub.sol | 42 ++++ .../testing/test/mocks/GraphTokenMock.sol | 20 ++ .../testing/test/mocks/HorizonStakingStub.sol | 34 +++ pnpm-lock.yaml | 24 ++ 24 files changed, 1374 insertions(+), 7 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/callbackGas.t.sol create mode 100644 packages/issuance/test/unit/common/enumerableSetUtil.t.sol create mode 100644 packages/issuance/test/unit/mocks/EnumerableSetUtilHarness.sol create mode 100644 packages/testing/foundry.toml create mode 100644 packages/testing/package.json create mode 100644 packages/testing/test/gas/CallbackGas.t.sol create mode 100644 packages/testing/test/harness/RealStackHarness.t.sol create mode 100644 packages/testing/test/mocks/ControllerStub.sol create mode 100644 packages/testing/test/mocks/GraphTokenMock.sol create mode 100644 packages/testing/test/mocks/HorizonStakingStub.sol diff --git a/packages/horizon/package.json b/packages/horizon/package.json index 09eb7eaaf..7662a48a3 100644 --- a/packages/horizon/package.json +++ b/packages/horizon/package.json @@ -34,7 +34,7 @@ "test:self": "forge test", "test:deployment": "SECURE_ACCOUNTS_DISABLE_PROVIDER=true hardhat test test/deployment/*.ts", "test:integration": "./scripts/integration", - "test:coverage": "pnpm build && pnpm test:coverage:self", + "test:coverage": "forge coverage", "test:coverage:self": "mkdir -p coverage && forge coverage --report lcov --report-file coverage/lcov.info", "prepublishOnly": "pnpm run build" }, diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol new file mode 100644 index 000000000..f8f35c2b7 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +/// @notice Tests for validation branch coverage in RecurringCollector.accept(). +contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + uint256 internal constant SIGNER_KEY = 0xBEEF; + + function _makeValidRCA() internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: vm.addr(SIGNER_KEY), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + nonce: 1, + metadata: "" + }); + } + + function _signAndAccept(IRecurringCollector.RecurringCollectionAgreement memory rca) internal { + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + // ==================== Zero address checks (L175) ==================== + + function test_Accept_Revert_WhenDataServiceZero() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + rca.dataService = address(0); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + + // dataService is zero, so msg.sender check (L173) will fail first because + // we can't prank as address(0) and match. But the addresses-not-set check + // fires after the caller check. Let's prank as address(0) to pass L173. + vm.prank(address(0)); + vm.expectRevert(IRecurringCollector.RecurringCollectorAgreementAddressNotSet.selector); + _recurringCollector.accept(rca, signature); + } + + // Note: payer=0 is impractical to test directly because authorization + // (L150) fails before the address check (L175). The zero-address branch + // is covered by the dataService=0 and serviceProvider=0 tests. + + function test_Accept_Revert_WhenServiceProviderZero() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + rca.serviceProvider = address(0); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + vm.prank(rca.dataService); + vm.expectRevert(IRecurringCollector.RecurringCollectorAgreementAddressNotSet.selector); + _recurringCollector.accept(rca, signature); + } + + // ==================== endsAt validation (L545) ==================== + + function test_Accept_Revert_WhenEndsAtInPast() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + rca.endsAt = uint64(block.timestamp); // endsAt == now, fails "endsAt > block.timestamp" + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementElapsedEndsAt.selector, + block.timestamp, + rca.endsAt + ) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + // ==================== Collection window validation (L548) ==================== + + function test_Accept_Revert_WhenCollectionWindowTooSmall() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + // min=600, max=1000 -> difference = 400 < MIN_SECONDS_COLLECTION_WINDOW (600) + rca.minSecondsPerCollection = 600; + rca.maxSecondsPerCollection = 1000; + rca.endsAt = uint64(block.timestamp + 365 days); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementInvalidCollectionWindow.selector, + _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(), + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection + ) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + function test_Accept_Revert_WhenMaxEqualsMin() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + // max == min -> fails "maxSecondsPerCollection > minSecondsPerCollection" + rca.minSecondsPerCollection = 3600; + rca.maxSecondsPerCollection = 3600; + rca.endsAt = uint64(block.timestamp + 365 days); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementInvalidCollectionWindow.selector, + _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(), + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection + ) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + // ==================== Duration validation (L560) ==================== + + function test_Accept_Revert_WhenDurationTooShort() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + // Need: endsAt - now >= minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW + // Set duration just under the minimum + uint32 minWindow = _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(); + rca.minSecondsPerCollection = 600; + rca.maxSecondsPerCollection = 600 + minWindow; // valid window + rca.endsAt = uint64(block.timestamp + rca.minSecondsPerCollection + minWindow - 1); // 1 second too short + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementInvalidDuration.selector, + rca.minSecondsPerCollection + minWindow, + rca.endsAt - block.timestamp + ) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + // ==================== Caller authorization (L173) ==================== + + function test_Accept_Revert_WhenCallerNotDataService() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + address wrongCaller = makeAddr("wrongCaller"); + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorUnauthorizedCaller.selector, + wrongCaller, + rca.dataService + ) + ); + vm.prank(wrongCaller); + _recurringCollector.accept(rca, signature); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol index 1c15ce738..1309de2b5 100644 --- a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol @@ -43,7 +43,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { _; } - modifier useProvision(uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) virtual { + modifier useProvision(uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) { _useProvision(subgraphDataServiceAddress, tokens, maxVerifierCut, thawingPeriod); _; } diff --git a/packages/issuance/package.json b/packages/issuance/package.json index 6223811a4..2030a0006 100644 --- a/packages/issuance/package.json +++ b/packages/issuance/package.json @@ -27,7 +27,8 @@ "clean": "rm -rf artifacts/ forge-artifacts/ cache_forge/ coverage/ cache/ types/ typechain-src/ .eslintcache test/node_modules/", "compile": "hardhat compile --quiet --no-tests", "typechain": "typechain --target ethers-v6 --out-dir typechain-src 'artifacts/contracts/**/!(*.dbg).json' && tsc -p tsconfig.typechain.json && rm -rf typechain-src && echo '{\"type\":\"commonjs\"}' > types/package.json", - "test": "forge test", + "test": "pnpm test:self", + "test:self": "forge test", "test:coverage": "forge coverage", "test:coverage:self": "mkdir -p coverage && forge coverage --report lcov --report-file coverage/lcov.info", "lint": "pnpm lint:ts; pnpm lint:sol; pnpm lint:forge; pnpm lint:md; pnpm lint:json", diff --git a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol new file mode 100644 index 000000000..eac2fe95d --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; + +/// @notice Gas regression canary for RAM callbacks (beforeCollection / afterCollection). +/// RecurringCollector caps gas forwarded to these callbacks at 1.5M (MAX_PAYER_CALLBACK_GAS). +/// +/// These tests use mocks for PaymentsEscrow, IssuanceAllocator, and RecurringCollector, +/// so measured gas is lower than production. They catch RAM code regressions (new loops, +/// extra external calls, etc.) but cannot validate the production gas margin. +/// +/// @dev Future work: add integration gas tests in a dedicated cross-package test harness +/// that uses the real PaymentsEscrow, RecurringCollector, and IssuanceAllocator contracts +/// to measure production-representative callback gas. +contract RecurringAgreementManagerCallbackGasTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice Gas budget that RecurringCollector forwards to each callback. + /// Must match MAX_PAYER_CALLBACK_GAS in RecurringCollector. + uint256 internal constant MAX_PAYER_CALLBACK_GAS = 1_500_000; + + /// @notice Alarm threshold — 1/10th of the callback gas budget. + /// Current mock worst-case is ~70k. Crossing 150k means RAM code got significantly + /// heavier and the production gas margin (against real contracts) must be re-evaluated. + uint256 internal constant GAS_ALARM_THRESHOLD = MAX_PAYER_CALLBACK_GAS / 10; // 150_000 + + MockIssuanceAllocator internal mockAllocator; + + function setUp() public override { + super.setUp(); + mockAllocator = new MockIssuanceAllocator(token, address(agreementManager)); + vm.label(address(mockAllocator), "MockIssuanceAllocator"); + + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(mockAllocator)); + } + + // ==================== beforeCollection gas ==================== + + /// @notice Worst-case beforeCollection: escrow short, triggers distributeIssuance + JIT deposit. + function test_BeforeCollection_GasWithinBudget_JitDeposit() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + mockAllocator.setMintPerDistribution(1000 ether); + vm.roll(block.number + 1); + + uint256 tokensToCollect = escrowBalance + 500 ether; + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, tokensToCollect); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_ALARM_THRESHOLD, "beforeCollection (JIT) exceeds 1/10th of callback gas budget"); + } + + /// @notice beforeCollection early-return path: escrow sufficient, no external calls. + function test_BeforeCollection_GasWithinBudget_EscrowSufficient() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + agreementManager.beforeCollection(agreementId, 1 ether); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_ALARM_THRESHOLD, "beforeCollection (sufficient) exceeds 1/10th of callback gas budget"); + } + + // ==================== afterCollection gas ==================== + + /// @notice Worst-case afterCollection: reconcile + full escrow update (rebalance path). + function test_AfterCollection_GasWithinBudget_FullReconcile() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + uint64 acceptedAt = uint64(block.timestamp); + uint64 lastCollectionAt = uint64(block.timestamp + 1 hours); + _setAgreementCollected(agreementId, rca, acceptedAt, lastCollectionAt); + vm.warp(lastCollectionAt); + + mockAllocator.setMintPerDistribution(1000 ether); + vm.roll(block.number + 1); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 500 ether); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt( + gasUsed, + GAS_ALARM_THRESHOLD, + "afterCollection (full reconcile) exceeds 1/10th of callback gas budget" + ); + } + + /// @notice afterCollection when agreement was canceled by SP — reconcile zeros out maxNextClaim. + function test_AfterCollection_GasWithinBudget_CanceledBySP() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + _setAgreementCanceledBySP(agreementId, rca); + + mockAllocator.setMintPerDistribution(1000 ether); + vm.roll(block.number + 1); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + agreementManager.afterCollection(agreementId, 0); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt( + gasUsed, + GAS_ALARM_THRESHOLD, + "afterCollection (canceled by SP) exceeds 1/10th of callback gas budget" + ); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index 042deb976..20443dda8 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -308,7 +308,9 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan // Deploy a contract that doesn't support ERC165 address notAllocator = address(new NoERC165Contract()); vm.prank(governor); - vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, notAllocator)); + vm.expectRevert( + abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, notAllocator) + ); agreementManager.setIssuanceAllocator(notAllocator); } diff --git a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol index 843d929ea..fdf933cd3 100644 --- a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol +++ b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.27; import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; diff --git a/packages/issuance/test/unit/common/enumerableSetUtil.t.sol b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol new file mode 100644 index 000000000..668f1e797 --- /dev/null +++ b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol @@ -0,0 +1,192 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { EnumerableSetUtilHarness } from "../mocks/EnumerableSetUtilHarness.sol"; + +/// @notice Unit tests for EnumerableSetUtil pagination helpers. +contract EnumerableSetUtilTest is Test { + /* solhint-disable graph/func-name-mixedcase */ + + EnumerableSetUtilHarness internal harness; + + function setUp() public { + harness = new EnumerableSetUtilHarness(); + } + + // ==================== getPage (AddressSet) ==================== + + function test_GetPage_EmptySet_ReturnsEmpty() public view { + address[] memory result = harness.getPage(0, 10); + assertEq(result.length, 0); + } + + function test_GetPage_ReturnsAllElements() public { + address a1 = makeAddr("a1"); + address a2 = makeAddr("a2"); + address a3 = makeAddr("a3"); + harness.addAddress(a1); + harness.addAddress(a2); + harness.addAddress(a3); + + address[] memory result = harness.getPage(0, 10); + assertEq(result.length, 3); + assertEq(result[0], a1); + assertEq(result[1], a2); + assertEq(result[2], a3); + } + + function test_GetPage_WithOffset() public { + address a1 = makeAddr("a1"); + address a2 = makeAddr("a2"); + address a3 = makeAddr("a3"); + harness.addAddress(a1); + harness.addAddress(a2); + harness.addAddress(a3); + + address[] memory result = harness.getPage(1, 10); + assertEq(result.length, 2); + assertEq(result[0], a2); + assertEq(result[1], a3); + } + + function test_GetPage_WithCount() public { + address a1 = makeAddr("a1"); + address a2 = makeAddr("a2"); + address a3 = makeAddr("a3"); + harness.addAddress(a1); + harness.addAddress(a2); + harness.addAddress(a3); + + address[] memory result = harness.getPage(0, 2); + assertEq(result.length, 2); + assertEq(result[0], a1); + assertEq(result[1], a2); + } + + function test_GetPage_OffsetAndCount() public { + address a1 = makeAddr("a1"); + address a2 = makeAddr("a2"); + address a3 = makeAddr("a3"); + harness.addAddress(a1); + harness.addAddress(a2); + harness.addAddress(a3); + + address[] memory result = harness.getPage(1, 1); + assertEq(result.length, 1); + assertEq(result[0], a2); + } + + function test_GetPage_OffsetAtEnd_ReturnsEmpty() public { + harness.addAddress(makeAddr("a1")); + + address[] memory result = harness.getPage(1, 10); + assertEq(result.length, 0); + } + + function test_GetPage_OffsetPastEnd_ReturnsEmpty() public { + harness.addAddress(makeAddr("a1")); + + address[] memory result = harness.getPage(5, 10); + assertEq(result.length, 0); + } + + function test_GetPage_CountClamped() public { + address a1 = makeAddr("a1"); + harness.addAddress(a1); + + address[] memory result = harness.getPage(0, 100); + assertEq(result.length, 1); + assertEq(result[0], a1); + } + + function test_GetPage_ZeroCount_ReturnsEmpty() public { + harness.addAddress(makeAddr("a1")); + + address[] memory result = harness.getPage(0, 0); + assertEq(result.length, 0); + } + + // ==================== getPageBytes16 (Bytes32Set) ==================== + + function test_GetPageBytes16_EmptySet_ReturnsEmpty() public view { + bytes16[] memory result = harness.getPageBytes16(0, 10); + assertEq(result.length, 0); + } + + function test_GetPageBytes16_ReturnsAllElements() public { + bytes32 b1 = bytes32(bytes16(hex"00010002000300040005000600070008")); + bytes32 b2 = bytes32(bytes16(hex"000a000b000c000d000e000f00100011")); + harness.addBytes32(b1); + harness.addBytes32(b2); + + bytes16[] memory result = harness.getPageBytes16(0, 10); + assertEq(result.length, 2); + assertEq(result[0], bytes16(b1)); + assertEq(result[1], bytes16(b2)); + } + + function test_GetPageBytes16_TruncatesBytes32ToBytes16() public { + // The high 16 bytes should be kept, low 16 bytes discarded + bytes32 full = hex"0102030405060708091011121314151617181920212223242526272829303132"; + harness.addBytes32(full); + + bytes16[] memory result = harness.getPageBytes16(0, 1); + assertEq(result.length, 1); + assertEq(result[0], bytes16(full)); + } + + function test_GetPageBytes16_WithOffset() public { + bytes32 b1 = bytes32(bytes16(hex"aaaa0000000000000000000000000001")); + bytes32 b2 = bytes32(bytes16(hex"bbbb0000000000000000000000000002")); + bytes32 b3 = bytes32(bytes16(hex"cccc0000000000000000000000000003")); + harness.addBytes32(b1); + harness.addBytes32(b2); + harness.addBytes32(b3); + + bytes16[] memory result = harness.getPageBytes16(1, 10); + assertEq(result.length, 2); + assertEq(result[0], bytes16(b2)); + assertEq(result[1], bytes16(b3)); + } + + function test_GetPageBytes16_WithCount() public { + bytes32 b1 = bytes32(bytes16(hex"aaaa0000000000000000000000000001")); + bytes32 b2 = bytes32(bytes16(hex"bbbb0000000000000000000000000002")); + bytes32 b3 = bytes32(bytes16(hex"cccc0000000000000000000000000003")); + harness.addBytes32(b1); + harness.addBytes32(b2); + harness.addBytes32(b3); + + bytes16[] memory result = harness.getPageBytes16(0, 2); + assertEq(result.length, 2); + assertEq(result[0], bytes16(b1)); + assertEq(result[1], bytes16(b2)); + } + + function test_GetPageBytes16_OffsetPastEnd_ReturnsEmpty() public { + harness.addBytes32(bytes32(uint256(1))); + + bytes16[] memory result = harness.getPageBytes16(5, 10); + assertEq(result.length, 0); + } + + function test_GetPageBytes16_CountClamped() public { + bytes32 b1 = bytes32(bytes16(hex"aaaa0000000000000000000000000001")); + harness.addBytes32(b1); + + bytes16[] memory result = harness.getPageBytes16(0, 100); + assertEq(result.length, 1); + assertEq(result[0], bytes16(b1)); + } + + function test_GetPageBytes16_ZeroCount_ReturnsEmpty() public { + harness.addBytes32(bytes32(uint256(1))); + + bytes16[] memory result = harness.getPageBytes16(0, 0); + assertEq(result.length, 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/eligibility/eligibility.t.sol b/packages/issuance/test/unit/eligibility/eligibility.t.sol index aaa74e0c6..871c2bc87 100644 --- a/packages/issuance/test/unit/eligibility/eligibility.t.sol +++ b/packages/issuance/test/unit/eligibility/eligibility.t.sol @@ -95,7 +95,7 @@ contract RewardsEligibilityOracleEligibilityTest is RewardsEligibilityOracleShar // ==================== Edge Cases ==================== function test_NeverRegisteredIndexerEligible_WhenPeriodExceedsTimestamp() public { - // TRST-L-1: When eligibilityPeriod > block.timestamp, all indexers become eligible + // When eligibilityPeriod > block.timestamp, all indexers become eligible // because block.timestamp < 0 + eligibilityPeriod _enableValidation(); _renewEligibility(unauthorized); // set lastOracleUpdateTime diff --git a/packages/issuance/test/unit/mocks/EnumerableSetUtilHarness.sol b/packages/issuance/test/unit/mocks/EnumerableSetUtilHarness.sol new file mode 100644 index 000000000..d77fae866 --- /dev/null +++ b/packages/issuance/test/unit/mocks/EnumerableSetUtilHarness.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; +import { EnumerableSetUtil } from "../../../contracts/common/EnumerableSetUtil.sol"; + +/// @notice Harness that exposes EnumerableSetUtil internal functions for testing. +contract EnumerableSetUtilHarness { + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSet for EnumerableSet.Bytes32Set; + using EnumerableSetUtil for EnumerableSet.AddressSet; + using EnumerableSetUtil for EnumerableSet.Bytes32Set; + + EnumerableSet.AddressSet private _addresses; + EnumerableSet.Bytes32Set private _bytes32s; + + // -- AddressSet helpers -- + + function addAddress(address a) external { + _addresses.add(a); + } + + function addressSetLength() external view returns (uint256) { + return _addresses.length(); + } + + function getPage(uint256 offset, uint256 count) external view returns (address[] memory) { + return _addresses.getPage(offset, count); + } + + // -- Bytes32Set helpers -- + + function addBytes32(bytes32 b) external { + _bytes32s.add(b); + } + + function bytes32SetLength() external view returns (uint256) { + return _bytes32s.length(); + } + + function getPageBytes16(uint256 offset, uint256 count) external view returns (bytes16[] memory) { + return _bytes32s.getPageBytes16(offset, count); + } +} diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index 068e81b8a..1dc7e7e87 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -32,7 +32,7 @@ "test:self": "forge test", "test:deployment": "SECURE_ACCOUNTS_DISABLE_PROVIDER=true hardhat test test/deployment/*.ts", "test:integration": "./scripts/integration", - "test:coverage": "pnpm build && pnpm test:coverage:self", + "test:coverage": "forge coverage", "test:coverage:self": "mkdir -p coverage && forge coverage --report lcov --report-file coverage/lcov.info", "prepublishOnly": "pnpm run build" }, diff --git a/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol b/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol index 73ca400bf..03782315f 100644 --- a/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol +++ b/packages/subgraph-service/test/unit/disputeManager/disputes/indexingFee/create.t.sol @@ -4,6 +4,8 @@ pragma solidity ^0.8.27; import { IDisputeManager } from "@graphprotocol/interfaces/contracts/subgraph-service/IDisputeManager.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol"; +import { IHorizonStakingBase } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol"; +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { SubgraphServiceIndexingAgreementSharedTest } from "../../../subgraphService/indexing-agreement/shared.t.sol"; @@ -176,6 +178,45 @@ contract DisputeManagerIndexingFeeCreateDisputeTest is SubgraphServiceIndexingAg assertEq(disputeId, expectedDisputeId); } + function test_IndexingFee_Create_Dispute_RevertWhen_ZeroStake( + Seed memory seed, + uint256 unboundedTokensCollected + ) public { + (bytes16 agreementId, IndexerState memory indexerState) = _setupCollectedAgreement( + seed, + unboundedTokensCollected + ); + + // Mock staking to return zero provision tokens and zero delegation + IHorizonStakingTypes.Provision memory emptyProvision; + vm.mockCall( + address(staking), + abi.encodeWithSelector( + IHorizonStakingBase.getProvision.selector, + indexerState.addr, + address(subgraphService) + ), + abi.encode(emptyProvision) + ); + IHorizonStakingTypes.DelegationPool memory emptyPool; + vm.mockCall( + address(staking), + abi.encodeWithSelector( + IHorizonStakingBase.getDelegationPool.selector, + indexerState.addr, + address(subgraphService) + ), + abi.encode(emptyPool) + ); + + resetPrank(users.fisherman); + token.approve(address(disputeManager), disputeManager.disputeDeposit()); + + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerZeroTokens.selector)); + // forge-lint: disable-next-line(unsafe-typecast) + disputeManager.createIndexingFeeDisputeV1(agreementId, bytes32("disputePOI"), 200, block.number); + } + function test_IndexingFee_Create_Dispute_RevertWhen_AlreadyCreated( Seed memory seed, uint256 unboundedTokensCollected @@ -196,4 +237,43 @@ contract DisputeManagerIndexingFeeCreateDisputeTest is SubgraphServiceIndexingAg // forge-lint: disable-next-line(unsafe-typecast) disputeManager.createIndexingFeeDisputeV1(agreementId, bytes32("POI"), 100, block.number); } + + function test_IndexingFee_Accept_Dispute_RevertWhen_InvalidDisputeId() public { + // forge-lint: disable-next-line(unsafe-typecast) + bytes32 fakeDisputeId = bytes32("nonexistent"); + + resetPrank(users.arbitrator); + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, fakeDisputeId)); + disputeManager.acceptDispute(fakeDisputeId, 1); + } + + function test_IndexingFee_Accept_Dispute_RevertWhen_NotPending( + Seed memory seed, + uint256 unboundedTokensCollected + ) public { + (bytes16 agreementId, ) = _setupCollectedAgreement(seed, unboundedTokensCollected); + + // Create and reject a dispute so it is no longer pending + resetPrank(users.fisherman); + token.approve(address(disputeManager), disputeManager.disputeDeposit()); + // forge-lint: disable-next-line(unsafe-typecast) + bytes32 disputeId = disputeManager.createIndexingFeeDisputeV1( + agreementId, + bytes32("disputePOI"), + 200, + block.number + ); + + resetPrank(users.arbitrator); + disputeManager.rejectDispute(disputeId); + + // Attempt to accept the already-rejected dispute + vm.expectRevert( + abi.encodeWithSelector( + IDisputeManager.DisputeManagerDisputeNotPending.selector, + IDisputeManager.DisputeStatus.Rejected + ) + ); + disputeManager.acceptDispute(disputeId, 1); + } } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index 4296c8415..1d2e2b9fb 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -318,6 +318,38 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg subgraphService.acceptIndexingAgreement(indexerState.allocationId, notAcceptableRcaSigned, signature); } + function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenTermsExceedRCALimit(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (IRecurringCollector.RecurringCollectionAgreement memory acceptableRca, ) = _generateAcceptableSignedRCA( + ctx, + indexerState.addr + ); + + // Override metadata with tokensPerSecond exceeding RCA maxOngoingTokensPerSecond + uint256 excessiveTokensPerSecond = acceptableRca.maxOngoingTokensPerSecond + 1; + acceptableRca.metadata = _encodeAcceptIndexingAgreementMetadataV1( + indexerState.subgraphDeploymentId, + IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: excessiveTokensPerSecond, + tokensPerEntityPerSecond: 0 + }) + ); + ( + IRecurringCollector.RecurringCollectionAgreement memory unacceptableRca, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCA(acceptableRca, ctx.payer.signerPrivateKey); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementInvalidTerms.selector, + excessiveTokensPerSecond, + unacceptableRca.maxOngoingTokensPerSecond + ); + vm.expectRevert(expectedErr); + vm.prank(indexerState.addr); + subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptableRca, signature); + } + function test_SubgraphService_AcceptIndexingAgreement(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index a0d4ed2d1..80bcb16c3 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -213,6 +213,23 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg subgraphService.cancelIndexingAgreement(indexerState.addr, acceptedAgreementId); } + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenWrongIndexer(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerStateA = _withIndexer(ctx); + IndexerState memory indexerStateB = _withIndexer(ctx); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerStateA); + + // IndexerB tries to cancel indexerA's agreement + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNonCancelableBy.selector, + indexerStateA.addr, + indexerStateB.addr + ); + vm.expectRevert(expectedErr); + resetPrank(indexerStateB.addr); + subgraphService.cancelIndexingAgreement(indexerStateB.addr, acceptedAgreementId); + } + function test_SubgraphService_CancelIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); ( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 5818a1d63..5fbca5f4e 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -308,6 +308,37 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); } + function test_SubgraphService_CollectIndexingFees_Revert_WhenNotCollectable( + Seed memory seed, + uint256 entities, + bytes32 poi + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState); + + resetPrank(indexerState.addr); + uint256 currentEpochBlock = epochManager.currentEpochBlock(); + + // Mock getCollectionInfo to return not collectable + vm.mockCall( + address(recurringCollector), + abi.encodeWithSelector(IRecurringCollector.getCollectionInfo.selector), + abi.encode(false, uint256(0), IRecurringCollector.AgreementNotCollectableReason.ZeroCollectionSeconds) + ); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementNotCollectable.selector, + acceptedAgreementId + ); + vm.expectRevert(expectedErr); + subgraphService.collect( + indexerState.addr, + IGraphPayments.PaymentTypes.IndexingFee, + _encodeCollectDataV1(acceptedAgreementId, entities, poi, currentEpochBlock, bytes("")) + ); + } + /* solhint-enable graph/func-name-mixedcase */ function _expectCollectCallAndEmit( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index b77d91644..321c26df0 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; @@ -157,6 +158,45 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA subgraphService.updateIndexingAgreement(indexerState.addr, unacceptableRcau, authData); } + function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenTermsExceedRCALimit(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); + + // Create update with tokensPerSecond exceeding the RCA's maxOngoingTokensPerSecond + uint256 excessiveTokensPerSecond = acceptedRca.maxOngoingTokensPerSecond + 1; + IRecurringCollector.RecurringCollectionAgreementUpdate + memory rcau = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, acceptedRca); + rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( + IndexingAgreement.UpdateIndexingAgreementMetadata({ + version: IIndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode( + IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: excessiveTokensPerSecond, + tokensPerEntityPerSecond: 0 + }) + ) + }) + ); + rcau.nonce = 1; + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory signedRcau, + bytes memory authData + ) = _recurringCollectorHelper.generateSignedRCAU(rcau, ctx.payer.signerPrivateKey); + + bytes memory expectedErr = abi.encodeWithSelector( + IndexingAgreement.IndexingAgreementInvalidTerms.selector, + excessiveTokensPerSecond, + acceptedRca.maxOngoingTokensPerSecond + ); + vm.expectRevert(expectedErr); + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, signedRcau, authData); + } + function test_SubgraphService_UpdateIndexingAgreement_OK(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); diff --git a/packages/testing/foundry.toml b/packages/testing/foundry.toml new file mode 100644 index 000000000..2b44a2bc6 --- /dev/null +++ b/packages/testing/foundry.toml @@ -0,0 +1,24 @@ +[profile.default] +src = 'test' +out = 'forge-artifacts' +test = 'test' +libs = ["node_modules"] +cache_path = 'cache_forge' +remappings = [ + "@openzeppelin/=node_modules/@openzeppelin/", + "@graphprotocol/=node_modules/@graphprotocol/", + "forge-std/=node_modules/forge-std/src/", + # Real contract sources via workspace symlinks + "horizon/=node_modules/@graphprotocol/horizon/contracts/", + "horizon-mocks/=node_modules/@graphprotocol/horizon/contracts/mocks/", + "issuance/=node_modules/@graphprotocol/issuance/contracts/", +] +optimizer = true +optimizer_runs = 100 +via_ir = true +solc_version = '0.8.34' +evm_version = 'cancun' + +[lint] +exclude_lints = ["mixed-case-function", "mixed-case-variable"] +ignore = ["node_modules/**", "**/node_modules/**"] diff --git a/packages/testing/package.json b/packages/testing/package.json new file mode 100644 index 000000000..93444e04a --- /dev/null +++ b/packages/testing/package.json @@ -0,0 +1,22 @@ +{ + "name": "@graphprotocol/testing", + "version": "0.0.0", + "private": true, + "description": "Cross-package integration tests for Graph Protocol contracts", + "license": "GPL-2.0-or-later", + "scripts": { + "build": "pnpm build:dep", + "build:dep": "pnpm --filter '@graphprotocol/testing^...' run build:self", + "test": "forge test", + "test:gas": "forge test --match-contract Gas -vv" + }, + "devDependencies": { + "@graphprotocol/contracts": "workspace:^", + "@graphprotocol/horizon": "workspace:^", + "@graphprotocol/interfaces": "workspace:^", + "@graphprotocol/issuance": "workspace:^", + "@openzeppelin/contracts": "^5.4.0", + "@openzeppelin/contracts-upgradeable": "^5.4.0", + "forge-std": "catalog:" + } +} diff --git a/packages/testing/test/gas/CallbackGas.t.sol b/packages/testing/test/gas/CallbackGas.t.sol new file mode 100644 index 000000000..ae703ad51 --- /dev/null +++ b/packages/testing/test/gas/CallbackGas.t.sol @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; + +import { RealStackHarness } from "../harness/RealStackHarness.t.sol"; + +/// @notice Gas measurement for RAM callbacks against real contracts. +/// RecurringCollector forwards at most MAX_PAYER_CALLBACK_GAS (1.5M) to each callback. +/// These tests verify the real contract stack stays within that budget. +/// +/// Real contracts on callback path: PaymentsEscrow, IssuanceAllocator, RecurringCollector. +/// Stubs (not on callback path): Controller, HorizonStaking, GraphToken (bare ERC20). +contract CallbackGasTest is RealStackHarness { + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice Must match MAX_PAYER_CALLBACK_GAS in RecurringCollector. + uint256 internal constant MAX_PAYER_CALLBACK_GAS = 1_500_000; + + /// @notice Assert callbacks use less than half the budget. + /// Leaves margin for cold storage and EVM repricing. + uint256 internal constant GAS_THRESHOLD = MAX_PAYER_CALLBACK_GAS / 2; // 750_000 + + // ==================== beforeCollection ==================== + + /// @notice Worst-case beforeCollection: escrow short, triggers distributeIssuance + JIT deposit. + function test_BeforeCollection_GasWithinBudget_JitDeposit() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + IPaymentsEscrow.EscrowAccount memory account = ram.getEscrowAccount( + IRecurringCollector(address(recurringCollector)), + indexer + ); + + // Advance block so distributeIssuance actually runs (not deduped) + vm.roll(block.number + 1); + + uint256 tokensToCollect = account.balance + 500 ether; + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.beforeCollection(agreementId, tokensToCollect); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "beforeCollection (JIT) exceeds half of callback gas budget"); + } + + /// @notice beforeCollection early-return path: escrow sufficient. + function test_BeforeCollection_GasWithinBudget_EscrowSufficient() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.beforeCollection(agreementId, 1 ether); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "beforeCollection (sufficient) exceeds half of callback gas budget"); + } + + // ==================== afterCollection ==================== + + /// @notice Worst-case afterCollection: reconcile against real RecurringCollector + escrow update. + /// Exercises real RecurringCollector.getAgreement() / getMaxNextClaim() and real + /// PaymentsEscrow.adjustThaw() / deposit(). + function test_AfterCollection_GasWithinBudget_FullReconcile() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Accept on the real RecurringCollector using ContractApproval path (empty signature). + // RAM.approveAgreement returns the selector when the hash is authorized. + vm.prank(dataService); + recurringCollector.accept(rca, ""); + + // Advance time past minSecondsPerCollection, then simulate post-collection + vm.warp(block.timestamp + 1 hours); + vm.roll(block.number + 1); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.afterCollection(agreementId, 500 ether); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "afterCollection (full reconcile) exceeds half of callback gas budget"); + } + + // ==================== beforeCollection: cold discovery path ==================== + + /// @notice beforeCollection on an agreement with a cold provider: exercises first-seen + /// escrow slot access + JIT deposit. This is the heaviest beforeCollection path. + function test_BeforeCollection_GasWithinBudget_ColdDiscoveryJit() public { + // Set up a second provider so we get cold escrow storage + address indexer2 = makeAddr("indexer2"); + _setUpProvider(indexer2); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + // Offer via RAM — triggers discovery for the new provider + bytes16 agreementId2 = _offerAgreement(rca2); + + // Advance block so distributeIssuance runs + vm.roll(block.number + 1); + + IPaymentsEscrow.EscrowAccount memory account = ram.getEscrowAccount( + IRecurringCollector(address(recurringCollector)), + indexer2 + ); + uint256 tokensToCollect = account.balance + 500 ether; + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.beforeCollection(agreementId2, tokensToCollect); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "beforeCollection (cold provider JIT) exceeds half of callback gas budget"); + } + + // ==================== afterCollection: withdraw + deposit path ==================== + + /// @notice afterCollection exercising the heaviest escrow mutation path: + /// Two agreements for the same provider. Cancel one → escrow excess triggers thaw. + /// After thaw matures, afterCollection on the remaining agreement hits withdraw + deposit. + function test_AfterCollection_GasWithinBudget_WithdrawAndDeposit() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId1 = _offerAndAccept(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + bytes16 agreementId2 = _offerAndAccept(rca2); + + // Cancel agreement 2 by SP — reduces escrow needs, triggers thaw of excess + vm.prank(dataService); + recurringCollector.cancel(agreementId2, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + // Advance past the thawing period so the thaw matures + vm.warp(block.timestamp + 2 days); + vm.roll(block.number + 1); + + // afterCollection on the remaining agreement: should hit withdraw + deposit path + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.afterCollection(agreementId1, 0); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "afterCollection (withdraw + deposit) exceeds half of callback gas budget"); + } + + // ==================== afterCollection: deletion cascade ==================== + + /// @notice afterCollection after SP cancels → maxNextClaim → 0, triggers deletion cascade. + function test_AfterCollection_GasWithinBudget_DeletionCascade() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAndAccept(rca); + + // SP cancels → state becomes CanceledByServiceProvider, maxNextClaim → 0 + vm.prank(dataService); + recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + vm.roll(block.number + 1); + + uint256 gasBefore = gasleft(); + vm.prank(address(recurringCollector)); + ram.afterCollection(agreementId, 0); + uint256 gasUsed = gasBefore - gasleft(); + + assertLt(gasUsed, GAS_THRESHOLD, "afterCollection (deletion cascade) exceeds half of callback gas budget"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/testing/test/harness/RealStackHarness.t.sol b/packages/testing/test/harness/RealStackHarness.t.sol new file mode 100644 index 000000000..37c4977c3 --- /dev/null +++ b/packages/testing/test/harness/RealStackHarness.t.sol @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { Test } from "forge-std/Test.sol"; + +// Real contracts +import { PaymentsEscrow } from "horizon/payments/PaymentsEscrow.sol"; +import { RecurringCollector } from "horizon/payments/collectors/RecurringCollector.sol"; +import { IssuanceAllocator } from "issuance/allocate/IssuanceAllocator.sol"; +import { RecurringAgreementManager } from "issuance/agreement/RecurringAgreementManager.sol"; +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; + +// Use the issuance IGraphToken for RAM/allocator (IERC20 + mint) +import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; + +// Interfaces +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +// Stubs for infra not on callback path +import { ControllerStub } from "../mocks/ControllerStub.sol"; +import { HorizonStakingStub } from "../mocks/HorizonStakingStub.sol"; +import { GraphTokenMock } from "../mocks/GraphTokenMock.sol"; + +/// @notice Deploys the real contract stack that participates in RAM callback gas: +/// - PaymentsEscrow (real) — RAM calls deposit/adjustThaw/withdraw/escrowAccounts +/// - RecurringCollector (real) — RAM calls getAgreement/getMaxNextClaim in afterCollection +/// - IssuanceAllocator (real, behind proxy) — RAM calls distributeIssuance +/// - RecurringAgreementManager (real, behind proxy) — the contract under test +/// +/// Only infrastructure not on the callback path is stubbed: +/// - Controller (paused() check, contract registry) +/// - HorizonStaking (provision check in RecurringCollector.collect, not in RAM callbacks) +/// - GraphToken (bare ERC20 — ~2-5k cheaper per op than proxied real token) +abstract contract RealStackHarness is Test { + // -- Real contracts -- + PaymentsEscrow internal paymentsEscrow; + RecurringCollector internal recurringCollector; + IssuanceAllocator internal issuanceAllocator; + RecurringAgreementManager internal ram; + + // -- Stubs -- + ControllerStub internal controller; + HorizonStakingStub internal staking; + GraphTokenMock internal token; + + // -- Accounts -- + address internal governor; + address internal operator; + address internal indexer; + address internal dataService; + + // -- Role constants -- + bytes32 internal constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE"); + bytes32 internal constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); + bytes32 internal constant DATA_SERVICE_ROLE = keccak256("DATA_SERVICE_ROLE"); + bytes32 internal constant COLLECTOR_ROLE = keccak256("COLLECTOR_ROLE"); + bytes32 internal constant AGREEMENT_MANAGER_ROLE = keccak256("AGREEMENT_MANAGER_ROLE"); + + function setUp() public virtual { + governor = makeAddr("governor"); + operator = makeAddr("operator"); + indexer = makeAddr("indexer"); + dataService = makeAddr("dataService"); + + // 1. Deploy stubs + token = new GraphTokenMock(); + controller = new ControllerStub(); + staking = new HorizonStakingStub(); + + // 2. Register in controller (GraphDirectory reads these immutably at construction) + controller.register("GraphToken", address(token)); + controller.register("Staking", address(staking)); + + // 3. Deploy real PaymentsEscrow behind proxy + PaymentsEscrow escrowImpl = new PaymentsEscrow(address(controller), 1 days); + TransparentUpgradeableProxy escrowProxy = new TransparentUpgradeableProxy( + address(escrowImpl), + address(this), + abi.encodeCall(PaymentsEscrow.initialize, ()) + ); + paymentsEscrow = PaymentsEscrow(address(escrowProxy)); + controller.register("PaymentsEscrow", address(paymentsEscrow)); + + // 4. Deploy real RecurringCollector behind proxy + RecurringCollector rcImpl = new RecurringCollector(address(controller), 1); + TransparentUpgradeableProxy rcProxy = new TransparentUpgradeableProxy( + address(rcImpl), + address(this), + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) + ); + recurringCollector = RecurringCollector(address(rcProxy)); + + // 5. Deploy real IssuanceAllocator behind proxy + IssuanceAllocator allocatorImpl = new IssuanceAllocator(IssuanceIGraphToken(address(token))); + TransparentUpgradeableProxy allocatorProxy = new TransparentUpgradeableProxy( + address(allocatorImpl), + address(this), + abi.encodeCall(IssuanceAllocator.initialize, (governor)) + ); + issuanceAllocator = IssuanceAllocator(address(allocatorProxy)); + + // 6. Deploy real RecurringAgreementManager behind proxy + RecurringAgreementManager ramImpl = new RecurringAgreementManager( + IssuanceIGraphToken(address(token)), + IPaymentsEscrow(address(paymentsEscrow)) + ); + TransparentUpgradeableProxy ramProxy = new TransparentUpgradeableProxy( + address(ramImpl), + address(this), + abi.encodeCall(RecurringAgreementManager.initialize, (governor)) + ); + ram = RecurringAgreementManager(address(ramProxy)); + + // 7. Wire up roles + vm.startPrank(governor); + ram.grantRole(OPERATOR_ROLE, operator); + ram.grantRole(DATA_SERVICE_ROLE, dataService); + ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); + ram.setIssuanceAllocator(address(issuanceAllocator)); + // Configure allocator: set total issuance rate, then allocate to RAM + issuanceAllocator.setIssuancePerBlock(1 ether); + issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); + vm.stopPrank(); + + vm.prank(operator); + ram.grantRole(AGREEMENT_MANAGER_ROLE, operator); + + // 8. Set up staking provision so RecurringCollector allows collections + staking.setProvision( + indexer, + dataService, + IHorizonStakingTypes.Provision({ + tokens: 1000 ether, + tokensThawing: 0, + sharesThawing: 0, + maxVerifierCut: 100000, + thawingPeriod: 604800, + createdAt: uint64(block.timestamp), + maxVerifierCutPending: 100000, + thawingPeriodPending: 604800, + lastParametersStagedAt: 0, + thawingNonce: 0 + }) + ); + + // Labels + vm.label(address(token), "GraphToken"); + vm.label(address(paymentsEscrow), "PaymentsEscrow"); + vm.label(address(recurringCollector), "RecurringCollector"); + vm.label(address(issuanceAllocator), "IssuanceAllocator"); + vm.label(address(ram), "RecurringAgreementManager"); + } + + // -- Helpers -- + + /// @notice Create an RCA with RAM as payer + function _makeRCA( + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + uint64 endsAt + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: endsAt, + payer: address(ram), + dataService: dataService, + serviceProvider: indexer, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: 60, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: 1, + metadata: "" + }); + } + + /// @notice Offer an agreement, funding the RAM first + function _offerAgreement(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + token.mint(address(ram), 1_000_000 ether); + vm.prank(operator); + return ram.offerAgreement(rca, IRecurringCollector(address(recurringCollector))); + } + + /// @notice Offer and accept an agreement via the unsigned path, returning the agreement ID + function _offerAndAccept(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + bytes16 agreementId = _offerAgreement(rca); + vm.prank(dataService); + recurringCollector.accept(rca, ""); + return agreementId; + } + + /// @notice Set up a staking provision for a provider so RecurringCollector allows operations + function _setUpProvider(address provider) internal { + staking.setProvision( + provider, + dataService, + IHorizonStakingTypes.Provision({ + tokens: 1000 ether, + tokensThawing: 0, + sharesThawing: 0, + maxVerifierCut: 100000, + thawingPeriod: 604800, + createdAt: uint64(block.timestamp), + maxVerifierCutPending: 100000, + thawingPeriodPending: 604800, + lastParametersStagedAt: 0, + thawingNonce: 0 + }) + ); + } +} diff --git a/packages/testing/test/mocks/ControllerStub.sol b/packages/testing/test/mocks/ControllerStub.sol new file mode 100644 index 000000000..6ece3ae1b --- /dev/null +++ b/packages/testing/test/mocks/ControllerStub.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { IController } from "@graphprotocol/interfaces/contracts/contracts/governance/IController.sol"; + +/// @notice Minimal Controller stub for GraphDirectory consumers. +/// Returns registered addresses; unregistered names return a dummy nonzero address +/// so GraphDirectory constructors don't revert on zero-address checks. +contract ControllerStub is IController { + mapping(bytes32 => address) private _registry; + address private immutable _dummy; + + constructor() { + _dummy = address(uint160(uint256(keccak256("ControllerStub.dummy")))); + } + + function register(string memory name, address addr) external { + _registry[keccak256(abi.encodePacked(name))] = addr; + } + + function getContractProxy(bytes32 id) external view override returns (address) { + address a = _registry[id]; + return a != address(0) ? a : _dummy; + } + + // -- Stubs -- + function getGovernor() external pure override returns (address) { + return address(1); + } + function paused() external pure override returns (bool) { + return false; + } + function partialPaused() external pure override returns (bool) { + return false; + } + function setContractProxy(bytes32, address) external override {} + function unsetContractProxy(bytes32) external override {} + function updateController(bytes32, address) external override {} + function setPartialPaused(bool) external override {} + function setPaused(bool) external override {} + function setPauseGuardian(address) external override {} +} diff --git a/packages/testing/test/mocks/GraphTokenMock.sol b/packages/testing/test/mocks/GraphTokenMock.sol new file mode 100644 index 000000000..95f9e7424 --- /dev/null +++ b/packages/testing/test/mocks/GraphTokenMock.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +/// @notice Mintable ERC20 standing in for the real GraphToken. +/// The real GraphToken is an ERC20 behind a proxy; this mock uses bare ERC20 +/// which is slightly cheaper per call. The gas delta is small (~2-5k per call). +contract GraphTokenMock is ERC20 { + constructor() ERC20("Graph Token", "GRT") {} + + function mint(address to, uint256 amount) external { + _mint(to, amount); + } + + /// @dev Matches the GraphToken burn interface (self-burn). + function burnFrom(address from, uint256 amount) external { + _burn(from, amount); + } +} diff --git a/packages/testing/test/mocks/HorizonStakingStub.sol b/packages/testing/test/mocks/HorizonStakingStub.sol new file mode 100644 index 000000000..d43cea22f --- /dev/null +++ b/packages/testing/test/mocks/HorizonStakingStub.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; + +/// @notice Minimal staking stub — only provides getProviderTokensAvailable +/// (needed by RecurringCollector to gate collection). +contract HorizonStakingStub { + mapping(address => mapping(address => IHorizonStakingTypes.Provision)) public provisions; + + function setProvision( + address serviceProvider, + address verifier, + IHorizonStakingTypes.Provision memory provision + ) external { + provisions[serviceProvider][verifier] = provision; + } + + function getProvision( + address serviceProvider, + address verifier + ) external view returns (IHorizonStakingTypes.Provision memory) { + return provisions[serviceProvider][verifier]; + } + + function getProviderTokensAvailable(address serviceProvider, address verifier) external view returns (uint256) { + IHorizonStakingTypes.Provision memory p = provisions[serviceProvider][verifier]; + return p.tokens - p.tokensThawing; + } + + function isAuthorized(address, address, address) external pure returns (bool) { + return true; + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4ae1a0f8..c555202ac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1303,6 +1303,30 @@ importers: specifier: 'catalog:' version: 5.9.3 + packages/testing: + devDependencies: + '@graphprotocol/contracts': + specifier: workspace:^ + version: link:../contracts + '@graphprotocol/horizon': + specifier: workspace:^ + version: link:../horizon + '@graphprotocol/interfaces': + specifier: workspace:^ + version: link:../interfaces + '@graphprotocol/issuance': + specifier: workspace:^ + version: link:../issuance + '@openzeppelin/contracts': + specifier: ^5.4.0 + version: 5.4.0 + '@openzeppelin/contracts-upgradeable': + specifier: ^5.4.0 + version: 5.4.0(@openzeppelin/contracts@5.4.0) + forge-std: + specifier: 'catalog:' + version: https://github.com/foundry-rs/forge-std/tarball/v1.14.0 + packages/token-distribution: dependencies: ajv: From efc51160fd1152ec447735d3f760e5e2576ca345 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:58:06 +0000 Subject: [PATCH 056/157] docs(audit): add PR1301 audit report and findings Trust Security audit (2026-03-03 to 2026-03-19) findings extracted from Graph_PR1301_v01.pdf into PR1301/ directory with README index. Includes auditor-supplied staleSnap PoC test. --- .../audits/PR1301/Graph_PR1301_v01.pdf | Bin 0 -> 555085 bytes packages/issuance/audits/PR1301/README.md | 49 ++++ packages/issuance/audits/PR1301/TRST-CR-1.md | 15 + packages/issuance/audits/PR1301/TRST-CR-2.md | 13 + packages/issuance/audits/PR1301/TRST-CR-3.md | 11 + packages/issuance/audits/PR1301/TRST-H-1.md | 22 ++ packages/issuance/audits/PR1301/TRST-H-2.md | 22 ++ packages/issuance/audits/PR1301/TRST-H-3.md | 24 ++ packages/issuance/audits/PR1301/TRST-H-4.md | 24 ++ packages/issuance/audits/PR1301/TRST-L-1.md | 22 ++ packages/issuance/audits/PR1301/TRST-L-2.md | 22 ++ packages/issuance/audits/PR1301/TRST-L-3.md | 22 ++ packages/issuance/audits/PR1301/TRST-L-4.md | 22 ++ packages/issuance/audits/PR1301/TRST-L-5.md | 22 ++ packages/issuance/audits/PR1301/TRST-M-1.md | 26 ++ packages/issuance/audits/PR1301/TRST-M-2.md | 22 ++ packages/issuance/audits/PR1301/TRST-M-3.md | 22 ++ packages/issuance/audits/PR1301/TRST-R-1.md | 7 + packages/issuance/audits/PR1301/TRST-R-2.md | 10 + packages/issuance/audits/PR1301/TRST-R-3.md | 7 + packages/issuance/audits/PR1301/TRST-R-4.md | 7 + packages/issuance/audits/PR1301/TRST-SR-1.md | 11 + packages/issuance/audits/PR1301/TRST-SR-2.md | 11 + packages/issuance/audits/PR1301/TRST-SR-3.md | 11 + packages/issuance/audits/PR1301/TRST-SR-4.md | 11 + .../unit/agreement-manager/staleSnap.t.sol | 270 ++++++++++++++++++ 26 files changed, 705 insertions(+) create mode 100644 packages/issuance/audits/PR1301/Graph_PR1301_v01.pdf create mode 100644 packages/issuance/audits/PR1301/README.md create mode 100644 packages/issuance/audits/PR1301/TRST-CR-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-CR-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-CR-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-H-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-H-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-H-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-H-4.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-4.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-5.md create mode 100644 packages/issuance/audits/PR1301/TRST-M-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-M-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-M-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-4.md create mode 100644 packages/issuance/audits/PR1301/TRST-SR-1.md create mode 100644 packages/issuance/audits/PR1301/TRST-SR-2.md create mode 100644 packages/issuance/audits/PR1301/TRST-SR-3.md create mode 100644 packages/issuance/audits/PR1301/TRST-SR-4.md create mode 100644 packages/issuance/test/unit/agreement-manager/staleSnap.t.sol diff --git a/packages/issuance/audits/PR1301/Graph_PR1301_v01.pdf b/packages/issuance/audits/PR1301/Graph_PR1301_v01.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8f14dd018160adebc8b0217c77283ed975780d04 GIT binary patch literal 555085 zcmeFZ1yq&Ywl|I-pfpHHZt321N;gP%N^QEkK@jPX?iT4TDW$thy1S$s{u_MXdwkD5 z=iGb7cfbD_cYJPv=UFx9T)!1_?K#(!R8~lYmVu595soyYqJ0t(jsZXqu+lR{gnRuO zDC1ynZej_t128Z!bAa>Zf&BWmRw7om7T_F4#>X64T_bRXpYICxwhsFCinbt-yp@$b zfPsbSv5K+@$O&XCYYQ?2*@7(fAL%jDKNcyvSc8Cqy7s!}Rz^T6U0XA8OG7IFnDxUu z$N&H)2;$)ZzR|Tbq5xS^0;NFqx(49tVE!zR6nJ z+5;Gwfs!T$b{c?3nE*_WtpUsr-IWLY>>c1INdOD$V!v3>4`_C#IKRIyxB*yWxIS2b=O$Pd(Nd|_W1Q-~8R%T#$B%uZPwRaB$ z{!{OOvbtbM!M%H+2b2fdSvlB(0R{so>})TpV6STr0>6tYumB!8f#1NSe^Lj-DywU6 z53;oc*N_Es{>dDittz8u3evX+XNy~aN0)&S0RDNP|1-%3V0i4>&m_k1veD2 zvV3SI0;cr{1yBUs^ykD8VFHi9BM}j10OMo#9t5zp(pLc4YXHHs5U2=pw*N^};O9f| z=R^Df2k^)nnCJ>vIctE4&;wXFSm>A-0qo2SbR3LY0Pq-F+JkYh1N`J6YHQ_S4VL6_ z7Ca_^3P43$T}wOb2fXxMfPxA@A&{eqK1g0v08Cv`SI-Vy<>v(ciK!ic{#W=P2>%Jc zh>1BEH=u|)7+xWezLfz8_y%NYWN!>$XJvb6WM^*+(zQT@b55>O(Xx`~NAVzE;(fCW zA8-FX;Z{14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H{l@P|h zPL6I4K*A?1EB9R>FDoOjfH1*e0NVrlU;^Icj1iVqkXuOTSgXk@$|z{dC@RY!kw}GY zNF}Th{2HH?z)Y~_BqZmiyX>(95?jF*+O?01+t+B z+cyODHYqv>%2`~Ej0-p!9HR=L#2jCm><)2@g0%i(XWNqB*ZuTqAax6Qur=w>>%+vhy+CDeSy5+HW=|*<&EHXnJdhSGC{80P;tVxUuZE)RfOvBZv{$ z(6y3*HCUmxU}x1=<+R*aBxin|8hdU2C*es`rdW@$fP0sRmKC6_#}&D>ZyvuKKI<2= zVI*D|Ryr71y|1e9&bCBSM1S>cFf@ta*vwsA$yMyxJ)!)P#Qw}XDF|EF_fVi#byvLA zv)Pk#b2=Lj(xmNG-lO!jFC!iBdUKUz~UA@Pi} zCt!NjVYapjRex6{g?JWLK@LF`|NgsP4Z#ul8WkfgvgX8nH1F`OOwqK>cmcFo1e&ez zF+9fW#Av9lVnNQx>WlX}&&}dhn{UicagTc0CVdK#)$pC8!N z;res86}{#^Dqk?jq7x`$a%Q+t!u!p1R2Nl$TvZ9aCy(&b@_2y_TDWMW`|N9VDAlut z`}nYXyLpkQOzk1{IsOkblNEMugChg&Z%nKDo}LXGF1}QEZ(3mbJ>O)CDdh~4XZET) zW5F_H0cFziBv=+XBS$UGF|qM{w0SC3bc#q`W&c@S2=16T_GZt){gj=@P5RKcqgf`gDBd}6>*6$IYe~EL)YmPWW>!~R6iOwxKUTsOy2uU8Jmk8a+|eaN qT-g}DwfGPBLUvXlAoleS@^x}%XH`&;S5j19XWg(t7p=$6`u_l1TDRN) literal 0 HcmV?d00001 diff --git a/packages/issuance/audits/PR1301/README.md b/packages/issuance/audits/PR1301/README.md new file mode 100644 index 000000000..46695b14a --- /dev/null +++ b/packages/issuance/audits/PR1301/README.md @@ -0,0 +1,49 @@ +# Trust Security Audit - PR #1301 + +**Auditor:** Trust Security +**Period:** 2026-03-03 to 2026-03-19 +**Commit:** 7405c9d5f73bce04734efb3f609b76d95ffb520e +**Report:** [Graph_PR1301_v01.pdf](Graph_PR1301_v01.pdf) + +## Findings Summary + +| ID | Title | Severity | +| ----------------------- | -------------------------------------------------------- | -------- | +| [TRST-H-1](TRST-H-1.md) | Malicious payer gas siphoning via 63/64 rule | High | +| [TRST-H-2](TRST-H-2.md) | Invalid supportsInterface() returndata escapes try/catch | High | +| [TRST-H-3](TRST-H-3.md) | Stale escrow snapshot causes perpetual revert loop | High | +| [TRST-H-4](TRST-H-4.md) | EOA payer can block collection via EIP-7702 | High | +| [TRST-M-1](TRST-M-1.md) | Micro-thaw griefing via permissionless depositTo() | Medium | +| [TRST-M-2](TRST-M-2.md) | tempJit fallback in beforeCollection() unreachable | Medium | +| [TRST-M-3](TRST-M-3.md) | Instant escrow mode degradation via agreement offer | Medium | +| [TRST-L-1](TRST-L-1.md) | Insufficient gas for afterCollection callback | Low | +| [TRST-L-2](TRST-L-2.md) | Pending update over-reserves escrow | Low | +| [TRST-L-3](TRST-L-3.md) | Unsafe approveAgreement behavior during pause | Low | +| [TRST-L-4](TRST-L-4.md) | Pair tracking removal blocked by 1 wei donation | Low | +| [TRST-L-5](TRST-L-5.md) | \_computeMaxFirstClaim overestimates near deadline | Low | + +## Recommendations + +| ID | Title | +| ----------------------- | ---------------------------------------------- | +| [TRST-R-1](TRST-R-1.md) | Avoid redeployment of RewardsEligibilityOracle | +| [TRST-R-2](TRST-R-2.md) | Improve stale documentation | +| [TRST-R-3](TRST-R-3.md) | Incorporate defensive coding best practices | +| [TRST-R-4](TRST-R-4.md) | Document critical assumptions in the RAM | + +## Centralization Risks + +| ID | Title | +| ------------------------- | --------------------------------------------------------------- | +| [TRST-CR-1](TRST-CR-1.md) | RAM Governor has unilateral control over payment infrastructure | +| [TRST-CR-2](TRST-CR-2.md) | Operator role controls agreement lifecycle and escrow mode | +| [TRST-CR-3](TRST-CR-3.md) | Single RAM instance manages all agreement escrow | + +## Systemic Risks + +| ID | Title | +| ------------------------- | -------------------------------------------------------------- | +| [TRST-SR-1](TRST-SR-1.md) | JIT mode provider payment race condition | +| [TRST-SR-2](TRST-SR-2.md) | Escrow thawing period creates prolonged fund immobility | +| [TRST-SR-3](TRST-SR-3.md) | Issuance distribution dependency for RAM solvency | +| [TRST-SR-4](TRST-SR-4.md) | Try/catch callback pattern silently degrades state consistency | diff --git a/packages/issuance/audits/PR1301/TRST-CR-1.md b/packages/issuance/audits/PR1301/TRST-CR-1.md new file mode 100644 index 000000000..00b8cde4e --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-CR-1.md @@ -0,0 +1,15 @@ +# TRST-CR-1: RAM Governor has unilateral control over payment infrastructure + +- **Severity:** Centralization Risk + +## Description + +The RecurringAgreementManager's `GOVERNOR_ROLE` has broad unilateral authority over critical payment infrastructure: + +- Controls which data services can participate (`DATA_SERVICE_ROLE` grants) +- Controls which collectors are trusted (`COLLECTOR_ROLE` grants) +- Can set the issuance allocator address, redirecting the token flow that funds all escrow +- Can set the provider eligibility oracle, which gates who can receive payments +- Can pause the entire contract, halting all agreement management + +A compromised or malicious governor could revoke a data service's role (preventing new agreements), change the issuance allocator to a contract that withholds funds, or set a malicious eligibility oracle that blocks specific providers from collecting. These actions affect all agreements managed by the RAM, not just future ones. diff --git a/packages/issuance/audits/PR1301/TRST-CR-2.md b/packages/issuance/audits/PR1301/TRST-CR-2.md new file mode 100644 index 000000000..1e512fbac --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-CR-2.md @@ -0,0 +1,13 @@ +# TRST-CR-2: Operator role controls agreement lifecycle and escrow mode + +- **Severity:** Centralization Risk + +## Description + +The `OPERATOR_ROLE` (admin of `AGREEMENT_MANAGER_ROLE`) controls the operational layer of the RAM: + +- Grants `AGREEMENT_MANAGER_ROLE`, which authorizes offering, updating, revoking, and canceling agreements +- Can change the `escrowBasis` (Full/OnDemand/JIT), instantly affecting escrow behavior for all existing agreements +- Can set `tempJit`, overriding the escrow mode to JIT for all pairs + +An operator switching from Full to JIT mode instantly removes proactive escrow guarantees for all providers. Providers who accepted agreements under the assumption of Full escrow backing may find their payment security degraded without notice or consent. The escrow mode change is a storage write with no timelock or multi-sig requirement. diff --git a/packages/issuance/audits/PR1301/TRST-CR-3.md b/packages/issuance/audits/PR1301/TRST-CR-3.md new file mode 100644 index 000000000..797710020 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-CR-3.md @@ -0,0 +1,11 @@ +# TRST-CR-3: Single RAM instance manages all agreement escrow + +- **Severity:** Centralization Risk + +## Description + +The RecurringAgreementManager is a single contract instance that manages escrow for all agreements across all (collector, provider) pairs. The `totalEscrowDeficit` is a global aggregate, and the escrow mode (Full/OnDemand/JIT) applies uniformly to all pairs. + +This means operational decisions or issues affecting one pair can cascade to all others. For example, a single large agreement that becomes insolvent increases `totalEscrowDeficit`, potentially degrading the escrow mode from Full to OnDemand for every other pair. Similarly, a stale snapshot on one pair (TRST-H-3) affects the global deficit calculation. + +There is no isolation between pairs beyond the per-pair `sumMaxNextClaim` tracking. The RAM does not support per-pair escrow mode configuration or per-pair balance ringfencing. diff --git a/packages/issuance/audits/PR1301/TRST-H-1.md b/packages/issuance/audits/PR1301/TRST-H-1.md new file mode 100644 index 000000000..c025974b4 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-H-1.md @@ -0,0 +1,22 @@ +# TRST-H-1: Malicious payer gas siphoning via 63/64 rule in collection callbacks leads to collection bypass + +- **Severity:** High +- **Category:** Gas-related issues +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +In `RecurringCollector._collect()`, the `beforeCollection()` and `afterCollection()` callbacks to contract payers are wrapped in try/catch blocks (lines 380, 416). A malicious contract payer can exploit the EVM's 63/64 gas forwarding rule to consume nearly all available gas in these callbacks. + +The attack works as follows: the malicious payer's `beforeCollection()` implementation consumes 63/64 of the gas forwarded to it, either returning successfully or reverting, but regardless leaving only 1/64 of the original gas for the remainder of `_collect()`. The core payment logic (`PaymentsEscrow.collect()` at line 384) and event emissions then execute with a fraction of the expected gas. The `afterCollection()` callback then consumes another 63/64 of what remains. + +Realistically, after both callbacks siphon gas, there will not be enough gas left to complete the `PaymentsEscrow.collect()` call and the subsequent event emissions, causing the entire `collect()` transaction to revert. The security model for Payer as a smart contract does not account for requiring such gas expenditure, which can also be obfuscated away. This gives the malicious payer effective veto power over all collections against their agreements. + +## Recommended Mitigation + +Enforce a minimum gas reservation before each callback. Before calling `beforeCollection()`, check that `gasleft()` is sufficient and forward only a bounded amount of gas using the `{gas: maxCallbackGas}` syntax, retaining enough gas for the core payment logic. Apply the same pattern to `afterCollection()`. This caps the gas available to the payer's callbacks regardless of their implementation, ensuring the critical `PaymentsEscrow.collect()` call always has enough gas to complete. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-H-2.md b/packages/issuance/audits/PR1301/TRST-H-2.md new file mode 100644 index 000000000..a0c261f48 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-H-2.md @@ -0,0 +1,22 @@ +# TRST-H-2: Invalid supportsInterface() returndata escapes try/catch leading to collection bypass + +- **Severity:** High +- **Category:** Logical flaws +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +In `RecurringCollector._collect()` (lines 368-378), the provider eligibility check calls `IERC165(agreement.payer).supportsInterface()` inside a try/catch block. The try clause expects a `(bool supported)` return value. If the external call succeeds at the EVM level (does not revert) but returns malformed data - such as fewer than 32 bytes of returndata or data that cannot be ABI-decoded as a bool - the Solidity ABI decoder reverts on the caller side when attempting to decode the return value. + +This ABI decoding revert occurs in the calling contract's execution context, not in the external call itself. Solidity's try/catch mechanism only catches reverts originating from the external call (callee-side reverts). Caller-side decoding failures escape the catch block and propagate as an unhandled revert, causing the entire `_collect()` transaction to fail. + +A malicious contract payer can exploit this by implementing a `supportsInterface()` function that returns success with empty returndata, a single byte, or any non-standard encoding. This permanently blocks all collections against agreements with that payer, since the `code.length > 0` check always routes through the vulnerable path. As before, the security model does not account for this bypass path to be validated against. + +## Recommended Mitigation + +Avoid receiving and decoding values from untrusted contract calls. This can be done manually by reading returndata at the assembly level. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-H-3.md b/packages/issuance/audits/PR1301/TRST-H-3.md new file mode 100644 index 000000000..617943d91 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-H-3.md @@ -0,0 +1,24 @@ +# TRST-H-3: Stale escrow snapshot causes a perpetual revert loop + +- **Severity:** High +- **Category:** Logical flaws +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +The RecurringAgreementManager (RAM) maintains an `escrowSnap` per (collector, provider) pair - a cached view of the escrow balance used to compute `totalEscrowDeficit`. This snap is only updated at the end of `_updateEscrow()` via `_setEscrowSnap()`. When `afterCollection()` is called by the RecurringCollector after a payment collection, the escrow balance has already been reduced by the collected amount, but `escrowSnap` still reflects the pre-collection value. + +The stale-high snap causes `_escrowMinMax()` to understate the deficit. In Full escrow mode, when the RAM's free token balance is low, this leads to an incorrect decision to deposit into escrow. The deposit attempt reverts due to insufficient ERC20 balance, and the entire `afterCollection()` call fails. Since RecurringCollector wraps `afterCollection()` in try/catch (line 416), the revert is silently swallowed - but the snap never gets updated, making it permanently stale. + +This is self-reinforcing: every subsequent `afterCollection()`, `reconcileAgreement()`, and `reconcileCollectorProvider()` call for the affected pair follows the same code path and reverts for the same reason. There is no manual recovery path. The escrow accounting diverges from reality for the affected pair, and `totalEscrowDeficit` is globally understated, potentially causing other pairs to incorrectly enter Full mode and over-deposit. + +The state only self-heals when the RAM receives enough tokens (e.g., from issuance distribution) to cover the phantom deposit, at which point the deposit succeeds but sends tokens to escrow unnecessarily. + +## Recommended Mitigation + +Read the fresh escrow balance inside `_escrowMinMax()` when computing the deficit, rather than relying on the cached `escrowSnap` derived from `totalEscrowDeficit`. This makes the function self-correcting: even if a prior `afterCollection()` failed, the next call sees the true balance and makes the correct deposit/thaw decision. This approach fixes the root cause rather than masking the symptom with a balance guard. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-H-4.md b/packages/issuance/audits/PR1301/TRST-H-4.md new file mode 100644 index 000000000..d7013dde9 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-H-4.md @@ -0,0 +1,24 @@ +# TRST-H-4: EOA payer can block collection by acquiring code via EIP-7702 + +- **Severity:** High +- **Category:** Type confusion +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +In `RecurringCollector._collect()` (lines 368-378), the provider eligibility gate is applied when `agreement.payer.code.length > 0`. This gate was designed as an opt-in mechanism for contract payers to control which providers can collect. However, with EIP-7702 (live on both Ethereum mainnet and Arbitrum), an EOA can set a code delegation to an arbitrary contract address. + +An EOA payer who originally signed an agreement via the ECDSA path can later acquire code using an EIP-7702 delegation transaction. This causes the `code.length > 0` branch to activate during collection. By delegating to a contract that implements `supportsInterface()` returning true for `IProviderEligibility` and `isEligible()` returning false, the payer triggers the `require()` on line 373. + +The `require()` is inside the try block's success handler. In Solidity, reverts in the success handler are NOT caught by the catch block - they propagate up and revert the entire transaction. This gives the payer complete, toggleable control over whether collections succeed. The payer can enable the delegation to block collections, disable it to sign new agreements, and re-enable it before collection attempts - all at negligible gas cost. + +The payer can then thaw and withdraw their escrowed funds after the thawing period, effectively receiving services for free. This bypasses the assumed security model where a provider can trust the escrow balance for an EOA payer to ensure collection will succeed. + +## Recommended Mitigation + +Record whether the payer had code at agreement acceptance time by adding a bool flag to the agreement struct (e.g., `payerIsContract`). Only apply the `IProviderEligibility` gate when the payer was a contract at acceptance. This preserves the eligibility feature for legitimate contract payers while closing the EOA-to-contract vector introduced by EIP-7702. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-L-1.md b/packages/issuance/audits/PR1301/TRST-L-1.md new file mode 100644 index 000000000..7c7a14f43 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-1.md @@ -0,0 +1,22 @@ +# TRST-L-1: Insufficient gas for afterCollection callback leaves escrow state outdated + +- **Severity:** Low +- **Category:** Time sensitivity flaw +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +In `RecurringCollector._collect()`, after a successful escrow collection, the function notifies contract payers via a try/catch call to `afterCollection()` (line 416). The caller (originating at data provider) controls the gas forwarded to the `collect()` transaction. By providing just enough gas for the core collection to succeed but not enough for the `afterCollection()` callback, the external call will revert due to an out-of-gas error, which is silently caught by the catch block. + +For the RecurringAgreementManager (RAM), `afterCollection()` triggers `_reconcileAndUpdateEscrow()`, which reconciles the agreement's `maxNextClaim` against on-chain state and updates the escrow snapshot via `_setEscrowSnap()`. When this callback is skipped, the `escrowSnap` remains at its pre-collection value, overstating the actual escrow balance. This stale snapshot causes `totalEscrowDeficit` to be understated, which can lead to incorrect escrow mode decisions in `_escrowMinMax()` for subsequent operations on the affected (collector, provider) pair. + +The state will self-correct on the next successful call to `_updateEscrow()` for the same pair (e.g., via `reconcileAgreement()` or a subsequent collection with sufficient gas), so the impact is temporary. However, during the stale window, escrow rebalancing decisions may be suboptimal. + +## Recommended Mitigation + +Enforce a minimum gas forwarding requirement for the `afterCollection()` callback. This can be done by checking `gasleft()` before the `afterCollection()` call and reverting if insufficient gas remains for the callback to execute meaningfully. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-L-2.md b/packages/issuance/audits/PR1301/TRST-L-2.md new file mode 100644 index 000000000..29491122e --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-2.md @@ -0,0 +1,22 @@ +# TRST-L-2: Pending update over-reserves escrow with unrealistically conservative calculation + +- **Severity:** Low +- **Category:** Arithmetic issues +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +In `offerAgreementUpdate()` (line 328), the pending update's `maxNextClaim` is computed via `_computeMaxFirstClaim()` using the full `maxSecondsPerCollection` window and the new `maxInitialTokens`. This amount is added to `sumMaxNextClaim` alongside the existing (non-pending) `maxNextClaim`, making both slots additive. + +This is overly conservative because only one set of terms is ever active at a time. While the update is pending, the RAM reserves escrow for both the current agreement terms and the proposed updated terms simultaneously. The correct calculation should take the maximum of the two rates multiplied by `maxSecondsPerCollection` plus the new `maxInitialTokens`, and add the old `maxInitialTokens` only if the initial collection has not yet occurred. + +The over-reservation reduces the effective capacity of the RAM, ties up capital that could serve other agreements, and in Full mode can trigger escrow mode degradation by inflating `totalEscrowDeficit`. Once the update is accepted or revoked, the excess is released, but during the pending window the impact on escrow accounting is significant for high-value agreements. Additionally, the over-reservation will trigger an unnecessary thaw as soon as the agreement update completes, since escrow will exceed the corrected target. + +## Recommended Mitigation + +The `pendingMaxNextClaim` should be computed as stated above, then reduced by the current `maxNextClaim` so that the total deficit is accurate. This reflects the reality that only one set of terms is active at any time, and the worst-case scenario where `collect()` is called before and after the agreement update. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-L-3.md b/packages/issuance/audits/PR1301/TRST-L-3.md new file mode 100644 index 000000000..ddac91ef0 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-3.md @@ -0,0 +1,22 @@ +# TRST-L-3: Unsafe behavior of approveAgreement during pause + +- **Severity:** Low +- **Category:** Access control issues +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +The `approveAgreement()` function (line 226) is a view function with no `whenNotPaused` modifier. During a pause, it continues to return the magic selector for authorized hashes, allowing the RecurringCollector to accept new agreements or apply updates even while the RAM is paused. + +A pause is typically an emergency measure intended to halt all state-changing operations. Allowing agreement acceptance during pause undermines this intent, as the accepted agreement creates obligations (escrow reservations, `maxNextClaim` tracking) that the paused RAM cannot manage. + +Similarly, `beforeCollection()` and `afterCollection()` do not check pause state. While blocking these during pause could prevent providers from collecting earned payments, allowing them could pose a security risk if the pause was triggered due to a discovered vulnerability in the escrow management logic. + +## Recommended Mitigation + +Add a pause check to `approveAgreement()` that returns `bytes4(0)` when the contract is paused, preventing new agreement acceptances and updates during emergency pauses. For `beforeCollection()` and `afterCollection()`, evaluate the trade-off: blocking them protects against exploitation of escrow logic bugs during pause, while allowing them ensures providers can still collect earned payments. Consider allowing collection callbacks only in a restricted mode during pause. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-L-4.md b/packages/issuance/audits/PR1301/TRST-L-4.md new file mode 100644 index 000000000..66f7eccf1 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-4.md @@ -0,0 +1,22 @@ +# TRST-L-4: Pair tracking removal blocked by 1 wei escrow donation + +- **Severity:** Low +- **Category:** Donation attacks +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +When the last agreement for a (collector, provider) pair is deleted, `_reconcilePairTracking()` is intended to remove the pair from the tracking sets (`collectorProviders`, `collectors`) and clean up the escrow state. However, an attacker can prevent this cleanup by depositing 1 wei of GRT into the pair's escrow account via `PaymentsEscrow.deposit()` just before the reconciliation occurs. + +The donation increases the escrow balance, which in turn updates the `escrowSnap` to a non-zero value during `_updateEscrow()`. The `_reconcilePairTracking()` function checks whether the `escrowSnap` is zero to determine if the pair can be safely removed. With the 1 wei donation, this check passes (snap != 0), and the pair is retained in the tracking sets even though it has no active agreements. + +This leaves orphaned entries in the `collectorProviders` and `collectors` tracking sets, preventing clean removal of the collector from the RAM's accounting. + +## Recommended Mitigation + +In `_reconcilePairTracking()`, base the removal decision on `pairAgreementCount` reaching zero rather than on `escrowSnap` being zero. If no agreements remain for a pair, remove it from tracking regardless of the escrow balance. Any residual escrow balance (from donations or rounding) can be handled by initiating a thaw before removal. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-L-5.md b/packages/issuance/audits/PR1301/TRST-L-5.md new file mode 100644 index 000000000..fa2c1e37e --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-5.md @@ -0,0 +1,22 @@ +# TRST-L-5: The \_computeMaxFirstClaim function overestimates when deadline is before full collection window + +- **Severity:** Low +- **Category:** Logical flaw +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +In `_computeMaxFirstClaim()` (line 645), the maximum first claim is computed as: `maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens`. This uses the full `maxSecondsPerCollection` window regardless of how much time actually remains until the agreement's `endsAt` deadline. + +In contrast, RecurringCollector's `getMaxNextClaim()` correctly accounts for the remaining time until the deadline, capping the collection window when the deadline is closer than `maxSecondsPerCollection`. The RAM's overestimate means `sumMaxNextClaim` is inflated for agreements near their end date, causing the RAM to reserve more escrow than the RecurringCollector would ever allow to be collected. + +The excess reservation is wasteful but not directly exploitable, as the collector enforces the actual cap during collection. However, it reduces the RAM's effective capacity and can contribute to unnecessary escrow mode degradation. + +## Recommended Mitigation + +Align `_computeMaxFirstClaim()` with the RecurringCollector's `getMaxNextClaim()` logic by accounting for the remaining time until the agreement's `endsAt`. Compute the collection window as `min(maxSecondsPerCollection, endsAt - lastCollectionAt)` when determining the maximum possible claim. This requires passing the `endsAt` parameter to the function. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-M-1.md b/packages/issuance/audits/PR1301/TRST-M-1.md new file mode 100644 index 000000000..50c1b4c66 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-M-1.md @@ -0,0 +1,26 @@ +# TRST-M-1: Micro-thaw griefing via permissionless depositTo() and reconcileAgreement() + +- **Severity:** Medium +- **Category:** Griefing attacks +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +Three independently benign features combine into a griefing vector: + +1. `PaymentsEscrow.depositTo()` has no access control - anyone can deposit any amount for any (payer, collector, receiver) tuple. +2. `reconcileAgreement()` is permissionless - anyone can trigger a reconciliation which calls `_updateEscrow()`. +3. `PaymentsEscrow.adjustThaw()` with `evenIfTimerReset=false` is a no-op when increasing the thaw amount would reset the thawing timer. + +An attacker deposits 1 wei into an escrow account via `depositTo()`, then calls `reconcileAgreement()`. The reconciliation detects escrow is 1 wei above target and initiates a thaw of 1 wei via `adjustThaw()`. This starts the thawing timer. When the RAM later needs to thaw a larger amount (e.g., after an agreement ends or is updated), it calls `adjustThaw()` with `evenIfTimerReset=false`, which becomes a no-op because increasing the thaw would reset the timer. + +In cases where thaws are needed to mobilize funds from one escrow pair to another - for example, to fund a new agreement or agreement update for a different provider - this griefing prevents the rebalancing. New agreements or updates that require escrow from the blocked pair's thawed funds could fail to be properly funded, causing escrow mode degradation or preventing the offers entirely. + +## Recommended Mitigation + +Add a minimum thaw threshold in `_updateEscrow()`. Amounts below the threshold should be ignored rather than initiating a thaw. This prevents an attacker from starting a thaw timer with a dust amount. If they do perform the attack, they will donate a non-negligible amount in exchange for the one-round block. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-M-2.md b/packages/issuance/audits/PR1301/TRST-M-2.md new file mode 100644 index 000000000..562ed2e83 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-M-2.md @@ -0,0 +1,22 @@ +# TRST-M-2: The tempJit fallback in beforeCollection() is unreachable in practice + +- **Severity:** Medium +- **Category:** Logical flaw +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +In `beforeCollection()` (line 236), when the escrow balance is insufficient for an upcoming collection, the function attempts a JIT (Just-In-Time) top-up by setting `$.tempJit = true` before returning. The `tempJit` flag forces `_escrowMinMax()` to return JustInTime mode, freeing escrow from other pairs to fund this collection. + +However, the JIT path is only entered when the escrow is insufficient to cover `tokensToCollect`. In the `RecurringCollector._collect()` flow, `beforeCollection()` is called before `PaymentsEscrow.collect()`. If `beforeCollection()` cannot top up the escrow (because the RAM lacks free balance and the `deficit >= balanceOf()` guard fails), it returns without action. The subsequent `PaymentsEscrow.collect()` then attempts to collect `tokensToCollect` from an escrow that is still insufficient, causing the entire `collect()` transaction to revert. + +This means `tempJit` is never set in the scenario where it would be most needed: when escrow is short and the collection will fail regardless. An admin cannot rely on `tempJit` being triggered automatically during the RecurringCollector collection flow and would need to manually set JIT mode to achieve the intended fallback behavior. This would cause a delay the first time the issue is encountered where presumably there is no reason for admin to intervene. + +## Recommended Mitigation + +The original intention cannot be truly fulfilled without major redesign of multiple contracts. It is in practice more advisable to take the scenario into account and introduce an off-chain monitoring bot which would set the `tempJit` when needed. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-M-3.md b/packages/issuance/audits/PR1301/TRST-M-3.md new file mode 100644 index 000000000..36d531125 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-M-3.md @@ -0,0 +1,22 @@ +# TRST-M-3: Instant escrow mode degradation from Full to OnDemand via agreement offer + +- **Severity:** Medium +- **Category:** Logical flaw +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +Neither `offerAgreement()` nor `offerAgreementUpdate()` verify that the RAM has sufficient token balance to fund the new escrow obligation without degrading the escrow mode. An operator can offer an agreement whose `maxNextClaim`, when added to the existing `sumMaxNextClaim`, causes `totalEscrowDeficit` to exceed the RAM's balance. This instantly degrades the escrow mode from Full to OnDemand for ALL (collector, provider) pairs. + +The degradation occurs because `_escrowMinMax()` checks: `totalEscrowDeficit < balanceOf(address(this))`. When the new agreement pushes the deficit above the balance, this condition becomes false, and `min` drops to 0 for every pair - meaning no proactive deposits are made for any agreement, not just the new one. Existing providers who had fully-escrowed agreements silently lose their escrow guarantees. + +Whether intentional or by misfortune, this behavior can be triggered instantly by a single offer. If this degradation is desirable in some cases, it should only occur by explicit intention, not as a side effect of a routine operation. + +## Recommended Mitigation + +Add a separate configuration flag (e.g., `allowModeDegradation`) that must be explicitly set by the admin to permit offers that would degrade the escrow mode. When the flag is false, `offerAgreement()` and `offerAgreementUpdate()` should revert if the new obligation would push `totalEscrowDeficit` above the current balance. This ensures mode degradation is always a conscious decision. + +## Team Response + +TBD diff --git a/packages/issuance/audits/PR1301/TRST-R-1.md b/packages/issuance/audits/PR1301/TRST-R-1.md new file mode 100644 index 000000000..7670076e2 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-1.md @@ -0,0 +1,7 @@ +# TRST-R-1: Avoid redeployment of the RewardsEligibilityOracle by restructuring storage + +- **Severity:** Recommendation + +## Description + +The modified RewardsEligibilityOracle has two new state variables, as well as moving `eligibilityValidationEnabled` from the original slot to the end of the structure. Due to the relocation, an upgrade is needed, meaning all previous eligibility state will be lost. It is possible to only append storage slots to the original structure, and avoid a hard redeployment flow, by leveraging the upgradeability of the oracle. diff --git a/packages/issuance/audits/PR1301/TRST-R-2.md b/packages/issuance/audits/PR1301/TRST-R-2.md new file mode 100644 index 000000000..0fd0b7767 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-2.md @@ -0,0 +1,10 @@ +# TRST-R-2: Improve stale documentation + +- **Severity:** Recommendation + +## Description + +The functions below are mentioned in various documentation files but do not exist in the current codebase: + +- `acceptUnsignedIndexingAgreement()` +- `removeAgreement()` diff --git a/packages/issuance/audits/PR1301/TRST-R-3.md b/packages/issuance/audits/PR1301/TRST-R-3.md new file mode 100644 index 000000000..d3fa90130 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-3.md @@ -0,0 +1,7 @@ +# TRST-R-3: Incorporate defensive coding best practices + +- **Severity:** Recommendation + +## Description + +In the RAM's `cancelAgreement()` function, the agreement state is required to not be not accepted. However, the logic could be more specific and require the agreement to be Accepted - rejecting previously cancelled agreements. There is no impact because corresponding checks in the RecurringCollector would deny such cancels, but it remains as a best practice. diff --git a/packages/issuance/audits/PR1301/TRST-R-4.md b/packages/issuance/audits/PR1301/TRST-R-4.md new file mode 100644 index 000000000..6e40e6682 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-4.md @@ -0,0 +1,7 @@ +# TRST-R-4: Document critical assumptions in the RAM + +- **Severity:** Recommendation + +## Description + +The `approveAgreement()` view checks if the agreement hash is valid, however it offers no replay protection for repeated agreement approvals. This attack vector is only stopped at the RecurringCollector as it checks the agreement does not exist and maintains unidirectional transitions from the agreement Accepted state. For future collectors this may not be the case, necessitating clear documentation of the assumption. diff --git a/packages/issuance/audits/PR1301/TRST-SR-1.md b/packages/issuance/audits/PR1301/TRST-SR-1.md new file mode 100644 index 000000000..092746b7b --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-SR-1.md @@ -0,0 +1,11 @@ +# TRST-SR-1: JIT mode provider payment race condition + +- **Severity:** Systemic Risk + +## Description + +When the RecurringAgreementManager operates in JustInTime (JIT) escrow mode, escrow is not proactively funded for any (collector, provider) pair. Instead, funds are deposited into escrow only during the `beforeCollection()` callback, moments before `PaymentsEscrow.collect()` executes. Since the RAM holds a shared pool of GRT that backs all agreements, multiple providers collecting around the same time are effectively racing for the same pool of tokens. + +If the RAM's balance is sufficient to cover any single collection but not all concurrent collections, the provider whose data service submits the `collect()` transaction first will succeed, while subsequent providers' collections will revert because the RAM's balance has been depleted by the first collection's JIT deposit. This creates a first-come-first-served dynamic where providers must compete on transaction ordering to receive payment. + +This race condition is inherent to the JIT mode design and cannot be fully eliminated without proactive escrow funding. In extreme cases, a well-resourced provider could use priority gas auctions or private mempools to consistently front-run other providers' collections, creating an unfair payment advantage unrelated to service quality. diff --git a/packages/issuance/audits/PR1301/TRST-SR-2.md b/packages/issuance/audits/PR1301/TRST-SR-2.md new file mode 100644 index 000000000..7089956f7 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-SR-2.md @@ -0,0 +1,11 @@ +# TRST-SR-2: Escrow thawing period creates prolonged fund immobility + +- **Severity:** Systemic Risk + +## Description + +The PaymentsEscrow thawing period (configurable up to `MAX_WAIT_PERIOD`, 90 days) creates a window during which escrowed funds are immobile. When the RAM needs to rebalance escrow across providers - for example, after an agreement ends and funds should be redirected to a new agreement - the thawing delay prevents immediate reallocation. During this window, the RAM effectively has reduced capacity. + +If multiple agreements end in a short period or the escrow mode degrades from Full to OnDemand, the RAM may enter a state where substantial funds are locked in thawing and unavailable for either existing or new obligations. This is compounded by the micro-thaw griefing vector (TRST-M-1), which can extend the immobility period by blocking thaw increases. + +The thawing period is a protocol-level parameter set on PaymentsEscrow and is outside the RAM's control. Changes to this parameter affect all users of the escrow system, not just the RAM. diff --git a/packages/issuance/audits/PR1301/TRST-SR-3.md b/packages/issuance/audits/PR1301/TRST-SR-3.md new file mode 100644 index 000000000..531a71ab6 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-SR-3.md @@ -0,0 +1,11 @@ +# TRST-SR-3: Issuance distribution dependency for RAM solvency + +- **Severity:** Systemic Risk + +## Description + +The RAM relies on periodic issuance distribution (via the issuance allocator) to receive GRT tokens for funding escrow obligations. If the issuance system experiences delays, governance disputes, or contract upgrades that temporarily halt distributions, the RAM's free balance depletes as collections drain escrow without replenishment. + +Once the free balance reaches zero, the RAM cannot fund JIT top-ups in `beforeCollection()`, cannot proactively deposit in Full mode for new agreements, and existing escrow accounts gradually drain with each collection. Prolonged issuance interruption could cascade into escrow mode degradation (Full -> OnDemand -> JIT), ultimately affecting all providers' payment reliability. + +This is an external dependency that the RAM admin cannot mitigate beyond maintaining a buffer balance. diff --git a/packages/issuance/audits/PR1301/TRST-SR-4.md b/packages/issuance/audits/PR1301/TRST-SR-4.md new file mode 100644 index 000000000..18c55ee81 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-SR-4.md @@ -0,0 +1,11 @@ +# TRST-SR-4: Try/catch callback pattern silently degrades state consistency + +- **Severity:** Systemic Risk + +## Description + +The RecurringCollector wraps all payer callbacks (`beforeCollection()`, `afterCollection()`) in try/catch blocks. While this design prevents malicious or buggy payer contracts from blocking collection, it means that any revert in these callbacks is silently discarded. The collection proceeds as if the callback succeeded, but the payer's internal state (escrow snapshots, deficit tracking, reconciliation) may not have been updated. + +This creates a systemic tension: the try/catch is necessary for liveness (ensuring providers can collect), but it trades state consistency for availability. Over time, if callbacks fail repeatedly (due to gas issues, contract bugs, or the stale snapshot issue in TRST-H-3), the divergence between the RAM's internal accounting and the actual escrow state can compound silently with no on-chain signal. + +There is no event emitted when a callback fails, making it difficult for off-chain monitoring to detect and respond to these silent failures. diff --git a/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol b/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol new file mode 100644 index 000000000..85478f82d --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +/// @notice PoC: stale escrowSnap in _escrowMinMax causes afterCollection to revert, +/// which is silently swallowed by RecurringCollector's try/catch, leaving the snap +/// permanently stale. Manual recovery via reconcileAgreement also reverts. + +contract StaleEscrowSnapTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + address internal indexer2; + + // Agreement parameters: maxNextClaim = 1 ether * 3600 + 100 ether = 3700 ether + uint256 constant MAX_INITIAL = 100 ether; + uint256 constant MAX_ONGOING = 1 ether; + uint32 constant MAX_SEC = 3600; + uint256 constant MAX_NEXT_CLAIM = MAX_ONGOING * MAX_SEC + MAX_INITIAL; // 3700 ether + + function setUp() public override { + super.setUp(); + indexer2 = makeAddr("indexer2"); + } + + /// @notice Helper: create an RCA for a specific provider with a specific nonce + function _makeRCAFor( + address provider, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { + rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(agreementManager), + dataService: dataService, + serviceProvider: provider, + maxInitialTokens: MAX_INITIAL, + maxOngoingTokensPerSecond: MAX_ONGOING, + minSecondsPerCollection: 60, + maxSecondsPerCollection: MAX_SEC, + nonce: nonce, + metadata: "" + }); + agreementId = recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + } + + /// @notice Helper: offer an agreement and fund just enough for Full mode deposit, + /// leaving the RAM with a tiny free balance (DUST) afterward. + uint256 constant DUST = 1 ether; + + function _offerWithTightBalance( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + // Mint maxNextClaim + dust so strict < check passes in _escrowMinMax: + // totalEscrowDeficit (3700) < balanceOf (3701) → true → Full mode + // After deposit of 3700 into escrow, RAM keeps DUST. + token.mint(address(agreementManager), MAX_NEXT_CLAIM + DUST); + vm.prank(operator); + return agreementManager.offerAgreement(rca, _collector()); + } + + /// @notice Helper: simulate a collection by directly draining escrow and updating + /// the collector's agreement state (as would happen in a real collection) + function _simulateCollection( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + address provider, + uint256 drainAmount, + uint64 acceptedAt, + uint64 lastCollectionAt + ) internal { + // Drain escrow balance (simulates PaymentsEscrow.collect called by RecurringCollector) + (uint256 balBefore, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + provider + ); + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + provider, + balBefore - drainAmount, // reduced balance + 0, // no thawing + 0 // no thaw timestamp + ); + + // Update collector state (lastCollectionAt advances, reducing maxNextClaim) + recurringCollector.setAgreement( + agreementId, + IRecurringCollector.AgreementData({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: acceptedAt, + lastCollectionAt: lastCollectionAt, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + updateNonce: 0, + canceledAt: 0, + state: IRecurringCollector.AgreementState.Accepted + }) + ); + } + + // ========================================================================= + // Test 1: afterCollection reverts when escrow is drained and RAM is underfunded + // ========================================================================= + + function test_AfterCollection_RevertsWhenEscrowDrainedAndRAMUnderfunded() public { + // --- Setup: offer agreement, accept it, fund escrow exactly --- + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); + bytes16 id = _offerWithTightBalance(rca); + assertEq(id, agreementId); + + // Verify escrow is fully funded, RAM has only dust remaining + (uint256 escrowBal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(escrowBal, MAX_NEXT_CLAIM, "escrow should be fully funded"); + assertEq(token.balanceOf(address(agreementManager)), DUST, "RAM should have only dust"); + + // Mark agreement as accepted on the collector + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // Advance time so collection is valid + vm.warp(block.timestamp + 1 hours); + + // --- Simulate collection draining most of the escrow --- + uint256 drainAmount = 3000 ether; + _simulateCollection( + agreementId, + rca, + indexer, + drainAmount, + uint64(block.timestamp - 1 hours), // acceptedAt + uint64(block.timestamp) // lastCollectionAt = now + ); + + // Verify state: escrow drained, RAM has only dust + (escrowBal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(escrowBal, MAX_NEXT_CLAIM - drainAmount, "escrow drained by collection"); + assertEq(token.balanceOf(address(agreementManager)), DUST, "RAM has only dust remaining"); + + // Snapshot BEFORE afterCollection + uint256 snapBefore = _getEscrowSnap(indexer); + assertEq(snapBefore, MAX_NEXT_CLAIM, "snap is stale (pre-collection value)"); + + // --- afterCollection reverts internally --- + // _reconcileAgreement will reduce sumMaxNextClaim, but the snap is stale-high + // so _escrowMinMax sees totalEscrowDeficit=0, keeps Full mode, tries to deposit + // to bring escrow back to the new sumMaxNextClaim — but RAM has 0 balance. + // The deposit reverts, which propagates up through afterCollection. + vm.prank(address(recurringCollector)); + vm.expectRevert(); // ERC20 transfer reverts (insufficient balance) + agreementManager.afterCollection(agreementId, drainAmount); + + // Snap is STILL stale because afterCollection reverted + uint256 snapAfter = _getEscrowSnap(indexer); + assertEq(snapAfter, snapBefore, "snap unchanged - afterCollection reverted before _setEscrowSnap"); + } + + // ========================================================================= + // Test 2: self-reinforcing — subsequent afterCollection also reverts + // ========================================================================= + + function test_SelfReinforcing_SubsequentAfterCollectionAlsoReverts() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); + _offerWithTightBalance(rca); + uint64 t0 = uint64(block.timestamp); + _setAgreementAccepted(agreementId, rca, t0); + + // --- First collection at t0 + 1h --- + vm.warp(t0 + 1 hours); + _simulateCollection(agreementId, rca, indexer, 3000 ether, t0, uint64(block.timestamp)); + + vm.prank(address(recurringCollector)); + vm.expectRevert(); + agreementManager.afterCollection(agreementId, 3000 ether); + + // --- Second collection at t0 + 2h --- + vm.warp(t0 + 2 hours); + // Escrow is at 700 after first drain; drain another 200 → 500 + _simulateCollection(agreementId, rca, indexer, 200 ether, t0, uint64(block.timestamp)); + + vm.prank(address(recurringCollector)); + vm.expectRevert(); + agreementManager.afterCollection(agreementId, 200 ether); + + // Snap is STILL the original value from offer time — permanently stale + uint256 snap = _getEscrowSnap(indexer); + assertEq(snap, MAX_NEXT_CLAIM, "snap permanently stale across multiple collections"); + } + + // ========================================================================= + // Test 3: manual reconcileAgreement also reverts (no recovery path) + // ========================================================================= + + function test_ManualReconcile_AlsoReverts() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); + _offerWithTightBalance(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + vm.warp(block.timestamp + 1 hours); + + // Collection drains escrow + _simulateCollection( + agreementId, + rca, + indexer, + 3000 ether, + uint64(block.timestamp - 1 hours), + uint64(block.timestamp) + ); + + // afterCollection reverts (as shown above) + vm.prank(address(recurringCollector)); + vm.expectRevert(); + agreementManager.afterCollection(agreementId, 3000 ether); + + // Try manual recovery via reconcileAgreement — ALSO reverts + // Same code path: _reconcileAndCleanup -> _reconcileAndUpdateEscrow -> _updateEscrow + // Same stale snap -> same deposit attempt -> same revert + vm.expectRevert(); + agreementManager.reconcileAgreement(agreementId); + + // reconcileCollectorProvider also reverts (same _updateEscrow path) + vm.expectRevert(); + agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + } + + // ========================================================================= + // Helper: read escrowSnap via the only observable proxy (totalEscrowDeficit) + // Since escrowSnap is internal storage, we infer it from the escrow balance + // returned by getEscrowAccount vs the deficit accounting. + // ========================================================================= + + /// @notice Get the effective escrow snap for a provider by computing what + /// the RAM thinks the balance is based on its deficit accounting. + /// escrowSnap = sumMaxNextClaim - providerDeficit + /// providerDeficit = totalEscrowDeficit (when only one pair exists) + function _getEscrowSnap(address provider) internal view returns (uint256) { + uint256 sumMax = agreementManager.getSumMaxNextClaim(_collector(), provider); + uint256 totalDeficit = agreementManager.getTotalEscrowDeficit(); + // With one pair, totalEscrowDeficit == providerDeficit + // providerDeficit = max(0, sumMaxNextClaim - escrowSnap) + // So escrowSnap = sumMaxNextClaim - providerDeficit (when deficit <= sumMax) + if (totalDeficit > sumMax) return 0; + return sumMax - totalDeficit; + } + + /* solhint-enable graph/func-name-mixedcase */ +} From 956d983aab3377ca62d1f04256db3ba44a8b1e97 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 28 Mar 2026 08:35:59 +0000 Subject: [PATCH 057/157] feat(RAM): threshold-based escrow basis degradation (TRST-M-2, TRST-M-3) Replace tempJit/fullReserveMargin with two configurable parameters: minOnDemandBasisThreshold (default 128) and minFullBasisMargin (default 16). Effective basis limited based on spare balance relative to sumMaxNextClaimAll using strict <. Delete staleSnap.t.sol (PoC scenario no longer applicable after threshold-based degradation replaces tempJit). --- .../agreement/IRecurringAgreementHelper.sol | 6 +- .../IRecurringAgreementManagement.sol | 13 +- .../agreement/IRecurringAgreements.sol | 17 +- .../agreement/IRecurringEscrowManagement.sol | 37 +- packages/issuance/audits/PR1301/TRST-M-2.md | 6 + packages/issuance/audits/PR1301/TRST-M-3.md | 6 + .../agreement/RecurringAgreementHelper.sol | 3 +- .../agreement/RecurringAgreementManager.md | 56 +- .../agreement/RecurringAgreementManager.sol | 82 +- .../unit/agreement-manager/edgeCases.t.sol | 23 +- .../agreement-manager/ensureDistributed.t.sol | 12 +- .../unit/agreement-manager/fundingModes.t.sol | 889 ++++++++++-------- .../test/unit/agreement-manager/fuzz.t.sol | 16 +- .../unit/agreement-manager/helperAudit.t.sol | 3 +- .../agreement-manager/multiCollector.t.sol | 16 +- .../unit/agreement-manager/offerUpdate.t.sol | 7 +- .../unit/agreement-manager/register.t.sol | 6 +- .../unit/agreement-manager/staleSnap.t.sol | 270 ------ 18 files changed, 670 insertions(+), 798 deletions(-) delete mode 100644 packages/issuance/test/unit/agreement-manager/staleSnap.t.sol diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol index 3e37e50e8..7436c9274 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol @@ -25,7 +25,8 @@ interface IRecurringAgreementHelper { * @param totalEscrowDeficit Total unfunded escrow across all pairs * @param totalAgreementCount Total number of tracked agreements * @param escrowBasis Configured escrow level (Full / OnDemand / JustInTime) - * @param tempJit Whether the temporary JIT breaker is active + * @param minOnDemandBasisThreshold Threshold for OnDemand basis (numerator over 256) + * @param minFullBasisMargin Margin for Full basis (added to 256) * @param collectorCount Number of collectors with active agreements */ struct GlobalAudit { @@ -34,7 +35,8 @@ interface IRecurringAgreementHelper { uint256 totalEscrowDeficit; uint256 totalAgreementCount; IRecurringEscrowManagement.EscrowBasis escrowBasis; - bool tempJit; + uint8 minOnDemandBasisThreshold; + uint8 minFullBasisMargin; uint256 collectorCount; } diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol index 43f72057a..e760498d3 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol @@ -160,6 +160,11 @@ interface IRecurringAgreementManagement { * @dev Calculates max next claim from RCA parameters, stores the authorized hash * for the {IAgreementOwner} callback, and deposits into escrow. * Requires AGREEMENT_MANAGER_ROLE. + * + * WARNING: increases `sumMaxNextClaim` (and `totalEscrowDeficit`) without checking escrow + * headroom. A single offer can push `spare` below the degradation threshold, instantly + * degrading the escrow mode for ALL (collector, provider) pairs. The caller should verify + * sufficient balance before calling. See RecurringAgreementManager.md, Automatic Degradation. * @param rca The Recurring Collection Agreement parameters * @param collector The RecurringCollector contract to use for this agreement * @return agreementId The deterministic agreement ID @@ -177,6 +182,12 @@ interface IRecurringAgreementManagement { * pending update as a separate escrow entry alongside the current agreement. * If a previous pending update exists, it is replaced. * Requires AGREEMENT_MANAGER_ROLE. + * + * WARNING: potentially increases `sumMaxNextClaim` (and `totalEscrowDeficit`), without + * checking escrow headroom. A single update can push `spare` below the degradation threshold, + * instantly degrading the escrow mode for ALL (collector, provider) pairs. The caller should + * verify sufficient balance before calling. + * See RecurringAgreementManager.md, Automatic Degradation. * @param rcau The Recurring Collection Agreement Update parameters * @return agreementId The agreement ID from the RCAU */ @@ -238,7 +249,7 @@ interface IRecurringAgreementManagement { * @dev Permissionless. First updates escrow state (deposit deficit, thaw excess, * withdraw completed thaws), then removes pair tracking when both pairAgreementCount * and escrow balance are zero. Also serves as the permissionless "poke" to rebalance - * escrow after {IRecurringEscrowManagement-setEscrowBasis} or {IRecurringEscrowManagement-setTempJit} + * escrow after {IRecurringEscrowManagement-setEscrowBasis} or threshold/margin * changes. Returns true if the pair still has agreements or escrow is still thawing. * @param collector The collector address * @param provider The provider address diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol index 9d6223ad0..b841618bf 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol @@ -149,13 +149,18 @@ interface IRecurringAgreements { function getTotalAgreementCount() external view returns (uint256 count); /** - * @notice Check whether temporary JIT mode is currently active - * @dev When active, the system operates in JIT-only mode regardless of the configured - * escrow basis. The configured basis is preserved and takes effect again when - * temp JIT recovers (totalEscrowDeficit < available) or operator calls {setTempJit}. - * @return active True if temporary JIT mode is active + * @notice Get the minimum spare balance threshold for OnDemand basis. + * @dev Effective basis limited to JustInTime when spare < sumMaxNextClaimAll * threshold / 256. + * @return threshold The numerator over 256 */ - function isTempJit() external view returns (bool active); + function getMinOnDemandBasisThreshold() external view returns (uint8 threshold); + + /** + * @notice Get the minimum spare balance margin for Full basis. + * @dev Effective basis limited to OnDemand when spare < sumMaxNextClaimAll * (256 + margin) / 256. + * @return margin The margin added to 256 + */ + function getMinFullBasisMargin() external view returns (uint8 margin); /** * @notice Get the number of collectors with active agreements diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol index ee4d3d35b..a087062ae 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol @@ -56,12 +56,18 @@ interface IRecurringEscrowManagement { event EscrowBasisSet(EscrowBasis indexed oldBasis, EscrowBasis indexed newBasis); /** - * @notice Emitted when temporary JIT mode is activated or deactivated - * @param active True when entering temp JIT, false when recovering - * @param automatic True when triggered by the system (beforeCollection/reconcileCollectorProvider), - * false when triggered by operator (setTempJit/setEscrowBasis) + * @notice Emitted when the OnDemand basis threshold is changed + * @param oldThreshold The previous threshold + * @param newThreshold The new threshold */ - event TempJitSet(bool indexed active, bool indexed automatic); + event MinOnDemandBasisThresholdSet(uint8 oldThreshold, uint8 newThreshold); + + /** + * @notice Emitted when the Full basis margin is changed + * @param oldMargin The previous margin + * @param newMargin The new margin + */ + event MinFullBasisMarginSet(uint8 oldMargin, uint8 newMargin); // solhint-enable gas-indexed-events @@ -77,11 +83,20 @@ interface IRecurringEscrowManagement { function setEscrowBasis(EscrowBasis basis) external; /** - * @notice Manually activate or deactivate temporary JIT mode - * @dev Requires OPERATOR_ROLE. When activated, the system operates in JIT-only mode - * regardless of the configured escrow basis. When deactivated, the configured basis - * takes effect again. Emits {TempJitSet}. - * @param active True to activate temp JIT, false to deactivate + * @notice Set the minimum spare balance threshold for OnDemand basis. + * @dev Requires OPERATOR_ROLE. The effective basis is limited to JustInTime + * when spare balance (balance - totalEscrowDeficit) is not strictly greater than + * sumMaxNextClaimAll * minOnDemandBasisThreshold / 256. + * @param threshold The numerator over 256 for the spare threshold + */ + function setMinOnDemandBasisThreshold(uint8 threshold) external; + + /** + * @notice Set the minimum spare balance margin for Full basis. + * @dev Requires OPERATOR_ROLE. The effective basis is limited to OnDemand + * when spare balance is not strictly greater than + * sumMaxNextClaimAll * (256 + minFullBasisMargin) / 256. + * @param margin The margin added to 256 for the spare threshold numerator */ - function setTempJit(bool active) external; + function setMinFullBasisMargin(uint8 margin) external; } diff --git a/packages/issuance/audits/PR1301/TRST-M-2.md b/packages/issuance/audits/PR1301/TRST-M-2.md index 562ed2e83..9fc633fa5 100644 --- a/packages/issuance/audits/PR1301/TRST-M-2.md +++ b/packages/issuance/audits/PR1301/TRST-M-2.md @@ -20,3 +20,9 @@ The original intention cannot be truly fulfilled without major redesign of multi ## Team Response TBD + +--- + +The `tempJit` mechanism has been replaced with threshold-based basis degradation. + +`_escrowMinMax()` now uses `minOnDemandBasisThreshold` and `minFullBasisMargin` parameters to automatically limit the effective escrow basis based on the ratio of spare balance to `sumMaxNextClaimAll`. This does not rely on a callback to activate and provides automatic, configurable transition boundaries. diff --git a/packages/issuance/audits/PR1301/TRST-M-3.md b/packages/issuance/audits/PR1301/TRST-M-3.md index 36d531125..ea3c6f7da 100644 --- a/packages/issuance/audits/PR1301/TRST-M-3.md +++ b/packages/issuance/audits/PR1301/TRST-M-3.md @@ -20,3 +20,9 @@ Add a separate configuration flag (e.g., `allowModeDegradation`) that must be ex ## Team Response TBD + +--- + +Acknowledged. The risk is documented in [RecurringAgreementManager.md — Automatic Degradation](../../contracts/agreement/RecurringAgreementManager.md#automatic-degradation), including the operator caution about pre-offer headroom checks. + +An on-chain guard was prototyped but added ~2.7KB to the contract, exceeding the Spurious Dragon 24576-byte limit. The operator (AGREEMENT_MANAGER_ROLE holder) is a trusted role expected to verify escrow headroom before offering agreements. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol index 250ca600d..ca934e131 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol @@ -53,7 +53,8 @@ contract RecurringAgreementHelper is IRecurringAgreementHelper { totalEscrowDeficit: mgr.getTotalEscrowDeficit(), totalAgreementCount: mgr.getTotalAgreementCount(), escrowBasis: mgr.getEscrowBasis(), - tempJit: mgr.isTempJit(), + minOnDemandBasisThreshold: mgr.getMinOnDemandBasisThreshold(), + minFullBasisMargin: mgr.getMinFullBasisMargin(), collectorCount: mgr.getCollectorCount() }); } diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.md b/packages/issuance/contracts/agreement/RecurringAgreementManager.md index 92b7c14de..e2fdf94d7 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.md +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.md @@ -115,7 +115,20 @@ The split ensures smooth transitions between levels. When degradation occurs, mi ### Automatic Degradation -The setting is a ceiling, not a mandate. **Full → OnDemand** when `available <= totalEscrowDeficit` (RAM's balance can't close the system-wide gap): min drops to 0, max stays at `sumMaxNextClaim`. Degradation never reaches JustInTime automatically — only explicit operator setting or temp JIT. +The setting is a ceiling, not a mandate. `_escrowMinMax` computes `spare = balance - totalEscrowDeficit` (floored at 0) and compares it against `sumMaxNextClaimAll` scaled by two configurable uint8 parameters (fractional units of 1/256): + +| Gate | Controls | Condition (active when true) | Parameter (default) | +| ---- | ---------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------- | +| max | Hold escrow at `sumMaxNextClaim` ceiling | `sumMaxNextClaimAll * minOnDemandBasisThreshold / 256 < spare` | `minOnDemandBasisThreshold` (128 = 50%) | +| min | Proactively deposit to `sumMaxNextClaim` | `sumMaxNextClaimAll * (256 + minFullBasisMargin) / 256 < spare` (requires basis = Full) | `minFullBasisMargin` (16 ~ 6% margin) | + +The min gate is stricter (0.5x < 1.0625x), giving three effective states as `spare` decreases: + +1. **Full** (`smnca × 1.0625 < spare`): both gates pass — min = max = `sumMaxNextClaim` +2. **OnDemand** (`smnca × 0.5 < spare ≤ smnca × 1.0625`): min gate fails, max holds — min = 0, max = `sumMaxNextClaim` (no new deposits, but existing escrow up to max is held) +3. **JIT** (`spare ≤ smnca × 0.5`): both gates fail — min = max = 0 (thaw everything) + +**Operator caution — new agreements can trigger instant degradation.** `offerAgreement()` and `offerAgreementUpdate()` increase `sumMaxNextClaim` (and therefore `totalEscrowDeficit`) without checking whether the RAM has sufficient balance to maintain the current escrow mode. A single offer can push `spare` below the threshold, instantly degrading escrow mode for **all** (collector, provider) pairs — not just the new agreement. Existing providers who had fully-escrowed agreements silently lose their proactive deposits. The operator (AGREEMENT_MANAGER_ROLE holder) should verify escrow headroom before offering agreements. An on-chain guard was considered but excluded due to contract size constraints (Spurious Dragon 24576-byte limit). ### `_updateEscrow` Flow @@ -132,40 +145,27 @@ Per-agreement reconciliation (`reconcileAgreement`) re-reads agreement state fro ### Global Tracking -| Storage field | Type | Updated at | -| ----------------------------------- | ------- | --------------------------------------------------------------------------- | -| `escrowBasis` | enum | `setEscrowBasis()` | -| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | -| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | -| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `removeAgreement` (-1) | -| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | -| `tempJit` | bool | `beforeCollection` (trip), `_updateEscrow` (recover), `setTempJit` (manual) | -| `issuanceAllocator` | address | `setIssuanceAllocator()` (governor) | -| `ensuredIncomingDistributedToBlock` | uint64 | `_ensureIncomingDistributionToCurrentBlock()` (per-block dedup) | +| Storage field | Type | Updated at | +| ----------------------------------- | ------- | -------------------------------------------------------------------- | +| `escrowBasis` | enum | `setEscrowBasis()` | +| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | +| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | +| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `reconcileAgreement` (-1) | +| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | +| `minOnDemandBasisThreshold` | uint8 | `setMinOnDemandBasisThreshold()` (operator) | +| `minFullBasisMargin` | uint8 | `setMinFullBasisMargin()` (operator) | +| `issuanceAllocator` | address | `setIssuanceAllocator()` (governor) | +| `ensuredIncomingDistributedToBlock` | uint64 | `_ensureIncomingDistributionToCurrentBlock()` (per-block dedup) | **`totalEscrowDeficit`** is maintained incrementally as `Σ max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p])` per (collector, provider). Over-deposited pairs cannot mask another pair's deficit. At each mutation point, the pair's deficit is recomputed before and after. -### Temp JIT - -If `beforeCollection` can't fully deposit for a collection (`available <= deficit`), it deposits nothing and activates temporary JIT mode. While active, `_escrowMinMax` returns `(0, 0)` — JIT-only behavior — regardless of the configured `escrowBasis`. The configured basis is preserved and takes effect again on recovery. - -**Trigger**: `beforeCollection` activates temp JIT when `available <= deficit` (all-or-nothing: no partial deposits). - -**Recovery**: `_updateEscrow` clears temp JIT when `totalEscrowDeficit < available`. Recovery uses `totalEscrowDeficit` (sum of per-(collector, provider) deficits) rather than total sumMaxNextClaim, correctly accounting for already-deposited escrow. During JIT mode, thaws complete and tokens return to RAM, naturally building toward recovery. - -**Operator override**: `setTempJit(bool)` allows direct control. `setEscrowBasis` does not affect `tempJit` — the two settings are independent. - -### Upgrade Safety - -Default storage value 0 maps to `JustInTime`, so `initialize()` sets `escrowBasis = Full` as the default. Future upgrades must set it explicitly via a reinitializer. `tempJit` defaults to `false` (0), which is correct — no temp JIT on fresh deployment. - ## Roles - **GOVERNOR_ROLE**: Sets issuance allocator, eligibility oracle; grants `DATA_SERVICE_ROLE`, `COLLECTOR_ROLE`, and other roles; admin of `OPERATOR_ROLE` -- **OPERATOR_ROLE**: Sets escrow basis and temp JIT; admin of `AGREEMENT_MANAGER_ROLE` +- **OPERATOR_ROLE**: Sets escrow basis and threshold/margin parameters; admin of `AGREEMENT_MANAGER_ROLE` - **AGREEMENT_MANAGER_ROLE**: Offers agreements/updates, revokes offers, cancels agreements -- **PAUSE_ROLE**: Pauses contract (reconcile/remove remain available) -- **Permissionless**: `reconcileAgreement`, `removeAgreement`, `reconcileCollectorProvider` +- **PAUSE_ROLE**: Pauses contract (reconcile remains available) +- **Permissionless**: `reconcileAgreement`, `reconcileCollectorProvider` - **RecurringAgreementHelper** (permissionless): `reconcile(provider)`, `reconcileBatch(ids[])` ## Deployment diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 309c81f21..3816ee7f7 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -132,15 +132,20 @@ contract RecurringAgreementManager is /// @notice Number of agreements per (collector, provider) pair mapping(address collector => mapping(address provider => uint256)) pairAgreementCount; /// @notice The issuance allocator that mints GRT to this contract (20 bytes) - /// @dev Packed slot (30/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + - /// escrowBasis (1) + tempJit (1). All read together in _updateEscrow / beforeCollection. + /// @dev Packed slot (31/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + + /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1). + /// All read together in _updateEscrow / beforeCollection. IIssuanceAllocationDistribution issuanceAllocator; /// @notice Block number when _ensureIncomingDistributionToCurrentBlock last ran uint64 ensuredIncomingDistributedToBlock; - /// @notice Governance-configured escrow level (not modified by temp JIT) + /// @notice Governance-configured escrow level (maximum target) EscrowBasis escrowBasis; - /// @notice Whether temporary JIT mode is active (beforeCollection couldn't deposit) - bool tempJit; + /// @notice Threshold for OnDemand: sumMaxNextClaimAll * threshold / 256 < spare. + /// Governance-configured. + uint8 minOnDemandBasisThreshold; + /// @notice Margin for Full: sumMaxNextClaimAll * (256 + margin) / 256 < spare. + /// Governance-configured. + uint8 minFullBasisMargin; /// @notice Optional oracle for checking payment eligibility of service providers (20/32 bytes in slot) IProviderEligibility providerEligibilityOracle; } @@ -172,7 +177,11 @@ contract RecurringAgreementManager is _setRoleAdmin(DATA_SERVICE_ROLE, GOVERNOR_ROLE); _setRoleAdmin(COLLECTOR_ROLE, GOVERNOR_ROLE); _setRoleAdmin(AGREEMENT_MANAGER_ROLE, OPERATOR_ROLE); - _getStorage().escrowBasis = EscrowBasis.Full; + + RecurringAgreementManagerStorage storage $ = _getStorage(); + $.escrowBasis = EscrowBasis.Full; + $.minOnDemandBasisThreshold = 128; + $.minFullBasisMargin = 16; } // -- ERC165 -- @@ -247,14 +256,10 @@ contract RecurringAgreementManager is // Ensure issuance is distributed so balanceOf reflects all available tokens _ensureIncomingDistributionToCurrentBlock($); - // Strict <: when deficit == available, enter tempJit rather than depleting entire balance uint256 deficit = tokensToCollect - escrowBalance; if (deficit < GRAPH_TOKEN.balanceOf(address(this))) { GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deficit); PAYMENTS_ESCROW.deposit(msg.sender, provider, deficit); - } else if (!$.tempJit) { - $.tempJit = true; - emit TempJitSet(true, true); } } @@ -434,12 +439,23 @@ contract RecurringAgreementManager is } /// @inheritdoc IRecurringEscrowManagement - function setTempJit(bool active) external onlyRole(OPERATOR_ROLE) { + function setMinOnDemandBasisThreshold(uint8 threshold) external onlyRole(OPERATOR_ROLE) { RecurringAgreementManagerStorage storage $ = _getStorage(); - if ($.tempJit != active) { - $.tempJit = active; - emit TempJitSet(active, false); - } + if ($.minOnDemandBasisThreshold == threshold) return; + + uint8 oldThreshold = $.minOnDemandBasisThreshold; + $.minOnDemandBasisThreshold = threshold; + emit MinOnDemandBasisThresholdSet(oldThreshold, threshold); + } + + /// @inheritdoc IRecurringEscrowManagement + function setMinFullBasisMargin(uint8 margin) external onlyRole(OPERATOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if ($.minFullBasisMargin == margin) return; + + uint8 oldMargin = $.minFullBasisMargin; + $.minFullBasisMargin = margin; + emit MinFullBasisMarginSet(oldMargin, margin); } // -- IProviderEligibilityManagement -- @@ -533,8 +549,13 @@ contract RecurringAgreementManager is } /// @inheritdoc IRecurringAgreements - function isTempJit() external view returns (bool) { - return _getStorage().tempJit; + function getMinOnDemandBasisThreshold() external view returns (uint8) { + return _getStorage().minOnDemandBasisThreshold; + } + + /// @inheritdoc IRecurringAgreements + function getMinFullBasisMargin() external view returns (uint8) { + return _getStorage().minFullBasisMargin; } /// @inheritdoc IRecurringAgreements @@ -818,9 +839,9 @@ contract RecurringAgreementManager is * | OnDemand | 0 | sumMaxNext | * | JustInTime | 0 | 0 | * - * When tempJit, behaves as JustInTime regardless of configured basis. - * Full degrades to OnDemand when available balance <= totalEscrowDeficit. - * Full requires strictly more tokens on hand than the global deficit. + * The effective basis is the configured escrowBasis limited based on spare balance + * (balance - totalEscrowDeficit). OnDemand requires sumMaxNextClaimAll * threshold / 256 < spare. + * Full requires sumMaxNextClaimAll * (256 + margin) / 256 < spare. * * @param collector The collector address * @param provider The service provider @@ -833,10 +854,18 @@ contract RecurringAgreementManager is address collector, address provider ) private view returns (uint256 min, uint256 max) { - EscrowBasis basis = $.tempJit ? EscrowBasis.JustInTime : $.escrowBasis; - - max = basis == EscrowBasis.JustInTime ? 0 : $.sumMaxNextClaim[collector][provider]; - min = (basis == EscrowBasis.Full && $.totalEscrowDeficit < GRAPH_TOKEN.balanceOf(address(this))) ? max : 0; + uint256 balance = GRAPH_TOKEN.balanceOf(address(this)); + uint256 totalDeficit = $.totalEscrowDeficit; + uint256 spare = totalDeficit < balance ? balance - totalDeficit : 0; + uint256 sumMaxNext = $.sumMaxNextClaimAll; + + EscrowBasis basis = $.escrowBasis; + max = basis != EscrowBasis.JustInTime && ((sumMaxNext * uint256($.minOnDemandBasisThreshold)) / 256 < spare) + ? $.sumMaxNextClaim[collector][provider] + : 0; + min = basis == EscrowBasis.Full && ((sumMaxNext * (256 + uint256($.minFullBasisMargin))) / 256 < spare) + ? max + : 0; } /** @@ -887,11 +916,6 @@ contract RecurringAgreementManager is // solhint-disable-next-line use-natspec function _updateEscrow(RecurringAgreementManagerStorage storage $, address collector, address provider) private { _ensureIncomingDistributionToCurrentBlock($); - // Auto-recover from tempJit when balance exceeds deficit (same strict < as beforeCollection/escrowMinMax) - if ($.tempJit && $.totalEscrowDeficit < GRAPH_TOKEN.balanceOf(address(this))) { - $.tempJit = false; - emit TempJitSet(false, true); - } IPaymentsEscrow.EscrowAccount memory account = _fetchEscrowAccount(collector, provider); (uint256 min, uint256 max) = _escrowMinMax($, collector, provider); diff --git a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol index c08476ff9..c8a99df8d 100644 --- a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol +++ b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol @@ -1123,8 +1123,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar vm.prank(address(recurringCollector)); agreementManager.beforeCollection(agreementId, escrowBalance); - // tempJit must NOT be set — there is no deficit - assertFalse(agreementManager.isTempJit(), "No tempJit when escrow exactly covers collection"); + // No deficit — collection should succeed without issue } // ==================== Cancel Event Behavior ==================== @@ -1243,24 +1242,4 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar assertEq(agreementManager.approveAgreement(hash2), bytes4(0)); assertEq(agreementManager.approveAgreement(hash3), IAgreementOwner.approveAgreement.selector); } - - // ==================== setTempJit No-Op ==================== - - function test_SetTempJit_NoopWhenAlreadyFalse() public { - // Default tempJit is false; setting false again should early-return with no event - vm.recordLogs(); - vm.prank(operator); - agreementManager.setTempJit(false); - - Vm.Log[] memory logs = vm.getRecordedLogs(); - for (uint256 i = 0; i < logs.length; i++) { - assertTrue( - logs[i].topics[0] != IRecurringEscrowManagement.TempJitSet.selector, - "TempJitSet should not be emitted" - ); - } - assertFalse(agreementManager.isTempJit()); - } - - /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index 20443dda8..51abcf32c 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -112,20 +112,18 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan token.transfer(address(1), freeBalance); assertEq(token.balanceOf(address(agreementManager)), 0); - // Configure allocator to mint enough to cover the deficit + // Configure allocator to mint enough to cover the deficit plus 50% of sumMaxNextClaimAll reserve uint256 deficit = 500 ether; - mockAllocator.setMintPerDistribution(deficit + 1 ether); + uint256 reserve = agreementManager.getSumMaxNextClaimAll(); // >= 50% threshold + mockAllocator.setMintPerDistribution(deficit + reserve); // Advance block so distribution actually mints vm.roll(block.number + 1); - // Without distribution, this would trigger tempJit (balance=0, deficit=500). - // With distribution, the allocator mints tokens first, so JIT deposit succeeds. + // Without distribution, balance would be 0. With distribution, the allocator mints + // tokens first, so JIT deposit succeeds. vm.prank(address(recurringCollector)); agreementManager.beforeCollection(agreementId, escrowBalance + deficit); - - // tempJit should NOT be active — distribution provided funds - assertFalse(agreementManager.isTempJit(), "tempJit should not be set when distribution provides funds"); } function test_BeforeCollection_SkipsDistributeWhenEscrowSufficient() public { diff --git a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol index 960825dc6..6060af619 100644 --- a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol @@ -885,43 +885,58 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS assertEq(afterWithdraw.tokensThawing, 0, "JIT: nothing left to thaw"); } - // ==================== Temp JIT ==================== - - function test_TempJit_TripsOnPartialBeforeCollection() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( - indexer, - 100 ether, - 1 ether, - 3600, - 1 - ); - bytes16 agreementId = _offerAgreement(rca); - - // Drain SAM's token balance so beforeCollection can't fully fund + // ==================== Threshold-Based Basis Degradation ==================== + // + // _escrowMinMax computes spare = balance - totalEscrowDeficit (floored at 0) + // and checks two gates against sumMaxNextClaimAll (smnca): + // + // max gate: smnca * minOnDemandBasisThreshold / 256 < spare [default threshold=128 -> 0.5x] + // min gate: smnca * (256 + minFullBasisMargin) / 256 < spare [default margin=16 -> 1.0625x] + // + // min gate is stricter (1.0625 > 0.5), giving three degradation states: + // Full: spare > smnca * 1.0625 (min=max=sumMaxNextClaim) + // OnDemand: 0.5*smnca < spare <= 1.0625*smnca (min=0, max=sumMaxNextClaim) + // JIT-like: spare <= 0.5*smnca (min=0, max=0) + + // -- Helpers for degradation tests -- + + /// @notice Drain SAM balance to zero + function _drainSAM() internal { uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); token.transfer(address(1), samBalance); } + } - // Request collection exceeding escrow balance - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(true, true); + /// @notice Get the effective escrow balance (balance - tokensThawing) for a pair + function _effectiveEscrow(address collector, address provider) internal view returns (uint256) { + (uint256 balance, uint256 thawing, ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + collector, + provider + ); + return balance - thawing; + } - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); + /// @notice Get full escrow account for a pair + function _escrowAccount( + address collector, + address provider + ) internal view returns (uint256 balance, uint256 tokensThawing, uint256 thawEndTimestamp) { + return paymentsEscrow.escrowAccounts(address(agreementManager), collector, provider); + } - // Verify state - assertTrue(agreementManager.isTempJit(), "Temp JIT should be tripped"); - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.Full), - "Basis unchanged (temp JIT overrides behavior, not escrowBasis)" - ); + /// @notice Fund SAM so spare equals exactly the given amount (above totalEscrowDeficit) + function _fundToSpare(uint256 targetSpare) internal { + _drainSAM(); + uint256 deficit = agreementManager.getTotalEscrowDeficit(); + token.mint(address(agreementManager), deficit + targetSpare); } - function test_BeforeCollection_TripsWhenAvailableEqualsDeficit() public { - // Boundary: available == deficit — strict '<' means trip, not deposit + // ---- Full basis: min gate (1.0625x) controls Full -> OnDemand ---- + + function test_BasisDegradation_Full_BothGatesPass_DepositsToSumMaxNextClaim() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -929,37 +944,23 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - - // Set manager balance to exactly the escrow shortfall - (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); - uint256 tokensToCollect = escrowBalance + 500 ether; - uint256 deficit = tokensToCollect - escrowBalance; // 500 ether - - // Drain SAM then mint exactly the deficit - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } - token.mint(address(agreementManager), deficit); - assertEq(token.balanceOf(address(agreementManager)), deficit, "Balance == deficit"); - - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(true, true); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, tokensToCollect); + // spare > smnca * 1.0625 -- both gates pass -> Full + _fundToSpare((smnca * (256 + 16)) / 256 + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertTrue(agreementManager.isTempJit(), "Trips when available == deficit"); + assertEq( + _effectiveEscrow(address(recurringCollector), indexer), + pairSmnc, + "Full: deposited to sumMaxNextClaim" + ); } - function test_BeforeCollection_DepositsWhenAvailableExceedsDeficit() public { - // Boundary: available == deficit + 1 — deposits instead of tripping + function test_BasisDegradation_Full_MinGateFail_DegradesToOnDemand() public { + // spare at min gate boundary: min gate fails but max gate passes -> OnDemand IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -967,41 +968,31 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - - (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); - uint256 tokensToCollect = escrowBalance + 500 ether; - uint256 deficit = tokensToCollect - escrowBalance; // 500 ether + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); - // Drain SAM then mint deficit + 1 - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } - token.mint(address(agreementManager), deficit + 1); + // spare = smnca * 272/256 exactly -- min gate fails (not strictly greater) + // but spare > smnca * 128/256, so max gate passes + uint256 minGateThreshold = (smnca * (256 + 16)) / 256; + _fundToSpare(minGateThreshold); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, tokensToCollect); + // OnDemand behavior: min=0 (no deposits), max=sumMaxNextClaim (holds ceiling) + // Escrow was deposited during offerAgreement, so it should still be at pairSmnc + // (max holds, no thaw started because balance <= max) + uint256 effective = _effectiveEscrow(address(recurringCollector), indexer); + assertEq(effective, pairSmnc, "OnDemand: escrow held at ceiling (no thaw)"); - assertFalse(agreementManager.isTempJit(), "No trip when deficit < available"); - (uint256 newEscrow, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer + // Stored basis unchanged + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Stored basis unchanged" ); - assertEq(newEscrow, tokensToCollect, "Escrow topped up to tokensToCollect"); } - function test_TempJit_PreservesBasisOnTrip() public { - // Set OnDemand, trip — escrowBasis should NOT change - vm.prank(operator); - agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); - + function test_BasisDegradation_Full_MinGateBoundary_OneWeiDifference() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1009,31 +1000,27 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - - // Drain SAM - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 minGateThreshold = (smnca * (256 + 16)) / 256; - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(true, true); + // At min gate boundary: OnDemand (min=0, max=smnc) + _fundToSpare(minGateThreshold); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); + // Escrow was pre-deposited, OnDemand holds it (no thaw because balance <= max) + assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "At boundary: OnDemand holds"); - // Basis stays OnDemand (not switched to JIT) - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), - "Basis unchanged during trip" - ); - assertTrue(agreementManager.isTempJit()); + // One wei above: Full (min=max=smnc) + _fundToSpare(minGateThreshold + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "One above boundary: Full deposits"); } - function test_TempJit_DoesNotTripWhenFullyCovered() public { + // ---- Full basis: max gate (0.5x) controls OnDemand -> JIT-like ---- + + function test_BasisDegradation_Full_MaxGateFail_DegradesToJIT() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1041,20 +1028,19 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - uint256 maxClaim = 1 ether * 3600 + 100 ether; - - // Ensure SAM has plenty of tokens - token.mint(address(agreementManager), 1_000_000 ether); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - // Request less than escrow balance — no trip - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, maxClaim); + // spare = smnca * 128/256 exactly -- max gate fails -> JIT-like (both 0) + uint256 maxGateThreshold = (smnca * 128) / 256; + _fundToSpare(maxGateThreshold); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertFalse(agreementManager.isTempJit(), "No trip when fully covered"); + (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, bal, "JIT-like: all escrow thawing"); } - function test_TempJit_DoesNotTripWhenAlreadyActive() public { + function test_BasisDegradation_Full_MaxGateBoundary_OneWeiDifference() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1062,40 +1048,36 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 maxGateThreshold = (smnca * 128) / 256; - // Drain SAM - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + // At max gate boundary: JIT-like + _fundToSpare(maxGateThreshold); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + (uint256 bal1, uint256 thawing1, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing1, bal1, "At max boundary: JIT thaws all"); - // First trip - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + // Complete thaw + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // Second partial collection — should NOT emit event again - vm.recordLogs(); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); + // One wei above max gate: OnDemand (max passes, min still fails since 0.5x+1 < 1.0625x) + _fundToSpare(maxGateThreshold + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // Check no TempJitSet event was emitted - Vm.Log[] memory logs = vm.getRecordedLogs(); - bytes32 tripSig = keccak256("TempJitSet(bool,bool)"); - bool found = false; - for (uint256 i = 0; i < logs.length; i++) { - if (logs[i].topics[0] == tripSig) found = true; - } - assertFalse(found, "No second trip event"); + // OnDemand: min=0 so no deposit happens (escrow was withdrawn during thaw) + // max=smnc so no thaw starts either. Effective balance stays at 0 (nothing to hold). + (uint256 bal2, uint256 thawing2, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing2, 0, "One above max boundary: OnDemand no thaw"); + // No deposit because min=0 + assertEq(bal2, 0, "OnDemand: no deposit (min=0)"); } - function test_TempJit_TripsEvenWhenAlreadyJustInTime() public { - // Governor explicitly sets JIT - vm.prank(operator); - agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + // ---- Intermediate OnDemand state: between the two thresholds ---- + function test_BasisDegradation_Full_IntermediateOnDemand_NoDepositButHoldsEscrow() public { + // Verify the intermediate state: min=0 (no deposit), max=smnc (holds ceiling) IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1103,22 +1085,29 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); - // Drain SAM so beforeCollection can't cover - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + // Fund to middle of OnDemand band: 0.5x < spare < 1.0625x + // Use spare = 0.75x (halfway in the band) + uint256 midSpare = (smnca * 3) / 4; + assertTrue(midSpare > (smnca * 128) / 256, "midSpare above max gate"); + assertTrue(midSpare <= (smnca * (256 + 16)) / 256, "midSpare below min gate"); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); + _fundToSpare(midSpare); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertTrue(agreementManager.isTempJit(), "Trips even in JIT mode"); + // Escrow was deposited during offerAgreement (when SAM had 1M ether). + // OnDemand: max=smnc so holds (no thaw), min=0 so no new deposit. + uint256 effective = _effectiveEscrow(address(recurringCollector), indexer); + assertEq(effective, pairSmnc, "OnDemand: holds pre-existing escrow at ceiling"); + (, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, 0, "OnDemand: no thaw"); } - function test_TempJit_JitStillWorksWhileActive() public { + function test_BasisDegradation_Full_IntermediateOnDemand_NoDepositFromZero() public { + // Start with zero escrow in OnDemand band -- verify no deposit happens IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1126,134 +1115,187 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - - // Drain SAM to trip the breaker - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } - - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - // Now fund SAM and do a JIT top-up while temp JIT is active - token.mint(address(agreementManager), 500 ether); + // Drain to JIT, complete thaw to clear escrow + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "Escrow cleared"); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 500 ether); + // Fund to OnDemand band + _fundToSpare((smnca * 3) / 4); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer + // OnDemand: min=0 -> no deposit from zero. max=smnc but nothing to hold. + assertEq( + _effectiveEscrow(address(recurringCollector), indexer), + 0, + "OnDemand: no deposit when starting from zero" ); - uint256 maxClaim = 1 ether * 3600 + 100 ether; - assertTrue(maxClaim <= escrowBalance, "JIT still works during temp JIT"); } - function test_TempJit_RecoveryOnUpdateEscrow() public { - // Offer rca1 (fully deposited), drain SAM, offer rca2 (creates undeposited deficit) - IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + // ---- OnDemand basis: max gate only (min always 0) ---- + + function test_BasisDegradation_OnDemand_MaxGatePass_HoldsAtCeiling() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca1); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + // OnDemand: only max gate matters (min is always 0 because basis != Full) + // max gate: smnca * threshold/256 < spare + _fundToSpare((smnca * 128) / 256 + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + (, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, 0, "OnDemand: no thaw when max gate passes"); + } + + function test_BasisDegradation_OnDemand_MaxGateFail_ThawsAll() public { + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, - 2 + 1 ); - vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - // Trip temp JIT - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + // Max gate fails -> max=0 -> thaw everything + _fundToSpare((smnca * 128) / 256); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // Mint more than totalEscrowDeficit — recovery requires strict deficit < available - uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); - assertTrue(0 < totalEscrowDeficit, "Deficit exists"); - token.mint(address(agreementManager), totalEscrowDeficit + 1); + (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, bal, "OnDemand degraded: all thawing"); + } - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(false, true); + function test_BasisDegradation_OnDemand_MinGateIrrelevant() public { + // Even with generous spare (above min gate), OnDemand never deposits + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + + // Drain to zero, complete thaw + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + // Fund well above both gates + _fundToSpare(smnca * 2); agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertFalse(agreementManager.isTempJit(), "Temp JIT recovered"); + // OnDemand: min=0 always (basis != Full), so no deposit from zero assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.Full), - "Basis still Full" + _effectiveEscrow(address(recurringCollector), indexer), + 0, + "OnDemand: no deposit regardless of spare (min always 0)" ); } - function test_TempJit_NoRecoveryWhenPartiallyFunded() public { - // Offer rca1 (fully deposited), drain, offer rca2 (undeposited — creates deficit) - IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + // ---- Zero spare ---- + + function test_BasisDegradation_ZeroSpare_DegradesToJIT() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca1); + _offerAgreement(rca); - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + _drainSAM(); + assertEq(token.balanceOf(address(agreementManager)), 0, "SAM drained"); - IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, bal, "JIT: thaws all when spare=0"); + } + + // ---- Recovery ---- + + function test_BasisDegradation_Recovery_JITToOnDemand() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, - 2 + 1 ); - vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - // Trip - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + // Drain to JIT, complete thaw + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "JIT: zero escrow"); - uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); - assertTrue(0 < totalEscrowDeficit, "0 < totalEscrowDeficit"); + // Fund to OnDemand band (above max gate, below min gate) + _fundToSpare((smnca * 128) / 256 + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // Mint less than totalEscrowDeficit — no recovery - token.mint(address(agreementManager), totalEscrowDeficit / 2); + // OnDemand: min=0 so no deposit, max=smnc but nothing to hold + assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "OnDemand recovery: no deposit (min=0)"); + (, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, 0, "OnDemand recovery: no thaw"); + } + function test_BasisDegradation_Recovery_JITToFull() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); + + // Drain to JIT, complete thaw + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + vm.warp(block.timestamp + 2 days); agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertTrue(agreementManager.isTempJit(), "Still tripped (insufficient balance)"); - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.Full), - "Basis unchanged" - ); + // Fund above min gate -> Full + _fundToSpare((smnca * (256 + 16)) / 256 + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "Full: recovered and deposited"); } - function test_TempJit_NoRecoveryWhenExactlyFunded() public { - // Boundary: available == totalEscrowDeficit — strict '<' means no recovery + // ---- Multi-provider: global degradation ---- + + function test_BasisDegradation_MultiProvider_BothDegraded() public { IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( indexer, 100 ether, @@ -1261,16 +1303,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca1); + _offerAgreement(rca1); - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + _drainSAM(); IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( - indexer, + indexer2, 100 ether, 1 ether, 3600, @@ -1279,105 +1317,112 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS vm.prank(operator); agreementManager.offerAgreement(rca2, _collector()); - // Trip - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); - - // Mint exactly totalEscrowDeficit — recovery requires strict deficit < available - uint256 totalEscrowDeficit = agreementManager.getTotalEscrowDeficit(); - assertTrue(0 < totalEscrowDeficit, "Deficit exists"); - token.mint(address(agreementManager), totalEscrowDeficit); - assertEq(token.balanceOf(address(agreementManager)), totalEscrowDeficit, "Balance == deficit"); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); - assertTrue(agreementManager.isTempJit(), "Still tripped (available == deficit, not >)"); - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.Full), - "Basis unchanged" - ); - } + (uint256 bal1, uint256 thawing1, ) = _escrowAccount(address(recurringCollector), indexer); + (uint256 bal2, uint256 thawing2, ) = _escrowAccount(address(recurringCollector), indexer2); - function test_TempJit_EscrowBasisPreservedDuringTrip() public { - // Set OnDemand, trip, recover — escrowBasis stays OnDemand throughout - vm.prank(operator); - agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + assertEq(thawing1, bal1, "indexer: degraded thaws all"); + assertEq(thawing2, bal2, "indexer2: degraded thaws all"); + } - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + function test_BasisDegradation_MultiProvider_RecoveryRestoresBoth() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); - - // Drain and trip - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } - - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + _offerAgreement(rca1); - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), - "Basis preserved during trip" + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 50 ether, + 2 ether, + 1800, + 2 ); + _offerAgreement(rca2); - // Recovery — mint more than deficit (recovery requires strict deficit < available) - token.mint(address(agreementManager), agreementManager.getSumMaxNextClaimAll() + 1); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc1 = agreementManager.getSumMaxNextClaim(_collector(), indexer); + uint256 pairSmnc2 = agreementManager.getSumMaxNextClaim(_collector(), indexer2); - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(false, true); + // Drain and degrade + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + + // Complete thaws + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + // Fund above min gate -> both recover to Full + _fundToSpare((smnca * (256 + 16)) / 256 + 1); agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertFalse(agreementManager.isTempJit()); - assertEq( - uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), - "Basis still OnDemand after recovery" - ); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + + assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc1, "indexer: recovered to Full"); + assertEq(_effectiveEscrow(address(recurringCollector), indexer2), pairSmnc2, "indexer2: recovered to Full"); } - function test_TempJit_SetTempJitClearsBreaker() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + // ---- offerAgreement can trigger instant degradation ---- + + function test_BasisDegradation_OfferAgreement_TriggersInstantDegradation() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); + _offerAgreement(rca1); + uint256 pairSmnc1 = agreementManager.getSumMaxNextClaim(_collector(), indexer); - // Drain and trip - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + assertEq( + _effectiveEscrow(address(recurringCollector), indexer), + pairSmnc1, + "indexer: initially fully escrowed" + ); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + // Fund to just above min gate for current smnca + _drainSAM(); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 deficit = agreementManager.getTotalEscrowDeficit(); + token.mint(address(agreementManager), deficit + (smnca * (256 + 16)) / 256 + 1); - // Operator clears tempJit directly - vm.expectEmit(address(agreementManager)); - emit IRecurringEscrowManagement.TempJitSet(false, false); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertEq( + _effectiveEscrow(address(recurringCollector), indexer), + pairSmnc1, + "indexer: still Full after careful funding" + ); + // Offer large new agreement -- increases smnca, pushing spare below min gate + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 500 ether, + 10 ether, + 7200, + 2 + ); vm.prank(operator); - agreementManager.setTempJit(false); + agreementManager.offerAgreement(rca2, _collector()); - assertFalse(agreementManager.isTempJit(), "Operator cleared breaker"); + // Reconcile indexer -- existing provider's escrow now degraded + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // New smnca much larger, spare likely below max gate too -> JIT-like + (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, bal, "indexer: degraded after new offer increased smnca"); } - function test_TempJit_SetEscrowBasisDoesNotClearBreaker() public { + // ---- Stored escrowBasis never changes automatically ---- + + function test_BasisDegradation_StoredBasisUnchanged() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -1385,159 +1430,199 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 3600, 1 ); - bytes16 agreementId = _offerAgreement(rca); + _offerAgreement(rca); - // Drain and trip - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis: Full before degradation" + ); - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + _drainSAM(); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // Operator changes basis — tempJit stays active - vm.prank(operator); - agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + assertEq( + uint256(agreementManager.getEscrowBasis()), + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis: still Full after degradation" + ); + + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + vm.warp(block.timestamp + 2 days); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + _fundToSpare((smnca * (256 + 16)) / 256 + 1); + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertTrue(agreementManager.isTempJit(), "setEscrowBasis does not clear tempJit"); assertEq( uint256(agreementManager.getEscrowBasis()), - uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand), - "Basis changed independently" + uint256(IRecurringEscrowManagement.EscrowBasis.Full), + "Basis: still Full after recovery" ); } - function test_TempJit_MultipleTripRecoverCycles() public { - // Offer rca1 (deposited), drain SAM, offer rca2 (undeposited — creates deficit) - IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( - indexer, - 100 ether, - 1 ether, - 3600, - 1 - ); - bytes16 agreementId = _offerAgreement(rca1); + // ---- Edge case: no agreements (smnca = 0) ---- - uint256 samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + function test_BasisDegradation_NoAgreements_NoRevert() public { + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "No agreements: zero escrow"); + } - IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + // ---- Custom params ---- + + function test_BasisDegradation_CustomMargin_WiderOnDemandBand() public { + // Increase margin to 128 -> min gate threshold = smnca * 384/256 = 1.5x + // OnDemand band becomes 0.5x < spare <= 1.5x (much wider) + vm.prank(operator); + agreementManager.setMinFullBasisMargin(128); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, - 2 + 1 ); - vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); - uint256 undeposited = agreementManager.getTotalEscrowDeficit(); - assertTrue(0 < undeposited, "Has undeposited deficit"); + // spare = smnca * 1.2 -- above max gate (0.5) but below min gate (1.5) + _fundToSpare((smnca * 307) / 256); // ~1.2x + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // --- Cycle 1: Trip --- - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + // OnDemand: holds pre-deposited escrow (max=smnc), no deposit (min=0) + assertEq( + _effectiveEscrow(address(recurringCollector), indexer), + pairSmnc, + "OnDemand with wide band: holds at ceiling" + ); - // --- Cycle 1: Recover (mint more than deficit — recovery requires strict deficit < available) --- - token.mint(address(agreementManager), undeposited + 1); + // Fund above 1.5x -> Full + _fundToSpare((smnca * (256 + 128)) / 256 + 1); agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertFalse(agreementManager.isTempJit()); - assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); - // After recovery, reconcileCollectorProvider deposited into escrow. Drain again and create new deficit. - samBalance = token.balanceOf(address(agreementManager)); - if (0 < samBalance) { - vm.prank(address(agreementManager)); - token.transfer(address(1), samBalance); - } + assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "Full with wide band: deposited"); + } + + function test_BasisDegradation_CustomThreshold_HigherMaxGate() public { + // Increase threshold to 200 -> max gate threshold = smnca * 200/256 ~ 0.78x + vm.prank(operator); + agreementManager.setMinOnDemandBasisThreshold(200); - IRecurringCollector.RecurringCollectionAgreement memory rca3 = _makeRCAForIndexer( + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, - 3 + 1 ); - vm.prank(operator); - agreementManager.offerAgreement(rca3, _collector()); + _offerAgreement(rca); + uint256 smnca = agreementManager.getSumMaxNextClaimAll(); - undeposited = agreementManager.getTotalEscrowDeficit(); - assertTrue(0 < undeposited, "New undeposited deficit"); + // spare = smnca * 0.6 -- below new max gate (0.78) -> JIT-like + _fundToSpare((smnca * 154) / 256); // ~0.6x + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - // --- Cycle 2: Trip --- - vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(agreementId, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); + (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing, bal, "JIT with higher threshold: thaws all at 0.6x"); - // --- Cycle 2: Recover (mint more than deficit) --- - token.mint(address(agreementManager), undeposited + 1); + // spare = smnca * 0.85 -- above new max gate (0.78) -> OnDemand + vm.warp(block.timestamp + 2 days); agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - assertFalse(agreementManager.isTempJit()); - assertEq(uint256(agreementManager.getEscrowBasis()), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); + _fundToSpare((smnca * 218) / 256); // ~0.85x + agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + + // OnDemand: no deposit (min=0), no thaw (max=smnc) + (uint256 bal2, uint256 thawing2, ) = _escrowAccount(address(recurringCollector), indexer); + assertEq(thawing2, 0, "OnDemand with higher threshold: no thaw at 0.85x"); + assertEq(bal2, 0, "OnDemand with higher threshold: no deposit (min=0, escrow cleared)"); } - function test_TempJit_MultiProvider() public { - // Offer rca1 (deposited), drain SAM, offer rca2 (creates deficit → 0 < totalEscrowDeficit) - IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + function test_BeforeCollection_JitTopUpStillWorks_WhenDegraded() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, 1 ether, 3600, 1 ); - bytes16 id1 = _offerAgreement(rca1); + bytes16 agreementId = _offerAgreement(rca); - // Drain SAM so rca2 can't be deposited + // Drain SAM uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); token.transfer(address(1), samBalance); } - // Offer rca2 directly (no mint) — escrow stays undeposited, creates deficit - IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( - indexer2, - 100 ether, - 1 ether, - 3600, - 2 - ); - vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); - assertTrue(0 < agreementManager.getTotalEscrowDeficit(), "should have undeposited escrow"); + // Mint just enough for JIT top-up + token.mint(address(agreementManager), 500 ether); - // Trip via indexer's agreement vm.prank(address(recurringCollector)); - agreementManager.beforeCollection(id1, 1_000_000 ether); - assertTrue(agreementManager.isTempJit()); - - // Both providers should see JIT behavior (thaw everything) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.beforeCollection(agreementId, 500 ether); - IPaymentsEscrow.EscrowAccount memory acc1; - (acc1.balance, acc1.tokensThawing, acc1.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + // JIT top-up should have succeeded + IPaymentsEscrow.EscrowAccount memory acc; + (acc.balance, acc.tokensThawing, acc.thawEndTimestamp) = paymentsEscrow.escrowAccounts( address(agreementManager), address(recurringCollector), indexer ); - IPaymentsEscrow.EscrowAccount memory acc2; - (acc2.balance, acc2.tokensThawing, acc2.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer2 - ); + assertTrue(500 ether <= acc.balance, "JIT top-up works when degraded"); + } + + // ==================== Setters ==================== + + function test_SetMinOnDemandBasisThreshold() public { + assertEq(agreementManager.getMinOnDemandBasisThreshold(), 128, "Default threshold"); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.MinOnDemandBasisThresholdSet(128, 64); - // Both providers should be thawing (JIT mode via temp JIT) - assertEq(acc1.tokensThawing, acc1.balance, "indexer: JIT thaws all"); - assertEq(acc2.tokensThawing, acc2.balance, "indexer2: JIT thaws all"); + vm.prank(operator); + agreementManager.setMinOnDemandBasisThreshold(64); + + assertEq(agreementManager.getMinOnDemandBasisThreshold(), 64, "Updated threshold"); + } + + function test_SetMinOnDemandBasisThreshold_NoopWhenSame() public { + vm.recordLogs(); + vm.prank(operator); + agreementManager.setMinOnDemandBasisThreshold(128); // same as default + + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue( + logs[i].topics[0] != IRecurringEscrowManagement.MinOnDemandBasisThresholdSet.selector, + "Should not emit when unchanged" + ); + } + } + + function test_SetMinFullBasisMargin() public { + assertEq(agreementManager.getMinFullBasisMargin(), 16, "Default margin"); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.MinFullBasisMarginSet(16, 32); + + vm.prank(operator); + agreementManager.setMinFullBasisMargin(32); + + assertEq(agreementManager.getMinFullBasisMargin(), 32, "Updated margin"); + } + + function test_SetMinFullBasisMargin_NoopWhenSame() public { + vm.recordLogs(); + vm.prank(operator); + agreementManager.setMinFullBasisMargin(16); // same as default + + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue( + logs[i].topics[0] != IRecurringEscrowManagement.MinFullBasisMarginSet.selector, + "Should not emit when unchanged" + ); + } } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol index 26912be11..8ad42ba34 100644 --- a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; @@ -67,14 +66,17 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes indexer ); - // In Full mode (default): - // If totalEscrowDeficit < available: Full deposits required (there is buffer). - // Otherwise (available <= totalEscrowDeficit): degrades to OnDemand (no buffer, deposit target = 0). - // JIT beforeCollection is the safety net for underfunded escrow. - if (maxNextClaim < availableTokens) { + // In Full mode (default), basis degrades based on spare = balance - totalEscrowDeficit. + // Before deposit: deficit = maxNextClaim, smnca = maxNextClaim. + // spare = availableTokens - maxNextClaim (if availableTokens > maxNextClaim, else 0). + // Full requires smnca * (256+16)/256 = maxNextClaim * 272/256 < spare. + // OnDemand requires smnca * 128/256 = maxNextClaim/2 < spare (but min=0, so no deposit). + // So Full deposits only when availableTokens > maxNextClaim + maxNextClaim * 272/256. + uint256 fullThreshold = maxNextClaim + (maxNextClaim * 272) / 256; + if (fullThreshold < availableTokens) { assertEq(escrowBalance, maxNextClaim); } else { - // Degraded to OnDemand: no deposit (no buffer or insufficient) + // Degraded — no deposit (OnDemand/JIT both have min=0) assertEq(escrowBalance, 0); } } diff --git a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol index f957eee9f..ac5e3caa7 100644 --- a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol @@ -64,7 +64,8 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes assertEq(g.totalEscrowDeficit, 0); assertEq(g.totalAgreementCount, 0); assertEq(uint256(g.escrowBasis), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); - assertFalse(g.tempJit); + assertEq(g.minOnDemandBasisThreshold, 128); + assertEq(g.minFullBasisMargin, 16); assertEq(g.collectorCount, 0); } diff --git a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol index f5785dcbd..6b40e5933 100644 --- a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol +++ b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol @@ -145,10 +145,6 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage 1 ); uint256 maxClaim1 = 1 ether * 3600 + 100 ether; - // Fund with surplus so Full mode stays active (deficit < balance required) - token.mint(address(agreementManager), maxClaim1 + 1); - vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); // Offer via collector2 (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector( @@ -160,8 +156,16 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage 2 ); uint256 maxClaim2 = 2 ether * 7200 + 200 ether; - // Fund with surplus so Full mode stays active (deficit < balance required) - token.mint(address(agreementManager), maxClaim2 + 1); + + // Fund generously so Full mode stays active through both offers. + // After both: smnca = maxClaim1 + maxClaim2, deficit = smnca. + // spare = balance - deficit. Full requires smnca * 272 / 256 < spare. + uint256 totalMaxClaim = maxClaim1 + maxClaim2; + token.mint(address(agreementManager), totalMaxClaim + (totalMaxClaim * 272) / 256 + 1); + + vm.prank(operator); + agreementManager.offerAgreement(rca1, _collector()); + vm.prank(operator); agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index 6049ea270..025b32630 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -88,13 +88,14 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; uint256 sumMaxNextClaim = originalMaxClaim + pendingMaxClaim; - // Fund and offer agreement - token.mint(address(agreementManager), sumMaxNextClaim); + // Fund generously so Full mode stays active through both offers. + // After both offers, smnca = sumMaxNextClaim, deficit = sumMaxNextClaim. + // spare = balance - deficit. Full requires spare > smnca * 272 / 256. + token.mint(address(agreementManager), sumMaxNextClaim + (sumMaxNextClaim * 272) / 256 + 1); vm.prank(operator); bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); // Offer update (should fund the deficit) - token.mint(address(agreementManager), pendingMaxClaim); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( agreementId, 200 ether, diff --git a/packages/issuance/test/unit/agreement-manager/register.t.sol b/packages/issuance/test/unit/agreement-manager/register.t.sol index 23e1516a1..e00567a9a 100644 --- a/packages/issuance/test/unit/agreement-manager/register.t.sol +++ b/packages/issuance/test/unit/agreement-manager/register.t.sol @@ -41,8 +41,10 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; - // Fund with surplus so Full mode stays active (deficit < balance required) - token.mint(address(agreementManager), expectedMaxClaim + 1); + // Fund with surplus so Full mode stays active. + // spare = balance - deficit (deficit = expectedMaxClaim before deposit). + // Full requires smnca * (256 + 16) / 256 = expectedMaxClaim * 272 / 256 < spare + token.mint(address(agreementManager), expectedMaxClaim + (expectedMaxClaim * 272) / 256 + 1); vm.prank(operator); agreementManager.offerAgreement(rca, _collector()); diff --git a/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol b/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol deleted file mode 100644 index 85478f82d..000000000 --- a/packages/issuance/test/unit/agreement-manager/staleSnap.t.sol +++ /dev/null @@ -1,270 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; -import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; - -import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; - -/// @notice PoC: stale escrowSnap in _escrowMinMax causes afterCollection to revert, -/// which is silently swallowed by RecurringCollector's try/catch, leaving the snap -/// permanently stale. Manual recovery via reconcileAgreement also reverts. - -contract StaleEscrowSnapTest is RecurringAgreementManagerSharedTest { - /* solhint-disable graph/func-name-mixedcase */ - - address internal indexer2; - - // Agreement parameters: maxNextClaim = 1 ether * 3600 + 100 ether = 3700 ether - uint256 constant MAX_INITIAL = 100 ether; - uint256 constant MAX_ONGOING = 1 ether; - uint32 constant MAX_SEC = 3600; - uint256 constant MAX_NEXT_CLAIM = MAX_ONGOING * MAX_SEC + MAX_INITIAL; // 3700 ether - - function setUp() public override { - super.setUp(); - indexer2 = makeAddr("indexer2"); - } - - /// @notice Helper: create an RCA for a specific provider with a specific nonce - function _makeRCAFor( - address provider, - uint256 nonce - ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) { - rca = IRecurringCollector.RecurringCollectionAgreement({ - deadline: uint64(block.timestamp + 1 hours), - endsAt: uint64(block.timestamp + 365 days), - payer: address(agreementManager), - dataService: dataService, - serviceProvider: provider, - maxInitialTokens: MAX_INITIAL, - maxOngoingTokensPerSecond: MAX_ONGOING, - minSecondsPerCollection: 60, - maxSecondsPerCollection: MAX_SEC, - nonce: nonce, - metadata: "" - }); - agreementId = recurringCollector.generateAgreementId( - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.deadline, - rca.nonce - ); - } - - /// @notice Helper: offer an agreement and fund just enough for Full mode deposit, - /// leaving the RAM with a tiny free balance (DUST) afterward. - uint256 constant DUST = 1 ether; - - function _offerWithTightBalance( - IRecurringCollector.RecurringCollectionAgreement memory rca - ) internal returns (bytes16) { - // Mint maxNextClaim + dust so strict < check passes in _escrowMinMax: - // totalEscrowDeficit (3700) < balanceOf (3701) → true → Full mode - // After deposit of 3700 into escrow, RAM keeps DUST. - token.mint(address(agreementManager), MAX_NEXT_CLAIM + DUST); - vm.prank(operator); - return agreementManager.offerAgreement(rca, _collector()); - } - - /// @notice Helper: simulate a collection by directly draining escrow and updating - /// the collector's agreement state (as would happen in a real collection) - function _simulateCollection( - bytes16 agreementId, - IRecurringCollector.RecurringCollectionAgreement memory rca, - address provider, - uint256 drainAmount, - uint64 acceptedAt, - uint64 lastCollectionAt - ) internal { - // Drain escrow balance (simulates PaymentsEscrow.collect called by RecurringCollector) - (uint256 balBefore, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - provider - ); - paymentsEscrow.setAccount( - address(agreementManager), - address(recurringCollector), - provider, - balBefore - drainAmount, // reduced balance - 0, // no thawing - 0 // no thaw timestamp - ); - - // Update collector state (lastCollectionAt advances, reducing maxNextClaim) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: acceptedAt, - lastCollectionAt: lastCollectionAt, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - } - - // ========================================================================= - // Test 1: afterCollection reverts when escrow is drained and RAM is underfunded - // ========================================================================= - - function test_AfterCollection_RevertsWhenEscrowDrainedAndRAMUnderfunded() public { - // --- Setup: offer agreement, accept it, fund escrow exactly --- - (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); - bytes16 id = _offerWithTightBalance(rca); - assertEq(id, agreementId); - - // Verify escrow is fully funded, RAM has only dust remaining - (uint256 escrowBal, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); - assertEq(escrowBal, MAX_NEXT_CLAIM, "escrow should be fully funded"); - assertEq(token.balanceOf(address(agreementManager)), DUST, "RAM should have only dust"); - - // Mark agreement as accepted on the collector - _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - - // Advance time so collection is valid - vm.warp(block.timestamp + 1 hours); - - // --- Simulate collection draining most of the escrow --- - uint256 drainAmount = 3000 ether; - _simulateCollection( - agreementId, - rca, - indexer, - drainAmount, - uint64(block.timestamp - 1 hours), // acceptedAt - uint64(block.timestamp) // lastCollectionAt = now - ); - - // Verify state: escrow drained, RAM has only dust - (escrowBal, , ) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); - assertEq(escrowBal, MAX_NEXT_CLAIM - drainAmount, "escrow drained by collection"); - assertEq(token.balanceOf(address(agreementManager)), DUST, "RAM has only dust remaining"); - - // Snapshot BEFORE afterCollection - uint256 snapBefore = _getEscrowSnap(indexer); - assertEq(snapBefore, MAX_NEXT_CLAIM, "snap is stale (pre-collection value)"); - - // --- afterCollection reverts internally --- - // _reconcileAgreement will reduce sumMaxNextClaim, but the snap is stale-high - // so _escrowMinMax sees totalEscrowDeficit=0, keeps Full mode, tries to deposit - // to bring escrow back to the new sumMaxNextClaim — but RAM has 0 balance. - // The deposit reverts, which propagates up through afterCollection. - vm.prank(address(recurringCollector)); - vm.expectRevert(); // ERC20 transfer reverts (insufficient balance) - agreementManager.afterCollection(agreementId, drainAmount); - - // Snap is STILL stale because afterCollection reverted - uint256 snapAfter = _getEscrowSnap(indexer); - assertEq(snapAfter, snapBefore, "snap unchanged - afterCollection reverted before _setEscrowSnap"); - } - - // ========================================================================= - // Test 2: self-reinforcing — subsequent afterCollection also reverts - // ========================================================================= - - function test_SelfReinforcing_SubsequentAfterCollectionAlsoReverts() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); - _offerWithTightBalance(rca); - uint64 t0 = uint64(block.timestamp); - _setAgreementAccepted(agreementId, rca, t0); - - // --- First collection at t0 + 1h --- - vm.warp(t0 + 1 hours); - _simulateCollection(agreementId, rca, indexer, 3000 ether, t0, uint64(block.timestamp)); - - vm.prank(address(recurringCollector)); - vm.expectRevert(); - agreementManager.afterCollection(agreementId, 3000 ether); - - // --- Second collection at t0 + 2h --- - vm.warp(t0 + 2 hours); - // Escrow is at 700 after first drain; drain another 200 → 500 - _simulateCollection(agreementId, rca, indexer, 200 ether, t0, uint64(block.timestamp)); - - vm.prank(address(recurringCollector)); - vm.expectRevert(); - agreementManager.afterCollection(agreementId, 200 ether); - - // Snap is STILL the original value from offer time — permanently stale - uint256 snap = _getEscrowSnap(indexer); - assertEq(snap, MAX_NEXT_CLAIM, "snap permanently stale across multiple collections"); - } - - // ========================================================================= - // Test 3: manual reconcileAgreement also reverts (no recovery path) - // ========================================================================= - - function test_ManualReconcile_AlsoReverts() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAFor(indexer, 1); - _offerWithTightBalance(rca); - _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - - vm.warp(block.timestamp + 1 hours); - - // Collection drains escrow - _simulateCollection( - agreementId, - rca, - indexer, - 3000 ether, - uint64(block.timestamp - 1 hours), - uint64(block.timestamp) - ); - - // afterCollection reverts (as shown above) - vm.prank(address(recurringCollector)); - vm.expectRevert(); - agreementManager.afterCollection(agreementId, 3000 ether); - - // Try manual recovery via reconcileAgreement — ALSO reverts - // Same code path: _reconcileAndCleanup -> _reconcileAndUpdateEscrow -> _updateEscrow - // Same stale snap -> same deposit attempt -> same revert - vm.expectRevert(); - agreementManager.reconcileAgreement(agreementId); - - // reconcileCollectorProvider also reverts (same _updateEscrow path) - vm.expectRevert(); - agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); - } - - // ========================================================================= - // Helper: read escrowSnap via the only observable proxy (totalEscrowDeficit) - // Since escrowSnap is internal storage, we infer it from the escrow balance - // returned by getEscrowAccount vs the deficit accounting. - // ========================================================================= - - /// @notice Get the effective escrow snap for a provider by computing what - /// the RAM thinks the balance is based on its deficit accounting. - /// escrowSnap = sumMaxNextClaim - providerDeficit - /// providerDeficit = totalEscrowDeficit (when only one pair exists) - function _getEscrowSnap(address provider) internal view returns (uint256) { - uint256 sumMax = agreementManager.getSumMaxNextClaim(_collector(), provider); - uint256 totalDeficit = agreementManager.getTotalEscrowDeficit(); - // With one pair, totalEscrowDeficit == providerDeficit - // providerDeficit = max(0, sumMaxNextClaim - escrowSnap) - // So escrowSnap = sumMaxNextClaim - providerDeficit (when deficit <= sumMax) - if (totalDeficit > sumMax) return 0; - return sumMax - totalDeficit; - } - - /* solhint-enable graph/func-name-mixedcase */ -} From e1d73c1094f46d484460630129ec8c5db28b9437 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 28 Mar 2026 08:37:18 +0000 Subject: [PATCH 058/157] fix(RAM): refresh escrow snapshot in _updateEscrow (TRST-H-3) --- packages/issuance/audits/PR1301/TRST-H-3.md | 4 ++++ .../contracts/agreement/RecurringAgreementManager.sol | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-H-3.md b/packages/issuance/audits/PR1301/TRST-H-3.md index 617943d91..5fac18493 100644 --- a/packages/issuance/audits/PR1301/TRST-H-3.md +++ b/packages/issuance/audits/PR1301/TRST-H-3.md @@ -22,3 +22,7 @@ Read the fresh escrow balance inside `_escrowMinMax()` when computing the defici ## Team Response TBD + +--- + +Now refreshing the cached `escrowSnap` at the start of `_updateEscrow()` so that `_escrowMinMax()` uses updated `totalEscrowDeficit`. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 3816ee7f7..f35f46aea 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -917,6 +917,14 @@ contract RecurringAgreementManager is function _updateEscrow(RecurringAgreementManagerStorage storage $, address collector, address provider) private { _ensureIncomingDistributionToCurrentBlock($); + // Sync snapshot before decisions: the escrow balance may have changed externally + // (e.g. RecurringCollector.collect drained it before calling afterCollection). + // Without this, totalEscrowDeficit is stale → spare is overstated → basis is inflated + // → deposit attempt for tokens we don't have → revert swallowed by try/catch → snap + // stays permanently stale. Reading the fresh balance here makes the function + // self-correcting regardless of prior callback failures. + _setEscrowSnap($, collector, provider); + IPaymentsEscrow.EscrowAccount memory account = _fetchEscrowAccount(collector, provider); (uint256 min, uint256 max) = _escrowMinMax($, collector, provider); From e1a3c5ade2147b90a8455abaa25c7f40e462a095 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 28 Mar 2026 08:39:07 +0000 Subject: [PATCH 059/157] fix(RAM): add minimum thaw fraction to prevent dust-thaw griefing (TRST-M-1) Added configurable `minThawFraction` (uint8, proportion of 256, default 16 = 6.25%) that skips thaws when the excess above max is below `sumMaxNextClaim * fraction / 256` for the (collector, provider) pair. --- .../agreement/IRecurringAgreements.sol | 7 +++ .../agreement/IRecurringEscrowManagement.sol | 25 ++++++++ packages/issuance/audits/PR1301/TRST-M-1.md | 4 ++ .../agreement/RecurringAgreementManager.sol | 63 ++++++++++++++----- .../unit/agreement-manager/fundingModes.t.sol | 32 ++++++++++ .../unit/agreement-manager/updateEscrow.t.sol | 10 +-- 6 files changed, 121 insertions(+), 20 deletions(-) diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol index b841618bf..2b9c344a4 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol @@ -162,6 +162,13 @@ interface IRecurringAgreements { */ function getMinFullBasisMargin() external view returns (uint8 margin); + /** + * @notice Minimum fraction of sumMaxNextClaim required to initiate an escrow thaw. + * @dev Escrow thaw is not initiated if excess is below sumMaxNextClaim * minThawFraction / 256 for a (collector, provider) pair. + * @return fraction The numerator over 256 + */ + function getMinThawFraction() external view returns (uint8 fraction); + /** * @notice Get the number of collectors with active agreements * @return count The number of tracked collectors diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol index a087062ae..9f193a777 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol @@ -69,6 +69,13 @@ interface IRecurringEscrowManagement { */ event MinFullBasisMarginSet(uint8 oldMargin, uint8 newMargin); + /** + * @notice Emitted when the minimum thaw fraction is changed + * @param oldFraction The previous fraction + * @param newFraction The new fraction + */ + event MinThawFractionSet(uint8 oldFraction, uint8 newFraction); + // solhint-enable gas-indexed-events // -- Functions -- @@ -99,4 +106,22 @@ interface IRecurringEscrowManagement { * @param margin The margin added to 256 for the spare threshold numerator */ function setMinFullBasisMargin(uint8 margin) external; + + /** + * @notice Set the minimum fraction to initiate thawing excess escrow. + * @dev Requires OPERATOR_ROLE. When excess above max for a (collector, provider) pair + * is less than sumMaxNextClaim[collector][provider] * minThawFraction / 256, the thaw + * is skipped. This avoids wasting the thaw timer on negligible amounts and prevents + * micro-deposit griefing where an attacker deposits dust via depositTo() and triggers + * reconciliation to start a tiny thaw that blocks legitimate thaw increases. + * + * WARNING: Setting fraction to 0 disables the dust threshold entirely, allowing any + * excess (including dust amounts) to trigger a thaw. This re-enables the micro-deposit + * griefing vector described above. Setting fraction to very high values (e.g. 255) + * means thaws are almost never triggered (excess must exceed ~99.6% of sumMaxNextClaim), + * which can cause escrow to remain over-funded indefinitely. The default of 16 (~6.25%) + * provides a reasonable balance. Operators should keep this value between 8 and 64. + * @param fraction The numerator over 256 for the dust threshold + */ + function setMinThawFraction(uint8 fraction) external; } diff --git a/packages/issuance/audits/PR1301/TRST-M-1.md b/packages/issuance/audits/PR1301/TRST-M-1.md index 50c1b4c66..6ff77952f 100644 --- a/packages/issuance/audits/PR1301/TRST-M-1.md +++ b/packages/issuance/audits/PR1301/TRST-M-1.md @@ -24,3 +24,7 @@ Add a minimum thaw threshold in `_updateEscrow()`. Amounts below the threshold s ## Team Response TBD + +--- + +Added configurable `minThawFraction` (uint8, proportion of 256, default 16 = 6.25%) that skips thaws when the excess above max is below `sumMaxNextClaim * fraction / 256` for the (collector, provider) pair. An attacker must now donate a meaningful fraction per griefing round, making such an attack both economically unattractive and less effective. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index f35f46aea..63cde5140 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -132,8 +132,8 @@ contract RecurringAgreementManager is /// @notice Number of agreements per (collector, provider) pair mapping(address collector => mapping(address provider => uint256)) pairAgreementCount; /// @notice The issuance allocator that mints GRT to this contract (20 bytes) - /// @dev Packed slot (31/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + - /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1). + /// @dev Packed slot (32/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + + /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1) + minThawFraction (1). /// All read together in _updateEscrow / beforeCollection. IIssuanceAllocationDistribution issuanceAllocator; /// @notice Block number when _ensureIncomingDistributionToCurrentBlock last ran @@ -146,6 +146,10 @@ contract RecurringAgreementManager is /// @notice Margin for Full: sumMaxNextClaimAll * (256 + margin) / 256 < spare. /// Governance-configured. uint8 minFullBasisMargin; + /// @notice Minimum thaw fraction: escrow excess below sumMaxNextClaim * minThawFraction / 256 + /// per (collector, provider) pair is skipped as operationally insignificant. + /// Governance-configured. + uint8 minThawFraction; /// @notice Optional oracle for checking payment eligibility of service providers (20/32 bytes in slot) IProviderEligibility providerEligibilityOracle; } @@ -182,6 +186,7 @@ contract RecurringAgreementManager is $.escrowBasis = EscrowBasis.Full; $.minOnDemandBasisThreshold = 128; $.minFullBasisMargin = 16; + $.minThawFraction = 16; } // -- ERC165 -- @@ -458,6 +463,16 @@ contract RecurringAgreementManager is emit MinFullBasisMarginSet(oldMargin, margin); } + /// @inheritdoc IRecurringEscrowManagement + function setMinThawFraction(uint8 fraction) external onlyRole(OPERATOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if ($.minThawFraction == fraction) return; + + uint8 oldFraction = $.minThawFraction; + $.minThawFraction = fraction; + emit MinThawFractionSet(oldFraction, fraction); + } + // -- IProviderEligibilityManagement -- /// @inheritdoc IProviderEligibilityManagement @@ -558,6 +573,11 @@ contract RecurringAgreementManager is return _getStorage().minFullBasisMargin; } + /// @inheritdoc IRecurringAgreements + function getMinThawFraction() external view returns (uint8) { + return _getStorage().minThawFraction; + } + /// @inheritdoc IRecurringAgreements function getCollectorCount() external view returns (uint256) { return _getStorage().collectors.length(); @@ -930,21 +950,30 @@ contract RecurringAgreementManager is // Defensive: PaymentsEscrow maintains tokensThawing <= balance, guard against external invariant breach uint256 escrowed = account.tokensThawing < account.balance ? account.balance - account.tokensThawing : 0; + // Thaw threshold: ignore thaws below this for two reasons: + // 1. Operational: small excess proportions are not worth thawing; better to wait for a larger rebalance. + // 2. Anti-griefing: an attacker could deposit dust via depositTo(), trigger reconciliation, + // and start a tiny thaw that blocks legitimate thaw increases for the entire thawing period. + uint256 thawThreshold = ($.sumMaxNextClaim[collector][provider] * uint256($.minThawFraction)) / 256; // Objectives in order of priority: // We want to end with escrowed of at least min, and seek to thaw down to no more than max. // 1. Do not reset thaw timer if a thaw is in progress. // (This is to avoid thrash of restarting thaws resulting in never withdrawing excess.) // 2. Make minimal adjustment to thawing tokens to get as close to min/max as possible. // (First cancel unrealised thawing before depositing.) + // 3. Skip thaw if excess above max is below the minimum thaw threshold. + uint256 excess = max < escrowed ? escrowed - max : 0; uint256 thawTarget = (escrowed < min) ? (min < account.balance ? account.balance - min : 0) - : (max < escrowed ? account.balance - max : account.tokensThawing); - if (thawTarget != account.tokensThawing) { + : (max < account.balance ? account.balance - max : 0); + // Act when the target differs, but skip thaw increases below thawThreshold (obj 3). + // Deficit adjustments (escrowed < min) always proceed — the threshold only gates new thaws. + if (thawTarget != account.tokensThawing && (escrowed < min || thawThreshold <= excess)) { PAYMENTS_ESCROW.adjustThaw(collector, provider, thawTarget, false); account = _fetchEscrowAccount(collector, provider); } - _withdrawAndRebalance(collector, provider, account, min, max); + _withdrawAndRebalance(collector, provider, account, min, max, thawThreshold); _setEscrowSnap($, collector, provider); } @@ -958,13 +987,15 @@ contract RecurringAgreementManager is * @param account Current escrow account state * @param min Deposit floor * @param max Thaw ceiling + * @param thawThreshold Thaw threshold — do not initiate a thaw if excess is less than this */ function _withdrawAndRebalance( address collector, address provider, IPaymentsEscrow.EscrowAccount memory account, uint256 min, - uint256 max + uint256 max, + uint256 thawThreshold ) private { // Withdraw any remaining thawed tokens (realised thawing is withdrawn even if within [min, max]) if (0 < account.tokensThawing && account.thawEndTimestamp < block.timestamp) { @@ -975,17 +1006,17 @@ contract RecurringAgreementManager is } if (account.tokensThawing == 0) { - if (max < account.balance) - // Thaw excess above max (might have withdrawn allowing a new thaw to start) - PAYMENTS_ESCROW.adjustThaw(collector, provider, account.balance - max, false); - else { + if (max < account.balance) { + unint256 excess = account.balance - max; + if (thawThreshold <= excess) + // Thaw excess above max (might have withdrawn allowing a new thaw to start) + PAYMENTS_ESCROW.adjustThaw(collector, provider, excess, false); + } else if (account.balance < min) { // Deposit any deficit below min (deposit exactly the missing amount, no more) - uint256 deposit = (min < account.balance) ? 0 : min - account.balance; - if (0 < deposit) { - GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deposit); - PAYMENTS_ESCROW.deposit(collector, provider, deposit); - emit EscrowFunded(provider, collector, deposit); - } + uint256 deficit = min - account.balance; + GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deficit); + PAYMENTS_ESCROW.deposit(collector, provider, deficit); + emit EscrowFunded(provider, collector, deficit); } } } diff --git a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol index 6060af619..9f2889c2a 100644 --- a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol @@ -1625,5 +1625,37 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS } } + function test_SetMinThawFraction() public { + assertEq(agreementManager.getMinThawFraction(), 16, "Default fraction"); + + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.MinThawFractionSet(16, 32); + + vm.prank(operator); + agreementManager.setMinThawFraction(32); + + assertEq(agreementManager.getMinThawFraction(), 32, "Updated fraction"); + } + + function test_SetMinThawFraction_NoopWhenSame() public { + vm.recordLogs(); + vm.prank(operator); + agreementManager.setMinThawFraction(16); // same as default + + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + assertTrue( + logs[i].topics[0] != IRecurringEscrowManagement.MinThawFractionSet.selector, + "Should not emit when unchanged" + ); + } + } + + function test_SetMinThawFraction_Revert_WhenNotOperator() public { + vm.prank(governor); + vm.expectRevert(); + agreementManager.setMinThawFraction(32); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol index 9fb9b6462..e7c19d75a 100644 --- a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol +++ b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol @@ -123,15 +123,16 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS function test_UpdateEscrow_ThawsExcessWithActiveAgreements() public { // Offer agreement, accept, then reconcile down — excess should be thawed + // Use 300 ether initial so excess (300) exceeds dust threshold (3600*16/256 = 225) (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, + 300 ether, 1 ether, 3600, uint64(block.timestamp + 365 days) ); bytes16 agreementId = _offerAgreement(rca); - uint256 maxClaim = 1 ether * 3600 + 100 ether; + uint256 maxClaim = 1 ether * 3600 + 300 ether; // Accept and simulate a collection (reduces maxNextClaim) _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); @@ -595,15 +596,16 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS function test_Reconcile_AutomaticallyThawsExcess() public { // Reconcile calls _updateEscrow, which should thaw excess automatically + // Use 300 ether initial so excess (300) exceeds dust threshold (3600*16/256 = 225) (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, + 300 ether, 1 ether, 3600, uint64(block.timestamp + 365 days) ); bytes16 agreementId = _offerAgreement(rca); - uint256 maxClaim = 1 ether * 3600 + 100 ether; + uint256 maxClaim = 1 ether * 3600 + 300 ether; // Accept and simulate a collection _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); From 56322cc502fdd54c2f94740d29f7ef0f36a29943 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:40:51 +0000 Subject: [PATCH 060/157] feat(RM): add revert control for ineligible indexers Add revertOnIneligible flag to RewardsManager. When true, ineligible indexers cause takeRewards to revert (blocking POI presentation and preserving rewards for future collection). When false (default), ineligible indexers have rewards reclaimed but takeRewards succeeds. --- .../tests/unit/rewards/rewards-config.test.ts | 42 +++++++++ .../rewards-eligibility-oracle.test.ts | 91 +++++++++++++++++++ .../unit/rewards/rewards-interface.test.ts | 2 +- .../contracts/rewards/RewardsManager.sol | 18 ++++ .../rewards/RewardsManagerStorage.sol | 5 + .../contracts/rewards/IRewardsManager.sol | 15 +++ .../test/unit/mocks/MockRewardsManager.sol | 6 ++ 7 files changed, 178 insertions(+), 1 deletion(-) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-config.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-config.test.ts index 3e510e1c1..bd3b2569a 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-config.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-config.test.ts @@ -274,5 +274,47 @@ describe('Rewards - Configuration', () => { expect(await rewardsManager.minimumSubgraphSignal()).eq(newMinimumSignal) }) }) + + describe('revertOnIneligible', function () { + it('should reject setRevertOnIneligible if unauthorized', async function () { + const tx = rewardsManager.connect(indexer1).setRevertOnIneligible(true) + await expect(tx).revertedWith('Only Controller governor') + }) + + it('should set revertOnIneligible to true', async function () { + const tx = rewardsManager.connect(governor).setRevertOnIneligible(true) + await expect(tx).emit(rewardsManager, 'ParameterUpdated').withArgs('revertOnIneligible') + expect(await rewardsManager.getRevertOnIneligible()).eq(true) + }) + + it('should set revertOnIneligible to false', async function () { + // First set to true + await rewardsManager.connect(governor).setRevertOnIneligible(true) + + // Then set back to false + const tx = rewardsManager.connect(governor).setRevertOnIneligible(false) + await expect(tx).emit(rewardsManager, 'ParameterUpdated').withArgs('revertOnIneligible') + expect(await rewardsManager.getRevertOnIneligible()).eq(false) + }) + + it('should be a no-op when setting same value (false to false)', async function () { + // Default is false + expect(await rewardsManager.getRevertOnIneligible()).eq(false) + + const tx = rewardsManager.connect(governor).setRevertOnIneligible(false) + await expect(tx).to.not.emit(rewardsManager, 'ParameterUpdated') + + expect(await rewardsManager.getRevertOnIneligible()).eq(false) + }) + + it('should be a no-op when setting same value (true to true)', async function () { + await rewardsManager.connect(governor).setRevertOnIneligible(true) + + const tx = rewardsManager.connect(governor).setRevertOnIneligible(true) + await expect(tx).to.not.emit(rewardsManager, 'ParameterUpdated') + + expect(await rewardsManager.getRevertOnIneligible()).eq(true) + }) + }) }) }) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts index 4db522378..c2137dc64 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-eligibility-oracle.test.ts @@ -533,6 +533,97 @@ describe('Rewards - Eligibility Oracle', () => { expectApproxEq(event.args[2], expectedIndexingRewards, 'rewards amount') }) + it('should revert for ineligible indexer when revertOnIneligible is true', async function () { + // Setup REO that denies indexer1 + const MockRewardsEligibilityOracleFactory = await hre.ethers.getContractFactory( + 'contracts/tests/MockRewardsEligibilityOracle.sol:MockRewardsEligibilityOracle', + ) + const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny + await mockOracle.deployed() + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) + + // Enable revert on ineligible + await rewardsManager.connect(governor).setRevertOnIneligible(true) + + // Align with the epoch boundary + await helpers.mineEpoch(epochManager) + + // Setup allocation + await setupIndexerAllocation() + + // Jump to next epoch + await helpers.mineEpoch(epochManager) + + // Close allocation - should revert because indexer is ineligible + const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) + await expect(tx).revertedWith('Indexer not eligible for rewards') + }) + + it('should not revert for eligible indexer when revertOnIneligible is true', async function () { + // Setup REO that allows indexer1 + const MockRewardsEligibilityOracleFactory = await hre.ethers.getContractFactory( + 'contracts/tests/MockRewardsEligibilityOracle.sol:MockRewardsEligibilityOracle', + ) + const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(true) // Allow + await mockOracle.deployed() + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) + + // Enable revert on ineligible + await rewardsManager.connect(governor).setRevertOnIneligible(true) + + // Align with the epoch boundary + await helpers.mineEpoch(epochManager) + + // Setup allocation + await setupIndexerAllocation() + + // Jump to next epoch + await helpers.mineEpoch(epochManager) + + // Close allocation - should succeed (indexer is eligible) + const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) + await expect(tx).emit(rewardsManager, 'HorizonRewardsAssigned') + }) + + it('should reclaim (not revert) for ineligible indexer when revertOnIneligible is false', async function () { + // Setup REO that denies indexer1 + const MockRewardsEligibilityOracleFactory = await hre.ethers.getContractFactory( + 'contracts/tests/MockRewardsEligibilityOracle.sol:MockRewardsEligibilityOracle', + ) + const mockOracle = await MockRewardsEligibilityOracleFactory.deploy(false) // Deny + await mockOracle.deployed() + await rewardsManager.connect(governor).setProviderEligibilityOracle(mockOracle.address) + + // Ensure revertOnIneligible is false (default) + expect(await rewardsManager.getRevertOnIneligible()).eq(false) + + // Align with the epoch boundary + await helpers.mineEpoch(epochManager) + + // Setup allocation + await setupIndexerAllocation() + + // Jump to next epoch + await helpers.mineEpoch(epochManager) + + // Close allocation - should succeed but deny rewards + const tx = await staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) + const receipt = await tx.wait() + + // Should emit RewardsDeniedDueToEligibility (not revert) + const rewardsDeniedEvents = receipt.logs + .map((log) => { + try { + return rewardsManager.interface.parseLog(log) + } catch { + return null + } + }) + .filter((event) => event?.name === 'RewardsDeniedDueToEligibility') + + expect(rewardsDeniedEvents.length).to.equal(1, 'RewardsDeniedDueToEligibility event not found') + }) + it('should verify event structure differences between denial mechanisms', async function () { // Test 1: Denylist denial - event WITHOUT amount // Create allocation FIRST, then deny (so there are pre-denial rewards to deny) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts index 3fdd15ee6..63280f5e8 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts @@ -58,7 +58,7 @@ describe('RewardsManager interfaces', () => { }) it('IRewardsManager should have stable interface ID', () => { - expect(IRewardsManager__factory.interfaceId).to.equal('0x7e0447a1') + expect(IRewardsManager__factory.interfaceId).to.equal('0x337b092e') }) }) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 9a9218093..a0ca5ca20 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -265,6 +265,14 @@ contract RewardsManager is } } + /// @inheritdoc IRewardsManager + function setRevertOnIneligible(bool _revertOnIneligible) external override onlyGovernor { + if (revertOnIneligible != _revertOnIneligible) { + revertOnIneligible = _revertOnIneligible; + emit ParameterUpdated("revertOnIneligible"); + } + } + // -- Denylist -- /** @@ -344,6 +352,11 @@ contract RewardsManager is return rewardsEligibilityOracle; } + /// @inheritdoc IRewardsManager + function getRevertOnIneligible() external view override returns (bool) { + return revertOnIneligible; + } + /// @inheritdoc IRewardsManager function getNewRewardsPerSignal() public view override returns (uint256 claimablePerSignal) { (claimablePerSignal, ) = _getNewRewardsPerSignal(); @@ -772,6 +785,11 @@ contract RewardsManager is bool isDeniedSubgraph = isDenied(subgraphDeploymentID); bool isIneligible = address(rewardsEligibilityOracle) != address(0) && !rewardsEligibilityOracle.isEligible(indexer); + + // When configured to revert, block collection so rewards remain claimable if + // the indexer becomes eligible and collects before the allocation goes stale. + require(!isIneligible || !revertOnIneligible, "Indexer not eligible for rewards"); + if (!isDeniedSubgraph && !isIneligible) return false; if (isDeniedSubgraph) emit RewardsDenied(indexer, allocationID); diff --git a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol index 5969d11c6..72a2d3176 100644 --- a/packages/contracts/contracts/rewards/RewardsManagerStorage.sol +++ b/packages/contracts/contracts/rewards/RewardsManagerStorage.sol @@ -117,4 +117,9 @@ abstract contract RewardsManagerV6Storage is RewardsManagerV5Storage { /// @dev Default fallback address for reclaiming rewards when no reason-specific address is configured. /// Zero address means rewards are dropped (not minted) if no specific reclaim address matches. address internal defaultReclaimAddress; + + /// @dev When true, ineligible indexers cause takeRewards to revert (blocking POI presentation + /// and allowing allocations to go stale). When false (default), ineligible indexers have + /// rewards reclaimed but takeRewards succeeds (returning 0). + bool internal revertOnIneligible; } diff --git a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol index 43a13d791..205bde73c 100644 --- a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol @@ -134,6 +134,21 @@ interface IRewardsManager { */ function setDefaultReclaimAddress(address newDefaultReclaimAddress) external; + /** + * @notice Set whether ineligible indexers cause takeRewards to revert + * @dev When true, takeRewards reverts for ineligible indexers, keeping rewards claimable + * if the indexer becomes eligible and collects before the allocation goes stale. + * When false (default), takeRewards succeeds but rewards are reclaimed. + * @param revertOnIneligible True to revert on ineligible, false to reclaim + */ + function setRevertOnIneligible(bool revertOnIneligible) external; + + /** + * @notice Get whether ineligible indexers cause takeRewards to revert + * @return revertOnIneligible True if takeRewards reverts for ineligible indexers + */ + function getRevertOnIneligible() external view returns (bool revertOnIneligible); + // -- Denylist -- /** diff --git a/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol b/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol index b6da3bb75..9326361fb 100644 --- a/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol +++ b/packages/subgraph-service/test/unit/mocks/MockRewardsManager.sol @@ -52,6 +52,12 @@ contract MockRewardsManager is IRewardsManager { function setDefaultReclaimAddress(address) external {} + function setRevertOnIneligible(bool) external {} + + function getRevertOnIneligible() external pure returns (bool) { + return false; + } + function reclaimRewards(bytes32, address _allocationId) external view returns (uint256) { address rewardsIssuer = msg.sender; ( From 3b617b47bc7e7068ee28dabd66101470eafff976 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 28 Mar 2026 13:06:25 +0000 Subject: [PATCH 061/157] docs(audit): acknowledge audit findings (TRST-CR-1/3, L-4, R-1, SR-1/2/3) --- docs/PaymentsTrustModel.md | 2 +- packages/issuance/audits/PR1301/TRST-CR-1.md | 4 ++++ packages/issuance/audits/PR1301/TRST-CR-2.md | 4 ++++ packages/issuance/audits/PR1301/TRST-CR-3.md | 4 ++++ packages/issuance/audits/PR1301/TRST-L-4.md | 4 ++++ packages/issuance/audits/PR1301/TRST-R-1.md | 4 ++++ packages/issuance/audits/PR1301/TRST-R-2.md | 4 ++++ packages/issuance/audits/PR1301/TRST-SR-1.md | 4 ++++ packages/issuance/audits/PR1301/TRST-SR-2.md | 4 ++++ packages/issuance/audits/PR1301/TRST-SR-3.md | 4 ++++ 10 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/PaymentsTrustModel.md b/docs/PaymentsTrustModel.md index a79c5f24e..07bff2468 100644 --- a/docs/PaymentsTrustModel.md +++ b/docs/PaymentsTrustModel.md @@ -68,7 +68,7 @@ RecurringCollector adds payer callbacks when the payer is a contract: <───┘ ``` -- **`isEligible`**: hard `require` — contract payer can block collection for ineligible receivers. Only called when `0 < tokensToCollect`. +- **`isEligible`**: fail-open gate — only an explicit return of `0` blocks collection; call failures (reverts, malformed data) are ignored to prevent a buggy payer from griefing the receiver. Only called when `0 < tokensToCollect`. - **`beforeCollection`**: try-catch — allows payer to top up escrow (RAM uses this for JIT deposits), but cannot block (though a malicious contract payer could consume excessive gas). Only called when `0 < tokensToCollect`. - **`afterCollection`**: try-catch — allows payer to reconcile state post-collection, cannot block (same gas exhaustion caveat). Called even when `tokensToCollect == 0` (zero-token collections still trigger reconciliation). diff --git a/packages/issuance/audits/PR1301/TRST-CR-1.md b/packages/issuance/audits/PR1301/TRST-CR-1.md index 00b8cde4e..65827afaa 100644 --- a/packages/issuance/audits/PR1301/TRST-CR-1.md +++ b/packages/issuance/audits/PR1301/TRST-CR-1.md @@ -13,3 +13,7 @@ The RecurringAgreementManager's `GOVERNOR_ROLE` has broad unilateral authority o - Can pause the entire contract, halting all agreement management A compromised or malicious governor could revoke a data service's role (preventing new agreements), change the issuance allocator to a contract that withholds funds, or set a malicious eligibility oracle that blocks specific providers from collecting. These actions affect all agreements managed by the RAM, not just future ones. + +--- + +Accepted centralization tradeoff. The governor must have these powers for effective protocol operation. Expected to be a multisig or governance contract in production. diff --git a/packages/issuance/audits/PR1301/TRST-CR-2.md b/packages/issuance/audits/PR1301/TRST-CR-2.md index 1e512fbac..3331459bb 100644 --- a/packages/issuance/audits/PR1301/TRST-CR-2.md +++ b/packages/issuance/audits/PR1301/TRST-CR-2.md @@ -11,3 +11,7 @@ The `OPERATOR_ROLE` (admin of `AGREEMENT_MANAGER_ROLE`) controls the operational - Can set `tempJit`, overriding the escrow mode to JIT for all pairs An operator switching from Full to JIT mode instantly removes proactive escrow guarantees for all providers. Providers who accepted agreements under the assumption of Full escrow backing may find their payment security degraded without notice or consent. The escrow mode change is a storage write with no timelock or multi-sig requirement. + +--- + +Accepted. The operator is a trusted role managing agreement lifecycle and escrow parameters on behalf of the protocol. Escrow parameter changes are visible on-chain via events. diff --git a/packages/issuance/audits/PR1301/TRST-CR-3.md b/packages/issuance/audits/PR1301/TRST-CR-3.md index 797710020..42097257c 100644 --- a/packages/issuance/audits/PR1301/TRST-CR-3.md +++ b/packages/issuance/audits/PR1301/TRST-CR-3.md @@ -9,3 +9,7 @@ The RecurringAgreementManager is a single contract instance that manages escrow This means operational decisions or issues affecting one pair can cascade to all others. For example, a single large agreement that becomes insolvent increases `totalEscrowDeficit`, potentially degrading the escrow mode from Full to OnDemand for every other pair. Similarly, a stale snapshot on one pair (TRST-H-3) affects the global deficit calculation. There is no isolation between pairs beyond the per-pair `sumMaxNextClaim` tracking. The RAM does not support per-pair escrow mode configuration or per-pair balance ringfencing. + +--- + +Accepted design tradeoff. The shared pool optimizes capital efficiency — per-pair isolation would significantly increase complexity, gas costs, and operational overhead. The snap-refresh fix (TRST-H-3) and minThawFraction (TRST-M-1) reduce cascading effects. diff --git a/packages/issuance/audits/PR1301/TRST-L-4.md b/packages/issuance/audits/PR1301/TRST-L-4.md index 66f7eccf1..71ea33109 100644 --- a/packages/issuance/audits/PR1301/TRST-L-4.md +++ b/packages/issuance/audits/PR1301/TRST-L-4.md @@ -20,3 +20,7 @@ In `_reconcilePairTracking()`, base the removal decision on `pairAgreementCount` ## Team Response TBD + +--- + +Accepted limitation. Orphaned tracking entries do not affect correctness or funds safety. The proposed fix (removing pairs regardless of escrow balance) would sacrifice discoverability of unreclaimed escrow. Residual balances are handled through offline reconciliation. diff --git a/packages/issuance/audits/PR1301/TRST-R-1.md b/packages/issuance/audits/PR1301/TRST-R-1.md index 7670076e2..5f1457f71 100644 --- a/packages/issuance/audits/PR1301/TRST-R-1.md +++ b/packages/issuance/audits/PR1301/TRST-R-1.md @@ -5,3 +5,7 @@ ## Description The modified RewardsEligibilityOracle has two new state variables, as well as moving `eligibilityValidationEnabled` from the original slot to the end of the structure. Due to the relocation, an upgrade is needed, meaning all previous eligibility state will be lost. It is possible to only append storage slots to the original structure, and avoid a hard redeployment flow, by leveraging the upgradeability of the oracle. + +--- + +Acknowledged. The oracle is not yet deployed to production so the storage restructuring does not lose live state. The current layout preserves clean append-only expansion for future upgrades. diff --git a/packages/issuance/audits/PR1301/TRST-R-2.md b/packages/issuance/audits/PR1301/TRST-R-2.md index 0fd0b7767..a9a30ff54 100644 --- a/packages/issuance/audits/PR1301/TRST-R-2.md +++ b/packages/issuance/audits/PR1301/TRST-R-2.md @@ -8,3 +8,7 @@ The functions below are mentioned in various documentation files but do not exis - `acceptUnsignedIndexingAgreement()` - `removeAgreement()` + +--- + +Updated documentation to remove references to `acceptUnsignedIndexingAgreement()` and `removeAgreement()`. diff --git a/packages/issuance/audits/PR1301/TRST-SR-1.md b/packages/issuance/audits/PR1301/TRST-SR-1.md index 092746b7b..1902b2ffd 100644 --- a/packages/issuance/audits/PR1301/TRST-SR-1.md +++ b/packages/issuance/audits/PR1301/TRST-SR-1.md @@ -9,3 +9,7 @@ When the RecurringAgreementManager operates in JustInTime (JIT) escrow mode, esc If the RAM's balance is sufficient to cover any single collection but not all concurrent collections, the provider whose data service submits the `collect()` transaction first will succeed, while subsequent providers' collections will revert because the RAM's balance has been depleted by the first collection's JIT deposit. This creates a first-come-first-served dynamic where providers must compete on transaction ordering to receive payment. This race condition is inherent to the JIT mode design and cannot be fully eliminated without proactive escrow funding. In extreme cases, a well-resourced provider could use priority gas auctions or private mempools to consistently front-run other providers' collections, creating an unfair payment advantage unrelated to service quality. + +--- + +Known architectural tradeoff. Full mode eliminates this entirely; OnDemand reduces its likelihood. JIT provides best-effort payment guarantees and is the fallback when the RAM's balance cannot sustain proactive escrow funding. diff --git a/packages/issuance/audits/PR1301/TRST-SR-2.md b/packages/issuance/audits/PR1301/TRST-SR-2.md index 7089956f7..5ad078675 100644 --- a/packages/issuance/audits/PR1301/TRST-SR-2.md +++ b/packages/issuance/audits/PR1301/TRST-SR-2.md @@ -9,3 +9,7 @@ The PaymentsEscrow thawing period (configurable up to `MAX_WAIT_PERIOD`, 90 days If multiple agreements end in a short period or the escrow mode degrades from Full to OnDemand, the RAM may enter a state where substantial funds are locked in thawing and unavailable for either existing or new obligations. This is compounded by the micro-thaw griefing vector (TRST-M-1), which can extend the immobility period by blocking thaw increases. The thawing period is a protocol-level parameter set on PaymentsEscrow and is outside the RAM's control. Changes to this parameter affect all users of the escrow system, not just the RAM. + +--- + +The thawing period protects providers from instant escrow drainage after service delivery. The minThawFraction fix (TRST-M-1) reduces griefing amplification and the snap-refresh fix (TRST-H-3) ensures accurate deficit tracking during rebalancing. The fundamental constraint is a protocol-level design decision outside the RAM's scope. diff --git a/packages/issuance/audits/PR1301/TRST-SR-3.md b/packages/issuance/audits/PR1301/TRST-SR-3.md index 531a71ab6..91a3a71fc 100644 --- a/packages/issuance/audits/PR1301/TRST-SR-3.md +++ b/packages/issuance/audits/PR1301/TRST-SR-3.md @@ -9,3 +9,7 @@ The RAM relies on periodic issuance distribution (via the issuance allocator) to Once the free balance reaches zero, the RAM cannot fund JIT top-ups in `beforeCollection()`, cannot proactively deposit in Full mode for new agreements, and existing escrow accounts gradually drain with each collection. Prolonged issuance interruption could cascade into escrow mode degradation (Full -> OnDemand -> JIT), ultimately affecting all providers' payment reliability. This is an external dependency that the RAM admin cannot mitigate beyond maintaining a buffer balance. + +--- + +Acknowledged. The RAM maintains a buffer balance and the escrow degradation mechanism (Full → OnDemand → JIT) provides graceful fallback. Issuance interruptions are visible on-chain, allowing operators to respond before provider payments are affected. From df93851fb5e2d14eb7f378c3d0c7f92461b7d867 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 30 Mar 2026 07:23:44 +0000 Subject: [PATCH 062/157] feat: resize allocations to zero instead of force-closing Over-allocated and stale allocations are now resized to zero tokens instead of being force-closed. This keeps the allocation open so that any bound indexing agreement remains active. The allocation stays as a stakeless (altruistic) allocation rather than being deleted. Changes: - AllocationHandler.presentPOI: call _resizeAllocation(0) instead of _closeAllocation when over-allocated - SubgraphService.closeStaleAllocation: resize to zero instead of _onCloseAllocation + _closeAllocation - SubgraphService._collectIndexingRewards: remove _onCloseAllocation call after over-allocation (allocation stays open) - Extract _resizeAllocation internal helper from resizeAllocation --- .../subgraph-service/ISubgraphService.sol | 15 +++-- .../contracts/SubgraphService.sol | 11 +--- .../contracts/libraries/AllocationHandler.sol | 56 +++++++++++++++++-- .../contracts/utilities/AllocationManager.sol | 2 +- .../subgraphService/SubgraphService.t.sol | 36 +++++------- .../indexing-agreement/collect.t.sol | 19 ++----- .../indexing-agreement/integration.t.sol | 14 +++-- 7 files changed, 95 insertions(+), 58 deletions(-) diff --git a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol index be0bf05d2..050dfe1f3 100644 --- a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol +++ b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol @@ -142,13 +142,13 @@ interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { error SubgraphServiceInvalidRAV(address ravIndexer, address allocationIndexer); /** - * @notice Thrown when trying to force close an allocation that is not stale and the indexer is not over-allocated + * @notice Thrown when trying to resize a stale allocation but it is not stale * @param allocationId The id of the allocation */ error SubgraphServiceCannotForceCloseAllocation(address allocationId); /** - * @notice Thrown when trying to force close an altruistic allocation + * @notice Thrown when trying to resize a stale allocation that is already altruistic (0 tokens) * @param allocationId The id of the allocation */ error SubgraphServiceAllocationIsAltruistic(address allocationId); @@ -181,16 +181,21 @@ interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { ) external; /** - * @notice Force close a stale allocation + * @notice Resize a stale allocation to zero tokens * @dev This function can be permissionlessly called when the allocation is stale. This * ensures that rewards for other allocations are not diluted by an inactive allocation. * + * The allocation stays open as a stakeless allocation (0 tokens) rather than being closed. + * Allocations are long-lived and track agreement bindings, so force-closing would + * inadvertently cancel the associated agreement. Any bound indexing agreement remains + * active. + * * Requirements: * - Allocation must exist and be open * - Allocation must be stale - * - Allocation cannot be altruistic + * - Allocation cannot already be stakeless * - * Emits a {AllocationClosed} event. + * Emits a {AllocationResized} event. * * @param allocationId The id of the allocation */ diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index b0b4b5944..7f7b81e03 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -210,7 +210,7 @@ contract SubgraphService is * @notice Close an allocation, indicating that the indexer has stopped indexing the subgraph deployment * @dev This is the equivalent of the `closeAllocation` function in the legacy Staking contract. * There are a few notable differences with the legacy function: - * - allocations are nowlong lived. All service payments, including indexing rewards, should be collected periodically + * - allocations are now long lived. All service payments, including indexing rewards, should be collected periodically * without the need of closing the allocation. Allocations should only be closed when indexers want to reclaim the allocated * tokens for other purposes. * - No POI is required to close an allocation. Indexers should present POIs to collect indexing rewards using {collect}. @@ -315,8 +315,7 @@ contract SubgraphService is IAllocation.State memory allocation = _allocations.get(allocationId); require(allocation.isStale(maxPOIStaleness), SubgraphServiceCannotForceCloseAllocation(allocationId)); require(!allocation.isAltruistic(), SubgraphServiceAllocationIsAltruistic(allocationId)); - _onCloseAllocation(allocationId, true); - _closeAllocation(allocationId, true); + _resizeAllocation(allocationId, 0, _delegationRatio); } /// @inheritdoc ISubgraphService @@ -722,7 +721,7 @@ contract SubgraphService is (address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(_data, (address, bytes32, bytes)); _checkAllocationOwnership(_indexer, allocationId); - (uint256 paymentCollected, bool allocationForceClosed) = _presentPoi( + (uint256 paymentCollected, ) = _presentPoi( allocationId, poi_, poiMetadata_, @@ -730,10 +729,6 @@ contract SubgraphService is paymentsDestination[_indexer] ); - if (allocationForceClosed) { - _onCloseAllocation(allocationId, true); - } - return paymentCollected; } diff --git a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol index 0519b3e3f..d7552718f 100644 --- a/packages/subgraph-service/contracts/libraries/AllocationHandler.sol +++ b/packages/subgraph-service/contracts/libraries/AllocationHandler.sol @@ -317,14 +317,14 @@ library AllocationHandler { * @param _subgraphAllocatedTokens The mapping of subgraph deployment ids to their allocated tokens * @param params The parameters for the POI presentation * @return rewardsCollected The amount of tokens collected - * @return allocationForceClosed True if the allocation was automatically closed due to over-allocation, false otherwise + * @return allocationDownsized True if the allocation was automatically resized down due to over-allocation, false otherwise */ function presentPOI( mapping(address allocationId => IAllocation.State allocation) storage _allocations, mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, PresentParams calldata params - ) external returns (uint256 rewardsCollected, bool allocationForceClosed) { + ) external returns (uint256 rewardsCollected, bool allocationDownsized) { IAllocation.State memory allocation = _allocations.get(params._allocationId); require(allocation.isOpen(), AllocationHandler.AllocationHandlerAllocationClosed(params._allocationId)); _allocations.presentPOI(params._allocationId); // Always record POI presentation to prevent staleness @@ -392,7 +392,7 @@ library AllocationHandler { ); } - // Check if the indexer is over-allocated and force close the allocation if necessary + // Check if the indexer is over-allocated and resize the allocation to zero if necessary if ( _isOverAllocated( allocationProvisionTracker, @@ -401,14 +401,18 @@ library AllocationHandler { params._delegationRatio ) ) { - allocationForceClosed = true; - _closeAllocation( + allocationDownsized = true; + _resizeAllocation( _allocations, allocationProvisionTracker, _subgraphAllocatedTokens, + params.graphStaking, params.graphRewardsManager, params._allocationId, - true + allocation, + 0, + params._delegationRatio, + params.maxPOIStaleness ); } } @@ -491,6 +495,46 @@ library AllocationHandler { AllocationHandler.AllocationHandlerAllocationSameSize(_allocationId, _tokens) ); + _resizeAllocation( + _allocations, + allocationProvisionTracker, + _subgraphAllocatedTokens, + graphStaking, + graphRewardsManager, + _allocationId, + allocation, + _tokens, + _delegationRatio, + _maxPOIStaleness + ); + } + + /** + * @notice Internal resize logic shared by explicit resize and over-allocation downsize. + * @dev Caller must validate preconditions (allocation open, tokens changed). + * @param _allocations The allocations mapping + * @param allocationProvisionTracker The provision tracker mapping + * @param _subgraphAllocatedTokens The subgraph allocated tokens mapping + * @param graphStaking The staking contract + * @param graphRewardsManager The rewards manager contract + * @param _allocationId The allocation ID to resize + * @param allocation The current allocation state + * @param _tokens The new token amount for the allocation + * @param _delegationRatio The delegation ratio for provision tracking + * @param _maxPOIStaleness The maximum POI staleness threshold + */ + function _resizeAllocation( + mapping(address allocationId => IAllocation.State allocation) storage _allocations, + mapping(address indexer => uint256 tokens) storage allocationProvisionTracker, + mapping(bytes32 subgraphDeploymentId => uint256 tokens) storage _subgraphAllocatedTokens, + IHorizonStaking graphStaking, + IRewardsManager graphRewardsManager, + address _allocationId, + IAllocation.State memory allocation, + uint256 _tokens, + uint32 _delegationRatio, + uint256 _maxPOIStaleness + ) internal { // Update provision tracker uint256 oldTokens = allocation.tokens; if (_tokens > oldTokens) { diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index 69d980b4d..051fa3260 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -118,7 +118,7 @@ abstract contract AllocationManager is * @param _delegationRatio The delegation ratio to consider when locking tokens * @param _paymentsDestination The address where indexing rewards should be sent * @return rewardsCollected Indexing rewards collected - * @return allocationForceClosed True if the allocation was force closed due to over-allocation + * @return allocationDownsized True if the allocation was resized down due to over-allocation */ // solhint-disable-next-line function-max-lines function _presentPoi( diff --git a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol index 5002900f1..f24106880 100644 --- a/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/SubgraphService.t.sol @@ -151,28 +151,30 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { uint256 previousSubgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens( allocation.subgraphDeploymentId ); + uint256 oldTokens = allocation.tokens; vm.expectEmit(address(subgraphService)); - emit IAllocationManager.AllocationClosed( + emit IAllocationManager.AllocationResized( allocation.indexer, _allocationId, allocation.subgraphDeploymentId, - allocation.tokens, - true + 0, + oldTokens ); - // close stale allocation + // close stale allocation (resizes to 0 instead of closing) subgraphService.closeStaleAllocation(_allocationId); // update allocation allocation = subgraphService.getAllocation(_allocationId); - // check allocation - assertEq(allocation.closedAt, block.timestamp); + // check allocation is still open but with zero tokens + assertTrue(allocation.isOpen()); + assertEq(allocation.tokens, 0); // check subgraph deployment allocated tokens uint256 subgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens(subgraphDeployment); - assertEq(subgraphAllocatedTokens, previousSubgraphAllocatedTokens - allocation.tokens); + assertEq(subgraphAllocatedTokens, previousSubgraphAllocatedTokens - oldTokens); } struct IndexingRewardsData { @@ -431,7 +433,9 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { // For too-young allocations (created in current epoch), the contract returns early // without updating other allocation state or emitting IndexingRewardsCollected if (currentEpoch > allocation.createdAtEpoch) { - assertEq(allocation.accRewardsPending, 0); + // Note: after resize (over-allocation), accRewardsPending is re-accumulated from + // the token delta and may be non-zero. This is expected — rewards from the resize + // delta are captured as pending for the next collection. uint256 accRewardsPerAllocatedToken = rewardsManager.onSubgraphAllocationUpdate( allocation.subgraphDeploymentId ); @@ -460,19 +464,9 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { collectPaymentDataBefore.delegationPoolBalance + indexingRewardsData.tokensDelegationRewards ); - // If after collecting indexing rewards the indexer is over allocated the allcation should close - uint256 tokensAvailable = staking.getTokensAvailable( - _indexer, - address(subgraphService), - subgraphService.getDelegationRatio() - ); - if (allocation.tokens <= tokensAvailable) { - // Indexer isn't over allocated so allocation should still be open - assertTrue(allocation.isOpen()); - } else { - // Indexer is over allocated so allocation should be closed - assertFalse(allocation.isOpen()); - } + // If after collecting indexing rewards the indexer is over allocated the allocation should be + // resized down (not closed), so the allocation always remains open + assertTrue(allocation.isOpen()); } function _migrateLegacyAllocation(address _indexer, address _allocationId, bytes32 _subgraphDeploymentId) internal { diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol index 5fbca5f4e..46d3dac26 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/collect.t.sol @@ -281,7 +281,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA ); } - function test_SubgraphService_CollectIndexingFees_Reverts_WhenCloseStaleAllocation( + function test_SubgraphService_CollectIndexingFees_AfterCloseStaleAllocation_ResizesToZero( Seed memory seed, uint256 entities, bytes32 poi @@ -292,20 +292,13 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA skip(MAX_POI_STALENESS + 1); resetPrank(indexerState.addr); + // closeStaleAllocation now resizes to zero instead of hard-closing, + // so the allocation remains open and collection can still proceed. subgraphService.closeStaleAllocation(indexerState.allocationId); - uint256 currentEpochBlock = epochManager.currentEpochBlock(); - - bytes memory expectedErr = abi.encodeWithSelector( - AllocationHandler.AllocationHandlerAllocationClosed.selector, - indexerState.allocationId - ); - vm.expectRevert(expectedErr); - subgraphService.collect( - indexerState.addr, - IGraphPayments.PaymentTypes.IndexingFee, - _encodeCollectDataV1(acceptedAgreementId, entities, poi, currentEpochBlock, bytes("")) - ); + IAllocation.State memory allocation = subgraphService.getAllocation(indexerState.allocationId); + assertEq(allocation.closedAt, 0, "allocation should still be open after resize-to-zero"); + assertEq(allocation.tokens, 0, "allocation tokens should be zero"); } function test_SubgraphService_CollectIndexingFees_Revert_WhenNotCollectable( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index d6f69414f..ccf3880ab 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; @@ -102,7 +103,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex _sharedAssert(beforeCollect, afterCollect, expectedTokens, tokensCollected); } - function test_SubgraphService_CollectIndexingRewards_CancelsAgreementWhenOverAllocated_Integration( + function test_SubgraphService_CollectIndexingRewards_ResizesToZeroWhenOverAllocated_Integration( Seed memory seed ) public { // Setup context and indexer with active agreement @@ -123,16 +124,21 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex // Advance past allocation creation epoch so POI is not considered "too young" vm.roll(block.number + EPOCH_LENGTH); - // Collect indexing rewards - this should trigger allocation closure and agreement cancellation + // Collect indexing rewards - resizes allocation to zero (not close+cancel) bytes memory collectData = abi.encode(indexerState.allocationId, keccak256("poi"), bytes("metadata")); resetPrank(indexerState.addr); subgraphService.collect(indexerState.addr, IGraphPayments.PaymentTypes.IndexingRewards, collectData); - // Verify the indexing agreement was properly cancelled + // Allocation resized to zero but stays open; agreement remains active + IAllocation.State memory allocation = subgraphService.getAllocation(indexerState.allocationId); + assertEq(allocation.closedAt, 0, "allocation should still be open"); + assertEq(allocation.tokens, 0, "allocation should be resized to zero"); + IIndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId); assertEq( uint8(agreement.collectorAgreement.state), - uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider) + uint8(IRecurringCollector.AgreementState.Accepted), + "agreement should remain active" ); } From b1246562ba5ea43c4a050167e7857d9375342bea Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 30 Mar 2026 07:41:06 +0000 Subject: [PATCH 063/157] feat: revert closing allocations with active indexing agreement Add a governor-controlled guard that prevents closing an allocation when it has an active indexing agreement. When enabled, stopService reverts with SubgraphServiceAllocationHasActiveAgreement instead of auto-canceling the agreement. - Add SubgraphServiceV2Storage with blockClosingAllocationWithActiveAgreement - Add setter/getter and BlockClosingAllocationWithActiveAgreementSet event - IndexingAgreement.onCloseAllocation: revert if active when guard enabled, otherwise cancel as ServiceProvider (forceClosed param removed since closeStaleAllocation now resizes instead of closing) --- .../subgraph-service/ISubgraphService.sol | 28 +++++++ .../contracts/SubgraphService.sol | 32 ++++++-- .../contracts/SubgraphServiceStorage.sol | 15 +++- .../contracts/libraries/IndexingAgreement.sol | 32 +++----- .../unit/libraries/IndexingAgreement.t.sol | 82 ++++++++++++++++--- 5 files changed, 147 insertions(+), 42 deletions(-) diff --git a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol index 050dfe1f3..7ebfa2c4f 100644 --- a/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol +++ b/packages/interfaces/contracts/subgraph-service/ISubgraphService.sol @@ -79,6 +79,13 @@ interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { event IndexingFeesCutSet(uint256 indexingFeesCut); // solhint-disable-previous-line gas-indexed-events + /** + * @notice Emitted when the block closing allocation with active agreement setting is toggled + * @param enabled Whether the setting is enabled + */ + event BlockClosingAllocationWithActiveAgreementSet(bool enabled); + // solhint-disable-previous-line gas-indexed-events + /** * @notice Thrown when trying to set a curation cut that is not a valid PPM value * @param curationCut The curation cut value @@ -164,6 +171,14 @@ interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { */ error SubgraphServiceInvalidCollectionId(bytes32 collectionId); + /** + * @notice Thrown when trying to close an allocation that has an active indexing agreement + * and the close allocation guard is enabled + * @param allocationId The id of the allocation + * @param agreementId The id of the active agreement + */ + error SubgraphServiceAllocationHasActiveAgreement(address allocationId, bytes16 agreementId); + /** * @notice Initialize the contract * @dev The thawingPeriod and verifierCut ranges are not set here because they are variables @@ -272,6 +287,19 @@ interface ISubgraphService is IDataServiceAgreements, IDataServiceFees { */ function setPaymentsDestination(address newPaymentsDestination) external; + /** + * @notice Enables or disables blocking allocation closure when an active agreement exists. + * When enabled, closing an allocation that has an active indexing agreement will revert. + * @param enabled True to enable, false to disable + */ + function setBlockClosingAllocationWithActiveAgreement(bool enabled) external; + + /** + * @notice Whether closing an allocation with an active agreement is blocked + * @return enabled True if blocking is enabled + */ + function getBlockClosingAllocationWithActiveAgreement() external view returns (bool enabled); + /** * @notice Accept an indexing agreement. * @dev If `signature` is non-empty it is treated as an ECDSA signature; if empty the payer diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 7f7b81e03..a222a6e0f 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -21,7 +21,7 @@ import { DataService } from "@graphprotocol/horizon/contracts/data-service/DataS import { DataServiceFees } from "@graphprotocol/horizon/contracts/data-service/extensions/DataServiceFees.sol"; import { Directory } from "./utilities/Directory.sol"; import { AllocationManager } from "./utilities/AllocationManager.sol"; -import { SubgraphServiceV1Storage } from "./SubgraphServiceStorage.sol"; +import { SubgraphServiceV2Storage } from "./SubgraphServiceStorage.sol"; import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; @@ -47,7 +47,7 @@ contract SubgraphService is AllocationManager, IRewardsIssuer, ISubgraphService, - SubgraphServiceV1Storage + SubgraphServiceV2Storage { using PPMMath for uint256; using Allocation for mapping(address => IAllocation.State); @@ -114,7 +114,7 @@ contract SubgraphService is } /** - * @notice + * @notice Register an indexer to the subgraph service * @dev Implements {IDataService.register} * * Requirements: @@ -229,7 +229,7 @@ contract SubgraphService is function stopService(address indexer, bytes calldata data) external override enforceService(indexer, REGISTERED) { address allocationId = abi.decode(data, (address)); _checkAllocationOwnership(indexer, allocationId); - _onCloseAllocation(allocationId, false); + _onCloseAllocation(allocationId); _closeAllocation(allocationId, false); emit ServiceStopped(indexer, data); } @@ -372,6 +372,14 @@ contract SubgraphService is emit IndexingFeesCutSet(indexingFeesCut_); } + /// @inheritdoc ISubgraphService + function setBlockClosingAllocationWithActiveAgreement(bool enabled) external override onlyOwner { + if (blockClosingAllocationWithActiveAgreement == enabled) return; + + blockClosingAllocationWithActiveAgreement = enabled; + emit BlockClosingAllocationWithActiveAgreementSet(enabled); + } + /** * @inheritdoc ISubgraphService * @notice Accept an indexing agreement. @@ -494,6 +502,11 @@ contract SubgraphService is ); } + /// @inheritdoc ISubgraphService + function getBlockClosingAllocationWithActiveAgreement() external view override returns (bool enabled) { + enabled = blockClosingAllocationWithActiveAgreement; + } + /// @inheritdoc IRewardsIssuer function getSubgraphAllocatedTokens(bytes32 subgraphDeploymentId) external view override returns (uint256) { return _subgraphAllocatedTokens[subgraphDeploymentId]; @@ -531,12 +544,15 @@ contract SubgraphService is /** * @notice Internal function to handle closing an allocation - * @dev This function is called when an allocation is closed, either by the indexer or by a third party + * @dev This function is called when an allocation is closed, either by the indexer or by a third party. + * Cancels any active indexing agreement on the allocation, or reverts if the close guard is enabled. * @param _allocationId The id of the allocation being closed - * @param _forceClosed Whether the allocation was force closed */ - function _onCloseAllocation(address _allocationId, bool _forceClosed) internal { - IndexingAgreement._getStorageManager().onCloseAllocation(_allocationId, _forceClosed); + function _onCloseAllocation(address _allocationId) internal { + IndexingAgreement._getStorageManager().onCloseAllocation( + _allocationId, + blockClosingAllocationWithActiveAgreement + ); } /** diff --git a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol index 2ecb69293..1296bd9ed 100644 --- a/packages/subgraph-service/contracts/SubgraphServiceStorage.sol +++ b/packages/subgraph-service/contracts/SubgraphServiceStorage.sol @@ -1,10 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later + +// solhint-disable one-contract-per-file + pragma solidity ^0.8.27; import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; /** - * @title SubgraphServiceStorage + * @title SubgraphServiceV1Storage * @author Edge & Node * @notice This contract holds all the storage variables for the Subgraph Service contract * @custom:security-contact Please email security+contracts@thegraph.com if you find any @@ -26,3 +29,13 @@ abstract contract SubgraphServiceV1Storage is ISubgraphService { /// @notice The cut data service takes from indexing fee payments. In PPM. uint256 public indexingFeesCut; } + +/** + * @title SubgraphServiceV2Storage + * @author Edge & Node + * @notice Adds allocation close guard. + */ +abstract contract SubgraphServiceV2Storage is SubgraphServiceV1Storage { + /// @notice When true, closing an allocation that has an active indexing agreement will revert. + bool internal blockClosingAllocationWithActiveAgreement; +} diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index d94e1401c..c68ec1f34 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -442,40 +442,32 @@ library IndexingAgreement { } /** - * @notice Cancel an allocation's indexing agreement if it exists. + * @notice Handle an allocation's indexing agreement when the allocation is closed. * - * @dev This function is to be called by the data service when an allocation is closed. - * - * Requirements: - * - The allocation must have an active agreement - * - Agreement must be active - * - * Emits {IndexingAgreementCanceled} event + * @dev Called by the data service when an allocation is closed. + * When `_blockIfActive` is true, reverts if the agreement is still active. + * When false, cancels any active agreement as ServiceProvider. * * @param self The indexing agreement storage manager * @param _allocationId The allocation ID - * @param forceClosed Whether the allocation was force closed - * + * @param _blockIfActive Whether to revert if the agreement is active */ - function onCloseAllocation(StorageManager storage self, address _allocationId, bool forceClosed) external { + function onCloseAllocation(StorageManager storage self, address _allocationId, bool _blockIfActive) external { bytes16 agreementId = self.allocationToActiveAgreementId[_allocationId]; - if (agreementId == bytes16(0)) { - return; - } + if (agreementId == bytes16(0)) return; IIndexingAgreement.AgreementWrapper memory wrapper = _get(self, agreementId); - if (!_isActive(wrapper)) { - return; - } + if (!_isActive(wrapper)) return; + + if (_blockIfActive) + revert ISubgraphService.SubgraphServiceAllocationHasActiveAgreement(_allocationId, agreementId); _cancel( self, agreementId, wrapper.agreement, wrapper.collectorAgreement, - forceClosed - ? IRecurringCollector.CancelAgreementBy.ThirdParty - : IRecurringCollector.CancelAgreementBy.ServiceProvider + IRecurringCollector.CancelAgreementBy.ServiceProvider ); } diff --git a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol index a5270e436..2044049dd 100644 --- a/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol +++ b/packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import { Test } from "forge-std/Test.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol"; import { Directory } from "../../../contracts/utilities/Directory.sol"; @@ -46,19 +47,23 @@ contract IndexingAgreementTest is Test { assertEq(wrapper.collectorAgreement.dataService, address(this)); } - function test_IndexingAgreement_OnCloseAllocation(bytes16 agreementId, address allocationId, bool stale) public { - vm.assume(agreementId != bytes16(0)); + function test_IndexingAgreement_OnCloseAllocation_NoAgreement(address allocationId) public { vm.assume(allocationId != address(0)); + // No active agreement — returns early regardless of blockIfActive + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, true); + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, false); + } - delete _storageManager; - vm.clearMockedCalls(); - - // No active agreement for allocation ID, returns early, no assertions needed - IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + function test_IndexingAgreement_OnCloseAllocation_InactiveAgreement( + bytes16 agreementId, + address allocationId + ) public { + vm.assume(agreementId != bytes16(0)); + vm.assume(allocationId != address(0)); - // Active agreement for allocation ID, but collector agreement is not set, returns early, no assertions needed _storageManager.allocationToActiveAgreementId[allocationId] = agreementId; + // Collector agreement not active (default state = NotAccepted) — returns early IRecurringCollector.AgreementData memory collectorAgreement; vm.mockCall( @@ -66,24 +71,76 @@ contract IndexingAgreementTest is Test { abi.encodeWithSelector(Directory.recurringCollector.selector), abi.encode(IRecurringCollector(_mockCollector)) ); - vm.mockCall( _mockCollector, abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), abi.encode(collectorAgreement) ); - IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + // Should not revert even with blockIfActive=true since agreement is not active + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, true); + } + + function test_IndexingAgreement_OnCloseAllocation_RevertsWhenActiveAndBlocked( + bytes16 agreementId, + address allocationId + ) public { + vm.assume(agreementId != bytes16(0)); + vm.assume(allocationId != address(0)); - // Active agreement for allocation ID, collector agreement is set, should cancel the agreement + _storageManager.allocationToActiveAgreementId[allocationId] = agreementId; + _storageManager.agreements[agreementId] = IIndexingAgreement.State({ + allocationId: allocationId, + version: IIndexingAgreement.IndexingAgreementVersion.V1 + }); + + IRecurringCollector.AgreementData memory collectorAgreement; collectorAgreement.dataService = address(this); collectorAgreement.state = IRecurringCollector.AgreementState.Accepted; + vm.mockCall( + address(this), + abi.encodeWithSelector(Directory.recurringCollector.selector), + abi.encode(IRecurringCollector(_mockCollector)) + ); + vm.mockCall( + _mockCollector, + abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), + abi.encode(collectorAgreement) + ); + + vm.expectRevert( + abi.encodeWithSelector( + ISubgraphService.SubgraphServiceAllocationHasActiveAgreement.selector, + allocationId, + agreementId + ) + ); + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, true); + } + + function test_IndexingAgreement_OnCloseAllocation_CancelsWhenActiveAndNotBlocked( + bytes16 agreementId, + address allocationId + ) public { + vm.assume(agreementId != bytes16(0)); + vm.assume(allocationId != address(0)); + + _storageManager.allocationToActiveAgreementId[allocationId] = agreementId; _storageManager.agreements[agreementId] = IIndexingAgreement.State({ allocationId: allocationId, version: IIndexingAgreement.IndexingAgreementVersion.V1 }); + IRecurringCollector.AgreementData memory collectorAgreement; + collectorAgreement.dataService = address(this); + collectorAgreement.state = IRecurringCollector.AgreementState.Accepted; + + vm.mockCall( + address(this), + abi.encodeWithSelector(Directory.recurringCollector.selector), + abi.encode(IRecurringCollector(_mockCollector)) + ); vm.mockCall( _mockCollector, abi.encodeWithSelector(IRecurringCollector.getAgreement.selector, agreementId), @@ -91,8 +148,7 @@ contract IndexingAgreementTest is Test { ); vm.expectCall(_mockCollector, abi.encodeWithSelector(IRecurringCollector.cancel.selector, agreementId)); - - IndexingAgreement.onCloseAllocation(_storageManager, allocationId, stale); + IndexingAgreement.onCloseAllocation(_storageManager, allocationId, false); } function test_IndexingAgreement_StorageManagerLocation() public pure { From 40c9104644c3afa89d520a50ec7a812bbe0ee798 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 06:03:47 +0000 Subject: [PATCH 064/157] fix(collector): reject agreements with overflow-prone token/duration terms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add checked-arithmetic overflow guard on accept and update paths to prevent agreements whose maxOngoingTokensPerSecond × maxSecondsPerCollection product would overflow during collection, with 1024× headroom margin. --- .../contracts/payments/collectors/RecurringCollector.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index c03e739a4..86ba4d17b 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -135,6 +135,9 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) ); + // Reverts on overflow — rejecting excessive terms that could prevent collection + _rca.maxOngoingTokensPerSecond * _rca.maxSecondsPerCollection * 1024; + // accept the agreement agreement.acceptedAt = uint64(block.timestamp); agreement.state = AgreementState.Accepted; @@ -650,6 +653,9 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _requireValidCollectionWindowParams(_rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection); + // Reverts on overflow — rejecting excessive terms that could prevent collection + _rcau.maxOngoingTokensPerSecond * _rcau.maxSecondsPerCollection * 1024; + // update the agreement _agreement.endsAt = _rcau.endsAt; _agreement.maxInitialTokens = _rcau.maxInitialTokens; From 83e25156ae765a3fd1cd08a5e05d215ac8b1419d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:49:48 +0000 Subject: [PATCH 065/157] feat(collector): offer storage, stored-hash auth, scoped claims and cancel (TRST-L-2, L-5) Payers pre-store RCA/RCAU offers on-chain; acceptance verifies the stored hash instead of calling back to the payer contract. This eliminates the callback-based approval flow and its associated trust assumptions. Escrow reservation uses max(active, pending) instead of additive current + pending, so only the larger of the two term sets is reserved (L-2). The claim formula caps the collection window at min(remaining time, maxSecondsPerCollection), eliminating overestimates for agreements near their deadline (L-5). Scoped getMaxNextClaim lets callers query active terms, pending offers, or both. Payer-initiated cancel targets specific terms by hash and scope (ACTIVE/PENDING), with a guard preventing deletion of offers whose terms are already active. --- .../collectors/RecurringCollector.sol | 490 ++++++++-- .../contracts/utilities/Authorizable.sol | 2 +- .../BareAgreementOwner.t.sol | 11 - .../MalformedERC165Payer.t.sol | 21 + .../MockAgreementOwner.t.sol | 66 +- .../RecurringCollectorAuthorizableTest.t.sol | 7 +- .../RecurringCollectorHelper.t.sol | 10 + .../payments/recurring-collector/accept.t.sol | 4 +- .../recurring-collector/acceptUnsigned.t.sol | 55 +- .../acceptValidation.t.sol | 35 + .../recurring-collector/afterCollection.t.sol | 46 +- .../payments/recurring-collector/cancel.t.sol | 1 + .../recurring-collector/collect.t.sol | 3 + .../recurring-collector/coverageGaps.t.sol | 852 ++++++++++++++++++ .../recurring-collector/eligibility.t.sol | 106 ++- .../getAgreementDetails.t.sol | 110 +++ .../recurring-collector/getMaxNextClaim.t.sol | 201 +++++ .../recurring-collector/hashRoundTrip.t.sol | 480 ++++++++++ .../recurring-collector/mixedPath.t.sol | 116 ++- .../payments/recurring-collector/update.t.sol | 3 + .../recurring-collector/updateUnsigned.t.sol | 72 +- .../recurring-collector/viewFunctions.t.sol | 151 ++++ .../test/unit/utilities/Authorizable.t.sol | 38 +- .../contracts/horizon/IAgreementCollector.sol | 164 ++++ .../contracts/horizon/IAgreementOwner.sol | 18 +- .../contracts/horizon/IRecurringCollector.sol | 84 +- packages/issuance/foundry.toml | 3 + .../unit/agreement-manager/approver.t.sol | 177 ---- .../agreement-manager/cancelAgreement.t.sol | 119 ++- .../cancelWithPendingUpdate.t.sol | 79 +- .../agreement-manager/cascadeCleanup.t.sol | 2 + .../unit/agreement-manager/edgeCases.t.sol | 40 +- .../agreement-manager/ensureDistributed.t.sol | 1 + .../unit/agreement-manager/fundingModes.t.sol | 3 + .../test/unit/agreement-manager/helper.t.sol | 2 + .../unit/agreement-manager/helperAudit.t.sol | 1 + .../agreement-manager/helperCleanup.t.sol | 2 + .../unit/agreement-manager/lifecycle.t.sol | 3 + .../mocks/MockIssuanceAllocator.sol | 18 +- .../mocks/MockPaymentsEscrow.sol | 2 + .../agreement-manager/multiCollector.t.sol | 1 + .../unit/agreement-manager/offerUpdate.t.sol | 7 +- .../unit/agreement-manager/reconcile.t.sol | 2 + .../unit/agreement-manager/register.t.sol | 2 - .../revokeAgreementUpdate.t.sol | 4 +- .../unit/agreement-manager/revokeOffer.t.sol | 2 - .../test/unit/agreement-manager/shared.t.sol | 10 + .../test/unit/common/enumerableSetUtil.t.sol | 3 + .../contracts/libraries/IndexingAgreement.sol | 2 +- .../indexing-agreement/integration.t.sol | 2 + .../indexing-agreement/shared.t.sol | 10 +- 51 files changed, 2923 insertions(+), 720 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/MalformedERC165Payer.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol create mode 100644 packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol create mode 100644 packages/interfaces/contracts/horizon/IAgreementCollector.sol delete mode 100644 packages/issuance/test/unit/agreement-manager/approver.t.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 86ba4d17b..2bf1607cc 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -11,9 +11,20 @@ import { GraphDirectory } from "../../utilities/GraphDirectory.sol"; import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol"; // for @inheritdoc import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + ACCEPTED, + REGISTERED, + UPDATE, + SCOPE_ACTIVE, + SCOPE_PENDING +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IDataServiceAgreements } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceAgreements.sol"; import { PPMMath } from "../../libraries/PPMMath.sol"; /** @@ -34,18 +45,28 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct bytes32 public constant EIP712_RCA_TYPEHASH = keccak256( - "RecurringCollectionAgreement(uint64 deadline,uint64 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint256 nonce,bytes metadata)" + "RecurringCollectionAgreement(uint64 deadline,uint64 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint256 nonce,bytes metadata)" ); /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct bytes32 public constant EIP712_RCAU_TYPEHASH = keccak256( - "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint32 nonce,bytes metadata)" + "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint32 nonce,bytes metadata)" ); /* solhint-enable gas-small-strings */ + /// @notice A stored offer (RCA or RCAU) with its EIP-712 hash + struct StoredOffer { + bytes32 offerHash; + bytes data; + } + /// @notice Tracks agreements mapping(bytes16 agreementId => AgreementData data) internal agreements; + /// @notice Stored RCA offers (pre-approval), keyed by agreement ID + mapping(bytes16 agreementId => StoredOffer offer) internal rcaOffers; + /// @notice Stored RCAU offers (pre-approval), keyed by agreement ID + mapping(bytes16 agreementId => StoredOffer offer) internal rcauOffers; /** * @notice Constructs a new instance of the RecurringCollector contract. @@ -88,19 +109,19 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ); /* solhint-enable gas-strict-inequalities */ - if (0 < signature.length) { - // ECDSA-signed path: verify signature - _requireAuthorizedRCASigner(rca, signature); - } else { - // Contract-approved path: verify payer is a contract and confirms the agreement - require(0 < rca.payer.code.length, RecurringCollectorApproverNotContract(rca.payer)); - bytes32 agreementHash = _hashRCA(rca); - require( - IAgreementOwner(rca.payer).approveAgreement(agreementHash) == IAgreementOwner.approveAgreement.selector, - RecurringCollectorInvalidSigner() - ); - } - return _validateAndStoreAgreement(rca); + bool isSigned = 0 < signature.length; + bytes32 rcaHash = _hashRCA(rca); + bytes16 agreementId = _generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + _requireAuthorization(rca.payer, rcaHash, signature, isSigned, agreementId, OFFER_TYPE_NEW); + + return _validateAndStoreAgreement(rca, agreementId, rcaHash); } /** @@ -109,15 +130,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return agreementId The deterministically generated agreement ID */ /* solhint-disable function-max-lines */ - function _validateAndStoreAgreement(RecurringCollectionAgreement memory _rca) private returns (bytes16) { - bytes16 agreementId = _generateAgreementId( - _rca.payer, - _rca.dataService, - _rca.serviceProvider, - _rca.deadline, - _rca.nonce - ); - + function _validateAndStoreAgreement( + RecurringCollectionAgreement memory _rca, + bytes16 agreementId, + bytes32 _rcaHash + ) private returns (bytes16) { require(agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); require(msg.sender == _rca.dataService, RecurringCollectorUnauthorizedCaller(msg.sender, _rca.dataService)); @@ -149,6 +166,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC agreement.maxOngoingTokensPerSecond = _rca.maxOngoingTokensPerSecond; agreement.minSecondsPerCollection = _rca.minSecondsPerCollection; agreement.maxSecondsPerCollection = _rca.maxSecondsPerCollection; + agreement.conditions = _rca.conditions; + agreement.activeTermsHash = _rcaHash; agreement.updateNonce = 0; emit AgreementAccepted( @@ -218,21 +237,12 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ); /* solhint-enable gas-strict-inequalities */ - if (0 < signature.length) { - // ECDSA-signed path: verify signature - _requireAuthorizedRCAUSigner(rcau, signature, agreement.payer); - } else { - // Contract-approved path: verify payer is a contract and confirms the update - require(0 < agreement.payer.code.length, RecurringCollectorApproverNotContract(agreement.payer)); - bytes32 updateHash = _hashRCAU(rcau); - require( - IAgreementOwner(agreement.payer).approveAgreement(updateHash) == - IAgreementOwner.approveAgreement.selector, - RecurringCollectorInvalidSigner() - ); - } + bool isSigned = 0 < signature.length; + bytes32 rcauHash = _hashRCAU(rcau); + + _requireAuthorization(agreement.payer, rcauHash, signature, isSigned, rcau.agreementId, OFFER_TYPE_UPDATE); - _validateAndStoreUpdate(agreement, rcau); + _validateAndStoreUpdate(agreement, rcau, rcauHash); } /// @inheritdoc IRecurringCollector @@ -268,14 +278,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @inheritdoc IRecurringCollector function getCollectionInfo( - AgreementData calldata agreement + bytes16 agreementId ) external view returns (bool isCollectable, uint256 collectionSeconds, AgreementNotCollectableReason reason) { - return _getCollectionInfo(agreement); + return _getCollectionInfo(_getAgreementStorage(agreementId)); } - /// @inheritdoc IRecurringCollector + /// @inheritdoc IAgreementCollector function getMaxNextClaim(bytes16 agreementId) external view returns (uint256) { - return _getMaxNextClaim(agreements[agreementId]); + return _getMaxNextClaimScoped(agreementId, SCOPE_ACTIVE | SCOPE_PENDING); } /// @inheritdoc IRecurringCollector @@ -289,6 +299,189 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC return _generateAgreementId(payer, dataService, serviceProvider, deadline, nonce); } + // -- IAgreementCollector -- + + /// @inheritdoc IAgreementCollector + function offer( + uint8 offerType, + bytes calldata data, + uint16 /* options */ + ) external returns (AgreementDetails memory details) { + if (offerType == OFFER_TYPE_NEW) details = _offerNew(data); + else if (offerType == OFFER_TYPE_UPDATE) details = _offerUpdate(data); + else revert RecurringCollectorInvalidCollectData(data); + } + + /** + * @notice Process a new offer (OFFER_TYPE_NEW). + * @param _data The ABI-encoded RecurringCollectionAgreement + * @return details The agreement details + */ + function _offerNew(bytes calldata _data) private returns (AgreementDetails memory details) { + RecurringCollectorStorage storage $ = _getStorage(); + RecurringCollectionAgreement memory rca = abi.decode(_data, (RecurringCollectionAgreement)); + require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); + _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); + + bytes16 agreementId = _generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + bytes32 offerHash = _hashRCA(rca); + + $.rcaOffers[agreementId] = StoredOffer({ offerHash: offerHash, data: _data }); + + details.agreementId = agreementId; + details.payer = rca.payer; + details.dataService = rca.dataService; + details.serviceProvider = rca.serviceProvider; + details.versionHash = offerHash; + details.state = REGISTERED; + + emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, offerHash); + } + + /** + * @notice Process an update offer (OFFER_TYPE_UPDATE). + * @param _data The ABI-encoded RecurringCollectionAgreementUpdate + * @return details The agreement details + */ + function _offerUpdate(bytes calldata _data) private returns (AgreementDetails memory details) { + RecurringCollectorStorage storage $ = _getStorage(); + RecurringCollectionAgreementUpdate memory rcau = abi.decode(_data, (RecurringCollectionAgreementUpdate)); + bytes16 agreementId = rcau.agreementId; + + // Payer check: look up the existing agreement or the stored RCA offer + AgreementData storage agreement = $.agreements[agreementId]; + address payer = agreement.payer; + if (payer == address(0)) { + // Not yet accepted — check stored RCA offer payer + require( + $.rcaOffers[agreementId].offerHash != bytes32(0), + RecurringCollectorAgreementIncorrectState(agreementId, AgreementState.NotAccepted) + ); + RecurringCollectionAgreement memory rca = abi.decode( + $.rcaOffers[agreementId].data, + (RecurringCollectionAgreement) + ); + payer = rca.payer; + details.dataService = rca.dataService; + details.serviceProvider = rca.serviceProvider; + } else { + details.dataService = agreement.dataService; + details.serviceProvider = agreement.serviceProvider; + } + require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); + _requirePayerToSupportEligibilityCheck(payer, rcau.conditions); + + bytes32 offerHash = _hashRCAU(rcau); + + $.rcauOffers[agreementId] = StoredOffer({ offerHash: offerHash, data: _data }); + + details.agreementId = agreementId; + details.payer = payer; + details.versionHash = offerHash; + details.state = REGISTERED | UPDATE; + + emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, offerHash); + } + + /// @inheritdoc IAgreementCollector + function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external whenNotPaused { + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage agreement = $.agreements[agreementId]; + _requirePayer($, agreement, agreementId); + + if (agreement.activeTermsHash != termsHash) { + if (options & SCOPE_PENDING != 0) + // Pending scope: delete stored offer if hash matches and terms are not currently active + if ($.rcaOffers[agreementId].offerHash == termsHash) delete $.rcaOffers[agreementId]; + else if ($.rcauOffers[agreementId].offerHash == termsHash) delete $.rcauOffers[agreementId]; + } else if (options & SCOPE_ACTIVE != 0 && agreement.state == AgreementState.Accepted) + // Active scope and hash matches: cancel accepted agreement + IDataServiceAgreements(agreement.dataService).cancelIndexingAgreementByPayer(agreementId); + } + + /** + * @notice Requires that msg.sender is the payer for an agreement. + * @dev Checks the on-chain agreement first, then falls back to stored RCA offer. + * @param agreement The agreement data + * @param agreementId The agreement ID + */ + // solhint-disable-next-line use-natspec + function _requirePayer( + RecurringCollectorStorage storage $, + AgreementData storage agreement, + bytes16 agreementId + ) private view { + if (agreement.payer == msg.sender) return; + + // Not payer on accepted agreement — check stored RCA offer + StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; + if (rcaOffer.offerHash != bytes32(0)) { + RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); + require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); + return; + } + if (agreement.payer == address(0)) revert RecurringCollectorAgreementNotFound(agreementId); + + revert RecurringCollectorUnauthorizedCaller(msg.sender, agreement.payer); + } + + /// @inheritdoc IAgreementCollector + function getAgreementDetails( + bytes16 agreementId, + uint256 /* index */ + ) external view returns (AgreementDetails memory details) { + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage agreement = $.agreements[agreementId]; + + if (agreement.state != AgreementState.NotAccepted) { + details.agreementId = agreementId; + details.payer = agreement.payer; + details.dataService = agreement.dataService; + details.serviceProvider = agreement.serviceProvider; + details.versionHash = agreement.activeTermsHash; + details.state = ACCEPTED; + return details; + } + + // Not yet accepted — check stored RCA offer + StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; + if (rcaOffer.offerHash != bytes32(0)) { + RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); + details.agreementId = agreementId; + details.payer = rca.payer; + details.dataService = rca.dataService; + details.serviceProvider = rca.serviceProvider; + details.versionHash = rcaOffer.offerHash; + details.state = REGISTERED; + } + } + + /// @inheritdoc IAgreementCollector + function getMaxNextClaim(bytes16 agreementId, uint8 agreementScope) external view returns (uint256) { + return _getMaxNextClaimScoped(agreementId, agreementScope); + } + + /// @inheritdoc IAgreementCollector + function getAgreementOfferAt( + bytes16 agreementId, + uint256 index + ) external view returns (uint8 offerType, bytes memory offerData) { + RecurringCollectorStorage storage $ = _getStorage(); + if (index == OFFER_TYPE_NEW) { + StoredOffer storage rca = $.rcaOffers[agreementId]; + if (rca.offerHash != bytes32(0)) return (OFFER_TYPE_NEW, rca.data); + } else if (index == OFFER_TYPE_UPDATE) { + StoredOffer storage rcau = $.rcauOffers[agreementId]; + if (rcau.offerHash != bytes32(0)) return (OFFER_TYPE_UPDATE, rcau.data); + } + } + /** * @notice Decodes the collect data. * @param data The encoded collect parameters. @@ -473,7 +666,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return The capped token amount: min(_tokens, payer's max for this collection) */ function _requireValidCollect( - AgreementData memory _agreement, + AgreementData storage _agreement, bytes16 _agreementId, uint256 _tokens, uint256 _collectionSeconds @@ -581,39 +774,32 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } /** - * @notice Requires that the signer for the RCA is authorized - * by the payer of the RCA. - * @param _rca The RCA whose hash was signed - * @param _signature The ECDSA signature bytes - * @return The address of the authorized signer + * @notice Verifies authorization for an EIP712 hash using the given basis. + * @param _payer The payer address (signer owner for ECDSA, contract for approval) + * @param _hash The EIP712 typed data hash + * @param _signature The ECDSA signature (only used when basis is Signature) + * @param _isSigned True if ECDSA-signed, false if pre-approved via stored offer + * @param _agreementId The agreement ID (used to look up stored offer when not signed) + * @param _offerType OFFER_TYPE_NEW or OFFER_TYPE_UPDATE (selects which stored offer to check) */ - function _requireAuthorizedRCASigner( - RecurringCollectionAgreement memory _rca, - bytes memory _signature - ) private view returns (address) { - address signer = _recoverRCASigner(_rca, _signature); - require(_isAuthorized(_rca.payer, signer), RecurringCollectorInvalidSigner()); - - return signer; - } - - /** - * @notice Requires that the signer for the RCAU is authorized - * by the payer. - * @param _rcau The RCAU whose hash was signed - * @param _signature The ECDSA signature bytes - * @param _payer The address of the payer - * @return The address of the authorized signer - */ - function _requireAuthorizedRCAUSigner( - RecurringCollectionAgreementUpdate memory _rcau, + function _requireAuthorization( + address _payer, + bytes32 _hash, bytes memory _signature, - address _payer - ) private view returns (address) { - address signer = _recoverRCAUSigner(_rcau, _signature); - require(_isAuthorized(_payer, signer), RecurringCollectorInvalidSigner()); + bool _isSigned, + bytes16 _agreementId, + uint8 _offerType + ) private view { + RecurringCollectorStorage storage $ = _getStorage(); - return signer; + if (_isSigned) + require(_isAuthorized(_payer, ECDSA.recover(_hash, _signature)), RecurringCollectorInvalidSigner()); + else + // Check stored offer hash instead of callback + require( + (_offerType == OFFER_TYPE_NEW ? rcaOffers[_agreementId] : rcauOffers[_agreementId]).offerHash == _hash, + RecurringCollectorInvalidSigner() + ); } /** @@ -639,11 +825,15 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * Shared validation/storage/emit logic for the update function. * @param _agreement The storage reference to the agreement data * @param _rcau The Recurring Collection Agreement Update to apply + * @param _rcauHash The EIP-712 hash of the RCAU */ function _validateAndStoreUpdate( AgreementData storage _agreement, - RecurringCollectionAgreementUpdate calldata _rcau + RecurringCollectionAgreementUpdate calldata _rcau, + bytes32 _rcauHash ) private { + RecurringCollectorStorage storage $ = _getStorage(); + // validate nonce to prevent replay attacks uint32 expectedNonce = _agreement.updateNonce + 1; require( @@ -656,12 +846,20 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC // Reverts on overflow — rejecting excessive terms that could prevent collection _rcau.maxOngoingTokensPerSecond * _rcau.maxSecondsPerCollection * 1024; + // Clean up stored replaced offer + bytes32 oldHash = _agreement.activeTermsHash; + if (oldHash != bytes32(0)) + if ($.rcaOffers[_rcau.agreementId].offerHash == oldHash) delete $.rcaOffers[_rcau.agreementId]; + else if ($.rcauOffers[_rcau.agreementId].offerHash == oldHash) delete $.rcauOffers[_rcau.agreementId]; + // update the agreement _agreement.endsAt = _rcau.endsAt; _agreement.maxInitialTokens = _rcau.maxInitialTokens; _agreement.maxOngoingTokensPerSecond = _rcau.maxOngoingTokensPerSecond; _agreement.minSecondsPerCollection = _rcau.minSecondsPerCollection; _agreement.maxSecondsPerCollection = _rcau.maxSecondsPerCollection; + _agreement.conditions = _rcau.conditions; + _agreement.activeTermsHash = _rcauHash; _agreement.updateNonce = _rcau.nonce; emit AgreementUpdated( @@ -708,7 +906,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return reason The reason why the agreement is not collectable (None if collectable) */ function _getCollectionInfo( - AgreementData memory _agreement + AgreementData storage _agreement ) private view returns (bool, uint256, AgreementNotCollectableReason) { // Check if agreement is in collectable state bool hasValidState = _agreement.state == AgreementState.Accepted || @@ -748,18 +946,18 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @param _agreement The agreement data * @return The start time for the collection of the agreement */ - function _agreementCollectionStartAt(AgreementData memory _agreement) private pure returns (uint256) { + function _agreementCollectionStartAt(AgreementData storage _agreement) private view returns (uint256) { return _agreement.lastCollectionAt > 0 ? _agreement.lastCollectionAt : _agreement.acceptedAt; } /** * @notice Compute the maximum tokens collectable in the next collection (worst case). - * @dev For active agreements uses endsAt as the collection end (worst case), - * not block.timestamp (current). Returns 0 for non-collectable states. + * @dev Determines the collection window from agreement state, then delegates to {_maxClaim}. + * Returns 0 for non-collectable states. * @param _a The agreement data * @return The maximum tokens that could be collected */ - function _getMaxNextClaim(AgreementData memory _a) private pure returns (uint256) { + function _getMaxNextClaim(AgreementData storage _a) private view returns (uint256) { // CanceledByServiceProvider = immediately non-collectable if (_a.state == AgreementState.CanceledByServiceProvider) return 0; // Only Accepted and CanceledByPayer are collectable @@ -778,35 +976,129 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC collectionEnd = _a.endsAt; } - // No collection possible if window is empty - // solhint-disable-next-line gas-strict-inequalities - if (collectionEnd <= collectionStart) return 0; + return + _maxClaim( + collectionStart, + collectionEnd, + _a.maxSecondsPerCollection, + _a.maxOngoingTokensPerSecond, + _a.lastCollectionAt == 0 ? _a.maxInitialTokens : 0 + ); + } + + /** + * @notice Compute max next claim with scope control (active, pending, or both). + * @dev Adapts the refactored _getMaxNextClaim(agreementId, agreementScope) pattern. + * Active claim comes from the on-chain agreement state. Pending claim comes from + * stored offers (RCA if not yet accepted, RCAU if pending update). + * @param agreementId The agreement ID + * @param agreementScope Bitmask: SCOPE_ACTIVE (1), SCOPE_PENDING (2), or both (3) + * @return maxClaim The maximum tokens claimable under the requested scope + */ + function _getMaxNextClaimScoped(bytes16 agreementId, uint8 agreementScope) private view returns (uint256 maxClaim) { + AgreementData storage _a = agreements[agreementId]; + + uint256 maxActiveClaim = 0; + uint256 maxPendingClaim = 0; + + if (agreementScope & SCOPE_ACTIVE != 0) { + if (_a.state == AgreementState.NotAccepted) { + // Not yet accepted — check stored RCA offer + StoredOffer storage rcaOffer = rcaOffers[agreementId]; + if (rcaOffer.offerHash != bytes32(0)) { + RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); + // Use block.timestamp as proxy for acceptedAt, deadline as expiry + if (block.timestamp < rca.deadline) { + maxActiveClaim = _maxClaim( + block.timestamp, + rca.endsAt, + rca.maxSecondsPerCollection, + rca.maxOngoingTokensPerSecond, + rca.maxInitialTokens + ); + } + } + } else { + maxActiveClaim = _getMaxNextClaim(_a); + } + } + + if (agreementScope & SCOPE_PENDING != 0) { + StoredOffer storage rcauOffer = rcauOffers[agreementId]; + if (rcauOffer.offerHash != bytes32(0)) { + RecurringCollectionAgreementUpdate memory rcau = abi.decode( + rcauOffer.data, + (RecurringCollectionAgreementUpdate) + ); + // Ongoing claim: time-capped from now to rcau.endsAt + maxPendingClaim = _maxClaim( + block.timestamp, + rcau.endsAt, + rcau.maxSecondsPerCollection, + rcau.maxOngoingTokensPerSecond, + _a.lastCollectionAt == 0 ? rcau.maxInitialTokens : 0 + ); + } + } - // Max seconds is capped by maxSecondsPerCollection (enforced by _requireValidCollect) - uint256 windowSeconds = collectionEnd - collectionStart; - uint256 maxSeconds = windowSeconds < _a.maxSecondsPerCollection ? windowSeconds : _a.maxSecondsPerCollection; + maxClaim = maxActiveClaim < maxPendingClaim ? maxPendingClaim : maxActiveClaim; + } - uint256 maxClaim = _a.maxOngoingTokensPerSecond * maxSeconds; - if (_a.lastCollectionAt == 0) maxClaim += _a.maxInitialTokens; - return maxClaim; + /** + * @notice Core claim formula: rate * min(window, maxSeconds) + initialBonus. + * @dev Single source of truth for all max-claim calculations. Returns 0 when + * windowEnd <= windowStart (empty or inverted window). + * @param windowStart Start of the collection window + * @param windowEnd End of the collection window + * @param maxSecondsPerCollection Maximum seconds per collection period + * @param maxOngoingTokensPerSecond Maximum ongoing tokens per second + * @param maxInitialTokens Initial bonus tokens (0 if already collected) + * @return The maximum possible claim amount + */ + function _maxClaim( + uint256 windowStart, + uint256 windowEnd, + uint256 maxSecondsPerCollection, + uint256 maxOngoingTokensPerSecond, + uint256 maxInitialTokens + ) private pure returns (uint256) { + // solhint-disable-next-line gas-strict-inequalities + if (windowEnd <= windowStart) return 0; + uint256 windowSeconds = windowEnd - windowStart; + uint256 effectiveSeconds = windowSeconds < maxSecondsPerCollection ? windowSeconds : maxSecondsPerCollection; + return maxOngoingTokensPerSecond * effectiveSeconds + maxInitialTokens; + } + + /** + * @notice RC is self-authorized for any authorizer. + * @dev Allows RC to call data service functions (e.g. cancelByPayer) that check + * rc.isAuthorized(payer, msg.sender). When msg.sender is RC itself, this returns true, + * meaning RC is trusted to have verified authorization before delegating. + * @param authorizer The authorizer address + * @param signer The signer address to check authorization for + * @return True if the signer is authorized + */ + function _isAuthorized(address authorizer, address signer) internal view override returns (bool) { + if (signer == address(this)) return true; + return super._isAuthorized(authorizer, signer); } /** * @notice Internal function to generate deterministic agreement ID - * @param _payer The address of the payer - * @param _dataService The address of the data service - * @param _serviceProvider The address of the service provider - * @param _deadline The deadline for accepting the agreement - * @param _nonce A unique nonce for preventing collisions + * @param payer The address of the payer + * @param dataService The address of the data service + * @param serviceProvider The address of the service provider + * @param deadline The deadline for accepting the agreement + * @param nonce A unique nonce for preventing collisions * @return agreementId The deterministically generated agreement ID */ function _generateAgreementId( - address _payer, - address _dataService, - address _serviceProvider, - uint64 _deadline, - uint256 _nonce + address payer, + address dataService, + address serviceProvider, + uint64 deadline, + uint256 nonce ) private pure returns (bytes16) { - return bytes16(keccak256(abi.encode(_payer, _dataService, _serviceProvider, _deadline, _nonce))); + return bytes16(keccak256(abi.encode(payer, dataService, serviceProvider, deadline, nonce))); } } diff --git a/packages/horizon/contracts/utilities/Authorizable.sol b/packages/horizon/contracts/utilities/Authorizable.sol index d48d2e1a3..58123c52b 100644 --- a/packages/horizon/contracts/utilities/Authorizable.sol +++ b/packages/horizon/contracts/utilities/Authorizable.sol @@ -97,7 +97,7 @@ abstract contract Authorizable is IAuthorizable { * @param _signer The address of the signer * @return true if the signer is authorized by the authorizer, false otherwise */ - function _isAuthorized(address _authorizer, address _signer) internal view returns (bool) { + function _isAuthorized(address _authorizer, address _signer) internal view virtual returns (bool) { return (_authorizer != address(0) && authorizations[_signer].authorizer == _authorizer && !authorizations[_signer].revoked); diff --git a/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol b/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol index 2f6324957..37384875d 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/BareAgreementOwner.t.sol @@ -7,17 +7,6 @@ import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAg /// Calling supportsInterface on this contract will revert (no such function), /// exercising the catch {} fallthrough in RecurringCollector's eligibility gate. contract BareAgreementOwner is IAgreementOwner { - mapping(bytes32 => bool) public authorizedHashes; - - function authorize(bytes32 agreementHash) external { - authorizedHashes[agreementHash] = true; - } - - function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { - if (!authorizedHashes[agreementHash]) return bytes4(0); - return IAgreementOwner.approveAgreement.selector; - } - function beforeCollection(bytes16, uint256) external override {} function afterCollection(bytes16, uint256) external override {} diff --git a/packages/horizon/test/unit/payments/recurring-collector/MalformedERC165Payer.t.sol b/packages/horizon/test/unit/payments/recurring-collector/MalformedERC165Payer.t.sol new file mode 100644 index 000000000..8f12a1538 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/MalformedERC165Payer.t.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; + +/// @notice Malicious payer that returns empty data from supportsInterface(), +/// causing an ABI decoding revert on the caller side that escapes try/catch. +contract MalformedERC165Payer is IAgreementOwner { + function beforeCollection(bytes16, uint256) external override {} + + function afterCollection(bytes16, uint256) external override {} + + /// @notice Responds to supportsInterface with empty returndata. + /// The call succeeds at the EVM level but the caller cannot ABI-decode the result. + fallback() external { + // solhint-disable-next-line no-inline-assembly + assembly { + return(0, 0) + } + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol index 614dab81a..3d8db160e 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol @@ -1,50 +1,25 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// @notice Mock contract approver for testing acceptUnsigned and updateUnsigned. /// Can be configured to return valid selector, wrong value, or revert. -/// Optionally supports IERC165 + IProviderEligibility for eligibility gate testing. -contract MockAgreementOwner is IAgreementOwner, IERC165, IProviderEligibility { - mapping(bytes32 => bool) public authorizedHashes; +/// Implements IProviderEligibility for eligibility gate testing. +contract MockAgreementOwner is IAgreementOwner, IProviderEligibility, IERC165 { bool public shouldRevert; - bytes4 public overrideReturnValue; - bool public useOverride; // -- Eligibility configuration -- - bool public eligibilityEnabled; - mapping(address => bool) public eligibleProviders; - bool public defaultEligible; - - function authorize(bytes32 agreementHash) external { - authorizedHashes[agreementHash] = true; - } + // Defaults to true: payers that don't care about eligibility allow all providers. + // Tests that want to deny must explicitly set a provider ineligible. + mapping(address => bool) public ineligibleProviders; function setShouldRevert(bool _shouldRevert) external { shouldRevert = _shouldRevert; } - function setOverrideReturnValue(bytes4 _value) external { - overrideReturnValue = _value; - useOverride = true; - } - - function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { - if (shouldRevert) { - revert("MockAgreementOwner: forced revert"); - } - if (useOverride) { - return overrideReturnValue; - } - if (!authorizedHashes[agreementHash]) { - return bytes4(0); - } - return IAgreementOwner.approveAgreement.selector; - } - bytes16 public lastBeforeCollectionAgreementId; uint256 public lastBeforeCollectionTokens; bool public shouldRevertOnBeforeCollection; @@ -77,31 +52,20 @@ contract MockAgreementOwner is IAgreementOwner, IERC165, IProviderEligibility { lastCollectedTokens = tokensCollected; } - // -- ERC165 + IProviderEligibility -- - - /// @notice Enable ERC165 reporting of IProviderEligibility support - function setEligibilityEnabled(bool _enabled) external { - eligibilityEnabled = _enabled; - } + // -- IProviderEligibility -- - /// @notice Set whether a specific provider is eligible - function setProviderEligible(address provider, bool _eligible) external { - eligibleProviders[provider] = _eligible; + /// @notice Mark a provider as ineligible (default is eligible) + function setProviderIneligible(address provider) external { + ineligibleProviders[provider] = true; } - /// @notice Set default eligibility for providers not explicitly configured - function setDefaultEligible(bool _eligible) external { - defaultEligible = _eligible; + function isEligible(address indexer) external view override returns (bool) { + return !ineligibleProviders[indexer]; } - function supportsInterface(bytes4 interfaceId) external view override returns (bool) { - if (interfaceId == type(IERC165).interfaceId) return true; - if (interfaceId == type(IProviderEligibility).interfaceId) return eligibilityEnabled; - return false; - } + // -- IERC165 -- - function isEligible(address indexer) external view override returns (bool) { - if (eligibleProviders[indexer]) return true; - return defaultEligible; + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return interfaceId == type(IProviderEligibility).interfaceId || interfaceId == type(IERC165).interfaceId; } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol index b4d109678..ed40d03ee 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol @@ -9,6 +9,11 @@ import { InvalidControllerMock } from "../../mocks/InvalidControllerMock.t.sol"; contract RecurringCollectorAuthorizableTest is AuthorizableTest { function newAuthorizable(uint256 thawPeriod) public override returns (IAuthorizable) { - return new RecurringCollector("RecurringCollector", "1", address(new InvalidControllerMock()), thawPeriod); + return + IAuthorizable( + address( + new RecurringCollector("RecurringCollector", "1", address(new InvalidControllerMock()), thawPeriod) + ) + ); } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index 9a01754aa..61d9e6764 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -104,6 +104,7 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { vm.assume(rca.dataService != address(0)); vm.assume(rca.payer != address(0)); vm.assume(rca.serviceProvider != address(0)); + // Exclude ProxyAdmin address — TransparentProxy routes admin calls to ProxyAdmin, not implementation // Ensure we have a nonce if it's zero if (rca.nonce == 0) { @@ -122,6 +123,14 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { rca.maxInitialTokens = _sensibleMaxInitialTokens(rca.maxInitialTokens); rca.maxOngoingTokensPerSecond = _sensibleMaxOngoingTokensPerSecond(rca.maxOngoingTokensPerSecond); + // Zero fuzzed conditions to avoid spurious ERC-165 failures. + // Eligibility tests set conditions explicitly before calling sensibleRCA. + // Preserve explicitly-set conditions (non-fuzz callers). + // Fuzz inputs can hit any value; we zero to keep non-eligibility tests clean. + // (sensibleRCA is always called — fuzz and explicit alike — so we zero unconditionally + // and eligibility tests re-set after sensibleRCA returns.) + rca.conditions = 0; + return rca; } @@ -138,6 +147,7 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { rcau.endsAt = _sensibleEndsAt(rcau.endsAt, rcau.maxSecondsPerCollection); rcau.maxInitialTokens = _sensibleMaxInitialTokens(rcau.maxInitialTokens); rcau.maxOngoingTokensPerSecond = _sensibleMaxOngoingTokensPerSecond(rcau.maxOngoingTokensPerSecond); + rcau.conditions = 0; return rcau; } diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index 8404db85e..d1742b690 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -13,7 +13,9 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ function test_Accept(FuzzyTestAccept calldata fuzzyTestAccept) public { - _sensibleAuthorizeAndAccept(fuzzyTestAccept); + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(agreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); } function test_Accept_Revert_WhenAcceptanceDeadlineElapsed( diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol index 153b69141..7feca10c9 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; @@ -24,6 +25,7 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) @@ -39,8 +41,8 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { ); rca.payer = address(approver); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); @@ -78,13 +80,12 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { assertEq(agreement.dataService, rca.dataService); } - function test_AcceptUnsigned_Revert_WhenPayerNotContract() public { + function test_AcceptUnsigned_Revert_WhenNoOfferStored() public { address eoa = makeAddr("eoa"); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(eoa); - vm.expectRevert( - abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, eoa) - ); + // No offer stored — stored-hash lookup fails + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); _recurringCollector.accept(rca, ""); } @@ -93,8 +94,8 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); - // Don't authorize the hash - vm.expectRevert(); + // Don't store an offer — should revert + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); _recurringCollector.accept(rca, ""); } @@ -103,8 +104,7 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); - approver.setOverrideReturnValue(bytes4(0xdeadbeef)); - + // With stored offers, "wrong magic value" maps to "no matching offer stored" vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); _recurringCollector.accept(rca, ""); @@ -114,8 +114,8 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); address notDataService = makeAddr("notDataService"); vm.expectRevert( @@ -136,31 +136,22 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { ); rca.payer = address(approver); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); bytes16 agreementId = _recurringCollector.accept(rca, ""); - bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, - agreementId, - IRecurringCollector.AgreementState.Accepted + // Stored offer persists, so authorization passes but state check fails + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.Accepted + ) ); - vm.expectRevert(expectedErr); - vm.prank(rca.dataService); - _recurringCollector.accept(rca, ""); - } - - function test_AcceptUnsigned_Revert_WhenApproverReverts() public { - MockAgreementOwner approver = _newApprover(); - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); - - approver.setShouldRevert(true); - - vm.expectRevert("MockAgreementOwner: forced revert"); vm.prank(rca.dataService); _recurringCollector.accept(rca, ""); } @@ -169,8 +160,8 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); // Advance time past the deadline vm.warp(rca.deadline + 1); diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol index f8f35c2b7..5e47e2fb4 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol @@ -23,6 +23,7 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }); @@ -184,5 +185,39 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest _recurringCollector.accept(rca, signature); } + // ==================== Overflow validation ==================== + + function test_Accept_Revert_WhenMaxOngoingTokensOverflows() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + // Set maxOngoingTokensPerSecond so that maxOngoingTokensPerSecond * maxSecondsPerCollection * 1024 overflows + rca.maxOngoingTokensPerSecond = type(uint256).max / 1024; // overflow when multiplied by 3600 * 1024 + rca.maxSecondsPerCollection = 3600; + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.expectRevert(); // overflow panic + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + function test_Accept_OK_WhenMaxOngoingTokensAtBoundary() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); + // Set values at exactly the boundary that does not overflow + rca.maxSecondsPerCollection = 3600; + rca.maxOngoingTokensPerSecond = type(uint256).max / (uint256(3600) * 1024); + // Ensure collection window is valid + rca.minSecondsPerCollection = 600; + + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Should not revert + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol index c84958daf..3e7396178 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; @@ -27,13 +28,14 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); @@ -124,6 +126,46 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { assertEq(approver.lastCollectedTokens(), 0); } + function test_Collect_Revert_WhenInsufficientCallbackGas() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + // Encode the outer collect call + bytes memory callData = abi.encodeCall( + _recurringCollector.collect, + (IGraphPayments.PaymentTypes.IndexingFee, data) + ); + + // Binary-search for a gas limit that passes core collect logic but trips the + // callback gas guard (gasleft < MAX_PAYER_CALLBACK_GAS * 64/63 ≈ 1_523_810). + // Core logic + escrow call + beforeCollection + events uses ~200k gas. + bool triggered; + for (uint256 gasLimit = 1_700_000; gasLimit > 1_500_000; gasLimit -= 10_000) { + uint256 snap = vm.snapshot(); + vm.prank(rca.dataService); + (bool success, bytes memory returnData) = address(_recurringCollector).call{ gas: gasLimit }(callData); + if (!success && returnData.length >= 4) { + bytes4 selector; + assembly { + selector := mload(add(returnData, 32)) + } + if (selector == IRecurringCollector.RecurringCollectorInsufficientCallbackGas.selector) { + triggered = true; + assertTrue(vm.revertTo(snap)); + break; + } + } + assertTrue(vm.revertTo(snap)); + } + assertTrue(triggered, "Should have triggered InsufficientCallbackGas at some gas limit"); + } + function test_AfterCollection_NotCalledForEOAPayer(FuzzyTestCollect calldata fuzzy) public { // Use standard ECDSA-signed path (EOA payer, no contract) (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, , , ) = _sensibleAuthorizeAndAccept( diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol index 1ccb0ccc1..cf1da6743 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol @@ -52,6 +52,7 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { address notDataService ) public { vm.assume(fuzzyTestAccept.rca.dataService != notDataService); + vm.assume(notDataService != _proxyAdmin); (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); diff --git a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol index d19f5caed..0bd6b7325 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/collect.t.sol @@ -15,6 +15,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ function test_Collect_Revert_WhenInvalidData(address caller, uint8 unboundedPaymentType, bytes memory data) public { + vm.assume(caller != _proxyAdmin); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorInvalidCollectData.selector, data @@ -29,6 +30,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { address notDataService ) public { vm.assume(fuzzy.fuzzyTestAccept.rca.dataService != notDataService); + vm.assume(notDataService != _proxyAdmin); (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy.fuzzyTestAccept); IRecurringCollector.CollectParams memory collectParams = fuzzy.collectParams; @@ -90,6 +92,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest { } function test_Collect_Revert_WhenUnknownAgreement(FuzzyTestCollect memory fuzzy, address dataService) public { + vm.assume(dataService != _proxyAdmin); bytes memory data = _generateCollectData(fuzzy.collectParams); bytes memory expectedErr = abi.encodeWithSelector( diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol new file mode 100644 index 000000000..e360b44e4 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -0,0 +1,852 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { + REGISTERED, + ACCEPTED, + UPDATE, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + SCOPE_ACTIVE, + SCOPE_PENDING, + IAgreementCollector +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice A payer contract that supports ERC165 + IProviderEligibility at offer time, +/// but returns malformed (< 32 bytes) data from isEligible at collection time. +contract MalformedEligibilityPayer is IAgreementOwner, IERC165 { + bool public returnMalformed; + + function setReturnMalformed(bool _malformed) external { + returnMalformed = _malformed; + } + + function beforeCollection(bytes16, uint256) external override {} + function afterCollection(bytes16, uint256) external override {} + + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return interfaceId == type(IERC165).interfaceId || interfaceId == type(IProviderEligibility).interfaceId; + } + + /// @notice When returnMalformed is true, returns empty data via assembly (< 32 bytes). + /// Otherwise returns true (eligible). + fallback() external { + if (returnMalformed) { + // solhint-disable-next-line no-inline-assembly + assembly { + return(0, 0) // return 0 bytes — triggers result.length < 32 + } + } else { + // solhint-disable-next-line no-inline-assembly + assembly { + mstore(0x00, 1) // true + return(0x00, 0x20) + } + } + } +} + +/// @notice Tests targeting specific uncovered lines in RecurringCollector.sol +contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ══════════════════════════════════════════════════════════════════════ + // Helper: offer an RCA via the payer and return the agreement ID + // ══════════════════════════════════════════════════════════════════════ + + function _offer( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16 agreementId) { + MockAgreementOwner approver; + if (rca.payer.code.length == 0) { + approver = new MockAgreementOwner(); + rca.payer = address(approver); + } + vm.prank(rca.payer); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + return details.agreementId; + } + + /// @dev Accept via offer+accept (unsigned path) and return rca + agreementId + function _offerAndAccept( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (IRecurringCollector.RecurringCollectionAgreement memory, bytes16) { + MockAgreementOwner approver; + if (rca.payer.code.length == 0) { + approver = new MockAgreementOwner(); + rca.payer = address(approver); + } + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.payer); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + return (rca, agreementId); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 1 — Invalid offer type + // ══════════════════════════════════════════════════════════════════════ + + function test_Offer_Revert_WhenOfferTypeInvalid_Two() public { + address payer = makeAddr("payer"); + vm.expectRevert(); + vm.prank(payer); + _recurringCollector.offer(2, bytes(""), 0); + } + + function test_Offer_Revert_WhenOfferTypeInvalid_MaxUint8() public { + address payer = makeAddr("payer"); + vm.expectRevert(); + vm.prank(payer); + _recurringCollector.offer(255, bytes(""), 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 2 — getAgreementDetails index 0 on accepted agreement + // ══════════════════════════════════════════════════════════════════════ + + function test_GetAgreementDetails_Index0_Accepted(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails(agreementId, 0); + assertTrue(details.versionHash != bytes32(0), "Index 0 should return non-zero active terms hash"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 3 — getAgreementDetails index 1 with pending update + // ══════════════════════════════════════════════════════════════════════ + + function test_GetAgreementOfferAt_PendingUpdateExists() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // Submit update via offer to create pending terms + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Pending update should be accessible at index 1 (OFFER_TYPE_UPDATE) + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(offerType, OFFER_TYPE_UPDATE, "Index 1 should be OFFER_TYPE_UPDATE"); + assertTrue(offerData.length > 0, "Pending update data should not be empty"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 4 — getAgreementOfferAt round-trip + // ══════════════════════════════════════════════════════════════════════ + + function test_GetAgreementOfferAt_Index0() public { + // Must use offer() path so the RCA is stored in rcaOffers + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = details.agreementId; + + // Before accept: offer is available + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(offerType, OFFER_TYPE_NEW, "Index 0 should be OFFER_TYPE_NEW"); + IRecurringCollector.RecurringCollectionAgreement memory decoded = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreement) + ); + bytes32 expectedHash = _recurringCollector.hashRCA(rca); + assertEq(_recurringCollector.hashRCA(decoded), expectedHash, "Reconstructed hash should match RCA hash"); + + // Accept + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // After accept: offer is cleaned up + (, bytes memory postAcceptData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(postAcceptData.length, 0, "RCA offer should be cleaned up after accept"); + } + + function test_GetAgreementOfferAt_Index1_WithPending() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // Submit update via offer + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + + assertEq(offerType, OFFER_TYPE_UPDATE, "Index 1 should be OFFER_TYPE_UPDATE"); + IRecurringCollector.RecurringCollectionAgreementUpdate memory decoded = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + bytes32 expectedHash = _recurringCollector.hashRCAU(rcau); + assertEq(_recurringCollector.hashRCAU(decoded), expectedHash, "Reconstructed hash should match offer hash"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 5 — getMaxNextClaim with scope + // ══════════════════════════════════════════════════════════════════════ + + function test_GetMaxNextClaim_ScopeActiveOnly(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + uint256 maxClaimActive = _recurringCollector.getMaxNextClaim(agreementId, SCOPE_ACTIVE); + uint256 maxClaimBoth = _recurringCollector.getMaxNextClaim(agreementId); + + assertEq(maxClaimActive, maxClaimBoth, "Active-only scope should match full scope when no pending terms"); + } + + function test_GetMaxNextClaim_ScopePendingOnly(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + uint256 maxClaimPending = _recurringCollector.getMaxNextClaim(agreementId, SCOPE_PENDING); + + assertEq(maxClaimPending, 0, "Pending-only scope should return 0 when no pending terms"); + } + + function test_GetMaxNextClaim_ScopePendingOnly_WithPending(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Submit update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.prank(rca.payer); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + uint256 maxClaimPending = _recurringCollector.getMaxNextClaim(agreementId, SCOPE_PENDING); + + assertTrue(0 < maxClaimPending, "Pending-only scope should be > 0 when pending terms exist"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 6 — PayerCallbackFailed when eligibility returns malformed data + // ══════════════════════════════════════════════════════════════════════ + + function test_Collect_EmitsPayerCallbackFailed_WhenEligibilityReturnsMalformed() public { + MalformedEligibilityPayer payer = new MalformedEligibilityPayer(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(payer), + dataService: makeAddr("ds-elig"), + serviceProvider: makeAddr("sp-elig"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, // sensibleRCA zeros this; we'll set it after + nonce: 1, + metadata: "" + }) + ); + // Set conditions AFTER sensibleRCA (which zeros conditions to avoid spurious failures) + rca.conditions = 1; // CONDITION_ELIGIBILITY_CHECK + + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Payer calls offer (isEligible works correctly at this point) + vm.prank(address(payer)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + // Accept via dataService (unsigned path: empty signature) + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Now make the payer return malformed (< 32 bytes) from isEligible + payer.setReturnMalformed(true); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData( + _generateCollectParams(rca, agreementId, bytes32("col-malformed"), tokens, 0) + ); + + // Collection should proceed despite malformed eligibility response + // (the PayerCallbackFailed event is emitted but collection continues) + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens, "Collection should proceed despite malformed eligibility response"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 7 — Update overwrites active terms when not yet accepted + // ══════════════════════════════════════════════════════════════════════ + + function test_Update_OverwritesOffer_WhenNotYetAccepted() public { + address dataService = makeAddr("ds"); + address serviceProvider = makeAddr("sp"); + + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: dataService, + serviceProvider: serviceProvider, + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + // Offer but do NOT accept + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory offerDetails = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = offerDetails.agreementId; + + // Submit OFFER_TYPE_UPDATE to overwrite + uint256 newMaxInitial = 200 ether; + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: newMaxInitial, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // The update offer should exist at index 1 + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(offerType, OFFER_TYPE_UPDATE, "Update offer should be stored"); + IRecurringCollector.RecurringCollectionAgreementUpdate memory decoded = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + assertEq(decoded.maxInitialTokens, newMaxInitial, "Update should contain new values"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 8 — getCollectionInfo returns zero seconds in same block as accept + // ══════════════════════════════════════════════════════════════════════ + + function test_GetCollectionInfo_ZeroCollectionSeconds(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + // Read agreement in the same block as accept + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); + + assertFalse(isCollectable, "Should not be collectable with zero elapsed time"); + assertEq(collectionSeconds, 0, "Collection seconds should be 0"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 9 — getMaxNextClaim for offered-but-not-accepted agreement + // ══════════════════════════════════════════════════════════════════════ + + function test_GetMaxNextClaim_OfferedButNotAccepted() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 100_000), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 5000, + maxOngoingTokensPerSecond: 100, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = details.agreementId; + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // Should return non-zero for valid offered agreement + assertTrue(0 < maxClaim, "maxClaim should be non-zero for valid offered agreement"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 10 — Cancel pending update clears pending terms + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_PendingUpdate_ClearsPendingTerms() public { + // Use offer path so payer is a contract we control + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Offer and accept + vm.prank(address(approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // Offer an update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt + 365 days, + maxInitialTokens: rca.maxInitialTokens * 2, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond * 2, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel specifically the pending update (using its hash + SCOPE_PENDING) + bytes32 pendingHash = _recurringCollector.hashRCAU(rcau); + assertTrue(pendingHash != bytes32(0), "Should have pending terms"); + + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, pendingHash, SCOPE_PENDING); + + // Pending terms cleared: getAgreementOfferAt(id, 1) should return empty + (, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(pendingData.length, 0, "Pending terms should be cleared"); + + // Active terms should still be intact + bytes32 activeHash = _recurringCollector.getAgreementDetails(agreementId, 0).versionHash; + assertTrue(activeHash != bytes32(0), "Active terms should remain"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 11 — Scoped cancel: cancel active terms with hash match + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_ActiveTerms_WhenPendingExists(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Submit update to create pending terms + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(rca.payer); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel via dataService cancel path (old cancel API) + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + // Active terms should be canceled + IRecurringCollector.AgreementData memory data = _recurringCollector.getAgreement(agreementId); + assertTrue( + data.state == IRecurringCollector.AgreementState.CanceledByServiceProvider, + "Should be canceled by SP" + ); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 12 — Cancel is idempotent when hash matches neither pending nor active + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_NoOp_WhenHashMatchesNeither(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + bytes32 bogusHash = bytes32(uint256(0xdead)); + + // Should not revert — cancel is idempotent + vm.prank(rca.payer); + _recurringCollector.cancel(agreementId, bogusHash, SCOPE_ACTIVE | SCOPE_PENDING); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 13 — getAgreementOfferAt edge cases + // ══════════════════════════════════════════════════════════════════════ + + function test_GetAgreementOfferAt_Index2_ReturnsEmpty(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 2); + assertEq(offerType, 0, "Out-of-range index should return 0 offerType"); + assertEq(offerData.length, 0, "Out-of-range index should return empty data"); + } + + function test_GetAgreementOfferAt_EmptyAgreement() public view { + bytes16 fakeId = bytes16(keccak256("nonexistent")); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(fakeId, 0); + assertEq(offerType, 0, "Empty agreement index 0 should return 0 offerType"); + assertEq(offerData.length, 0, "Empty agreement index 0 should return empty data"); + } + + function test_GetAgreementOfferAt_Index1_NoPending(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(offerType, 0, "No pending terms should return 0 offerType"); + assertEq(offerData.length, 0, "No pending terms should return empty data"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 14 — Offer revert when deadline expired + // ══════════════════════════════════════════════════════════════════════ + + function test_Accept_Revert_WhenOfferedWithExpiredDeadline() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1), // valid at offer time + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + // Offer stores successfully (deadline not checked at offer time) + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Warp past deadline + skip(2); + + // Accept should revert with expired deadline + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + rca.deadline + ) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 15 — getMaxNextClaim returns 0 for empty state + // ══════════════════════════════════════════════════════════════════════ + + function test_GetMaxNextClaim_EmptyState_ReturnsZero() public view { + bytes16 fakeId = bytes16(keccak256("nonexistent")); + uint256 maxClaim = _recurringCollector.getMaxNextClaim(fakeId); + assertEq(maxClaim, 0, "Empty state agreement should return 0"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 16 — Cancel by SP allows final collection + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_ByServiceProvider_AllowsFinalCollection(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Skip some time to accumulate collectable seconds + skip(rca.minSecondsPerCollection); + + // Cancel by service provider + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + // Verify the agreement is canceled by SP + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq( + uint8(agreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "Should be CanceledByServiceProvider" + ); + + // SP cancel should NOT allow further collection (SP forfeits) + (bool isCollectable, , ) = _recurringCollector.getCollectionInfo(agreementId); + assertFalse(isCollectable, "CanceledByServiceProvider should not be collectable"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 17 — Cancel by payer allows final collection + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_ByPayer_AllowsFinalCollection(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Skip some time to accumulate collectable seconds + skip(rca.minSecondsPerCollection); + + // Cancel by payer + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + // Verify the agreement is canceled by payer + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq( + uint8(agreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByPayer), + "Should be CanceledByPayer" + ); + + // Payer cancel should allow final collection + (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); + assertTrue(isCollectable, "CanceledByPayer should be collectable for final period"); + assertTrue(collectionSeconds > 0, "Should have collectable seconds"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 18 — Offer caller must be payer + // ══════════════════════════════════════════════════════════════════════ + + function test_Offer_Revert_WhenCallerNotPayer() public { + MockAgreementOwner approver = new MockAgreementOwner(); + address notPayer = makeAddr("notPayer"); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorUnauthorizedCaller.selector, + notPayer, + address(approver) + ) + ); + vm.prank(notPayer); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 19 — Scoped cancel on pending revokes the stored offer + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_Scoped_PendingNewOffer() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + // Offer but don't accept + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = details.agreementId; + + // Verify offer exists + (uint8 offerType, ) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(offerType, OFFER_TYPE_NEW, "Offer should exist before cancel"); + + // Cancel the pending offer + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, details.versionHash, SCOPE_PENDING); + + // Verify offer is gone + (uint8 offerTypeAfter, bytes memory dataAfter) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(offerTypeAfter, 0, "Offer type should be 0 after cancel"); + assertEq(dataAfter.length, 0, "Offer data should be empty after cancel"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol b/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol index 310e1a88f..b507e522f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/eligibility.t.sol @@ -3,10 +3,12 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; import { BareAgreementOwner } from "./BareAgreementOwner.t.sol"; +import { MalformedERC165Payer } from "./MalformedERC165Payer.t.sol"; /// @notice Tests for the IProviderEligibility gate in RecurringCollector._collect() contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { @@ -28,13 +30,15 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); + rca.conditions = 1; // CONDITION_ELIGIBILITY_CHECK — set after sensibleRCA - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); @@ -49,10 +53,7 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { approver ); - // Enable eligibility check and mark provider as eligible - approver.setEligibilityEnabled(true); - approver.setProviderEligible(rca.serviceProvider, true); - + // Provider is eligible by default — isEligible returns true skip(rca.minSecondsPerCollection); uint256 tokens = 1 ether; bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); @@ -68,9 +69,8 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { approver ); - // Enable eligibility check but provider is NOT eligible - approver.setEligibilityEnabled(true); - // defaultEligible is false, and provider not explicitly set + // Explicitly mark provider as ineligible + approver.setProviderIneligible(rca.serviceProvider); skip(rca.minSecondsPerCollection); uint256 tokens = 1 ether; @@ -87,19 +87,40 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); } - function test_Collect_OK_WhenPayerDoesNotSupportInterface() public { - MockAgreementOwner approver = _newApprover(); - (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( - approver + function test_Collect_OK_WhenPayerDoesNotImplementEligibility() public { + // BareAgreementOwner implements IAgreementOwner but NOT IProviderEligibility. + // The isEligible call will revert — treated as "no opinion" (collection proceeds). + BareAgreementOwner bare = new BareAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(bare), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) ); - // eligibilityEnabled is false by default — supportsInterface returns false for IProviderEligibility - // Collection should proceed normally (backward compatible) + vm.prank(address(bare)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); skip(rca.minSecondsPerCollection); uint256 tokens = 1 ether; bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + // Collection succeeds — revert from missing isEligible is treated as "no opinion" vm.prank(rca.dataService); uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); assertEq(collected, tokens); @@ -128,29 +149,48 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { assertEq(collected, tokens); } - function test_Collect_OK_WhenPayerHasNoERC165() public { - // BareAgreementOwner implements IAgreementOwner but NOT IERC165. - // The supportsInterface call will revert, hitting the catch {} branch. - BareAgreementOwner bare = new BareAgreementOwner(); + function test_Collect_OK_ZeroTokensSkipsEligibilityCheck() public { + MockAgreementOwner approver = _newApprover(); + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( + approver + ); + + // Provider is ineligible, but zero-token collection should skip the gate + approver.setProviderIneligible(rca.serviceProvider); + + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), 0, 0)); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, 0); + } + + function test_Collect_OK_WhenPayerReturnsMalformedData() public { + // A malicious payer returns empty data from isEligible (via fallback). + // The call succeeds at the EVM level but returndata is empty — treated as + // "no opinion" (collection proceeds), not a caller-side revert. + MalformedERC165Payer malicious = new MalformedERC165Payer(); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( IRecurringCollector.RecurringCollectionAgreement({ deadline: uint64(block.timestamp + 1 hours), endsAt: uint64(block.timestamp + 365 days), - payer: address(bare), + payer: address(malicious), dataService: makeAddr("ds"), serviceProvider: makeAddr("sp"), maxInitialTokens: 100 ether, maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - bare.authorize(agreementHash); + vm.prank(address(malicious)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); @@ -160,31 +200,11 @@ contract RecurringCollectorEligibilityTest is RecurringCollectorSharedTest { uint256 tokens = 1 ether; bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); - // Collection succeeds — the catch {} swallows the revert from supportsInterface + // Collection must succeed — malformed returndata must not block collection vm.prank(rca.dataService); uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); assertEq(collected, tokens); } - function test_Collect_OK_ZeroTokensSkipsEligibilityCheck() public { - MockAgreementOwner approver = _newApprover(); - (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( - approver - ); - - // Enable eligibility check, provider is NOT eligible - approver.setEligibilityEnabled(true); - // defaultEligible = false - - // Zero-token collection should NOT trigger the eligibility gate - // (the guard is inside `if (0 < tokensToCollect && ...)`) - skip(rca.minSecondsPerCollection); - bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), 0, 0)); - - vm.prank(rca.dataService); - uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); - assertEq(collected, 0); - } - /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol new file mode 100644 index 000000000..91d788020 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW, + REGISTERED +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +contract RecurringCollectorGetAgreementDetailsTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- Accepted agreement -- + + function test_GetAgreementDetails_Accepted(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails(agreementId, 0); + + assertEq(details.agreementId, agreementId); + assertEq(details.payer, rca.payer); + assertEq(details.dataService, rca.dataService); + assertEq(details.serviceProvider, rca.serviceProvider); + assertNotEq(details.versionHash, bytes32(0)); + } + + // -- Stored RCA offer (not yet accepted) -- + + function test_GetAgreementDetails_StoredOffer() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory offerDetails = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = offerDetails.agreementId; + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails(agreementId, 0); + + assertEq(details.agreementId, agreementId); + assertEq(details.payer, address(approver)); + assertEq(details.dataService, rca.dataService); + assertEq(details.serviceProvider, rca.serviceProvider); + assertEq(details.versionHash, offerDetails.versionHash); + assertEq(details.state, REGISTERED); + } + + // -- Unknown agreement returns zero -- + + function test_GetAgreementDetails_Unknown() public view { + bytes16 unknownId = bytes16(keccak256("nonexistent")); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails(unknownId, 0); + + assertEq(details.agreementId, bytes16(0)); + assertEq(details.payer, address(0)); + assertEq(details.dataService, address(0)); + assertEq(details.serviceProvider, address(0)); + assertEq(details.versionHash, bytes32(0)); + } + + // -- Canceled agreement still returns details -- + + function test_GetAgreementDetails_Canceled(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails(agreementId, 0); + + assertEq(details.agreementId, agreementId); + assertEq(details.payer, rca.payer); + assertEq(details.dataService, rca.dataService); + assertEq(details.serviceProvider, rca.serviceProvider); + assertNotEq(details.versionHash, bytes32(0)); + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol index 801beef6d..58aa6961d 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol @@ -2,8 +2,10 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW, OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ @@ -15,6 +17,203 @@ contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { assertEq(_recurringCollector.getMaxNextClaim(fakeId), 0, "NotAccepted agreement should return 0"); } + // -- Pre-acceptance stored-offer tests -- + + /// @notice After offer(OFFER_TYPE_NEW), getMaxNextClaim returns expected value before accept + function test_GetMaxNextClaim_StoredOffer_BeforeAccept() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + + // Pre-acceptance: window = endsAt - now, capped at maxSecondsPerCollection + uint256 windowSeconds = rca.endsAt - block.timestamp; + uint256 maxSeconds = windowSeconds < rca.maxSecondsPerCollection ? windowSeconds : rca.maxSecondsPerCollection; + uint256 expected = rca.maxOngoingTokensPerSecond * maxSeconds + rca.maxInitialTokens; + assertEq(maxClaim, expected, "Stored RCA offer should return expected maxNextClaim before accept"); + assertTrue(maxClaim > 0, "Stored offer maxNextClaim should be non-zero"); + } + + /// @notice After offer(OFFER_TYPE_NEW), getMaxNextClaim returns 0 if deadline has passed + function test_GetMaxNextClaim_StoredOffer_ExpiredDeadline() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 100), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + // Warp past deadline + vm.warp(rca.deadline + 1); + + uint256 maxClaim = _recurringCollector.getMaxNextClaim(agreementId); + assertEq(maxClaim, 0, "Stored offer past deadline should return 0"); + } + + /// @notice After offer(OFFER_TYPE_UPDATE), getMaxNextClaim reflects pending update + function test_GetMaxNextClaim_StoredUpdate_PendingScope() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + // Accept via unsigned path + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Store a pending update with higher rates + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Check pending scope + uint256 pendingClaim = _recurringCollector.getMaxNextClaim(agreementId, 2); // SCOPE_PENDING + + // Pending: window = rcau.endsAt - now, capped at rcau.maxSecondsPerCollection + // Never collected so includes maxInitialTokens + uint256 windowSeconds = rcau.endsAt - block.timestamp; + uint256 maxSeconds = windowSeconds < rcau.maxSecondsPerCollection + ? windowSeconds + : rcau.maxSecondsPerCollection; + uint256 expected = rcau.maxOngoingTokensPerSecond * maxSeconds + rcau.maxInitialTokens; + assertEq(pendingClaim, expected, "Pending RCAU should return expected maxNextClaim"); + assertTrue(pendingClaim > 0, "Pending maxNextClaim should be non-zero"); + } + + /// @notice getMaxNextClaim (no scope) returns max(active, pending) when both exist + function test_GetMaxNextClaim_MaxOfActiveAndPending() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + // Accept + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Store a pending update with higher rates + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + uint256 activeClaim = _recurringCollector.getMaxNextClaim(agreementId, 1); // SCOPE_ACTIVE + uint256 pendingClaim = _recurringCollector.getMaxNextClaim(agreementId, 2); // SCOPE_PENDING + uint256 combinedClaim = _recurringCollector.getMaxNextClaim(agreementId); // max of both + + uint256 expectedMax = activeClaim < pendingClaim ? pendingClaim : activeClaim; + assertEq(combinedClaim, expectedMax, "Combined should be max(active, pending)"); + // With higher rates on pending, pending should dominate + assertGe(pendingClaim, activeClaim, "Higher-rate pending should be >= active"); + } + // -- Test 2: CanceledByServiceProvider agreement returns 0 -- function test_GetMaxNextClaim_CanceledByServiceProvider(FuzzyTestAccept calldata fuzzy) public { @@ -233,6 +432,7 @@ contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, + conditions: 0, nonce: 1, metadata: "" }); @@ -283,6 +483,7 @@ contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, + conditions: 0, nonce: 1, metadata: "" }); diff --git a/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol new file mode 100644 index 000000000..955f274ed --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol @@ -0,0 +1,480 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + SCOPE_PENDING, + IAgreementCollector +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Round-trip hash verification: reconstruct offers from on-chain data and verify hashes. +/// Uses the offer() + accept() path so that offers are stored in rcaOffers/rcauOffers. +contract RecurringCollectorHashRoundTripTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockAgreementOwner internal _approver; + + function setUp() public override { + super.setUp(); + _approver = new MockAgreementOwner(); + } + + // ==================== Helpers ==================== + + function _makeRCA() internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(_approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + } + + function _offerRCA(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(address(_approver)); + return _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + } + + function _offerAndAcceptRCA( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + bytes16 agreementId = _offerRCA(rca); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + return agreementId; + } + + function _makeUpdate( + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes16 agreementId, + uint32 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 30 days), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: rca.conditions, + nonce: nonce, + metadata: rca.metadata + }); + } + + /// @notice Verify that getAgreementOfferAt round-trips: decode and rehash matches expected hash + function _verifyOfferRoundTrip(bytes16 agreementId, uint256 index, bytes32 expectedHash) internal view { + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, index); + require(offerData.length > 0, "Offer data should not be empty"); + + bytes32 reconstructedHash; + if (offerType == OFFER_TYPE_NEW) { + IRecurringCollector.RecurringCollectionAgreement memory rca = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreement) + ); + reconstructedHash = _recurringCollector.hashRCA(rca); + } else { + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + reconstructedHash = _recurringCollector.hashRCAU(rcau); + } + + assertEq(reconstructedHash, expectedHash, "Reconstructed hash must match expected hash"); + } + + // ==================== RCA round-trip (pending, before accept) ==================== + + /// @notice Stored RCA offer round-trips before acceptance + function test_HashRoundTrip_RCA_Pending() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerRCA(rca); + + // Verify stored offer round-trips before acceptance + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + + // Verify reconstructed RCA fields match original + (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + IRecurringCollector.RecurringCollectionAgreement memory reconstructed = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreement) + ); + assertEq(reconstructed.payer, rca.payer, "payer mismatch"); + assertEq(reconstructed.dataService, rca.dataService, "dataService mismatch"); + assertEq(reconstructed.serviceProvider, rca.serviceProvider, "serviceProvider mismatch"); + assertEq(reconstructed.nonce, rca.nonce, "nonce mismatch"); + assertEq(reconstructed.endsAt, rca.endsAt, "endsAt mismatch"); + } + + /// @notice Stored RCA offer is cleaned up after acceptance + function test_HashRoundTrip_RCA_CleanedUpAfterAccept() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // activeTermsHash matches + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should match RCA hash"); + + // Stored offer should be cleaned up after accept + (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(offerData.length, 0, "RCA offer should be cleaned up after accept"); + } + + // ==================== RCAU round-trip (pending) ==================== + + function test_HashRoundTrip_RCAU_Pending() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer update (creates pending terms) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Verify pending update round-trips + _verifyOfferRoundTrip(agreementId, 1, rcauHash); + } + + // ==================== RCAU round-trip (accepted → cleaned up) ==================== + + function test_HashRoundTrip_RCAU_CleanedUpAfterUpdate() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer and accept update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + // After update, activeTermsHash should be the RCAU hash + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash should be RCAU hash after update"); + + // Stored update offer should be cleaned up + (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(offerData.length, 0, "RCAU offer should be cleaned up after update"); + } + + // ==================== Cancel pending, active stays ==================== + + function test_HashRoundTrip_CancelPending_ActiveStays() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel the pending update using its hash + vm.prank(address(_approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + // RCA offer was already cleaned up at accept time + (, bytes memory rcaData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(rcaData.length, 0, "RCA offer should have been cleaned up at accept"); + + // Pending update should be gone + (, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(pendingData.length, 0, "Pending update should be cleared after cancel"); + + // activeTermsHash should still be the RCA hash + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should still be RCA hash"); + } + + // ==================== Pre-acceptance overwrite ==================== + + function test_HashRoundTrip_RCAU_PreAcceptOverwrite() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Offer RCA + vm.prank(address(_approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + + // Overwrite with RCAU before acceptance + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Update offer should be stored at index 1 and round-trip + _verifyOfferRoundTrip(agreementId, 1, rcauHash); + + // Original RCA offer should still be at index 0 + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + } + + /* solhint-enable graph/func-name-mixedcase */ +} + +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + SCOPE_PENDING, + IAgreementCollector +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Round-trip hash verification: reconstruct offers from on-chain data and verify hashes. +/// Uses the offer() + accept() path so that offers are stored in rcaOffers/rcauOffers. +contract RecurringCollectorHashRoundTripTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + MockAgreementOwner internal _approver; + + function setUp() public override { + super.setUp(); + _approver = new MockAgreementOwner(); + } + + // ==================== Helpers ==================== + + function _makeRCA() internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(_approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + } + + function _offerRCA(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(address(_approver)); + return _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + } + + function _offerAndAcceptRCA( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + bytes16 agreementId = _offerRCA(rca); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + return agreementId; + } + + function _makeUpdate( + IRecurringCollector.RecurringCollectionAgreement memory rca, + bytes16 agreementId, + uint32 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 30 days), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: rca.conditions, + nonce: nonce, + metadata: rca.metadata + }); + } + + /// @notice Verify that getAgreementOfferAt round-trips: decode and rehash matches expected hash + function _verifyOfferRoundTrip(bytes16 agreementId, uint256 index, bytes32 expectedHash) internal view { + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, index); + require(offerData.length > 0, "Offer data should not be empty"); + + bytes32 reconstructedHash; + if (offerType == OFFER_TYPE_NEW) { + IRecurringCollector.RecurringCollectionAgreement memory rca = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreement) + ); + reconstructedHash = _recurringCollector.hashRCA(rca); + } else { + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + reconstructedHash = _recurringCollector.hashRCAU(rcau); + } + + assertEq(reconstructedHash, expectedHash, "Reconstructed hash must match expected hash"); + } + + // ==================== RCA round-trip (pending, before accept) ==================== + + /// @notice Stored RCA offer round-trips before acceptance + function test_HashRoundTrip_RCA_Pending() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerRCA(rca); + + // Verify stored offer round-trips before acceptance + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + + // Verify reconstructed RCA fields match original + (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + IRecurringCollector.RecurringCollectionAgreement memory reconstructed = abi.decode( + offerData, + (IRecurringCollector.RecurringCollectionAgreement) + ); + assertEq(reconstructed.payer, rca.payer, "payer mismatch"); + assertEq(reconstructed.dataService, rca.dataService, "dataService mismatch"); + assertEq(reconstructed.serviceProvider, rca.serviceProvider, "serviceProvider mismatch"); + assertEq(reconstructed.nonce, rca.nonce, "nonce mismatch"); + assertEq(reconstructed.endsAt, rca.endsAt, "endsAt mismatch"); + } + + /// @notice Stored RCA offer persists after acceptance + function test_HashRoundTrip_RCA_PersistsAfterAccept() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // activeTermsHash matches + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should match RCA hash"); + + // Stored offer persists after accept + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + } + + // ==================== RCAU round-trip (pending) ==================== + + function test_HashRoundTrip_RCAU_Pending() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer update (creates pending terms) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Verify pending update round-trips + _verifyOfferRoundTrip(agreementId, 1, rcauHash); + } + + // ==================== RCAU round-trip (accepted → persists) ==================== + + function test_HashRoundTrip_RCAU_PersistsAfterUpdate() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer and accept update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + // After update, activeTermsHash should be the RCAU hash + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash should be RCAU hash after update"); + + // Stored update offer persists after update + _verifyOfferRoundTrip(agreementId, 1, rcauHash); + } + + // ==================== Cancel pending, active stays ==================== + + function test_HashRoundTrip_CancelPending_ActiveStays() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _offerAndAcceptRCA(rca); + + // Offer update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel the pending update using its hash + vm.prank(address(_approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + // RCA offer persists after accept + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + + // Pending update should be gone + (, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(pendingData.length, 0, "Pending update should be cleared after cancel"); + + // activeTermsHash should still be the RCA hash + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should still be RCA hash"); + } + + // ==================== Pre-acceptance overwrite ==================== + + function test_HashRoundTrip_RCAU_PreAcceptOverwrite() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Offer RCA + vm.prank(address(_approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + + // Overwrite with RCAU before acceptance + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(_approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Update offer should be stored at index 1 and round-trip + _verifyOfferRoundTrip(agreementId, 1, rcauHash); + + // Original RCA offer should still be at index 0 + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + _verifyOfferRoundTrip(agreementId, 0, rcaHash); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol index 10d6ee5e0..f81aa0f04 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW, OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; @@ -10,151 +11,178 @@ import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { /* solhint-disable graph/func-name-mixedcase */ - /// @notice ECDSA accept, then contract-approved update should fail (payer is EOA) - function test_MixedPath_ECDSAAccept_UnsignedUpdate_RevertsForEOA() public { - uint256 signerKey = 0xA11CE; - address payer = vm.addr(signerKey); + /// @notice Contract-approved accept, then contract-approved update works + function test_MixedPath_UnsignedAccept_UnsignedUpdate_OK() public { + MockAgreementOwner approver = new MockAgreementOwner(); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( IRecurringCollector.RecurringCollectionAgreement({ deadline: uint64(block.timestamp + 1 hours), endsAt: uint64(block.timestamp + 365 days), - payer: payer, + payer: address(approver), dataService: makeAddr("ds"), serviceProvider: makeAddr("sp"), maxInitialTokens: 100 ether, maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); - // Accept via ECDSA - (, , bytes16 agreementId) = _authorizeAndAccept(rca, signerKey); + // Accept via contract-approved path + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); - // Try unsigned update — should revert because payer is an EOA + // Update via contract-approved path (use sensibleRCAU to stay in valid ranges) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( IRecurringCollector.RecurringCollectionAgreementUpdate({ agreementId: agreementId, deadline: 0, endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 200 ether, - maxOngoingTokensPerSecond: 2 ether, + maxInitialTokens: 50 ether, + maxOngoingTokensPerSecond: 0.5 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 7200, + conditions: 0, nonce: 1, metadata: "" }) ); - vm.expectRevert( - abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, payer) + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementUpdated( + rca.dataService, + address(approver), + rca.serviceProvider, + agreementId, + uint64(block.timestamp), + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection ); + vm.prank(rca.dataService); _recurringCollector.update(rcau, ""); + + // Verify updated terms + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.maxOngoingTokensPerSecond, rcau.maxOngoingTokensPerSecond); + assertEq(agreement.maxSecondsPerCollection, rcau.maxSecondsPerCollection); + assertEq(agreement.updateNonce, 1); } - /// @notice Contract-approved accept, then ECDSA update should fail (no authorized signer) - function test_MixedPath_UnsignedAccept_ECDSAUpdate_RevertsForUnauthorizedSigner() public { - MockAgreementOwner approver = new MockAgreementOwner(); + /// @notice ECDSA-accepted agreement with EOA payer → unsigned update fails (no stored offer for EOA). + /// Restored negative test: verifies EOA payers accepted via ECDSA cannot be updated via unsigned path. + function test_MixedPath_ECDSAAccept_UnsignedUpdate_RevertsForEOA() public { + uint256 signerKey = 0xA11CE; + address payer = vm.addr(signerKey); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( IRecurringCollector.RecurringCollectionAgreement({ deadline: uint64(block.timestamp + 1 hours), endsAt: uint64(block.timestamp + 365 days), - payer: address(approver), + payer: payer, dataService: makeAddr("ds"), serviceProvider: makeAddr("sp"), maxInitialTokens: 100 ether, maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); - // Accept via contract-approved path - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + // Accept via ECDSA + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); - bytes16 agreementId = _recurringCollector.accept(rca, ""); + bytes16 agreementId = _recurringCollector.accept(rca, signature); - // Try ECDSA update with an unauthorized signer - uint256 wrongKey = 0xDEAD; + // Try unsigned update — should revert because no offer is stored (EOA can't call offer()) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( IRecurringCollector.RecurringCollectionAgreementUpdate({ agreementId: agreementId, - deadline: uint64(block.timestamp + 1 hours), + deadline: 0, endsAt: uint64(block.timestamp + 730 days), maxInitialTokens: 200 ether, maxOngoingTokensPerSecond: 2 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 7200, + conditions: 0, nonce: 1, metadata: "" }) ); - (, bytes memory sig) = _recurringCollectorHelper.generateSignedRCAU(rcau, wrongKey); - - vm.expectRevert(IRecurringCollector.RecurringCollectorInvalidSigner.selector); + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); - _recurringCollector.update(rcau, sig); + _recurringCollector.update(rcau, ""); } - /// @notice Contract-approved accept, then contract-approved update works - function test_MixedPath_UnsignedAccept_UnsignedUpdate_OK() public { - MockAgreementOwner approver = new MockAgreementOwner(); + /// @notice ECDSA-accepted agreement → ECDSA-signed update succeeds (both paths consistent) + function test_MixedPath_ECDSAAccept_ECDSAUpdate_OK() public { + uint256 signerKey = 0xA11CE; + address payer = vm.addr(signerKey); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( IRecurringCollector.RecurringCollectionAgreement({ deadline: uint64(block.timestamp + 1 hours), endsAt: uint64(block.timestamp + 365 days), - payer: address(approver), + payer: payer, dataService: makeAddr("ds"), serviceProvider: makeAddr("sp"), maxInitialTokens: 100 ether, maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) ); - // Accept via contract-approved path - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + // Accept via ECDSA + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); _setupValidProvision(rca.serviceProvider, rca.dataService); vm.prank(rca.dataService); - bytes16 agreementId = _recurringCollector.accept(rca, ""); + bytes16 agreementId = _recurringCollector.accept(rca, signature); - // Update via contract-approved path (use sensibleRCAU to stay in valid ranges) + // Update via ECDSA — should succeed IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( IRecurringCollector.RecurringCollectionAgreementUpdate({ agreementId: agreementId, deadline: 0, endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 50 ether, - maxOngoingTokensPerSecond: 0.5 ether, + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 7200, + conditions: 0, nonce: 1, metadata: "" }) ); - - bytes32 updateHash = _recurringCollector.hashRCAU(rcau); - approver.authorize(updateHash); + (, bytes memory updateSig) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementUpdated( rca.dataService, - address(approver), + payer, rca.serviceProvider, agreementId, uint64(block.timestamp), @@ -166,12 +194,10 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { ); vm.prank(rca.dataService); - _recurringCollector.update(rcau, ""); + _recurringCollector.update(rcau, updateSig); - // Verify updated terms IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(agreement.maxOngoingTokensPerSecond, rcau.maxOngoingTokensPerSecond); - assertEq(agreement.maxSecondsPerCollection, rcau.maxSecondsPerCollection); assertEq(agreement.updateNonce, 1); } diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index d466f3c49..be84dde2f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -76,6 +76,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { address notDataService ) public { vm.assume(fuzzyTestUpdate.fuzzyTestAccept.rca.dataService != notDataService); + vm.assume(notDataService != _proxyAdmin); (, , uint256 signerKey, bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( @@ -241,6 +242,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: rcau1.maxOngoingTokensPerSecond * 2, // Different terms minSecondsPerCollection: rcau1.minSecondsPerCollection, maxSecondsPerCollection: rcau1.maxSecondsPerCollection, + conditions: 0, nonce: 2, metadata: rcau1.metadata }); @@ -298,6 +300,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: rcau1.maxOngoingTokensPerSecond * 2, // Different terms minSecondsPerCollection: rcau1.minSecondsPerCollection, maxSecondsPerCollection: rcau1.maxSecondsPerCollection, + conditions: 0, nonce: 2, metadata: rcau1.metadata }); diff --git a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol index 22016075a..45d05c55b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW, OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; @@ -16,8 +17,8 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { MockAgreementOwner approver, IRecurringCollector.RecurringCollectionAgreement memory rca ) internal returns (bytes16) { - bytes32 agreementHash = _recurringCollector.hashRCA(rca); - approver.authorize(agreementHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); _setupValidProvision(rca.serviceProvider, rca.dataService); @@ -38,6 +39,7 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, + conditions: 0, nonce: 1, metadata: "" }) @@ -58,6 +60,7 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 2 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 7200, + conditions: 0, nonce: nonce, metadata: "" }) @@ -74,9 +77,9 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - // Authorize the update hash - bytes32 updateHash = _recurringCollector.hashRCAU(rcau); - approver.authorize(updateHash); + // Store the update offer + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.AgreementUpdated( @@ -104,43 +107,6 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { assertEq(rcau.nonce, agreement.updateNonce); } - function test_UpdateUnsigned_Revert_WhenPayerNotContract() public { - // Use the signed accept path to create an agreement with an EOA payer, - // then attempt updateUnsigned which should fail because payer isn't a contract - uint256 signerKey = 0xA11CE; - address payer = vm.addr(signerKey); - IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( - IRecurringCollector.RecurringCollectionAgreement({ - deadline: uint64(block.timestamp + 1 hours), - endsAt: uint64(block.timestamp + 365 days), - payer: payer, - dataService: makeAddr("ds"), - serviceProvider: makeAddr("sp"), - maxInitialTokens: 100 ether, - maxOngoingTokensPerSecond: 1 ether, - minSecondsPerCollection: 600, - maxSecondsPerCollection: 3600, - nonce: 1, - metadata: "" - }) - ); - - // Accept via signed path - _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); - (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); - _setupValidProvision(rca.serviceProvider, rca.dataService); - vm.prank(rca.dataService); - bytes16 agreementId = _recurringCollector.accept(rca, signature); - - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - - vm.expectRevert( - abi.encodeWithSelector(IRecurringCollector.RecurringCollectorApproverNotContract.selector, payer) - ); - vm.prank(rca.dataService); - _recurringCollector.update(rcau, ""); - } - function test_UpdateUnsigned_Revert_WhenHashNotAuthorized() public { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); @@ -163,8 +129,7 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - approver.setOverrideReturnValue(bytes4(0xdeadbeef)); - + // With stored offers, "wrong magic value" maps to "no matching offer stored" vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); _recurringCollector.update(rcau, ""); @@ -178,8 +143,8 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - bytes32 updateHash = _recurringCollector.hashRCAU(rcau); - approver.authorize(updateHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); address notDataService = makeAddr("notDataService"); vm.expectRevert( @@ -217,8 +182,8 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { // Use wrong nonce (0 instead of 1) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 0); - bytes32 updateHash = _recurringCollector.hashRCAU(rcau); - approver.authorize(updateHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorInvalidUpdateNonce.selector, @@ -231,7 +196,7 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { _recurringCollector.update(rcau, ""); } - function test_UpdateUnsigned_Revert_WhenApproverReverts() public { + function test_UpdateUnsigned_Revert_WhenNoOfferStored() public { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeSimpleRCA(address(approver)); @@ -239,9 +204,8 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - approver.setShouldRevert(true); - - vm.expectRevert("MockAgreementOwner: forced revert"); + // No offer stored — should revert with InvalidSigner + vm.expectRevert(abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidSigner.selector)); vm.prank(rca.dataService); _recurringCollector.update(rcau, ""); } @@ -257,8 +221,8 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { // Set the update deadline in the past rcau.deadline = uint64(block.timestamp - 1); - bytes32 updateHash = _recurringCollector.hashRCAU(rcau); - approver.authorize(updateHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, diff --git a/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol new file mode 100644 index 000000000..839cd146e --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +/// @notice Tests for getCollectionInfo and getAgreement view functions across agreement states. +contract RecurringCollectorViewFunctionsTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ==================== getCollectionInfo: Accepted ==================== + + function test_GetCollectionInfo_Accepted_AfterTime(FuzzyTestAccept calldata fuzzy) public { + (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + // Skip some time + skip(agreement.minSecondsPerCollection); + + // Re-read agreement (timestamps don't change but view computes based on block.timestamp) + (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); + + assertTrue(isCollectable, "Should be collectable after min time"); + assertTrue(collectionSeconds > 0, "Should have collectable seconds"); + } + + // ==================== getCollectionInfo: CanceledByServiceProvider ==================== + + function test_GetCollectionInfo_CanceledBySP(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Cancel by service provider + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + (bool isCollectable, , IRecurringCollector.AgreementNotCollectableReason reason) = _recurringCollector + .getCollectionInfo(agreementId); + + assertFalse(isCollectable, "CanceledByServiceProvider should not be collectable"); + assertEq( + uint8(reason), + uint8(IRecurringCollector.AgreementNotCollectableReason.InvalidAgreementState), + "Reason should be InvalidAgreementState" + ); + } + + // ==================== getCollectionInfo: NotAccepted ==================== + + function test_GetCollectionInfo_NotAccepted() public view { + // Non-existent agreement has state NotAccepted + bytes16 nonExistentId = bytes16(uint128(999)); + + (bool isCollectable, , IRecurringCollector.AgreementNotCollectableReason reason) = _recurringCollector + .getCollectionInfo(nonExistentId); + + assertFalse(isCollectable, "NotAccepted should not be collectable"); + assertEq( + uint8(reason), + uint8(IRecurringCollector.AgreementNotCollectableReason.InvalidAgreementState), + "Reason should be InvalidAgreementState" + ); + } + + // ==================== getCollectionInfo: CanceledByPayer same block ==================== + + function test_GetCollectionInfo_CanceledByPayer_SameBlock(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Cancel by payer in the same block as accept + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); + + // Same block cancel means no time elapsed + assertFalse(isCollectable, "Same-block payer cancel should not be collectable"); + assertEq(collectionSeconds, 0, "Should have 0 collection seconds"); + } + + // ==================== getCollectionInfo: CanceledByPayer with window ==================== + + function test_GetCollectionInfo_CanceledByPayer_WithWindow(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + // Skip time then cancel by payer + skip(rca.minSecondsPerCollection); + _cancel(rca, agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); + + assertTrue(isCollectable, "Payer cancel with elapsed time should be collectable"); + assertTrue(collectionSeconds > 0, "Should have collectable seconds"); + } + + // ==================== getAgreement: basic field checks ==================== + + function test_GetAgreement_FieldsMatch(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + + assertEq(agreement.payer, rca.payer, "payer should match"); + assertEq(agreement.dataService, rca.dataService, "dataService should match"); + assertEq(agreement.serviceProvider, rca.serviceProvider, "serviceProvider should match"); + assertEq(agreement.endsAt, rca.endsAt, "endsAt should match"); + assertEq(agreement.minSecondsPerCollection, rca.minSecondsPerCollection, "minSeconds should match"); + assertEq(agreement.maxSecondsPerCollection, rca.maxSecondsPerCollection, "maxSeconds should match"); + assertEq(agreement.maxInitialTokens, rca.maxInitialTokens, "maxInitialTokens should match"); + assertEq( + agreement.maxOngoingTokensPerSecond, + rca.maxOngoingTokensPerSecond, + "maxOngoingTokensPerSecond should match" + ); + assertEq( + uint8(agreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "state should be Accepted" + ); + assertTrue(agreement.acceptedAt > 0, "acceptedAt should be set"); + assertTrue(agreement.activeTermsHash != bytes32(0), "activeTermsHash should be set"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/utilities/Authorizable.t.sol b/packages/horizon/test/unit/utilities/Authorizable.t.sol index 66c4bb921..18ed8df54 100644 --- a/packages/horizon/test/unit/utilities/Authorizable.t.sol +++ b/packages/horizon/test/unit/utilities/Authorizable.t.sol @@ -37,8 +37,14 @@ contract AuthorizableTest is Test, Bounder { return new AuthorizableImp(_thawPeriod); } + /// @dev Override to exclude addresses that would interfere with fuzz tests + /// (e.g. proxy admin addresses that reject non-admin calls with a different error). + function assumeValidFuzzAddress(address addr) internal virtual { + vm.assume(addr != address(0)); + } + function test_AuthorizeSigner(uint256 _unboundedKey, address _authorizer) public { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); uint256 signerKey = boundKey(_unboundedKey); authHelper.authorizeSignerWithChecks(_authorizer, signerKey); @@ -141,15 +147,15 @@ contract AuthorizableTest is Test, Bounder { } function test_ThawSigner(address _authorizer, uint256 _unboundedKey, uint256 _thaw) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); uint256 signerKey = boundKey(_unboundedKey); authHelper.authorizeAndThawSignerWithChecks(_authorizer, signerKey); } function test_ThawSigner_Revert_WhenNotAuthorized(address _authorizer, address _signer) public { - vm.assume(_authorizer != address(0)); - vm.assume(_signer != address(0)); + assumeValidFuzzAddress(_authorizer); + assumeValidFuzzAddress(_signer); bytes memory expectedErr = abi.encodeWithSelector( IAuthorizable.AuthorizableSignerNotAuthorized.selector, @@ -166,7 +172,7 @@ contract AuthorizableTest is Test, Bounder { uint256 _unboundedKey, uint256 _thaw ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeAndRevokeSignerWithChecks(_authorizer, signerKey); @@ -185,7 +191,7 @@ contract AuthorizableTest is Test, Bounder { uint256 _unboundedKey, uint256 _thaw ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeAndThawSignerWithChecks(_authorizer, signerKey); @@ -198,8 +204,8 @@ contract AuthorizableTest is Test, Bounder { } function test_CancelThawSigner_Revert_When_NotAuthorized(address _authorizer, address _signer) public { - vm.assume(_authorizer != address(0)); - vm.assume(_signer != address(0)); + assumeValidFuzzAddress(_authorizer); + assumeValidFuzzAddress(_signer); bytes memory expectedErr = abi.encodeWithSelector( IAuthorizable.AuthorizableSignerNotAuthorized.selector, @@ -216,7 +222,7 @@ contract AuthorizableTest is Test, Bounder { uint256 _unboundedKey, uint256 _thaw ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeAndRevokeSignerWithChecks(_authorizer, signerKey); @@ -231,7 +237,7 @@ contract AuthorizableTest is Test, Bounder { } function test_CancelThawSigner_Revert_When_NotThawing(address _authorizer, uint256 _unboundedKey) public { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeSignerWithChecks(_authorizer, signerKey); @@ -247,15 +253,15 @@ contract AuthorizableTest is Test, Bounder { uint256 _unboundedKey, uint256 _thaw ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); uint256 signerKey = boundKey(_unboundedKey); authHelper.authorizeAndRevokeSignerWithChecks(_authorizer, signerKey); } function test_RevokeAuthorizedSigner_Revert_WhenNotAuthorized(address _authorizer, address _signer) public { - vm.assume(_authorizer != address(0)); - vm.assume(_signer != address(0)); + assumeValidFuzzAddress(_authorizer); + assumeValidFuzzAddress(_signer); bytes memory expectedErr = abi.encodeWithSelector( IAuthorizable.AuthorizableSignerNotAuthorized.selector, @@ -272,7 +278,7 @@ contract AuthorizableTest is Test, Bounder { uint256 _unboundedKey, uint256 _thaw ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeAndRevokeSignerWithChecks(_authorizer, signerKey); @@ -287,7 +293,7 @@ contract AuthorizableTest is Test, Bounder { } function test_RevokeAuthorizedSigner_Revert_WhenNotThawing(address _authorizer, uint256 _unboundedKey) public { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeSignerWithChecks(_authorizer, signerKey); @@ -303,7 +309,7 @@ contract AuthorizableTest is Test, Bounder { uint256 _thaw, uint256 _skip ) public withFuzzyThaw(_thaw) { - vm.assume(_authorizer != address(0)); + assumeValidFuzzAddress(_authorizer); (uint256 signerKey, address signer) = boundAddrAndKey(_unboundedKey); authHelper.authorizeAndThawSignerWithChecks(_authorizer, signerKey); diff --git a/packages/interfaces/contracts/horizon/IAgreementCollector.sol b/packages/interfaces/contracts/horizon/IAgreementCollector.sol new file mode 100644 index 000000000..ee8bad086 --- /dev/null +++ b/packages/interfaces/contracts/horizon/IAgreementCollector.sol @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.22; + +import { IPaymentsCollector } from "./IPaymentsCollector.sol"; + +// -- Agreement state flags -- +// REGISTERED, ACCEPTED are monotonic (once set, never cleared). +// All other flags are clearable — cleared when pending terms are accepted. + +/// @dev Offer exists in storage +uint16 constant REGISTERED = 1; +/// @dev Provider accepted terms +uint16 constant ACCEPTED = 2; +/// @dev collectableUntil has been reduced, collection capped (clearable) +uint16 constant NOTICE_GIVEN = 4; +/// @dev Nothing to collect in current state (clearable — cleared on new terms promotion) +uint16 constant SETTLED = 8; + +// -- Who-initiated flags (clearable, meaningful when NOTICE_GIVEN is set) -- + +/// @dev Notice given by payer +uint16 constant BY_PAYER = 16; +/// @dev Notice given by provider (forfeit — immediate SETTLED) +uint16 constant BY_PROVIDER = 32; +/// @dev Notice given by data service +uint16 constant BY_DATA_SERVICE = 64; + +// -- Update-origin flag -- + +/// @dev Terms originated from an RCAU (update), not the initial RCA. +/// Set on agreement state when active terms come from an accepted or pre-acceptance update. +/// ORed into returned state by getAgreementDetails for pending versions (index 1). +uint16 constant UPDATE = 128; + +// -- Togglable option flags (set via accept options parameter) -- + +/// @dev Provider opts in to automatic update on final collect +uint16 constant AUTO_UPDATE = 256; + +// -- Lifecycle flags (set by the collector during auto-update, clearable) -- + +/// @dev Active terms were promoted via auto-update (not explicit provider accept) +uint16 constant AUTO_UPDATED = 512; + +// -- Offer type constants -- + +/// @dev Create a new agreement +uint8 constant OFFER_TYPE_NEW = 0; +/// @dev Update an existing agreement +uint8 constant OFFER_TYPE_UPDATE = 1; + +// -- Cancel scope constants -- + +/// @dev Cancel targets active terms +uint8 constant SCOPE_ACTIVE = 1; +/// @dev Cancel targets pending offers +uint8 constant SCOPE_PENDING = 2; + +// -- Offer option constants (for unsigned offer path) -- + +/// @dev Reduce collectableUntil and set NOTICE_GIVEN | BY_PAYER on the agreement +uint16 constant WITH_NOTICE = 1; +/// @dev Revert if the targeted version has already been accepted +uint16 constant IF_NOT_ACCEPTED = 2; + +/** + * @title Base interface for agreement-based payment collectors + * @notice Base interface for agreement-based payment collectors. + * @author Edge & Node + * @dev Defines the generic lifecycle operations shared by all agreement-based + * collectors. Concrete collectors (e.g. {IRecurringCollector}) extend this + * with agreement-type-specific structures, methods, and validation. + * Inherits {IPaymentsCollector} for the collect() entry point. + * Does not prescribe pausability or signer authorization — those are + * implementation concerns for concrete collectors. + */ +interface IAgreementCollector is IPaymentsCollector { + // -- Structs -- + + /** + * @notice Agreement details: participants, version hash, and state flags. + * Returned by {offer} and {getAgreementDetails}. + * @param agreementId The agreement ID + * @param payer The address of the payer + * @param dataService The address of the data service + * @param serviceProvider The address of the service provider + * @param versionHash The EIP-712 hash of the terms at the requested version + * @param state Agreement state flags, with UPDATE set when applicable + */ + // solhint-disable-next-line gas-struct-packing + struct AgreementDetails { + bytes16 agreementId; + address payer; + address dataService; + address serviceProvider; + bytes32 versionHash; + uint16 state; + } + + // -- Enums -- + + /// @dev The stage of a payer callback + enum PayerCallbackStage { + EligibilityCheck, + BeforeCollection, + AfterCollection + } + + // -- Methods -- + + /** + * @notice Offer a new agreement or update an existing one. + * @param offerType The type of offer (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) + * @param data ABI-encoded offer data + * @param options Bitmask of offer options + * @return Agreement details including participants and version hash + */ + function offer(uint8 offerType, bytes calldata data, uint16 options) external returns (AgreementDetails memory); + + /** + * @notice Cancel an agreement or revoke a pending update, determined by termsHash. + * @param agreementId The agreement's ID. + * @param termsHash EIP-712 hash identifying which terms to cancel (active or pending). + * @param options Bitmask — SCOPE_ACTIVE (1) targets active terms, SCOPE_PENDING (2) targets pending offers. + */ + function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external; + + /** + * @notice Get agreement details at a given version index. + * @param agreementId The ID of the agreement + * @param index The zero-based version index + * @return Agreement details including participants, version hash, and state flags + */ + function getAgreementDetails(bytes16 agreementId, uint256 index) external view returns (AgreementDetails memory); + + /** + * @notice Get the maximum tokens collectable for an agreement, scoped by active and/or pending terms. + * @param agreementId The ID of the agreement + * @param scope Bitmask: 1 = active terms, 2 = pending terms, 3 = max of both + * @return The maximum tokens that could be collected under the requested scope + */ + function getMaxNextClaim(bytes16 agreementId, uint8 scope) external view returns (uint256); + + /** + * @notice Convenience overload: returns max of both active and pending terms. + * @param agreementId The ID of the agreement + * @return The maximum tokens that could be collected + */ + function getMaxNextClaim(bytes16 agreementId) external view returns (uint256); + + /** + * @notice Original offer for a given version, enabling independent access and hash verification. + * @dev Returns the offer type (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) and the ABI-encoded + * original struct. Callers can decode and hash to verify the stored version hash. + * @param agreementId The ID of the agreement + * @param index The zero-based version index + * @return offerType OFFER_TYPE_NEW (0) or OFFER_TYPE_UPDATE (1) + * @return offerData ABI-encoded original offer struct + */ + function getAgreementOfferAt( + bytes16 agreementId, + uint256 index + ) external view returns (uint8 offerType, bytes memory offerData); +} diff --git a/packages/interfaces/contracts/horizon/IAgreementOwner.sol b/packages/interfaces/contracts/horizon/IAgreementOwner.sol index 00de00f9e..03750789d 100644 --- a/packages/interfaces/contracts/horizon/IAgreementOwner.sol +++ b/packages/interfaces/contracts/horizon/IAgreementOwner.sol @@ -7,32 +7,16 @@ pragma solidity ^0.8.22; * @notice Callbacks that RecurringCollector invokes on contract payers (payers with * deployed code, as opposed to EOA payers that use ECDSA signatures). * - * Three callbacks: - * - {approveAgreement}: gate — called during accept/update to verify authorization. - * Uses the magic-value pattern (return selector on success). Called with RCA hash - * on accept, RCAU hash on update; namespaces don't collide (different EIP712 type hashes). + * Collection callbacks: * - {beforeCollection}: called before PaymentsEscrow.collect() so the payer can top up * escrow if needed. Only acts when the escrow balance is short for the collection. * - {afterCollection}: called after collection so the payer can reconcile escrow state. * Both collection callbacks are wrapped in try/catch — reverts do not block collection. * - * No per-payer authorization step is needed — the contract's code is the authorization. - * The trust chain is: governance grants operator role → operator registers - * (validates and pre-funds) → approveAgreement confirms → RC accepts/updates. - * * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ interface IAgreementOwner { - /** - * @notice Confirms this contract authorized the given agreement or update - * @dev Called by {RecurringCollector.accept} with an RCA hash or by - * {RecurringCollector.update} with an RCAU hash to verify authorization (empty authData path). - * @param agreementHash The EIP712 hash of the RCA or RCAU struct - * @return magic `IAgreementOwner.approveAgreement.selector` if authorized - */ - function approveAgreement(bytes32 agreementHash) external view returns (bytes4); - /** * @notice Called by RecurringCollector before PaymentsEscrow.collect() * @dev Allows contract payers to top up escrow if the balance is insufficient diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index ef34f11bd..1e6d37f1f 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; -import { IPaymentsCollector } from "./IPaymentsCollector.sol"; +import { IAgreementCollector } from "./IAgreementCollector.sol"; import { IGraphPayments } from "./IGraphPayments.sol"; import { IAuthorizable } from "./IAuthorizable.sol"; /** * @title Interface for the {RecurringCollector} contract * @author Edge & Node - * @dev Implements the {IPaymentCollector} interface as defined by the Graph - * Horizon payments protocol. + * @dev Extends {IAgreementCollector} with Recurring Collection Agreement (RCA) specific + * structures, methods, and validation rules. * @notice Implements a payments collector contract that can be used to collect * recurrent payments. */ -interface IRecurringCollector is IAuthorizable, IPaymentsCollector { +interface IRecurringCollector is IAuthorizable, IAgreementCollector { /// @notice The state of an agreement enum AgreementState { NotAccepted, @@ -50,6 +50,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection + * @param conditions Bitmask of payer-declared conditions (e.g. CONDITION_ELIGIBILITY_CHECK) * @param nonce A unique nonce for preventing collisions (user-chosen) * @param metadata Arbitrary metadata to extend functionality if a data service requires it * @@ -65,6 +66,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 maxOngoingTokensPerSecond; uint32 minSecondsPerCollection; uint32 maxSecondsPerCollection; + uint16 conditions; uint256 nonce; bytes metadata; } @@ -80,6 +82,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection + * @param conditions Bitmask of payer-declared conditions (e.g. CONDITION_ELIGIBILITY_CHECK) * @param nonce The nonce for preventing replay attacks (must be current nonce + 1) * @param metadata Arbitrary metadata to extend functionality if a data service requires it */ @@ -92,43 +95,49 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 maxOngoingTokensPerSecond; uint32 minSecondsPerCollection; uint32 maxSecondsPerCollection; + uint16 conditions; uint32 nonce; bytes metadata; } /** * @notice The data for an agreement - * @dev This struct is used to store the data of an agreement in the contract + * @dev This struct is used to store the data of an agreement in the contract. + * Fields are ordered for optimal storage packing (7 slots). * @param dataService The address of the data service - * @param payer The address of the payer - * @param serviceProvider The address of the service provider * @param acceptedAt The timestamp when the agreement was accepted + * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections + * @param payer The address of the payer * @param lastCollectionAt The timestamp when the agreement was last collected at + * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection + * @param serviceProvider The address of the service provider * @param endsAt The timestamp when the agreement ends + * @param updateNonce The current nonce for updates (prevents replay attacks) * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection * on top of the amount allowed for subsequent collections * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second * except for the first collection - * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections - * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection - * @param updateNonce The current nonce for updates (prevents replay attacks) + * @param activeTermsHash EIP-712 hash of the currently active terms (RCA or RCAU) * @param canceledAt The timestamp when the agreement was canceled + * @param conditions Bitmask of payer-declared conditions * @param state The state of the agreement */ struct AgreementData { - address dataService; - address payer; - address serviceProvider; - uint64 acceptedAt; - uint64 lastCollectionAt; - uint64 endsAt; - uint256 maxInitialTokens; - uint256 maxOngoingTokensPerSecond; - uint32 minSecondsPerCollection; - uint32 maxSecondsPerCollection; - uint32 updateNonce; - uint64 canceledAt; - AgreementState state; + address dataService; // 20 bytes ─┐ slot 0 (32/32) + uint64 acceptedAt; // 8 bytes ─┤ + uint32 minSecondsPerCollection; // 4 bytes ─┘ + address payer; // 20 bytes ─┐ slot 1 (32/32) + uint64 lastCollectionAt; // 8 bytes ─┤ + uint32 maxSecondsPerCollection; // 4 bytes ─┘ + address serviceProvider; // 20 bytes ─┐ slot 2 (32/32) + uint64 endsAt; // 8 bytes ─┤ + uint32 updateNonce; // 4 bytes ─┘ + uint256 maxInitialTokens; // 32 bytes ─── slot 3 + uint256 maxOngoingTokensPerSecond; // 32 bytes ─── slot 4 + bytes32 activeTermsHash; // 32 bytes ─── slot 5 + uint64 canceledAt; // 8 bytes ─┐ slot 6 (11/32) + uint16 conditions; // 2 bytes ─┤ + AgreementState state; // 1 byte ─┘ } /** @@ -239,6 +248,12 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { uint256 dataServiceCut ); + /** + * @notice Thrown when an agreement does not exist (no accepted state and no stored offer) + * @param agreementId The agreement ID that was not found + */ + error RecurringCollectorAgreementNotFound(bytes16 agreementId); + /** * @notice Thrown when accepting an agreement with a zero ID */ @@ -377,10 +392,13 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { error RecurringCollectorCollectionNotEligible(bytes16 agreementId, address serviceProvider); /** - * @notice Thrown when the contract approver is not a contract - * @param approver The address that is not a contract + * @notice Emitted when an offer (RCA or RCAU) is stored via {IAgreementCollector.offer} + * @param agreementId The agreement ID + * @param payer The payer that stored the offer + * @param offerType OFFER_TYPE_NEW or OFFER_TYPE_UPDATE + * @param offerHash The EIP-712 hash of the stored offer */ - error RecurringCollectorApproverNotContract(address approver); + event OfferStored(bytes16 indexed agreementId, address indexed payer, uint8 indexed offerType, bytes32 offerHash); /** * @notice Accept a Recurring Collection Agreement. @@ -458,26 +476,16 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector { */ function getAgreement(bytes16 agreementId) external view returns (AgreementData memory); - /** - * @notice Get the maximum tokens collectable in the next collection for an agreement. - * @dev Computes the worst-case (maximum possible) claim amount based on current on-chain - * agreement state. For active agreements, uses `endsAt` as the upper bound (not block.timestamp). - * Returns 0 for NotAccepted, CanceledByServiceProvider, or fully expired agreements. - * @param agreementId The ID of the agreement - * @return The maximum tokens that could be collected in the next collection - */ - function getMaxNextClaim(bytes16 agreementId) external view returns (uint256); - /** * @notice Get collection info for an agreement - * @param agreement The agreement data + * @param agreementId The agreement id * @return isCollectable Whether the agreement is in a valid state that allows collection attempts, * not that there are necessarily funds available to collect. * @return collectionSeconds The valid collection duration in seconds (0 if not collectable) * @return reason The reason why the agreement is not collectable (None if collectable) */ function getCollectionInfo( - AgreementData calldata agreement + bytes16 agreementId ) external view returns (bool isCollectable, uint256 collectionSeconds, AgreementNotCollectableReason reason); /** diff --git a/packages/issuance/foundry.toml b/packages/issuance/foundry.toml index 9251965b5..c30c68e03 100644 --- a/packages/issuance/foundry.toml +++ b/packages/issuance/foundry.toml @@ -20,6 +20,9 @@ evm_version = 'cancun' # Exclude test files from coverage reports no_match_coverage = "(^test/|^contracts/test/|/mocks/)" +[profile.test] +via_ir = false + [lint] exclude_lints = ["mixed-case-function", "mixed-case-variable"] ignore = ["node_modules/**", "test/node_modules/**"] diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol deleted file mode 100644 index 1bf635a1f..000000000 --- a/packages/issuance/test/unit/agreement-manager/approver.t.sol +++ /dev/null @@ -1,177 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; -import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; -import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; -import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; -import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; -import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; -import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; - -import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; -import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; - -contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerSharedTest { - /* solhint-disable graph/func-name-mixedcase */ - - // -- IAgreementOwner Tests -- - - function test_ApproveAgreement_ReturnsSelector() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - _offerAgreement(rca); - - bytes32 agreementHash = recurringCollector.hashRCA(rca); - bytes4 result = agreementManager.approveAgreement(agreementHash); - assertEq(result, IAgreementOwner.approveAgreement.selector); - } - - function test_ApproveAgreement_ReturnsZero_WhenNotAuthorized() public { - bytes32 fakeHash = keccak256("fake agreement"); - assertEq(agreementManager.approveAgreement(fakeHash), bytes4(0)); - } - - function test_ApproveAgreement_DifferentHashesAreIndependent() public { - IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - rca1.nonce = 1; - - IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( - 200 ether, - 2 ether, - 60, - 7200, - uint64(block.timestamp + 365 days) - ); - rca2.nonce = 2; - - // Only offer rca1 - _offerAgreement(rca1); - - // rca1 hash should be authorized - bytes32 hash1 = recurringCollector.hashRCA(rca1); - assertEq(agreementManager.approveAgreement(hash1), IAgreementOwner.approveAgreement.selector); - - // rca2 hash should NOT be authorized - bytes32 hash2 = recurringCollector.hashRCA(rca2); - assertEq(agreementManager.approveAgreement(hash2), bytes4(0)); - } - - // -- ERC165 Tests -- - - function test_SupportsInterface_IIssuanceTarget() public view { - assertTrue(agreementManager.supportsInterface(type(IIssuanceTarget).interfaceId)); - } - - function test_SupportsInterface_IAgreementOwner() public view { - assertTrue(agreementManager.supportsInterface(type(IAgreementOwner).interfaceId)); - } - - function test_SupportsInterface_IRecurringAgreementManagement() public view { - assertTrue(agreementManager.supportsInterface(type(IRecurringAgreementManagement).interfaceId)); - } - - function test_SupportsInterface_IRecurringEscrowManagement() public view { - assertTrue(agreementManager.supportsInterface(type(IRecurringEscrowManagement).interfaceId)); - } - - function test_SupportsInterface_IProviderEligibilityManagement() public view { - assertTrue(agreementManager.supportsInterface(type(IProviderEligibilityManagement).interfaceId)); - } - - function test_SupportsInterface_IRecurringAgreements() public view { - assertTrue(agreementManager.supportsInterface(type(IRecurringAgreements).interfaceId)); - } - - // -- IIssuanceTarget Tests -- - - function test_BeforeIssuanceAllocationChange_DoesNotRevert() public { - agreementManager.beforeIssuanceAllocationChange(); - } - - function test_SetIssuanceAllocator_OnlyGovernor() public { - address nonGovernor = makeAddr("nonGovernor"); - MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); - vm.expectRevert(); - vm.prank(nonGovernor); - agreementManager.setIssuanceAllocator(address(alloc)); - } - - function test_SetIssuanceAllocator_Governor() public { - MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); - vm.prank(governor); - agreementManager.setIssuanceAllocator(address(alloc)); - } - - // -- View Function Tests -- - - function test_GetDeficit_ZeroWhenFullyFunded() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - _offerAgreement(rca); - - // Fully funded (offerAgreement mints enough tokens) - IPaymentsEscrow.EscrowAccount memory account = agreementManager.getEscrowAccount(_collector(), indexer); - assertEq(account.balance - account.tokensThawing, agreementManager.getSumMaxNextClaim(_collector(), indexer)); - } - - function test_GetEscrowAccount_MatchesUnderlying() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - uint256 available = 500 ether; - - token.mint(address(agreementManager), available); - vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); - - IPaymentsEscrow.EscrowAccount memory expected; - (expected.balance, expected.tokensThawing, expected.thawEndTimestamp) = paymentsEscrow.escrowAccounts( - address(agreementManager), - address(recurringCollector), - indexer - ); - IPaymentsEscrow.EscrowAccount memory actual = agreementManager.getEscrowAccount(_collector(), indexer); - assertEq(actual.balance, expected.balance); - assertEq(actual.tokensThawing, expected.tokensThawing); - assertEq(actual.thawEndTimestamp, expected.thawEndTimestamp); - } - - function test_GetRequiredEscrow_ZeroForUnknownIndexer() public { - assertEq(agreementManager.getSumMaxNextClaim(_collector(), makeAddr("unknown")), 0); - } - - function test_GetAgreementMaxNextClaim_ZeroForUnknown() public view { - assertEq(agreementManager.getAgreementMaxNextClaim(bytes16(keccak256("unknown"))), 0); - } - - function test_GetIndexerAgreementCount_ZeroForUnknown() public { - assertEq(agreementManager.getProviderAgreementCount(makeAddr("unknown")), 0); - } - - /* solhint-enable graph/func-name-mixedcase */ -} diff --git a/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol index 2eae0a66e..85d1bafd7 100644 --- a/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cancelAgreement.t.sol @@ -1,11 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManagerSharedTest { @@ -21,19 +24,25 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag bytes16 agreementId = _offerAgreement(rca); - // Simulate acceptance + // Simulate acceptance, then advance time so cancel creates a non-zero claim window _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - - vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); - - vm.prank(operator); - bool gone = agreementManager.cancelAgreement(agreementId); - assertFalse(gone); // still tracked after cancel - - // Verify the mock was called - assertTrue(mockSubgraphService.canceled(agreementId)); - assertEq(mockSubgraphService.cancelCallCount(agreementId), 1); + vm.warp(block.timestamp + 10); + + // After cancel by payer with 10s elapsed: maxNextClaim = 1e18 * 10 + 100e18 = 110e18 + uint256 preMaxClaim = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + + bool gone = _cancelAgreement(agreementId); + // CanceledByPayer with remaining claim window => still tracked + assertFalse(gone); + + // Verify maxNextClaim decreased to the payer-cancel window + uint256 postMaxClaim = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + assertEq(postMaxClaim, 1 ether * 10 + 100 ether, "maxNextClaim should reflect payer-cancel window"); + assertTrue(postMaxClaim < preMaxClaim, "maxNextClaim should decrease after cancel"); } function test_CancelAgreement_ReconcileAfterCancel() public { @@ -54,15 +63,14 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag _setAgreementCanceledBySP(agreementId, rca); // CanceledBySP has maxNextClaim=0 so agreement is deleted inline - vm.prank(operator); - bool gone = agreementManager.cancelAgreement(agreementId); + bool gone = _cancelAgreement(agreementId); assertTrue(gone); // deleted inline — nothing left to claim // After cancelAgreement (which now reconciles), required escrow should decrease assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_CancelAgreement_Idempotent_CanceledByPayer() public { + function test_CancelAgreement_AlreadyCanceled_StillForwards() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -75,13 +83,12 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag // Set as CanceledByPayer (already canceled) _setAgreementCanceledByPayer(agreementId, rca, uint64(block.timestamp), uint64(block.timestamp + 1 hours), 0); - // Should succeed — idempotent, skips the external cancel call - vm.prank(operator); - bool gone = agreementManager.cancelAgreement(agreementId); - assertFalse(gone); // still tracked after cancel - - // Should NOT have called SubgraphService - assertEq(mockSubgraphService.cancelCallCount(agreementId), 0); + // cancelAgreement always forwards to collector — caller is responsible + // for knowing whether the agreement is already canceled + bool gone = _cancelAgreement(agreementId); + // Agreement may or may not be fully gone depending on collector behavior + // after re-cancel — the key invariant is that it doesn't revert + assertTrue(gone || !gone); // no-op assertion, just verify no revert } function test_CancelAgreement_Idempotent_CanceledByServiceProvider() public { @@ -99,18 +106,14 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag // Should succeed — idempotent, reconciles to update escrow // CanceledBySP has maxNextClaim=0 so agreement is deleted inline - vm.prank(operator); - bool gone = agreementManager.cancelAgreement(agreementId); + bool gone = _cancelAgreement(agreementId); assertTrue(gone); // deleted inline — nothing left to claim - // Should NOT have called SubgraphService - assertEq(mockSubgraphService.cancelCallCount(agreementId), 0); - // Required escrow should drop to 0 assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_CancelAgreement_Revert_WhenNotAccepted() public { + function test_CancelAgreement_Offered() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -120,21 +123,25 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag bytes16 agreementId = _offerAgreement(rca); - // Agreement is NotAccepted — should revert - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotAccepted.selector, agreementId) - ); - vm.prank(operator); - agreementManager.cancelAgreement(agreementId); + // Cancel an offered (not yet accepted) agreement — should succeed and clean up + bool gone = _cancelAgreement(agreementId); + assertTrue(gone); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_CancelAgreement_ReturnsTrue_WhenNotOffered() public { + function test_CancelAgreement_RejectsUnknown_WhenNotOffered() public { bytes16 fakeId = bytes16(keccak256("fake")); - // Returns true (gone) when agreement not found + // cancelAgreement is a passthrough — unknown agreement triggers AgreementRejected via callback + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + fakeId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.UnknownAgreement + ); + vm.prank(operator); - bool gone = agreementManager.cancelAgreement(fakeId); - assertTrue(gone); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), fakeId, bytes32(0), 0); } function test_CancelAgreement_Revert_WhenNotOperator() public { @@ -154,6 +161,7 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag rca.nonce ); + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; address nonOperator = makeAddr("nonOperator"); vm.expectRevert( abi.encodeWithSelector( @@ -163,10 +171,10 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag ) ); vm.prank(nonOperator); - agreementManager.cancelAgreement(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } - function test_CancelAgreement_Revert_WhenPaused() public { + function test_CancelAgreement_SucceedsWhenPaused() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -181,9 +189,10 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag agreementManager.pause(); vm.stopPrank(); - vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + // Role-gated functions should succeed even when paused + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; vm.prank(operator); - agreementManager.cancelAgreement(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } function test_CancelAgreement_EmitsEvent() public { @@ -198,10 +207,30 @@ contract RecurringAgreementManagerCancelAgreementTest is RecurringAgreementManag _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); + + _cancelAgreement(agreementId); + } + + function test_CancelAgreement_Succeeds_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + // Role-gated functions should succeed even when paused + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; vm.prank(operator); - agreementManager.cancelAgreement(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol index 33f9e5a16..a1eac4ba8 100644 --- a/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cancelWithPendingUpdate.t.sol @@ -1,10 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; /// @notice Tests that canceling an agreement correctly clears pending update escrow. @@ -43,42 +46,38 @@ contract RecurringAgreementManagerCancelWithPendingUpdateTest is RecurringAgreem ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; assertEq( agreementManager.getSumMaxNextClaim(_collector(), indexer), - originalMaxClaim + pendingMaxClaim, - "both original and pending escrow should be reserved" + pendingMaxClaim, + "escrow reserved for max of current and pending" ); // 3. Cancel the agreement — simulate CanceledByPayer with remaining collection window. // The collector still has a non-zero maxNextClaim (remaining window to collect). // updateNonce is still 0 — the pending update was never applied. - uint64 canceledAt = uint64(block.timestamp + 1 hours); - vm.warp(canceledAt); - _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); - - // Call cancelAgreement — state is already CanceledByPayer so it skips the DS call - // and goes straight to reconcile-and-cleanup. - vm.prank(operator); - bool gone = agreementManager.cancelAgreement(agreementId); - assertFalse(gone, "agreement should still exist (has remaining claims)"); + uint64 collectableUntil = uint64(block.timestamp + 1 hours); + vm.warp(collectableUntil); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, collectableUntil, 0); + + // State is CanceledByPayer — cancelAgreement rejects non-Accepted states, + // so use reconcileAgreement to trigger cleanup. + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertTrue(exists, "agreement should still exist (has remaining claims)"); // 4. BUG: The pending update can never be accepted (collector rejects updates on // canceled agreements), yet pendingUpdateMaxNextClaim is still reserved. - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); uint256 sumAfterCancel = agreementManager.getSumMaxNextClaim(_collector(), indexer); // The pending escrow should have been freed (zeroed) since the update is dead. - // This assertion demonstrates the bug — it will FAIL because the pending escrow - // is still included in sumMaxNextClaim. - assertEq( - info.pendingUpdateMaxNextClaim, - 0, - "BUG: pending update escrow should be zero after cancel (update can never be applied)" - ); + // sumMaxNextClaim should only include the base claim, not the dead pending update. assertEq( sumAfterCancel, - agreementManager.getAgreementMaxNextClaim(agreementId), + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), "BUG: sumMaxNextClaim should only include the base claim, not the dead pending update" ); } @@ -111,25 +110,25 @@ contract RecurringAgreementManagerCancelWithPendingUpdateTest is RecurringAgreem _offerAgreementUpdate(rcau); // 3. Cancel (CanceledByPayer, remaining window) - uint64 canceledAt = uint64(block.timestamp + 1 hours); - vm.warp(canceledAt); - _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); - - vm.prank(operator); - agreementManager.cancelAgreement(agreementId); - - // 4. Explicit reconcile — pending should already be cleared - agreementManager.reconcileAgreement(agreementId); - - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.pendingUpdateMaxNextClaim, 0, "pending escrow should be zero after cancel"); - assertEq(info.pendingUpdateNonce, 0, "pending nonce should be zero after cancel"); - assertEq(info.pendingUpdateHash, bytes32(0), "pending hash should be zero after cancel"); + uint64 collectableUntil = uint64(block.timestamp + 1 hours); + vm.warp(collectableUntil); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, collectableUntil, 0); + + // State is CanceledByPayer — cancelAgreement rejects non-Accepted states, + // so use reconcileAgreement to trigger cleanup. + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + // After cancel + reconcile, maxNextClaim should reflect only the remaining collection window + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertEq( + info.maxNextClaim, + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId) + ); - // 5. The dead update hash should no longer be authorized - bytes32 updateHash = recurringCollector.hashRCAU(rcau); - bytes4 result = agreementManager.approveAgreement(updateHash); - assertTrue(result != agreementManager.approveAgreement.selector, "dead hash should not be authorized"); + // The pending update can no longer be applied (collector handles hash lifecycle) } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol index e8d6c579e..4c62cc1e9 100644 --- a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol @@ -42,6 +42,7 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, nonce: nonce, + conditions: 0, metadata: "" }); agreementId = collector.generateAgreementId( @@ -68,6 +69,7 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, nonce: nonce, + conditions: 0, metadata: "" }); agreementId = recurringCollector.generateAgreementId( diff --git a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol index c8a99df8d..805ced38e 100644 --- a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol +++ b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol @@ -5,7 +5,6 @@ import { Vm } from "forge-std/Vm.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; @@ -69,6 +68,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -93,14 +94,10 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); bytes32 rcaHash = recurringCollector.hashRCA(rca); - // Hash is authorized - assertEq(agreementManager.approveAgreement(rcaHash), IAgreementOwner.approveAgreement.selector); - vm.prank(operator); agreementManager.revokeOffer(agreementId); - // Hash is cleaned up (not just stale — actually deleted) - assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); + // Offer is revoked — revokeOffer succeeded without revert } function test_RevokeOffer_CleansUpPendingUpdateHash() public { @@ -125,15 +122,10 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - bytes32 updateHash = recurringCollector.hashRCAU(rcau); - // Update hash is authorized - assertEq(agreementManager.approveAgreement(updateHash), IAgreementOwner.approveAgreement.selector); - vm.prank(operator); agreementManager.revokeOffer(agreementId); - // Both hashes cleaned up - assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); + // Offer revoked successfully } function test_Remove_CleansUpAgreementHash() public { @@ -153,7 +145,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileAgreement(agreementId); // Hash is cleaned up - assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); } function test_Remove_CleansUpPendingUpdateHash() public { @@ -185,7 +176,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileAgreement(agreementId); // Pending update hash also cleaned up - assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); } function test_Reconcile_CleansUpAppliedPendingUpdateHash() public { @@ -211,7 +201,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau); bytes32 updateHash = recurringCollector.hashRCAU(rcau); - assertEq(agreementManager.approveAgreement(updateHash), IAgreementOwner.approveAgreement.selector); // Simulate: agreement accepted with pending <= updateNonce (update was applied) recurringCollector.setAgreement( @@ -228,6 +217,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar minSecondsPerCollection: 60, maxSecondsPerCollection: 7200, updateNonce: 1, // (pending <=) + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -236,7 +227,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileAgreement(agreementId); // Pending update hash should be cleaned up after reconcile clears the applied update - assertEq(agreementManager.approveAgreement(updateHash), bytes4(0)); } function test_OfferUpdate_CleansUpReplacedPendingHash() public { @@ -263,7 +253,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau1); bytes32 hash1 = recurringCollector.hashRCAU(rcau1); - assertEq(agreementManager.approveAgreement(hash1), IAgreementOwner.approveAgreement.selector); // Second pending update replaces first (same nonce — collector hasn't accepted either) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( @@ -278,11 +267,9 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau2); // First update hash should be cleaned up - assertEq(agreementManager.approveAgreement(hash1), bytes4(0)); // Second update hash should be authorized bytes32 hash2 = recurringCollector.hashRCAU(rcau2); - assertEq(agreementManager.approveAgreement(hash2), IAgreementOwner.approveAgreement.selector); } function test_GetAgreementInfo_IncludesHashes() public { @@ -445,6 +432,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -647,7 +636,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes32 zeroHash = recurringCollector.hashRCAU(rcau1); // Zero-value hash should still be authorized - assertEq(agreementManager.approveAgreement(zeroHash), IAgreementOwner.approveAgreement.selector); // sumMaxNextClaim should be unchanged (original + 0) assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); @@ -664,11 +652,9 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau2); // Old zero-value hash should be cleaned up - assertEq(agreementManager.approveAgreement(zeroHash), bytes4(0)); // New hash should be authorized bytes32 newHash = recurringCollector.hashRCAU(rcau2); - assertEq(agreementManager.approveAgreement(newHash), IAgreementOwner.approveAgreement.selector); uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); @@ -698,7 +684,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau); bytes32 zeroHash = recurringCollector.hashRCAU(rcau); - assertEq(agreementManager.approveAgreement(zeroHash), IAgreementOwner.approveAgreement.selector); // Simulate: agreement accepted with update applied (pending nonce <= updateNonce) recurringCollector.setAgreement( @@ -715,6 +700,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, updateNonce: 1, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -723,7 +710,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar agreementManager.reconcileAgreement(agreementId); // Zero-value pending hash should be cleaned up - assertEq(agreementManager.approveAgreement(zeroHash), bytes4(0)); // Pending fields should be cleared IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); @@ -769,7 +755,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Hash is authorized again bytes32 rcaHash = recurringCollector.hashRCA(rca); - assertEq(agreementManager.approveAgreement(rcaHash), IAgreementOwner.approveAgreement.selector); } function test_ReofferAfterRemove_WithDifferentNonce() public { @@ -1115,6 +1100,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } assertEq(token.balanceOf(address(agreementManager)), 0, "Manager has no free tokens"); @@ -1237,9 +1223,5 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes32 hash1 = recurringCollector.hashRCAU(rcau1); bytes32 hash2 = recurringCollector.hashRCAU(rcau2); bytes32 hash3 = recurringCollector.hashRCAU(rcau3); - - assertEq(agreementManager.approveAgreement(hash1), bytes4(0)); - assertEq(agreementManager.approveAgreement(hash2), bytes4(0)); - assertEq(agreementManager.approveAgreement(hash3), IAgreementOwner.approveAgreement.selector); } } diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index 51abcf32c..cd144d58a 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -109,6 +109,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan // Burn RAM's free balance so it can't cover a JIT deposit without distribution uint256 freeBalance = token.balanceOf(address(agreementManager)); vm.prank(address(agreementManager)); + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), freeBalance); assertEq(token.balanceOf(address(agreementManager)), 0); diff --git a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol index 9f2889c2a..585dff852 100644 --- a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol @@ -228,6 +228,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } @@ -905,6 +906,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } } @@ -1552,6 +1554,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } diff --git a/packages/issuance/test/unit/agreement-manager/helper.t.sol b/packages/issuance/test/unit/agreement-manager/helper.t.sol index 5a8c95722..962dab945 100644 --- a/packages/issuance/test/unit/agreement-manager/helper.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helper.t.sol @@ -350,6 +350,8 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { minSecondsPerCollection: rcau.minSecondsPerCollection, maxSecondsPerCollection: rcau.maxSecondsPerCollection, updateNonce: 1, // matches pending nonce, so update was applied + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) diff --git a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol index ac5e3caa7..4c21e4d22 100644 --- a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol @@ -42,6 +42,7 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, nonce: nonce, + conditions: 0, metadata: "" }); } diff --git a/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol index 8a56264f2..e4684093f 100644 --- a/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol @@ -61,6 +61,8 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: uint64(block.timestamp), state: IRecurringCollector.AgreementState.CanceledByServiceProvider }) diff --git a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol index fdf933cd3..5a560d8e2 100644 --- a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol +++ b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol @@ -47,6 +47,7 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest minSecondsPerCollection: 60, maxSecondsPerCollection: maxSec, nonce: nonce, + conditions: 0, metadata: "" }); } @@ -79,6 +80,8 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: uint64(block.timestamp), state: IRecurringCollector.AgreementState.CanceledByServiceProvider }) diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol index 3b3e1528e..7b7d5b728 100644 --- a/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol @@ -11,14 +11,14 @@ contract MockIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { uint256 public distributeCallCount; uint256 public lastDistributedBlock; - MockGraphToken public immutable graphToken; - address public immutable target; + MockGraphToken public immutable GRAPH_TOKEN; + address public immutable TARGET; uint256 public mintPerDistribution; bool public shouldRevert; constructor(MockGraphToken _graphToken, address _target) { - graphToken = _graphToken; - target = _target; + GRAPH_TOKEN = _graphToken; + TARGET = _target; } /// @notice Set how many tokens to mint to the target on each distribution call @@ -37,13 +37,19 @@ contract MockIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { if (lastDistributedBlock == block.number) return block.number; lastDistributedBlock = block.number; if (mintPerDistribution > 0) { - graphToken.mint(target, mintPerDistribution); + GRAPH_TOKEN.mint(TARGET, mintPerDistribution); } return block.number; } function getTargetIssuancePerBlock(address) external pure override returns (TargetIssuancePerBlock memory) { - return TargetIssuancePerBlock(0, 0, 0, 0); + return + TargetIssuancePerBlock({ + allocatorIssuanceRate: 0, + allocatorIssuanceBlockAppliedTo: 0, + selfIssuanceRate: 0, + selfIssuanceBlockAppliedTo: 0 + }); } function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol index 7cab89243..5eca5de7d 100644 --- a/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol @@ -28,6 +28,7 @@ contract MockPaymentsEscrow is IPaymentsEscrow { } function deposit(address collector, address receiver, uint256 tokens) external { + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transferFrom(msg.sender, address(this), tokens); accounts[msg.sender][collector][receiver].balance += tokens; } @@ -81,6 +82,7 @@ contract MockPaymentsEscrow is IPaymentsEscrow { account.balance -= tokens; account.tokensThawing = 0; account.thawEndTimestamp = 0; + // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(msg.sender, tokens); } diff --git a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol index 6b40e5933..7b01ac08e 100644 --- a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol +++ b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol @@ -42,6 +42,7 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage minSecondsPerCollection: 60, maxSecondsPerCollection: maxSecondsPerCollection, nonce: nonce, + conditions: 0, metadata: "" }); agreementId = collector.generateAgreementId( diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index 025b32630..65b41ac88 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -71,8 +71,6 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh // The update hash should be authorized for the IAgreementOwner callback bytes32 updateHash = recurringCollector.hashRCAU(rcau); - bytes4 result = agreementManager.approveAgreement(updateHash); - assertEq(result, agreementManager.approveAgreement.selector); } function test_OfferUpdate_FundsEscrow() public { @@ -336,6 +334,8 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh minSecondsPerCollection: 60, maxSecondsPerCollection: 7200, updateNonce: 1, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -356,7 +356,6 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh // Verify pending state was set IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2Check = rcau2; bytes32 updateHash = recurringCollector.hashRCAU(rcau2Check); - assertEq(agreementManager.approveAgreement(updateHash), agreementManager.approveAgreement.selector); } function test_OfferUpdate_Revert_Nonce1_AfterFirstAccepted() public { @@ -397,6 +396,8 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh minSecondsPerCollection: 60, maxSecondsPerCollection: 7200, updateNonce: 1, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) diff --git a/packages/issuance/test/unit/agreement-manager/reconcile.t.sol b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol index b2d45f413..46572be92 100644 --- a/packages/issuance/test/unit/agreement-manager/reconcile.t.sol +++ b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol @@ -260,6 +260,8 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar minSecondsPerCollection: rcau.minSecondsPerCollection, maxSecondsPerCollection: rcau.maxSecondsPerCollection, updateNonce: 1, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) diff --git a/packages/issuance/test/unit/agreement-manager/register.t.sol b/packages/issuance/test/unit/agreement-manager/register.t.sol index e00567a9a..9fd4869db 100644 --- a/packages/issuance/test/unit/agreement-manager/register.t.sol +++ b/packages/issuance/test/unit/agreement-manager/register.t.sol @@ -126,8 +126,6 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe // The agreement hash should be authorized for the IAgreementOwner callback bytes32 agreementHash = recurringCollector.hashRCA(rca); - bytes4 result = agreementManager.approveAgreement(agreementHash); - assertEq(result, agreementManager.approveAgreement.selector); } function test_Offer_MultipleAgreements_SameIndexer() public { diff --git a/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol index 2ad9d1bca..04e10a231 100644 --- a/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol @@ -54,8 +54,6 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen // The update hash should no longer be authorized bytes32 updateHash = recurringCollector.hashRCAU(rcau); - bytes4 result = agreementManager.approveAgreement(updateHash); - assertTrue(result != agreementManager.approveAgreement.selector, "hash should not be authorized"); } function test_RevokeAgreementUpdate_EmitsEvent() public { @@ -141,6 +139,8 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen minSecondsPerCollection: rcau.minSecondsPerCollection, maxSecondsPerCollection: rcau.maxSecondsPerCollection, updateNonce: 1, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) diff --git a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol index 8f69e20d0..732ef7f87 100644 --- a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol +++ b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol @@ -46,13 +46,11 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh // Hash is authorized before revoke bytes32 rcaHash = recurringCollector.hashRCA(rca); - agreementManager.approveAgreement(rcaHash); // should not revert vm.prank(operator); agreementManager.revokeOffer(agreementId); // Hash should be rejected after revoke (agreement no longer exists) - assertEq(agreementManager.approveAgreement(rcaHash), bytes4(0)); } function test_RevokeOffer_ClearsPendingUpdate() public { diff --git a/packages/issuance/test/unit/agreement-manager/shared.t.sol b/packages/issuance/test/unit/agreement-manager/shared.t.sol index 97056e564..2514306d8 100644 --- a/packages/issuance/test/unit/agreement-manager/shared.t.sol +++ b/packages/issuance/test/unit/agreement-manager/shared.t.sol @@ -113,6 +113,7 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, nonce: 1, + conditions: 0, metadata: "" }); } @@ -163,6 +164,7 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, nonce: nonce, + conditions: 0, metadata: "" }); } @@ -195,6 +197,8 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) @@ -220,6 +224,8 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: uint64(block.timestamp), state: IRecurringCollector.AgreementState.CanceledByServiceProvider }) @@ -248,6 +254,8 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: canceledAt, state: IRecurringCollector.AgreementState.CanceledByPayer }) @@ -275,6 +283,8 @@ contract RecurringAgreementManagerSharedTest is Test { minSecondsPerCollection: rca.minSecondsPerCollection, maxSecondsPerCollection: rca.maxSecondsPerCollection, updateNonce: 0, + conditions: 0, + activeTermsHash: bytes32(0), canceledAt: 0, state: IRecurringCollector.AgreementState.Accepted }) diff --git a/packages/issuance/test/unit/common/enumerableSetUtil.t.sol b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol index 668f1e797..96be9ab15 100644 --- a/packages/issuance/test/unit/common/enumerableSetUtil.t.sol +++ b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol @@ -115,6 +115,7 @@ contract EnumerableSetUtilTest is Test { assertEq(result.length, 0); } + // forge-lint: disable(unsafe-typecast) function test_GetPageBytes16_ReturnsAllElements() public { bytes32 b1 = bytes32(bytes16(hex"00010002000300040005000600070008")); bytes32 b2 = bytes32(bytes16(hex"000a000b000c000d000e000f00100011")); @@ -188,5 +189,7 @@ contract EnumerableSetUtilTest is Test { assertEq(result.length, 0); } + // forge-lint: enable(unsafe-typecast) + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index c68ec1f34..1aa2b9677 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -541,7 +541,7 @@ library IndexingAgreement { ); // Get collection info from RecurringCollector (single source of truth for temporal logic) (bool isCollectable, uint256 collectionSeconds, ) = _directory().recurringCollector().getCollectionInfo( - wrapper.collectorAgreement + params.agreementId ); require(_isValid(wrapper) && isCollectable, IndexingAgreementNotCollectable(params.agreementId)); diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index ccf3880ab..6b2bbb6c5 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -44,6 +44,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); + rca.conditions = 0; bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); @@ -77,6 +78,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); + rca.conditions = 0; bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); // Cancel the indexing agreement by the payer diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index 32e7ff1e7..8bfdca3dc 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -184,6 +184,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun rca.metadata = abi.encode(metadata); rca = _recurringCollectorHelper.sensibleRCA(rca); + rca.conditions = 0; ( IRecurringCollector.RecurringCollectionAgreement memory signedRca, @@ -267,7 +268,10 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun rca.dataService = address(subgraphService); rca.metadata = abi.encode(metadata); - return _recurringCollectorHelper.sensibleRCA(rca); + rca = _recurringCollectorHelper.sensibleRCA(rca); + // Zero conditions for EOA payers — CONDITION_ELIGIBILITY_CHECK requires ERC-165 + rca.conditions = 0; + return rca; } function _generateAcceptableSignedRCAU( @@ -300,7 +304,9 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun _ctx.ctxInternal.seed.termsV1.tokensPerEntityPerSecond ) ); - return _recurringCollectorHelper.sensibleRCAU(rcau); + rcau = _recurringCollectorHelper.sensibleRCAU(rcau); + rcau.conditions = 0; + return rcau; } function _requireIndexer(Context storage _ctx, address _indexer) internal view returns (IndexerState memory) { From 38b090c2b4f537f0d24d0a903e036a7946035f0e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:49:48 +0000 Subject: [PATCH 066/157] fix(collector): harden payer callbacks, add opt-in eligibility gate (TRST-H-1, H-2, H-4, L-1, SR-4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Payer callbacks (beforeCollection, afterCollection, isEligible) now use gas-capped low-level call/staticcall instead of try/catch, preventing gas siphoning via the 63/64 rule (H-1) and caller-side ABI decode reverts from malformed returndata (H-2). A gasleft() guard before each callback reverts when insufficient gas remains (L-1). Failed callbacks emit PayerCallbackFailed for off-chain monitoring (SR-4). Eligibility checking is now opt-in via a conditions bitmask on RCA/RCAU. CONDITION_ELIGIBILITY_CHECK gates the IProviderEligibility staticcall at collection time. At acceptance, _requireEligibilityCapability validates ERC-165 support — an EOA without code cannot set this flag, closing the EIP-7702 attack vector where an EOA later acquires code to block collection (H-4). --- .../collectors/RecurringCollector.sol | 116 ++++++++++++++---- .../contracts/horizon/IRecurringCollector.sol | 23 ++++ packages/issuance/audits/PR1301/TRST-H-1.md | 4 + packages/issuance/audits/PR1301/TRST-H-2.md | 4 + packages/issuance/audits/PR1301/TRST-H-4.md | 4 + packages/issuance/audits/PR1301/TRST-L-1.md | 4 + packages/issuance/audits/PR1301/TRST-L-2.md | 4 + packages/issuance/audits/PR1301/TRST-SR-4.md | 10 ++ 8 files changed, 147 insertions(+), 22 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 2bf1607cc..963ce668f 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.27; import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Authorizable } from "../../utilities/Authorizable.sol"; import { GraphDirectory } from "../../utilities/GraphDirectory.sol"; // solhint-disable-next-line no-unused-import import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol"; // for @inheritdoc -import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IAgreementCollector, @@ -41,6 +41,14 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC /// @notice The minimum number of seconds that must be between two collections uint32 public constant MIN_SECONDS_COLLECTION_WINDOW = 600; + /// @notice Condition flag: agreement requires eligibility checks before collection + uint16 public constant CONDITION_ELIGIBILITY_CHECK = 1; + + /// @notice Maximum gas forwarded to payer contract callbacks (beforeCollection / afterCollection). + /// Caps gas available to payer implementations, preventing 63/64-rule gas siphoning attacks + /// that could starve the core collect() call of gas. + uint256 private constant MAX_PAYER_CALLBACK_GAS = 1_500_000; + /* solhint-disable gas-small-strings */ /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct bytes32 public constant EIP712_RCA_TYPEHASH = @@ -144,6 +152,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ); _requireValidCollectionWindowParams(_rca.endsAt, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection); + _requirePayerToSupportEligibilityCheck(_rca.payer, _rca.conditions); AgreementData storage agreement = _getAgreementStorage(agreementId); // check that the agreement is not already accepted @@ -560,23 +569,9 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } agreement.lastCollectionAt = uint64(block.timestamp); - // Hard eligibility gate for contract payers that opt in via ERC165 - if (0 < tokensToCollect && 0 < agreement.payer.code.length) { - try IERC165(agreement.payer).supportsInterface(type(IProviderEligibility).interfaceId) returns ( - bool supported - ) { - if (supported) { - require( - IProviderEligibility(agreement.payer).isEligible(agreement.serviceProvider), - RecurringCollectorCollectionNotEligible(_params.agreementId, agreement.serviceProvider) - ); - } - } catch {} - // Let contract payers top up escrow if short - try IAgreementOwner(agreement.payer).beforeCollection(_params.agreementId, tokensToCollect) {} catch {} - } - if (0 < tokensToCollect) { + _preCollectCallbacks(agreement, _params.agreementId, tokensToCollect); + _graphPaymentsEscrow().collect( _paymentType, agreement.payer, @@ -607,15 +602,91 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC _params.dataServiceCut ); - // Notify contract payers so they can reconcile escrow in the same transaction - if (0 < agreement.payer.code.length) { - try IAgreementOwner(agreement.payer).afterCollection(_params.agreementId, tokensToCollect) {} catch {} - } - + if (0 < tokensToCollect) _postCollectCallback(agreement.payer, _params.agreementId, tokensToCollect); return tokensToCollect; } /* solhint-enable function-max-lines */ + /** + * @notice Validates that a contract payer supports IProviderEligibility via ERC-165. + * @param payer The payer address to validate + * @param conditions The conditions bitmask + */ + function _requirePayerToSupportEligibilityCheck(address payer, uint16 conditions) private view { + if (conditions & CONDITION_ELIGIBILITY_CHECK != 0) { + require( + ERC165Checker.supportsInterface(payer, type(IProviderEligibility).interfaceId), + RecurringCollectorPayerDoesNotSupportEligibilityInterface(payer) + ); + } + } + + /** + * @notice Executes pre-collection callbacks: eligibility check and beforeCollection notification. + * @dev Extracted from _collect to reduce stack depth for coverage builds. + * @param agreement The agreement storage data + * @param agreementId The agreement ID + * @param tokensToCollect The amount of tokens to collect + */ + function _preCollectCallbacks( + AgreementData storage agreement, + bytes16 agreementId, + uint256 tokensToCollect + ) private { + address payer = agreement.payer; + address provider = agreement.serviceProvider; + // Payer callbacks use gas-capped low-level calls to prevent gas siphoning and + // caller-side ABI decode reverts. Failures emit events but do not block collection. + + if ((agreement.conditions & CONDITION_ELIGIBILITY_CHECK) != 0) { + // 64/63 accounts for EIP-150 63/64 gas forwarding rule. + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + + // Eligibility gate (opt-in via conditions bitmask): low-level staticcall avoids + // caller-side ABI decode reverts. Only an explicit return of 0 blocks collection; + // reverts, short returndata, and malformed responses are treated as "no opinion" + // (collection proceeds). + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory result) = payer.staticcall{ gas: MAX_PAYER_CALLBACK_GAS }( + abi.encodeCall(IProviderEligibility.isEligible, (provider)) + ); + if (success && !(result.length < 32) && abi.decode(result, (uint256)) == 0) + revert RecurringCollectorCollectionNotEligible(agreementId, provider); + if (!success || result.length < 32) + emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.EligibilityCheck); + } + + if (payer.code.length != 0 && payer != msg.sender) { + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + + // solhint-disable-next-line avoid-low-level-calls + (bool beforeOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( + abi.encodeCall(IAgreementOwner.beforeCollection, (agreementId, tokensToCollect)) + ); + if (!beforeOk) emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.BeforeCollection); + } + } + + /** + * @notice Executes post-collection callback: afterCollection notification. + * @dev Extracted from _collect to reduce stack depth for coverage builds. + * @param payer The payer address + * @param agreementId The agreement ID + * @param tokensToCollect The amount of tokens collected + */ + function _postCollectCallback(address payer, bytes16 agreementId, uint256 tokensToCollect) private { + // Notify contract payers so they can reconcile escrow in the same transaction. + if (payer != msg.sender && payer.code.length != 0) { + // 64/63 accounts for EIP-150 63/64 gas forwarding rule. + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + // solhint-disable-next-line avoid-low-level-calls + (bool afterOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( + abi.encodeCall(IAgreementOwner.afterCollection, (agreementId, tokensToCollect)) + ); + if (!afterOk) emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.AfterCollection); + } + } + /** * @notice Requires that the collection window parameters are valid. * @@ -842,6 +913,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC ); _requireValidCollectionWindowParams(_rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection); + _requirePayerToSupportEligibilityCheck(_agreement.payer, _rcau.conditions); // Reverts on overflow — rejecting excessive terms that could prevent collection _rcau.maxOngoingTokensPerSecond * _rcau.maxSecondsPerCollection * 1024; diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 1e6d37f1f..b518c708e 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -391,6 +391,29 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ error RecurringCollectorCollectionNotEligible(bytes16 agreementId, address serviceProvider); + /** + * @notice Thrown when an offer sets CONDITION_ELIGIBILITY_CHECK but the payer + * does not support IProviderEligibility (via ERC-165) + * @param payer The payer address + */ + error RecurringCollectorPayerDoesNotSupportEligibilityInterface(address payer); + + /** + * @notice Thrown when the caller does not provide enough gas for the payer callback + * after collection + */ + error RecurringCollectorInsufficientCallbackGas(); + + /** + * @notice Emitted when a payer callback (beforeCollection / afterCollection) reverts. + * @dev The try/catch ensures provider liveness but this event enables off-chain + * monitoring to detect repeated failures and trigger reconciliation. + * @param agreementId The agreement ID + * @param payer The payer contract whose callback reverted + * @param stage Whether the failure occurred before or after collection + */ + event PayerCallbackFailed(bytes16 indexed agreementId, address indexed payer, PayerCallbackStage stage); + /** * @notice Emitted when an offer (RCA or RCAU) is stored via {IAgreementCollector.offer} * @param agreementId The agreement ID diff --git a/packages/issuance/audits/PR1301/TRST-H-1.md b/packages/issuance/audits/PR1301/TRST-H-1.md index c025974b4..f250ee55c 100644 --- a/packages/issuance/audits/PR1301/TRST-H-1.md +++ b/packages/issuance/audits/PR1301/TRST-H-1.md @@ -20,3 +20,7 @@ Enforce a minimum gas reservation before each callback. Before calling `beforeCo ## Team Response TBD + +--- + +Fixed. Added `MAX_PAYER_CALLBACK_GAS` constant (1,500,000 gas) in `RecurringCollector._collect()`. All external calls to payer contracts (`isEligible`, `beforeCollection`, `afterCollection`) now use gas-capped low-level `call`/`staticcall`, preventing gas siphoning via the 63/64 forwarding rule. A `gasleft()` guard before the callback block reverts with `RecurringCollectorInsufficientCallbackGas` when insufficient gas remains, ensuring core payment logic always has enough gas to complete. diff --git a/packages/issuance/audits/PR1301/TRST-H-2.md b/packages/issuance/audits/PR1301/TRST-H-2.md index a0c261f48..0f2acbffa 100644 --- a/packages/issuance/audits/PR1301/TRST-H-2.md +++ b/packages/issuance/audits/PR1301/TRST-H-2.md @@ -20,3 +20,7 @@ Avoid receiving and decoding values from untrusted contract calls. This can be d ## Team Response TBD + +--- + +Fixed. Replaced the `supportsInterface` → `isEligible` two-step with a single direct `isEligible` low-level `staticcall` with gas cap. Returndata is validated for length (>= 32 bytes) and decoded as `uint256`. Only an explicit return of `0` blocks collection; reverts, short returndata, and malformed responses are treated as "no opinion" (collection proceeds), with a `PayerCallbackFailed` event emitted for observability. diff --git a/packages/issuance/audits/PR1301/TRST-H-4.md b/packages/issuance/audits/PR1301/TRST-H-4.md index d7013dde9..80b4c4195 100644 --- a/packages/issuance/audits/PR1301/TRST-H-4.md +++ b/packages/issuance/audits/PR1301/TRST-H-4.md @@ -22,3 +22,7 @@ Record whether the payer had code at agreement acceptance time by adding a bool ## Team Response TBD + +--- + +Eligibility checks are now opt-in via the `CONDITION_ELIGIBILITY_CHECK` flag, set explicitly in the agreement terms. Providers agree to eligibility gating by accepting an agreement that includes this condition. When the flag is set, the payer must pass an ERC-165 `supportsInterface` check for `IProviderEligibility` at offer time. An EOA cannot pass this check, so an EOA cannot create an agreement with eligibility gating enabled. diff --git a/packages/issuance/audits/PR1301/TRST-L-1.md b/packages/issuance/audits/PR1301/TRST-L-1.md index 7c7a14f43..512e00e98 100644 --- a/packages/issuance/audits/PR1301/TRST-L-1.md +++ b/packages/issuance/audits/PR1301/TRST-L-1.md @@ -20,3 +20,7 @@ Enforce a minimum gas forwarding requirement for the `afterCollection()` callbac ## Team Response TBD + +--- + +A `gasleft()` guard before each payer callback (`isEligible`, `beforeCollection`, `afterCollection`) reverts the entire collection when insufficient gas remains. Callbacks use low-level `call`/`staticcall` with gas cap (`MAX_PAYER_CALLBACK_GAS`); failures emit `PayerCallbackFailed` for observability but do not block collection. diff --git a/packages/issuance/audits/PR1301/TRST-L-2.md b/packages/issuance/audits/PR1301/TRST-L-2.md index 29491122e..3fd0d45e4 100644 --- a/packages/issuance/audits/PR1301/TRST-L-2.md +++ b/packages/issuance/audits/PR1301/TRST-L-2.md @@ -20,3 +20,7 @@ The `pendingMaxNextClaim` should be computed as stated above, then reduced by th ## Team Response TBD + +--- + +Fixed. RAM now delegates all max-claim estimates to the collector via `IAgreementCollector.getMaxNextClaim(agreementId)`, which returns `max(active, pending)` — only the larger of current or pending terms is reserved, not both additively. The RC's `_getMaxNextClaimScoped` computes active and pending claims independently and returns the maximum, ensuring per-agreement escrow contribution reflects the worst-case single-term scenario. diff --git a/packages/issuance/audits/PR1301/TRST-SR-4.md b/packages/issuance/audits/PR1301/TRST-SR-4.md index 18c55ee81..e9502f2ec 100644 --- a/packages/issuance/audits/PR1301/TRST-SR-4.md +++ b/packages/issuance/audits/PR1301/TRST-SR-4.md @@ -9,3 +9,13 @@ The RecurringCollector wraps all payer callbacks (`beforeCollection()`, `afterCo This creates a systemic tension: the try/catch is necessary for liveness (ensuring providers can collect), but it trades state consistency for availability. Over time, if callbacks fail repeatedly (due to gas issues, contract bugs, or the stale snapshot issue in TRST-H-3), the divergence between the RAM's internal accounting and the actual escrow state can compound silently with no on-chain signal. There is no event emitted when a callback fails, making it difficult for off-chain monitoring to detect and respond to these silent failures. + +## Team Response + +TBD + +--- + +Non-reverting callbacks are intentional — collector liveness takes priority over payer state updates. Callbacks now use low-level `call`/`staticcall` with gas caps instead of try/catch. The snap-refresh fix (TRST-H-3) ensures the next successful `_reconcileProviderEscrow` call self-corrects any divergence. Permissionless `reconcileAgreement` and `reconcileProvider` provide external recovery paths. + +Failed callbacks emit `PayerCallbackFailed(agreementId, payer, stage)` with a `PayerCallbackStage` enum (`EligibilityCheck`, `BeforeCollection`, `AfterCollection`), giving off-chain monitoring a signal to detect failures and trigger reconciliation. From 5b4100543a0e55eb46ef5db2308a273ca201097f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 21:16:54 +0000 Subject: [PATCH 067/157] fix: compiler stack overflow --- .../collectors/RecurringCollector.sol | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 963ce668f..044d106da 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -798,22 +798,28 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return The EIP712 hash of the RCA */ function _hashRCA(RecurringCollectionAgreement memory _rca) private view returns (bytes32) { + // Split abi.encode into two halves to avoid stack-too-deep without optimizer return _hashTypedDataV4( keccak256( - abi.encode( - EIP712_RCA_TYPEHASH, - _rca.deadline, - _rca.endsAt, - _rca.payer, - _rca.dataService, - _rca.serviceProvider, - _rca.maxInitialTokens, - _rca.maxOngoingTokensPerSecond, - _rca.minSecondsPerCollection, - _rca.maxSecondsPerCollection, - _rca.nonce, - keccak256(_rca.metadata) + bytes.concat( + abi.encode( + EIP712_RCA_TYPEHASH, + _rca.deadline, + _rca.endsAt, + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.maxInitialTokens + ), + abi.encode( + _rca.maxOngoingTokensPerSecond, + _rca.minSecondsPerCollection, + _rca.maxSecondsPerCollection, + _rca.conditions, + _rca.nonce, + keccak256(_rca.metadata) + ) ) ) ); @@ -825,20 +831,26 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return The EIP712 hash of the RCAU */ function _hashRCAU(RecurringCollectionAgreementUpdate memory _rcau) private view returns (bytes32) { + // Split abi.encode into two halves to avoid stack-too-deep without optimizer return _hashTypedDataV4( keccak256( - abi.encode( - EIP712_RCAU_TYPEHASH, - _rcau.agreementId, - _rcau.deadline, - _rcau.endsAt, - _rcau.maxInitialTokens, - _rcau.maxOngoingTokensPerSecond, - _rcau.minSecondsPerCollection, - _rcau.maxSecondsPerCollection, - _rcau.nonce, - keccak256(_rcau.metadata) + bytes.concat( + abi.encode( + EIP712_RCAU_TYPEHASH, + _rcau.agreementId, + _rcau.deadline, + _rcau.endsAt, + _rcau.maxInitialTokens, + _rcau.maxOngoingTokensPerSecond + ), + abi.encode( + _rcau.minSecondsPerCollection, + _rcau.maxSecondsPerCollection, + _rcau.conditions, + _rcau.nonce, + keccak256(_rcau.metadata) + ) ) ) ); From 608346eb22043841fd7f59330fabe96453d05953 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:49:06 +0000 Subject: [PATCH 068/157] refactor(RAM): replace set-based range views with indexed accessors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace getCollectors, getCollectorProviders, getProviderAgreements (and their paginated overloads), getCollectorProviderCount, getProviderAgreementCount, getPairAgreementCount, and getTotalAgreementCount with indexed accessors: getCollectorAt, getProviderCount/At, getAgreementCount/At, and getEscrowSnap. Remove EnumerableSetUtil import and using statements. The getPage and getPageBytes16 helpers inline substantial library code at each call site — six call sites pushed RAM over the 24576-byte Spurious Dragon deployable bytecode limit. Also switches view param types from IRecurringCollector to IAgreementCollector and renames getSumMaxNextClaimAll to getSumMaxNextClaim to match the updated IRecurringAgreements interface. Does not compile: new accessors reference future hierarchical storage ($.collectors[c].providers[p], $.collectorSet) introduced in a later commit. --- .../agreement/IRecurringAgreementHelper.sol | 2 - .../agreement/IRecurringAgreements.sol | 239 ++++++++---------- .../agreement/RecurringAgreementManager.sol | 85 +++---- 3 files changed, 133 insertions(+), 193 deletions(-) diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol index 7436c9274..d6132fad0 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol @@ -23,7 +23,6 @@ interface IRecurringAgreementHelper { * @param tokenBalance GRT balance available to the manager * @param sumMaxNextClaimAll Global sum of maxNextClaim across all (collector, provider) pairs * @param totalEscrowDeficit Total unfunded escrow across all pairs - * @param totalAgreementCount Total number of tracked agreements * @param escrowBasis Configured escrow level (Full / OnDemand / JustInTime) * @param minOnDemandBasisThreshold Threshold for OnDemand basis (numerator over 256) * @param minFullBasisMargin Margin for Full basis (added to 256) @@ -33,7 +32,6 @@ interface IRecurringAgreementHelper { uint256 tokenBalance; uint256 sumMaxNextClaimAll; uint256 totalEscrowDeficit; - uint256 totalAgreementCount; IRecurringEscrowManagement.EscrowBasis escrowBasis; uint8 minOnDemandBasisThreshold; uint8 minFullBasisMargin; diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol index 2b9c344a4..debbff6c0 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol @@ -1,9 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; -import { IDataServiceAgreements } from "../../data-service/IDataServiceAgreements.sol"; import { IPaymentsEscrow } from "../../horizon/IPaymentsEscrow.sol"; -import { IRecurringCollector } from "../../horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "../../horizon/IAgreementCollector.sol"; import { IRecurringEscrowManagement } from "./IRecurringEscrowManagement.sol"; /** @@ -21,116 +20,60 @@ interface IRecurringAgreements { /** * @notice Tracked state for a managed agreement * @dev An agreement is considered tracked when `provider != address(0)`. + * The collector owns all agreement terms, pending update state, and + * data service reference. The RAM only caches the max next claim + * and the minimum needed for routing and tracking. * - * Storage layout (7 slots): - * slot 0: provider (20) + deadline (8) + pendingUpdateNonce (4) = 32 (packed) + * The collector is implicit from the storage key: agreements are stored + * under `collectors[collector].agreements[agreementId]`. + * + * Storage layout (2 slots): + * slot 0: provider (20) (12 bytes free) * slot 1: maxNextClaim (32) - * slot 2: pendingUpdateMaxNextClaim (32) - * slot 3: agreementHash (32) - * slot 4: pendingUpdateHash (32) - * slot 5: dataService (20) (12 bytes free) - * slot 6: collector (20) (12 bytes free) * * @param provider The service provider for this agreement - * @param deadline The RCA deadline for acceptance (used to detect expired offers) - * @param pendingUpdateNonce The RCAU nonce for the pending update (0 means no pending) - * @param maxNextClaim The current maximum tokens claimable in the next collection - * @param pendingUpdateMaxNextClaim Max next claim for an offered-but-not-yet-applied update - * @param agreementHash The RCA hash stored for cleanup of authorizedHashes on deletion - * @param pendingUpdateHash The RCAU hash stored for cleanup of authorizedHashes on deletion - * @param dataService The data service contract for this agreement - * @param collector The RecurringCollector contract for this agreement + * @param maxNextClaim Cached max of active and pending claims from collector */ struct AgreementInfo { address provider; - uint64 deadline; - uint32 pendingUpdateNonce; uint256 maxNextClaim; - uint256 pendingUpdateMaxNextClaim; - bytes32 agreementHash; - bytes32 pendingUpdateHash; - IDataServiceAgreements dataService; - IRecurringCollector collector; } - // -- View Functions -- - - /** - * @notice Get the sum of maxNextClaim for all managed agreements for a (collector, provider) pair - * @param collector The collector contract - * @param provider The provider address - * @return tokens The sum of max next claims - */ - function getSumMaxNextClaim(IRecurringCollector collector, address provider) external view returns (uint256 tokens); - - /** - * @notice Get the escrow account for a (collector, provider) pair - * @param collector The collector contract - * @param provider The provider address - * @return account The escrow account data - */ - function getEscrowAccount( - IRecurringCollector collector, - address provider - ) external view returns (IPaymentsEscrow.EscrowAccount memory account); - - /** - * @notice Get the max next claim for a specific agreement - * @param agreementId The agreement ID - * @return tokens The current max next claim stored for this agreement - */ - function getAgreementMaxNextClaim(bytes16 agreementId) external view returns (uint256 tokens); - - /** - * @notice Get the full tracked state for a specific agreement - * @param agreementId The agreement ID - * @return info The agreement info struct (all fields zero if not tracked) - */ - function getAgreementInfo(bytes16 agreementId) external view returns (AgreementInfo memory info); + // -- Global -- /** - * @notice Get the number of managed agreements for a provider - * @param provider The provider address - * @return count The count of tracked agreements + * @notice Get the current escrow basis setting + * @return basis The configured escrow basis */ - function getProviderAgreementCount(address provider) external view returns (uint256 count); + function getEscrowBasis() external view returns (IRecurringEscrowManagement.EscrowBasis basis); /** - * @notice Get all managed agreement IDs for a provider - * @dev Returns the full set of tracked agreement IDs. May be expensive for providers - * with many agreements — prefer the paginated overload or {getProviderAgreementCount} - * for on-chain use. - * @param provider The provider address - * @return agreementIds The array of agreement IDs + * @notice Get the minimum spare balance threshold for OnDemand basis. + * @dev Effective basis limited to JustInTime when spare < sumMaxNextClaimAll * threshold / 256. + * @return threshold The numerator over 256 */ - function getProviderAgreements(address provider) external view returns (bytes16[] memory agreementIds); + function getMinOnDemandBasisThreshold() external view returns (uint8 threshold); /** - * @notice Get a paginated slice of managed agreement IDs for a provider - * @param provider The provider address - * @param offset The index to start from - * @param count Maximum number of IDs to return (clamped to available) - * @return agreementIds The array of agreement IDs + * @notice Get the minimum spare balance margin for Full basis. + * @dev Effective basis limited to OnDemand when spare < sumMaxNextClaimAll * (256 + margin) / 256. + * @return margin The margin added to 256 */ - function getProviderAgreements( - address provider, - uint256 offset, - uint256 count - ) external view returns (bytes16[] memory agreementIds); + function getMinFullBasisMargin() external view returns (uint8 margin); /** - * @notice Get the current escrow basis setting - * @return basis The configured escrow basis + * @notice Minimum fraction of sumMaxNextClaim required to initiate an escrow thaw. + * @dev Escrow thaw is not initiated if excess is below sumMaxNextClaim * minThawFraction / 256 for a (collector, provider) pair. + * @return fraction The numerator over 256 */ - function getEscrowBasis() external view returns (IRecurringEscrowManagement.EscrowBasis basis); + function getMinThawFraction() external view returns (uint8 fraction); /** * @notice Get the sum of maxNextClaim across all (collector, provider) pairs - * @dev Populated lazily through normal operations. May be stale if agreements were - * offered before this feature was deployed — run reconciliation to populate. + * @dev Populated lazily through normal operations. * @return tokens The global sum of max next claims */ - function getSumMaxNextClaimAll() external view returns (uint256 tokens); + function getSumMaxNextClaim() external view returns (uint256 tokens); /** * @notice Get the total undeposited escrow across all providers @@ -141,88 +84,110 @@ interface IRecurringAgreements { */ function getTotalEscrowDeficit() external view returns (uint256 tokens); + // -- Collector enumeration -- + /** - * @notice Get the total number of tracked agreements across all providers - * @dev Populated lazily through normal operations. - * @return count The total agreement count + * @notice Get the number of collectors with active agreements + * @return count The number of tracked collectors */ - function getTotalAgreementCount() external view returns (uint256 count); + function getCollectorCount() external view returns (uint256 count); /** - * @notice Get the minimum spare balance threshold for OnDemand basis. - * @dev Effective basis limited to JustInTime when spare < sumMaxNextClaimAll * threshold / 256. - * @return threshold The numerator over 256 + * @notice Get a collector address by index + * @param index The index in the collector set + * @return collector The collector address */ - function getMinOnDemandBasisThreshold() external view returns (uint8 threshold); + function getCollectorAt(uint256 index) external view returns (IAgreementCollector collector); + + // -- Provider enumeration -- /** - * @notice Get the minimum spare balance margin for Full basis. - * @dev Effective basis limited to OnDemand when spare < sumMaxNextClaimAll * (256 + margin) / 256. - * @return margin The margin added to 256 + * @notice Get the number of providers with active agreements for a collector + * @param collector The collector contract + * @return count The number of tracked providers */ - function getMinFullBasisMargin() external view returns (uint8 margin); + function getProviderCount(IAgreementCollector collector) external view returns (uint256 count); /** - * @notice Minimum fraction of sumMaxNextClaim required to initiate an escrow thaw. - * @dev Escrow thaw is not initiated if excess is below sumMaxNextClaim * minThawFraction / 256 for a (collector, provider) pair. - * @return fraction The numerator over 256 + * @notice Get a provider address by index for a given collector + * @param collector The collector contract + * @param index The index in the provider set + * @return provider The provider address */ - function getMinThawFraction() external view returns (uint8 fraction); + function getProviderAt(IAgreementCollector collector, uint256 index) external view returns (address provider); + + // -- Per-(collector, provider) -- /** - * @notice Get the number of collectors with active agreements - * @return count The number of tracked collectors + * @notice Get the sum of maxNextClaim for all managed agreements for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @return tokens The sum of max next claims */ - function getCollectorCount() external view returns (uint256 count); + function getSumMaxNextClaim(IAgreementCollector collector, address provider) external view returns (uint256 tokens); /** - * @notice Get all collector addresses with active agreements - * @dev May be expensive for large sets — prefer the paginated overload for on-chain use. - * @return result Array of collector addresses + * @notice Get the escrow account for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @return account The escrow account data */ - function getCollectors() external view returns (address[] memory result); + function getEscrowAccount( + IAgreementCollector collector, + address provider + ) external view returns (IPaymentsEscrow.EscrowAccount memory account); /** - * @notice Get a paginated slice of collector addresses - * @param offset The index to start from - * @param count Maximum number to return (clamped to available) - * @return result Array of collector addresses + * @notice Get the cached escrow balance for a (collector, provider) pair + * @dev Compare with {getEscrowAccount} to detect stale escrow state requiring reconciliation. + * @param collector The collector contract + * @param provider The provider address + * @return escrowSnap The last-known escrow balance */ - function getCollectors(uint256 offset, uint256 count) external view returns (address[] memory result); + function getEscrowSnap(IAgreementCollector collector, address provider) external view returns (uint256 escrowSnap); /** - * @notice Get the number of providers with active agreements for a collector - * @param collector The collector address - * @return count The number of tracked providers + * @notice Get the number of managed agreements for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @return count The pair agreement count */ - function getCollectorProviderCount(address collector) external view returns (uint256 count); + function getAgreementCount(IAgreementCollector collector, address provider) external view returns (uint256 count); /** - * @notice Get all provider addresses with active agreements for a collector - * @dev May be expensive for large sets — prefer the paginated overload for on-chain use. - * @param collector The collector address - * @return result Array of provider addresses + * @notice Get a managed agreement ID by index for a (collector, provider) pair + * @param collector The collector contract + * @param provider The provider address + * @param index The index in the agreement set + * @return agreementId The agreement ID */ - function getCollectorProviders(address collector) external view returns (address[] memory result); + function getAgreementAt( + IAgreementCollector collector, + address provider, + uint256 index + ) external view returns (bytes16 agreementId); + + // -- Per-agreement -- /** - * @notice Get a paginated slice of provider addresses for a collector - * @param collector The collector address - * @param offset The index to start from - * @param count Maximum number to return (clamped to available) - * @return result Array of provider addresses + * @notice Get the full tracked state for a specific agreement + * @param collector The collector contract + * @param agreementId The agreement ID + * @return info The agreement info struct (all fields zero if not tracked) */ - function getCollectorProviders( - address collector, - uint256 offset, - uint256 count - ) external view returns (address[] memory result); + function getAgreementInfo( + IAgreementCollector collector, + bytes16 agreementId + ) external view returns (AgreementInfo memory info); /** - * @notice Get the number of managed agreements for a (collector, provider) pair - * @param collector The collector address - * @param provider The provider address - * @return count The pair agreement count + * @notice Get the max next claim for a specific agreement + * @param collector The collector contract address + * @param agreementId The agreement ID + * @return tokens The current max next claim stored for this agreement */ - function getPairAgreementCount(address collector, address provider) external view returns (uint256 count); + function getAgreementMaxNextClaim( + IAgreementCollector collector, + bytes16 agreementId + ) external view returns (uint256 tokens); } diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 63cde5140..cbd06fe7a 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -15,11 +15,9 @@ import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/ import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; -import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; -import { IDataServiceAgreements } from "@graphprotocol/interfaces/contracts/data-service/IDataServiceAgreements.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; -import { EnumerableSetUtil } from "../common/EnumerableSetUtil.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; import { IGraphToken } from "../common/IGraphToken.sol"; @@ -64,7 +62,6 @@ contract RecurringAgreementManager is { using EnumerableSet for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.AddressSet; - using EnumerableSetUtil for EnumerableSet.AddressSet; /// @notice Emitted when distributeIssuance() reverts (collection continues without fresh issuance) /// @param allocator The allocator that reverted @@ -73,8 +70,6 @@ contract RecurringAgreementManager is /// @notice Thrown when the issuance allocator does not support IIssuanceAllocationDistribution error InvalidIssuanceAllocator(address allocator); - using EnumerableSetUtil for EnumerableSet.Bytes32Set; - // -- Role Constants -- /** @@ -502,45 +497,46 @@ contract RecurringAgreementManager is // -- IRecurringAgreements -- /// @inheritdoc IRecurringAgreements - function getSumMaxNextClaim(IRecurringCollector collector, address provider) external view returns (uint256) { - return _getStorage().sumMaxNextClaim[address(collector)][provider]; + function getSumMaxNextClaim(IAgreementCollector collector, address provider) external view returns (uint256) { + return _getStorage().collectors[address(collector)].providers[provider].sumMaxNextClaim; } /// @inheritdoc IRecurringAgreements function getEscrowAccount( - IRecurringCollector collector, + IAgreementCollector collector, address provider ) external view returns (IPaymentsEscrow.EscrowAccount memory account) { return _fetchEscrowAccount(address(collector), provider); } /// @inheritdoc IRecurringAgreements - function getAgreementMaxNextClaim(bytes16 agreementId) external view returns (uint256) { - return _getStorage().agreements[agreementId].maxNextClaim; - } - - /// @inheritdoc IRecurringAgreements - function getAgreementInfo(bytes16 agreementId) external view returns (AgreementInfo memory) { - return _getStorage().agreements[agreementId]; + function getAgreementMaxNextClaim( + IAgreementCollector collector, + bytes16 agreementId + ) external view returns (uint256) { + return _getStorage().collectors[address(collector)].agreements[agreementId].maxNextClaim; } /// @inheritdoc IRecurringAgreements - function getProviderAgreementCount(address provider) external view returns (uint256) { - return _getStorage().providerAgreementIds[provider].length(); + function getAgreementInfo( + IAgreementCollector collector, + bytes16 agreementId + ) external view returns (AgreementInfo memory) { + return _getStorage().collectors[address(collector)].agreements[agreementId]; } /// @inheritdoc IRecurringAgreements - function getProviderAgreements(address provider) external view returns (bytes16[] memory) { - return _getStorage().providerAgreementIds[provider].getPageBytes16(0, type(uint256).max); + function getAgreementCount(IAgreementCollector collector, address provider) external view returns (uint256) { + return _getStorage().collectors[address(collector)].providers[provider].agreements.length(); } /// @inheritdoc IRecurringAgreements - function getProviderAgreements( + function getAgreementAt( + IAgreementCollector collector, address provider, - uint256 offset, - uint256 count - ) external view returns (bytes16[] memory) { - return _getStorage().providerAgreementIds[provider].getPageBytes16(offset, count); + uint256 index + ) external view returns (bytes16) { + return bytes16(_getStorage().collectors[address(collector)].providers[provider].agreements.at(index)); } /// @inheritdoc IRecurringAgreements @@ -549,7 +545,7 @@ contract RecurringAgreementManager is } /// @inheritdoc IRecurringAgreements - function getSumMaxNextClaimAll() external view returns (uint256) { + function getSumMaxNextClaim() external view returns (uint256) { return _getStorage().sumMaxNextClaimAll; } @@ -558,11 +554,6 @@ contract RecurringAgreementManager is return _getStorage().totalEscrowDeficit; } - /// @inheritdoc IRecurringAgreements - function getTotalAgreementCount() external view returns (uint256) { - return _getStorage().totalAgreementCount; - } - /// @inheritdoc IRecurringAgreements function getMinOnDemandBasisThreshold() external view returns (uint8) { return _getStorage().minOnDemandBasisThreshold; @@ -580,41 +571,27 @@ contract RecurringAgreementManager is /// @inheritdoc IRecurringAgreements function getCollectorCount() external view returns (uint256) { - return _getStorage().collectors.length(); - } - - /// @inheritdoc IRecurringAgreements - function getCollectors() external view returns (address[] memory) { - return _getStorage().collectors.getPage(0, type(uint256).max); + return _getStorage().collectorSet.length(); } /// @inheritdoc IRecurringAgreements - function getCollectors(uint256 offset, uint256 count) external view returns (address[] memory) { - return _getStorage().collectors.getPage(offset, count); + function getCollectorAt(uint256 index) external view returns (IAgreementCollector) { + return IAgreementCollector(_getStorage().collectorSet.at(index)); } /// @inheritdoc IRecurringAgreements - function getCollectorProviderCount(address collector) external view returns (uint256) { - return _getStorage().collectorProviders[collector].length(); + function getProviderCount(IAgreementCollector collector) external view returns (uint256) { + return _getStorage().collectors[address(collector)].providerSet.length(); } /// @inheritdoc IRecurringAgreements - function getCollectorProviders(address collector) external view returns (address[] memory) { - return _getStorage().collectorProviders[collector].getPage(0, type(uint256).max); - } - - /// @inheritdoc IRecurringAgreements - function getCollectorProviders( - address collector, - uint256 offset, - uint256 count - ) external view returns (address[] memory) { - return _getStorage().collectorProviders[collector].getPage(offset, count); + function getProviderAt(IAgreementCollector collector, uint256 index) external view returns (address) { + return _getStorage().collectors[address(collector)].providerSet.at(index); } /// @inheritdoc IRecurringAgreements - function getPairAgreementCount(address collector, address provider) external view returns (uint256) { - return _getStorage().pairAgreementCount[collector][provider]; + function getEscrowSnap(IAgreementCollector collector, address provider) external view returns (uint256) { + return _getStorage().collectors[address(collector)].providers[provider].escrowSnap; } // -- Internal Functions -- From 0b22a1408a69ac75da88174c971219c151165a9f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:49:19 +0000 Subject: [PATCH 069/157] feat(RAM): add emergency role control and eligibility oracle escape hatch Add IEmergencyRoleControl implementation allowing pause guardians to revoke any non-governor role as a fast-response emergency measure. Governor role is excluded to prevent locking out governance. Also adds emergencyClearEligibilityOracle for fail-open when the oracle is broken, extracts _setProviderEligibilityOracle private helper to share between the governor setter and emergency clear, and removes the afterAgreementStateChange stub (obsolete for thin pass-through). --- .../issuance/common/IEmergencyRoleControl.sol | 23 ++++++++++++++ .../agreement/RecurringAgreementManager.md | 13 ++------ .../agreement/RecurringAgreementManager.sol | 30 ++++++++++++++++++- 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 packages/interfaces/contracts/issuance/common/IEmergencyRoleControl.sol diff --git a/packages/interfaces/contracts/issuance/common/IEmergencyRoleControl.sol b/packages/interfaces/contracts/issuance/common/IEmergencyRoleControl.sol new file mode 100644 index 000000000..f47fe584d --- /dev/null +++ b/packages/interfaces/contracts/issuance/common/IEmergencyRoleControl.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +pragma solidity ^0.7.6 || ^0.8.0; + +/** + * @title IEmergencyRoleControl + * @author Edge & Node + * @notice Interface for emergency role revocation by pause-role holders. + * @dev Provides a surgical alternative to pausing: disable a specific actor + * (operator, collector, data service) without halting the entire contract. + * Only the governor (role admin) can re-grant revoked roles. + */ +interface IEmergencyRoleControl { + /** + * @notice Emergency role revocation by pause-role holder + * @dev Allows pause-role holders to revoke any non-governor role as a fast-response + * emergency measure. Governor role is excluded to prevent a pause guardian from + * locking out governance. + * @param role The role to revoke + * @param account The account to revoke the role from + */ + function emergencyRevokeRole(bytes32 role, address account) external; +} diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.md b/packages/issuance/contracts/agreement/RecurringAgreementManager.md index e2fdf94d7..b69589669 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.md +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.md @@ -7,7 +7,7 @@ It implements seven interfaces: - **`IIssuanceTarget`** — receives minted GRT from IssuanceAllocator - **`IAgreementOwner`** — authorizes RCA acceptance and updates via callback (replaces ECDSA signature) - **`IRecurringAgreementManagement`** — agreement lifecycle: offer, update, revoke, cancel, remove, reconcile -- **`IRecurringEscrowManagement`** — escrow configuration: setEscrowBasis, setTempJit +- **`IRecurringEscrowManagement`** — escrow configuration: setEscrowBasis, limit thresholds, thaw fraction - **`IProviderEligibilityManagement`** — eligibility oracle configuration: setProviderEligibilityOracle - **`IRecurringAgreements`** — read-only queries: agreement info, escrow state, global tracking - **`IProviderEligibility`** — delegates payment eligibility checks to an optional oracle @@ -16,7 +16,7 @@ It implements seven interfaces: RAM pulls minted GRT from IssuanceAllocator via `_ensureIncomingDistributionToCurrentBlock()` before any balance-dependent decision. This ensures `balanceOf(address(this))` reflects all available tokens before escrow deposits or JIT calculations. -**Trigger points**: `beforeCollection` (JIT path, when escrow is insufficient) and `_updateEscrow` (all escrow rebalancing). Both may fire in the same transaction, so a per-block deduplication guard (`ensuredIncomingDistributedToBlock`) skips redundant allocator calls. +**Trigger points**: `beforeCollection` (JIT path, when escrow is insufficient) and `_reconcileProviderEscrow` (all escrow rebalancing). Both may fire in the same transaction, so a per-block deduplication guard (`ensuredIncomingDistributedToBlock`) skips redundant allocator calls. **Failure tolerance**: Allocator reverts are caught via try-catch — collection continues and a `DistributeIssuanceFailed` event is emitted for monitoring. This prevents a malfunctioning allocator from blocking payments. @@ -32,10 +32,6 @@ sum(maxNextClaim + pendingUpdateMaxNextClaim for all active agreements for that Deposits never revert — `_escrowMinMax` degrades the mode when balance is insufficient, ensuring the deposit amount is always affordable. The `getEscrowAccount` view exposes the underlying escrow account for monitoring. -## Hash Authorization - -The `authorizedHashes` mapping stores `hash → agreementId` rather than `hash → bool`. Hashes are automatically invalidated when agreements are deleted, preventing reuse without explicit cleanup. - ## Max Next Claim For accepted agreements, delegated to `RecurringCollector.getMaxNextClaim(agreementId)` as the single source of truth. For pre-accepted offers, a conservative estimate calculated at offer time: @@ -58,10 +54,7 @@ maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialT ### Offer → Accept (two-step) -1. **Agreement manager** calls `offerAgreement(rca, collector)` — stores hash, calculates conservative maxNextClaim, deposits into escrow -2. **Service provider operator** calls `SubgraphService.acceptUnsignedIndexingAgreement(allocationId, rca)` — SubgraphService → RecurringCollector → `approveAgreement(hash)` callback to RecurringAgreementManager - -During the pending update window, both current and pending maxNextClaim are escrowed simultaneously (conservative). +1. **Agreement manager** calls `offerAgreement(collector, offerType, offerData)` — forwards opaque offer to collector (new or update), tracks agreement, calculates conservative maxNextClaim, deposits into escrow ### Collect → Reconcile diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index cbd06fe7a..4dcef9a78 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -17,6 +17,7 @@ import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuan import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { IEmergencyRoleControl } from "@graphprotocol/interfaces/contracts/issuance/common/IEmergencyRoleControl.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; import { IGraphToken } from "../common/IGraphToken.sol"; @@ -58,7 +59,8 @@ contract RecurringAgreementManager is IRecurringEscrowManagement, IProviderEligibilityManagement, IRecurringAgreements, - IProviderEligibility + IProviderEligibility, + IEmergencyRoleControl { using EnumerableSet for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.AddressSet; @@ -70,6 +72,9 @@ contract RecurringAgreementManager is /// @notice Thrown when the issuance allocator does not support IIssuanceAllocationDistribution error InvalidIssuanceAllocator(address allocator); + /// @notice Thrown when attempting to emergency-revoke the governor role + error CannotRevokeGovernorRole(); + // -- Role Constants -- /** @@ -196,6 +201,7 @@ contract RecurringAgreementManager is interfaceId == type(IProviderEligibilityManagement).interfaceId || interfaceId == type(IRecurringAgreements).interfaceId || interfaceId == type(IProviderEligibility).interfaceId || + interfaceId == type(IEmergencyRoleControl).interfaceId || super.supportsInterface(interfaceId); } @@ -341,6 +347,21 @@ contract RecurringAgreementManager is emit AgreementUpdateOffered(agreementId, pendingMaxNextClaim, rcau.nonce); } + /// @inheritdoc IRecurringAgreementManagement + /// @dev Emergency fail-open: if the oracle is broken or compromised and is wrongly + /// blocking collections, the pause guardian can clear it so all providers become eligible. + /// The governor can later set a replacement oracle. + function emergencyClearEligibilityOracle() external override onlyRole(PAUSE_ROLE) { + _setProviderEligibilityOracle(IProviderEligibility(address(0))); + } + + /// @inheritdoc IEmergencyRoleControl + /// @dev Governor role is excluded to prevent a pause guardian from locking out governance. + function emergencyRevokeRole(bytes32 role, address account) external override onlyRole(PAUSE_ROLE) { + require(role != GOVERNOR_ROLE, CannotRevokeGovernorRole()); + _revokeRole(role, account); + } + /// @inheritdoc IRecurringAgreementManagement function revokeAgreementUpdate( bytes16 agreementId @@ -433,6 +454,7 @@ contract RecurringAgreementManager is function setEscrowBasis(EscrowBasis basis) external onlyRole(OPERATOR_ROLE) { RecurringAgreementManagerStorage storage $ = _getStorage(); if ($.escrowBasis == basis) return; + EscrowBasis oldBasis = $.escrowBasis; $.escrowBasis = basis; emit EscrowBasisSet(oldBasis, basis); @@ -472,8 +494,14 @@ contract RecurringAgreementManager is /// @inheritdoc IProviderEligibilityManagement function setProviderEligibilityOracle(IProviderEligibility oracle) external onlyRole(GOVERNOR_ROLE) { + _setProviderEligibilityOracle(oracle); + } + + // solhint-disable-next-line use-natspec + function _setProviderEligibilityOracle(IProviderEligibility oracle) private { RecurringAgreementManagerStorage storage $ = _getStorage(); if (address($.providerEligibilityOracle) == address(oracle)) return; + IProviderEligibility oldOracle = $.providerEligibilityOracle; $.providerEligibilityOracle = oracle; emit ProviderEligibilityOracleSet(oldOracle, oracle); From 77fc87f78a0c83887d299fdecd81ad4ed9df4e54 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:02:53 +0000 Subject: [PATCH 070/157] refactor(RAM): convert offerAgreement and cancelAgreement to IAgreementCollector pass-throughs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit offerAgreement now calls collector.offer() with opaque offer data instead of constructing RCA hashes and storage directly. cancelAgreement calls collector.cancel() with a version hash and options bitmask instead of routing through the data service. Both forward to the collector then reconcile locally — the collector owns agreement state, RAM just caches maxNextClaim for escrow accounting. Does not compile: new function bodies reference _reconcileAgreement with a collector parameter that is introduced in a later commit. --- .../IRecurringAgreementManagement.sol | 236 +++++++----------- .../agreement/IRecurringEscrowManagement.sol | 4 +- .../agreement/RecurringAgreementManager.md | 76 +++--- .../agreement/RecurringAgreementManager.sol | 66 ++--- 4 files changed, 147 insertions(+), 235 deletions(-) diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol index e760498d3..b6b02f1bc 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; -import { IRecurringCollector } from "../../horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "../../horizon/IAgreementCollector.sol"; /** * @title Interface for agreement lifecycle operations on {RecurringAgreementManager} @@ -17,33 +17,41 @@ interface IRecurringAgreementManagement { // solhint-disable gas-indexed-events /** - * @notice Emitted when an agreement is offered for escrow management + * @notice Emitted when an agreement is discovered and registered for escrow management. * @param agreementId The deterministic agreement ID + * @param collector The collector contract address + * @param dataService The data service address * @param provider The service provider for this agreement - * @param maxNextClaim The calculated maximum next claim amount */ - event AgreementOffered(bytes16 indexed agreementId, address indexed provider, uint256 maxNextClaim); + event AgreementAdded( + bytes16 indexed agreementId, + address indexed collector, + address dataService, + address indexed provider + ); /** - * @notice Emitted when an agreement offer is revoked before acceptance + * @notice Emitted when an agreement callback is ignored because it does not belong to this manager. + * @dev Useful for debugging missed agreements. * @param agreementId The agreement ID - * @param provider The provider whose sumMaxNextClaim was reduced + * @param collector The collector that sent the callback + * @param reason The rejection reason */ - event OfferRevoked(bytes16 indexed agreementId, address indexed provider); + event AgreementRejected(bytes16 indexed agreementId, address indexed collector, AgreementRejectionReason reason); - /** - * @notice Emitted when an agreement is canceled via the data service - * @param agreementId The agreement ID - * @param provider The provider for this agreement - */ - event AgreementCanceled(bytes16 indexed agreementId, address indexed provider); + /// @notice Why an agreement was not tracked by this manager. + enum AgreementRejectionReason { + UnauthorizedCollector, + UnknownAgreement, + PayerMismatch, + UnauthorizedDataService + } /** * @notice Emitted when an agreement is removed from escrow management * @param agreementId The agreement ID being removed - * @param provider The provider whose sumMaxNextClaim was reduced */ - event AgreementRemoved(bytes16 indexed agreementId, address indexed provider); + event AgreementRemoved(bytes16 indexed agreementId); /** * @notice Emitted when an agreement's max next claim is recalculated @@ -53,30 +61,14 @@ interface IRecurringAgreementManagement { */ event AgreementReconciled(bytes16 indexed agreementId, uint256 oldMaxNextClaim, uint256 newMaxNextClaim); - /** - * @notice Emitted when a pending agreement update is offered - * @param agreementId The agreement ID - * @param pendingMaxNextClaim The max next claim for the pending update - * @param updateNonce The RCAU nonce for the pending update - */ - event AgreementUpdateOffered(bytes16 indexed agreementId, uint256 pendingMaxNextClaim, uint32 updateNonce); - - /** - * @notice Emitted when a pending agreement update is revoked - * @param agreementId The agreement ID - * @param pendingMaxNextClaim The escrow that was freed - * @param updateNonce The RCAU nonce that was revoked - */ - event AgreementUpdateRevoked(bytes16 indexed agreementId, uint256 pendingMaxNextClaim, uint32 updateNonce); - /** * @notice Emitted when a (collector, provider) pair is removed from tracking * @dev Emitted when the pair has no agreements AND escrow is fully recovered (balance zero). - * May cascade inline from agreement deletion or be triggered by {reconcileCollectorProvider}. + * May cascade inline from agreement deletion or be triggered by {reconcileProvider}. * @param collector The collector address * @param provider The provider address */ - event CollectorProviderRemoved(address indexed collector, address indexed provider); + event ProviderRemoved(address indexed collector, address indexed provider); /** * @notice Emitted when a collector is removed from the global tracking set @@ -89,42 +81,8 @@ interface IRecurringAgreementManagement { // -- Errors -- - /** - * @notice Thrown when trying to offer an agreement that is already offered - * @param agreementId The agreement ID - */ - error AgreementAlreadyOffered(bytes16 agreementId); - - /** - * @notice Thrown when trying to operate on an agreement that is not offered - * @param agreementId The agreement ID - */ - error AgreementNotOffered(bytes16 agreementId); - - /** - * @notice Thrown when the RCA payer is not this contract - * @param payer The payer address in the RCA - * @param expected The expected payer (this contract) - */ - error PayerMustBeManager(address payer, address expected); - - /** - * @notice Thrown when trying to revoke an agreement that is already accepted - * @param agreementId The agreement ID - */ - error AgreementAlreadyAccepted(bytes16 agreementId); - - /** - * @notice Thrown when trying to cancel an agreement that has not been accepted yet - * @param agreementId The agreement ID - */ - error AgreementNotAccepted(bytes16 agreementId); - - /** - * @notice Thrown when the data service address has no deployed code - * @param dataService The address that was expected to be a contract - */ - error InvalidDataService(address dataService); + /// @notice Thrown when the collector returns a zero agreement ID + error AgreementIdZero(); /// @notice Thrown when the RCA service provider is the zero address error ServiceProviderZeroAddress(); @@ -135,125 +93,101 @@ interface IRecurringAgreementManagement { */ error UnauthorizedDataService(address dataService); - /// @notice Thrown when a collection callback is called by an address other than the agreement's collector - error OnlyAgreementCollector(); - - /** - * @notice Thrown when the RCAU nonce does not match the expected next update nonce - * @param agreementId The agreement ID - * @param expectedNonce The expected nonce (collector's updateNonce + 1) - * @param actualNonce The nonce provided in the RCAU - */ - error InvalidUpdateNonce(bytes16 agreementId, uint32 expectedNonce, uint32 actualNonce); - /** * @notice Thrown when the collector address does not have COLLECTOR_ROLE * @param collector The unauthorized collector address */ error UnauthorizedCollector(address collector); + /** + * @notice Thrown when the collector returns a payer that does not match this contract + * @param payer The payer address returned by the collector + */ + error PayerMismatch(address payer); + // -- Functions -- /** - * @notice Offer an RCA for escrow management. Must be called before - * the data service accepts the agreement (with empty authData). - * @dev Calculates max next claim from RCA parameters, stores the authorized hash - * for the {IAgreementOwner} callback, and deposits into escrow. + * @notice Offer an RCA for escrow management. + * @dev Forwards opaque offer data to the collector, which decodes and validates it, + * then reconciles agreement tracking and escrow locally after the call returns. + * The collector does not callback to `msg.sender` — see RecurringCollector callback model. * Requires AGREEMENT_MANAGER_ROLE. - * - * WARNING: increases `sumMaxNextClaim` (and `totalEscrowDeficit`) without checking escrow - * headroom. A single offer can push `spare` below the degradation threshold, instantly - * degrading the escrow mode for ALL (collector, provider) pairs. The caller should verify - * sufficient balance before calling. See RecurringAgreementManager.md, Automatic Degradation. - * @param rca The Recurring Collection Agreement parameters * @param collector The RecurringCollector contract to use for this agreement + * @param offerType The offer type (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) + * @param offerData Opaque ABI-encoded agreement data forwarded to the collector * @return agreementId The deterministic agreement ID */ function offerAgreement( - IRecurringCollector.RecurringCollectionAgreement calldata rca, - IRecurringCollector collector - ) external returns (bytes16 agreementId); - - /** - * @notice Offer a pending agreement update for escrow management. Must be called - * before the data service applies the update (with empty authData). - * @dev Stores the authorized RCAU hash for the {IAgreementOwner} callback and - * adds the pending update's max next claim to sumMaxNextClaim. Treats the - * pending update as a separate escrow entry alongside the current agreement. - * If a previous pending update exists, it is replaced. - * Requires AGREEMENT_MANAGER_ROLE. - * - * WARNING: potentially increases `sumMaxNextClaim` (and `totalEscrowDeficit`), without - * checking escrow headroom. A single update can push `spare` below the degradation threshold, - * instantly degrading the escrow mode for ALL (collector, provider) pairs. The caller should - * verify sufficient balance before calling. - * See RecurringAgreementManager.md, Automatic Degradation. - * @param rcau The Recurring Collection Agreement Update parameters - * @return agreementId The agreement ID from the RCAU - */ - function offerAgreementUpdate( - IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau + IAgreementCollector collector, + uint8 offerType, + bytes calldata offerData ) external returns (bytes16 agreementId); /** - * @notice Revoke a pending agreement update, freeing its reserved escrow. - * @dev Requires AGREEMENT_MANAGER_ROLE. Reconciles the agreement first to - * detect if the update was already applied. If the pending update is still - * outstanding after reconciliation, clears it and frees the escrow. - * No-op (returns false) if no pending update exists after reconciliation. - * @param agreementId The agreement ID whose pending update to revoke - * @return revoked True if a pending update was cleared by this call - */ - function revokeAgreementUpdate(bytes16 agreementId) external returns (bool revoked); - - /** - * @notice Revoke an un-accepted agreement offer. Only for agreements not yet - * accepted in RecurringCollector. - * @dev Requires AGREEMENT_MANAGER_ROLE. Clears the agreement tracking and authorized hashes, - * freeing the reserved escrow. Any pending update is also cleared. - * No-op (returns true) if the agreement is not tracked. - * @param agreementId The agreement ID to revoke - * @return gone True if the agreement is not tracked (whether revoked by this call or already absent) - */ - function revokeOffer(bytes16 agreementId) external returns (bool gone); - - /** - * @notice Cancel an accepted agreement by routing through the data service. - * @dev Requires AGREEMENT_MANAGER_ROLE. Reads agreement state from RecurringCollector: - * - NotAccepted: reverts (use {revokeOffer} instead) - * - Accepted: cancels via the data service, then reconciles and updates escrow - * - Already canceled: idempotent — reconciles and updates escrow without re-canceling - * After cancellation, call {reconcileAgreement} once the collection window closes. + * @notice Cancel an agreement or pending update by routing through the collector. + * @dev Requires AGREEMENT_MANAGER_ROLE. Forwards the terms hash to the collector's + * cancel function, then reconciles locally after the call returns. The collector does + * not callback to `msg.sender` — see RecurringCollector callback model. + * @param collector The collector contract address for this agreement * @param agreementId The agreement ID to cancel - * @return gone True if the agreement is not tracked (already absent); false when - * the agreement is still tracked (caller should eventually call {reconcileAgreement}) + * @param versionHash The terms hash to cancel (activeTerms.hash or pendingTerms.hash) + * @param options Bitmask — SCOPE_ACTIVE (1) targets active terms, SCOPE_PENDING (2) targets pending offers. */ - function cancelAgreement(bytes16 agreementId) external returns (bool gone); + function cancelAgreement( + IAgreementCollector collector, + bytes16 agreementId, + bytes32 versionHash, + uint16 options + ) external; /** * @notice Reconcile a single agreement: re-read on-chain state, recalculate * max next claim, update escrow, and delete the agreement if fully settled. * @dev Permissionless. Handles all agreement states: - * - NotAccepted before deadline: keeps pre-offer estimate (returns true) - * - NotAccepted past deadline: zeroes and deletes (returns false) + * - NotAccepted before deadline: keeps pre-offer estimate (tracked = true) + * - NotAccepted past deadline: zeroes and deletes (tracked = false) * - Accepted/Canceled: reconciles maxNextClaim, deletes if zero * Should be called after collections, cancellations, or agreement updates. + * @param collector The collector contract address for this agreement * @param agreementId The agreement ID to reconcile - * @return exists True if the agreement is still tracked after this call + * @return tracked True if the agreement is still tracked after this call */ - function reconcileAgreement(bytes16 agreementId) external returns (bool exists); + function reconcileAgreement(IAgreementCollector collector, bytes16 agreementId) external returns (bool tracked); + + /** + * @notice Force-remove a tracked agreement whose collector is unresponsive. + * @dev Operator escape hatch for when a collector contract reverts on all calls + * (broken upgrade, self-destruct, permanent pause), making normal reconciliation + * impossible. Zeroes the agreement's maxNextClaim, removes it from pair tracking, + * and triggers pair reconciliation to thaw/withdraw the freed escrow. + * + * Requires OPERATOR_ROLE. Only use when the collector cannot be fixed. + * + * @param collector The collector contract address + * @param agreementId The agreement ID to force-remove + */ + function forceRemoveAgreement(IAgreementCollector collector, bytes16 agreementId) external; /** * @notice Reconcile a (collector, provider) pair: rebalance escrow, withdraw * completed thaws, and remove tracking if fully drained. * @dev Permissionless. First updates escrow state (deposit deficit, thaw excess, - * withdraw completed thaws), then removes pair tracking when both pairAgreementCount + * withdraw completed thaws), then removes pair tracking when both agreementCount * and escrow balance are zero. Also serves as the permissionless "poke" to rebalance * escrow after {IRecurringEscrowManagement-setEscrowBasis} or threshold/margin * changes. Returns true if the pair still has agreements or escrow is still thawing. * @param collector The collector address * @param provider The provider address - * @return exists True if the pair is still tracked after this call + * @return tracked True if the pair is still tracked after this call + */ + function reconcileProvider(IAgreementCollector collector, address provider) external returns (bool tracked); + + /** + * @notice Emergency: clear the eligibility oracle so all providers become eligible. + * @dev Callable by PAUSE_ROLE holders. Use when the oracle is broken or compromised + * and is wrongly blocking collections. The governor can later set a replacement oracle + * via {IProviderEligibilityManagement.setProviderEligibilityOracle}. */ - function reconcileCollectorProvider(address collector, address provider) external returns (bool exists); + function emergencyClearEligibilityOracle() external; } diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol index 9f193a777..f19bc108b 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol @@ -6,7 +6,7 @@ pragma solidity ^0.8.22; * @author Edge & Node * @notice Functions for configuring escrow deposits that back * managed RCAs. Controls how aggressively escrow is pre-deposited. - * Escrow rebalancing is performed by {IRecurringAgreementManagement-reconcileCollectorProvider}. + * Escrow rebalancing is performed by {IRecurringAgreementManagement-reconcileProvider}. * * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. @@ -84,7 +84,7 @@ interface IRecurringEscrowManagement { * @notice Set the escrow basis (maximum aspiration level). * @dev Requires OPERATOR_ROLE. The system automatically degrades below the configured * level when balance is insufficient. Changing the basis does not immediately rebalance - * escrow — call {IRecurringAgreementManagement-reconcileCollectorProvider} per pair to apply. + * escrow — call {IRecurringAgreementManagement-reconcileProvider} per pair to apply. * @param basis The new escrow basis */ function setEscrowBasis(EscrowBasis basis) external; diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.md b/packages/issuance/contracts/agreement/RecurringAgreementManager.md index b69589669..db57dcdec 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.md +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.md @@ -27,7 +27,7 @@ RAM pulls minted GRT from IssuanceAllocator via `_ensureIncomingDistributionToCu One escrow account per (RecurringAgreementManager, collector, provider) tuple covers **all** managed RCAs for that (collector, provider) pair. Multiple agreements for the same pair share a single escrow balance: ``` -sum(maxNextClaim + pendingUpdateMaxNextClaim for all active agreements for that provider) <= PaymentsEscrow.escrowAccounts[RecurringAgreementManager][RecurringCollector][provider] +sum(maxNextClaim for all active agreements for that provider) <= PaymentsEscrow.escrowAccounts[RecurringAgreementManager][RecurringCollector][provider] ``` Deposits never revert — `_escrowMinMax` degrades the mode when balance is insufficient, ensuring the deposit amount is always affordable. The `getEscrowAccount` view exposes the underlying escrow account for monitoring. @@ -40,15 +40,15 @@ For accepted agreements, delegated to `RecurringCollector.getMaxNextClaim(agreem maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens ``` -| Agreement State | maxNextClaim | -| --------------------------- | -------------------------------------------------------------- | -| NotAccepted (pre-offered) | Stored estimate from `offerAgreement` | -| NotAccepted (past deadline) | 0 (expired offer, removable) | -| Accepted, never collected | Calculated by RecurringCollector (includes initial + ongoing) | -| Accepted, after collect | Calculated by RecurringCollector (ongoing only) | -| CanceledByPayer | Calculated by RecurringCollector (window frozen at canceledAt) | -| CanceledByServiceProvider | 0 | -| Fully expired | 0 | +| Agreement State | maxNextClaim | +| --------------------------- | -------------------------------------------------------------------- | +| NotAccepted (pre-offered) | Stored estimate from `offerAgreement` | +| NotAccepted (past deadline) | 0 (expired offer, removable) | +| Accepted, never collected | Calculated by RecurringCollector (includes initial + ongoing) | +| Accepted, after collect | Calculated by RecurringCollector (ongoing only) | +| CanceledByPayer | Calculated by RecurringCollector (window capped at collectableUntil) | +| CanceledByServiceProvider | 0 | +| Fully expired | 0 | ## Lifecycle @@ -60,15 +60,16 @@ maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialT Collection flows through `SubgraphService → RecurringCollector → PaymentsEscrow`. RecurringCollector then calls `IAgreementOwner.afterCollection` on the payer, which triggers automatic reconciliation and escrow top-up in the same transaction. Manual reconcile is still available as a fallback. -The manager exposes `reconcileAgreement` (gas-predictable, per-agreement). Batch convenience functions `reconcileBatch` (caller-selected list) and `reconcile(provider)` (iterates all agreements) are in the stateless `RecurringAgreementHelper` contract, which delegates each reconciliation back to the manager. +The manager exposes `reconcileAgreement` (gas-predictable, per-agreement) and `reconcileProvider` (pair-level escrow rebalancing). Batch convenience functions `reconcile`, `reconcileCollector`, and `reconcileAll` are in the stateless `RecurringAgreementHelper` contract, which iterates agreements and delegates each reconciliation back to the manager. -### Revoke / Cancel / Remove +### Cancel / Remove -- **`revokeOffer`** — withdraws an un-accepted offer -- **`cancelAgreement`** — for accepted agreements, routes cancellation through the data service then reconciles; idempotent for already-canceled agreements -- **`removeAgreement`** (permissionless) — cleans up agreements with maxNextClaim = 0 +- **`cancelAgreement`** — routes cancellation through the collector's `cancel` function (passing the terms hash), then reconciles locally. Cancels un-accepted offers, accepted agreements, or pending updates depending on the `versionHash` provided. Requires AGREEMENT_MANAGER_ROLE. +- **`forceRemoveAgreement`** — operator escape hatch for agreements whose collector is unresponsive (broken upgrade, permanent pause). Zeroes the agreement's maxNextClaim, removes it from pair tracking, and triggers pair reconciliation. Requires OPERATOR_ROLE. -| State | Removable when | +Cleanup is automatic: `reconcileAgreement` deletes agreements whose `maxNextClaim` is 0. + +| State | Deleted by reconcile when | | ------------------------- | ------------------------------------- | | CanceledByServiceProvider | Immediately (maxNextClaim = 0) | | CanceledByPayer | After collection window expires | @@ -99,7 +100,7 @@ Ordered low-to-high: ### Min/Max Model -`_updateEscrow` uses two numbers from `_escrowMinMax` instead of a single `sumMaxNextClaim`: +`_reconcileProviderEscrow` uses two numbers from `_escrowMinMax` instead of a single `sumMaxNextClaim`: - **min**: deposit floor — deposit if effective balance is below this - **max**: thaw ceiling — thaw effective balance above this (never resetting an active thaw timer) @@ -121,11 +122,11 @@ The min gate is stricter (0.5x < 1.0625x), giving three effective states as `spa 2. **OnDemand** (`smnca × 0.5 < spare ≤ smnca × 1.0625`): min gate fails, max holds — min = 0, max = `sumMaxNextClaim` (no new deposits, but existing escrow up to max is held) 3. **JIT** (`spare ≤ smnca × 0.5`): both gates fail — min = max = 0 (thaw everything) -**Operator caution — new agreements can trigger instant degradation.** `offerAgreement()` and `offerAgreementUpdate()` increase `sumMaxNextClaim` (and therefore `totalEscrowDeficit`) without checking whether the RAM has sufficient balance to maintain the current escrow mode. A single offer can push `spare` below the threshold, instantly degrading escrow mode for **all** (collector, provider) pairs — not just the new agreement. Existing providers who had fully-escrowed agreements silently lose their proactive deposits. The operator (AGREEMENT_MANAGER_ROLE holder) should verify escrow headroom before offering agreements. An on-chain guard was considered but excluded due to contract size constraints (Spurious Dragon 24576-byte limit). +**Operator caution — new agreements can trigger instant degradation.** `offerAgreement()` (both new and update) increases `sumMaxNextClaim` (and therefore `totalEscrowDeficit`) without checking whether the RAM has sufficient balance to maintain the current escrow mode. A single offer can push `spare` below the threshold, instantly degrading escrow mode for **all** (collector, provider) pairs — not just the new agreement. Existing providers who had fully-escrowed agreements silently lose their proactive deposits. The operator (AGREEMENT_MANAGER_ROLE holder) should verify escrow headroom before offering agreements. An on-chain guard was considered but excluded due to contract size constraints (Spurious Dragon 24576-byte limit). -### `_updateEscrow` Flow +### `_reconcileProviderEscrow` Flow -`_updateEscrow(collector, provider)` normalizes escrow state in four steps using (min, max) from `_escrowMinMax`. Steps 3 and 4 are mutually exclusive (min <= max); the thaw timer is never reset. +`_reconcileProviderEscrow(collector, provider)` normalizes escrow state in four steps using (min, max) from `_escrowMinMax`. Steps 3 and 4 are mutually exclusive (min <= max); the thaw timer is never reset. 1. **Adjust thaw target** — cancel/reduce thawing to keep min <= effective balance, or increase toward max (without timer reset) 2. **Withdraw completed thaw** — always withdrawn, even if within [min, max] @@ -134,32 +135,33 @@ The min gate is stricter (0.5x < 1.0625x), giving three effective states as `spa ### Reconciliation -Per-agreement reconciliation (`reconcileAgreement`) re-reads agreement state from RecurringCollector and updates `sumMaxNextClaim`. Pair-level escrow rebalancing and cleanup is O(1) via `reconcileCollectorProvider(collector, provider)`. Batch helpers `reconcileBatch` and `reconcile(provider)` live in the separate `RecurringAgreementHelper` contract — they are stateless wrappers that call `reconcileAgreement` in a loop. +Per-agreement reconciliation (`reconcileAgreement`) re-reads agreement state from RecurringCollector and updates `sumMaxNextClaim`. Pair-level escrow rebalancing and cleanup is O(1) via `reconcileProvider(collector, provider)`. Batch helpers `reconcile`, `reconcileCollector`, and `reconcileAll` live in the separate `RecurringAgreementHelper` contract — they are stateless wrappers that call `reconcileAgreement` in a loop, then call `reconcileProvider` per pair. ### Global Tracking -| Storage field | Type | Updated at | -| ----------------------------------- | ------- | -------------------------------------------------------------------- | -| `escrowBasis` | enum | `setEscrowBasis()` | -| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | -| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | -| `totalAgreementCount` | uint256 | `offerAgreement` (+1), `revokeOffer` (-1), `reconcileAgreement` (-1) | -| `escrowSnap[c][p]` | mapping | End of `_updateEscrow` via snapshot diff | -| `minOnDemandBasisThreshold` | uint8 | `setMinOnDemandBasisThreshold()` (operator) | -| `minFullBasisMargin` | uint8 | `setMinFullBasisMargin()` (operator) | -| `issuanceAllocator` | address | `setIssuanceAllocator()` (governor) | -| `ensuredIncomingDistributedToBlock` | uint64 | `_ensureIncomingDistributionToCurrentBlock()` (per-block dedup) | +| Storage field | Type | Updated at | +| ----------------------------------- | ------- | --------------------------------------------------------------------------------------------- | +| `escrowBasis` | enum | `setEscrowBasis()` | +| `sumMaxNextClaimAll` | uint256 | Every `sumMaxNextClaim[c][p]` mutation | +| `totalEscrowDeficit` | uint256 | Every `sumMaxNextClaim[c][p]` or `escrowSnap[c][p]` mutation | +| `providerEligibilityOracle` | address | `setProviderEligibilityOracle()` (governor), `emergencyClearEligibilityOracle()` (pause role) | +| `escrowSnap[c][p]` | mapping | End of `_reconcileProviderEscrow` via snapshot diff | +| `minOnDemandBasisThreshold` | uint8 | `setMinOnDemandBasisThreshold()` (operator) | +| `minFullBasisMargin` | uint8 | `setMinFullBasisMargin()` (operator) | +| `minThawFraction` | uint8 | `setMinThawFraction()` (operator) | +| `issuanceAllocator` | address | `setIssuanceAllocator()` (governor) | +| `ensuredIncomingDistributedToBlock` | uint32 | `_ensureIncomingDistributionToCurrentBlock()` (per-block dedup) | **`totalEscrowDeficit`** is maintained incrementally as `Σ max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p])` per (collector, provider). Over-deposited pairs cannot mask another pair's deficit. At each mutation point, the pair's deficit is recomputed before and after. ## Roles - **GOVERNOR_ROLE**: Sets issuance allocator, eligibility oracle; grants `DATA_SERVICE_ROLE`, `COLLECTOR_ROLE`, and other roles; admin of `OPERATOR_ROLE` -- **OPERATOR_ROLE**: Sets escrow basis and threshold/margin parameters; admin of `AGREEMENT_MANAGER_ROLE` - - **AGREEMENT_MANAGER_ROLE**: Offers agreements/updates, revokes offers, cancels agreements -- **PAUSE_ROLE**: Pauses contract (reconcile remains available) -- **Permissionless**: `reconcileAgreement`, `reconcileCollectorProvider` -- **RecurringAgreementHelper** (permissionless): `reconcile(provider)`, `reconcileBatch(ids[])` +- **OPERATOR_ROLE**: Sets escrow basis, threshold/margin, and thaw-fraction parameters; `forceRemoveAgreement`; admin of `AGREEMENT_MANAGER_ROLE` + - **AGREEMENT_MANAGER_ROLE**: Offers agreements/updates, cancels agreements +- **PAUSE_ROLE**: Pauses contract (reconcile remains available); `emergencyClearEligibilityOracle` +- **Permissionless**: `reconcileAgreement`, `reconcileProvider` +- **RecurringAgreementHelper** (permissionless): `reconcile`, `reconcileCollector`, `reconcileAll` ## Deployment diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 4dcef9a78..033bb10ad 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -283,30 +283,22 @@ contract RecurringAgreementManager is /// @inheritdoc IRecurringAgreementManagement function offerAgreement( - IRecurringCollector.RecurringCollectionAgreement calldata rca, - IRecurringCollector collector - ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bytes16 agreementId) { - require(rca.payer == address(this), PayerMustBeManager(rca.payer, address(this))); - require(rca.serviceProvider != address(0), ServiceProviderZeroAddress()); - require(hasRole(DATA_SERVICE_ROLE, rca.dataService), UnauthorizedDataService(rca.dataService)); + IAgreementCollector collector, + uint8 offerType, + bytes calldata offerData + ) external onlyRole(AGREEMENT_MANAGER_ROLE) nonReentrant returns (bytes16 agreementId) { require(hasRole(COLLECTOR_ROLE, address(collector)), UnauthorizedCollector(address(collector))); - RecurringAgreementManagerStorage storage $ = _getStorage(); + // Forward to collector — no callback to msg.sender, we reconcile after return + IAgreementCollector.AgreementDetails memory details = collector.offer(offerType, offerData, 0); + require(hasRole(DATA_SERVICE_ROLE, details.dataService), UnauthorizedDataService(details.dataService)); + agreementId = details.agreementId; - agreementId = collector.generateAgreementId( - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.deadline, - rca.nonce - ); - require($.agreements[agreementId].provider == address(0), AgreementAlreadyOffered(agreementId)); + require(agreementId != bytes16(0), AgreementIdZero()); + require(details.payer == address(this), PayerMismatch(details.payer)); + require(details.serviceProvider != address(0), ServiceProviderZeroAddress()); - bytes32 agreementHash = collector.hashRCA(rca); - uint256 maxNextClaim = _createAgreement($, agreementId, rca, collector, agreementHash); - _updateEscrow($, address(collector), rca.serviceProvider); - - emit AgreementOffered(agreementId, rca.serviceProvider, maxNextClaim); + _reconcileAgreement(_getStorage(), address(collector), agreementId); } /// @inheritdoc IRecurringAgreementManagement @@ -408,30 +400,14 @@ contract RecurringAgreementManager is /// @inheritdoc IRecurringAgreementManagement function cancelAgreement( - bytes16 agreementId - ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused nonReentrant returns (bool gone) { - RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - if (agreement.provider == address(0)) return true; - - IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); - - // Not accepted — use revokeOffer instead - require(rca.state != IRecurringCollector.AgreementState.NotAccepted, AgreementNotAccepted(agreementId)); - - // If still active, route cancellation through the data service. - // Note: external call before state update — safe because caller must hold - // AGREEMENT_MANAGER_ROLE and data service is governance-gated. nonReentrant - // provides defence-in-depth (see CEI note in contract header). - if (rca.state == IRecurringCollector.AgreementState.Accepted) { - IDataServiceAgreements ds = agreement.dataService; - require(address(ds).code.length != 0, InvalidDataService(address(ds))); - ds.cancelIndexingAgreementByPayer(agreementId); - emit AgreementCanceled(agreementId, agreement.provider); - } - // else: already canceled (CanceledByPayer or CanceledByServiceProvider) — skip cancel call, just reconcile - - return _reconcileAndCleanup($, agreementId, agreement); + IAgreementCollector collector, + bytes16 agreementId, + bytes32 versionHash, + uint16 options + ) external onlyRole(AGREEMENT_MANAGER_ROLE) nonReentrant { + // Forward to collector — no callback to msg.sender, we reconcile after return + collector.cancel(agreementId, versionHash, options); + _reconcileAgreement(_getStorage(), address(collector), agreementId); } /// @inheritdoc IRecurringAgreementManagement @@ -1012,7 +988,7 @@ contract RecurringAgreementManager is if (account.tokensThawing == 0) { if (max < account.balance) { - unint256 excess = account.balance - max; + uint256 excess = account.balance - max; if (thawThreshold <= excess) // Thaw excess above max (might have withdrawn allowing a new thaw to start) PAYMENTS_ESCROW.adjustThaw(collector, provider, excess, false); From 64bc0f0ed4502bb6643b113cc0cc5e19c1b8227d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:26:56 +0000 Subject: [PATCH 071/157] refactor(RAM): remove offerAgreementUpdate, revokeAgreementUpdate, and revokeOffer These functions are subsumed by the IAgreementCollector offer/cancel interface: updates are offered via offerAgreement with an update offer type, and revocations use cancelAgreement targeting the relevant terms hash. The collector now owns offer/update lifecycle state. Also add forceRemoveAgreement. --- .../agreement/RecurringAgreementManager.sol | 85 ++----------------- 1 file changed, 9 insertions(+), 76 deletions(-) diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 033bb10ad..7d66e6f52 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -302,41 +302,18 @@ contract RecurringAgreementManager is } /// @inheritdoc IRecurringAgreementManagement - function offerAgreementUpdate( - IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau - ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bytes16 agreementId) { - agreementId = rcau.agreementId; + function forceRemoveAgreement( + IAgreementCollector collector, + bytes16 agreementId + ) external onlyRole(OPERATOR_ROLE) nonReentrant { RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - require(agreement.provider != address(0), AgreementNotOffered(agreementId)); - - // Reconcile against on-chain state before layering a new pending update, - // so escrow accounting is current and we can validate the nonce. - _reconcileAgreement($, agreementId); - - // Validate nonce: must be the next expected nonce on the collector - IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); - uint32 expectedNonce = rca.updateNonce + 1; - require(rcau.nonce == expectedNonce, InvalidUpdateNonce(agreementId, expectedNonce, rcau.nonce)); - - // Clean up old pending hash if replacing - if (agreement.pendingUpdateHash != bytes32(0)) delete $.authorizedHashes[agreement.pendingUpdateHash]; - - // Authorize the RCAU hash for the IAgreementOwner callback - bytes32 updateHash = agreement.collector.hashRCAU(rcau); - $.authorizedHashes[updateHash] = agreementId; - agreement.pendingUpdateNonce = rcau.nonce; - agreement.pendingUpdateHash = updateHash; + AgreementInfo storage agreement = $.collectors[address(collector)].agreements[agreementId]; + address provider = agreement.provider; + if (provider == address(0)) return; - uint256 pendingMaxNextClaim = _computeMaxFirstClaim( - rcau.maxOngoingTokensPerSecond, - rcau.maxSecondsPerCollection, - rcau.maxInitialTokens - ); - _setAgreementMaxNextClaim($, agreementId, pendingMaxNextClaim, true); - _updateEscrow($, address(agreement.collector), agreement.provider); + CollectorProviderData storage cpd = $.collectors[address(collector)].providers[provider]; - emit AgreementUpdateOffered(agreementId, pendingMaxNextClaim, rcau.nonce); + _removeAgreement($, cpd, address(collector), provider, agreementId); } /// @inheritdoc IRecurringAgreementManagement @@ -354,50 +331,6 @@ contract RecurringAgreementManager is _revokeRole(role, account); } - /// @inheritdoc IRecurringAgreementManagement - function revokeAgreementUpdate( - bytes16 agreementId - ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bool revoked) { - RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - require(agreement.provider != address(0), AgreementNotOffered(agreementId)); - - // Reconcile first — the update may have been accepted since the offer was made - _reconcileAgreement($, agreementId); - - if (agreement.pendingUpdateHash == bytes32(0)) return false; - - uint256 pendingMaxClaim = agreement.pendingUpdateMaxNextClaim; - uint32 nonce = agreement.pendingUpdateNonce; - - _setAgreementMaxNextClaim($, agreementId, 0, true); - delete $.authorizedHashes[agreement.pendingUpdateHash]; - agreement.pendingUpdateNonce = 0; - agreement.pendingUpdateHash = bytes32(0); - - _updateEscrow($, address(agreement.collector), agreement.provider); - - emit AgreementUpdateRevoked(agreementId, pendingMaxClaim, nonce); - return true; - } - - /// @inheritdoc IRecurringAgreementManagement - function revokeOffer( - bytes16 agreementId - ) external onlyRole(AGREEMENT_MANAGER_ROLE) whenNotPaused returns (bool gone) { - RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - if (agreement.provider == address(0)) return true; - - // Only revoke un-accepted agreements — accepted ones must be canceled via cancelAgreement - IRecurringCollector.AgreementData memory rca = agreement.collector.getAgreement(agreementId); - require(rca.state == IRecurringCollector.AgreementState.NotAccepted, AgreementAlreadyAccepted(agreementId)); - - address provider = _deleteAgreement($, agreementId, agreement); - emit OfferRevoked(agreementId, provider); - return true; - } - /// @inheritdoc IRecurringAgreementManagement function cancelAgreement( IAgreementCollector collector, From daf0b47edf8d8e71a59da7f62c96e0e667d38ee9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 17:19:11 +0000 Subject: [PATCH 072/157] =?UTF-8?q?refactor(RAM):=20restructure=20storage?= =?UTF-8?q?=20into=20collector=20=E2=86=92=20provider=20hierarchy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace flat storage mappings with hierarchical CollectorData and CollectorProviderData structs. Agreements are now namespaced under their collector ($.collectors[c].agreements[id]) instead of a global mapping, preventing cross-collector ID collisions. Add _getAgreementProvider for lazy discovery: on first encounter, validates collector role, reads agreement details, checks payer/dataService, and registers in tracking sets. Subsequent accesses use the cached provider. Rewrite internal functions to use the hierarchical storage: - _reconcileAgreement: discover-then-reconcile flow - _removeAgreement: replaces _deleteAgreement - _reconcileProvider: replaces _reconcilePairTracking - _setAgreementMaxNextClaim: takes CollectorProviderData, reads old value - _escrowMinMax: takes sumMaxNextClaim value parameter - _providerEscrowDeficit: takes CollectorProviderData - _reconcileProviderEscrow: replaces _updateEscrow, uses cpd - _setEscrowSnap: takes CollectorProviderData Add forceRemoveAgreement operator escape hatch. Update beforeCollection, afterCollection, reconcileAgreement, and reconcileProvider to use the new collector-parameterised internal functions. Reduces AgreementInfo to {provider, maxNextClaim}. --- .../agreement/IRecurringAgreementHelper.sol | 140 ++++- packages/issuance/audits/PR1301/TRST-L-5.md | 4 + .../agreement/RecurringAgreementHelper.sol | 206 ++++--- .../agreement/RecurringAgreementManager.sol | 565 +++++++++--------- .../agreement-manager/afterCollection.t.sol | 22 +- .../unit/agreement-manager/approver.t.sol | 136 +++++ .../agreement-manager/branchCoverage.t.sol | 270 +++++++++ .../unit/agreement-manager/callbackGas.t.sol | 14 +- .../agreement-manager/cascadeCleanup.t.sol | 184 +++--- .../unit/agreement-manager/discovery.t.sol | 348 +++++++++++ .../unit/agreement-manager/edgeCases.t.sol | 564 ++++++++--------- .../agreement-manager/ensureDistributed.t.sol | 27 +- .../agreement-manager/escrowEdgeCases.t.sol | 425 +++++++++++++ .../unit/agreement-manager/fundingModes.t.sol | 232 +++---- .../test/unit/agreement-manager/fuzz.t.sol | 83 ++- .../test/unit/agreement-manager/helper.t.sol | 117 ++-- .../unit/agreement-manager/helperAudit.t.sol | 205 ++++++- .../agreement-manager/helperCleanup.t.sol | 139 +++-- .../unit/agreement-manager/lifecycle.t.sol | 190 +++--- .../mocks/MockIssuanceAllocator.sol | 18 +- .../mocks/MockPaymentsEscrow.sol | 2 - .../mocks/MockRecurringCollector.sol | 274 +++++++-- .../agreement-manager/multiCollector.t.sol | 36 +- .../unit/agreement-manager/multiIndexer.t.sol | 87 +-- .../unit/agreement-manager/offerUpdate.t.sol | 242 ++++---- .../unit/agreement-manager/reconcile.t.sol | 271 ++++++--- .../unit/agreement-manager/register.t.sol | 75 +-- .../revokeAgreementUpdate.t.sol | 160 ++--- .../unit/agreement-manager/revokeOffer.t.sol | 98 ++- .../test/unit/agreement-manager/shared.t.sol | 205 ++++--- .../unit/agreement-manager/updateEscrow.t.sol | 184 +++++- .../test/unit/common/enumerableSetUtil.t.sol | 3 - .../test/harness/RealStackHarness.t.sol | 7 +- 33 files changed, 3714 insertions(+), 1819 deletions(-) create mode 100644 packages/issuance/test/unit/agreement-manager/approver.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/discovery.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/escrowEdgeCases.t.sol diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol index d6132fad0..adde8dda9 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.22; +import { IAgreementCollector } from "../../horizon/IAgreementCollector.sol"; import { IPaymentsEscrow } from "../../horizon/IPaymentsEscrow.sol"; import { IRecurringEscrowManagement } from "./IRecurringEscrowManagement.sol"; @@ -39,18 +40,20 @@ interface IRecurringAgreementHelper { } /** - * @notice Per-(collector, provider) pair financial summary + * @notice Per-(collector, provider) financial summary * @param collector The collector address * @param provider The provider address * @param agreementCount Number of agreements for this pair * @param sumMaxNextClaim Sum of maxNextClaim for this pair + * @param escrowSnap Cached escrow balance (compare with escrow.balance to detect staleness) * @param escrow Escrow account state (balance, tokensThawing, thawEndTimestamp) */ - struct PairAudit { - address collector; + struct ProviderAudit { + IAgreementCollector collector; address provider; uint256 agreementCount; uint256 sumMaxNextClaim; + uint256 escrowSnap; IPaymentsEscrow.EscrowAccount escrow; } @@ -63,50 +66,128 @@ interface IRecurringAgreementHelper { function auditGlobal() external view returns (GlobalAudit memory audit); /** - * @notice All pair summaries for a specific collector + * @notice All provider summaries for a specific collector * @param collector The collector address - * @return pairs Array of pair audit structs + * @return providers Array of provider audit structs */ - function auditPairs(address collector) external view returns (PairAudit[] memory pairs); + function auditProviders(IAgreementCollector collector) external view returns (ProviderAudit[] memory providers); /** - * @notice Paginated pair summaries for a collector + * @notice Paginated provider summaries for a collector * @param collector The collector address * @param offset Index to start from * @param count Maximum number to return - * @return pairs Array of pair audit structs + * @return providers Array of provider audit structs */ - function auditPairs( - address collector, + function auditProviders( + IAgreementCollector collector, uint256 offset, uint256 count - ) external view returns (PairAudit[] memory pairs); + ) external view returns (ProviderAudit[] memory providers); /** - * @notice Single pair summary + * @notice Single provider summary * @param collector The collector address * @param provider The provider address - * @return pair The pair audit struct + * @return providerAudit The provider audit struct */ - function auditPair(address collector, address provider) external view returns (PairAudit memory pair); + function auditProvider( + IAgreementCollector collector, + address provider + ) external view returns (ProviderAudit memory providerAudit); - // -- Reconciliation -- + // -- Enumeration Views -- + + /** + * @notice Get all managed agreement IDs for a (collector, provider) pair + * @param collector The collector address + * @param provider The provider address + * @return agreementIds The array of agreement IDs + */ + function getAgreements( + IAgreementCollector collector, + address provider + ) external view returns (bytes16[] memory agreementIds); + + /** + * @notice Get a paginated slice of managed agreement IDs for a (collector, provider) pair + * @param collector The collector address + * @param provider The provider address + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return agreementIds The array of agreement IDs + */ + function getAgreements( + IAgreementCollector collector, + address provider, + uint256 offset, + uint256 count + ) external view returns (bytes16[] memory agreementIds); /** - * @notice Reconcile all agreements for a provider, cleaning up fully settled ones. - * @dev Permissionless. O(n) gas — may hit gas limits with many agreements. - * @param provider The provider to reconcile - * @return removed Number of agreements removed during reconciliation + * @notice Get all collector addresses with active agreements + * @return result Array of collector addresses */ - function reconcile(address provider) external returns (uint256 removed); + function getCollectors() external view returns (address[] memory result); /** - * @notice Reconcile a batch of specific agreement IDs, cleaning up fully settled ones. - * @dev Permissionless. Skips non-existent agreements. - * @param agreementIds The agreement IDs to reconcile - * @return removed Number of agreements removed during reconciliation + * @notice Get a paginated slice of collector addresses + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return result Array of collector addresses */ - function reconcileBatch(bytes16[] calldata agreementIds) external returns (uint256 removed); + function getCollectors(uint256 offset, uint256 count) external view returns (address[] memory result); + + /** + * @notice Get all provider addresses with active agreements for a collector + * @param collector The collector address + * @return result Array of provider addresses + */ + function getProviders(IAgreementCollector collector) external view returns (address[] memory result); + + /** + * @notice Get a paginated slice of provider addresses for a collector + * @param collector The collector address + * @param offset The index to start from + * @param count Maximum number to return (clamped to available) + * @return result Array of provider addresses + */ + function getProviders( + IAgreementCollector collector, + uint256 offset, + uint256 count + ) external view returns (address[] memory result); + + // -- Reconciliation Discovery -- + + /** + * @notice Per-agreement staleness info for reconciliation discovery + * @param agreementId The agreement ID + * @param cachedMaxNextClaim The RAM's cached maxNextClaim + * @param liveMaxNextClaim The collector's current maxNextClaim + * @param stale True if cached != live (reconciliation needed) + */ + struct AgreementStaleness { + bytes16 agreementId; + uint256 cachedMaxNextClaim; + uint256 liveMaxNextClaim; + bool stale; + } + + /** + * @notice Check which agreements in a (collector, provider) pair need reconciliation + * @dev Compares cached maxNextClaim against live collector values. + * @param collector The collector address + * @param provider The provider address + * @return staleAgreements Array of staleness info per agreement + * @return escrowStale True if escrowSnap differs from actual escrow balance + */ + function checkStaleness( + IAgreementCollector collector, + address provider + ) external view returns (AgreementStaleness[] memory staleAgreements, bool escrowStale); + + // -- Reconciliation -- /** * @notice Reconcile all agreements for a (collector, provider) pair, then @@ -115,9 +196,12 @@ interface IRecurringAgreementHelper { * @param collector The collector address * @param provider The provider address * @return removed Number of agreements removed - * @return pairExists True if the pair is still tracked + * @return providerExists True if the provider is still tracked */ - function reconcilePair(address collector, address provider) external returns (uint256 removed, bool pairExists); + function reconcile( + IAgreementCollector collector, + address provider + ) external returns (uint256 removed, bool providerExists); /** * @notice Reconcile all pairs for a collector, then attempt collector removal. @@ -126,7 +210,7 @@ interface IRecurringAgreementHelper { * @return removed Total agreements removed * @return collectorExists True if the collector is still tracked */ - function reconcileCollector(address collector) external returns (uint256 removed, bool collectorExists); + function reconcileCollector(IAgreementCollector collector) external returns (uint256 removed, bool collectorExists); /** * @notice Reconcile all agreements across all collectors and providers. diff --git a/packages/issuance/audits/PR1301/TRST-L-5.md b/packages/issuance/audits/PR1301/TRST-L-5.md index fa2c1e37e..812ac5c35 100644 --- a/packages/issuance/audits/PR1301/TRST-L-5.md +++ b/packages/issuance/audits/PR1301/TRST-L-5.md @@ -20,3 +20,7 @@ Align `_computeMaxFirstClaim()` with the RecurringCollector's `getMaxNextClaim() ## Team Response TBD + +--- + +RAM delegates to `IRecurringCollector.getMaxNextClaim(agreementId)` for all `maxNextClaim` calculations. The RC's `_maxClaimForTerms` correctly caps the collection window by remaining time until `endsAt`, eliminating the overestimate. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol index ca934e131..2f01d9183 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementHelper.sol @@ -7,7 +7,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; -import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; /** * @title RecurringAgreementHelper @@ -21,8 +21,11 @@ import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon * bugs. We may have an active bug bounty program. */ contract RecurringAgreementHelper is IRecurringAgreementHelper { - /// @notice The RecurringAgreementManager contract address - address public immutable MANAGER; + /// @notice The RecurringAgreementManager contract (management interface) + IRecurringAgreementManagement public immutable MANAGER; + + /// @notice The RecurringAgreementManager contract (read-only interface) + IRecurringAgreements public immutable AGREEMENTS; /// @notice The GRT token contract IERC20 public immutable GRAPH_TOKEN; @@ -38,7 +41,8 @@ contract RecurringAgreementHelper is IRecurringAgreementHelper { constructor(address manager, IERC20 graphToken) { require(manager != address(0), ZeroAddress()); require(address(graphToken) != address(0), ZeroAddress()); - MANAGER = manager; + MANAGER = IRecurringAgreementManagement(manager); + AGREEMENTS = IRecurringAgreements(manager); GRAPH_TOKEN = graphToken; } @@ -46,126 +50,192 @@ contract RecurringAgreementHelper is IRecurringAgreementHelper { /// @inheritdoc IRecurringAgreementHelper function auditGlobal() external view returns (GlobalAudit memory audit) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); audit = GlobalAudit({ - tokenBalance: GRAPH_TOKEN.balanceOf(MANAGER), - sumMaxNextClaimAll: mgr.getSumMaxNextClaimAll(), - totalEscrowDeficit: mgr.getTotalEscrowDeficit(), - totalAgreementCount: mgr.getTotalAgreementCount(), - escrowBasis: mgr.getEscrowBasis(), - minOnDemandBasisThreshold: mgr.getMinOnDemandBasisThreshold(), - minFullBasisMargin: mgr.getMinFullBasisMargin(), - collectorCount: mgr.getCollectorCount() + tokenBalance: GRAPH_TOKEN.balanceOf(address(MANAGER)), + sumMaxNextClaimAll: AGREEMENTS.getSumMaxNextClaim(), + totalEscrowDeficit: AGREEMENTS.getTotalEscrowDeficit(), + escrowBasis: AGREEMENTS.getEscrowBasis(), + minOnDemandBasisThreshold: AGREEMENTS.getMinOnDemandBasisThreshold(), + minFullBasisMargin: AGREEMENTS.getMinFullBasisMargin(), + collectorCount: AGREEMENTS.getCollectorCount() }); } /// @inheritdoc IRecurringAgreementHelper - function auditPairs(address collector) external view returns (PairAudit[] memory pairs) { - return _auditPairs(collector, 0, type(uint256).max); + function auditProviders(IAgreementCollector collector) external view returns (ProviderAudit[] memory pairs) { + return _auditProviders(collector, 0, type(uint256).max); } /// @inheritdoc IRecurringAgreementHelper - function auditPairs( - address collector, + function auditProviders( + IAgreementCollector collector, uint256 offset, uint256 count - ) external view returns (PairAudit[] memory pairs) { - return _auditPairs(collector, offset, count); + ) external view returns (ProviderAudit[] memory pairs) { + return _auditProviders(collector, offset, count); } /// @inheritdoc IRecurringAgreementHelper - function auditPair(address collector, address provider) external view returns (PairAudit memory pair) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - pair = PairAudit({ + function auditProvider( + IAgreementCollector collector, + address provider + ) external view returns (ProviderAudit memory pair) { + pair = ProviderAudit({ collector: collector, provider: provider, - agreementCount: mgr.getPairAgreementCount(collector, provider), - sumMaxNextClaim: mgr.getSumMaxNextClaim(IRecurringCollector(collector), provider), - escrow: mgr.getEscrowAccount(IRecurringCollector(collector), provider) + agreementCount: AGREEMENTS.getAgreementCount(collector, provider), + sumMaxNextClaim: AGREEMENTS.getSumMaxNextClaim(collector, provider), + escrowSnap: AGREEMENTS.getEscrowSnap(collector, provider), + escrow: AGREEMENTS.getEscrowAccount(collector, provider) }); } - // -- Reconciliation -- + // -- Enumeration Views -- + + /// @inheritdoc IRecurringAgreementHelper + function getAgreements(IAgreementCollector collector, address provider) external view returns (bytes16[] memory) { + return getAgreements(collector, provider, 0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreementHelper + function getAgreements( + IAgreementCollector collector, + address provider, + uint256 offset, + uint256 count + ) public view returns (bytes16[] memory result) { + uint256 total = AGREEMENTS.getAgreementCount(collector, provider); + // solhint-disable-next-line gas-strict-inequalities + if (total <= offset) return new bytes16[](0); + uint256 remaining = total - offset; + if (remaining < count) count = remaining; + result = new bytes16[](count); + for (uint256 i = 0; i < count; ++i) result[i] = AGREEMENTS.getAgreementAt(collector, provider, offset + i); + } + + /// @inheritdoc IRecurringAgreementHelper + function getCollectors() external view returns (address[] memory) { + return getCollectors(0, type(uint256).max); + } /// @inheritdoc IRecurringAgreementHelper - function reconcile(address provider) external returns (uint256 removed) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); - bytes16[] memory ids = mgr.getProviderAgreements(provider); - for (uint256 i = 0; i < ids.length; ++i) if (!mgt.reconcileAgreement(ids[i])) ++removed; + function getCollectors(uint256 offset, uint256 count) public view returns (address[] memory result) { + uint256 total = AGREEMENTS.getCollectorCount(); + // solhint-disable-next-line gas-strict-inequalities + if (total <= offset) return new address[](0); + uint256 remaining = total - offset; + if (remaining < count) count = remaining; + result = new address[](count); + for (uint256 i = 0; i < count; ++i) result[i] = address(AGREEMENTS.getCollectorAt(offset + i)); } /// @inheritdoc IRecurringAgreementHelper - function reconcileBatch(bytes16[] calldata agreementIds) external returns (uint256 removed) { - IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); - for (uint256 i = 0; i < agreementIds.length; ++i) { - if (!mgt.reconcileAgreement(agreementIds[i])) ++removed; + function getProviders(IAgreementCollector collector) external view returns (address[] memory) { + return getProviders(collector, 0, type(uint256).max); + } + + /// @inheritdoc IRecurringAgreementHelper + function getProviders( + IAgreementCollector collector, + uint256 offset, + uint256 count + ) public view returns (address[] memory result) { + uint256 total = AGREEMENTS.getProviderCount(collector); + // solhint-disable-next-line gas-strict-inequalities + if (total <= offset) return new address[](0); + uint256 remaining = total - offset; + if (remaining < count) count = remaining; + result = new address[](count); + for (uint256 i = 0; i < count; ++i) result[i] = AGREEMENTS.getProviderAt(collector, offset + i); + } + + // -- Reconciliation Discovery -- + + /// @inheritdoc IRecurringAgreementHelper + function checkStaleness( + IAgreementCollector collector, + address provider + ) external view returns (AgreementStaleness[] memory staleAgreements, bool escrowStale) { + uint256 count = AGREEMENTS.getAgreementCount(collector, provider); + staleAgreements = new AgreementStaleness[](count); + for (uint256 i = 0; i < count; ++i) { + bytes16 id = AGREEMENTS.getAgreementAt(collector, provider, i); + uint256 cached = AGREEMENTS.getAgreementMaxNextClaim(collector, id); + uint256 live = collector.getMaxNextClaim(id); + staleAgreements[i] = AgreementStaleness({ + agreementId: id, + cachedMaxNextClaim: cached, + liveMaxNextClaim: live, + stale: cached != live + }); } + escrowStale = + AGREEMENTS.getEscrowSnap(collector, provider) != AGREEMENTS.getEscrowAccount(collector, provider).balance; } + // -- Reconciliation -- + /// @inheritdoc IRecurringAgreementHelper - function reconcilePair(address collector, address provider) external returns (uint256 removed, bool pairExists) { - removed = _reconcilePair(collector, provider); - pairExists = IRecurringAgreementManagement(MANAGER).reconcileCollectorProvider(collector, provider); + function reconcile( + IAgreementCollector collector, + address provider + ) external returns (uint256 removed, bool providerExists) { + removed = _reconcile(collector, provider); + providerExists = MANAGER.reconcileProvider(collector, provider); } /// @inheritdoc IRecurringAgreementHelper - function reconcileCollector(address collector) external returns (uint256 removed, bool collectorExists) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); + function reconcileCollector( + IAgreementCollector collector + ) external returns (uint256 removed, bool collectorExists) { // Snapshot providers before iterating (removal modifies the set) - address[] memory providers = mgr.getCollectorProviders(collector); + address[] memory providers = this.getProviders(collector); for (uint256 p = 0; p < providers.length; ++p) { - removed += _reconcilePair(collector, providers[p]); - mgt.reconcileCollectorProvider(collector, providers[p]); + removed += _reconcile(collector, providers[p]); + MANAGER.reconcileProvider(collector, providers[p]); } - collectorExists = mgr.getCollectorProviders(collector).length != 0; + collectorExists = AGREEMENTS.getProviderCount(collector) != 0; } /// @inheritdoc IRecurringAgreementHelper function reconcileAll() external returns (uint256 removed) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); // Snapshot collectors before iterating - address[] memory collectors = mgr.getCollectors(); + address[] memory collectors = this.getCollectors(); for (uint256 c = 0; c < collectors.length; ++c) { - address[] memory providers = mgr.getCollectorProviders(collectors[c]); + IAgreementCollector collector = IAgreementCollector(collectors[c]); + address[] memory providers = this.getProviders(collector); for (uint256 p = 0; p < providers.length; ++p) { - removed += _reconcilePair(collectors[c], providers[p]); - mgt.reconcileCollectorProvider(collectors[c], providers[p]); + removed += _reconcile(collector, providers[p]); + MANAGER.reconcileProvider(collector, providers[p]); } } } // -- Private Helpers -- - function _auditPairs( - address collector, + function _auditProviders( + IAgreementCollector collector, uint256 offset, uint256 count - ) private view returns (PairAudit[] memory pairs) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - address[] memory providers = mgr.getCollectorProviders(collector, offset, count); - pairs = new PairAudit[](providers.length); + ) private view returns (ProviderAudit[] memory pairs) { + address[] memory providers = this.getProviders(collector, offset, count); + pairs = new ProviderAudit[](providers.length); for (uint256 i = 0; i < providers.length; ++i) { - pairs[i] = PairAudit({ + pairs[i] = ProviderAudit({ collector: collector, provider: providers[i], - agreementCount: mgr.getPairAgreementCount(collector, providers[i]), - sumMaxNextClaim: mgr.getSumMaxNextClaim(IRecurringCollector(collector), providers[i]), - escrow: mgr.getEscrowAccount(IRecurringCollector(collector), providers[i]) + agreementCount: AGREEMENTS.getAgreementCount(collector, providers[i]), + sumMaxNextClaim: AGREEMENTS.getSumMaxNextClaim(collector, providers[i]), + escrowSnap: AGREEMENTS.getEscrowSnap(collector, providers[i]), + escrow: AGREEMENTS.getEscrowAccount(collector, providers[i]) }); } } - function _reconcilePair(address collector, address provider) private returns (uint256 removed) { - IRecurringAgreements mgr = IRecurringAgreements(MANAGER); - IRecurringAgreementManagement mgt = IRecurringAgreementManagement(MANAGER); - bytes16[] memory ids = mgr.getProviderAgreements(provider); + function _reconcile(IAgreementCollector collector, address provider) private returns (uint256 removed) { + bytes16[] memory ids = this.getAgreements(collector, provider); for (uint256 i = 0; i < ids.length; ++i) { - if (address(mgr.getAgreementInfo(ids[i]).collector) == collector) { - if (!mgt.reconcileAgreement(ids[i])) ++removed; - } + if (!MANAGER.reconcileAgreement(collector, ids[i])) ++removed; } } } diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 7d66e6f52..881208eed 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -29,23 +29,57 @@ import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/Reentran /** * @title RecurringAgreementManager * @author Edge & Node - * @notice Manages escrow for RCAs (Recurring Collection Agreements) using - * issuance-allocated tokens. This contract: + * @notice Manages escrow for collector-managed agreements using issuance-allocated tokens. + * This contract: * - * 1. Receives minted GRT from IssuanceAllocator (implements IIssuanceTarget) - * 2. Authorizes RCA acceptance via contract callback (implements IAgreementOwner) - * 3. Tracks max-next-claim per agreement, deposits into PaymentsEscrow to cover maximums + * 1. Receives minted GRT from IssuanceAllocator ({IIssuanceTarget}) + * 2. Offers and cancels agreements by calling collectors directly (AGREEMENT_MANAGER_ROLE-gated) + * 3. Handles collection callbacks — JIT escrow top-up and post-collection reconciliation + * ({IAgreementOwner}) + * 4. Tracks max-next-claim per agreement, deposits into PaymentsEscrow to cover maximums * - * One escrow per (this contract, collector, provider) covers all managed - * RCAs for that (collector, provider) pair. Each agreement stores its own collector - * address. Other participants can independently use RCAs via the standard ECDSA-signed flow. + * One escrow per (this contract, collector, provider) covers all managed agreements for that + * (collector, provider) pair. Agreements are namespaced under their collector to prevent + * cross-collector ID collisions. * - * @custom:security CEI — All external calls target trusted protocol contracts (PaymentsEscrow, - * GRT, RecurringCollector) except {cancelAgreement}'s call to the data service, which is - * governance-gated, and {_ensureIncomingDistributionToCurrentBlock}'s call to the issuance - * allocator, which is also governance-gated. {nonReentrant} on {beforeCollection}, - * {afterCollection}, and {cancelAgreement} guards against reentrancy through these external - * calls as defence-in-depth. + * @custom:design-coupling All collector interactions go through {IAgreementCollector}: + * discovery via {IAgreementCollector.getAgreementDetails}, claim computation via + * {IAgreementCollector.getMaxNextClaim}. A collector with a different pricing model or + * agreement type works without changes here. + * + * @custom:security CEI — external calls target trusted protocol contracts (PaymentsEscrow, + * GRT, issuance allocator) which are governance-gated. + * + * Collector trust: collectors are COLLECTOR_ROLE-gated (governor-managed). {offerAgreement} + * and {cancelAgreement} call collectors directly. Discovery calls `getAgreementDetails`; + * reconciliation calls `getMaxNextClaim` — these return values drive escrow accounting. + * A broken or malicious collector can cause reconciliation to revert; use + * {forceRemoveAgreement} as an operator escape hatch. Once tracked, reconciliation proceeds + * even if COLLECTOR_ROLE is later revoked, ensuring orderly settlement. + * + * {offerAgreement} and {cancelAgreement} forward to the collector then reconcile locally. + * The collector does not callback to `msg.sender`, so these methods own the full call + * sequence and hold the reentrancy lock for the entire operation. + * + * All state-mutating entry points are {nonReentrant}. + * + * @custom:security-pause This contract and RecurringCollector are independently pausable. + * + * When paused, all permissionless state-changing operations are blocked: collection callbacks, + * reconciliation, and agreement management. Operator-gated functions ({forceRemoveAgreement}, + * configuration setters) remain callable during pause. + * + * Cross-contract: when this contract is paused but RecurringCollector is not, providers can + * still collect. The collector proceeds but payer callbacks revert (low-level calls, so + * collection succeeds without JIT top-up). Escrow accounting drifts until unpaused and + * {reconcileAgreement} is called. To fully halt collections, pause RecurringCollector too. + * + * Escalation ladder (targeted → full stop): + * 1. {emergencyRevokeRole} — disable a specific actor (operator, collector, guardian) + * 2. {emergencyClearEligibilityOracle} — fail-open if oracle blocks collections + * 3. Pause this contract — stops all permissionless escrow management + * 4. Pause RecurringCollector — stops all collections and state changes + * 5. Pause both — full halt * * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. @@ -106,39 +140,49 @@ contract RecurringAgreementManager is // -- Storage (ERC-7201) -- + /** + * @notice Per-(collector, provider) pair tracking data + * @param sumMaxNextClaim Sum of maxNextClaim for all agreements in this pair + * @param escrowSnap Last known escrow balance (for snapshot diff) + * @param agreements Set of agreement IDs for this pair (stored as bytes32 for EnumerableSet) + */ + struct CollectorProviderData { + uint256 sumMaxNextClaim; + uint256 escrowSnap; + EnumerableSet.Bytes32Set agreements; + } + + /** + * @notice Per-collector tracking data + * @param agreements Agreement data keyed by agreement ID + * @param providers Per-provider tracking data + * @param providerSet Set of provider addresses with active agreements + */ + struct CollectorData { + mapping(bytes16 agreementId => AgreementInfo) agreements; + mapping(address provider => CollectorProviderData) providers; + EnumerableSet.AddressSet providerSet; + } + /// @custom:storage-location erc7201:graphprotocol.issuance.storage.RecurringAgreementManager // solhint-disable-next-line gas-struct-packing struct RecurringAgreementManagerStorage { - /// @notice Authorized agreement hashes — maps hash to agreementId (bytes16(0) = not authorized) - mapping(bytes32 agreementHash => bytes16) authorizedHashes; - /// @notice Per-agreement tracking data - mapping(bytes16 agreementId => AgreementInfo) agreements; - /// @notice Sum of maxNextClaim for all agreements per (collector, provider) pair - mapping(address collector => mapping(address provider => uint256)) sumMaxNextClaim; - /// @notice Set of agreement IDs per service provider (stored as bytes32 for EnumerableSet) - mapping(address provider => EnumerableSet.Bytes32Set) providerAgreementIds; + /// @notice Per-collector tracking data (agreements, providers, escrow) + mapping(address collector => CollectorData) collectors; + /// @notice Set of all collector addresses with active agreements + EnumerableSet.AddressSet collectorSet; /// @notice Sum of sumMaxNextClaim across all (collector, provider) pairs uint256 sumMaxNextClaimAll; /// @notice Total unfunded escrow: sum of max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p]) uint256 totalEscrowDeficit; - /// @notice Total number of tracked agreements across all providers - uint256 totalAgreementCount; - /// @notice Last known escrow balance per (collector, provider) pair (for snapshot diff) - mapping(address collector => mapping(address provider => uint256)) escrowSnap; - /// @notice Set of all collector addresses with active agreements - EnumerableSet.AddressSet collectors; - /// @notice Set of provider addresses per collector - mapping(address collector => EnumerableSet.AddressSet) collectorProviders; - /// @notice Number of agreements per (collector, provider) pair - mapping(address collector => mapping(address provider => uint256)) pairAgreementCount; /// @notice The issuance allocator that mints GRT to this contract (20 bytes) - /// @dev Packed slot (32/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (8) + + /// @dev Packed slot (28/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (4) + /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1) + minThawFraction (1). - /// All read together in _updateEscrow / beforeCollection. + /// All read together in _reconcileProviderEscrow / beforeCollection. IIssuanceAllocationDistribution issuanceAllocator; /// @notice Block number when _ensureIncomingDistributionToCurrentBlock last ran - uint64 ensuredIncomingDistributedToBlock; - /// @notice Governance-configured escrow level (maximum target) + uint32 ensuredIncomingDistributedToBlock; + /// @notice Governance-configured escrow level (maximum aspiration) EscrowBasis escrowBasis; /// @notice Threshold for OnDemand: sumMaxNextClaimAll * threshold / 256 < spare. /// Governance-configured. @@ -238,25 +282,17 @@ contract RecurringAgreementManager is // -- IAgreementOwner -- /// @inheritdoc IAgreementOwner - function approveAgreement(bytes32 agreementHash) external view override returns (bytes4) { - RecurringAgreementManagerStorage storage $ = _getStorage(); - bytes16 agreementId = $.authorizedHashes[agreementHash]; - - if (agreementId == bytes16(0) || $.agreements[agreementId].provider == address(0)) return bytes4(0); - - return IAgreementOwner.approveAgreement.selector; - } - - /// @inheritdoc IAgreementOwner - function beforeCollection(bytes16 agreementId, uint256 tokensToCollect) external override nonReentrant { + function beforeCollection( + bytes16 agreementId, + uint256 tokensToCollect + ) external override whenNotPaused nonReentrant { RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - address provider = agreement.provider; + address collector = msg.sender; + address provider = _getAgreementProvider($, collector, agreementId); if (provider == address(0)) return; - _requireCollector(agreement); // JIT top-up: deposit only when escrow balance cannot cover this collection - uint256 escrowBalance = _fetchEscrowAccount(msg.sender, provider).balance; + uint256 escrowBalance = _fetchEscrowAccount(collector, provider).balance; if (tokensToCollect <= escrowBalance) return; // Ensure issuance is distributed so balanceOf reflects all available tokens @@ -265,18 +301,16 @@ contract RecurringAgreementManager is uint256 deficit = tokensToCollect - escrowBalance; if (deficit < GRAPH_TOKEN.balanceOf(address(this))) { GRAPH_TOKEN.approve(address(PAYMENTS_ESCROW), deficit); - PAYMENTS_ESCROW.deposit(msg.sender, provider, deficit); + PAYMENTS_ESCROW.deposit(collector, provider, deficit); } } /// @inheritdoc IAgreementOwner - function afterCollection(bytes16 agreementId, uint256 /* tokensCollected */) external override nonReentrant { - RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - if (agreement.provider == address(0)) return; - _requireCollector(agreement); - - _reconcileAndUpdateEscrow($, agreementId); + function afterCollection( + bytes16 agreementId, + uint256 /* tokensCollected */ + ) external override whenNotPaused nonReentrant { + _reconcileAgreement(_getStorage(), msg.sender, agreementId); } // -- IRecurringAgreementManagement -- @@ -344,17 +378,19 @@ contract RecurringAgreementManager is } /// @inheritdoc IRecurringAgreementManagement - function reconcileAgreement(bytes16 agreementId) external returns (bool exists) { - RecurringAgreementManagerStorage storage $ = _getStorage(); - AgreementInfo storage agreement = $.agreements[agreementId]; - if (agreement.provider == address(0)) return false; - - return !_reconcileAndCleanup($, agreementId, agreement); + function reconcileAgreement( + IAgreementCollector collector, + bytes16 agreementId + ) external whenNotPaused nonReentrant returns (bool tracked) { + tracked = _reconcileAgreement(_getStorage(), address(collector), agreementId); } /// @inheritdoc IRecurringAgreementManagement - function reconcileCollectorProvider(address collector, address provider) external returns (bool exists) { - return !_reconcilePairTracking(_getStorage(), collector, provider); + function reconcileProvider( + IAgreementCollector collector, + address provider + ) external whenNotPaused nonReentrant returns (bool tracked) { + return _reconcileProvider(_getStorage(), address(collector), provider); } // -- IRecurringEscrowManagement -- @@ -531,236 +567,180 @@ contract RecurringAgreementManager is return _getStorage().collectors[address(collector)].providers[provider].escrowSnap; } - // -- Internal Functions -- - - /** - * @notice Require that msg.sender is the agreement's collector. - * @param agreement The agreement info to check against - */ - function _requireCollector(AgreementInfo storage agreement) private view { - require(msg.sender == address(agreement.collector), OnlyAgreementCollector()); - } - /** - * @notice Create agreement storage, authorize its hash, update pair tracking, and set max-next-claim. - * @param agreementId The generated agreement ID - * @param rca The recurring collection agreement parameters - * @param collector The collector contract - * @param agreementHash The hash of the RCA to authorize - * @return maxNextClaim The computed max-next-claim for the new agreement + * @notice Get the service provider for an agreement, discovering from the collector if first-seen. + * @dev Returns the cached provider for known agreements. For first-seen agreements: + * reads from the collector, validates roles and payer, registers in tracking sets, + * and returns the provider. Returns address(0) for agreements that don't belong to + * this manager (unauthorized collector, wrong payer, unauthorized data service, or + * non-existent). Once tracked, reconciliation bypasses this function's discovery path. + * @param $ The storage reference + * @param collector The collector contract address + * @param agreementId The agreement ID + * @return provider The service provider address, or address(0) if not ours */ // solhint-disable-next-line use-natspec - function _createAgreement( + function _getAgreementProvider( RecurringAgreementManagerStorage storage $, - bytes16 agreementId, - IRecurringCollector.RecurringCollectionAgreement calldata rca, - IRecurringCollector collector, - bytes32 agreementHash - ) private returns (uint256 maxNextClaim) { - $.authorizedHashes[agreementHash] = agreementId; - - $.agreements[agreementId] = AgreementInfo({ - provider: rca.serviceProvider, - deadline: rca.deadline, - pendingUpdateNonce: 0, - maxNextClaim: 0, - pendingUpdateMaxNextClaim: 0, - agreementHash: agreementHash, - pendingUpdateHash: bytes32(0), - dataService: IDataServiceAgreements(rca.dataService), - collector: collector - }); - $.providerAgreementIds[rca.serviceProvider].add(bytes32(agreementId)); - ++$.totalAgreementCount; - if (++$.pairAgreementCount[address(collector)][rca.serviceProvider] == 1) { - $.collectorProviders[address(collector)].add(rca.serviceProvider); - $.collectors.add(address(collector)); + address collector, + bytes16 agreementId + ) private returns (address provider) { + provider = $.collectors[collector].agreements[agreementId].provider; + if (provider != address(0)) return provider; + + // Untracked agreement; validate collector role, existence, payer, and data service. + // COLLECTOR_ROLE is required for discovery (first encounter). Once tracked, reconciliation + // of already-added agreements proceeds regardless of role — a deauthorized collector's + // agreements can still be reconciled, settled, and force-removed. + if (!hasRole(COLLECTOR_ROLE, collector)) { + emit AgreementRejected(agreementId, collector, AgreementRejectionReason.UnauthorizedCollector); + return address(0); } - - maxNextClaim = _computeMaxFirstClaim( - rca.maxOngoingTokensPerSecond, - rca.maxSecondsPerCollection, - rca.maxInitialTokens + IAgreementCollector.AgreementDetails memory details = IAgreementCollector(collector).getAgreementDetails( + agreementId, + 0 ); - _setAgreementMaxNextClaim($, agreementId, maxNextClaim, false); - } - - /** - * @notice Compute maximum first claim from agreement rate parameters. - * @param maxOngoingTokensPerSecond Maximum ongoing tokens per second - * @param maxSecondsPerCollection Maximum seconds per collection period - * @param maxInitialTokens Maximum initial tokens - * @return Maximum possible claim amount - */ - function _computeMaxFirstClaim( - uint256 maxOngoingTokensPerSecond, - uint256 maxSecondsPerCollection, - uint256 maxInitialTokens - ) private pure returns (uint256) { - return maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens; - } + provider = details.serviceProvider; + if (provider == address(0)) { + emit AgreementRejected(agreementId, collector, AgreementRejectionReason.UnknownAgreement); + return address(0); + } + if (details.payer != address(this)) { + emit AgreementRejected(agreementId, collector, AgreementRejectionReason.PayerMismatch); + return address(0); + } + if (!hasRole(DATA_SERVICE_ROLE, details.dataService)) { + emit AgreementRejected(agreementId, collector, AgreementRejectionReason.UnauthorizedDataService); + return address(0); + } - /** - * @notice Reconcile an agreement and update escrow for its (collector, provider) pair. - * @param agreementId The agreement ID to reconcile - */ - // solhint-disable-next-line use-natspec - function _reconcileAndUpdateEscrow(RecurringAgreementManagerStorage storage $, bytes16 agreementId) private { - _reconcileAgreement($, agreementId); - AgreementInfo storage info = $.agreements[agreementId]; - _updateEscrow($, address(info.collector), info.provider); + // Register agreement + $.collectors[collector].agreements[agreementId].provider = provider; + CollectorProviderData storage cpd = $.collectors[collector].providers[provider]; + cpd.agreements.add(bytes32(agreementId)); + $.collectors[collector].providerSet.add(provider); + $.collectorSet.add(collector); + emit AgreementAdded(agreementId, collector, details.dataService, provider); } /** - * @notice Reconcile an agreement, update escrow, and delete if nothing left to claim. - * @param agreementId The agreement ID to reconcile - * @param agreement Storage pointer to the agreement info - * @return deleted True if the agreement was removed + * @notice Discover (if first-seen) and reconcile a single agreement. + * @dev Used by {afterCollection}, {reconcileAgreement}, {offerAgreement}, and {cancelAgreement}. + * Resolves the provider via {_getAgreementProvider}, refreshes the cached + * maxNextClaim from the collector, and reconciles escrow. + * @param $ The storage reference + * @param collector The collector contract address + * @param agreementId The agreement ID + * @return tracked True if the agreement is still tracked after this call */ // solhint-disable-next-line use-natspec - function _reconcileAndCleanup( + function _reconcileAgreement( RecurringAgreementManagerStorage storage $, - bytes16 agreementId, - AgreementInfo storage agreement - ) private returns (bool deleted) { - _reconcileAndUpdateEscrow($, agreementId); - if (agreement.maxNextClaim == 0) { - address provider = _deleteAgreement($, agreementId, agreement); - emit AgreementRemoved(agreementId, provider); - return true; - } - } + address collector, + bytes16 agreementId + ) private returns (bool tracked) { + address provider = _getAgreementProvider($, collector, agreementId); + if (provider == address(0)) return false; - /** - * @notice Reconcile a single agreement's max next claim against on-chain state - * @param agreementId The agreement ID to reconcile - */ - // solhint-disable-next-line use-natspec - function _reconcileAgreement(RecurringAgreementManagerStorage storage $, bytes16 agreementId) private { - AgreementInfo storage agreement = $.agreements[agreementId]; - - IRecurringCollector rc = agreement.collector; - IRecurringCollector.AgreementData memory rca = rc.getAgreement(agreementId); - - // Not yet accepted — keep the pre-offer estimate unless the deadline has passed - if (rca.state == IRecurringCollector.AgreementState.NotAccepted) { - if (block.timestamp <= agreement.deadline) return; - // Deadline passed: zero out so the caller can delete the expired offer - uint256 prev = agreement.maxNextClaim; - if (prev != 0) { - _setAgreementMaxNextClaim($, agreementId, 0, false); - emit AgreementReconciled(agreementId, prev, 0); - } - return; - } + AgreementInfo storage agreement = $.collectors[collector].agreements[agreementId]; + CollectorProviderData storage cpd = $.collectors[collector].providers[provider]; - // Clear pending update if applied (updateNonce advanced) or unreachable (agreement canceled) - if ( - agreement.pendingUpdateHash != bytes32(0) && - (agreement.pendingUpdateNonce <= rca.updateNonce || - rca.state != IRecurringCollector.AgreementState.Accepted) - ) { - _setAgreementMaxNextClaim($, agreementId, 0, true); - delete $.authorizedHashes[agreement.pendingUpdateHash]; - agreement.pendingUpdateNonce = 0; - agreement.pendingUpdateHash = bytes32(0); - } + // Refresh cached maxNextClaim from collector + uint256 newMaxClaim = IAgreementCollector(collector).getMaxNextClaim(agreementId); - uint256 oldMaxClaim = agreement.maxNextClaim; - uint256 newMaxClaim = rc.getMaxNextClaim(agreementId); + // Update agreement + all derived totals (reads old value from storage) + uint256 oldMaxClaim = _setAgreementMaxNextClaim($, cpd, agreement, newMaxClaim); + if (oldMaxClaim != newMaxClaim) emit AgreementReconciled(agreementId, oldMaxClaim, newMaxClaim); - if (oldMaxClaim != newMaxClaim) { - _setAgreementMaxNextClaim($, agreementId, newMaxClaim, false); - emit AgreementReconciled(agreementId, oldMaxClaim, newMaxClaim); - } + tracked = newMaxClaim != 0; + if (!tracked) _removeAgreement($, cpd, collector, provider, agreementId); + else _reconcileProviderEscrow($, collector, provider); } /** - * @notice Delete an agreement: clean up hashes, zero escrow obligations, remove from provider set, and update escrow. - * @param agreementId The agreement ID to delete - * @param agreement Storage pointer to the agreement info - * @return provider The provider address (captured before deletion) + * @notice Remove an agreement and reconcile the provider's escrow. + * @dev Zeroes the agreement's maxNextClaim contribution before deleting, so callers + * do not need to call {_setAgreementMaxNextClaim} themselves. + * @param $ The storage reference + * @param cpd The provider's CollectorProviderData + * @param collector The collector contract address + * @param provider Service provider address + * @param agreementId The agreement ID */ // solhint-disable-next-line use-natspec - function _deleteAgreement( + function _removeAgreement( RecurringAgreementManagerStorage storage $, - bytes16 agreementId, - AgreementInfo storage agreement - ) private returns (address provider) { - provider = agreement.provider; - IRecurringCollector collector = agreement.collector; - - // Clean up authorized hashes - delete $.authorizedHashes[agreement.agreementHash]; - if (agreement.pendingUpdateHash != bytes32(0)) delete $.authorizedHashes[agreement.pendingUpdateHash]; - - // Zero out escrow requirements before deleting - _setAgreementMaxNextClaim($, agreementId, 0, false); - _setAgreementMaxNextClaim($, agreementId, 0, true); - --$.totalAgreementCount; - $.providerAgreementIds[provider].remove(bytes32(agreementId)); - - --$.pairAgreementCount[address(collector)][provider]; - delete $.agreements[agreementId]; - - _reconcilePairTracking($, address(collector), provider); + CollectorProviderData storage cpd, + address collector, + address provider, + bytes16 agreementId + ) private { + _setAgreementMaxNextClaim($, cpd, $.collectors[collector].agreements[agreementId], 0); + cpd.agreements.remove(bytes32(agreementId)); + delete $.collectors[collector].agreements[agreementId]; + emit AgreementRemoved(agreementId); + _reconcileProvider($, collector, provider); } /** * @notice Reconcile escrow then remove (collector, provider) tracking if fully drained. - * @dev Calls {_updateEscrow} to withdraw completed thaws, then removes the pair from - * tracking only when both pairAgreementCount and escrowSnap are zero. + * @dev Calls {_reconcileProviderEscrow} to withdraw completed thaws, then removes the pair from + * tracking only when both agreement count and escrowSnap are zero. * Cascades to remove the collector when it has no remaining providers. - * @return gone True if the pair is not tracked after this call + * @param $ The storage reference + * @param collector The collector contract address + * @param provider Service provider address + * @return tracked True if the pair is still tracked after this call */ // solhint-disable-next-line use-natspec - function _reconcilePairTracking( + function _reconcileProvider( RecurringAgreementManagerStorage storage $, address collector, address provider - ) private returns (bool gone) { - _updateEscrow($, collector, provider); - if ($.pairAgreementCount[collector][provider] != 0) return false; - if ($.escrowSnap[collector][provider] != 0) return false; - if ($.collectorProviders[collector].remove(provider)) { - emit CollectorProviderRemoved(collector, provider); - if ($.collectorProviders[collector].length() == 0) { - $.collectors.remove(collector); + ) private returns (bool tracked) { + _reconcileProviderEscrow($, collector, provider); + CollectorProviderData storage cpd = $.collectors[collector].providers[provider]; + + if (cpd.agreements.length() != 0 || cpd.escrowSnap != 0) tracked = true; + else if ($.collectors[collector].providerSet.remove(provider)) { + emit ProviderRemoved(collector, provider); + if ($.collectors[collector].providerSet.length() == 0) { + // Provider agreement count will already be zero at this point. + $.collectorSet.remove(collector); emit CollectorRemoved(collector); } } - return true; } /** - * @notice Atomically set one escrow obligation slot of an agreement and cascade to provider/global totals. - * @dev This and {_setEscrowSnap} are the only two functions that mutate totalEscrowDeficit. - * @param agreementId The agreement to update - * @param newValue The new obligation value - * @param pending If true, updates pendingUpdateMaxNextClaim; otherwise updates maxNextClaim + * @notice The sole mutation point for agreement.maxNextClaim and all derived totals. + * @dev ALL writes to agreement.maxNextClaim, sumMaxNextClaim, sumMaxNextClaimAll, and + * claim-driven totalEscrowDeficit MUST go through this function. It reads the old value + * from storage itself — callers cannot supply a stale or incorrect old value. + * (Escrow-balance-driven deficit updates go through {_setEscrowSnap} instead.) + * @param $ The storage reference + * @param cpd The collector-provider data storage pointer + * @param agreement The agreement whose maxNextClaim is changing + * @param newMaxClaim The new maxNextClaim for the agreement + * @return oldMaxClaim The previous maxNextClaim (read from storage) */ // solhint-disable-next-line use-natspec function _setAgreementMaxNextClaim( RecurringAgreementManagerStorage storage $, - bytes16 agreementId, - uint256 newValue, - bool pending - ) private { - AgreementInfo storage agreement = $.agreements[agreementId]; - - uint256 oldValue = pending ? agreement.pendingUpdateMaxNextClaim : agreement.maxNextClaim; - if (oldValue == newValue) return; - - address collector = address(agreement.collector); - address provider = agreement.provider; - uint256 oldDeficit = _providerEscrowDeficit($, collector, provider); + CollectorProviderData storage cpd, + AgreementInfo storage agreement, + uint256 newMaxClaim + ) private returns (uint256 oldMaxClaim) { + oldMaxClaim = agreement.maxNextClaim; - if (pending) agreement.pendingUpdateMaxNextClaim = newValue; - else agreement.maxNextClaim = newValue; + if (oldMaxClaim != newMaxClaim) { + agreement.maxNextClaim = newMaxClaim; - $.sumMaxNextClaim[collector][provider] = $.sumMaxNextClaim[collector][provider] - oldValue + newValue; - $.sumMaxNextClaimAll = $.sumMaxNextClaimAll - oldValue + newValue; - $.totalEscrowDeficit = $.totalEscrowDeficit - oldDeficit + _providerEscrowDeficit($, collector, provider); + uint256 oldDeficit = _providerEscrowDeficit(cpd); + cpd.sumMaxNextClaim = cpd.sumMaxNextClaim - oldMaxClaim + newMaxClaim; + $.sumMaxNextClaimAll = $.sumMaxNextClaimAll - oldMaxClaim + newMaxClaim; + $.totalEscrowDeficit = $.totalEscrowDeficit - oldDeficit + _providerEscrowDeficit(cpd); + } } /** @@ -773,20 +753,19 @@ contract RecurringAgreementManager is * | OnDemand | 0 | sumMaxNext | * | JustInTime | 0 | 0 | * - * The effective basis is the configured escrowBasis limited based on spare balance + * The effective basis is the configured escrowBasis degraded based on spare balance * (balance - totalEscrowDeficit). OnDemand requires sumMaxNextClaimAll * threshold / 256 < spare. * Full requires sumMaxNextClaimAll * (256 + margin) / 256 < spare. * - * @param collector The collector address - * @param provider The service provider + * @param $ The storage reference + * @param sumMaxNextClaim The collector-provider's sumMaxNextClaim * @return min Deposit floor — deposit if balance is below this * @return max Thaw ceiling — thaw if balance is above this */ // solhint-disable-next-line use-natspec function _escrowMinMax( RecurringAgreementManagerStorage storage $, - address collector, - address provider + uint256 sumMaxNextClaim ) private view returns (uint256 min, uint256 max) { uint256 balance = GRAPH_TOKEN.balanceOf(address(this)); uint256 totalDeficit = $.totalEscrowDeficit; @@ -795,7 +774,7 @@ contract RecurringAgreementManager is EscrowBasis basis = $.escrowBasis; max = basis != EscrowBasis.JustInTime && ((sumMaxNext * uint256($.minOnDemandBasisThreshold)) / 256 < spare) - ? $.sumMaxNextClaim[collector][provider] + ? sumMaxNextClaim : 0; min = basis == EscrowBasis.Full && ((sumMaxNext * (256 + uint256($.minFullBasisMargin))) / 256 < spare) ? max @@ -804,18 +783,13 @@ contract RecurringAgreementManager is /** * @notice Compute a (collector, provider) pair's escrow deficit: max(0, sumMaxNext - snapshot). - * @param collector The collector address - * @param provider The service provider + * @param cpd The collector-provider data * @return deficit The amount not in escrow for this (collector, provider) */ // solhint-disable-next-line use-natspec - function _providerEscrowDeficit( - RecurringAgreementManagerStorage storage $, - address collector, - address provider - ) private view returns (uint256 deficit) { - uint256 sumMaxNext = $.sumMaxNextClaim[collector][provider]; - uint256 snapshot = $.escrowSnap[collector][provider]; + function _providerEscrowDeficit(CollectorProviderData storage cpd) private view returns (uint256 deficit) { + uint256 sumMaxNext = cpd.sumMaxNextClaim; + uint256 snapshot = cpd.escrowSnap; deficit = (snapshot < sumMaxNext) ? sumMaxNext - snapshot : 0; } @@ -844,31 +818,36 @@ contract RecurringAgreementManager is * * Updates escrow snapshot at the end for global tracking. * + * @param $ The storage reference * @param collector The collector contract address * @param provider The service provider to update escrow for */ // solhint-disable-next-line use-natspec - function _updateEscrow(RecurringAgreementManagerStorage storage $, address collector, address provider) private { + function _reconcileProviderEscrow( + RecurringAgreementManagerStorage storage $, + address collector, + address provider + ) private { _ensureIncomingDistributionToCurrentBlock($); - // Sync snapshot before decisions: the escrow balance may have changed externally - // (e.g. RecurringCollector.collect drained it before calling afterCollection). + CollectorProviderData storage cpd = $.collectors[collector].providers[provider]; + // Sync snapshot before decisions: the escrow balance may have changed externally. // Without this, totalEscrowDeficit is stale → spare is overstated → basis is inflated - // → deposit attempt for tokens we don't have → revert swallowed by try/catch → snap + // → deposit attempt for tokens we don't have → revert swallowed → snap // stays permanently stale. Reading the fresh balance here makes the function // self-correcting regardless of prior callback failures. - _setEscrowSnap($, collector, provider); + _setEscrowSnap($, cpd, collector, provider); IPaymentsEscrow.EscrowAccount memory account = _fetchEscrowAccount(collector, provider); - (uint256 min, uint256 max) = _escrowMinMax($, collector, provider); + (uint256 min, uint256 max) = _escrowMinMax($, cpd.sumMaxNextClaim); // Defensive: PaymentsEscrow maintains tokensThawing <= balance, guard against external invariant breach uint256 escrowed = account.tokensThawing < account.balance ? account.balance - account.tokensThawing : 0; - // Thaw threshold: ignore thaws below this for two reasons: - // 1. Operational: small excess proportions are not worth thawing; better to wait for a larger rebalance. - // 2. Anti-griefing: an attacker could deposit dust via depositTo(), trigger reconciliation, - // and start a tiny thaw that blocks legitimate thaw increases for the entire thawing period. - uint256 thawThreshold = ($.sumMaxNextClaim[collector][provider] * uint256($.minThawFraction)) / 256; + // Thaw threshold: ignore thaws below this to prevent micro-thaw griefing. + // An attacker depositing dust via depositTo() then triggering reconciliation could start + // a tiny thaw that blocks legitimate thaw increases for the entire thawing period. + uint256 thawThreshold = (cpd.sumMaxNextClaim * uint256($.minThawFraction)) / 256; + // Objectives in order of priority: // We want to end with escrowed of at least min, and seek to thaw down to no more than max. // 1. Do not reset thaw timer if a thaw is in progress. @@ -888,7 +867,7 @@ contract RecurringAgreementManager is } _withdrawAndRebalance(collector, provider, account, min, max, thawThreshold); - _setEscrowSnap($, collector, provider); + _setEscrowSnap($, cpd, collector, provider); } /** @@ -901,7 +880,7 @@ contract RecurringAgreementManager is * @param account Current escrow account state * @param min Deposit floor * @param max Thaw ceiling - * @param thawThreshold Thaw threshold — do not initiate a thaw if excess is less than this + * @param thawThreshold Minimum excess to start a new thaw */ function _withdrawAndRebalance( address collector, @@ -942,14 +921,19 @@ contract RecurringAgreementManager is * @param provider The service provider */ // solhint-disable-next-line use-natspec - function _setEscrowSnap(RecurringAgreementManagerStorage storage $, address collector, address provider) private { - uint256 oldEscrow = $.escrowSnap[collector][provider]; + function _setEscrowSnap( + RecurringAgreementManagerStorage storage $, + CollectorProviderData storage cpd, + address collector, + address provider + ) private { + uint256 oldEscrow = cpd.escrowSnap; uint256 newEscrow = _fetchEscrowAccount(collector, provider).balance; if (oldEscrow == newEscrow) return; - uint256 oldDeficit = _providerEscrowDeficit($, collector, provider); - $.escrowSnap[collector][provider] = newEscrow; - uint256 newDeficit = _providerEscrowDeficit($, collector, provider); + uint256 oldDeficit = _providerEscrowDeficit(cpd); + cpd.escrowSnap = newEscrow; + uint256 newDeficit = _providerEscrowDeficit(cpd); $.totalEscrowDeficit = $.totalEscrowDeficit - oldDeficit + newDeficit; } @@ -970,15 +954,16 @@ contract RecurringAgreementManager is * @dev No-op if allocator is not set or already ensured this block. The local ensuredIncomingDistributedToBlock * check avoids the external call overhead (~2800 gas) on redundant same-block invocations * (e.g. beforeCollection + afterCollection in the same collection tx). + * @param $ The storage reference */ // solhint-disable-next-line use-natspec function _ensureIncomingDistributionToCurrentBlock(RecurringAgreementManagerStorage storage $) private { - // Uses low 8 bytes of block.number; consecutive blocks always differ so same-block - // dedup works correctly even past uint64 wrap. A false match requires the previous - // last call to have been exactly 2^64 blocks ago (~584 billion years at 1 block/s). - uint64 blockNum; + // Uses low 4 bytes of block.number; consecutive blocks always differ so same-block + // dedup works correctly even past uint32 wrap. A false match requires the previous + // last call to have been exactly 2^32 blocks ago (~1,630 years at 12 s/block). + uint32 blockNum; unchecked { - blockNum = uint64(block.number); + blockNum = uint32(block.number); } if ($.ensuredIncomingDistributedToBlock == blockNum) return; $.ensuredIncomingDistributedToBlock = blockNum; diff --git a/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol b/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol index 6e0eae7c3..36513982d 100644 --- a/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol +++ b/packages/issuance/test/unit/agreement-manager/afterCollection.t.sol @@ -1,9 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementManagerSharedTest { @@ -77,7 +79,7 @@ contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementMa assertEq(escrowAfter, escrowBefore); } - function test_BeforeCollection_Revert_WhenCallerNotRecurringCollector() public { + function test_BeforeCollection_NoOp_WhenCallerNotRecurringCollector() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -87,7 +89,7 @@ contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementMa bytes16 agreementId = _offerAgreement(rca); - vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + // Wrong collector sees no agreement under its namespace — silent no-op agreementManager.beforeCollection(agreementId, 100 ether); } @@ -126,11 +128,14 @@ contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementMa // After first collection, maxInitialTokens no longer applies // New max = 1e18 * 3600 = 3600e18 - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 3600 ether); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 3600 ether + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3600 ether); } - function test_AfterCollection_Revert_WhenCallerNotRecurringCollector() public { + function test_AfterCollection_NoOp_WhenCallerNotRecurringCollector() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -140,7 +145,7 @@ contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementMa bytes16 agreementId = _offerAgreement(rca); - vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); + // Wrong collector sees no agreement under its namespace — silent no-op agreementManager.afterCollection(agreementId, 100 ether); } @@ -166,7 +171,10 @@ contract RecurringAgreementManagerCollectionCallbackTest is RecurringAgreementMa vm.prank(address(recurringCollector)); agreementManager.afterCollection(agreementId, 0); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol new file mode 100644 index 000000000..f38db6a7c --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/approver.t.sol @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; + +contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- ERC165 Tests -- + + function test_SupportsInterface_IIssuanceTarget() public view { + assertTrue(agreementManager.supportsInterface(type(IIssuanceTarget).interfaceId)); + } + + function test_SupportsInterface_IAgreementOwner() public view { + assertTrue(agreementManager.supportsInterface(type(IAgreementOwner).interfaceId)); + } + + function test_SupportsInterface_IRecurringAgreementManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringAgreementManagement).interfaceId)); + } + + function test_SupportsInterface_IRecurringEscrowManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringEscrowManagement).interfaceId)); + } + + function test_SupportsInterface_IProviderEligibilityManagement() public view { + assertTrue(agreementManager.supportsInterface(type(IProviderEligibilityManagement).interfaceId)); + } + + function test_SupportsInterface_IRecurringAgreements() public view { + assertTrue(agreementManager.supportsInterface(type(IRecurringAgreements).interfaceId)); + } + + // -- IIssuanceTarget Tests -- + + function test_BeforeIssuanceAllocationChange_DoesNotRevert() public { + agreementManager.beforeIssuanceAllocationChange(); + } + + function test_SetIssuanceAllocator_OnlyGovernor() public { + address nonGovernor = makeAddr("nonGovernor"); + MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); + vm.expectRevert(); + vm.prank(nonGovernor); + agreementManager.setIssuanceAllocator(address(alloc)); + } + + function test_SetIssuanceAllocator_Governor() public { + MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); + vm.prank(governor); + agreementManager.setIssuanceAllocator(address(alloc)); + } + + // -- View Function Tests -- + + function test_GetDeficit_ZeroWhenFullyFunded() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + _offerAgreement(rca); + + // Fully funded (offerAgreement mints enough tokens) + IPaymentsEscrow.EscrowAccount memory account = agreementManager.getEscrowAccount(_collector(), indexer); + assertEq(account.balance - account.tokensThawing, agreementManager.getSumMaxNextClaim(_collector(), indexer)); + } + + function test_GetEscrowAccount_MatchesUnderlying() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + uint256 available = 500 ether; + + token.mint(address(agreementManager), available); + vm.prank(operator); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + + IPaymentsEscrow.EscrowAccount memory expected; + (expected.balance, expected.tokensThawing, expected.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + IPaymentsEscrow.EscrowAccount memory actual = agreementManager.getEscrowAccount(_collector(), indexer); + assertEq(actual.balance, expected.balance); + assertEq(actual.tokensThawing, expected.tokensThawing); + assertEq(actual.thawEndTimestamp, expected.thawEndTimestamp); + } + + function test_GetRequiredEscrow_ZeroForUnknownIndexer() public { + assertEq(agreementManager.getSumMaxNextClaim(_collector(), makeAddr("unknown")), 0); + } + + function test_GetAgreementMaxNextClaim_ZeroForUnknown() public view { + assertEq( + agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + bytes16(keccak256("unknown")) + ), + 0 + ); + } + + function test_GetIndexerAgreementCount_ZeroForUnknown() public { + assertEq( + agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), makeAddr("unknown")), + 0 + ); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol new file mode 100644 index 000000000..2b7db27a4 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { RecurringAgreementManager } from "../../../contracts/agreement/RecurringAgreementManager.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +/// @notice Targeted tests for uncovered branches in RecurringAgreementManager. +contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + bytes32 internal constant PAUSE_ROLE = keccak256("PAUSE_ROLE"); + + // ══════════════════════════════════════════════════════════════════════ + // setIssuanceAllocator — ERC165 validation (L305) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice Setting allocator to an address that does not support IIssuanceAllocationDistribution reverts. + function test_SetIssuanceAllocator_Revert_InvalidERC165() public { + // Use an address with code but wrong interface (the mock collector doesn't implement IIssuanceAllocationDistribution) + vm.prank(governor); + vm.expectRevert( + abi.encodeWithSelector( + RecurringAgreementManager.InvalidIssuanceAllocator.selector, + address(recurringCollector) + ) + ); + agreementManager.setIssuanceAllocator(address(recurringCollector)); + } + + /// @notice Setting allocator to an EOA (no code) also fails ERC165 check. + function test_SetIssuanceAllocator_Revert_EOA() public { + address eoa = makeAddr("randomEOA"); + vm.prank(governor); + vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); + agreementManager.setIssuanceAllocator(eoa); + } + + // ══════════════════════════════════════════════════════════════════════ + // offerAgreement — unauthorized collector (L372) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice offerAgreement reverts when collector lacks COLLECTOR_ROLE. + function test_OfferAgreement_Revert_UnauthorizedCollector() public { + MockRecurringCollector rogue = new MockRecurringCollector(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.payer = address(agreementManager); + + vm.prank(operator); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedCollector.selector, address(rogue)) + ); + agreementManager.offerAgreement(IRecurringCollector(address(rogue)), OFFER_TYPE_NEW, abi.encode(rca)); + } + + // ══════════════════════════════════════════════════════════════════════ + // offerAgreement — payer mismatch + // ══════════════════════════════════════════════════════════════════════ + + /// @notice offerAgreement reverts when collector returns payer != address(this). + function test_OfferAgreement_Revert_PayerMismatch() public { + address wrongPayer = makeAddr("wrongPayer"); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.payer = wrongPayer; // mock will return this as-is + + token.mint(address(agreementManager), 1_000_000 ether); + + vm.prank(operator); + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.PayerMismatch.selector, wrongPayer)); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + } + + // ══════════════════════════════════════════════════════════════════════ + // offerAgreement — zero service provider (L378) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice offerAgreement reverts when collector returns serviceProvider = address(0). + function test_OfferAgreement_Revert_ZeroServiceProvider() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.serviceProvider = address(0); // mock will return this as-is + + token.mint(address(agreementManager), 1_000_000 ether); + + vm.prank(operator); + vm.expectRevert(IRecurringAgreementManagement.ServiceProviderZeroAddress.selector); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + } + + // ══════════════════════════════════════════════════════════════════════ + // offerAgreement — unauthorized data service (L379) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice offerAgreement reverts when the returned dataService lacks DATA_SERVICE_ROLE. + function test_OfferAgreement_Revert_UnauthorizedDataService() public { + address rogueDS = makeAddr("rogueDataService"); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca.dataService = rogueDS; // not granted DATA_SERVICE_ROLE + + token.mint(address(agreementManager), 1_000_000 ether); + + vm.prank(operator); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, rogueDS) + ); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + } + + // ══════════════════════════════════════════════════════════════════════ + // forceRemoveAgreement (L412–424) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice forceRemoveAgreement is a no-op when the agreement is unknown (provider == address(0)). + function test_ForceRemoveAgreement_NoOp_UnknownAgreement() public { + bytes16 unknownId = bytes16(keccak256("nonexistent")); + + // Should not revert — early return + vm.prank(operator); + agreementManager.forceRemoveAgreement(IAgreementCollector(address(recurringCollector)), unknownId); + + // No state changes + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + } + + /// @notice forceRemoveAgreement removes a tracked agreement. + function test_ForceRemoveAgreement_RemovesTracked() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + // Verify tracked + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + assertTrue(agreementManager.getSumMaxNextClaim(_collector(), indexer) > 0); + + // Force remove + vm.prank(operator); + agreementManager.forceRemoveAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + // Cleaned up + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(), 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // emergencyRevokeRole (L437–439) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice emergencyRevokeRole reverts when attempting to revoke GOVERNOR_ROLE. + function test_EmergencyRevokeRole_Revert_CannotRevokeGovernor() public { + // Grant PAUSE_ROLE to governor for this test + vm.prank(governor); + agreementManager.grantRole(PAUSE_ROLE, governor); + + vm.prank(governor); + vm.expectRevert(RecurringAgreementManager.CannotRevokeGovernorRole.selector); + agreementManager.emergencyRevokeRole(GOVERNOR_ROLE, governor); + } + + /// @notice emergencyRevokeRole succeeds for non-governor roles. + function test_EmergencyRevokeRole_Success() public { + // Grant PAUSE_ROLE to an account + address pauseGuardian = makeAddr("pauseGuardian"); + vm.prank(governor); + agreementManager.grantRole(PAUSE_ROLE, pauseGuardian); + + // Grant a role to revoke + address target = makeAddr("target"); + vm.prank(operator); + agreementManager.grantRole(AGREEMENT_MANAGER_ROLE, target); + assertTrue(agreementManager.hasRole(AGREEMENT_MANAGER_ROLE, target)); + + // Emergency revoke + vm.prank(pauseGuardian); + agreementManager.emergencyRevokeRole(AGREEMENT_MANAGER_ROLE, target); + assertFalse(agreementManager.hasRole(AGREEMENT_MANAGER_ROLE, target)); + } + + // ══════════════════════════════════════════════════════════════════════ + // _withdrawAndRebalance — deposit deficit branch (L854/857–862) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice When escrow balance drops below min (after collection), reconcile deposits the deficit. + function test_WithdrawAndRebalance_DepositDeficit() public { + // Offer agreement in Full mode — escrow gets fully funded + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; // 3700 ether + + // Verify fully funded + (uint256 balBefore, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(balBefore, expectedMaxClaim); + + // Simulate collection draining most of the escrow: + // Set escrow balance to a small amount (below min), no thawing + uint256 drainedBalance = 100 ether; // well below min = expectedMaxClaim in Full mode + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + drainedBalance, + 0, // no thawing + 0 // no thaw end + ); + + // Manager still has tokens (minted 1M in _offerAgreement, deposited 3700) + // Reconcile should trigger deposit deficit branch + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // After reconcile, escrow should be topped up + (uint256 balAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertTrue(balAfter > drainedBalance, "escrow should be topped up after reconcile"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol index eac2fe95d..e4870924f 100644 --- a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol +++ b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol @@ -7,26 +7,26 @@ import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; /// @notice Gas regression canary for RAM callbacks (beforeCollection / afterCollection). -/// RecurringCollector caps gas forwarded to these callbacks at 1.5M (MAX_PAYER_CALLBACK_GAS). +/// RecurringCollector caps gas forwarded to these callbacks at 1.5M (MAX_CALLBACK_GAS). /// /// These tests use mocks for PaymentsEscrow, IssuanceAllocator, and RecurringCollector, /// so measured gas is lower than production. They catch RAM code regressions (new loops, /// extra external calls, etc.) but cannot validate the production gas margin. /// -/// @dev Future work: add integration gas tests in a dedicated cross-package test harness -/// that uses the real PaymentsEscrow, RecurringCollector, and IssuanceAllocator contracts -/// to measure production-representative callback gas. +/// Production-representative gas measurements live in the testing package: +/// packages/testing/test/gas/CallbackGas.t.sol (uses real PaymentsEscrow, RecurringCollector, +/// and IssuanceAllocator via RealStackHarness). contract RecurringAgreementManagerCallbackGasTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ /// @notice Gas budget that RecurringCollector forwards to each callback. - /// Must match MAX_PAYER_CALLBACK_GAS in RecurringCollector. - uint256 internal constant MAX_PAYER_CALLBACK_GAS = 1_500_000; + /// Must match MAX_CALLBACK_GAS in RecurringCollector. + uint256 internal constant MAX_CALLBACK_GAS = 1_500_000; /// @notice Alarm threshold — 1/10th of the callback gas budget. /// Current mock worst-case is ~70k. Crossing 150k means RAM code got significantly /// heavier and the production gas margin (against real contracts) must be re-evaluated. - uint256 internal constant GAS_ALARM_THRESHOLD = MAX_PAYER_CALLBACK_GAS / 10; // 150_000 + uint256 internal constant GAS_ALARM_THRESHOLD = MAX_CALLBACK_GAS / 10; // 150_000 MockIssuanceAllocator internal mockAllocator; diff --git a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol index 4c62cc1e9..eeffa61e1 100644 --- a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol @@ -2,6 +2,10 @@ pragma solidity ^0.8.27; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -41,8 +45,8 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); agreementId = collector.generateAgreementId( @@ -68,8 +72,8 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); agreementId = recurringCollector.generateAgreementId( @@ -87,7 +91,8 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage ) internal returns (bytes16) { token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + return + agreementManager.offerAgreement(IRecurringCollector(address(collector)), OFFER_TYPE_NEW, abi.encode(rca)); } // -- Tests: Enumeration after offer -- @@ -97,10 +102,10 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _offerAgreement(rca); assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectors()[0], address(recurringCollector)); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getCollectorProviders(address(recurringCollector))[0], indexer); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + assertEq(address(agreementManager.getCollectorAt(0)), address(recurringCollector)); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 0), indexer); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Cascade_TwoAgreements_SamePair_CountIncrements() public { @@ -112,8 +117,8 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage // Sets still have one entry each, but pair count is 2 assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 2); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 2); } function test_Cascade_MultiCollector_BothTracked() public { @@ -124,8 +129,8 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _offerForCollector(collector2, rca2); assertEq(agreementManager.getCollectorCount(), 2); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getCollectorProviderCount(address(collector2)), 1); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(collector2))), 1); } function test_Cascade_MultiProvider_BothTracked() public { @@ -138,7 +143,7 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _offerAgreement(rca2); assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 2); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 2); } // -- Tests: Cascade on reconciliation -- @@ -152,12 +157,12 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage // Reconcile first (SP canceled → deleted) _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Pair still tracked assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Cascade_ReconcileLast_PairStaysWhileEscrowThawing() public { @@ -165,29 +170,29 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - agreementManager.reconcileAgreement(id); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id); // Agreement removed, but pair stays tracked while escrow is thawing - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); assertEq(agreementManager.getCollectorCount(), 1, "collector stays tracked during thaw"); assertEq( - agreementManager.getCollectorProviderCount(address(recurringCollector)), + agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1, "provider stays tracked during thaw" ); - // After thaw period, reconcileCollectorProvider reconciles escrow and removes + // After thaw period, reconcileProvider reconciles escrow and removes vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.CollectorProviderRemoved(address(recurringCollector), indexer); + emit IRecurringAgreementManagement.ProviderRemoved(address(recurringCollector), indexer); vm.expectEmit(address(agreementManager)); emit IRecurringAgreementManagement.CollectorRemoved(address(recurringCollector)); - assertFalse(agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer)); + assertFalse(agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer)); assertEq(agreementManager.getCollectorCount(), 0); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); } function test_Cascade_ReconcileLastProvider_CollectorCleanedUp_OtherCollectorRemains() public { @@ -200,24 +205,24 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage // Reconcile collector1's agreement — pair stays tracked during thaw _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); assertEq(agreementManager.getCollectorCount(), 2, "both collectors tracked during thaw"); assertEq( - agreementManager.getCollectorProviderCount(address(recurringCollector)), + agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1, "provider stays during thaw" ); - // After thaw period, reconcileCollectorProvider reconciles escrow and removes + // After thaw period, reconcileProvider reconciles escrow and removes vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); // collector1 cleaned up, collector2 remains assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectors()[0], address(collector2)); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); - assertEq(agreementManager.getCollectorProviderCount(address(collector2)), 1); + assertEq(address(agreementManager.getCollectorAt(0)), address(collector2)); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(collector2))), 1); } function test_Cascade_ReconcileProvider_CollectorRetainsOtherProvider() public { @@ -231,24 +236,24 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage // Reconcile indexer's agreement — pair stays tracked during thaw _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); assertEq(agreementManager.getCollectorCount(), 1); assertEq( - agreementManager.getCollectorProviderCount(address(recurringCollector)), + agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 2, "both providers tracked during thaw" ); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer2), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 1); - // After thaw period, reconcileCollectorProvider reconciles escrow and removes + // After thaw period, reconcileProvider reconciles escrow and removes vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); // Now only indexer2 remains - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getCollectorProviders(address(recurringCollector))[0], indexer2); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 0), indexer2); } // -- Tests: Re-addition after cleanup -- @@ -259,12 +264,12 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage // Reconcile agreement — pair stays tracked during escrow thaw _setAgreementCanceledBySP(id, rca); - agreementManager.reconcileAgreement(id); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id); assertEq(agreementManager.getCollectorCount(), 1, "stays tracked during thaw"); - // After thaw period, full cleanup via reconcileCollectorProvider + // After thaw period, full cleanup via reconcileProvider vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(agreementManager.getCollectorCount(), 0); // Re-add — sets repopulate @@ -272,31 +277,30 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _offerAgreement(rca2); assertEq(agreementManager.getCollectorCount(), 1); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 1); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } - // -- Tests: Revoke also cascades -- + // -- Tests: Cancel also cascades -- - function test_Cascade_RevokeOffer_DeferredCleanup() public { + function test_Cascade_CancelOffered_DeferredCleanup() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAForCollector(recurringCollector, 1); bytes16 id = _offerAgreement(rca); assertEq(agreementManager.getCollectorCount(), 1); - vm.prank(operator); - agreementManager.revokeOffer(id); + _cancelAgreement(id); // Agreement gone, but pair stays tracked during escrow thaw - assertEq(agreementManager.getPairAgreementCount(address(recurringCollector), indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); assertEq(agreementManager.getCollectorCount(), 1, "stays tracked during thaw"); - // After thaw period, reconcileCollectorProvider reconciles escrow and removes + // After thaw period, reconcileProvider reconciles escrow and removes vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(agreementManager.getCollectorCount(), 0); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); } // -- Tests: Permissionless safety valve functions -- @@ -306,14 +310,14 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _offerAgreement(rca); // Exists: pair has agreements - bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + bool exists = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertTrue(exists); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 1); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 1); } function test_ReconcileCollectorProvider_ReturnsFalse_WhenNotTracked() public { // Not exists: pair was never added - bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + bool exists = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertFalse(exists); } @@ -322,10 +326,10 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - agreementManager.reconcileAgreement(id); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id); // Exists: escrow still has pending thaw - bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + bool exists = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertTrue(exists); } @@ -334,18 +338,18 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - agreementManager.reconcileAgreement(id); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id); - // After thaw period, reconcileCollectorProvider reconciles escrow internally + // After thaw period, reconcileProvider reconciles escrow internally vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + bool exists = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertFalse(exists); } function test_ReconcileCollectorProvider_Permissionless() public { address anyone = makeAddr("anyone"); vm.prank(anyone); - bool exists = agreementManager.reconcileCollectorProvider(address(recurringCollector), indexer); + bool exists = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertFalse(exists); } @@ -357,15 +361,21 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _setAgreementCanceledBySP(id, rca); // First call: reconciles agreement (deletes it), starts thaw, but pair stays - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists, "pair stays during thaw"); + assertTrue(providerExists, "pair stays during thaw"); // Second call after thaw period: completes withdrawal and removes pair vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - (removed, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (removed, providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 0, "no agreements left to reconcile"); - assertFalse(pairExists, "pair gone after escrow recovered"); + assertFalse(providerExists, "pair gone after escrow recovered"); } function test_Helper_ReconcileCollector_TwoPhase() public { @@ -374,45 +384,41 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage _setAgreementCanceledBySP(id, rca); // First call: reconciles agreement (deletes it), starts thaw - (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector( + IAgreementCollector(address(recurringCollector)) + ); assertEq(removed, 1); assertTrue(collectorExists, "collector stays during thaw"); // Second call after thaw: completes vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); - (removed, collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + (removed, collectorExists) = agreementHelper.reconcileCollector( + IAgreementCollector(address(recurringCollector)) + ); assertEq(removed, 0); assertFalse(collectorExists, "collector gone after escrow recovered"); } // -- Tests: Pagination -- - function test_GetCollectors_Pagination() public { + function test_GetCollectors_Enumeration() public { (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForCollector(recurringCollector, 1); _offerAgreement(rca1); (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(collector2, 2); _offerForCollector(collector2, rca2); - // Full list - address[] memory all = agreementManager.getCollectors(); - assertEq(all.length, 2); - - // Paginated - address[] memory first = agreementManager.getCollectors(0, 1); - assertEq(first.length, 1); - assertEq(first[0], all[0]); - - address[] memory second = agreementManager.getCollectors(1, 1); - assertEq(second.length, 1); - assertEq(second[0], all[1]); + // Full enumeration + assertEq(agreementManager.getCollectorCount(), 2); + IAgreementCollector collector0 = agreementManager.getCollectorAt(0); + IAgreementCollector collector1 = agreementManager.getCollectorAt(1); - // Past end - address[] memory empty = agreementManager.getCollectors(2, 1); - assertEq(empty.length, 0); + // Individual access by index + assertEq(address(agreementManager.getCollectorAt(0)), address(collector0)); + assertEq(address(agreementManager.getCollectorAt(1)), address(collector1)); } - function test_GetCollectorProviders_Pagination() public { + function test_GetCollectorProviders_Enumeration() public { address indexer2 = makeAddr("indexer2"); (IRecurringCollector.RecurringCollectionAgreement memory rca1, ) = _makeRCAForProvider(indexer, 1); @@ -421,14 +427,14 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForProvider(indexer2, 2); _offerAgreement(rca2); - // Full list - address[] memory all = agreementManager.getCollectorProviders(address(recurringCollector)); - assertEq(all.length, 2); + // Full enumeration + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 2); + address provider0 = agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 0); + address provider1 = agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 1); - // Paginated - address[] memory first = agreementManager.getCollectorProviders(address(recurringCollector), 0, 1); - assertEq(first.length, 1); - assertEq(first[0], all[0]); + // Individual access by index + assertEq(agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 0), provider0); + assertEq(agreementManager.getProviderAt(IAgreementCollector(address(recurringCollector)), 1), provider1); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/discovery.t.sol b/packages/issuance/test/unit/agreement-manager/discovery.t.sol new file mode 100644 index 000000000..50af4e6bb --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/discovery.t.sol @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { + IAgreementCollector, + REGISTERED, + ACCEPTED +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; + +/// @notice Tests for agreement discovery via reconcileAgreement when the RAM +/// has never been notified about the agreement (no prior offer/callback). +/// This covers scenarios like: +/// - RAM deployed after agreements already existed on the collector +/// - Collector state changed out-of-band (e.g. SP cancel via collector directly) +/// - Callback was missed or failed silently +contract RecurringAgreementManagerDiscoveryTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ==================== Discovery via reconcileAgreement ==================== + + function test_Discovery_AcceptedAgreement_ViaReconcile() public { + // Set up an agreement directly on the mock collector — RAM never saw offer() + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + // Fund the RAM so escrow management works + token.mint(address(agreementManager), 1_000_000 ether); + + // RAM has no knowledge of this agreement + assertEq( + agreementManager.getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId).provider, + address(0) + ); + + // reconcileAgreement should discover, register, and reconcile + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementAdded( + agreementId, + address(recurringCollector), + dataService, + indexer + ); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + + assertTrue(exists); + assertEq( + agreementManager.getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId).provider, + indexer + ); + + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + assertEq( + agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim, + expectedMaxClaim + ); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); + } + + function test_Discovery_CanceledBySP_ViaReconcile() public { + // Agreement was accepted and then SP-canceled before RAM ever learned about it + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _setAgreementCanceledBySP(agreementId, rca); + + token.mint(address(agreementManager), 1_000_000 ether); + + // SP cancel → SETTLED → maxNextClaim = 0 → should discover then immediately remove + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementAdded( + agreementId, + address(recurringCollector), + dataService, + indexer + ); + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + + assertFalse(exists); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_Discovery_Idempotent_SecondReconcileNoReRegister() public { + // Set up and discover an agreement + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + token.mint(address(agreementManager), 1_000_000 ether); + + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + // Second reconcile should NOT emit AgreementAdded again + vm.recordLogs(); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + // Check no AgreementAdded was emitted + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 addedSig = IRecurringAgreementManagement.AgreementAdded.selector; + for (uint256 i = 0; i < logs.length; i++) { + assertTrue(logs[i].topics[0] != addedSig, "AgreementAdded should not be emitted on re-reconcile"); + } + } + + // ==================== Rejection scenarios ==================== + + function test_Discovery_RejectsUnknownAgreement() public { + // Reconcile a completely unknown agreement ID + bytes16 fakeId = bytes16(keccak256("nonexistent")); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + fakeId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.UnknownAgreement + ); + + bool exists = agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), fakeId); + assertFalse(exists); + } + + function test_Discovery_RejectsUnauthorizedCollector() public { + // COLLECTOR_ROLE is required for discovery (first encounter). + // Once tracked, reconciliation proceeds regardless of role. + MockRecurringCollector rogue = new MockRecurringCollector(); + vm.label(address(rogue), "RogueCollector"); + + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + // Store agreement on the rogue collector + rogue.setAgreement( + agreementId, + _buildAgreementStorage(rca, REGISTERED | ACCEPTED, uint64(block.timestamp), 0, 0) + ); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + agreementId, + address(rogue), + IRecurringAgreementManagement.AgreementRejectionReason.UnauthorizedCollector + ); + + bool exists = agreementManager.reconcileAgreement(IAgreementCollector(address(rogue)), agreementId); + assertFalse(exists); + } + + function test_Discovery_RejectsPayerMismatch() public { + // Agreement where payer is NOT the RAM + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + // Override payer to some other address + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.payer = address(0xdead); + recurringCollector.setAgreement(agreementId, data); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + agreementId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.PayerMismatch + ); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertFalse(exists); + } + + function test_Discovery_RejectsUnauthorizedDataService() public { + // Agreement with a dataService that does NOT have DATA_SERVICE_ROLE + address rogueDataService = makeAddr("rogueDataService"); + + bytes16 agreementId = bytes16(keccak256("rogue-ds-agreement")); + + IRecurringCollector.RecurringCollectionAgreement memory rogueRca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rogueRca.dataService = rogueDataService; + recurringCollector.setAgreement( + agreementId, + _buildAgreementStorage(rogueRca, REGISTERED | ACCEPTED, uint64(block.timestamp), 0, 0) + ); + + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + agreementId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.UnauthorizedDataService + ); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertFalse(exists); + } + + // ==================== Out-of-band state changes ==================== + + function test_OutOfBand_AcceptedThenSPCancel_ReconcileRemoves() public { + // Offer via normal path (RAM tracks it) + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + + uint256 trackedMaxClaim = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + assertTrue(trackedMaxClaim > 0, "Should be tracked after offer"); + + // SP cancels directly on collector (out-of-band, no callback to RAM) + _setAgreementCanceledBySP(agreementId, rca); + + // RAM still thinks it has the old maxNextClaim + assertEq( + agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim, + trackedMaxClaim, + "RAM should still have stale maxNextClaim" + ); + + // Permissionless reconcile syncs the state + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertFalse(exists); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); + } + + function test_OutOfBand_CollectionReducesMaxClaim_ReconcileUpdates() public { + // Offer and accept via normal path + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + bytes16 agreementId = _offerAgreement(rca); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + + uint256 preReconcileMax = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + + // Simulate a collection happened out-of-band (lastCollectionAt advanced) + uint64 collectionTime = uint64(block.timestamp + 1800); + _setAgreementCollected(agreementId, rca, uint64(block.timestamp), collectionTime); + + // Warp to collection time so the mock's maxNextClaim reflects the collection + vm.warp(collectionTime); + + // Reconcile should update maxNextClaim (no more initialTokens, reduced window) + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertTrue(exists); + + uint256 postReconcileMax = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + assertTrue(postReconcileMax < preReconcileMax, "maxNextClaim should decrease after collection"); + // After collection: no initialTokens, maxSeconds still 3600 → 1e18 * 3600 = 3600e18 + assertEq(postReconcileMax, 1 ether * 3600, "Should be ongoing-only after first collection"); + } + + // ==================== Permissionless reconcile ==================== + + function test_Discovery_Permissionless() public { + // Anyone can call reconcileAgreement — no role required + (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + token.mint(address(agreementManager), 1_000_000 ether); + + address randomUser = makeAddr("randomUser"); + vm.prank(randomUser); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertTrue(exists); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol index 805ced38e..f8bb00e8f 100644 --- a/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol +++ b/packages/issuance/test/unit/agreement-manager/edgeCases.t.sol @@ -1,22 +1,47 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { Vm } from "forge-std/Vm.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + REGISTERED, + ACCEPTED, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; /// @notice Edge case and boundary condition tests for RecurringAgreementManager. contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ + // -- Helpers -- + + function _getProviderAgreements(address provider) internal view returns (bytes16[] memory result) { + uint256 count = agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), provider); + result = new bytes16[](count); + for (uint256 i = 0; i < count; ++i) + result[i] = agreementManager.getAgreementAt(IAgreementCollector(address(recurringCollector)), provider, i); + } + // ==================== supportsInterface Fallback ==================== function test_SupportsInterface_UnknownInterfaceReturnsFalse() public view { @@ -30,59 +55,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar assertTrue(agreementManager.supportsInterface(type(IERC165).interfaceId)); } - // ==================== Cancel with Invalid Data Service ==================== - - function test_CancelAgreement_Revert_WhenDataServiceHasNoCode() public { - // Use an EOA as dataService so ds.code.length == 0 (line 255) - address eoa = makeAddr("eoa-data-service"); - - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - rca.dataService = eoa; - - // Grant DATA_SERVICE_ROLE so the offer goes through - vm.prank(governor); - agreementManager.grantRole(DATA_SERVICE_ROLE, eoa); - - token.mint(address(agreementManager), 1_000_000 ether); - vm.prank(operator); - bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); - - // Set as Accepted so it takes the cancel-via-dataService path - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: eoa, - payer: address(agreementManager), - serviceProvider: indexer, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - - vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.InvalidDataService.selector, eoa)); - vm.prank(operator); - agreementManager.cancelAgreement(agreementId); - } + // NOTE: test_CancelAgreement_Revert_WhenDataServiceHasNoCode removed — + // cancelAgreement now calls collector.cancel() directly, no data service interaction. // ==================== Hash Cleanup Tests ==================== - function test_RevokeOffer_CleansUpAgreementHash() public { + function test_CancelOffered_CleansUpAgreement() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -92,15 +70,18 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); bytes16 agreementId = _offerAgreement(rca); - bytes32 rcaHash = recurringCollector.hashRCA(rca); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + // Agreement is tracked + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + + _cancelAgreement(agreementId); - // Offer is revoked — revokeOffer succeeded without revert + // Agreement is cleaned up + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_RevokeOffer_CleansUpPendingUpdateHash() public { + function test_CancelOffered_CleansUpPendingUpdate() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -122,13 +103,14 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + _cancelAgreement(agreementId); - // Offer revoked successfully + // Agreement and pending update fully cleaned up + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_Remove_CleansUpAgreementHash() public { + function test_Remove_CleansUpAgreement() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -138,16 +120,17 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); bytes16 agreementId = _offerAgreement(rca); - bytes32 rcaHash = recurringCollector.hashRCA(rca); // SP cancels — removable _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - // Hash is cleaned up + // Agreement is fully cleaned up + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_Remove_CleansUpPendingUpdateHash() public { + function test_Remove_CleansUpPendingUpdate() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -169,16 +152,16 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - bytes32 updateHash = recurringCollector.hashRCAU(rcau); - // SP cancels — removable _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - // Pending update hash also cleaned up + // Agreement and pending update fully cleaned up + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_Reconcile_CleansUpAppliedPendingUpdateHash() public { + function test_Reconcile_ClearsAppliedPendingUpdate() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -200,36 +183,41 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - bytes32 updateHash = recurringCollector.hashRCAU(rcau); + // Pending update is tracked on the collector - // Simulate: agreement accepted with pending <= updateNonce (update was applied) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 200 ether, - maxOngoingTokensPerSecond: 2 ether, - minSecondsPerCollection: 60, - maxSecondsPerCollection: 7200, - updateNonce: 1, // (pending <=) - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - - agreementManager.reconcileAgreement(agreementId); - - // Pending update hash should be cleaned up after reconcile clears the applied update + // Simulate: agreement accepted with update applied (pending terms cleared on collector) + IRecurringCollector.RecurringCollectionAgreement memory updatedRca = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days) + ); + updatedRca.payer = rca.payer; + updatedRca.dataService = rca.dataService; + updatedRca.serviceProvider = rca.serviceProvider; + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + updatedRca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.updateNonce = 1; + recurringCollector.setAgreement(agreementId, data); + + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + // After reconcile, maxNextClaim is recalculated from the new active terms + IRecurringAgreements.AgreementInfo memory infoAfter = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + // maxNextClaim = 2e18 * 7200 + 200e18 = 14600e18 + assertEq(infoAfter.maxNextClaim, 14600 ether); } - function test_OfferUpdate_CleansUpReplacedPendingHash() public { + function test_OfferUpdate_ReplacesExistingPendingOnCollector() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -252,9 +240,17 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau1); - bytes32 hash1 = recurringCollector.hashRCAU(rcau1); + // max(current=3700, pending=14600) = 14600 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14600 ether); + + // Cancel pending update clears pending terms on the collector — sum drops to active-only + _cancelPendingUpdate(agreementId); - // Second pending update replaces first (same nonce — collector hasn't accepted either) + // Sum drops to active-only (3700) since pending was cleared + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + + // Collector's updateNonce is still 1, so next valid nonce is 2. IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 50 ether, @@ -262,48 +258,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar 60, 1800, uint64(block.timestamp + 180 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - // First update hash should be cleaned up - - // Second update hash should be authorized - bytes32 hash2 = recurringCollector.hashRCAU(rcau2); - } - - function test_GetAgreementInfo_IncludesHashes() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - bytes32 rcaHash = recurringCollector.hashRCA(rca); - - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.agreementHash, rcaHash); - assertEq(info.pendingUpdateHash, bytes32(0)); - - // Offer an update - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( - agreementId, - 200 ether, - 2 ether, - 60, - 7200, - uint64(block.timestamp + 730 days), - 1 - ); - _offerAgreementUpdate(rcau); - - bytes32 updateHash = recurringCollector.hashRCAU(rcau); - info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.agreementHash, rcaHash); - assertEq(info.pendingUpdateHash, updateHash); + // max(current=3700, pending=950) = 3700 (current dominates) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3700 ether); } // ==================== Zero-Value Parameter Tests ==================== @@ -321,7 +281,10 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // maxNextClaim = 1e18 * 3600 + 0 = 3600e18 uint256 expectedMaxClaim = 1 ether * 3600; - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + expectedMaxClaim + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); } @@ -337,7 +300,10 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); // maxNextClaim = 0 * 3600 + 100e18 = 100e18 - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 100 ether); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 100 ether + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 100 ether); } @@ -352,10 +318,13 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); - // maxNextClaim = 0 * 0 + 0 = 0 - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + // maxNextClaim = 0 * 0 + 0 = 0 — immediately cleaned up + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } // ==================== Deadline Boundary Tests ==================== @@ -378,9 +347,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // At deadline (block.timestamp == deadline), the condition is `block.timestamp <= info.deadline` // so this should still be claimable - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Remove_OneSecondAfterDeadline_NotAccepted() public { @@ -398,9 +370,13 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Warp to one second past deadline vm.warp(deadline + 1); - // Now removable (deadline < block.timestamp) - agreementManager.reconcileAgreement(agreementId); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + // Now removable (deadline < block.timestamp → getMaxNextClaim returns 0) + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertFalse(exists); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } // ==================== Reconcile Edge Cases ==================== @@ -418,57 +394,22 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar uint64 now_ = uint64(block.timestamp); // Set as accepted with lastCollectionAt == endsAt (fully consumed) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: now_, - lastCollectionAt: rca.endsAt, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - - agreementManager.reconcileAgreement(agreementId); + _setAgreementCollected(agreementId, rca, now_, rca.endsAt); + + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); // getMaxNextClaim returns 0 when collectionEnd <= collectionStart - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } // ==================== Cancel Edge Cases ==================== - function test_CancelAgreement_Revert_WhenDataServiceReverts() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - - // Set as accepted - _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - - // Configure the mock SubgraphService to revert - mockSubgraphService.setRevert(true, "SubgraphService: cannot cancel"); - - vm.expectRevert("SubgraphService: cannot cancel"); - vm.prank(operator); - agreementManager.cancelAgreement(agreementId); - } + // NOTE: test_CancelAgreement_Revert_WhenDataServiceReverts removed — + // cancelAgreement now calls collector.cancel() directly, no data service interaction. // ==================== Offer With Zero Balance Tests ==================== @@ -483,12 +424,15 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Don't fund the contract — zero token balance vm.prank(operator); - bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + bytes16 agreementId = agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); uint256 maxClaim = 1 ether * 3600 + 100 ether; // Agreement is tracked even though escrow couldn't be funded - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + maxClaim + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); // Escrow has zero balance @@ -554,7 +498,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ids[2] = id3; // Should succeed without error — _fundEscrow is idempotent - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); // All reconciled to 0 assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); @@ -564,7 +509,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar function test_ReconcileBatch_EmptyArray() public { // Empty batch should succeed with no effect bytes16[] memory ids = new bytes16[](0); - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); } function test_ReconcileBatch_NonExistentAgreements() public { @@ -573,7 +519,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ids[0] = bytes16(keccak256("nonexistent1")); ids[1] = bytes16(keccak256("nonexistent2")); - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); } // ==================== UpdateEscrow Edge Cases ==================== @@ -591,26 +538,26 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Remove the agreement _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - // First reconcileCollectorProvider: initiates thaw - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + // First reconcileProvider: initiates thaw + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Warp past mock's thawing period (1 day) vm.warp(block.timestamp + 1 days + 1); - // Second reconcileCollectorProvider: withdraws thawed tokens, then no more to thaw - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + // Second reconcileProvider: withdraws thawed tokens, then no more to thaw + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - // Third reconcileCollectorProvider: should be a no-op (nothing to thaw or withdraw) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + // Third reconcileProvider: should be a no-op (nothing to thaw or withdraw) + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); } // ==================== Multiple Pending Update Replacements ==================== // ==================== Zero-Value Pending Update Hash Cleanup ==================== - function test_OfferUpdate_ZeroValuePendingUpdate_HashCleanedOnReplace() public { + function test_OfferUpdate_ZeroValuePendingUpdate_ReplacedByNonZero() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -634,12 +581,13 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau1); - bytes32 zeroHash = recurringCollector.hashRCAU(rcau1); - // Zero-value hash should still be authorized // sumMaxNextClaim should be unchanged (original + 0) assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); - // Replace with a non-zero update (same nonce — collector hasn't accepted either) + // Cancel pending update and replace with a non-zero update + _cancelPendingUpdate(agreementId); + + // Collector's updateNonce is now 1, so next nonce must be 2 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 200 ether, @@ -647,17 +595,13 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar 60, 7200, uint64(block.timestamp + 730 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - // Old zero-value hash should be cleaned up - - // New hash should be authorized - bytes32 newHash = recurringCollector.hashRCAU(rcau2); - - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); } function test_Reconcile_ZeroValuePendingUpdate_ClearedWhenApplied() public { @@ -683,39 +627,35 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - bytes32 zeroHash = recurringCollector.hashRCAU(rcau); + // Simulate: agreement accepted with update applied (pending terms cleared on collector) + IRecurringCollector.RecurringCollectionAgreement memory updatedRca = _makeRCA( + 0, + 0, + 60, + 3600, + uint64(block.timestamp + 730 days) + ); + updatedRca.payer = rca.payer; + updatedRca.dataService = rca.dataService; + updatedRca.serviceProvider = rca.serviceProvider; + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + updatedRca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.updateNonce = 1; + recurringCollector.setAgreement(agreementId, data); + + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - // Simulate: agreement accepted with update applied (pending nonce <= updateNonce) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 0, - maxOngoingTokensPerSecond: 0, - minSecondsPerCollection: 60, - maxSecondsPerCollection: 3600, - updateNonce: 1, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - - agreementManager.reconcileAgreement(agreementId); - - // Zero-value pending hash should be cleaned up - - // Pending fields should be cleared - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.pendingUpdateMaxNextClaim, 0); - assertEq(info.pendingUpdateNonce, 0); - assertEq(info.pendingUpdateHash, bytes32(0)); + // maxNextClaim should reflect the new (zero-value) active terms + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertEq(info.maxNextClaim, 0); } // ==================== Re-offer After Remove ==================== @@ -733,28 +673,28 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); uint256 maxClaim = 1 ether * 3600 + 100 ether; assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); // 2. SP cancels and remove _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); // 3. Re-offer the same agreement (same parameters, same agreementId) bytes16 reofferedId = _offerAgreement(rca); assertEq(reofferedId, agreementId); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); // 4. Verify the re-offered agreement is fully functional - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(reofferedId); + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + reofferedId + ); assertTrue(info.provider != address(0)); assertEq(info.provider, indexer); assertEq(info.maxNextClaim, maxClaim); - - // Hash is authorized again - bytes32 rcaHash = recurringCollector.hashRCA(rca); } function test_ReofferAfterRemove_WithDifferentNonce() public { @@ -771,7 +711,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Remove _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Re-offer with different nonce (different agreementId) IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( @@ -788,7 +728,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar uint256 maxClaim2 = 2 ether * 7200 + 200 ether; assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } // ==================== Input Validation ==================== @@ -806,7 +746,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar token.mint(address(agreementManager), 1_000_000 ether); vm.expectRevert(IRecurringAgreementManagement.ServiceProviderZeroAddress.selector); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } function test_Offer_Revert_ZeroDataService() public { @@ -824,13 +764,13 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0)) ); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } // ==================== getProviderAgreements ==================== function test_GetIndexerAgreements_Empty() public { - bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + bytes16[] memory ids = _getProviderAgreements(indexer); assertEq(ids.length, 0); } @@ -845,7 +785,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); - bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + bytes16[] memory ids = _getProviderAgreements(indexer); assertEq(ids.length, 1); assertEq(ids[0], agreementId); } @@ -872,7 +812,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 id1 = _offerAgreement(rca1); bytes16 id2 = _offerAgreement(rca2); - bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + bytes16[] memory ids = _getProviderAgreements(indexer); assertEq(ids.length, 2); // EnumerableSet maintains insertion order assertEq(ids[0], id1); @@ -903,9 +843,9 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Remove first agreement _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); - bytes16[] memory ids = agreementManager.getProviderAgreements(indexer); + bytes16[] memory ids = _getProviderAgreements(indexer); assertEq(ids.length, 1); assertEq(ids[0], id2); } @@ -935,8 +875,8 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 id1 = _offerAgreement(rca1); bytes16 id2 = _offerAgreement(rca2); - bytes16[] memory indexer1Ids = agreementManager.getProviderAgreements(indexer); - bytes16[] memory indexer2Ids = agreementManager.getProviderAgreements(indexer2); + bytes16[] memory indexer1Ids = _getProviderAgreements(indexer); + bytes16[] memory indexer2Ids = _getProviderAgreements(indexer2); assertEq(indexer1Ids.length, 1); assertEq(indexer1Ids[0], id1); @@ -944,7 +884,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar assertEq(indexer2Ids[0], id2); } - function test_GetIndexerAgreements_Paginated() public { + function test_GetIndexerAgreements_Enumeration() public { IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( 100 ether, 1 ether, @@ -966,21 +906,12 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 id1 = _offerAgreement(rca1); bytes16 id2 = _offerAgreement(rca2); - // Full range returns both - bytes16[] memory all = agreementManager.getProviderAgreements(indexer, 0, 10); - assertEq(all.length, 2); - assertEq(all[0], id1); - assertEq(all[1], id2); - - // Offset skips first - bytes16[] memory fromOne = agreementManager.getProviderAgreements(indexer, 1, 10); - assertEq(fromOne.length, 1); - assertEq(fromOne[0], id2); - - // Count limits result - bytes16[] memory firstOnly = agreementManager.getProviderAgreements(indexer, 0, 1); - assertEq(firstOnly.length, 1); - assertEq(firstOnly[0], id1); + // Count returns total + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 2); + + // Individual access by index + assertEq(agreementManager.getAgreementAt(IAgreementCollector(address(recurringCollector)), indexer, 0), id1); + assertEq(agreementManager.getAgreementAt(IAgreementCollector(address(recurringCollector)), indexer, 1), id2); } // ==================== Withdraw Timing Boundary (Issue 1) ==================== @@ -1001,7 +932,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // SP cancels — reconcile triggers thaw _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); IPaymentsEscrow.EscrowAccount memory accountBeforeWarp; ( @@ -1018,7 +949,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Record logs to verify no EscrowWithdrawn event vm.recordLogs(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); Vm.Log[] memory entries = vm.getRecordedLogs(); bytes32 withdrawSig = keccak256("EscrowWithdrawn(address,address,uint256)"); @@ -1050,7 +981,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar uint256 maxClaim = 1 ether * 3600 + 100 ether; _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); (, , uint256 thawEnd) = paymentsEscrow.escrowAccounts( address(agreementManager), @@ -1064,7 +995,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar vm.expectEmit(address(agreementManager)); emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Escrow should be empty (uint256 finalBalance, , ) = paymentsEscrow.escrowAccounts( @@ -1100,7 +1031,6 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } assertEq(token.balanceOf(address(agreementManager)), 0, "Manager has no free tokens"); @@ -1114,7 +1044,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // ==================== Cancel Event Behavior ==================== - function test_CancelAgreement_NoEvent_WhenAlreadyCanceled() public { + function test_CancelAgreement_AlreadyCanceled_StillForwards() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -1128,20 +1058,11 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar // Set as already CanceledByServiceProvider _setAgreementCanceledBySP(agreementId, rca); - // Record logs to verify no AgreementCanceled event - vm.recordLogs(); + // cancelAgreement always forwards to collector — no idempotent skip + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; vm.prank(operator); - agreementManager.cancelAgreement(agreementId); - - // Check that no AgreementCanceled event was emitted - Vm.Log[] memory entries = vm.getRecordedLogs(); - bytes32 cancelEventSig = keccak256("AgreementCanceled(bytes16,address)"); - for (uint256 i = 0; i < entries.length; i++) { - assertTrue( - entries[i].topics[0] != cancelEventSig, - "AgreementCanceled should not be emitted on idempotent path" - ); - } + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); + // Verify it doesn't revert — collector handles already-canceled state } function test_CancelAgreement_EmitsEvent_WhenAccepted() public { @@ -1156,16 +1077,19 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; + + // cancelAgreement triggers the callback which reconciles — expect AgreementRemoved vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementCanceled(agreementId, indexer); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); vm.prank(operator); - agreementManager.cancelAgreement(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } // ==================== Multiple Pending Update Replacements ==================== - function test_OfferUpdate_ThreeConsecutiveReplacements() public { + function test_OfferUpdate_ThreeConsecutiveUpdates() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -1177,7 +1101,7 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - // Update 1 + // Update 1 (nonce=1) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( agreementId, 200 ether, @@ -1188,10 +1112,14 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar 1 ); _offerAgreementUpdate(rcau1); - uint256 pending1 = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending1); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pending1 = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pending1); + + // Cancel pending update clears pending on collector, sum drops to active-only + _cancelPendingUpdate(agreementId); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); - // Update 2 replaces 1 (same nonce — collector hasn't accepted either) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 50 ether, @@ -1199,13 +1127,15 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar 60, 1800, uint64(block.timestamp + 180 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - uint256 pending2 = 0.5 ether * 1800 + 50 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending2); + // max(current, pending) = max(3700, 950) = 3700 (current dominates) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + + // Cancel pending update 2 and offer update 3 (nonce=3) + _cancelPendingUpdate(agreementId); - // Update 3 replaces 2 (same nonce — collector still hasn't accepted) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau3 = _makeRCAU( agreementId, 300 ether, @@ -1213,15 +1143,11 @@ contract RecurringAgreementManagerEdgeCasesTest is RecurringAgreementManagerShar 60, 3600, uint64(block.timestamp + 1095 days), - 1 + 3 ); _offerAgreementUpdate(rcau3); - uint256 pending3 = 3 ether * 3600 + 300 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pending3); - - // Only hash for update 3 should be authorized - bytes32 hash1 = recurringCollector.hashRCAU(rcau1); - bytes32 hash2 = recurringCollector.hashRCAU(rcau2); - bytes32 hash3 = recurringCollector.hashRCAU(rcau3); + // max(current, pending) = max(3700, 11100) = 11100 + uint256 pending3 = 11100 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pending3); } } diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index cd144d58a..d84782d37 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -109,13 +109,12 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan // Burn RAM's free balance so it can't cover a JIT deposit without distribution uint256 freeBalance = token.balanceOf(address(agreementManager)); vm.prank(address(agreementManager)); - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), freeBalance); assertEq(token.balanceOf(address(agreementManager)), 0); // Configure allocator to mint enough to cover the deficit plus 50% of sumMaxNextClaimAll reserve uint256 deficit = 500 ether; - uint256 reserve = agreementManager.getSumMaxNextClaimAll(); // >= 50% threshold + uint256 reserve = agreementManager.getSumMaxNextClaim(); // >= 50% threshold mockAllocator.setMintPerDistribution(deficit + reserve); // Advance block so distribution actually mints @@ -226,9 +225,9 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan agreementManager.beforeCollection(agreementId, escrowBalance + 500 ether); } - // ==================== uint64 wrap ==================== + // ==================== uint32 wrap ==================== - function test_EnsureDistributed_WorksAcrossUint64Boundary() public { + function test_EnsureDistributed_WorksAcrossUint32Boundary() public { // Use afterCollection path which always reaches _updateEscrow → _ensureIncomingDistributionToCurrentBlock, // regardless of escrow balance (unlike beforeCollection which has an early return). (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( @@ -244,31 +243,31 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan uint256 countBefore = mockAllocator.distributeCallCount(); - // Jump to uint64 max - vm.roll(type(uint64).max); + // Jump to uint32 max + vm.roll(type(uint32).max); vm.prank(address(recurringCollector)); agreementManager.afterCollection(agreementId, 0); - assertGt(mockAllocator.distributeCallCount(), countBefore, "should distribute at uint64.max"); + assertGt(mockAllocator.distributeCallCount(), countBefore, "should distribute at uint32.max"); uint256 countAtMax = mockAllocator.distributeCallCount(); - // Cross the boundary: uint64.max + 1 wraps to 0 in uint64. - // ensuredIncomingDistributedToBlock is uint64.max from the previous call, so no false match. - vm.roll(uint256(type(uint64).max) + 1); + // Cross the boundary: uint32.max + 1 wraps to 0 in uint32. + // ensuredIncomingDistributedToBlock is uint32.max from the previous call, so no false match. + vm.roll(uint256(type(uint32).max) + 1); vm.prank(address(recurringCollector)); agreementManager.afterCollection(agreementId, 0); - assertGt(mockAllocator.distributeCallCount(), countAtMax, "should distribute after uint64 wrap to 0"); + assertGt(mockAllocator.distributeCallCount(), countAtMax, "should distribute after uint32 wrap to 0"); uint256 countAfterWrap = mockAllocator.distributeCallCount(); // Next block after wrap (wraps to 1) also works - vm.roll(uint256(type(uint64).max) + 2); + vm.roll(uint256(type(uint32).max) + 2); vm.prank(address(recurringCollector)); agreementManager.afterCollection(agreementId, 0); assertGt(mockAllocator.distributeCallCount(), countAfterWrap, "should distribute on block after wrap"); } - function test_EnsureDistributed_SameBlockDedup_AtUint64Boundary() public { + function test_EnsureDistributed_SameBlockDedup_AtUint32Boundary() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -279,7 +278,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan token.mint(address(agreementManager), 10_000 ether); // Jump past the boundary - vm.roll(uint256(type(uint64).max) + 3); + vm.roll(uint256(type(uint32).max) + 3); (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( address(agreementManager), address(recurringCollector), diff --git a/packages/issuance/test/unit/agreement-manager/escrowEdgeCases.t.sol b/packages/issuance/test/unit/agreement-manager/escrowEdgeCases.t.sol new file mode 100644 index 000000000..76cf085b2 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/escrowEdgeCases.t.sol @@ -0,0 +1,425 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { MockEligibilityOracle } from "./mocks/MockEligibilityOracle.sol"; + +/// @notice Edge case tests for escrow lifecycle, basis degradation, and cross-provider isolation. +/// Covers audit gaps: +/// - REGISTERED-only agreement aging and cleanup (audit gap 6) +/// - Basis degradation when RAM balance is insufficient (audit gap 12) +/// - Cross-provider escrow tracking isolation (audit gap 13) +/// - Eligibility oracle toggle during active agreement (audit gap 16) +contract RecurringAgreementManagerEscrowEdgeCasesTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + address internal indexer2; + + function setUp() public override { + super.setUp(); + indexer2 = makeAddr("indexer2"); + } + + // -- Helpers -- + + function _makeRCAForIndexer( + address sp, + uint256 maxInitial, + uint256 maxOngoing, + uint32 maxSec, + uint256 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + maxInitial, + maxOngoing, + 60, + maxSec, + uint64(block.timestamp + 365 days) + ); + rca.serviceProvider = sp; + rca.nonce = nonce; + return rca; + } + + function _escrowBalance(address collector_, address provider_) internal view returns (uint256) { + (uint256 bal, , ) = paymentsEscrow.escrowAccounts(address(agreementManager), collector_, provider_); + return bal; + } + + function _escrowThawing(address collector_, address provider_) internal view returns (uint256) { + (, uint256 thawing, ) = paymentsEscrow.escrowAccounts(address(agreementManager), collector_, provider_); + return thawing; + } + + // ══════════════════════════════════════════════════════════════════════ + // 6. REGISTERED-only agreement — aging and cleanup + // ══════════════════════════════════════════════════════════════════════ + + /// @notice REGISTERED-only agreement: immediately after offer, it's tracked with non-zero maxNextClaim. + /// Can be canceled and cleaned up without ever being accepted. + function test_RegisteredOnly_TrackedAndCancelable() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + // Tracked with non-zero maxNextClaim + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + assertTrue( + agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim > 0, + "REGISTERED agreement should have non-zero maxNextClaim" + ); + + // Cancel without ever accepting — cleans up immediately + _cancelAgreement(agreementId); + assertEq( + agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), + 0, + "canceled REGISTERED agreement should be removed" + ); + assertEq( + agreementManager.getSumMaxNextClaim(_collector(), indexer), + 0, + "maxNextClaim should be 0 after cleanup" + ); + assertEq(agreementManager.getSumMaxNextClaim(), 0, "global maxNextClaim should be 0"); + } + + /// @notice After aging past endsAt, reconcile removes a REGISTERED agreement because + /// maxNextClaim drops to 0 when the collection window expires. + function test_RegisteredOnly_RemovedOnReconcileAfterExpiry() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 30 days) // shorter endsAt + ); + + bytes16 agreementId = _offerAgreement(rca); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + + // Warp past endsAt — collector reports maxNextClaim = 0 + vm.warp(block.timestamp + 31 days); + + // Reconcile removes the expired agreement automatically + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + assertEq( + agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), + 0, + "expired REGISTERED agreement should be auto-removed on reconcile" + ); + assertEq(agreementManager.getSumMaxNextClaim(), 0, "global sum should be 0"); + } + + /// @notice REGISTERED-only agreement contributes to escrow tracking while alive + function test_RegisteredOnly_ContributesToEscrow() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + + // In Full basis mode, the escrow should have been deposited + assertEq(agreementManager.getSumMaxNextClaim(), expectedMaxClaim, "global sum should include REGISTERED"); + assertEq( + agreementManager.getSumMaxNextClaim(_collector(), indexer), + expectedMaxClaim, + "pair sum should include REGISTERED" + ); + + // Escrow should be funded (Full mode) + uint256 escrowed = _escrowBalance(address(recurringCollector), indexer); + assertEq(escrowed, expectedMaxClaim, "escrow should be fully funded in Full mode"); + + // After cancel, escrow should start thawing + _cancelAgreement(agreementId); + uint256 thawing = _escrowThawing(address(recurringCollector), indexer); + assertEq(thawing, expectedMaxClaim, "escrow should be thawing after cancel"); + } + + // ══════════════════════════════════════════════════════════════════════ + // 12. Basis degradation when balance is insufficient + // ══════════════════════════════════════════════════════════════════════ + + /// @notice When RAM's token balance is too low for Full mode, escrow deposit is + /// partial and deficit tracking reflects the shortfall. + function test_BasisDegradation_InsufficientBalance_PartialDeposit() public { + // Fund RAM with a small amount + uint256 limitedFunding = 100 ether; + token.mint(address(agreementManager), limitedFunding); + + // Offer agreement that requires much more escrow than available + // maxNextClaim = 10 ether * 3600 + 500 ether = 36500 ether >> 100 ether + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 500 ether, + 10 ether, + 3600, + 1 + ); + + // Don't use _offerAgreement since it mints 1M tokens — call directly + vm.prank(operator); + bytes16 agreementId = agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + + uint256 expectedMaxClaim = 10 ether * 3600 + 500 ether; // 36500 ether + assertEq(agreementManager.getSumMaxNextClaim(), expectedMaxClaim, "sum should reflect full maxNextClaim"); + + // RAM only had 100 ether. In Full mode, spare = balance - deficit. + // Since deposit uses available balance, only partial deposit was possible. + // totalEscrowDeficit should be > 0 reflecting the unfunded portion. + uint256 escrowed = _escrowBalance(address(recurringCollector), indexer); + assertTrue(escrowed < expectedMaxClaim, "escrow should be less than maxNextClaim (partial deposit)"); + + // Verify deficit reflects the gap + uint256 deficit = agreementManager.getTotalEscrowDeficit(); + assertEq(deficit, expectedMaxClaim - escrowed, "deficit should be maxNextClaim - escrowBalance"); + } + + /// @notice Sufficient funding allows Full basis mode to fully deposit escrow. + /// Demonstrates recovery from degraded state to fully-funded state. + function test_BasisDegradation_RecoveryWithSufficientFunding() public { + // Use _offerAgreement which mints 1M tokens — sufficient for Full mode + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + + _offerAgreement(rca); + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; // 3700 ether + + // Full mode: escrow fully deposited + uint256 escrowFull = _escrowBalance(address(recurringCollector), indexer); + assertEq(escrowFull, expectedMaxClaim, "Full mode: escrow should be fully funded"); + assertEq(agreementManager.getTotalEscrowDeficit(), 0, "Full mode: no deficit"); + + // Switch to JIT — no proactive deposits + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + // Reconcile to trigger escrow rebalancing + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // In JIT, excess should be thawing + uint256 thawing = _escrowThawing(address(recurringCollector), indexer); + assertTrue(thawing > 0, "JIT mode: excess should be thawing"); + + // Switch back to Full + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + + // Reconcile — should cancel thaw and maintain full deposit + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + uint256 escrowRecovered = _escrowBalance(address(recurringCollector), indexer); + assertEq(escrowRecovered, expectedMaxClaim, "recovered: escrow should be fully funded again"); + } + + // ══════════════════════════════════════════════════════════════════════ + // 13. Cross-provider escrow isolation + // ══════════════════════════════════════════════════════════════════════ + + /// @notice Two providers' escrow tracking is fully isolated — canceling one + /// has no effect on the other's sumMaxNextClaim or escrow balance. + function test_CrossProviderEscrow_IsolatedTracking() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 200 ether, + 2 ether, + 7200, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + bytes16 id2 = _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; // 3700 ether + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; // 14600 ether + + // Verify isolated sums + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1, "indexer1 sum"); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2, "indexer2 sum"); + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim1 + maxClaim2, "global sum"); + + // Verify isolated escrow deposits (Full mode) + assertEq(_escrowBalance(address(recurringCollector), indexer), maxClaim1, "indexer1 escrow"); + assertEq(_escrowBalance(address(recurringCollector), indexer2), maxClaim2, "indexer2 escrow"); + + // Cancel indexer1's agreement + _cancelAgreement(id1); + + // Indexer1 tracking cleared + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0, "indexer1 sum after cancel"); + + // Indexer2 completely unaffected + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2, "indexer2 sum after cancel"); + assertEq( + _escrowBalance(address(recurringCollector), indexer2), + maxClaim2, + "indexer2 escrow untouched after indexer1 cancel" + ); + + // Global sum reflects only indexer2 + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim2, "global sum after indexer1 cancel"); + } + + /// @notice One provider's thaw-in-progress does not affect another's escrow min/max + function test_CrossProviderEscrow_ThawDoesNotAffectOther() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( + indexer, + 100 ether, + 1 ether, + 3600, + 1 + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForIndexer( + indexer2, + 100 ether, + 1 ether, + 3600, + 2 + ); + + bytes16 id1 = _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Cancel indexer1 — triggers thaw + _cancelAgreement(id1); + + // Indexer1 has thawing escrow + uint256 thawing1 = _escrowThawing(address(recurringCollector), indexer); + assertEq(thawing1, maxClaim, "indexer1 escrow should be thawing"); + + // Indexer2 escrow should be completely unaffected (no thawing) + uint256 thawing2 = _escrowThawing(address(recurringCollector), indexer2); + assertEq(thawing2, 0, "indexer2 should have no thawing"); + assertEq( + _escrowBalance(address(recurringCollector), indexer2), + maxClaim, + "indexer2 balance should be fully funded" + ); + + // After thaw period, withdraw for indexer1 does not touch indexer2 + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + assertEq( + _escrowBalance(address(recurringCollector), indexer2), + maxClaim, + "indexer2 balance untouched after indexer1 thaw completion" + ); + } + + // ══════════════════════════════════════════════════════════════════════ + // 16. Eligibility oracle toggle during active agreement + // ══════════════════════════════════════════════════════════════════════ + + /// @notice When the eligibility oracle flips a provider to ineligible while they have + /// an active agreement, isEligible reflects the change immediately. + function test_EligibilityOracle_FlipDuringActiveAgreement() public { + MockEligibilityOracle oracle = new MockEligibilityOracle(); + vm.label(address(oracle), "EligibilityOracle"); + + // Set oracle — initially all eligible + oracle.setDefaultEligible(true); + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(IProviderEligibility(address(oracle))); + + // Offer agreement for indexer + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + + // Indexer is eligible + assertTrue(agreementManager.isEligible(indexer), "should be eligible initially"); + + // Oracle flips indexer to ineligible + oracle.setDefaultEligible(false); + // Default is false and indexer not explicitly set → ineligible + assertFalse(agreementManager.isEligible(indexer), "should be ineligible after oracle flip"); + + // Agreement is still tracked (eligibility doesn't auto-remove) + assertEq( + agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), + 1, + "agreement should persist despite ineligibility" + ); + assertTrue( + agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), bytes16(0)) + .maxNextClaim == + 0 || + agreementManager.getSumMaxNextClaim(_collector(), indexer) > 0, + "escrow tracking should be unaffected by eligibility" + ); + + // Oracle flips back + oracle.setEligible(indexer, true); + assertTrue(agreementManager.isEligible(indexer), "should be eligible again after oracle flip back"); + } + + /// @notice Emergency clear of eligibility oracle makes all providers eligible (fail-open) + function test_EligibilityOracle_EmergencyClear_FailOpen() public { + MockEligibilityOracle oracle = new MockEligibilityOracle(); + + // Set oracle that denies indexer + vm.prank(governor); + agreementManager.setProviderEligibilityOracle(IProviderEligibility(address(oracle))); + assertFalse(agreementManager.isEligible(indexer), "should be ineligible"); + + // Emergency clear (PAUSE_ROLE needed — grant it first) + bytes32 PAUSE_ROLE = keccak256("PAUSE_ROLE"); + vm.prank(governor); + agreementManager.grantRole(PAUSE_ROLE, governor); + + vm.prank(governor); + agreementManager.emergencyClearEligibilityOracle(); + + // All providers now eligible (fail-open) + assertTrue(agreementManager.isEligible(indexer), "should be eligible after emergency clear"); + assertTrue(agreementManager.isEligible(indexer2), "all providers eligible after emergency clear"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol index 585dff852..b2d3b80e7 100644 --- a/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fundingModes.t.sol @@ -5,6 +5,10 @@ import { Vm } from "forge-std/Vm.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -83,13 +87,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS _offerAgreement(rca1); uint256 maxClaim1 = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim1); - assertEq(agreementManager.getTotalAgreementCount(), 1); - + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim1); _offerAgreement(rca2); uint256 maxClaim2 = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim1 + maxClaim2); - assertEq(agreementManager.getTotalAgreementCount(), 2); + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim1 + maxClaim2); } function test_GlobalTracking_TotalUndeposited() public { @@ -126,7 +127,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS assertEq(agreementManager.getTotalEscrowDeficit(), maxClaim, "JIT: totalEscrowDeficit = sumMaxNextClaim"); } - function test_GlobalTracking_RevokeDecrementsCountAndRequired() public { + function test_GlobalTracking_CancelDecrementsCountAndRequired() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAForIndexer( indexer, 100 ether, @@ -137,14 +138,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS bytes16 agreementId = _offerAgreement(rca); uint256 maxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); - assertEq(agreementManager.getTotalAgreementCount(), 1); - - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim); + _cancelAgreement(agreementId); - assertEq(agreementManager.getSumMaxNextClaimAll(), 0); - assertEq(agreementManager.getTotalAgreementCount(), 0); + assertEq(agreementManager.getSumMaxNextClaim(), 0); } function test_GlobalTracking_RemoveDecrementsCountAndRequired() public { @@ -157,13 +154,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); bytes16 agreementId = _offerAgreement(rca); - assertEq(agreementManager.getTotalAgreementCount(), 1); - _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - assertEq(agreementManager.getSumMaxNextClaimAll(), 0); - assertEq(agreementManager.getTotalAgreementCount(), 0); + assertEq(agreementManager.getSumMaxNextClaim(), 0); } function test_GlobalTracking_ReconcileUpdatesRequired() public { @@ -177,15 +171,13 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS bytes16 agreementId = _offerAgreement(rca); uint256 maxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim); // SP cancels — reconcile sets maxNextClaim to 0 _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - assertEq(agreementManager.getSumMaxNextClaimAll(), 0); - // Reconcile now deletes settled agreements inline - assertEq(agreementManager.getTotalAgreementCount(), 0); + assertEq(agreementManager.getSumMaxNextClaim(), 0); } function test_GlobalTracking_TotalUndeposited_MultiProvider() public { @@ -228,7 +220,6 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } @@ -241,7 +232,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 2 ); vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca2)); uint256 maxClaim2 = 2 ether * 7200 + 200 ether; // indexer is fully deposited (undeposited = 0), indexer2 has full deficit (undeposited = maxClaim2) @@ -294,7 +285,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // SP cancels, remove (triggers thaw of all excess) _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -325,7 +316,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); // Update escrow — should thaw everything - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -429,7 +420,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // OnDemand thaw ceiling = required — no thaw expected (balance == thawCeiling) vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -460,7 +451,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // JustInTime would thaw everything vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory jitAccount; (jitAccount.balance, jitAccount.tokensThawing, jitAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -473,7 +464,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch to OnDemand — min=0, min <= liquid=0, so thaw is left alone vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory odAccount; (odAccount.balance, odAccount.tokensThawing, odAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -535,7 +526,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); token.mint(address(agreementManager), 100_000 ether); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } // sumMaxNextClaim should be larger than totalEscrowDeficit (degradation occurred: Full -> OnDemand) @@ -583,13 +574,19 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch through all modes — agreement data preserved vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + maxClaim + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaim); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + maxClaim + ); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_ModeSwitch_UpdateEscrowAppliesNewMode() public { @@ -609,7 +606,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch to JustInTime and update escrow vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -675,7 +672,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS vm.prank(address(recurringCollector)); agreementManager.afterCollection(agreementId, 500 ether); - uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertEq(newMaxClaim, 1 ether * 3600, "maxNextClaim = ongoing only after first collection"); } @@ -692,7 +692,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS bytes16 agreementId = _offerAgreement(rca); uint256 maxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim); + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( agreementId, @@ -705,8 +705,9 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(), pendingMaxClaim); } function test_GlobalTracking_ReplacePendingUpdate() public { @@ -731,10 +732,13 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); _offerAgreementUpdate(rcau1); - uint256 pendingMaxClaim1 = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim1); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim1 = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(), pendingMaxClaim1); + + // Revoke first update, then offer replacement with next valid nonce + _cancelPendingUpdate(agreementId); - // Replace with different terms (same nonce — collector hasn't accepted either) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 50 ether, @@ -742,12 +746,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 60, 1800, uint64(block.timestamp + 180 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - uint256 pendingMaxClaim2 = 0.5 ether * 1800 + 50 ether; - assertEq(agreementManager.getSumMaxNextClaimAll(), maxClaim + pendingMaxClaim2); + // max(current, pending) = max(3700, 950) = 3700 (current dominates) + assertEq(agreementManager.getSumMaxNextClaim(), maxClaim); } // ==================== Upward Transitions ==================== @@ -777,7 +781,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch to Full vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq( paymentsEscrow.getBalance(address(agreementManager), address(recurringCollector), indexer), @@ -801,7 +805,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch to OnDemand — holds at required (no thaw for 1 agreement) vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory odAccount; (odAccount.balance, odAccount.tokensThawing, odAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -814,7 +818,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Switch back to Full — no change needed (already at required) vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory fullAccount; (fullAccount.balance, fullAccount.tokensThawing, fullAccount.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -851,7 +855,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Cancel and remove rca1 — this triggers a thaw for excess _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); IPaymentsEscrow.EscrowAccount memory beforeSwitch; (beforeSwitch.balance, beforeSwitch.tokensThawing, beforeSwitch.thawEndTimestamp) = paymentsEscrow @@ -863,7 +867,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // remaining balance thaws after current thaw completes and is withdrawn vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory midCycle; (midCycle.balance, midCycle.tokensThawing, midCycle.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -876,7 +880,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Complete thaw, withdraw all vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory afterWithdraw; (afterWithdraw.balance, afterWithdraw.tokensThawing, afterWithdraw.thawEndTimestamp) = paymentsEscrow @@ -906,7 +910,6 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } } @@ -947,12 +950,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); // spare > smnca * 1.0625 -- both gates pass -> Full _fundToSpare((smnca * (256 + 16)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq( _effectiveEscrow(address(recurringCollector), indexer), @@ -971,14 +974,14 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); // spare = smnca * 272/256 exactly -- min gate fails (not strictly greater) // but spare > smnca * 128/256, so max gate passes uint256 minGateThreshold = (smnca * (256 + 16)) / 256; _fundToSpare(minGateThreshold); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand behavior: min=0 (no deposits), max=sumMaxNextClaim (holds ceiling) // Escrow was deposited during offerAgreement, so it should still be at pairSmnc @@ -1003,20 +1006,20 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); uint256 minGateThreshold = (smnca * (256 + 16)) / 256; // At min gate boundary: OnDemand (min=0, max=smnc) _fundToSpare(minGateThreshold); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Escrow was pre-deposited, OnDemand holds it (no thaw because balance <= max) assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "At boundary: OnDemand holds"); // One wei above: Full (min=max=smnc) _fundToSpare(minGateThreshold + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "One above boundary: Full deposits"); } @@ -1031,12 +1034,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // spare = smnca * 128/256 exactly -- max gate fails -> JIT-like (both 0) uint256 maxGateThreshold = (smnca * 128) / 256; _fundToSpare(maxGateThreshold); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing, bal, "JIT-like: all escrow thawing"); @@ -1051,22 +1054,22 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 maxGateThreshold = (smnca * 128) / 256; // At max gate boundary: JIT-like _fundToSpare(maxGateThreshold); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (uint256 bal1, uint256 thawing1, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing1, bal1, "At max boundary: JIT thaws all"); // Complete thaw vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // One wei above max gate: OnDemand (max passes, min still fails since 0.5x+1 < 1.0625x) _fundToSpare(maxGateThreshold + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: min=0 so no deposit happens (escrow was withdrawn during thaw) // max=smnc so no thaw starts either. Effective balance stays at 0 (nothing to hold). @@ -1088,7 +1091,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); // Fund to middle of OnDemand band: 0.5x < spare < 1.0625x @@ -1098,7 +1101,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS assertTrue(midSpare <= (smnca * (256 + 16)) / 256, "midSpare below min gate"); _fundToSpare(midSpare); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Escrow was deposited during offerAgreement (when SAM had 1M ether). // OnDemand: max=smnc so holds (no thaw), min=0 so no new deposit. @@ -1118,18 +1121,18 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // Drain to JIT, complete thaw to clear escrow _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "Escrow cleared"); // Fund to OnDemand band _fundToSpare((smnca * 3) / 4); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: min=0 -> no deposit from zero. max=smnc but nothing to hold. assertEq( @@ -1153,12 +1156,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // OnDemand: only max gate matters (min is always 0 because basis != Full) // max gate: smnca * threshold/256 < spare _fundToSpare((smnca * 128) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing, 0, "OnDemand: no thaw when max gate passes"); @@ -1176,11 +1179,11 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // Max gate fails -> max=0 -> thaw everything _fundToSpare((smnca * 128) / 256); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing, bal, "OnDemand degraded: all thawing"); @@ -1199,17 +1202,17 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // Drain to zero, complete thaw _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Fund well above both gates _fundToSpare(smnca * 2); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: min=0 always (basis != Full), so no deposit from zero assertEq( @@ -1234,7 +1237,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS _drainSAM(); assertEq(token.balanceOf(address(agreementManager)), 0, "SAM drained"); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing, bal, "JIT: thaws all when spare=0"); @@ -1251,18 +1254,18 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // Drain to JIT, complete thaw _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "JIT: zero escrow"); // Fund to OnDemand band (above max gate, below min gate) _fundToSpare((smnca * 128) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: min=0 so no deposit, max=smnc but nothing to hold assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "OnDemand recovery: no deposit (min=0)"); @@ -1279,18 +1282,18 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); // Drain to JIT, complete thaw _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Fund above min gate -> Full _fundToSpare((smnca * (256 + 16)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "Full: recovered and deposited"); } @@ -1317,10 +1320,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 2 ); vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca2)); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); (uint256 bal1, uint256 thawing1, ) = _escrowAccount(address(recurringCollector), indexer); (uint256 bal2, uint256 thawing2, ) = _escrowAccount(address(recurringCollector), indexer2); @@ -1348,24 +1351,24 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); _offerAgreement(rca2); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc1 = agreementManager.getSumMaxNextClaim(_collector(), indexer); uint256 pairSmnc2 = agreementManager.getSumMaxNextClaim(_collector(), indexer2); // Drain and degrade _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); // Complete thaws vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); // Fund above min gate -> both recover to Full _fundToSpare((smnca * (256 + 16)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc1, "indexer: recovered to Full"); assertEq(_effectiveEscrow(address(recurringCollector), indexer2), pairSmnc2, "indexer2: recovered to Full"); @@ -1392,11 +1395,11 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Fund to just above min gate for current smnca _drainSAM(); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 deficit = agreementManager.getTotalEscrowDeficit(); token.mint(address(agreementManager), deficit + (smnca * (256 + 16)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq( _effectiveEscrow(address(recurringCollector), indexer), pairSmnc1, @@ -1412,10 +1415,10 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 2 ); vm.prank(operator); - agreementManager.offerAgreement(rca2, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca2)); // Reconcile indexer -- existing provider's escrow now degraded - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // New smnca much larger, spare likely below max gate too -> JIT-like (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); @@ -1441,7 +1444,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS ); _drainSAM(); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq( uint256(agreementManager.getEscrowBasis()), @@ -1449,11 +1452,11 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS "Basis: still Full after degradation" ); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); _fundToSpare((smnca * (256 + 16)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq( uint256(agreementManager.getEscrowBasis()), @@ -1465,7 +1468,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // ---- Edge case: no agreements (smnca = 0) ---- function test_BasisDegradation_NoAgreements_NoRevert() public { - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), 0, "No agreements: zero escrow"); } @@ -1485,12 +1488,12 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); uint256 pairSmnc = agreementManager.getSumMaxNextClaim(_collector(), indexer); // spare = smnca * 1.2 -- above max gate (0.5) but below min gate (1.5) _fundToSpare((smnca * 307) / 256); // ~1.2x - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: holds pre-deposited escrow (max=smnc), no deposit (min=0) assertEq( @@ -1501,7 +1504,7 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS // Fund above 1.5x -> Full _fundToSpare((smnca * (256 + 128)) / 256 + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); assertEq(_effectiveEscrow(address(recurringCollector), indexer), pairSmnc, "Full with wide band: deposited"); } @@ -1519,20 +1522,20 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS 1 ); _offerAgreement(rca); - uint256 smnca = agreementManager.getSumMaxNextClaimAll(); + uint256 smnca = agreementManager.getSumMaxNextClaim(); // spare = smnca * 0.6 -- below new max gate (0.78) -> JIT-like _fundToSpare((smnca * 154) / 256); // ~0.6x - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); (uint256 bal, uint256 thawing, ) = _escrowAccount(address(recurringCollector), indexer); assertEq(thawing, bal, "JIT with higher threshold: thaws all at 0.6x"); // spare = smnca * 0.85 -- above new max gate (0.78) -> OnDemand vm.warp(block.timestamp + 2 days); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); _fundToSpare((smnca * 218) / 256); // ~0.85x - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // OnDemand: no deposit (min=0), no thaw (max=smnc) (uint256 bal2, uint256 thawing2, ) = _escrowAccount(address(recurringCollector), indexer); @@ -1554,7 +1557,6 @@ contract RecurringAgreementManagerFundingModesTest is RecurringAgreementManagerS uint256 samBalance = token.balanceOf(address(agreementManager)); if (0 < samBalance) { vm.prank(address(agreementManager)); - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(address(1), samBalance); } diff --git a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol index 8ad42ba34..a456934e6 100644 --- a/packages/issuance/test/unit/agreement-manager/fuzz.t.sol +++ b/packages/issuance/test/unit/agreement-manager/fuzz.t.sol @@ -2,6 +2,10 @@ pragma solidity ^0.8.27; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -30,9 +34,15 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes bytes16 agreementId = _offerAgreement(rca); - uint256 expectedMaxClaim = uint256(maxOngoingTokensPerSecond) * uint256(maxSecondsPerCollection) + - uint256(maxInitialTokens); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + uint256 remainingSeconds = endsAt > block.timestamp ? endsAt - block.timestamp : 0; + uint256 effectiveSeconds = remainingSeconds < maxSecondsPerCollection + ? remainingSeconds + : maxSecondsPerCollection; + uint256 expectedMaxClaim = uint256(maxOngoingTokensPerSecond) * effectiveSeconds + uint256(maxInitialTokens); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + expectedMaxClaim + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); } @@ -57,9 +67,12 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes // Fund with a specific amount instead of the default 1M ether token.mint(address(agreementManager), availableTokens); vm.prank(operator); - bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + bytes16 agreementId = agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); - uint256 maxNextClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 maxNextClaim = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( address(agreementManager), address(recurringCollector), @@ -115,16 +128,23 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes _offerAgreement(rca2); uint256 required2 = agreementManager.getSumMaxNextClaim(_collector(), indexer); - uint256 maxClaim1 = uint256(maxOngoing1) * uint256(maxSec1) + uint256(maxInitial1); - uint256 maxClaim2 = uint256(maxOngoing2) * uint256(maxSec2) + uint256(maxInitial2); + uint256 remaining = uint256(block.timestamp + 365 days) - block.timestamp; + uint256 eff1 = remaining < maxSec1 ? remaining : maxSec1; + uint256 eff2 = remaining < maxSec2 ? remaining : maxSec2; + uint256 maxClaim1 = uint256(maxOngoing1) * eff1 + uint256(maxInitial1); + uint256 maxClaim2 = uint256(maxOngoing2) * eff2 + uint256(maxInitial2); assertEq(required1, maxClaim1); assertEq(required2, maxClaim1 + maxClaim2); } - // -- revokeOffer / reconcileAgreement -- + // -- cancelAgreement / reconcileAgreement -- - function testFuzz_RevokeOffer_RequiredEscrowDecrements(uint64 maxInitial, uint64 maxOngoing, uint32 maxSec) public { + function testFuzz_CancelOffered_RequiredEscrowDecrements( + uint64 maxInitial, + uint64 maxOngoing, + uint32 maxSec + ) public { vm.assume(0 < maxSec); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( @@ -139,11 +159,10 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes uint256 requiredBefore = agreementManager.getSumMaxNextClaim(_collector(), indexer); assertTrue(0 < requiredBefore || (maxInitial == 0 && maxOngoing == 0)); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + _cancelAgreement(agreementId); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function testFuzz_Remove_AfterSPCancel_ClearsState(uint64 maxInitial, uint64 maxOngoing, uint32 maxSec) public { @@ -160,11 +179,14 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes bytes16 agreementId = _offerAgreement(rca); _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); } // -- reconcile -- @@ -198,7 +220,7 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes // Warp to collection time vm.warp(collectionAt); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); uint256 postReconcileRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); @@ -218,6 +240,8 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes uint32 updateMaxSec ) public { vm.assume(0 < maxSec && 0 < updateMaxSec); + // Ensure non-zero claim so agreement isn't immediately cleaned up + vm.assume(0 < maxInitial || 0 < maxOngoing); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( maxInitial, @@ -229,24 +253,30 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes bytes16 agreementId = _offerAgreement(rca); - uint256 originalMaxClaim = uint256(maxOngoing) * uint256(maxSec) + uint256(maxInitial); + uint256 remainingOrig = uint256(block.timestamp + 365 days) - block.timestamp; + uint256 effOrig = remainingOrig < maxSec ? remainingOrig : maxSec; + uint256 originalMaxClaim = uint256(maxOngoing) * effOrig + uint256(maxInitial); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); + uint64 updateEndsAt = uint64(block.timestamp + 730 days); IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( agreementId, updateMaxInitial, updateMaxOngoing, 60, updateMaxSec, - uint64(block.timestamp + 730 days), + updateEndsAt, 1 ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = uint256(updateMaxOngoing) * uint256(updateMaxSec) + uint256(updateMaxInitial); + uint256 remainingUpdate = uint256(updateEndsAt) - block.timestamp; + uint256 effUpdate = remainingUpdate < updateMaxSec ? remainingUpdate : updateMaxSec; + uint256 fullPendingMaxClaim = uint256(updateMaxOngoing) * effUpdate + uint256(updateMaxInitial); - // Both original and pending are funded simultaneously - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // Sum uses max(current, pending) since only one set of terms is active at a time + uint256 expectedSum = fullPendingMaxClaim > originalMaxClaim ? fullPendingMaxClaim : originalMaxClaim; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedSum); } // -- reconcileAgreement deadline -- @@ -264,15 +294,18 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes bytes16 agreementId = _offerAgreement(rca); // Before deadline: should return true (still claimable) - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); // Warp past deadline vm.warp(rca.deadline + extraTime); // After deadline: should succeed - agreementManager.reconcileAgreement(agreementId); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } // -- getEscrowAccount -- @@ -291,7 +324,7 @@ contract RecurringAgreementManagerFuzzTest is RecurringAgreementManagerSharedTes token.mint(address(agreementManager), available); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); IPaymentsEscrow.EscrowAccount memory expected; (expected.balance, expected.tokensThawing, expected.thawEndTimestamp) = paymentsEscrow.escrowAccounts( diff --git a/packages/issuance/test/unit/agreement-manager/helper.t.sol b/packages/issuance/test/unit/agreement-manager/helper.t.sol index 962dab945..1560bb7e9 100644 --- a/packages/issuance/test/unit/agreement-manager/helper.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helper.t.sol @@ -4,10 +4,13 @@ pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementHelper } from "../../../contracts/agreement/RecurringAgreementHelper.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +// solhint-disable-next-line no-unused-import +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ @@ -63,20 +66,23 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { // Fund for reconcile token.mint(address(agreementManager), 1_000_000 ether); - agreementHelper.reconcile(indexer); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); // Agreement 1: CanceledBySP -> maxClaim = 0 - assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); + assertEq(agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id1), 0); // Agreement 2: collected, remaining window large, capped at maxSecondsPerCollection = 7200 // maxClaim = 2e18 * 7200 = 14400e18 (no initial since collected) - assertEq(agreementManager.getAgreementMaxNextClaim(id2), 14400 ether); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id2), + 14400 ether + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14400 ether); } function test_Reconcile_EmptyProvider() public { // reconcile for a provider with no agreements — should be a no-op address unknown = makeAddr("unknown"); - agreementHelper.reconcile(unknown); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), unknown); assertEq(agreementManager.getSumMaxNextClaim(_collector(), unknown), 0); } @@ -94,16 +100,22 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); // First reconcile - agreementHelper.reconcile(indexer); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); uint256 escrowAfterFirst = agreementManager.getSumMaxNextClaim(_collector(), indexer); - uint256 maxClaimAfterFirst = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 maxClaimAfterFirst = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); // Second reconcile should produce identical results (idempotent) vm.recordLogs(); - agreementHelper.reconcile(indexer); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), escrowAfterFirst); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), maxClaimAfterFirst); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + maxClaimAfterFirst + ); // No reconcile event on the second call since nothing changed Vm.Log[] memory logs = vm.getRecordedLogs(); @@ -159,12 +171,18 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { vm.warp(lastCollectionAt); token.mint(address(agreementManager), 1_000_000 ether); - agreementHelper.reconcile(indexer); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); - assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); - assertEq(agreementManager.getAgreementMaxNextClaim(id2), 14400 ether); // 2e18 * 7200 + assertEq(agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id1), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id2), + 14400 ether + ); // 2e18 * 7200 // id3 unchanged: 3e18 * 1800 = 5400e18 (pre-offer estimate) - assertEq(agreementManager.getAgreementMaxNextClaim(id3), 5400 ether); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id3), + 5400 ether + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14400 ether + 5400 ether); } @@ -204,12 +222,16 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { bytes16[] memory ids = new bytes16[](2); ids[0] = id1; ids[1] = id2; - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); // Agreement 1 canceled by SP -> maxNextClaim = 0 - assertEq(agreementManager.getAgreementMaxNextClaim(id1), 0); + assertEq(agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id1), 0); // Agreement 2 accepted, never collected -> maxNextClaim = initial + ongoing - assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id2), + maxClaim2 + ); // Required should be just agreement 2 now assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); } @@ -232,17 +254,22 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { bytes16[] memory ids = new bytes16[](2); ids[0] = fakeId; ids[1] = realId; - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); // Real agreement should still be tracked uint256 maxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getAgreementMaxNextClaim(realId), maxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), realId), + maxClaim + ); } function test_ReconcileBatch_Empty() public { // Empty array — should succeed silently bytes16[] memory ids = new bytes16[](0); - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); } function test_ReconcileBatch_CrossIndexer() public { @@ -284,7 +311,8 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { bytes16[] memory ids = new bytes16[](2); ids[0] = id1; ids[1] = id2; - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), 0); @@ -306,7 +334,16 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { bytes16[] memory ids = new bytes16[](1); ids[0] = agreementId; vm.prank(anyone); - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); + } + + function _setSimulatedAgreement( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) private { + _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + recurringCollector.setUpdateNonce(agreementId, 1); } function test_ReconcileBatch_ClearsPendingUpdate() public { @@ -319,7 +356,6 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { bytes16 agreementId = _offerAgreement(rca); - // Offer a pending update (nonce 1) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( agreementId, 200 ether, @@ -331,39 +367,24 @@ contract RecurringAgreementHelperTest is RecurringAgreementManagerSharedTest { ); _offerAgreementUpdate(rcau); - uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 14600 ether); - // Simulate: accepted with the update already applied (pending <= updateNonce) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rcau.endsAt, - maxInitialTokens: rcau.maxInitialTokens, - maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, - minSecondsPerCollection: rcau.minSecondsPerCollection, - maxSecondsPerCollection: rcau.maxSecondsPerCollection, - updateNonce: 1, // matches pending nonce, so update was applied - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); + // Simulate: accepted with the update already applied (use updated terms) + rca.maxInitialTokens = 200 ether; + rca.maxOngoingTokensPerSecond = 2 ether; + rca.minSecondsPerCollection = 60; + rca.maxSecondsPerCollection = 7200; + rca.endsAt = uint64(block.timestamp + 730 days); + _setSimulatedAgreement(agreementId, rca); bytes16[] memory ids = new bytes16[](1); ids[0] = agreementId; - agreementHelper.reconcileBatch(ids); + for (uint256 i = 0; i < ids.length; ++i) + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), ids[i]); // Pending should be cleared; required escrow should be based on new terms - uint256 newMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), newMaxClaim); + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 2 ether * 7200 + 200 ether); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol index 4c21e4d22..72272c3e6 100644 --- a/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helperAudit.t.sol @@ -3,6 +3,12 @@ pragma solidity ^0.8.27; import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { + IAgreementCollector, + REGISTERED, + ACCEPTED, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -41,8 +47,8 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 60, maxSecondsPerCollection: 3600, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); } @@ -53,7 +59,8 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes ) internal returns (bytes16) { token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + return + agreementManager.offerAgreement(IRecurringCollector(address(collector)), OFFER_TYPE_NEW, abi.encode(rca)); } // -- Tests: auditGlobal -- @@ -63,7 +70,6 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes assertEq(g.tokenBalance, 0); assertEq(g.sumMaxNextClaimAll, 0); assertEq(g.totalEscrowDeficit, 0); - assertEq(g.totalAgreementCount, 0); assertEq(uint256(g.escrowBasis), uint256(IRecurringEscrowManagement.EscrowBasis.Full)); assertEq(g.minOnDemandBasisThreshold, 128); assertEq(g.minFullBasisMargin, 16); @@ -82,7 +88,6 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); assertEq(g.sumMaxNextClaimAll, maxClaim); - assertEq(g.totalAgreementCount, 1); assertEq(g.collectorCount, 1); // Token balance is the minted amount minus what was deposited to escrow assertTrue(0 < g.tokenBalance); @@ -100,15 +105,17 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes _offerForCollector(collector2, rca2); IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 2); assertEq(g.collectorCount, 2); } - // -- Tests: auditPair -- + // -- Tests: auditProvider -- function test_AuditPair_NonExistent() public view { - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); - assertEq(p.collector, address(recurringCollector)); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); + assertEq(address(p.collector), address(recurringCollector)); assertEq(p.provider, indexer); assertEq(p.agreementCount, 0); assertEq(p.sumMaxNextClaim, 0); @@ -125,7 +132,10 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes uint256 maxClaim = 1 ether * 3600 + 100 ether; - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(p.agreementCount, 1); assertEq(p.sumMaxNextClaim, maxClaim); assertEq(p.escrow.balance, maxClaim); // Full mode deposits all @@ -141,19 +151,24 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes // Cancel by SP to make maxNextClaim = 0, then reconcile (thaw starts) _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); // sumMaxNextClaim should be 0 after reconcile assertEq(p.sumMaxNextClaim, 0); // Escrow should be thawing assertTrue(0 < p.escrow.tokensThawing); } - // -- Tests: auditPairs -- + // -- Tests: auditProviders -- function test_AuditPairs_EmptyCollector() public view { - IRecurringAgreementHelper.PairAudit[] memory pairs = agreementHelper.auditPairs(address(recurringCollector)); + IRecurringAgreementHelper.ProviderAudit[] memory pairs = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)) + ); assertEq(pairs.length, 0); } @@ -172,7 +187,9 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes ); _offerAgreement(rca2); - IRecurringAgreementHelper.PairAudit[] memory pairs = agreementHelper.auditPairs(address(recurringCollector)); + IRecurringAgreementHelper.ProviderAudit[] memory pairs = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)) + ); assertEq(pairs.length, 2); // Both should have agreementCount = 1 assertEq(pairs[0].agreementCount, 1); @@ -195,28 +212,127 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes _offerAgreement(rca2); // First page - IRecurringAgreementHelper.PairAudit[] memory first = agreementHelper.auditPairs( - address(recurringCollector), + IRecurringAgreementHelper.ProviderAudit[] memory first = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)), + 0, + 1 + ); + assertEq(first.length, 1); + + // Second page + IRecurringAgreementHelper.ProviderAudit[] memory second = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)), + 1, + 1 + ); + assertEq(second.length, 1); + + // Past end + IRecurringAgreementHelper.ProviderAudit[] memory empty = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)), + 2, + 1 + ); + assertEq(empty.length, 0); + } + + // -- Tests: getProviderAgreements (paginated) -- + + function test_GetProviderAgreements_Paginated() public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector( + recurringCollector, + indexer, + 2 + ); + _offerAgreement(rca2); + + // Full list + bytes16[] memory all = agreementHelper.getAgreements(IAgreementCollector(address(recurringCollector)), indexer); + assertEq(all.length, 2); + + // First page + bytes16[] memory first = agreementHelper.getAgreements( + IAgreementCollector(address(recurringCollector)), + indexer, 0, 1 ); assertEq(first.length, 1); + assertEq(first[0], all[0]); // Second page - IRecurringAgreementHelper.PairAudit[] memory second = agreementHelper.auditPairs( - address(recurringCollector), + bytes16[] memory second = agreementHelper.getAgreements( + IAgreementCollector(address(recurringCollector)), + indexer, 1, 1 ); assertEq(second.length, 1); + assertEq(second[0], all[1]); // Past end - IRecurringAgreementHelper.PairAudit[] memory empty = agreementHelper.auditPairs( - address(recurringCollector), + bytes16[] memory empty = agreementHelper.getAgreements( + IAgreementCollector(address(recurringCollector)), + indexer, 2, 1 ); assertEq(empty.length, 0); + + // Count larger than remaining + bytes16[] memory clamped = agreementHelper.getAgreements( + IAgreementCollector(address(recurringCollector)), + indexer, + 1, + 100 + ); + assertEq(clamped.length, 1); + assertEq(clamped[0], all[1]); + } + + // -- Tests: getCollectors (paginated) -- + + function test_GetCollectors_Paginated() public { + // Create agreements under two different collectors to register them + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForCollector( + recurringCollector, + indexer, + 1 + ); + _offerAgreement(rca1); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector(collector2, indexer, 2); + _offerForCollector(collector2, rca2); + + // Full list + address[] memory all = agreementHelper.getCollectors(); + assertEq(all.length, 2); + + // First page + address[] memory first = agreementHelper.getCollectors(0, 1); + assertEq(first.length, 1); + assertEq(first[0], all[0]); + + // Second page + address[] memory second = agreementHelper.getCollectors(1, 1); + assertEq(second.length, 1); + assertEq(second[0], all[1]); + + // Past end + address[] memory empty = agreementHelper.getCollectors(2, 1); + assertEq(empty.length, 0); + + // Count larger than remaining + address[] memory clamped = agreementHelper.getCollectors(1, 100); + assertEq(clamped.length, 1); + assertEq(clamped[0], all[1]); } function test_AuditPairs_IsolatesCollectors() public { @@ -230,12 +346,57 @@ contract RecurringAgreementHelperAuditTest is RecurringAgreementManagerSharedTes IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCAForCollector(collector2, indexer, 2); _offerForCollector(collector2, rca2); - IRecurringAgreementHelper.PairAudit[] memory c1Pairs = agreementHelper.auditPairs(address(recurringCollector)); + IRecurringAgreementHelper.ProviderAudit[] memory c1Pairs = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)) + ); assertEq(c1Pairs.length, 1); - IRecurringAgreementHelper.PairAudit[] memory c2Pairs = agreementHelper.auditPairs(address(collector2)); + IRecurringAgreementHelper.ProviderAudit[] memory c2Pairs = agreementHelper.auditProviders( + IAgreementCollector(address(collector2)) + ); assertEq(c2Pairs.length, 1); } + // -- checkStaleness -- + + function test_CheckPairStaleness_DetectsStaleAgreement() public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + token.mint(address(agreementManager), 1_000_000 ether); + bytes16 agreementId = _offerAgreement(rca); + + // Fresh state: cached == live + (IRecurringAgreementHelper.AgreementStaleness[] memory stale, bool escrowStale) = agreementHelper + .checkStaleness(IAgreementCollector(address(recurringCollector)), indexer); + assertEq(stale.length, 1); + assertEq(stale[0].agreementId, agreementId); + assertFalse(stale[0].stale, "Should not be stale when cached == live"); + + // Make it stale: modify the collector's agreement so getMaxNextClaim diverges + MockRecurringCollector.AgreementStorage memory mockData = _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + rca.endsAt, + 0 + ); + mockData.activeTerms.maxOngoingTokensPerSecond = 2 ether; // double the rate + recurringCollector.setAgreement(agreementId, mockData); + + // Now cached != live + (stale, escrowStale) = agreementHelper.checkStaleness( + IAgreementCollector(address(recurringCollector)), + indexer + ); + assertEq(stale.length, 1); + assertTrue(stale[0].stale, "Should be stale when collector rate changed"); + assertTrue(stale[0].liveMaxNextClaim > stale[0].cachedMaxNextClaim); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol index e4684093f..6136a2b2b 100644 --- a/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol +++ b/packages/issuance/test/unit/agreement-manager/helperCleanup.t.sol @@ -1,9 +1,21 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PROVIDER, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedTest { @@ -39,7 +51,8 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT ) internal returns (bytes16) { token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + return + agreementManager.offerAgreement(IRecurringCollector(address(collector)), OFFER_TYPE_NEW, abi.encode(rca)); } function _setCanceledBySPOnCollector( @@ -49,23 +62,13 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT ) internal { collector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: uint64(block.timestamp), - state: IRecurringCollector.AgreementState.CanceledByServiceProvider - }) + _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED | NOTICE_GIVEN | SETTLED | BY_PROVIDER, + uint64(block.timestamp), + uint64(block.timestamp), + 0 + ) ); } @@ -76,9 +79,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_Reconcile_SkipsStillClaimable() public { @@ -86,9 +89,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id = _offerAgreement(rca); _setAgreementAccepted(id, rca, uint64(block.timestamp)); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Reconcile_MixedStates() public { @@ -102,13 +105,13 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id2 = _offerAgreement(rca2); _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Reconcile_EmptyProvider() public { - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 0); } @@ -119,9 +122,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT // Warp past deadline vm.warp(rca.deadline + 1); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_Reconcile_Permissionless() public { @@ -131,28 +134,31 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT address anyone = makeAddr("anyone"); vm.prank(anyone); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); } - // -- Tests: reconcilePair -- + // -- Tests: reconcile -- function test_ReconcilePair_RemovesAgreementButPairStaysWhileThawing() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); // escrow still thawing — pair stays tracked + assertTrue(providerExists); // escrow still thawing — pair stays tracked // Drain escrow, then pair can be removed vm.warp(block.timestamp + 1 days + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); - assertFalse(pairExists); - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 0); + (, providerExists) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(providerExists); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); } function test_ReconcilePair_PairExistsWhenAgreementsRemain() public { @@ -165,9 +171,12 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id2 = _offerAgreement(rca2); _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); + assertTrue(providerExists); } function test_ReconcilePair_IsolatesCollectors() public { @@ -182,12 +191,15 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT _offerForCollector(collector2, rca2); // Reconcile only collector1's pair — escrow still thawing - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); // escrow still thawing + assertTrue(providerExists); // escrow still thawing // Collector2's agreement untouched - assertEq(agreementManager.getPairAgreementCount(address(collector2), indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(collector2)), indexer), 1); } // -- Tests: reconcileCollector -- @@ -201,16 +213,18 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id2 = _offerAgreement(rca2); _setAgreementCanceledBySP(id2, rca2); - (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector( + IAgreementCollector(address(recurringCollector)) + ); assertEq(removed, 2); assertTrue(collectorExists); // escrow still thawing for both pairs // Drain escrows, then collector can be removed vm.warp(block.timestamp + 1 days + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); - (, collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + (, collectorExists) = agreementHelper.reconcileCollector(IAgreementCollector(address(recurringCollector))); assertFalse(collectorExists); assertEq(agreementManager.getCollectorCount(), 0); } @@ -225,7 +239,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id2 = _offerAgreement(rca2); _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); - (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector(address(recurringCollector)); + (uint256 removed, bool collectorExists) = agreementHelper.reconcileCollector( + IAgreementCollector(address(recurringCollector)) + ); assertEq(removed, 1); assertTrue(collectorExists); // indexer2 still has an active agreement } @@ -245,13 +261,12 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT uint256 removed = agreementHelper.reconcileAll(); assertEq(removed, 2); - assertEq(agreementManager.getTotalAgreementCount(), 0); assertEq(agreementManager.getCollectorCount(), 2); // escrow still thawing // Drain escrows, then collectors can be removed vm.warp(block.timestamp + 1 days + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(collector2), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(collector2)), indexer); agreementHelper.reconcileAll(); assertEq(agreementManager.getCollectorCount(), 0); @@ -275,10 +290,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT uint256 removed = agreementHelper.reconcileAll(); assertEq(removed, 1); - assertEq(agreementManager.getTotalAgreementCount(), 1); } - // -- Tests: reconcilePair (value reconciliation + cleanup) -- + // -- Tests: reconcile (value reconciliation + cleanup) -- function test_ReconcilePair_OnlyReconcilesPairAgreements() public { // Collector1 + indexer: cancel by SP @@ -296,7 +310,7 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); // Reconcile only collector1's pair - (uint256 removed, ) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); // Collector1's pair reconciled to 0 @@ -332,9 +346,9 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT // Set as CanceledBySP — after reconcile, maxNextClaim=0, then removable _setAgreementCanceledBySP(id, rca); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_Reconcile_NoopWhenAllActive() public { @@ -342,28 +356,31 @@ contract RecurringAgreementHelperCleanupTest is RecurringAgreementManagerSharedT bytes16 id = _offerAgreement(rca); _setAgreementAccepted(id, rca, uint64(block.timestamp)); - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } - // -- Tests: reconcilePair does reconcile+cleanup+pair removal -- + // -- Tests: reconcile does reconcile+cleanup+pair removal -- function test_ReconcilePair_RemovesAgreementAndPairAfterThaw() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor(indexer, 1); bytes16 id = _offerAgreement(rca); _setAgreementCanceledBySP(id, rca); - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); // escrow still thawing + assertTrue(providerExists); // escrow still thawing // Drain escrow, then pair can be removed vm.warp(block.timestamp + 1 days + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); - assertFalse(pairExists); + (, providerExists) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(providerExists); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol index 5a560d8e2..b7052ecc1 100644 --- a/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol +++ b/packages/issuance/test/unit/agreement-manager/lifecycle.t.sol @@ -1,11 +1,25 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PROVIDER, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest { @@ -46,8 +60,8 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest maxOngoingTokensPerSecond: maxOngoing, minSecondsPerCollection: 60, maxSecondsPerCollection: maxSec, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); } @@ -58,7 +72,8 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest ) internal returns (bytes16) { token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - return agreementManager.offerAgreement(rca, IRecurringCollector(address(collector))); + return + agreementManager.offerAgreement(IRecurringCollector(address(collector)), OFFER_TYPE_NEW, abi.encode(rca)); } function _setCanceledBySPOnCollector( @@ -68,23 +83,13 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest ) internal { collector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: uint64(block.timestamp), - state: IRecurringCollector.AgreementState.CanceledByServiceProvider - }) + _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED | NOTICE_GIVEN | SETTLED | BY_PROVIDER, + uint64(block.timestamp), + uint64(block.timestamp), + 0 + ) ); } @@ -93,8 +98,6 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest function test_Lifecycle_OfferAcceptCancelReconcileCleanup() public { // 1. Start empty IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 0); - // 2. Offer IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCAFor( recurringCollector, @@ -109,11 +112,13 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest // 3. Audit: agreement tracked, escrow deposited g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 1); assertEq(g.sumMaxNextClaimAll, maxClaim); assertEq(g.collectorCount, 1); - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(p.agreementCount, 1); assertEq(p.sumMaxNextClaim, maxClaim); assertEq(p.escrow.balance, maxClaim); // Full mode @@ -126,7 +131,7 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _setAgreementCollected(agreementId, rca, uint64(block.timestamp - 1800), uint64(block.timestamp)); // 6. Reconcile — maxInitialTokens drops out after first collection - agreementHelper.reconcile(indexer); + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); uint256 reducedMaxClaim = 1 ether * 3600; // no more initial assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), reducedMaxClaim); @@ -134,29 +139,28 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _setAgreementCanceledBySP(agreementId, rca); // 8. Reconcile - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); // 9. Agreements gone, but escrow still thawing — collector stays tracked g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 0); assertEq(g.sumMaxNextClaimAll, 0); assertEq(g.collectorCount, 1); // still tracked — escrow not yet drained // 10. Escrow is thawing - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertTrue(0 < p.escrow.tokensThawing); // 11. Wait for thaw and withdraw vm.warp(block.timestamp + THAW_PERIOD + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.balance, 0); assertEq(p.escrow.tokensThawing, 0); - // 12. Now that escrow is drained, reconcilePair removes tracking - agreementHelper.reconcilePair(address(recurringCollector), indexer); + // 12. Now that escrow is drained, reconcile removes tracking + agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); g = agreementHelper.auditGlobal(); assertEq(g.collectorCount, 0); // fully cleaned up @@ -178,7 +182,10 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); uint256 maxClaim = 1 ether * 3600 + 100 ether; - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(p.escrow.balance, maxClaim); assertEq(p.escrow.tokensThawing, 0); @@ -189,35 +196,35 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); assertEq(uint256(g.escrowBasis), uint256(IRecurringEscrowManagement.EscrowBasis.OnDemand)); - // reconcileCollectorProvider — OnDemand has min=0, max=sumMaxNextClaim. + // reconcileProvider — OnDemand has min=0, max=sumMaxNextClaim. // Balance == max so no thaw needed (balanced) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); // In OnDemand with balance == max, no thaw assertEq(p.escrow.balance, maxClaim); // Switch to JustInTime — should start thawing everything vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.tokensThawing, maxClaim); // thawing everything // Wait for thaw and withdraw vm.warp(block.timestamp + THAW_PERIOD + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.balance, 0); // Switch back to Full — should deposit again vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.balance, maxClaim); assertEq(p.escrow.tokensThawing, 0); } @@ -261,15 +268,18 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest // Audit global IRecurringAgreementHelper.GlobalAudit memory g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 3); assertEq(g.sumMaxNextClaimAll, maxClaim1 + maxClaim2 + maxClaim3); assertEq(g.collectorCount, 2); // Audit pairs per collector - IRecurringAgreementHelper.PairAudit[] memory c1Pairs = agreementHelper.auditPairs(address(recurringCollector)); + IRecurringAgreementHelper.ProviderAudit[] memory c1Pairs = agreementHelper.auditProviders( + IAgreementCollector(address(recurringCollector)) + ); assertEq(c1Pairs.length, 2); - IRecurringAgreementHelper.PairAudit[] memory c2Pairs = agreementHelper.auditPairs(address(collector2)); + IRecurringAgreementHelper.ProviderAudit[] memory c2Pairs = agreementHelper.auditProviders( + IAgreementCollector(address(collector2)) + ); assertEq(c2Pairs.length, 1); assertEq(c2Pairs[0].sumMaxNextClaim, maxClaim3); @@ -279,16 +289,18 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _setAgreementCanceledBySP(id1, rca1); // Selective reconcile: only collector1+indexer — escrow still thawing - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); // escrow still thawing + assertTrue(providerExists); // escrow still thawing // collector1 still has indexer2 (+ c1+indexer pair tracked due to thawing escrow) - assertEq(agreementManager.getCollectorProviderCount(address(recurringCollector)), 2); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 2); // Global state updated g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 2); assertEq(g.sumMaxNextClaimAll, maxClaim2 + maxClaim3); // Cancel remaining and full reconcile @@ -301,43 +313,48 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest // Agreements gone, but escrows still thawing — collectors stay tracked g = agreementHelper.auditGlobal(); - assertEq(g.totalAgreementCount, 0); assertEq(g.sumMaxNextClaimAll, 0); assertEq(g.collectorCount, 2); // still tracked — escrow not yet drained // Escrows should be thawing for all pairs - IRecurringAgreementHelper.PairAudit memory p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p1 = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertTrue(0 < p1.escrow.tokensThawing, "c1+indexer should be thawing"); - IRecurringAgreementHelper.PairAudit memory p2 = agreementHelper.auditPair( - address(recurringCollector), + IRecurringAgreementHelper.ProviderAudit memory p2 = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), indexer2 ); assertTrue(0 < p2.escrow.tokensThawing, "c1+indexer2 should be thawing"); - IRecurringAgreementHelper.PairAudit memory p3 = agreementHelper.auditPair(address(collector2), indexer); + IRecurringAgreementHelper.ProviderAudit memory p3 = agreementHelper.auditProvider( + IAgreementCollector(address(collector2)), + indexer + ); assertTrue(0 < p3.escrow.tokensThawing, "c2+indexer should be thawing"); // Wait for thaw, withdraw all vm.warp(block.timestamp + THAW_PERIOD + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); - agreementManager.reconcileCollectorProvider(address(collector2), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(collector2)), indexer); // All escrows drained - p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + p1 = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p1.escrow.balance, 0); assertEq(p1.escrow.tokensThawing, 0); - p2 = agreementHelper.auditPair(address(recurringCollector), indexer2); + p2 = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer2); assertEq(p2.escrow.balance, 0); assertEq(p2.escrow.tokensThawing, 0); - p3 = agreementHelper.auditPair(address(collector2), indexer); + p3 = agreementHelper.auditProvider(IAgreementCollector(address(collector2)), indexer); assertEq(p3.escrow.balance, 0); assertEq(p3.escrow.tokensThawing, 0); - // Now reconcile tracking (escrow drained, so reconcileCollectorProvider succeeds) + // Now reconcile tracking (escrow drained, so reconcileProvider succeeds) agreementHelper.reconcileAll(); g = agreementHelper.auditGlobal(); @@ -358,31 +375,34 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _offerAgreement(rca); // Before deadline: not removable - uint256 removed = agreementHelper.reconcile(indexer); + (uint256 removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 0); // Warp past deadline vm.warp(rca.deadline + 1); // Now removable - removed = agreementHelper.reconcile(indexer); + (removed, ) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); assertEq(removed, 1); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); // Escrow deposited in Full mode should now be thawing - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertTrue(0 < p.escrow.tokensThawing, "escrow should be thawing after expired offer removal"); // Wait for thaw and withdraw vm.warp(block.timestamp + THAW_PERIOD + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.balance, 0); assertEq(p.escrow.tokensThawing, 0); } - // -- Tests: reconcilePair Isolation -- + // -- Tests: reconcile Isolation -- function test_Lifecycle_ReconcilePair_IsolatesCollectors() public { // Both collectors have agreements with the same indexer @@ -408,36 +428,45 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _offerForCollector(collector2, rca2); // Reconcile only collector1's pair — escrow still thawing so pair still exists - (uint256 removed, bool pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); + (uint256 removed, bool providerExists) = agreementHelper.reconcile( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(removed, 1); - assertTrue(pairExists); // escrow still thawing, pair stays tracked + assertTrue(providerExists); // escrow still thawing, pair stays tracked // Collector2's agreement untouched uint256 maxClaim1 = 1 ether * 3600 + 100 ether; uint256 maxClaim2 = 2 ether * 7200 + 200 ether; assertEq(agreementManager.getSumMaxNextClaim(IRecurringCollector(address(collector2)), indexer), maxClaim2); - assertEq(agreementManager.getPairAgreementCount(address(collector2), indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(collector2)), indexer), 1); // Collector1's escrow should be thawing after reconcile - IRecurringAgreementHelper.PairAudit memory p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p1 = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertTrue(0 < p1.escrow.tokensThawing, "c1 escrow should be thawing after reconcile"); // Collector2's escrow should still be fully deposited (not thawing) - IRecurringAgreementHelper.PairAudit memory p2 = agreementHelper.auditPair(address(collector2), indexer); + IRecurringAgreementHelper.ProviderAudit memory p2 = agreementHelper.auditProvider( + IAgreementCollector(address(collector2)), + indexer + ); assertEq(p2.escrow.balance, maxClaim2); assertEq(p2.escrow.tokensThawing, 0); // Wait for thaw, then drain collector1's escrow vm.warp(block.timestamp + THAW_PERIOD + 1); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p1 = agreementHelper.auditPair(address(recurringCollector), indexer); + p1 = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p1.escrow.balance, 0); assertEq(p1.escrow.tokensThawing, 0); // Now pair can be fully removed - (, pairExists) = agreementHelper.reconcilePair(address(recurringCollector), indexer); - assertFalse(pairExists); // escrow drained, pair removed + (, providerExists) = agreementHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(providerExists); // escrow drained, pair removed } // -- Tests: Escrow Basis Mid-Lifecycle with Audit Verification -- @@ -459,7 +488,10 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest _offerAgreement(rca); uint256 maxClaim = 1 ether * 3600 + 100 ether; - IRecurringAgreementHelper.PairAudit memory p = agreementHelper.auditPair(address(recurringCollector), indexer); + IRecurringAgreementHelper.ProviderAudit memory p = agreementHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer + ); assertEq(p.sumMaxNextClaim, maxClaim); // OnDemand: no deposit, but _updateEscrow in offerAgreement may have deposited // Actually in OnDemand min=0 so no deposit happens @@ -468,9 +500,9 @@ contract RecurringAgreementLifecycleTest is RecurringAgreementManagerSharedTest // Switch to Full vm.prank(operator); agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); - p = agreementHelper.auditPair(address(recurringCollector), indexer); + p = agreementHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(p.escrow.balance, maxClaim); // Full deposits everything } diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol index 7b7d5b728..3b3e1528e 100644 --- a/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockIssuanceAllocator.sol @@ -11,14 +11,14 @@ contract MockIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { uint256 public distributeCallCount; uint256 public lastDistributedBlock; - MockGraphToken public immutable GRAPH_TOKEN; - address public immutable TARGET; + MockGraphToken public immutable graphToken; + address public immutable target; uint256 public mintPerDistribution; bool public shouldRevert; constructor(MockGraphToken _graphToken, address _target) { - GRAPH_TOKEN = _graphToken; - TARGET = _target; + graphToken = _graphToken; + target = _target; } /// @notice Set how many tokens to mint to the target on each distribution call @@ -37,19 +37,13 @@ contract MockIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { if (lastDistributedBlock == block.number) return block.number; lastDistributedBlock = block.number; if (mintPerDistribution > 0) { - GRAPH_TOKEN.mint(TARGET, mintPerDistribution); + graphToken.mint(target, mintPerDistribution); } return block.number; } function getTargetIssuancePerBlock(address) external pure override returns (TargetIssuancePerBlock memory) { - return - TargetIssuancePerBlock({ - allocatorIssuanceRate: 0, - allocatorIssuanceBlockAppliedTo: 0, - selfIssuanceRate: 0, - selfIssuanceBlockAppliedTo: 0 - }); + return TargetIssuancePerBlock(0, 0, 0, 0); } function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol index 5eca5de7d..7cab89243 100644 --- a/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockPaymentsEscrow.sol @@ -28,7 +28,6 @@ contract MockPaymentsEscrow is IPaymentsEscrow { } function deposit(address collector, address receiver, uint256 tokens) external { - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transferFrom(msg.sender, address(this), tokens); accounts[msg.sender][collector][receiver].balance += tokens; } @@ -82,7 +81,6 @@ contract MockPaymentsEscrow is IPaymentsEscrow { account.balance -= tokens; account.tokensThawing = 0; account.thawEndTimestamp = 0; - // forge-lint: disable-next-line(erc20-unchecked-transfer) token.transfer(msg.sender, tokens); } diff --git a/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol b/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol index 36275f404..66bf92b39 100644 --- a/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol +++ b/packages/issuance/test/unit/agreement-manager/mocks/MockRecurringCollector.sol @@ -1,50 +1,238 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PAYER, + BY_PROVIDER, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; /// @notice Minimal mock of RecurringCollector for RecurringAgreementManager testing. /// Stores agreement data set by tests, computes agreementId and hashRCA deterministically. contract MockRecurringCollector { - mapping(bytes16 => IRecurringCollector.AgreementData) private _agreements; - mapping(bytes16 => bool) private _agreementExists; + /// @dev Local terms struct for mock internal storage. + struct MockTerms { + uint64 deadline; + uint64 endsAt; + uint32 minSecondsPerCollection; + uint32 maxSecondsPerCollection; + uint16 conditions; + uint256 maxInitialTokens; + uint256 maxOngoingTokensPerSecond; + bytes32 hash; + } + + /// @dev Internal storage layout for mock agreements. + struct AgreementStorage { + address dataService; + uint64 acceptedAt; + uint32 updateNonce; + address payer; + uint64 lastCollectionAt; + uint16 state; + address serviceProvider; + uint64 collectableUntil; + MockTerms activeTerms; + MockTerms pendingTerms; + } + + mapping(bytes16 => AgreementStorage) private _agreements; + + // -- Simple views for test assertions -- + + function getUpdateNonce(bytes16 agreementId) external view returns (uint32) { + return _agreements[agreementId].updateNonce; + } + + function setUpdateNonce(bytes16 agreementId, uint32 nonce) external { + _agreements[agreementId].updateNonce = nonce; + } // -- Test helpers -- - function setAgreement(bytes16 agreementId, IRecurringCollector.AgreementData memory data) external { + function setAgreement(bytes16 agreementId, AgreementStorage memory data) external { _agreements[agreementId] = data; - _agreementExists[agreementId] = true; } - // -- IRecurringCollector subset -- + // -- IAgreementCollector subset -- - function getAgreement(bytes16 agreementId) external view returns (IRecurringCollector.AgreementData memory) { - return _agreements[agreementId]; + function getAgreementDetails( + bytes16 agreementId, + uint256 index + ) external view returns (IAgreementCollector.AgreementDetails memory details) { + AgreementStorage storage a = _agreements[agreementId]; + details.agreementId = agreementId; + details.payer = a.payer; + details.dataService = a.dataService; + details.serviceProvider = a.serviceProvider; + details.state = a.state; + if (index == 0) { + details.versionHash = a.activeTerms.hash; + } else if (index == 1) { + details.versionHash = a.pendingTerms.hash; + } } function getMaxNextClaim(bytes16 agreementId) external view returns (uint256) { - IRecurringCollector.AgreementData memory a = _agreements[agreementId]; - // Mirror RecurringCollector._getMaxNextClaim logic - if (a.state == IRecurringCollector.AgreementState.CanceledByServiceProvider) return 0; - if ( - a.state != IRecurringCollector.AgreementState.Accepted && - a.state != IRecurringCollector.AgreementState.CanceledByPayer - ) return 0; - - uint256 collectionStart = 0 < a.lastCollectionAt ? a.lastCollectionAt : a.acceptedAt; + return this.getMaxNextClaim(agreementId, 3); + } + + function getMaxNextClaim(bytes16 agreementId, uint8 claimScope) external view returns (uint256 maxClaim) { + AgreementStorage storage a = _agreements[agreementId]; + if (claimScope & 1 != 0) { + maxClaim = _mockClaimForTerms(a, a.activeTerms); + } + if (claimScope & 2 != 0) { + uint256 pendingClaim = _mockClaimForTerms(a, a.pendingTerms); + if (pendingClaim > maxClaim) maxClaim = pendingClaim; + } + } + + function _mockClaimForTerms(AgreementStorage storage a, MockTerms memory terms) private view returns (uint256) { + if (terms.endsAt == 0) return 0; + uint256 collectionStart; uint256 collectionEnd; - if (a.state == IRecurringCollector.AgreementState.CanceledByPayer) { - collectionEnd = a.canceledAt < a.endsAt ? a.canceledAt : a.endsAt; + + uint16 s = a.state; + bool isRegistered = (s & REGISTERED) != 0; + bool isAccepted = (s & ACCEPTED) != 0; + bool isTerminated = (s & NOTICE_GIVEN) != 0; + bool isByPayer = (s & BY_PAYER) != 0; + + if (isRegistered && !isAccepted && !isTerminated) { + if (a.dataService == address(0)) return 0; + if (terms.deadline != 0 && block.timestamp > terms.deadline) return 0; + collectionStart = block.timestamp; + collectionEnd = terms.endsAt; + } else if (isRegistered && isAccepted && !isTerminated) { + collectionStart = 0 < a.lastCollectionAt ? a.lastCollectionAt : a.acceptedAt; + collectionEnd = terms.endsAt; + } else if (isRegistered && isAccepted && isTerminated && isByPayer) { + collectionStart = 0 < a.lastCollectionAt ? a.lastCollectionAt : a.acceptedAt; + collectionEnd = a.collectableUntil < terms.endsAt ? a.collectableUntil : terms.endsAt; } else { - collectionEnd = a.endsAt; + return 0; } - if (collectionEnd <= collectionStart) return 0; + if (collectionEnd <= collectionStart) return 0; uint256 windowSeconds = collectionEnd - collectionStart; - uint256 maxSeconds = windowSeconds < a.maxSecondsPerCollection ? windowSeconds : a.maxSecondsPerCollection; - uint256 maxClaim = a.maxOngoingTokensPerSecond * maxSeconds; - if (a.lastCollectionAt == 0) maxClaim += a.maxInitialTokens; - return maxClaim; + uint256 maxSeconds = windowSeconds < terms.maxSecondsPerCollection + ? windowSeconds + : terms.maxSecondsPerCollection; + uint256 claim = terms.maxOngoingTokensPerSecond * maxSeconds; + if (a.lastCollectionAt == 0) claim += terms.maxInitialTokens; + return claim; + } + + function offer( + uint8 offerType, + bytes calldata data, + uint16 /* options */ + ) external returns (IAgreementCollector.AgreementDetails memory details) { + if (offerType == OFFER_TYPE_NEW) { + _offerNew(data, details); + } else if (offerType == OFFER_TYPE_UPDATE) { + _offerUpdate(data, details); + } + } + + function _offerNew(bytes calldata data, IAgreementCollector.AgreementDetails memory details) private { + IRecurringCollector.RecurringCollectionAgreement memory rca = abi.decode( + data, + (IRecurringCollector.RecurringCollectionAgreement) + ); + details.agreementId = _storeOffer(rca); + details.payer = rca.payer; + details.dataService = rca.dataService; + details.serviceProvider = rca.serviceProvider; + } + + function _offerUpdate(bytes calldata data, IAgreementCollector.AgreementDetails memory details) private { + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = abi.decode( + data, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + _storeUpdate(rcau); + details.agreementId = rcau.agreementId; + AgreementStorage storage a = _agreements[rcau.agreementId]; + details.payer = a.payer; + details.dataService = a.dataService; + details.serviceProvider = a.serviceProvider; + } + + function _storeOffer(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { + bytes16 agreementId = bytes16( + keccak256(abi.encode(rca.payer, rca.dataService, rca.serviceProvider, rca.deadline, rca.nonce)) + ); + AgreementStorage storage agreement = _agreements[agreementId]; + agreement.dataService = rca.dataService; + agreement.payer = rca.payer; + agreement.serviceProvider = rca.serviceProvider; + agreement.state = REGISTERED; + agreement.acceptedAt = 0; + agreement.lastCollectionAt = 0; + agreement.updateNonce = 0; + agreement.collectableUntil = 0; + _storeOfferTerms(agreement, rca); + delete agreement.pendingTerms; + return agreementId; + } + + function _storeOfferTerms( + AgreementStorage storage agreement, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) private { + agreement.activeTerms.deadline = rca.deadline; + agreement.activeTerms.endsAt = rca.endsAt; + agreement.activeTerms.maxInitialTokens = rca.maxInitialTokens; + agreement.activeTerms.maxOngoingTokensPerSecond = rca.maxOngoingTokensPerSecond; + agreement.activeTerms.minSecondsPerCollection = rca.minSecondsPerCollection; + agreement.activeTerms.maxSecondsPerCollection = rca.maxSecondsPerCollection; + agreement.activeTerms.conditions = rca.conditions; + agreement.activeTerms.hash = keccak256(abi.encode("rca", rca.payer, rca.nonce)); + } + + function _storeUpdate(IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau) internal { + AgreementStorage storage agreement = _agreements[rcau.agreementId]; + require(rcau.nonce == agreement.updateNonce + 1, "MockRecurringCollector: invalid nonce"); + agreement.pendingTerms.endsAt = rcau.endsAt; + agreement.pendingTerms.maxInitialTokens = rcau.maxInitialTokens; + agreement.pendingTerms.maxOngoingTokensPerSecond = rcau.maxOngoingTokensPerSecond; + agreement.pendingTerms.minSecondsPerCollection = rcau.minSecondsPerCollection; + agreement.pendingTerms.maxSecondsPerCollection = rcau.maxSecondsPerCollection; + agreement.pendingTerms.conditions = rcau.conditions; + agreement.pendingTerms.hash = keccak256(abi.encode("rcau", rcau.agreementId, rcau.nonce, rcau.endsAt)); + agreement.updateNonce = rcau.nonce; + } + + function cancel(bytes16 agreementId, bytes32 termsHash, uint16 /* options */) external { + AgreementStorage storage agreement = _agreements[agreementId]; + if (termsHash == agreement.pendingTerms.hash && agreement.pendingTerms.endsAt > 0) { + delete agreement.pendingTerms; + } else { + _cancelInternal(agreementId, BY_PAYER); + } + } + + function _cancelInternal(bytes16 agreementId, uint16 byFlag) private { + AgreementStorage storage agreement = _agreements[agreementId]; + agreement.collectableUntil = uint64(block.timestamp); + bool isAccepted = (agreement.state & ACCEPTED) != 0; + if (!isAccepted) { + agreement.state = REGISTERED | NOTICE_GIVEN | SETTLED; + } else if (byFlag == BY_PROVIDER) { + agreement.state = REGISTERED | ACCEPTED | NOTICE_GIVEN | SETTLED | BY_PROVIDER; + } else { + agreement.state = REGISTERED | ACCEPTED | NOTICE_GIVEN | byFlag; + } + delete agreement.pendingTerms; } function generateAgreementId( @@ -56,42 +244,4 @@ contract MockRecurringCollector { ) external pure returns (bytes16) { return bytes16(keccak256(abi.encode(payer, dataService, serviceProvider, deadline, nonce))); } - - function hashRCA(IRecurringCollector.RecurringCollectionAgreement calldata rca) external pure returns (bytes32) { - return - keccak256( - abi.encode( - rca.deadline, - rca.endsAt, - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.maxInitialTokens, - rca.maxOngoingTokensPerSecond, - rca.minSecondsPerCollection, - rca.maxSecondsPerCollection, - rca.nonce, - rca.metadata - ) - ); - } - - function hashRCAU( - IRecurringCollector.RecurringCollectionAgreementUpdate calldata rcau - ) external pure returns (bytes32) { - return - keccak256( - abi.encode( - rcau.agreementId, - rcau.deadline, - rcau.endsAt, - rcau.maxInitialTokens, - rcau.maxOngoingTokensPerSecond, - rcau.minSecondsPerCollection, - rcau.maxSecondsPerCollection, - rcau.nonce, - rcau.metadata - ) - ); - } } diff --git a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol index 7b01ac08e..51cf7bc62 100644 --- a/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol +++ b/packages/issuance/test/unit/agreement-manager/multiCollector.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -41,8 +41,8 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, minSecondsPerCollection: 60, maxSecondsPerCollection: maxSecondsPerCollection, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); agreementId = collector.generateAgreementId( @@ -68,7 +68,7 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage ); token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca1)); uint256 maxClaim1 = 1 ether * 3600 + 100 ether; @@ -82,7 +82,7 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage 2 ); vm.prank(operator); - agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + agreementManager.offerAgreement(IRecurringCollector(address(collector2)), OFFER_TYPE_NEW, abi.encode(rca2)); uint256 maxClaim2 = 2 ether * 7200 + 200 ether; @@ -103,11 +103,11 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage ); token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca1)); - // collector2 cannot call beforeCollection on collector1's agreement + // collector2 calling beforeCollection on collector1's agreement is a no-op + // (agreement doesn't exist under collector2's namespace) vm.prank(address(collector2)); - vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); agreementManager.beforeCollection(agreementId1, 100 ether); // collector1 can call beforeCollection on its own agreement @@ -127,11 +127,11 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage ); token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca1)); - // collector2 cannot call afterCollection on collector1's agreement + // collector2 calling afterCollection on collector1's agreement is a no-op + // (agreement doesn't exist under collector2's namespace) vm.prank(address(collector2)); - vm.expectRevert(IRecurringAgreementManagement.OnlyAgreementCollector.selector); agreementManager.afterCollection(agreementId1, 100 ether); } @@ -165,10 +165,9 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage token.mint(address(agreementManager), totalMaxClaim + (totalMaxClaim * 272) / 256 + 1); vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); - + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca1)); vm.prank(operator); - agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + agreementManager.offerAgreement(IRecurringCollector(address(collector2)), OFFER_TYPE_NEW, abi.encode(rca2)); // Escrow accounts are separate per (collector, provider) (uint256 collector1Balance, , ) = paymentsEscrow.escrowAccounts( @@ -185,7 +184,7 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage assertEq(collector2Balance, maxClaim2); } - function test_MultiCollector_RevokeOnlyAffectsOwnCollectorEscrow() public { + function test_MultiCollector_CancelOnlyAffectsOwnCollectorEscrow() public { // Offer via both collectors (IRecurringCollector.RecurringCollectionAgreement memory rca1, bytes16 agreementId1) = _makeRCAForCollector( recurringCollector, @@ -197,7 +196,7 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage ); token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - agreementManager.offerAgreement(rca1, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca1)); (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector( collector2, @@ -208,13 +207,12 @@ contract RecurringAgreementManagerMultiCollectorTest is RecurringAgreementManage 2 ); vm.prank(operator); - agreementManager.offerAgreement(rca2, IRecurringCollector(address(collector2))); + agreementManager.offerAgreement(IRecurringCollector(address(collector2)), OFFER_TYPE_NEW, abi.encode(rca2)); uint256 maxClaim2 = 2 ether * 7200 + 200 ether; - // Revoke collector1's agreement - vm.prank(operator); - agreementManager.revokeOffer(agreementId1); + // Cancel collector1's agreement + _cancelAgreement(agreementId1); // Collector1 escrow cleared, collector2 unaffected assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); diff --git a/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol index 0a07ecef1..4f958fdc9 100644 --- a/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol +++ b/packages/issuance/test/unit/agreement-manager/multiIndexer.t.sol @@ -1,10 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerSharedTest { @@ -79,9 +83,9 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer3), maxClaim3); // Each has exactly 1 agreement - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); - assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); - assertEq(agreementManager.getProviderAgreementCount(indexer3), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer3), 1); // Each has independent escrow balance (uint256 indexerBalance, , ) = paymentsEscrow.escrowAccounts( @@ -106,7 +110,7 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS // -- Isolation: revoke one indexer doesn't affect others -- - function test_MultiIndexer_RevokeIsolation() public { + function test_MultiIndexer_CancelIsolation() public { IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCAForIndexer( indexer, 100 ether, @@ -127,17 +131,16 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS uint256 maxClaim2 = 2 ether * 7200 + 200 ether; - // Revoke indexer1's agreement - vm.prank(operator); - agreementManager.revokeOffer(id1); + // Cancel indexer1's agreement + _cancelAgreement(id1); // Indexer1 cleared assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); // Indexer2 unaffected assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); - assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 1); } // -- Isolation: reconcile one indexer doesn't affect others -- @@ -165,7 +168,7 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS // SP cancels indexer1, reconcile it _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Indexer1 cleared assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); @@ -201,14 +204,17 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS _setAgreementCanceledBySP(id1, rca1); // Reconcile only indexer1 - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Indexer1 required escrow drops to 0 (CanceledBySP -> maxNextClaim=0) assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); // Indexer2 completely unaffected (still pre-offered estimate) assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); - assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id2), + maxClaim2 + ); } // -- Multiple agreements per indexer -- @@ -245,16 +251,16 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS uint256 maxClaim1b = 0.5 ether * 1800 + 50 ether; uint256 maxClaim2 = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getProviderAgreementCount(indexer), 2); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 2); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1a + maxClaim1b); - assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 1); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), maxClaim2); // Reconcile one of indexer's agreements _setAgreementCanceledBySP(id1a, rca1a); - agreementManager.reconcileAgreement(id1a); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1a); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim1b); // Indexer2 still unaffected @@ -286,21 +292,18 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS _setAgreementAccepted(id1, rca1, uint64(block.timestamp)); _setAgreementAccepted(id2, rca2, uint64(block.timestamp)); - // Cancel indexer1's agreement via operator - vm.prank(operator); - agreementManager.cancelAgreement(id1); + // Advance time so CanceledByPayer has a non-zero claim window + vm.warp(block.timestamp + 10); - // Indexer1's required escrow updated by cancelAgreement's inline reconcile - // (still has maxNextClaim from RC since it's CanceledByPayer not CanceledBySP) - // But the mock just calls SubgraphService — the RC state doesn't change automatically. - // The cancelAgreement reconciles against whatever the mock RC says. + // Cancel indexer1's agreement via operator — collector.cancel() sets CanceledByPayer + _cancelAgreement(id1); // Reconcile indexer2 independently - agreementManager.reconcileAgreement(id2); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); - // Both indexers tracked independently - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); - assertEq(agreementManager.getProviderAgreementCount(indexer2), 1); + // Both indexers tracked independently — id1 still has remaining claim window + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 1); } // -- Maintain isolation -- @@ -329,10 +332,10 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS // Reconcile indexer1's agreement _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Update escrow for indexer1 — should thaw excess - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Indexer1 escrow thawing (excess = maxClaim1, required = 0) IPaymentsEscrow.EscrowAccount memory acct1; @@ -351,8 +354,8 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS ); assertEq(indexer2Bal, maxClaim2); - // reconcileCollectorProvider on indexer2 is a no-op (balance == required, no excess) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + // reconcileProvider on indexer2 is a no-op (balance == required, no excess) + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); } // -- Full lifecycle across multiple indexers -- @@ -393,7 +396,7 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS vm.warp(collectionTime); // 4. Reconcile indexer1 — required should decrease (no more initial tokens) - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); assertTrue(agreementManager.getSumMaxNextClaim(_collector(), indexer) < maxClaim1); // Indexer2 unaffected @@ -401,15 +404,15 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS // 5. Cancel indexer2 by SP _setAgreementCanceledBySP(id2, rca2); - agreementManager.reconcileAgreement(id2); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer2), 0); // 6. Reconcile indexer2's agreement - agreementManager.reconcileAgreement(id2); - assertEq(agreementManager.getProviderAgreementCount(indexer2), 0); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer2), 0); // 7. Update escrow for indexer2 (thaw excess) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); IPaymentsEscrow.EscrowAccount memory acct2; (acct2.balance, acct2.tokensThawing, acct2.thawEndTimestamp) = paymentsEscrow.escrowAccounts( address(agreementManager), @@ -419,7 +422,7 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS assertEq(acct2.balance - acct2.tokensThawing, 0); // 8. Indexer1 still active - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); assertTrue(0 < agreementManager.getSumMaxNextClaim(_collector(), indexer)); } @@ -444,8 +447,14 @@ contract RecurringAgreementManagerMultiIndexerTest is RecurringAgreementManagerS bytes16 id1 = _offerAgreement(rca1); bytes16 id2 = _offerAgreement(rca2); - IRecurringAgreements.AgreementInfo memory info1 = agreementManager.getAgreementInfo(id1); - IRecurringAgreements.AgreementInfo memory info2 = agreementManager.getAgreementInfo(id2); + IRecurringAgreements.AgreementInfo memory info1 = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + id1 + ); + IRecurringAgreements.AgreementInfo memory info2 = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + id2 + ); assertEq(info1.provider, indexer); assertEq(info2.provider, indexer2); diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index 65b41ac88..e58a356cf 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -1,12 +1,24 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + REGISTERED, + ACCEPTED, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ @@ -33,21 +45,24 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh _offerAgreementUpdate(rcau); - // pendingMaxNextClaim = 2e18 * 7200 + 200e18 = 14600e18 - uint256 expectedPendingMaxClaim = 2 ether * 7200 + 200 ether; // Original maxNextClaim = 1e18 * 3600 + 100e18 = 3700e18 uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + // Pending = ongoing + initialExtra = 2e18 * 7200 + 200e18 = 14600e18 + uint256 pendingTotal = 2 ether * 7200 + 200 ether; - // Required escrow should include both + // Contribution = max(pending, current) since only one set of terms is active at a time assertEq( agreementManager.getSumMaxNextClaim(_collector(), indexer), - originalMaxClaim + expectedPendingMaxClaim + pendingTotal // max(3700, 14600) = 14600 + ); + // maxNextClaim now stores max(active, pending) + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + pendingTotal ); - // Original maxNextClaim unchanged - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); } - function test_OfferUpdate_AuthorizesHash() public { + function test_OfferUpdate_StoresOnCollector() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -69,8 +84,9 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh _offerAgreementUpdate(rcau); - // The update hash should be authorized for the IAgreementOwner callback - bytes32 updateHash = recurringCollector.hashRCAU(rcau); + // The update is stored on the collector (not via hash authorization) + bytes32 pendingHash = recurringCollector.getAgreementDetails(agreementId, 1).versionHash; + assertTrue(pendingHash != bytes32(0), "Pending update should be stored"); } function test_OfferUpdate_FundsEscrow() public { @@ -83,15 +99,17 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh ); uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - uint256 sumMaxNextClaim = originalMaxClaim + pendingMaxClaim; + // Pending = ongoing + initialExtra = 2e18 * 7200 + 200e18 = 14600e18 + uint256 pendingTotal = 2 ether * 7200 + 200 ether; + // Contribution = max(pendingTotal, originalMaxClaim) = 14600 (only one agreement) + uint256 sumMaxNextClaim = pendingTotal; // Fund generously so Full mode stays active through both offers. // After both offers, smnca = sumMaxNextClaim, deficit = sumMaxNextClaim. - // spare = balance - deficit. Full requires spare > smnca * 272 / 256. + // spare = balance - deficit. Full requires smnca * 272 / 256 < spare. token.mint(address(agreementManager), sumMaxNextClaim + (sumMaxNextClaim * 272) / 256 + 1); vm.prank(operator); - bytes16 agreementId = agreementManager.offerAgreement(rca, _collector()); + bytes16 agreementId = agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); // Offer update (should fund the deficit) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( @@ -104,7 +122,7 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); // Verify escrow was funded for both (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( @@ -127,7 +145,7 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - // First pending update + // First pending update (nonce=1) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( agreementId, 200 ether, @@ -139,10 +157,14 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh ); _offerAgreementUpdate(rcau1); - uint256 pendingMaxClaim1 = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim1); + // Pending1 = ongoing + initialExtra = 2e18 * 7200 + 200e18 = 14600e18 + // Contribution = max(14600, 3700) = 14600 + uint256 pendingTotal1 = 2 ether * 7200 + 200 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingTotal1); + + // Revoke first, then offer second (nonce=2, since collector incremented to 1) + _cancelPendingUpdate(agreementId); - // Second pending update (replaces first — same nonce since first was never accepted) IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 50 ether, @@ -150,13 +172,13 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 60, 1800, uint64(block.timestamp + 180 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - uint256 pendingMaxClaim2 = 0.5 ether * 1800 + 50 ether; - // Old pending removed, new pending added - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim2); + // Pending2 = ongoing + initialExtra = 0.5e18 * 1800 + 50e18 = 950e18 + // Contribution = max(950, 3700) = 3700 (original dominates) + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); } function test_OfferUpdate_EmitsEvent() public { @@ -179,13 +201,16 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + // Pending maxNextClaim = ongoing + initialExtra = 2e18 * 7200 + 200e18 = 14600e18 + uint256 pendingTotal = 2 ether * 7200 + 200 ether; + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; + // The callback fires during offer, emitting AgreementReconciled vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementUpdateOffered(agreementId, pendingMaxClaim, 1); + emit IRecurringAgreementManagement.AgreementReconciled(agreementId, originalMaxClaim, pendingTotal); vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } function test_OfferUpdate_Revert_WhenNotOffered() public { @@ -200,9 +225,11 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); - vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotOffered.selector, fakeId)); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0)) + ); vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } function test_OfferUpdate_Revert_WhenNotOperator() public { @@ -234,38 +261,7 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh ) ); vm.prank(nonOperator); - agreementManager.offerAgreementUpdate(rcau); - } - - function test_OfferUpdate_Revert_WhenPaused() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, - 1 ether, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( - agreementId, - 200 ether, - 2 ether, - 60, - 7200, - uint64(block.timestamp + 730 days), - 1 - ); - - // Grant pause role and pause - vm.startPrank(governor); - agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); - agreementManager.pause(); - vm.stopPrank(); - - vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); - vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } function test_OfferUpdate_Revert_WhenNonceWrong() public { @@ -289,11 +285,10 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 2 ); - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.InvalidUpdateNonce.selector, agreementId, 1, 2) - ); + // Nonce validation is now done by the collector + vm.expectRevert("MockRecurringCollector: invalid nonce"); vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } function test_OfferUpdate_Nonce2_AfterFirstAccepted() public { @@ -320,26 +315,25 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh _offerAgreementUpdate(rcau1); // Simulate: agreement accepted with update nonce=1 applied - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 200 ether, - maxOngoingTokensPerSecond: 2 ether, - minSecondsPerCollection: 60, - maxSecondsPerCollection: 7200, - updateNonce: 1, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) + IRecurringCollector.RecurringCollectionAgreement memory updatedRca = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days) ); + updatedRca.payer = rca.payer; + updatedRca.dataService = rca.dataService; + updatedRca.serviceProvider = rca.serviceProvider; + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + updatedRca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.updateNonce = 1; + recurringCollector.setAgreement(agreementId, data); // Offer second update (nonce=2) — should succeed because collector's updateNonce=1 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( @@ -353,9 +347,10 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh ); _offerAgreementUpdate(rcau2); - // Verify pending state was set - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2Check = rcau2; - bytes32 updateHash = recurringCollector.hashRCAU(rcau2Check); + // Verify pending state was set on the collector + bytes32 pendingHash = recurringCollector.getAgreementDetails(agreementId, 1).versionHash; + assertTrue(pendingHash != bytes32(0), "Second pending update should be stored"); + assertEq(recurringCollector.getUpdateNonce(agreementId), 2); } function test_OfferUpdate_Revert_Nonce1_AfterFirstAccepted() public { @@ -382,26 +377,25 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh _offerAgreementUpdate(rcau1); // Simulate: agreement accepted with update nonce=1 applied - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: uint64(block.timestamp + 730 days), - maxInitialTokens: 200 ether, - maxOngoingTokensPerSecond: 2 ether, - minSecondsPerCollection: 60, - maxSecondsPerCollection: 7200, - updateNonce: 1, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) + IRecurringCollector.RecurringCollectionAgreement memory updatedRca = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days) + ); + updatedRca.payer = rca.payer; + updatedRca.dataService = rca.dataService; + updatedRca.serviceProvider = rca.serviceProvider; + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + updatedRca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 ); + data.updateNonce = 1; + recurringCollector.setAgreement(agreementId, data); // Try nonce=1 again — should fail because collector already at updateNonce=1 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( @@ -414,11 +408,10 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.InvalidUpdateNonce.selector, agreementId, 2, 1) - ); + // Nonce validation is now done by the collector + vm.expectRevert("MockRecurringCollector: invalid nonce"); vm.prank(operator); - agreementManager.offerAgreementUpdate(rcau2); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau2)); } function test_OfferUpdate_ReconcilesDuringOffer() public { @@ -461,5 +454,36 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh assertTrue(postOfferMax < preOfferMax + pendingMaxClaim); } + function test_OfferUpdate_Succeeds_WhenPaused() public { + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + + bytes16 agreementId = _offerAgreement(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( + agreementId, + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 730 days), + 1 + ); + + // Grant pause role and pause + vm.startPrank(governor); + agreementManager.grantRole(keccak256("PAUSE_ROLE"), governor); + agreementManager.pause(); + vm.stopPrank(); + + // Role-gated functions should succeed even when paused + vm.prank(operator); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/test/unit/agreement-manager/reconcile.t.sol b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol index 46572be92..c33d7e92b 100644 --- a/packages/issuance/test/unit/agreement-manager/reconcile.t.sol +++ b/packages/issuance/test/unit/agreement-manager/reconcile.t.sol @@ -4,9 +4,15 @@ pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { + IAgreementCollector, + REGISTERED, + ACCEPTED +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; +import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ @@ -21,7 +27,10 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar ); bytes16 agreementId = _offerAgreement(rca); - uint256 initialMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 initialMaxClaim = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertEq(initialMaxClaim, 3700 ether); // Simulate: agreement accepted and first collection happened @@ -34,10 +43,16 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // remaining = endsAt - lastCollectionAt (large), capped by maxSecondsPerCollection = 3600 // New max = 1e18 * 3600 = 3600e18 vm.warp(lastCollectionAt); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 newMaxClaim = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertEq(newMaxClaim, 3600 ether); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 3600 ether); } @@ -51,17 +66,26 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar ); bytes16 agreementId = _offerAgreement(rca); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 3700 ether); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 3700 ether + ); // SP cancels - immediately non-collectable → reconcile deletes _setAgreementCanceledBySP(agreementId, rca); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertFalse(exists); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_ReconcileAgreement_CanceledByPayer_WindowOpen() public { @@ -78,16 +102,22 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // Payer cancels 2 hours from now, never collected uint64 acceptedAt = startTime; - uint64 canceledAt = uint64(startTime + 2 hours); - _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, 0); + uint64 collectableUntil = uint64(startTime + 2 hours); + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, collectableUntil, 0); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - // Window = canceledAt - acceptedAt = 7200s, capped by maxSecondsPerCollection = 3600s + // Window = collectableUntil - acceptedAt = 7200s, capped by maxSecondsPerCollection = 3600s // maxClaim = 1e18 * 3600 + 100e18 (never collected, so includes initial) uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + expectedMaxClaim + ); } function test_ReconcileAgreement_CanceledByPayer_WindowExpired() public { @@ -104,17 +134,23 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // Payer cancels, and the collection already happened covering the full window uint64 acceptedAt = startTime; - uint64 canceledAt = uint64(startTime + 2 hours); - // lastCollectionAt == canceledAt means window is empty - _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, canceledAt, canceledAt); + uint64 collectableUntil = uint64(startTime + 2 hours); + // lastCollectionAt == collectableUntil means window is empty + _setAgreementCanceledByPayer(agreementId, rca, acceptedAt, collectableUntil, collectableUntil); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); - // collectionEnd = canceledAt, collectionStart = lastCollectionAt = canceledAt + // collectionEnd = collectableUntil, collectionStart = lastCollectionAt = collectableUntil // window is empty -> maxClaim = 0 → deleted assertFalse(exists); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_ReconcileAgreement_SkipsNotAccepted() public { @@ -126,15 +162,24 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar ); bytes16 agreementId = _offerAgreement(rca); - uint256 originalMaxClaim = agreementManager.getAgreementMaxNextClaim(agreementId); + uint256 originalMaxClaim = agreementManager.getAgreementMaxNextClaim( + IAgreementCollector(address(recurringCollector)), + agreementId + ); // Mock returns NotAccepted (default state in mock - zero struct) // reconcile should skip recalculation and preserve the original estimate - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + originalMaxClaim + ); } function test_ReconcileAgreement_EmitsEvent() public { @@ -153,9 +198,9 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar vm.expectEmit(address(agreementManager)); emit IRecurringAgreementManagement.AgreementReconciled(agreementId, 3700 ether, 0); vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementRemoved(agreementId, indexer); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); } function test_ReconcileAgreement_NoEmitWhenUnchanged() public { @@ -174,12 +219,12 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // maxClaim should remain 3700e18 (never collected, maxSecondsPerCollection < window) // No event should be emitted vm.recordLogs(); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); // Check no AgreementReconciled or AgreementRemoved events were emitted Vm.Log[] memory logs = vm.getRecordedLogs(); bytes32 reconciledTopic = keccak256("AgreementReconciled(bytes16,uint256,uint256)"); - bytes32 removedTopic = keccak256("AgreementRemoved(bytes16,address)"); + bytes32 removedTopic = keccak256("AgreementRemoved(bytes16)"); for (uint256 i = 0; i < logs.length; i++) { assertTrue(logs[i].topics[0] != reconciledTopic, "Unexpected AgreementReconciled event"); assertTrue(logs[i].topics[0] != removedTopic, "Unexpected AgreementRemoved event"); @@ -190,7 +235,7 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar bytes16 fakeId = bytes16(keccak256("fake")); // Returns false (not exists) when agreement not found (idempotent) - bool exists = agreementManager.reconcileAgreement(fakeId); + bool exists = agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), fakeId); assertFalse(exists); } @@ -210,13 +255,19 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar _setAgreementCollected(agreementId, rca, uint64(block.timestamp), endsAt); vm.warp(endsAt); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); // collectionEnd = endsAt, collectionStart = lastCollectionAt = endsAt // window empty -> maxClaim = 0 → deleted assertFalse(exists); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_ReconcileAgreement_ClearsPendingUpdate() public { @@ -242,38 +293,44 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); // Simulate: agreement accepted and update applied on-chain (updateNonce = 1) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rcau.endsAt, - maxInitialTokens: rcau.maxInitialTokens, - maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, - minSecondsPerCollection: rcau.minSecondsPerCollection, - maxSecondsPerCollection: rcau.maxSecondsPerCollection, - updateNonce: 1, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); - - bool exists = agreementManager.reconcileAgreement(agreementId); + IRecurringCollector.RecurringCollectionAgreement memory updatedRca = _makeRCA( + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection, + rcau.endsAt + ); + updatedRca.payer = rca.payer; + updatedRca.dataService = rca.dataService; + updatedRca.serviceProvider = rca.serviceProvider; + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + updatedRca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.updateNonce = 1; + recurringCollector.setAgreement(agreementId, data); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); // Pending should be cleared, maxNextClaim recalculated from new terms // newMaxClaim = 2e18 * 7200 + 200e18 = 14600e18 (never collected, maxSecondsPerCollection < window) uint256 newMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), newMaxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + newMaxClaim + ); // Required = only new maxClaim (pending cleared) assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), newMaxClaim); } @@ -301,18 +358,44 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; + // Full update max = 14600 + uint256 pendingMaxClaim = 14600 ether; // Simulate: agreement accepted but update NOT yet applied (updateNonce = 0) - _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - - bool exists = agreementManager.reconcileAgreement(agreementId); + // Must preserve pending terms on the collector (setAgreementAccepted would erase them) + MockRecurringCollector.AgreementStorage memory data = _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED, + uint64(block.timestamp), + 0, + 0 + ); + data.pendingTerms = MockRecurringCollector.MockTerms({ + deadline: 0, + endsAt: rcau.endsAt, + maxInitialTokens: rcau.maxInitialTokens, + maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, + minSecondsPerCollection: rcau.minSecondsPerCollection, + maxSecondsPerCollection: rcau.maxSecondsPerCollection, + conditions: 0, + hash: bytes32(0) + }); + recurringCollector.setAgreement(agreementId, data); + + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - // maxNextClaim recalculated from original terms (same value since never collected) - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), originalMaxClaim); - // Pending still present - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // maxNextClaim stores max(active, pending) + // max(3700, 14600) = 14600 (pending dominates, update not yet applied) + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + pendingMaxClaim + ); + // Sum also reflects the max + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); } // -- Tests merged from remove (cleanup behavior) -- @@ -330,9 +413,12 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // Set as accepted but never collected - still claimable _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_ReconcileAgreement_DeletesExpiredOffer() public { @@ -349,10 +435,13 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar vm.warp(block.timestamp + 2 hours); // Agreement not accepted + past deadline — should be deleted - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertFalse(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } @@ -367,9 +456,12 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); // Not accepted yet, before deadline - still potentially claimable - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_ReconcileAgreement_ReturnsTrue_WhenCanceledByPayer_WindowStillOpen() public { @@ -385,13 +477,16 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar bytes16 agreementId = _offerAgreement(rca); // Payer canceled but window is still open (not yet collected) - uint64 canceledAt = uint64(startTime + 2 hours); - _setAgreementCanceledByPayer(agreementId, rca, startTime, canceledAt, 0); + uint64 collectableUntil = uint64(startTime + 2 hours); + _setAgreementCanceledByPayer(agreementId, rca, startTime, collectableUntil, 0); - // Still claimable: window = canceledAt - acceptedAt = 7200s, capped at 3600s - bool exists = agreementManager.reconcileAgreement(agreementId); + // Still claimable: window = collectableUntil - acceptedAt = 7200s, capped at 3600s + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertTrue(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_ReconcileAgreement_ReducesRequiredEscrow_WithMultipleAgreements() public { @@ -422,15 +517,18 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // Cancel agreement 1 by SP and reconcile it (deletes) _setAgreementCanceledBySP(id1, rca1); - bool exists = agreementManager.reconcileAgreement(id1); + bool exists = agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); assertFalse(exists); // Only agreement 2's original maxClaim remains assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim2); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); // Agreement 2 still tracked - assertEq(agreementManager.getAgreementMaxNextClaim(id2), maxClaim2); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), id2), + maxClaim2 + ); } function test_ReconcileAgreement_Permissionless() public { @@ -449,10 +547,13 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar // Anyone can reconcile address anyone = makeAddr("anyone"); vm.prank(anyone); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertFalse(exists); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } function test_ReconcileAgreement_ClearsPendingUpdate_WhenCanceled() public { @@ -478,18 +579,22 @@ contract RecurringAgreementManagerReconcileTest is RecurringAgreementManagerShar _offerAgreementUpdate(rcau); uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); // SP cancels - immediately removable _setAgreementCanceledBySP(agreementId, rca); - bool exists = agreementManager.reconcileAgreement(agreementId); + bool exists = agreementManager.reconcileAgreement( + IAgreementCollector(address(recurringCollector)), + agreementId + ); assertFalse(exists); // Both original and pending should be cleared from sumMaxNextClaim assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/register.t.sol b/packages/issuance/test/unit/agreement-manager/register.t.sol index 9fd4869db..ecdbf2344 100644 --- a/packages/issuance/test/unit/agreement-manager/register.t.sol +++ b/packages/issuance/test/unit/agreement-manager/register.t.sol @@ -2,9 +2,12 @@ pragma solidity ^0.8.27; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; @@ -25,9 +28,12 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe // maxNextClaim = maxOngoingTokensPerSecond * maxSecondsPerCollection + maxInitialTokens // = 1e18 * 3600 + 100e18 = 3700e18 uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), expectedMaxClaim); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + expectedMaxClaim + ); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), expectedMaxClaim); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); } function test_Offer_FundsEscrow() public { @@ -46,7 +52,7 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe // Full requires smnca * (256 + 16) / 256 = expectedMaxClaim * 272 / 256 < spare token.mint(address(agreementManager), expectedMaxClaim + (expectedMaxClaim * 272) / 256 + 1); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); // Verify escrow was funded (uint256 escrowBalance, , ) = paymentsEscrow.escrowAccounts( @@ -72,7 +78,7 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe // Fund with less than needed token.mint(address(agreementManager), available); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); // Since available < required, Full degrades to OnDemand (deposit target = 0). // No proactive deposit; JIT beforeCollection is the safety net. @@ -106,14 +112,15 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe token.mint(address(agreementManager), expectedMaxClaim); + // The callback fires during offer, emitting AgreementReconciled vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementOffered(expectedId, indexer, expectedMaxClaim); + emit IRecurringAgreementManagement.AgreementReconciled(expectedId, 0, expectedMaxClaim); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } - function test_Offer_AuthorizesHash() public { + function test_Offer_StoresOnCollector() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -122,10 +129,13 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe uint64(block.timestamp + 365 days) ); - _offerAgreement(rca); + bytes16 agreementId = _offerAgreement(rca); - // The agreement hash should be authorized for the IAgreementOwner callback - bytes32 agreementHash = recurringCollector.hashRCA(rca); + // The offer is stored on the collector (not via hash authorization) + IAgreementCollector.AgreementDetails memory details = recurringCollector.getAgreementDetails(agreementId, 0); + assertEq(details.dataService, rca.dataService); + assertEq(details.payer, rca.payer); + assertEq(details.serviceProvider, rca.serviceProvider); } function test_Offer_MultipleAgreements_SameIndexer() public { @@ -151,7 +161,7 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe bytes16 id2 = _offerAgreement(rca2); assertTrue(id1 != id2); - assertEq(agreementManager.getProviderAgreementCount(indexer), 2); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 2); uint256 maxClaim1 = 1 ether * 3600 + 100 ether; uint256 maxClaim2 = 2 ether * 7200 + 200 ether; @@ -166,35 +176,11 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe 3600, uint64(block.timestamp + 365 days) ); - rca.payer = address(0xdead); // Wrong payer + rca.payer = address(0xdead); // Wrong payer — RAM rejects because details.payer != address(this) - vm.expectRevert( - abi.encodeWithSelector( - IRecurringAgreementManagement.PayerMustBeManager.selector, - address(0xdead), - address(agreementManager) - ) - ); - vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); - } - - function test_Offer_Revert_WhenAlreadyOffered() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( - 100 ether, - 1 ether, - 60, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.AgreementAlreadyOffered.selector, agreementId) - ); + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.PayerMismatch.selector, address(0xdead))); vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } function test_Offer_Revert_WhenNotOperator() public { @@ -215,7 +201,7 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe ) ); vm.prank(nonOperator); - agreementManager.offerAgreement(rca, _collector()); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } function test_Offer_Revert_WhenUnauthorizedCollector() public { @@ -233,10 +219,10 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedCollector.selector, fakeCollector) ); vm.prank(operator); - agreementManager.offerAgreement(rca, IRecurringCollector(fakeCollector)); + agreementManager.offerAgreement(IRecurringCollector(fakeCollector), OFFER_TYPE_NEW, abi.encode(rca)); } - function test_Offer_Revert_WhenPaused() public { + function test_Offer_Succeeds_WhenPaused() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( 100 ether, 1 ether, @@ -251,9 +237,10 @@ contract RecurringAgreementManagerOfferTest is RecurringAgreementManagerSharedTe agreementManager.pause(); vm.stopPrank(); - vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + // Role-gated functions should succeed even when paused vm.prank(operator); - agreementManager.offerAgreement(rca, _collector()); + bytes16 agreementId = agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + assertTrue(agreementId != bytes16(0)); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol index 04e10a231..4028768cd 100644 --- a/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/revokeAgreementUpdate.t.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.27; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; -contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreementManagerSharedTest { +contract RecurringAgreementManagerCancelPendingUpdateTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ - function test_RevokeAgreementUpdate_ClearsPendingState() public { + function test_CancelPendingUpdate_ClearsPendingState() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -21,7 +21,6 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ); bytes16 agreementId = _offerAgreement(rca); - uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; // Offer a pending update IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( @@ -35,28 +34,19 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); - - // Revoke the pending update - vm.prank(operator); - bool revoked = agreementManager.revokeAgreementUpdate(agreementId); - assertTrue(revoked); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); - // Pending state should be fully cleared - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.pendingUpdateMaxNextClaim, 0, "pending escrow should be zero"); - assertEq(info.pendingUpdateNonce, 0, "pending nonce should be zero"); - assertEq(info.pendingUpdateHash, bytes32(0), "pending hash should be zero"); + // Cancel pending update clears pending terms on the collector and reconciles + _cancelPendingUpdate(agreementId); - // sumMaxNextClaim should only include the base claim + // sumMaxNextClaim drops to active-only (3700) since pending was cleared + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim); - - // The update hash should no longer be authorized - bytes32 updateHash = recurringCollector.hashRCAU(rcau); } - function test_RevokeAgreementUpdate_EmitsEvent() public { + function test_CancelPendingUpdate_EmitsEvent() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -77,83 +67,24 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ); _offerAgreementUpdate(rcau); - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - - vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.AgreementUpdateRevoked(agreementId, pendingMaxClaim, 1); - - vm.prank(operator); - agreementManager.revokeAgreementUpdate(agreementId); - } - - function test_RevokeAgreementUpdate_ReturnsFalse_WhenNoPending() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, - 1 ether, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); + // Read pending terms hash from the collector + bytes32 pendingHash = recurringCollector.getAgreementDetails(agreementId, 1).versionHash; - // No pending update — should return false - vm.prank(operator); - bool revoked = agreementManager.revokeAgreementUpdate(agreementId); - assertFalse(revoked); - } + // Before cancel: maxNextClaim = max(active=3700, pending=14600) = 14600 + // After cancel: pending deleted, maxNextClaim = active-only = 3700 + uint256 oldMaxClaim = agreementManager + .getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId) + .maxNextClaim; + uint256 activeOnlyClaim = 1 ether * 3600 + 100 ether; - function test_RevokeAgreementUpdate_ReturnsFalse_WhenAlreadyApplied() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, - 1 ether, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - - // Offer update - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRCAU( - agreementId, - 200 ether, - 2 ether, - 60, - 7200, - uint64(block.timestamp + 730 days), - 1 - ); - _offerAgreementUpdate(rcau); - - // Simulate: accepted with update already applied (updateNonce=1) - recurringCollector.setAgreement( - agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rcau.endsAt, - maxInitialTokens: rcau.maxInitialTokens, - maxOngoingTokensPerSecond: rcau.maxOngoingTokensPerSecond, - minSecondsPerCollection: rcau.minSecondsPerCollection, - maxSecondsPerCollection: rcau.maxSecondsPerCollection, - updateNonce: 1, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) - ); + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementReconciled(agreementId, oldMaxClaim, activeOnlyClaim); - // Reconcile inside revokeAgreementUpdate detects the update was applied - // and clears it — returns false (nothing left to revoke) vm.prank(operator); - bool revoked = agreementManager.revokeAgreementUpdate(agreementId); - assertFalse(revoked); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, pendingHash, 0); } - function test_RevokeAgreementUpdate_CanOfferNewUpdateAfterRevoke() public { + function test_CancelPendingUpdate_CanOfferNewUpdateAfterCancel() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -162,6 +93,7 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ); bytes16 agreementId = _offerAgreement(rca); + uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; // Offer update nonce=1 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRCAU( @@ -175,12 +107,10 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ); _offerAgreementUpdate(rcau1); - // Revoke it - vm.prank(operator); - agreementManager.revokeAgreementUpdate(agreementId); + // Cancel pending update on collector, then offer a new update + _cancelPendingUpdate(agreementId); - // Offer a new update with the same nonce (1) — should succeed since the - // collector's updateNonce is still 0 and the pending was cleared + // Offer a new update with the next valid nonce (2) — collector incremented to 1 IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRCAU( agreementId, 50 ether, @@ -188,26 +118,34 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen 60, 1800, uint64(block.timestamp + 180 days), - 1 + 2 ); _offerAgreementUpdate(rcau2); - // New pending should be set - uint256 newPendingMaxClaim = 0.5 ether * 1800 + 50 ether; - IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo(agreementId); - assertEq(info.pendingUpdateMaxNextClaim, newPendingMaxClaim); - assertEq(info.pendingUpdateNonce, 1); + // maxNextClaim = max(3700, 950) = 3700 (active dominates) + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertEq(info.maxNextClaim, originalMaxClaim); } - function test_RevokeAgreementUpdate_Revert_WhenNotOffered() public { + function test_CancelPendingUpdate_RejectsUnknown_WhenNotOffered() public { bytes16 fakeId = bytes16(keccak256("fake")); - vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.AgreementNotOffered.selector, fakeId)); + // cancelAgreement is a passthrough — unknown agreement triggers AgreementRejected via callback + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + fakeId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.UnknownAgreement + ); + vm.prank(operator); - agreementManager.revokeAgreementUpdate(fakeId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), fakeId, bytes32(0), 0); } - function test_RevokeAgreementUpdate_Revert_WhenNotOperator() public { + function test_CancelPendingUpdate_Revert_WhenNotOperator() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -226,10 +164,10 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen ) ); vm.prank(nonOperator); - agreementManager.revokeAgreementUpdate(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, bytes32(0), 0); } - function test_RevokeAgreementUpdate_Revert_WhenPaused() public { + function test_CancelPendingUpdate_Succeeds_WhenPaused() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -251,9 +189,9 @@ contract RecurringAgreementManagerRevokeAgreementUpdateTest is RecurringAgreemen agreementManager.pause(); vm.stopPrank(); - vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + // Role-gated functions should succeed even when paused vm.prank(operator); - agreementManager.revokeAgreementUpdate(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, bytes32(0), 0); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol index 732ef7f87..72828f084 100644 --- a/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol +++ b/packages/issuance/test/unit/agreement-manager/revokeOffer.t.sol @@ -1,17 +1,22 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; -import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; -contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSharedTest { +contract RecurringAgreementManagerCancelOfferedTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ - function test_RevokeOffer_ClearsAgreement() public { + function test_CancelOffered_ClearsAgreement() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -20,21 +25,23 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh ); bytes16 agreementId = _offerAgreement(rca); - assertEq(agreementManager.getProviderAgreementCount(indexer), 1); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 1); uint256 maxClaim = 1 ether * 3600 + 100 ether; assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), maxClaim); - vm.prank(operator); - bool gone = agreementManager.revokeOffer(agreementId); + bool gone = _cancelAgreement(agreementId); assertTrue(gone); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); - assertEq(agreementManager.getAgreementMaxNextClaim(agreementId), 0); + assertEq( + agreementManager.getAgreementMaxNextClaim(IAgreementCollector(address(recurringCollector)), agreementId), + 0 + ); } - function test_RevokeOffer_InvalidatesHash() public { + function test_CancelOffered_FullyRemovesTracking() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -44,16 +51,18 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh bytes16 agreementId = _offerAgreement(rca); - // Hash is authorized before revoke - bytes32 rcaHash = recurringCollector.hashRCA(rca); - - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + _cancelAgreement(agreementId); - // Hash should be rejected after revoke (agreement no longer exists) + // Agreement info should be zeroed out after cancel + IRecurringAgreements.AgreementInfo memory info = agreementManager.getAgreementInfo( + IAgreementCollector(address(recurringCollector)), + agreementId + ); + assertEq(info.provider, address(0)); + assertEq(info.maxNextClaim, 0); } - function test_RevokeOffer_ClearsPendingUpdate() public { + function test_CancelOffered_ClearsPendingUpdate() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -76,17 +85,17 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh _offerAgreementUpdate(rcau); uint256 originalMaxClaim = 1 ether * 3600 + 100 ether; - uint256 pendingMaxClaim = 2 ether * 7200 + 200 ether; - assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), originalMaxClaim + pendingMaxClaim); + // max(current, pending) = max(3700, 14600) = 14600 + uint256 pendingMaxClaim = 14600 ether; + assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), pendingMaxClaim); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + _cancelAgreement(agreementId); // Both original and pending should be cleared assertEq(agreementManager.getSumMaxNextClaim(_collector(), indexer), 0); } - function test_RevokeOffer_EmitsEvent() public { + function test_CancelOffered_EmitsEvent() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -97,40 +106,27 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh bytes16 agreementId = _offerAgreement(rca); vm.expectEmit(address(agreementManager)); - emit IRecurringAgreementManagement.OfferRevoked(agreementId, indexer); + emit IRecurringAgreementManagement.AgreementRemoved(agreementId); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); + _cancelAgreement(agreementId); } - function test_RevokeOffer_Revert_WhenAlreadyAccepted() public { - (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( - 100 ether, - 1 ether, - 3600, - uint64(block.timestamp + 365 days) - ); - - bytes16 agreementId = _offerAgreement(rca); - - // Simulate acceptance in RC - _setAgreementAccepted(agreementId, rca, uint64(block.timestamp)); + function test_CancelOffered_RejectsUnknown_WhenNotOffered() public { + bytes16 fakeId = bytes16(keccak256("fake")); - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.AgreementAlreadyAccepted.selector, agreementId) + // cancelAgreement is a passthrough — unknown agreement triggers AgreementRejected via callback + vm.expectEmit(address(agreementManager)); + emit IRecurringAgreementManagement.AgreementRejected( + fakeId, + address(recurringCollector), + IRecurringAgreementManagement.AgreementRejectionReason.UnknownAgreement ); - vm.prank(operator); - agreementManager.revokeOffer(agreementId); - } - function test_RevokeOffer_ReturnsTrue_WhenNotOffered() public { - bytes16 fakeId = bytes16(keccak256("fake")); vm.prank(operator); - bool gone = agreementManager.revokeOffer(fakeId); - assertTrue(gone); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), fakeId, bytes32(0), 0); } - function test_RevokeOffer_Revert_WhenNotOperator() public { + function test_CancelOffered_Revert_WhenNotOperator() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -141,6 +137,7 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh bytes16 agreementId = _offerAgreement(rca); address nonOperator = makeAddr("nonOperator"); + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; vm.expectRevert( abi.encodeWithSelector( IAccessControl.AccessControlUnauthorizedAccount.selector, @@ -149,10 +146,10 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh ) ); vm.prank(nonOperator); - agreementManager.revokeOffer(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } - function test_RevokeOffer_Revert_WhenPaused() public { + function test_CancelOffered_Succeeds_WhenPaused() public { (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, 1 ether, @@ -167,9 +164,10 @@ contract RecurringAgreementManagerRevokeOfferTest is RecurringAgreementManagerSh agreementManager.pause(); vm.stopPrank(); - vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); + // Role-gated functions should succeed even when paused + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; vm.prank(operator); - agreementManager.revokeOffer(agreementId); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/shared.t.sol b/packages/issuance/test/unit/agreement-manager/shared.t.sol index 2514306d8..2daee568b 100644 --- a/packages/issuance/test/unit/agreement-manager/shared.t.sol +++ b/packages/issuance/test/unit/agreement-manager/shared.t.sol @@ -1,19 +1,39 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { Test } from "forge-std/Test.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PAYER, + BY_PROVIDER, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManager } from "../../../contracts/agreement/RecurringAgreementManager.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementHelper } from "../../../contracts/agreement/RecurringAgreementHelper.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockGraphToken } from "./mocks/MockGraphToken.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockPaymentsEscrow } from "./mocks/MockPaymentsEscrow.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; -import { MockSubgraphService } from "./mocks/MockSubgraphService.sol"; /// @notice Shared test setup for RecurringAgreementManager tests. contract RecurringAgreementManagerSharedTest is Test { @@ -21,7 +41,6 @@ contract RecurringAgreementManagerSharedTest is Test { MockGraphToken internal token; MockPaymentsEscrow internal paymentsEscrow; MockRecurringCollector internal recurringCollector; - MockSubgraphService internal mockSubgraphService; RecurringAgreementManager internal agreementManager; RecurringAgreementHelper internal agreementHelper; @@ -47,8 +66,7 @@ contract RecurringAgreementManagerSharedTest is Test { token = new MockGraphToken(); paymentsEscrow = new MockPaymentsEscrow(address(token)); recurringCollector = new MockRecurringCollector(); - mockSubgraphService = new MockSubgraphService(); - dataService = address(mockSubgraphService); + dataService = makeAddr("subgraphService"); // Deploy RecurringAgreementManager behind proxy RecurringAgreementManager impl = new RecurringAgreementManager( @@ -83,7 +101,7 @@ contract RecurringAgreementManagerSharedTest is Test { vm.label(address(recurringCollector), "RecurringCollector"); vm.label(address(agreementManager), "RecurringAgreementManager"); vm.label(address(agreementHelper), "RecurringAgreementHelper"); - vm.label(address(mockSubgraphService), "SubgraphService"); + vm.label(dataService, "SubgraphService"); } // -- Helpers -- @@ -112,8 +130,8 @@ contract RecurringAgreementManagerSharedTest is Test { maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, - nonce: 1, conditions: 0, + nonce: 1, metadata: "" }); } @@ -141,7 +159,7 @@ contract RecurringAgreementManagerSharedTest is Test { token.mint(address(agreementManager), 1_000_000 ether); vm.prank(operator); - return agreementManager.offerAgreement(rca, _collector()); + return agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); } /// @notice Create a standard RCAU for an existing agreement @@ -163,18 +181,95 @@ contract RecurringAgreementManagerSharedTest is Test { maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, minSecondsPerCollection: minSecondsPerCollection, maxSecondsPerCollection: maxSecondsPerCollection, - nonce: nonce, conditions: 0, + nonce: nonce, metadata: "" }); } /// @notice Offer an RCAU via the operator - function _offerAgreementUpdate( - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau - ) internal returns (bytes16) { + function _offerAgreementUpdate(IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau) internal { + vm.prank(operator); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); + } + + /// @notice Cancel an agreement by reading the activeTerms hash from the collector + /// @return gone True if the agreement was removed (no longer tracked) + function _cancelAgreement(bytes16 agreementId) internal returns (bool gone) { + bytes32 activeHash = recurringCollector.getAgreementDetails(agreementId, 0).versionHash; + vm.prank(operator); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, activeHash, 0); + // cancelAgreement is void; the callback handles reconciliation. + // Check if the agreement was removed by looking at the provider field. + return + agreementManager.getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId).provider == + address(0); + } + + /// @notice Cancel a pending update by reading the pendingTerms hash from the collector + /// @return gone True if the agreement was removed (no longer tracked) + function _cancelPendingUpdate(bytes16 agreementId) internal returns (bool gone) { + bytes32 pendingHash = recurringCollector.getAgreementDetails(agreementId, 1).versionHash; vm.prank(operator); - return agreementManager.offerAgreementUpdate(rcau); + agreementManager.cancelAgreement(IAgreementCollector(address(recurringCollector)), agreementId, pendingHash, 0); + return + agreementManager.getAgreementInfo(IAgreementCollector(address(recurringCollector)), agreementId).provider == + address(0); + } + + /// @notice Build active terms from an RCA + function _activeTermsFromRCA( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal pure returns (MockRecurringCollector.MockTerms memory) { + return + MockRecurringCollector.MockTerms({ + deadline: 0, + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + hash: bytes32(0) + }); + } + + /// @notice Build empty pending terms + function _emptyTerms() internal pure returns (MockRecurringCollector.MockTerms memory) { + return + MockRecurringCollector.MockTerms({ + deadline: 0, + endsAt: 0, + maxInitialTokens: 0, + maxOngoingTokensPerSecond: 0, + minSecondsPerCollection: 0, + maxSecondsPerCollection: 0, + conditions: 0, + hash: bytes32(0) + }); + } + + /// @notice Build agreement data from common parameters + function _buildAgreementStorage( + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint16 state, + uint64 acceptedAt, + uint64 collectableUntil, + uint64 lastCollectionAt + ) internal pure returns (MockRecurringCollector.AgreementStorage memory) { + return + MockRecurringCollector.AgreementStorage({ + dataService: rca.dataService, + payer: rca.payer, + serviceProvider: rca.serviceProvider, + acceptedAt: acceptedAt, + lastCollectionAt: lastCollectionAt, + updateNonce: 0, + collectableUntil: collectableUntil, + state: state, + activeTerms: _activeTermsFromRCA(rca), + pendingTerms: _emptyTerms() + }); } /// @notice Set up a mock agreement in RecurringCollector as Accepted @@ -185,23 +280,7 @@ contract RecurringAgreementManagerSharedTest is Test { ) internal { recurringCollector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: acceptedAt, - lastCollectionAt: 0, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) + _buildAgreementStorage(rca, REGISTERED | ACCEPTED, acceptedAt, 0, 0) ); } @@ -212,23 +291,13 @@ contract RecurringAgreementManagerSharedTest is Test { ) internal { recurringCollector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: uint64(block.timestamp), - lastCollectionAt: 0, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: uint64(block.timestamp), - state: IRecurringCollector.AgreementState.CanceledByServiceProvider - }) + _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED | NOTICE_GIVEN | SETTLED | BY_PROVIDER, + uint64(block.timestamp), + uint64(block.timestamp), + 0 + ) ); } @@ -237,28 +306,18 @@ contract RecurringAgreementManagerSharedTest is Test { bytes16 agreementId, IRecurringCollector.RecurringCollectionAgreement memory rca, uint64 acceptedAt, - uint64 canceledAt, + uint64 collectableUntil, uint64 lastCollectionAt ) internal { recurringCollector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: acceptedAt, - lastCollectionAt: lastCollectionAt, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: canceledAt, - state: IRecurringCollector.AgreementState.CanceledByPayer - }) + _buildAgreementStorage( + rca, + REGISTERED | ACCEPTED | NOTICE_GIVEN | BY_PAYER, + acceptedAt, + collectableUntil, + lastCollectionAt + ) ); } @@ -271,23 +330,7 @@ contract RecurringAgreementManagerSharedTest is Test { ) internal { recurringCollector.setAgreement( agreementId, - IRecurringCollector.AgreementData({ - dataService: rca.dataService, - payer: rca.payer, - serviceProvider: rca.serviceProvider, - acceptedAt: acceptedAt, - lastCollectionAt: lastCollectionAt, - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - updateNonce: 0, - conditions: 0, - activeTermsHash: bytes32(0), - canceledAt: 0, - state: IRecurringCollector.AgreementState.Accepted - }) + _buildAgreementStorage(rca, REGISTERED | ACCEPTED, acceptedAt, 0, lastCollectionAt) ); } } diff --git a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol index e7c19d75a..9550f2ee0 100644 --- a/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol +++ b/packages/issuance/test/unit/agreement-manager/updateEscrow.t.sol @@ -1,10 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerSharedTest { @@ -35,9 +39,9 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // SP cancels — reconcileAgreement triggers escrow update, thawing the full balance _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); - assertEq(agreementManager.getProviderAgreementCount(indexer), 0); + assertEq(agreementManager.getAgreementCount(IAgreementCollector(address(recurringCollector)), indexer), 0); // balance should now be fully thawing IPaymentsEscrow.EscrowAccount memory account; @@ -62,18 +66,18 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // SP cancels and reconcile (triggers thaw) _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); // Fast forward past thawing period (1 day in mock) vm.warp(block.timestamp + 1 days + 1); uint256 agreementManagerBalanceBefore = token.balanceOf(address(agreementManager)); - // reconcileCollectorProvider: withdraw + // reconcileProvider: withdraw vm.expectEmit(address(agreementManager)); emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Tokens should be back in RecurringAgreementManager uint256 agreementManagerBalanceAfter = token.balanceOf(address(agreementManager)); @@ -82,7 +86,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS function test_UpdateEscrow_NoopWhenNoBalance() public { // No agreements, no balance — should succeed silently - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); } function test_UpdateEscrow_NoopWhenStillThawing() public { @@ -97,10 +101,10 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // SP cancels and reconcile (triggers thaw) _setAgreementCanceledBySP(agreementId, rca); - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); // Subsequent call before thaw complete: no-op (thaw in progress, amount is correct) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Balance should still be fully thawing IPaymentsEscrow.EscrowAccount memory account; @@ -113,10 +117,10 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS } function test_UpdateEscrow_Permissionless() public { - // Anyone can call reconcileCollectorProvider + // Anyone can call reconcileProvider address anyone = makeAddr("anyone"); vm.prank(anyone); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); } // ==================== Excess Thawing With Active Agreements ==================== @@ -141,7 +145,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS vm.warp(collectionTime); // Reconcile — should reduce required escrow - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); uint256 newRequired = agreementManager.getSumMaxNextClaim(_collector(), indexer); assertTrue(newRequired < maxClaim, "Required should have decreased"); @@ -190,8 +194,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // SP cancels agreement 1, reconcile to 0 (triggers thaw of excess) _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Verify excess is thawing IPaymentsEscrow.EscrowAccount memory accountBefore; @@ -247,8 +251,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // SP cancels, reconcile to 0 (triggers thaw of all excess) _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -304,8 +308,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Reconcile agreement 1 to create excess (triggers thaw) _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); IPaymentsEscrow.EscrowAccount memory accountBefore; (accountBefore.balance, accountBefore.tokensThawing, accountBefore.thawEndTimestamp) = paymentsEscrow @@ -328,8 +332,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS ) ); _setAgreementCanceledBySP(id2, rca2); - agreementManager.reconcileAgreement(id2); - agreementManager.reconcileAgreement(id2); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); IPaymentsEscrow.EscrowAccount memory accountAfter; (accountAfter.balance, accountAfter.tokensThawing, accountAfter.thawEndTimestamp) = paymentsEscrow @@ -346,7 +350,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Tests all (escrowBasis, accountState) combinations via a helper that: // 1. Sets escrowBasis (controls min/max) // 2. Overrides mock escrow to desired (balance, tokensThawing, thawReady) - // 3. Calls reconcileCollectorProvider + // 3. Calls reconcileProvider // 4. Asserts expected (balance, tokensThawing) // // Desired behavior (the 4 objectives): @@ -378,7 +382,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS ready ? block.timestamp - 1 : (0 < thawing ? block.timestamp + 1 days : 0) ); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory r; (r.balance, r.tokensThawing, r.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -416,7 +420,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS thawEndTimestamp ); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); IPaymentsEscrow.EscrowAccount memory r; (r.balance, r.tokensThawing, r.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -523,7 +527,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Reconcile indexer1's agreement (triggers thaw) _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); IPaymentsEscrow.EscrowAccount memory acct1; (acct1.balance, acct1.tokensThawing, acct1.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -541,8 +545,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS ); assertEq(indexer2Balance, maxClaim2); - // reconcileCollectorProvider on indexer2 should be a no-op (balance == required) - agreementManager.reconcileCollectorProvider(address(_collector()), indexer2); + // reconcileProvider on indexer2 should be a no-op (balance == required) + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer2); (uint256 indexer2BalanceAfter, , ) = paymentsEscrow.escrowAccounts( address(agreementManager), address(recurringCollector), @@ -572,8 +576,8 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS ); assertEq(balanceBefore, maxClaim); - // reconcileCollectorProvider should be a no-op - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + // reconcileProvider should be a no-op + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // Nothing changed (uint256 balanceAfter, , ) = paymentsEscrow.escrowAccounts( @@ -614,7 +618,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS vm.warp(collectionTime); // Reconcile — triggers _updateEscrow internally - agreementManager.reconcileAgreement(agreementId); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); // Excess should already be thawing IPaymentsEscrow.EscrowAccount memory account; @@ -660,7 +664,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Cancel and reconcile rca2 -> excess (950) thawed, rca1 remains _setAgreementCanceledBySP(id2, rca2); - agreementManager.reconcileAgreement(id2); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id2); IPaymentsEscrow.EscrowAccount memory account; (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -678,7 +682,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS vm.expectEmit(address(agreementManager)); emit IRecurringEscrowManagement.EscrowWithdrawn(indexer, address(recurringCollector), maxClaim2); - agreementManager.reconcileCollectorProvider(address(_collector()), indexer); + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); // After withdraw: only rca1's required amount remains, nothing thawing (account.balance, account.tokensThawing, account.thawEndTimestamp) = paymentsEscrow.escrowAccounts( @@ -707,7 +711,7 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS // Reconcile -> full thaw _setAgreementCanceledBySP(id1, rca1); - agreementManager.reconcileAgreement(id1); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), id1); // Verify: entire balance is thawing, liquid = 0 IPaymentsEscrow.EscrowAccount memory account; @@ -745,5 +749,123 @@ contract RecurringAgreementManagerUpdateEscrowTest is RecurringAgreementManagerS assertEq(account.tokensThawing, 0, "Nothing thawing after withdraw"); } + // ==================== ThawTarget edge cases (minThawFraction variants) ==================== + // + // The thawTarget calculation has two subtraction branches that need underflow guards: + // escrowed < min → account.balance - min (guarded by: min < account.balance) + // else → account.balance - max (guarded by: max < account.balance) + // + // When minThawFraction = 0 the thaw threshold (minThawAmount) is zero, so the + // `minThawAmount <= excess` gate passes even when excess = 0. Without the + // `max < account.balance` guard this would underflow. + + /// @dev Like _check but also sets minThawFraction before snapshotting. + function _checkFrac( + IRecurringEscrowManagement.EscrowBasis basis, + uint8 fraction, + uint256 bal, + uint256 thawing, + bool ready, + uint256 expBal, + uint256 expThaw, + string memory label + ) internal { + uint256 snap = vm.snapshot(); + + vm.startPrank(operator); + agreementManager.setEscrowBasis(basis); + agreementManager.setMinThawFraction(fraction); + vm.stopPrank(); + + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + bal, + thawing, + ready ? block.timestamp - 1 : (0 < thawing ? block.timestamp + 1 days : 0) + ); + + agreementManager.reconcileProvider(IAgreementCollector(address(_collector())), indexer); + + IPaymentsEscrow.EscrowAccount memory r; + (r.balance, r.tokensThawing, r.thawEndTimestamp) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(r.balance, expBal, string.concat(label, ": balance")); + assertEq(r.tokensThawing, expThaw, string.concat(label, ": thawing")); + + assertTrue(vm.revertTo(snap)); + } + + function test_UpdateEscrow_ThawTargetEdgeCases() public { + // S = sumMaxNextClaim, established by offering one agreement in Full mode. + (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( + 100 ether, + 1 ether, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + uint256 S = 1 ether * 3600 + 100 ether; // 3700 ether + + token.mint(address(paymentsEscrow), 10 * S); + vm.warp(100); + + IRecurringEscrowManagement.EscrowBasis O = IRecurringEscrowManagement.EscrowBasis.OnDemand; + IRecurringEscrowManagement.EscrowBasis F = IRecurringEscrowManagement.EscrowBasis.Full; + IRecurringEscrowManagement.EscrowBasis J = IRecurringEscrowManagement.EscrowBasis.JustInTime; + + // ── Key bug-fix case: balance < max, minThawFraction = 0 ──────────── + // Without the `max < account.balance` guard the thawTarget subtraction underflows. + // OnDemand: min = 0, max = S. balance = S/2, thawing = S/4. + // escrowed = S/4, excess = 0, minThawAmount = 0 → thawTarget = 0 (no excess). + // Stale thaw is cancelled; balance stays unchanged. + _checkFrac(O, 0, S / 2, S / 4, false, S / 2, 0, "E1:balcancel-thaw"); + + // Same but with zero thawing — already at ideal, no-op + _checkFrac(O, 0, S / 2, 0, false, S / 2, 0, "E2:balnoop"); + + // ── balance == max, minThawFraction = 0 ───────────────────────────── + // excess = 0, thawTarget = 0 (max == balance → no excess to thaw). + // Stale thaw cancelled; escrowed rises to full balance = max. + _checkFrac(O, 0, S, S / 4, false, S, 0, "E3:bal=max,frac=0->cancel-thaw"); + + // ── balance == 0, 0 < max, minThawFraction = 0 ───────────────────── + // escrowed = 0, excess = 0, guard: max(S) < balance(0) → false → keep 0. + _checkFrac(O, 0, 0, 0, false, 0, 0, "E4:bal=0,frac=0->noop"); + + // ── max < balance, minThawFraction = 0, excess above threshold ────── + // Normal thaw case: excess = S, 0 <= S && S < 2S → true → thawTarget = balance - max = S. + _checkFrac(O, 0, 2 * S, 0, false, 2 * S, S, "E5:excess,frac=0->thaw"); + + // ── JIT mode (max = 0): 0 < balance, minThawFraction = 0 ─────────── + // excess = escrowed, 0 <= escrowed && 0 < balance → thaw everything. + _checkFrac(J, 0, S, 0, false, S, S, "E6:jit,frac=0->thaw-all"); + + // ── Full mode: balance < min, minThawFraction = 0 ────────────────── + // Tests the min-branch underflow guard: min(S) < balance(S/2) → false → thawTarget = 0. + // Then _withdrawAndRebalance deposits to reach min. + _checkFrac(F, 0, S / 2, 0, false, S, 0, "E7:full,baldeposit"); + + // ── Default minThawFraction (16): excess below thaw threshold ─────── + // balance slightly above max, but excess < minThawAmount → no thaw. + // minThawAmount = S * 16 / 256 = S/16. excess = 1 wei < S/16 → skip. + _checkFrac(O, 16, S + 1, 0, false, S + 1, 0, "E8:below-threshold,frac=16->noop"); + + // ── Default minThawFraction (16): excess above thaw threshold ─────── + // excess = S, minThawAmount = S/16, S/16 <= S → thaw. + _checkFrac(O, 16, 2 * S, 0, false, 2 * S, S, "E9:above-threshold,frac=16->thaw"); + + // ── Thaw threshold must NOT block deficit adjustments ─────────────── + // Full mode: balance = 2*S, tokensThawing = 3*S/2 → escrowed = S/2 < min = S. + // thawTarget = balance - min = S (cancel half the thaw to reach min). + // excess = 0, 0 < minThawAmount = S/16 → threshold would block, + // but the escrowed < min exemption ensures we still act. + _checkFrac(F, 16, 2 * S, (3 * S) / 2, false, 2 * S, S, "E10:deficit-ignores-threshold"); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/test/unit/common/enumerableSetUtil.t.sol b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol index 96be9ab15..668f1e797 100644 --- a/packages/issuance/test/unit/common/enumerableSetUtil.t.sol +++ b/packages/issuance/test/unit/common/enumerableSetUtil.t.sol @@ -115,7 +115,6 @@ contract EnumerableSetUtilTest is Test { assertEq(result.length, 0); } - // forge-lint: disable(unsafe-typecast) function test_GetPageBytes16_ReturnsAllElements() public { bytes32 b1 = bytes32(bytes16(hex"00010002000300040005000600070008")); bytes32 b2 = bytes32(bytes16(hex"000a000b000c000d000e000f00100011")); @@ -189,7 +188,5 @@ contract EnumerableSetUtilTest is Test { assertEq(result.length, 0); } - // forge-lint: enable(unsafe-typecast) - /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/testing/test/harness/RealStackHarness.t.sol b/packages/testing/test/harness/RealStackHarness.t.sol index 37c4977c3..db99ace6c 100644 --- a/packages/testing/test/harness/RealStackHarness.t.sol +++ b/packages/testing/test/harness/RealStackHarness.t.sol @@ -16,6 +16,10 @@ import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken. // Interfaces import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; @@ -175,6 +179,7 @@ abstract contract RealStackHarness is Test { minSecondsPerCollection: 60, maxSecondsPerCollection: maxSecondsPerCollection, nonce: 1, + conditions: 0, metadata: "" }); } @@ -183,7 +188,7 @@ abstract contract RealStackHarness is Test { function _offerAgreement(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { token.mint(address(ram), 1_000_000 ether); vm.prank(operator); - return ram.offerAgreement(rca, IRecurringCollector(address(recurringCollector))); + return ram.offerAgreement(IAgreementCollector(address(recurringCollector)), OFFER_TYPE_NEW, abi.encode(rca)); } /// @notice Offer and accept an agreement via the unsigned path, returning the agreement ID From 9ec2c072e33660e06c5b6f6efeb877d6e68c99fe Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:38:47 +0000 Subject: [PATCH 073/157] feat(collector): make RecurringCollector upgradeable Convert RecurringCollector to TransparentUpgradeableProxy pattern with ERC-7201 namespaced storage. Authorizable storage also converted to ERC-7201 for proxy compatibility. --- .gitignore | 5 +- .../collectors/RecurringCollector.sol | 64 +++- .../contracts/utilities/Authorizable.sol | 74 +++-- .../configs/migrate.arbitrumOne.json5 | 5 + .../configs/migrate.arbitrumSepolia.json5 | 5 + .../ignition/configs/migrate.default.json5 | 5 + .../configs/migrate.integration.json5 | 5 + .../configs/migrate.localNetwork.json5 | 5 + .../ignition/configs/protocol.default.json5 | 5 + .../configs/protocol.localNetwork.json5 | 5 + .../modules/core/RecurringCollector.ts | 54 ++++ .../horizon/ignition/modules/core/core.ts | 8 +- packages/horizon/ignition/modules/deploy.ts | 6 + .../proxy/TransparentUpgradeableProxy.ts | 6 +- .../horizon/ignition/modules/proxy/utils.ts | 5 +- .../RecurringCollectorAuthorizableTest.t.sol | 27 +- .../RecurringCollectorHelper.t.sol | 8 +- .../payments/recurring-collector/shared.t.sol | 22 +- .../recurring-collector/upgradeScenario.t.sol | 150 +++++++++ .../escrowSnapStaleness.t.sol | 294 ++++++++++++++++++ .../unit/agreement-manager/offerUpdate.t.sol | 4 +- .../test/unit/SubgraphBaseTest.t.sol | 21 +- ...ClosingAllocationWithActiveAgreement.t.sol | 53 ++++ .../indexing-agreement/integration.t.sol | 64 +++- .../indexing-agreement/shared.t.sol | 12 +- 25 files changed, 836 insertions(+), 76 deletions(-) create mode 100644 packages/horizon/ignition/modules/core/RecurringCollector.ts create mode 100644 packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol create mode 100644 packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol create mode 100644 packages/subgraph-service/test/unit/subgraphService/governance/blockClosingAllocationWithActiveAgreement.t.sol diff --git a/.gitignore b/.gitignore index e81627835..ba06116ad 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ packages/*/.eslintcache dist/ dist-v5/ build/ +packages/contracts/**/types/ deployments/hardhat/ *.js.map *.d.ts.map @@ -58,7 +59,9 @@ bin/ .env .DS_Store .vscode -core +# Forge core dumps +**/core +!**/core/ # Coverage and other reports coverage/ diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 044d106da..9f87b2bb8 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.27; -import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; +import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; +import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; @@ -35,7 +36,7 @@ import { PPMMath } from "../../libraries/PPMMath.sol"; * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ -contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringCollector { +contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, Authorizable, IRecurringCollector { using PPMMath for uint256; /// @notice The minimum number of seconds that must be between two collections @@ -69,12 +70,28 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC bytes data; } - /// @notice Tracks agreements - mapping(bytes16 agreementId => AgreementData data) internal agreements; - /// @notice Stored RCA offers (pre-approval), keyed by agreement ID - mapping(bytes16 agreementId => StoredOffer offer) internal rcaOffers; - /// @notice Stored RCAU offers (pre-approval), keyed by agreement ID - mapping(bytes16 agreementId => StoredOffer offer) internal rcauOffers; + /// @custom:storage-location erc7201:graphprotocol.storage.RecurringCollector + struct RecurringCollectorStorage { + /// @notice List of pause guardians and their allowed status + mapping(address pauseGuardian => bool allowed) pauseGuardians; + /// @notice Tracks agreements + mapping(bytes16 agreementId => AgreementData data) agreements; + /// @notice Stored RCA offers (pre-approval), keyed by agreement ID + mapping(bytes16 agreementId => StoredOffer offer) rcaOffers; + /// @notice Stored RCAU offers (pre-approval), keyed by agreement ID + mapping(bytes16 agreementId => StoredOffer offer) rcauOffers; + } + + /// @dev keccak256(abi.encode(uint256(keccak256("graphprotocol.storage.RecurringCollector")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant RECURRING_COLLECTOR_STORAGE_LOCATION = + 0x436d179d846767cf46c6cda3ec5a404bcbe1b4351ce320082402e5e9ab4d6600; + + function _getStorage() private pure returns (RecurringCollectorStorage storage $) { + // solhint-disable-next-line no-inline-assembly + assembly { + $.slot := RECURRING_COLLECTOR_STORAGE_LOCATION + } + } /** * @notice Constructs a new instance of the RecurringCollector contract. @@ -84,11 +101,22 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @param revokeSignerThawingPeriod The duration (in seconds) in which a signer is thawing before they can be revoked. */ constructor( - string memory eip712Name, - string memory eip712Version, address controller, uint256 revokeSignerThawingPeriod - ) EIP712(eip712Name, eip712Version) GraphDirectory(controller) Authorizable(revokeSignerThawingPeriod) {} + ) GraphDirectory(controller) Authorizable(revokeSignerThawingPeriod) { + _disableInitializers(); + } + + /* solhint-disable gas-calldata-parameters */ + /** + * @notice Initializes the contract (proxy storage). + * @param eip712Name The name of the EIP712 domain. + * @param eip712Version The version of the EIP712 domain. + */ + function initialize(string memory eip712Name, string memory eip712Version) external initializer { + __EIP712_init(eip712Name, eip712Version); + } + /* solhint-enable gas-calldata-parameters */ /** * @inheritdoc IPaymentsCollector @@ -880,7 +908,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC else // Check stored offer hash instead of callback require( - (_offerType == OFFER_TYPE_NEW ? rcaOffers[_agreementId] : rcauOffers[_agreementId]).offerHash == _hash, + (_offerType == OFFER_TYPE_NEW ? $.rcaOffers[_agreementId] : $.rcauOffers[_agreementId]).offerHash == + _hash, RecurringCollectorInvalidSigner() ); } @@ -966,7 +995,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return The storage reference to the agreement data */ function _getAgreementStorage(bytes16 _agreementId) private view returns (AgreementData storage) { - return agreements[_agreementId]; + return _getStorage().agreements[_agreementId]; } /** @@ -975,7 +1004,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return The agreement data */ function _getAgreement(bytes16 _agreementId) private view returns (AgreementData memory) { - return agreements[_agreementId]; + return _getStorage().agreements[_agreementId]; } /** @@ -1080,7 +1109,8 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC * @return maxClaim The maximum tokens claimable under the requested scope */ function _getMaxNextClaimScoped(bytes16 agreementId, uint8 agreementScope) private view returns (uint256 maxClaim) { - AgreementData storage _a = agreements[agreementId]; + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage _a = $.agreements[agreementId]; uint256 maxActiveClaim = 0; uint256 maxPendingClaim = 0; @@ -1088,7 +1118,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC if (agreementScope & SCOPE_ACTIVE != 0) { if (_a.state == AgreementState.NotAccepted) { // Not yet accepted — check stored RCA offer - StoredOffer storage rcaOffer = rcaOffers[agreementId]; + StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; if (rcaOffer.offerHash != bytes32(0)) { RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); // Use block.timestamp as proxy for acceptedAt, deadline as expiry @@ -1108,7 +1138,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC } if (agreementScope & SCOPE_PENDING != 0) { - StoredOffer storage rcauOffer = rcauOffers[agreementId]; + StoredOffer storage rcauOffer = $.rcauOffers[agreementId]; if (rcauOffer.offerHash != bytes32(0)) { RecurringCollectionAgreementUpdate memory rcau = abi.decode( rcauOffer.data, diff --git a/packages/horizon/contracts/utilities/Authorizable.sol b/packages/horizon/contracts/utilities/Authorizable.sol index 58123c52b..24bdc32ac 100644 --- a/packages/horizon/contracts/utilities/Authorizable.sol +++ b/packages/horizon/contracts/utilities/Authorizable.sol @@ -16,6 +16,7 @@ import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/Mes * @notice A mechanism to authorize signers to sign messages on behalf of an authorizer. * Signers cannot be reused for different authorizers. * @dev Contract uses "authorizeSignerProof" as the domain for signer proofs. + * Uses ERC-7201 namespaced storage for upgrade safety. * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ @@ -23,8 +24,36 @@ abstract contract Authorizable is IAuthorizable { /// @notice The duration (in seconds) for which an authorization is thawing before it can be revoked uint256 public immutable REVOKE_AUTHORIZATION_THAWING_PERIOD; - /// @notice Authorization details for authorizer-signer pairs - mapping(address signer => Authorization authorization) public authorizations; + /// @custom:storage-location erc7201:graphprotocol.storage.Authorizable + struct AuthorizableStorage { + /// @notice Authorization details for authorizer-signer pairs + mapping(address signer => Authorization authorization) authorizations; + } + + /// @dev keccak256(abi.encode(uint256(keccak256("graphprotocol.storage.Authorizable")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant AUTHORIZABLE_STORAGE_LOCATION = + 0x09a0d55e31421ed256ea7c0d86e067159825634deef4770e03c18fe9dc08b900; + + function _getAuthorizableStorage() private pure returns (AuthorizableStorage storage $) { + // solhint-disable-next-line no-inline-assembly + assembly { + $.slot := AUTHORIZABLE_STORAGE_LOCATION + } + } + + /** + * @notice Authorization details for authorizer-signer pairs + * @param signer The address of the signer + * @return authorizer The address of the authorizer + * @return thawEndTimestamp The timestamp when the thawing period ends + * @return revoked Whether the authorization has been revoked + */ + function authorizations( + address signer + ) public view returns (address authorizer, uint256 thawEndTimestamp, bool revoked) { + Authorization storage auth = _getAuthorizableStorage().authorizations[signer]; + return (auth.authorizer, auth.thawEndTimestamp, auth.revoked); + } /** * @dev Revert if the caller has not authorized the signer @@ -45,45 +74,49 @@ abstract contract Authorizable is IAuthorizable { /// @inheritdoc IAuthorizable function authorizeSigner(address signer, uint256 proofDeadline, bytes calldata proof) external { + AuthorizableStorage storage $ = _getAuthorizableStorage(); require( - authorizations[signer].authorizer == address(0), + $.authorizations[signer].authorizer == address(0), AuthorizableSignerAlreadyAuthorized( - authorizations[signer].authorizer, + $.authorizations[signer].authorizer, signer, - authorizations[signer].revoked + $.authorizations[signer].revoked ) ); _verifyAuthorizationProof(proof, proofDeadline, signer); - authorizations[signer].authorizer = msg.sender; + $.authorizations[signer].authorizer = msg.sender; emit SignerAuthorized(msg.sender, signer); } /// @inheritdoc IAuthorizable function thawSigner(address signer) external onlyAuthorized(signer) { - authorizations[signer].thawEndTimestamp = block.timestamp + REVOKE_AUTHORIZATION_THAWING_PERIOD; - emit SignerThawing(msg.sender, signer, authorizations[signer].thawEndTimestamp); + AuthorizableStorage storage $ = _getAuthorizableStorage(); + $.authorizations[signer].thawEndTimestamp = block.timestamp + REVOKE_AUTHORIZATION_THAWING_PERIOD; + emit SignerThawing(msg.sender, signer, $.authorizations[signer].thawEndTimestamp); } /// @inheritdoc IAuthorizable function cancelThawSigner(address signer) external onlyAuthorized(signer) { - require(authorizations[signer].thawEndTimestamp > 0, AuthorizableSignerNotThawing(signer)); - uint256 thawEnd = authorizations[signer].thawEndTimestamp; - authorizations[signer].thawEndTimestamp = 0; + AuthorizableStorage storage $ = _getAuthorizableStorage(); + require($.authorizations[signer].thawEndTimestamp > 0, AuthorizableSignerNotThawing(signer)); + uint256 thawEnd = $.authorizations[signer].thawEndTimestamp; + $.authorizations[signer].thawEndTimestamp = 0; emit SignerThawCanceled(msg.sender, signer, thawEnd); } /// @inheritdoc IAuthorizable function revokeAuthorizedSigner(address signer) external onlyAuthorized(signer) { - uint256 thawEndTimestamp = authorizations[signer].thawEndTimestamp; + AuthorizableStorage storage $ = _getAuthorizableStorage(); + uint256 thawEndTimestamp = $.authorizations[signer].thawEndTimestamp; require(thawEndTimestamp > 0, AuthorizableSignerNotThawing(signer)); require(thawEndTimestamp <= block.timestamp, AuthorizableSignerStillThawing(block.timestamp, thawEndTimestamp)); - authorizations[signer].revoked = true; + $.authorizations[signer].revoked = true; emit SignerRevoked(msg.sender, signer); } /// @inheritdoc IAuthorizable function getThawEnd(address signer) external view returns (uint256) { - return authorizations[signer].thawEndTimestamp; + return _getAuthorizableStorage().authorizations[signer].thawEndTimestamp; } /// @inheritdoc IAuthorizable @@ -93,14 +126,15 @@ abstract contract Authorizable is IAuthorizable { /** * @notice Returns true if the signer is authorized by the authorizer - * @param _authorizer The address of the authorizer - * @param _signer The address of the signer + * @param authorizer The address of the authorizer + * @param signer The address of the signer * @return true if the signer is authorized by the authorizer, false otherwise */ - function _isAuthorized(address _authorizer, address _signer) internal view virtual returns (bool) { - return (_authorizer != address(0) && - authorizations[_signer].authorizer == _authorizer && - !authorizations[_signer].revoked); + function _isAuthorized(address authorizer, address signer) internal view virtual returns (bool) { + AuthorizableStorage storage $ = _getAuthorizableStorage(); + return (authorizer != address(0) && + $.authorizations[signer].authorizer == authorizer && + !$.authorizations[signer].revoked); } /** diff --git a/packages/horizon/ignition/configs/migrate.arbitrumOne.json5 b/packages/horizon/ignition/configs/migrate.arbitrumOne.json5 index 25b2e5a31..c28f8974c 100644 --- a/packages/horizon/ignition/configs/migrate.arbitrumOne.json5 +++ b/packages/horizon/ignition/configs/migrate.arbitrumOne.json5 @@ -45,5 +45,10 @@ "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 2592000 + }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 2592000 } } diff --git a/packages/horizon/ignition/configs/migrate.arbitrumSepolia.json5 b/packages/horizon/ignition/configs/migrate.arbitrumSepolia.json5 index 8060e2123..adb2eb86d 100644 --- a/packages/horizon/ignition/configs/migrate.arbitrumSepolia.json5 +++ b/packages/horizon/ignition/configs/migrate.arbitrumSepolia.json5 @@ -45,5 +45,10 @@ "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10800 + }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10800 } } diff --git a/packages/horizon/ignition/configs/migrate.default.json5 b/packages/horizon/ignition/configs/migrate.default.json5 index e662822fe..b770de7a3 100644 --- a/packages/horizon/ignition/configs/migrate.default.json5 +++ b/packages/horizon/ignition/configs/migrate.default.json5 @@ -45,5 +45,10 @@ "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 + }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10000 } } diff --git a/packages/horizon/ignition/configs/migrate.integration.json5 b/packages/horizon/ignition/configs/migrate.integration.json5 index 7cdc530b9..5b2f2155f 100644 --- a/packages/horizon/ignition/configs/migrate.integration.json5 +++ b/packages/horizon/ignition/configs/migrate.integration.json5 @@ -45,5 +45,10 @@ "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 + }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10000 } } diff --git a/packages/horizon/ignition/configs/migrate.localNetwork.json5 b/packages/horizon/ignition/configs/migrate.localNetwork.json5 index 357cffb49..8b052634d 100644 --- a/packages/horizon/ignition/configs/migrate.localNetwork.json5 +++ b/packages/horizon/ignition/configs/migrate.localNetwork.json5 @@ -45,5 +45,10 @@ "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 + }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10000 } } diff --git a/packages/horizon/ignition/configs/protocol.default.json5 b/packages/horizon/ignition/configs/protocol.default.json5 index f86ba80de..817758796 100644 --- a/packages/horizon/ignition/configs/protocol.default.json5 +++ b/packages/horizon/ignition/configs/protocol.default.json5 @@ -22,6 +22,11 @@ "eip712Version": "1", "revokeSignerThawingPeriod": 10000 }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10000 + }, "RewardsManager": { "issuancePerBlock": "114155251141552511415n" }, diff --git a/packages/horizon/ignition/configs/protocol.localNetwork.json5 b/packages/horizon/ignition/configs/protocol.localNetwork.json5 index 078286aa6..2d3c08b39 100644 --- a/packages/horizon/ignition/configs/protocol.localNetwork.json5 +++ b/packages/horizon/ignition/configs/protocol.localNetwork.json5 @@ -22,6 +22,11 @@ "eip712Version": "1", "revokeSignerThawingPeriod": 10000 }, + "RecurringCollector": { + "eip712Name": "RecurringCollector", + "eip712Version": "1", + "revokeSignerThawingPeriod": 10000 + }, "RewardsManager": { "issuancePerBlock": "114155251141552511415n" }, diff --git a/packages/horizon/ignition/modules/core/RecurringCollector.ts b/packages/horizon/ignition/modules/core/RecurringCollector.ts new file mode 100644 index 000000000..c1481aa4f --- /dev/null +++ b/packages/horizon/ignition/modules/core/RecurringCollector.ts @@ -0,0 +1,54 @@ +import { buildModule } from '@nomicfoundation/hardhat-ignition/modules' + +import RecurringCollectorArtifact from '../../../build/contracts/contracts/payments/collectors/RecurringCollector.sol/RecurringCollector.json' +import GraphPeripheryModule from '../periphery/periphery' +import { deployImplementation } from '../proxy/implementation' +import { + deployTransparentUpgradeableProxy, + upgradeTransparentUpgradeableProxy, +} from '../proxy/TransparentUpgradeableProxy' +import HorizonProxiesModule from './HorizonProxies' + +export default buildModule('RecurringCollector', (m) => { + const { Controller } = m.useModule(GraphPeripheryModule) + + const governor = m.getAccount(1) + const revokeSignerThawingPeriod = m.getParameter('revokeSignerThawingPeriod') + const eip712Name = m.getParameter('eip712Name') + const eip712Version = m.getParameter('eip712Version') + + // Deploy RecurringCollector proxy + const { Proxy: RecurringCollectorProxy, ProxyAdmin: RecurringCollectorProxyAdmin } = + deployTransparentUpgradeableProxy(m, { + name: 'RecurringCollector', + artifact: RecurringCollectorArtifact, + }) + + // Deploy RecurringCollector implementation + const RecurringCollectorImplementation = deployImplementation( + m, + { + name: 'RecurringCollector', + artifact: RecurringCollectorArtifact, + constructorArgs: [Controller, revokeSignerThawingPeriod], + }, + { after: [GraphPeripheryModule, HorizonProxiesModule] }, + ) + + // Upgrade proxy to implementation contract + const RecurringCollector = upgradeTransparentUpgradeableProxy( + m, + RecurringCollectorProxyAdmin, + RecurringCollectorProxy, + RecurringCollectorImplementation, + { + name: 'RecurringCollector', + artifact: RecurringCollectorArtifact, + initArgs: [eip712Name, eip712Version], + }, + ) + + m.call(RecurringCollectorProxyAdmin, 'transferOwnership', [governor], { after: [RecurringCollector] }) + + return { RecurringCollector, RecurringCollectorProxyAdmin, RecurringCollectorImplementation } +}) diff --git a/packages/horizon/ignition/modules/core/core.ts b/packages/horizon/ignition/modules/core/core.ts index c71ae232b..7644e8c76 100644 --- a/packages/horizon/ignition/modules/core/core.ts +++ b/packages/horizon/ignition/modules/core/core.ts @@ -4,12 +4,15 @@ import GraphPaymentsModule, { MigrateGraphPaymentsModule } from './GraphPayments import GraphTallyCollectorModule, { MigrateGraphTallyCollectorModule } from './GraphTallyCollector' import HorizonStakingModule, { MigrateHorizonStakingDeployerModule } from './HorizonStaking' import PaymentsEscrowModule, { MigratePaymentsEscrowModule } from './PaymentsEscrow' +import RecurringCollectorModule from './RecurringCollector' export default buildModule('GraphHorizon_Core', (m) => { const { HorizonStaking, HorizonStakingImplementation } = m.useModule(HorizonStakingModule) const { GraphPaymentsProxyAdmin, GraphPayments, GraphPaymentsImplementation } = m.useModule(GraphPaymentsModule) const { PaymentsEscrowProxyAdmin, PaymentsEscrow, PaymentsEscrowImplementation } = m.useModule(PaymentsEscrowModule) const { GraphTallyCollector } = m.useModule(GraphTallyCollectorModule) + const { RecurringCollectorProxyAdmin, RecurringCollector, RecurringCollectorImplementation } = + m.useModule(RecurringCollectorModule) return { HorizonStaking, @@ -21,10 +24,13 @@ export default buildModule('GraphHorizon_Core', (m) => { PaymentsEscrow, PaymentsEscrowImplementation, GraphTallyCollector, + RecurringCollectorProxyAdmin, + RecurringCollector, + RecurringCollectorImplementation, } }) -export const MigrateHorizonCoreModule = buildModule('GraphHorizon_Core', (m) => { +export const MigrateHorizonCoreModule = buildModule('MigrateGraphHorizon_Core', (m) => { const { HorizonStakingProxy: HorizonStaking, HorizonStakingImplementation } = m.useModule( MigrateHorizonStakingDeployerModule, ) diff --git a/packages/horizon/ignition/modules/deploy.ts b/packages/horizon/ignition/modules/deploy.ts index f2f5fecde..428f2e0c7 100644 --- a/packages/horizon/ignition/modules/deploy.ts +++ b/packages/horizon/ignition/modules/deploy.ts @@ -31,6 +31,9 @@ export default buildModule('GraphHorizon_Deploy', (m) => { PaymentsEscrow, PaymentsEscrowImplementation, GraphTallyCollector, + RecurringCollectorProxyAdmin, + RecurringCollector, + RecurringCollectorImplementation, } = m.useModule(GraphHorizonCoreModule) const governor = m.getAccount(1) @@ -74,5 +77,8 @@ export default buildModule('GraphHorizon_Deploy', (m) => { Transparent_Proxy_PaymentsEscrow: PaymentsEscrow, Implementation_PaymentsEscrow: PaymentsEscrowImplementation, GraphTallyCollector, + Transparent_ProxyAdmin_RecurringCollector: RecurringCollectorProxyAdmin, + Transparent_Proxy_RecurringCollector: RecurringCollector, + Implementation_RecurringCollector: RecurringCollectorImplementation, } }) diff --git a/packages/horizon/ignition/modules/proxy/TransparentUpgradeableProxy.ts b/packages/horizon/ignition/modules/proxy/TransparentUpgradeableProxy.ts index 35e2ec5a4..30df8b3e3 100644 --- a/packages/horizon/ignition/modules/proxy/TransparentUpgradeableProxy.ts +++ b/packages/horizon/ignition/modules/proxy/TransparentUpgradeableProxy.ts @@ -65,5 +65,9 @@ export function upgradeTransparentUpgradeableProxy( [proxy, implementation, m.encodeFunctionCall(implementation, 'initialize', metadata.initArgs)], options, ) - return loadProxyWithABI(m, proxy, metadata, { ...options, after: [upgradeCall] }) + return loadProxyWithABI(m, proxy, metadata, { + ...options, + id: `${metadata.name}_UpgradedProxyWithABI`, + after: [upgradeCall], + }) } diff --git a/packages/horizon/ignition/modules/proxy/utils.ts b/packages/horizon/ignition/modules/proxy/utils.ts index c6b7f4c2a..23ee71775 100644 --- a/packages/horizon/ignition/modules/proxy/utils.ts +++ b/packages/horizon/ignition/modules/proxy/utils.ts @@ -13,11 +13,12 @@ export function loadProxyWithABI( contract: ImplementationMetadata, options?: ContractOptions, ) { + const { id: customId, ...rest } = options ?? {} let proxyWithABI if (contract.artifact === undefined) { - proxyWithABI = m.contractAt(contract.name, proxy, options) + proxyWithABI = m.contractAt(customId ?? contract.name, proxy, rest) } else { - proxyWithABI = m.contractAt(`${contract.name}_ProxyWithABI`, contract.artifact, proxy, options) + proxyWithABI = m.contractAt(customId ?? `${contract.name}_ProxyWithABI`, contract.artifact, proxy, rest) } return proxyWithABI } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol index ed40d03ee..41f285e13 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorAuthorizableTest.t.sol @@ -3,17 +3,32 @@ pragma solidity ^0.8.27; import { IAuthorizable } from "@graphprotocol/interfaces/contracts/horizon/IAuthorizable.sol"; import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import { AuthorizableTest } from "../../../unit/utilities/Authorizable.t.sol"; import { InvalidControllerMock } from "../../mocks/InvalidControllerMock.t.sol"; contract RecurringCollectorAuthorizableTest is AuthorizableTest { + address internal _proxyAdmin; + function newAuthorizable(uint256 thawPeriod) public override returns (IAuthorizable) { - return - IAuthorizable( - address( - new RecurringCollector("RecurringCollector", "1", address(new InvalidControllerMock()), thawPeriod) - ) - ); + RecurringCollector implementation = new RecurringCollector(address(new InvalidControllerMock()), thawPeriod); + address proxyAdminOwner = makeAddr("proxyAdmin"); + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(implementation), + proxyAdminOwner, + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) + ); + // TransparentUpgradeableProxy deploys a ProxyAdmin contract — that's the address to exclude + _proxyAdmin = address(uint160(uint256(vm.load(address(proxy), ERC1967Utils.ADMIN_SLOT)))); + return IAuthorizable(address(proxy)); + } + + function assumeValidFuzzAddress(address addr) internal override { + super.assumeValidFuzzAddress(addr); + vm.assume(addr != _proxyAdmin); + // RC overrides _isAuthorized to treat address(this) (the proxy) as always authorized + vm.assume(addr != address(authorizable)); } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index 61d9e6764..5914b422d 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -8,11 +8,14 @@ import { Bounder } from "../../../unit/utils/Bounder.t.sol"; contract RecurringCollectorHelper is AuthorizableHelper, Bounder { RecurringCollector public collector; + address public proxyAdmin; constructor( - RecurringCollector collector_ + RecurringCollector collector_, + address proxyAdmin_ ) AuthorizableHelper(collector_, collector_.REVOKE_AUTHORIZATION_THAWING_PERIOD()) { collector = collector_; + proxyAdmin = proxyAdmin_; } function generateSignedRCA( @@ -105,6 +108,9 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { vm.assume(rca.payer != address(0)); vm.assume(rca.serviceProvider != address(0)); // Exclude ProxyAdmin address — TransparentProxy routes admin calls to ProxyAdmin, not implementation + vm.assume(rca.dataService != proxyAdmin); + vm.assume(rca.payer != proxyAdmin); + vm.assume(rca.serviceProvider != proxyAdmin); // Ensure we have a nonce if it's zero if (rca.nonce == 0) { diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 0c20ccf7f..3e88525e9 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -8,6 +8,8 @@ import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/ import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import { Bounder } from "../../../unit/utils/Bounder.t.sol"; import { PartialControllerMock } from "../../mocks/PartialControllerMock.t.sol"; @@ -36,20 +38,26 @@ contract RecurringCollectorSharedTest is Test, Bounder { PaymentsEscrowMock internal _paymentsEscrow; HorizonStakingMock internal _horizonStaking; RecurringCollectorHelper internal _recurringCollectorHelper; + address internal _proxyAdmin; - function setUp() public { + function setUp() public virtual { _paymentsEscrow = new PaymentsEscrowMock(); _horizonStaking = new HorizonStakingMock(); PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](2); entries[0] = PartialControllerMock.Entry({ name: "PaymentsEscrow", addr: address(_paymentsEscrow) }); entries[1] = PartialControllerMock.Entry({ name: "Staking", addr: address(_horizonStaking) }); - _recurringCollector = new RecurringCollector( - "RecurringCollector", - "1", - address(new PartialControllerMock(entries)), - 1 + address controller = address(new PartialControllerMock(entries)); + RecurringCollector implementation = new RecurringCollector(controller, 1); + address proxyAdminOwner = makeAddr("proxyAdminOwner"); + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(implementation), + proxyAdminOwner, + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) ); - _recurringCollectorHelper = new RecurringCollectorHelper(_recurringCollector); + _recurringCollector = RecurringCollector(address(proxy)); + // Store the actual ProxyAdmin contract address to exclude from fuzz inputs + _proxyAdmin = address(uint160(uint256(vm.load(address(proxy), ERC1967Utils.ADMIN_SLOT)))); + _recurringCollectorHelper = new RecurringCollectorHelper(_recurringCollector, _proxyAdmin); } function _sensibleAuthorizeAndAccept( diff --git a/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol b/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol new file mode 100644 index 000000000..f65fe9464 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Test } from "forge-std/Test.sol"; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { RecurringCollector } from "../../../../contracts/payments/collectors/RecurringCollector.sol"; +import { + ITransparentUpgradeableProxy, + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; +import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; + +import { PartialControllerMock } from "../../mocks/PartialControllerMock.t.sol"; +import { HorizonStakingMock } from "../../mocks/HorizonStakingMock.t.sol"; +import { PaymentsEscrowMock } from "./PaymentsEscrowMock.t.sol"; +import { RecurringCollectorHelper } from "./RecurringCollectorHelper.t.sol"; +import { Bounder } from "../../utils/Bounder.t.sol"; + +/// @notice Upgrade scenario tests for RecurringCollector (TransparentUpgradeableProxy). +contract RecurringCollectorUpgradeScenarioTest is Test, Bounder { + RecurringCollector internal _recurringCollector; + PaymentsEscrowMock internal _paymentsEscrow; + HorizonStakingMock internal _horizonStaking; + RecurringCollectorHelper internal _recurringCollectorHelper; + address internal _proxyAdminAddr; + address internal _proxyAdminOwner; + address internal _controller; + + function setUp() public { + _paymentsEscrow = new PaymentsEscrowMock(); + _horizonStaking = new HorizonStakingMock(); + PartialControllerMock.Entry[] memory entries = new PartialControllerMock.Entry[](2); + entries[0] = PartialControllerMock.Entry({ name: "PaymentsEscrow", addr: address(_paymentsEscrow) }); + entries[1] = PartialControllerMock.Entry({ name: "Staking", addr: address(_horizonStaking) }); + _controller = address(new PartialControllerMock(entries)); + + RecurringCollector implementation = new RecurringCollector(_controller, 1); + _proxyAdminOwner = makeAddr("proxyAdminOwner"); + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(implementation), + _proxyAdminOwner, + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) + ); + _recurringCollector = RecurringCollector(address(proxy)); + _proxyAdminAddr = address(uint160(uint256(vm.load(address(proxy), ERC1967Utils.ADMIN_SLOT)))); + _recurringCollectorHelper = new RecurringCollectorHelper(_recurringCollector, _proxyAdminAddr); + } + + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice Verify that initialize cannot be called twice + function test_Upgrade_InitializeRevertsOnSecondCall() public { + vm.expectRevert(); + _recurringCollector.initialize("RecurringCollector", "1"); + } + + /// @notice Deploy v1, create state (agreement + pause guardian), upgrade to v2, verify state persists + function test_Upgrade_StatePreservedAfterUpgrade() public { + // --- v1: create state --- + + // Set up a pause guardian + vm.prank(address(0)); // governor is address(0) in mock controller + _recurringCollector.setPauseGuardian(makeAddr("guardian"), true); + + // Accept an agreement via signed path + uint256 signerKey = boundKey(12345); + address payer = vm.addr(signerKey); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _recurringCollectorHelper.authorizeSignerWithChecks(payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + + _horizonStaking.setProvision( + rca.serviceProvider, + rca.dataService, + IHorizonStakingTypes.Provision({ + tokens: 1000 ether, + tokensThawing: 0, + sharesThawing: 0, + maxVerifierCut: 100000, + thawingPeriod: 604800, + createdAt: uint64(block.timestamp), + maxVerifierCutPending: 100000, + thawingPeriodPending: 604800, + lastParametersStagedAt: 0, + thawingNonce: 0 + }) + ); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, signature); + + // Capture v1 state + IRecurringCollector.AgreementData memory v1Agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(v1Agreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + assertTrue(_recurringCollector.pauseGuardians(makeAddr("guardian"))); + + // --- Upgrade to v2 (same implementation, simulates upgrade) --- + + RecurringCollector v2Implementation = new RecurringCollector(_controller, 1); + vm.prank(_proxyAdminOwner); + ProxyAdmin(_proxyAdminAddr).upgradeAndCall( + ITransparentUpgradeableProxy(address(_recurringCollector)), + address(v2Implementation), + "" + ); + + // --- Verify state persisted --- + + IRecurringCollector.AgreementData memory v2Agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(v2Agreement.state), uint8(IRecurringCollector.AgreementState.Accepted), "agreement state lost"); + assertEq(v2Agreement.payer, payer, "payer lost"); + assertEq(v2Agreement.serviceProvider, rca.serviceProvider, "serviceProvider lost"); + assertEq(v2Agreement.dataService, rca.dataService, "dataService lost"); + assertEq(v2Agreement.maxOngoingTokensPerSecond, rca.maxOngoingTokensPerSecond, "terms lost"); + assertTrue(_recurringCollector.pauseGuardians(makeAddr("guardian")), "pause guardian lost"); + } + + /// @notice Only the proxy admin owner can upgrade + function test_Upgrade_RevertWhen_NotProxyAdminOwner() public { + RecurringCollector v2Implementation = new RecurringCollector(_controller, 1); + + vm.prank(makeAddr("attacker")); + vm.expectRevert(); + ProxyAdmin(_proxyAdminAddr).upgradeAndCall( + ITransparentUpgradeableProxy(address(_recurringCollector)), + address(v2Implementation), + "" + ); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol b/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol new file mode 100644 index 000000000..65cc44245 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +/// @notice Tests for escrow snapshot staleness correction and threshold boundary behavior. +/// Covers gaps: +/// - Stale escrow snap self-correction via _setEscrowSnap (TRST-H-3) +/// - Threshold-based basis degradation boundary conditions (TRST-M-2, M-3) +/// - Deficit tracking accuracy after external escrow mutations +contract RecurringAgreementManagerEscrowSnapStalenessTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ══════════════════════════════════════════════════════════════════════ + // Stale snap self-correction + // ══════════════════════════════════════════════════════════════════════ + + /// @notice When external deposit changes escrow balance between reconciliations, + /// _setEscrowSnap corrects the snapshot and totalEscrowDeficit on next reconcile. + function test_EscrowSnap_SelfCorrectionAfterExternalDeposit() public { + // Create agreement requiring 3700 ether escrow + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + + // Verify initial state is correct (Full mode, fully funded) + assertEq(agreementManager.getTotalEscrowDeficit(), 0, "initial deficit should be 0"); + + // Externally remove some escrow balance (simulates external withdrawal or slash) + uint256 reduction = 1000 ether; + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + expectedMaxClaim - reduction, // reduced balance + 0, // no thawing + 0 // no thaw end + ); + + // Snap is now stale — deficit is understated. + // Reconcile should self-correct the snap. + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // After reconcile, deficit should reflect the shortfall (or be corrected via deposit) + // The reconcile calls _setEscrowSnap which corrects totalEscrowDeficit + uint256 deficitAfter = agreementManager.getTotalEscrowDeficit(); + (uint256 balAfter, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // In Full mode with sufficient RAM balance, it deposits to fill the gap + // If deposit succeeded, deficit should be 0 and balance should be expectedMaxClaim + if (balAfter >= expectedMaxClaim) { + assertEq(deficitAfter, 0, "deficit should be 0 after correction + deposit"); + } else { + // If insufficient RAM tokens, deficit reflects actual shortfall + assertEq(deficitAfter, expectedMaxClaim - balAfter, "deficit should reflect actual shortfall"); + } + } + + /// @notice When escrow balance increases externally (e.g., depositTo from a third party), + /// reconcile corrects the stale snap downward (reduced deficit). + function test_EscrowSnap_CorrectionOnExternalIncrease() public { + // Start with limited funding so we have a deficit + uint256 limitedFunding = 100 ether; + token.mint(address(agreementManager), limitedFunding); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 500 ether, + 10 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + // Don't use _offerAgreement since it mints 1M tokens + vm.prank(operator); + agreementManager.offerAgreement(_collector(), OFFER_TYPE_NEW, abi.encode(rca)); + + uint256 deficitBefore = agreementManager.getTotalEscrowDeficit(); + assertTrue(deficitBefore > 0, "should have deficit with limited funding"); + + // Externally add tokens to escrow (simulates third-party deposit) + (uint256 bal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 topUp = 5000 ether; + paymentsEscrow.setAccount(address(agreementManager), address(recurringCollector), indexer, bal + topUp, 0, 0); + + // Reconcile corrects the stale snap + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + uint256 deficitAfter = agreementManager.getTotalEscrowDeficit(); + assertTrue(deficitAfter < deficitBefore, "deficit should decrease after external top-up"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Threshold boundary conditions + // ══════════════════════════════════════════════════════════════════════ + + /// @notice OnDemand tier threshold: when spare is exactly at the boundary, + /// verify correct degradation behavior. + function test_ThresholdBoundary_OnDemandExactThreshold() public { + // Set OnDemand mode + vm.prank(operator); + agreementManager.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + + // Create agreement + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; // 3700 ether + + // After offer, reconcile to stable state + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // OnDemand threshold check: sumMaxNext * threshold / 256 < spare + // Default threshold = 128, so need: maxClaim * 128 / 256 < spare → maxClaim/2 < spare + // If spare > maxClaim/2, max = maxClaim; otherwise max = 0 (JIT degradation) + + // Set escrow to exactly the threshold boundary: balance = maxClaim + maxClaim * 128 / 256 + // where totalDeficit = 0 (single provider), so spare = balance + // At boundary: maxClaim * 128 / 256 == spare → NOT strictly less → should degrade to JIT + uint256 exactBoundary = maxClaim + (maxClaim * 128) / 256; + paymentsEscrow.setAccount(address(agreementManager), address(recurringCollector), indexer, exactBoundary, 0, 0); + + // Reconcile to observe behavior at exact threshold + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // At exact boundary the condition is NOT strictly-less, so it should NOT deposit + // This verifies the < vs <= boundary correctly + // The system should thaw excess since max = 0 at exact boundary + // Just above boundary should trigger OnDemand (max = maxClaim) + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + exactBoundary + 1, + 0, + 0 + ); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // After reconcile at just-above boundary, OnDemand mode means max = maxClaim + // No thaw needed since balance is within bounds + (uint256 balAbove, uint256 thawAbove, ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + // In OnDemand, min = 0, max = maxClaim. Balance >> maxClaim, so excess thaws + assertTrue(thawAbove > 0 || balAbove <= maxClaim, "above threshold: should thaw excess or be within max"); + } + + /// @notice Full basis margin boundary: verify the margin requirement works correctly + function test_ThresholdBoundary_FullBasisMargin() public { + // Full mode (default) + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + _offerAgreement(rca); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Full mode threshold: sumMaxNext * (256 + margin) / 256 < spare + // Default margin = 16, so need: maxClaim * 272 / 256 < spare + // Below this → OnDemand (min = 0, max = maxClaim) instead of Full (min = max = maxClaim) + + // Set balance to just below the Full threshold + uint256 fullThreshold = (maxClaim * 272) / 256; + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + fullThreshold, // exactly at boundary (not strictly less, so not Full) + 0, + 0 + ); + + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // At exact boundary, Full condition fails (not strictly less) → degrades to OnDemand + // In OnDemand, min = 0, so no deposit is forced + // The system should still work without reverting + assertTrue(true, "reconcile at Full boundary should not revert"); + + // Just above Full threshold — Full mode active (min = max = maxClaim) + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + fullThreshold + 1, + 0, + 0 + ); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + (uint256 balAbove, uint256 thawAbove, ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + // In Full mode, min = max = maxClaim. Excess above maxClaim should thaw. + assertTrue( + thawAbove > 0 || balAbove <= maxClaim + 1, + "Full mode above threshold: excess should thaw to maxClaim" + ); + } + + /// @notice Deficit tracking remains accurate across multiple provider operations + function test_EscrowSnap_DeficitAccuracyMultipleOps() public { + // Create two agreements for different providers + address indexer2 = makeAddr("indexer2"); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 200 ether, + 2 ether, + 60, + 7200, + uint64(block.timestamp + 365 days) + ); + rca2.serviceProvider = indexer2; + rca2.nonce = 2; + + _offerAgreement(rca1); + _offerAgreement(rca2); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + // Both fully funded — deficit should be 0 + assertEq(agreementManager.getTotalEscrowDeficit(), 0, "initial: no deficit"); + + // Externally reduce indexer1's escrow + paymentsEscrow.setAccount(address(agreementManager), address(recurringCollector), indexer, maxClaim1 / 2, 0, 0); + + // Reconcile indexer1 — deficit should reflect only indexer1's shortfall + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Check balance after reconcile (may have deposited to restore) + paymentsEscrow.escrowAccounts(address(agreementManager), address(recurringCollector), indexer); + + // Reconcile indexer2 — should not affect indexer1's deficit + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer2); + + // Total deficit should be consistent + uint256 finalDeficit = agreementManager.getTotalEscrowDeficit(); + (uint256 finalBal1, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + (uint256 finalBal2, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer2 + ); + + uint256 deficit1 = maxClaim1 < finalBal1 ? 0 : maxClaim1 - finalBal1; + uint256 deficit2 = maxClaim2 < finalBal2 ? 0 : maxClaim2 - finalBal2; + assertEq(finalDeficit, deficit1 + deficit2, "total deficit should be sum of per-provider deficits"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index e58a356cf..19d74c1b0 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -225,9 +225,7 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); - vm.expectRevert( - abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0)) - ); + vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0))); vm.prank(operator); agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } diff --git a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol index 31f18bbe0..0063bd232 100644 --- a/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol @@ -11,6 +11,8 @@ import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPa import { GraphTallyCollector } from "@graphprotocol/horizon/contracts/payments/collectors/GraphTallyCollector.sol"; import { RecurringCollector } from "@graphprotocol/horizon/contracts/payments/collectors/RecurringCollector.sol"; import { PaymentsEscrow } from "@graphprotocol/horizon/contracts/payments/PaymentsEscrow.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import { UnsafeUpgrades } from "@openzeppelin/foundry-upgrades/src/Upgrades.sol"; import { Constants } from "./utils/Constants.sol"; @@ -40,6 +42,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { IPaymentsEscrow escrow; GraphTallyCollector graphTallyCollector; RecurringCollector recurringCollector; + address recurringCollectorProxyAdmin; HorizonStaking private stakingBase; @@ -152,12 +155,18 @@ abstract contract SubgraphBaseTest is Utils, Constants { address(controller), REVOKE_SIGNER_THAWING_PERIOD ); - recurringCollector = new RecurringCollector( - "RecurringCollector", - "1", - address(controller), - REVOKE_SIGNER_THAWING_PERIOD - ); + { + RecurringCollector rcImpl = new RecurringCollector(address(controller), REVOKE_SIGNER_THAWING_PERIOD); + TransparentUpgradeableProxy rcProxy = new TransparentUpgradeableProxy( + address(rcImpl), + users.governor, + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) + ); + recurringCollector = RecurringCollector(address(rcProxy)); + recurringCollectorProxyAdmin = address( + uint160(uint256(vm.load(address(rcProxy), ERC1967Utils.ADMIN_SLOT))) + ); + } address subgraphServiceImplementation = address( new SubgraphService( diff --git a/packages/subgraph-service/test/unit/subgraphService/governance/blockClosingAllocationWithActiveAgreement.t.sol b/packages/subgraph-service/test/unit/subgraphService/governance/blockClosingAllocationWithActiveAgreement.t.sol new file mode 100644 index 000000000..3b4d67592 --- /dev/null +++ b/packages/subgraph-service/test/unit/subgraphService/governance/blockClosingAllocationWithActiveAgreement.t.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; +import { SubgraphServiceTest } from "../SubgraphService.t.sol"; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; + +contract SubgraphServiceGovernanceBlockClosingAllocationTest is SubgraphServiceTest { + /* + * TESTS + */ + + function test_Governance_SetBlockClosingAllocationWithActiveAgreement_Enable() public useGovernor { + // Default is false + assertFalse(subgraphService.getBlockClosingAllocationWithActiveAgreement()); + + vm.expectEmit(address(subgraphService)); + emit ISubgraphService.BlockClosingAllocationWithActiveAgreementSet(true); + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + + assertTrue(subgraphService.getBlockClosingAllocationWithActiveAgreement()); + } + + function test_Governance_SetBlockClosingAllocationWithActiveAgreement_Disable() public useGovernor { + // Enable first + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + assertTrue(subgraphService.getBlockClosingAllocationWithActiveAgreement()); + + vm.expectEmit(address(subgraphService)); + emit ISubgraphService.BlockClosingAllocationWithActiveAgreementSet(false); + subgraphService.setBlockClosingAllocationWithActiveAgreement(false); + + assertFalse(subgraphService.getBlockClosingAllocationWithActiveAgreement()); + } + + function test_Governance_SetBlockClosingAllocationWithActiveAgreement_NoopWhenSameValue() public useGovernor { + // Default is false — setting false again should be a noop (no event) + vm.recordLogs(); + subgraphService.setBlockClosingAllocationWithActiveAgreement(false); + assertEq(vm.getRecordedLogs().length, 0, "should not emit when value unchanged"); + + // Enable, then set true again — noop + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + vm.recordLogs(); + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + assertEq(vm.getRecordedLogs().length, 0, "should not emit when value unchanged (true)"); + } + + function test_Governance_SetBlockClosingAllocationWithActiveAgreement_RevertWhen_NotGovernor() public useIndexer { + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.indexer)); + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + } +} diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 6b2bbb6c5..609a91b46 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { SCOPE_ACTIVE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; @@ -44,7 +45,6 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); - rca.conditions = 0; bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); TestState memory beforeCollect = _getState(rca.payer, indexerState.addr); @@ -78,7 +78,6 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( ctx.ctxInternal.seed.rca ); - rca.conditions = 0; bytes16 acceptedAgreementId = _sharedSetup(ctx, rca, indexerState, expectedTokens); // Cancel the indexing agreement by the payer @@ -105,6 +104,67 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex _sharedAssert(beforeCollect, afterCollect, expectedTokens, tokensCollected); } + /// @notice Payer-initiated scoped cancel via RC.cancel(id, hash, SCOPE_ACTIVE). + /// Exercises the full reentrant callback chain: + /// payer → RC.cancel(id, hash, SCOPE_ACTIVE) + /// → SubgraphService.cancelIndexingAgreementByPayer(id) + /// → RC.cancel(id, CancelAgreementBy.Payer) + /// Verifies the callback is not blocked by reentrancy and the agreement ends up canceled. + function test_SubgraphService_ScopedCancelActive_ViaRecurringCollector_Integration(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Read activeTermsHash from the accepted agreement + IRecurringCollector.AgreementData memory agreementData = recurringCollector.getAgreement(agreementId); + bytes32 activeTermsHash = agreementData.activeTermsHash; + assertTrue(activeTermsHash != bytes32(0), "activeTermsHash should be set after accept"); + + // Expect the SubgraphService cancel event + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementCanceled( + acceptedRca.serviceProvider, + acceptedRca.payer, + agreementId, + acceptedRca.payer + ); + + // Expect the RC cancel event from the callback + vm.expectEmit(address(recurringCollector)); + emit IRecurringCollector.AgreementCanceled( + acceptedRca.dataService, + acceptedRca.payer, + acceptedRca.serviceProvider, + agreementId, + uint64(block.timestamp), + IRecurringCollector.CancelAgreementBy.Payer + ); + + // Payer calls RC's scoped cancel — triggers the full callback chain + resetPrank(acceptedRca.payer); + recurringCollector.cancel(agreementId, activeTermsHash, SCOPE_ACTIVE); + + // Verify agreement is canceled in RecurringCollector + IRecurringCollector.AgreementData memory afterCancel = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(afterCancel.state), + uint8(IRecurringCollector.AgreementState.CanceledByPayer), + "RC agreement should be CanceledByPayer" + ); + assertEq(afterCancel.canceledAt, uint64(block.timestamp), "canceledAt should be set"); + + // Verify agreement is canceled in SubgraphService + IIndexingAgreement.AgreementWrapper memory wrapper = subgraphService.getIndexingAgreement(agreementId); + assertEq( + uint8(wrapper.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByPayer), + "SubgraphService should reflect CanceledByPayer" + ); + } + function test_SubgraphService_CollectIndexingRewards_ResizesToZeroWhenOverAllocated_Integration( Seed memory seed ) public { diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index 8bfdca3dc..cd35f4aa0 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -74,7 +74,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun function setUp() public override { super.setUp(); - _recurringCollectorHelper = new RecurringCollectorHelper(recurringCollector); + _recurringCollectorHelper = new RecurringCollectorHelper(recurringCollector, recurringCollectorProxyAdmin); } /* @@ -184,7 +184,6 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun rca.metadata = abi.encode(metadata); rca = _recurringCollectorHelper.sensibleRCA(rca); - rca.conditions = 0; ( IRecurringCollector.RecurringCollectionAgreement memory signedRca, @@ -268,10 +267,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun rca.dataService = address(subgraphService); rca.metadata = abi.encode(metadata); - rca = _recurringCollectorHelper.sensibleRCA(rca); - // Zero conditions for EOA payers — CONDITION_ELIGIBILITY_CHECK requires ERC-165 - rca.conditions = 0; - return rca; + return _recurringCollectorHelper.sensibleRCA(rca); } function _generateAcceptableSignedRCAU( @@ -304,9 +300,7 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun _ctx.ctxInternal.seed.termsV1.tokensPerEntityPerSecond ) ); - rcau = _recurringCollectorHelper.sensibleRCAU(rcau); - rcau.conditions = 0; - return rcau; + return _recurringCollectorHelper.sensibleRCAU(rcau); } function _requireIndexer(Context storage _ctx, address _indexer) internal view returns (IndexerState memory) { From bbe01958866e5cae093edc4d184544b5c520e3d9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:38:47 +0000 Subject: [PATCH 074/157] feat(collector): add pause mechanism to RecurringCollector (TRST-L-3) Add pause guardian pattern gating accept, update, collect, cancel, and offer behind whenNotPaused. This provides a middle layer between the RAM-level pause (agreement lifecycle only) and the Controller-level nuclear pause (all escrow operations protocol-wide). The previous approveAgreement pause-bypass vector no longer exists since callback- based approval was replaced by stored-hash authorization (L-3). --- .../collectors/RecurringCollector.sol | 80 ++++- .../recurring-collector/coverageGaps.t.sol | 7 +- .../recurring-collector/hashRoundTrip.t.sol | 242 --------------- .../payments/recurring-collector/pause.t.sol | 281 ++++++++++++++++++ .../contracts/horizon/IRecurringCollector.sol | 46 +++ packages/issuance/audits/PR1301/TRST-L-3.md | 6 + 6 files changed, 408 insertions(+), 254 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/pause.t.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 9f87b2bb8..171e6e8f0 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; @@ -36,7 +37,14 @@ import { PPMMath } from "../../libraries/PPMMath.sol"; * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ -contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, Authorizable, IRecurringCollector { +contract RecurringCollector is + Initializable, + EIP712Upgradeable, + GraphDirectory, + Authorizable, + PausableUpgradeable, + IRecurringCollector +{ using PPMMath for uint256; /// @notice The minimum number of seconds that must be between two collections @@ -94,9 +102,29 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, } /** - * @notice Constructs a new instance of the RecurringCollector contract. - * @param eip712Name The name of the EIP712 domain. - * @param eip712Version The version of the EIP712 domain. + * @notice List of pause guardians and their allowed status + * @param pauseGuardian The address to check + * @return Whether the address is a pause guardian + */ + function pauseGuardians(address pauseGuardian) public view override returns (bool) { + return _getStorage().pauseGuardians[pauseGuardian]; + } + + /** + * @notice Checks if the caller is a pause guardian. + */ + modifier onlyPauseGuardian() { + _checkPauseGuardian(); + _; + } + + function _checkPauseGuardian() internal view { + require(_getStorage().pauseGuardians[msg.sender], RecurringCollectorNotPauseGuardian(msg.sender)); + } + + /** + * @notice Constructs a new instance of the RecurringCollector implementation contract. + * @dev Immutables are set here; proxy state is initialized via {initialize}. * @param controller The address of the Graph controller. * @param revokeSignerThawingPeriod The duration (in seconds) in which a signer is thawing before they can be revoked. */ @@ -115,16 +143,47 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, */ function initialize(string memory eip712Name, string memory eip712Version) external initializer { __EIP712_init(eip712Name, eip712Version); + __Pausable_init(); } /* solhint-enable gas-calldata-parameters */ + /// @inheritdoc IRecurringCollector + function pause() external override onlyPauseGuardian { + _pause(); + } + + /// @inheritdoc IRecurringCollector + function unpause() external override onlyPauseGuardian { + _unpause(); + } + + /** + * @notice Sets a pause guardian. + * @dev Only callable by the governor. + * @param _pauseGuardian The address of the pause guardian + * @param _allowed Whether the address should be a pause guardian + */ + function setPauseGuardian(address _pauseGuardian, bool _allowed) external { + require(msg.sender == _graphController().getGovernor(), RecurringCollectorNotGovernor(msg.sender)); + RecurringCollectorStorage storage $ = _getStorage(); + require( + $.pauseGuardians[_pauseGuardian] != _allowed, + RecurringCollectorPauseGuardianNoChange(_pauseGuardian, _allowed) + ); + $.pauseGuardians[_pauseGuardian] = _allowed; + emit PauseGuardianSet(_pauseGuardian, _allowed); + } + /** * @inheritdoc IPaymentsCollector * @notice Initiate a payment collection through the payments protocol. * See {IPaymentsCollector.collect}. * @dev Caller must be the data service the RCA was issued to. */ - function collect(IGraphPayments.PaymentTypes paymentType, bytes calldata data) external returns (uint256) { + function collect( + IGraphPayments.PaymentTypes paymentType, + bytes calldata data + ) external whenNotPaused returns (uint256) { try this.decodeCollectData(data) returns (CollectParams memory collectParams) { return _collect(paymentType, collectParams); } catch { @@ -137,7 +196,10 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, * @notice Accept a Recurring Collection Agreement. * @dev Caller must be the data service the RCA was issued to. */ - function accept(RecurringCollectionAgreement calldata rca, bytes calldata signature) external returns (bytes16) { + function accept( + RecurringCollectionAgreement calldata rca, + bytes calldata signature + ) external whenNotPaused returns (bytes16) { /* solhint-disable gas-strict-inequalities */ require( rca.deadline >= block.timestamp, @@ -230,7 +292,7 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, * See {IRecurringCollector.cancel}. * @dev Caller must be the data service for the agreement. */ - function cancel(bytes16 agreementId, CancelAgreementBy by) external { + function cancel(bytes16 agreementId, CancelAgreementBy by) external whenNotPaused { AgreementData storage agreement = _getAgreementStorage(agreementId); require( agreement.state == AgreementState.Accepted, @@ -264,7 +326,7 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, * @dev Note: Updated pricing terms apply immediately and will affect the next collection * for the entire period since lastCollectionAt. */ - function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external { + function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external whenNotPaused { AgreementData storage agreement = _requireValidUpdateTarget(rcau.agreementId); /* solhint-disable gas-strict-inequalities */ @@ -343,7 +405,7 @@ contract RecurringCollector is Initializable, EIP712Upgradeable, GraphDirectory, uint8 offerType, bytes calldata data, uint16 /* options */ - ) external returns (AgreementDetails memory details) { + ) external whenNotPaused returns (AgreementDetails memory details) { if (offerType == OFFER_TYPE_NEW) details = _offerNew(data); else if (offerType == OFFER_TYPE_UPDATE) details = _offerUpdate(data); else revert RecurringCollectorInvalidCollectData(data); diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index e360b44e4..bf85ce63b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -225,9 +225,10 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { vm.prank(rca.dataService); _recurringCollector.accept(rca, ""); - // After accept: offer is cleaned up - (, bytes memory postAcceptData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); - assertEq(postAcceptData.length, 0, "RCA offer should be cleaned up after accept"); + // After accept: offer persists + (uint8 postOfferType, bytes memory postAcceptData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(postOfferType, OFFER_TYPE_NEW, "Index 0 should still be OFFER_TYPE_NEW after accept"); + assertTrue(postAcceptData.length > 0, "RCA offer should persist after accept"); } function test_GetAgreementOfferAt_Index1_WithPending() public { diff --git a/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol index 955f274ed..7c5c73cbe 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol @@ -128,248 +128,6 @@ contract RecurringCollectorHashRoundTripTest is RecurringCollectorSharedTest { assertEq(reconstructed.endsAt, rca.endsAt, "endsAt mismatch"); } - /// @notice Stored RCA offer is cleaned up after acceptance - function test_HashRoundTrip_RCA_CleanedUpAfterAccept() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - bytes32 rcaHash = _recurringCollector.hashRCA(rca); - bytes16 agreementId = _offerAndAcceptRCA(rca); - - // activeTermsHash matches - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should match RCA hash"); - - // Stored offer should be cleaned up after accept - (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); - assertEq(offerData.length, 0, "RCA offer should be cleaned up after accept"); - } - - // ==================== RCAU round-trip (pending) ==================== - - function test_HashRoundTrip_RCAU_Pending() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - bytes16 agreementId = _offerAndAcceptRCA(rca); - - // Offer update (creates pending terms) - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); - bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); - vm.prank(address(_approver)); - _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - - // Verify pending update round-trips - _verifyOfferRoundTrip(agreementId, 1, rcauHash); - } - - // ==================== RCAU round-trip (accepted → cleaned up) ==================== - - function test_HashRoundTrip_RCAU_CleanedUpAfterUpdate() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - bytes16 agreementId = _offerAndAcceptRCA(rca); - - // Offer and accept update - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); - bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); - vm.prank(address(_approver)); - _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - - vm.prank(rca.dataService); - _recurringCollector.update(rcau, ""); - - // After update, activeTermsHash should be the RCAU hash - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash should be RCAU hash after update"); - - // Stored update offer should be cleaned up - (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); - assertEq(offerData.length, 0, "RCAU offer should be cleaned up after update"); - } - - // ==================== Cancel pending, active stays ==================== - - function test_HashRoundTrip_CancelPending_ActiveStays() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - bytes32 rcaHash = _recurringCollector.hashRCA(rca); - bytes16 agreementId = _offerAndAcceptRCA(rca); - - // Offer update - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); - bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); - vm.prank(address(_approver)); - _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - - // Cancel the pending update using its hash - vm.prank(address(_approver)); - _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); - - // RCA offer was already cleaned up at accept time - (, bytes memory rcaData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); - assertEq(rcaData.length, 0, "RCA offer should have been cleaned up at accept"); - - // Pending update should be gone - (, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); - assertEq(pendingData.length, 0, "Pending update should be cleared after cancel"); - - // activeTermsHash should still be the RCA hash - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.activeTermsHash, rcaHash, "activeTermsHash should still be RCA hash"); - } - - // ==================== Pre-acceptance overwrite ==================== - - function test_HashRoundTrip_RCAU_PreAcceptOverwrite() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - _setupValidProvision(rca.serviceProvider, rca.dataService); - - // Offer RCA - vm.prank(address(_approver)); - bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; - - // Overwrite with RCAU before acceptance - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeUpdate(rca, agreementId, 1); - bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); - vm.prank(address(_approver)); - _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - - // Update offer should be stored at index 1 and round-trip - _verifyOfferRoundTrip(agreementId, 1, rcauHash); - - // Original RCA offer should still be at index 0 - bytes32 rcaHash = _recurringCollector.hashRCA(rca); - _verifyOfferRoundTrip(agreementId, 0, rcaHash); - } - - /* solhint-enable graph/func-name-mixedcase */ -} - -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import { - OFFER_TYPE_NEW, - OFFER_TYPE_UPDATE, - SCOPE_PENDING, - IAgreementCollector -} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; -import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; - -import { RecurringCollectorSharedTest } from "./shared.t.sol"; -import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; - -/// @notice Round-trip hash verification: reconstruct offers from on-chain data and verify hashes. -/// Uses the offer() + accept() path so that offers are stored in rcaOffers/rcauOffers. -contract RecurringCollectorHashRoundTripTest is RecurringCollectorSharedTest { - /* solhint-disable graph/func-name-mixedcase */ - - MockAgreementOwner internal _approver; - - function setUp() public override { - super.setUp(); - _approver = new MockAgreementOwner(); - } - - // ==================== Helpers ==================== - - function _makeRCA() internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { - return - _recurringCollectorHelper.sensibleRCA( - IRecurringCollector.RecurringCollectionAgreement({ - deadline: uint64(block.timestamp + 1 hours), - endsAt: uint64(block.timestamp + 365 days), - payer: address(_approver), - dataService: makeAddr("ds"), - serviceProvider: makeAddr("sp"), - maxInitialTokens: 100 ether, - maxOngoingTokensPerSecond: 1 ether, - minSecondsPerCollection: 600, - maxSecondsPerCollection: 3600, - conditions: 0, - nonce: 1, - metadata: "" - }) - ); - } - - function _offerRCA(IRecurringCollector.RecurringCollectionAgreement memory rca) internal returns (bytes16) { - _setupValidProvision(rca.serviceProvider, rca.dataService); - vm.prank(address(_approver)); - return _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; - } - - function _offerAndAcceptRCA( - IRecurringCollector.RecurringCollectionAgreement memory rca - ) internal returns (bytes16) { - bytes16 agreementId = _offerRCA(rca); - vm.prank(rca.dataService); - _recurringCollector.accept(rca, ""); - return agreementId; - } - - function _makeUpdate( - IRecurringCollector.RecurringCollectionAgreement memory rca, - bytes16 agreementId, - uint32 nonce - ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { - return - IRecurringCollector.RecurringCollectionAgreementUpdate({ - agreementId: agreementId, - deadline: uint64(block.timestamp + 30 days), - endsAt: rca.endsAt, - maxInitialTokens: rca.maxInitialTokens, - maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, - minSecondsPerCollection: rca.minSecondsPerCollection, - maxSecondsPerCollection: rca.maxSecondsPerCollection, - conditions: rca.conditions, - nonce: nonce, - metadata: rca.metadata - }); - } - - /// @notice Verify that getAgreementOfferAt round-trips: decode and rehash matches expected hash - function _verifyOfferRoundTrip(bytes16 agreementId, uint256 index, bytes32 expectedHash) internal view { - (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, index); - require(offerData.length > 0, "Offer data should not be empty"); - - bytes32 reconstructedHash; - if (offerType == OFFER_TYPE_NEW) { - IRecurringCollector.RecurringCollectionAgreement memory rca = abi.decode( - offerData, - (IRecurringCollector.RecurringCollectionAgreement) - ); - reconstructedHash = _recurringCollector.hashRCA(rca); - } else { - IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = abi.decode( - offerData, - (IRecurringCollector.RecurringCollectionAgreementUpdate) - ); - reconstructedHash = _recurringCollector.hashRCAU(rcau); - } - - assertEq(reconstructedHash, expectedHash, "Reconstructed hash must match expected hash"); - } - - // ==================== RCA round-trip (pending, before accept) ==================== - - /// @notice Stored RCA offer round-trips before acceptance - function test_HashRoundTrip_RCA_Pending() public { - IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); - bytes32 rcaHash = _recurringCollector.hashRCA(rca); - bytes16 agreementId = _offerRCA(rca); - - // Verify stored offer round-trips before acceptance - _verifyOfferRoundTrip(agreementId, 0, rcaHash); - - // Verify reconstructed RCA fields match original - (, bytes memory offerData) = _recurringCollector.getAgreementOfferAt(agreementId, 0); - IRecurringCollector.RecurringCollectionAgreement memory reconstructed = abi.decode( - offerData, - (IRecurringCollector.RecurringCollectionAgreement) - ); - assertEq(reconstructed.payer, rca.payer, "payer mismatch"); - assertEq(reconstructed.dataService, rca.dataService, "dataService mismatch"); - assertEq(reconstructed.serviceProvider, rca.serviceProvider, "serviceProvider mismatch"); - assertEq(reconstructed.nonce, rca.nonce, "nonce mismatch"); - assertEq(reconstructed.endsAt, rca.endsAt, "endsAt mismatch"); - } - /// @notice Stored RCA offer persists after acceptance function test_HashRoundTrip_RCA_PersistsAfterAccept() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA(); diff --git a/packages/horizon/test/unit/payments/recurring-collector/pause.t.sol b/packages/horizon/test/unit/payments/recurring-collector/pause.t.sol new file mode 100644 index 000000000..65e9ed3a8 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/pause.t.sol @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Pausable } from "@openzeppelin/contracts/utils/Pausable.sol"; + +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Tests for the pause mechanism in RecurringCollector. +contract RecurringCollectorPauseTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + address internal guardian = makeAddr("guardian"); + + // Governor is address(0) in the mock controller + function _governor() internal pure returns (address) { + return address(0); + } + + function _setGuardian(address who, bool allowed) internal { + vm.prank(_governor()); + _recurringCollector.setPauseGuardian(who, allowed); + } + + function _pause() internal { + vm.prank(guardian); + _recurringCollector.pause(); + } + + // ==================== setPauseGuardian ==================== + + function test_SetPauseGuardian_OK() public { + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.PauseGuardianSet(guardian, true); + _setGuardian(guardian, true); + assertTrue(_recurringCollector.pauseGuardians(guardian)); + } + + function test_SetPauseGuardian_Remove() public { + _setGuardian(guardian, true); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.PauseGuardianSet(guardian, false); + _setGuardian(guardian, false); + assertFalse(_recurringCollector.pauseGuardians(guardian)); + } + + function test_SetPauseGuardian_Revert_WhenNotGovernor() public { + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorNotGovernor.selector, address(this)) + ); + _recurringCollector.setPauseGuardian(guardian, true); + } + + function test_SetPauseGuardian_Revert_WhenNoChange() public { + // guardian is not set, trying to set false (no change) + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorPauseGuardianNoChange.selector, + guardian, + false + ) + ); + vm.prank(_governor()); + _recurringCollector.setPauseGuardian(guardian, false); + } + + function test_SetPauseGuardian_Revert_WhenNoChange_AlreadySet() public { + _setGuardian(guardian, true); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorPauseGuardianNoChange.selector, guardian, true) + ); + vm.prank(_governor()); + _recurringCollector.setPauseGuardian(guardian, true); + } + + // ==================== pause / unpause ==================== + + function test_Pause_OK() public { + _setGuardian(guardian, true); + assertFalse(_recurringCollector.paused()); + + _pause(); + assertTrue(_recurringCollector.paused()); + } + + function test_Pause_Revert_WhenNotGuardian() public { + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorNotPauseGuardian.selector, address(this)) + ); + _recurringCollector.pause(); + } + + function test_Unpause_OK() public { + _setGuardian(guardian, true); + _pause(); + assertTrue(_recurringCollector.paused()); + + vm.prank(guardian); + _recurringCollector.unpause(); + assertFalse(_recurringCollector.paused()); + } + + function test_Unpause_Revert_WhenNotGuardian() public { + _setGuardian(guardian, true); + _pause(); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorNotPauseGuardian.selector, address(this)) + ); + _recurringCollector.unpause(); + } + + // ==================== whenNotPaused guards ==================== + + function test_Accept_Revert_WhenPaused(FuzzyTestAccept calldata fuzzy) public { + _setGuardian(guardian, true); + _pause(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA(fuzzy.rca); + uint256 key = boundKey(fuzzy.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, key); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, key); + + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + function test_Collect_Revert_WhenPaused(FuzzyTestAccept calldata fuzzy) public { + // Accept first (before pausing) + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + _setGuardian(guardian, true); + _pause(); + + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, keccak256("col"), 1, 0)); + + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(rca.dataService); + _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + } + + function test_Cancel_Revert_WhenPaused(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + _setGuardian(guardian, true); + _pause(); + + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + } + + function test_Update_Revert_WhenPaused(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + uint256 key, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + _setGuardian(guardian, true); + _pause(); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + (, bytes memory updateSig) = _recurringCollectorHelper.generateSignedRCAU(rcau, key); + + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, updateSig); + } + + // ==================== offer() during pause ==================== + + /// @notice offer() is also guarded by whenNotPaused — it should revert while paused. + function test_Offer_Revert_WhenPaused() public { + _setGuardian(guardian, true); + _pause(); + assertTrue(_recurringCollector.paused()); + + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + } + + /// @notice Offer stored before pause, then accept reverts during pause, then succeeds after unpause. + function test_OfferBeforePause_AcceptAfterUnpause() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + // Store offer while unpaused + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + // Pause + _setGuardian(guardian, true); + _pause(); + + // Accept reverts during pause + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.expectRevert(Pausable.EnforcedPause.selector); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // Unpause + vm.prank(guardian); + _recurringCollector.unpause(); + + // Accept succeeds after unpause (offer is still stored) + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(agreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index b518c708e..33501f940 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -404,6 +404,33 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ error RecurringCollectorInsufficientCallbackGas(); + /** + * @notice Thrown when the caller is not the governor + * @param account The address of the caller + */ + error RecurringCollectorNotGovernor(address account); + + /** + * @notice Thrown when the caller is not a pause guardian + * @param account The address of the caller + */ + error RecurringCollectorNotPauseGuardian(address account); + + /** + * @notice Thrown when setting a pause guardian to the same status + * @param account The address of the pause guardian + * @param allowed The (unchanged) allowed status + */ + error RecurringCollectorPauseGuardianNoChange(address account, bool allowed); + + /** + * @notice Emitted when a pause guardian is set + * @param account The address of the pause guardian + * @param allowed The allowed status + */ + event PauseGuardianSet(address indexed account, bool allowed); + // solhint-disable-previous-line gas-indexed-events + /** * @notice Emitted when a payer callback (beforeCollection / afterCollection) reverts. * @dev The try/catch ensures provider liveness but this event enables off-chain @@ -423,6 +450,25 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ event OfferStored(bytes16 indexed agreementId, address indexed payer, uint8 indexed offerType, bytes32 offerHash); + /** + * @notice Pauses the collector, blocking accept, update, collect, and cancel. + * @dev Only callable by a pause guardian. Uses OpenZeppelin Pausable. + */ + function pause() external; + + /** + * @notice Unpauses the collector. + * @dev Only callable by a pause guardian. + */ + function unpause() external; + + /** + * @notice Returns the status of a pause guardian. + * @param pauseGuardian The address to check + * @return Whether the address is a pause guardian + */ + function pauseGuardians(address pauseGuardian) external view returns (bool); + /** * @notice Accept a Recurring Collection Agreement. * @dev Caller must be the data service the RCA was issued to. diff --git a/packages/issuance/audits/PR1301/TRST-L-3.md b/packages/issuance/audits/PR1301/TRST-L-3.md index ddac91ef0..ff8edd1a8 100644 --- a/packages/issuance/audits/PR1301/TRST-L-3.md +++ b/packages/issuance/audits/PR1301/TRST-L-3.md @@ -20,3 +20,9 @@ Add a pause check to `approveAgreement()` that returns `bytes4(0)` when the cont ## Team Response TBD + +--- + +Fixed. RecurringCollector now has a pause mechanism with `whenNotPaused` modifier gating `accept`, `update`, `collect`, `cancel`, and `offer`. Pause guardians are managed by the governor via `setPauseGuardian`. This provides a middle layer between the RAM-level pause (agreement lifecycle only) and the Controller-level nuclear pause (all escrow operations protocol-wide). + +The `approveAgreement` callback has been removed entirely — stored-hash authorization replaced callback-based approval, so the pause-bypass vector no longer exists. Collection callbacks (`beforeCollection`, `afterCollection`) are wrapped in try/catch and cannot block collection regardless of pause state. From 0bbb476f37f85d042927e84d8764fa58eb020ccf Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Thu, 2 Apr 2026 12:18:49 +0000 Subject: [PATCH 075/157] fix(subgraph-service): remove VALID_PROVISION and REGISTERED from cancelIndexingAgreement cancelIndexingAgreement (introduced in a7fb8758f) required a valid provision check (onlyValidProvision, later refactored to enforceService with VALID_PROVISION | REGISTERED). Cancel should remain available regardless of provision state. Combined with blockClosingAllocationWithActiveAgreement (b1246562b), an indexer whose provision drops below minimum is stuck in a catch-22: VALID_PROVISION blocks cancel, and the active agreement blocks closing the allocation. REGISTERED is not relevant to cancelling on accepted agreement either. Changed to enforceService(indexer, DEFAULT). IndexingAgreement.cancel() validates the caller and pause check remains. Tests added (not all related to this issue): - Cross-package integration lifecycle - Cancel with below-minimum provision - Horizon coverage gaps --- .../graph-tally-collector/coverageGaps.t.sol | 62 ++ .../recurring-collector/coverageGaps.t.sol | 157 +++++ .../test/unit/staking/coverageGaps.t.sol | 91 +++ .../unit/agreement-manager/offerUpdate.t.sol | 4 +- .../contracts/SubgraphService.sol | 5 +- .../indexing-agreement/cancel.t.sol | 54 +- packages/testing/foundry.toml | 3 + packages/testing/package.json | 4 +- .../test/harness/FullStackHarness.t.sol | 536 +++++++++++++++ .../test/integration/AgreementLifecycle.t.sol | 366 ++++++++++ .../AgreementLifecycleAdvanced.t.sol | 629 ++++++++++++++++++ pnpm-lock.yaml | 3 + 12 files changed, 1899 insertions(+), 15 deletions(-) create mode 100644 packages/horizon/test/unit/payments/graph-tally-collector/coverageGaps.t.sol create mode 100644 packages/horizon/test/unit/staking/coverageGaps.t.sol create mode 100644 packages/testing/test/harness/FullStackHarness.t.sol create mode 100644 packages/testing/test/integration/AgreementLifecycle.t.sol create mode 100644 packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol diff --git a/packages/horizon/test/unit/payments/graph-tally-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/graph-tally-collector/coverageGaps.t.sol new file mode 100644 index 000000000..dfb8db254 --- /dev/null +++ b/packages/horizon/test/unit/payments/graph-tally-collector/coverageGaps.t.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IGraphTallyCollector } from "@graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol"; + +import { GraphTallyTest } from "./GraphTallyCollector.t.sol"; + +/// @notice Tests targeting uncovered view functions in GraphTallyCollector.sol +contract GraphTallyCollectorCoverageGapsTest is GraphTallyTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ══════════════════════════════════════════════════════════════════════ + // recoverRAVSigner (L90-91) + // ══════════════════════════════════════════════════════════════════════ + + function test_RecoverRAVSigner() public useGateway useSigner { + uint128 tokens = 1000 ether; + + IGraphTallyCollector.ReceiptAggregateVoucher memory rav = IGraphTallyCollector.ReceiptAggregateVoucher({ + dataService: subgraphDataServiceAddress, + serviceProvider: users.indexer, + timestampNs: 0, + valueAggregate: tokens, + metadata: "", + payer: users.gateway, + collectionId: bytes32("test-collection") + }); + + bytes32 messageHash = graphTallyCollector.encodeRAV(rav); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); + bytes memory signature = abi.encodePacked(r, s, v); + + IGraphTallyCollector.SignedRAV memory signedRAV = IGraphTallyCollector.SignedRAV({ + rav: rav, + signature: signature + }); + + address recovered = graphTallyCollector.recoverRAVSigner(signedRAV); + assertEq(recovered, signer); + } + + // ══════════════════════════════════════════════════════════════════════ + // authorizations view function (Authorizable L51, L54-55) + // ══════════════════════════════════════════════════════════════════════ + + function test_Authorizations_UnknownSigner() public { + address unknown = makeAddr("unknown"); + (address authorizer, uint256 thawEndTimestamp, bool revoked) = graphTallyCollector.authorizations(unknown); + assertEq(authorizer, address(0)); + assertEq(thawEndTimestamp, 0); + assertFalse(revoked); + } + + function test_Authorizations_KnownSigner() public useGateway useSigner { + (address authorizer, uint256 thawEndTimestamp, bool revoked) = graphTallyCollector.authorizations(signer); + assertEq(authorizer, users.gateway); + assertEq(thawEndTimestamp, 0); + assertFalse(revoked); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index bf85ce63b..696f97584 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -849,5 +849,162 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { assertEq(dataAfter.length, 0, "Offer data should be empty after cancel"); } + // ══════════════════════════════════════════════════════════════════════ + // Gap 16 — _requirePayer: agreement not found (L528) + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_Revert_WhenAgreementNotFound() public { + bytes16 fakeId = bytes16(keccak256("nonexistent")); + address caller = makeAddr("randomCaller"); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorAgreementNotFound.selector, fakeId) + ); + vm.prank(caller); + _recurringCollector.cancel(fakeId, bytes32(0), SCOPE_ACTIVE); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 17 — _requirePayer: unauthorized caller (L530) + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_Revert_WhenUnauthorizedCaller(FuzzyTestAccept calldata fuzzy) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzy); + + address imposter = makeAddr("imposter"); + vm.assume(imposter != rca.payer); + + bytes32 activeHash = _recurringCollector.getAgreementDetails(agreementId, 0).versionHash; + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorUnauthorizedCaller.selector, + imposter, + rca.payer + ) + ); + vm.prank(imposter); + _recurringCollector.cancel(agreementId, activeHash, SCOPE_ACTIVE); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 18 — IAgreementCollector.cancel with SCOPE_PENDING to delete RCAU offer (L501) + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_PendingScope_DeletesRcauOffer() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Offer and accept + vm.prank(address(approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + vm.prank(rca.dataService); + _recurringCollector.accept(rca, ""); + + // Offer an update + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt + 100 days, + maxInitialTokens: rca.maxInitialTokens * 2, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Verify RCAU offer exists + (, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertTrue(pendingData.length > 0, "RCAU offer should exist"); + + // Cancel via IAgreementCollector.cancel with RCAU hash and SCOPE_PENDING + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + // Verify RCAU offer is deleted + (, bytes memory afterData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(afterData.length, 0, "RCAU offer should be deleted after cancel"); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 19 — IAgreementCollector.cancel with SCOPE_ACTIVE on accepted (L502-504) + // ══════════════════════════════════════════════════════════════════════ + + function test_Cancel_ActiveScope_CallsDataService() public { + MockAgreementOwner approver = new MockAgreementOwner(); + MockDataServiceForCancel dataServiceMock = new MockDataServiceForCancel(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: address(dataServiceMock), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + _setupValidProvision(rca.serviceProvider, address(dataServiceMock)); + + // Offer and accept + vm.prank(address(approver)); + bytes16 agreementId = _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0).agreementId; + vm.prank(address(dataServiceMock)); + _recurringCollector.accept(rca, ""); + + // Cancel via IAgreementCollector.cancel with active hash and SCOPE_ACTIVE + bytes32 activeHash = _recurringCollector.getAgreementDetails(agreementId, 0).versionHash; + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, activeHash, SCOPE_ACTIVE); + + // Verify the mock was called + assertTrue(dataServiceMock.cancelCalled(), "cancelIndexingAgreementByPayer should have been called"); + assertEq(dataServiceMock.canceledAgreementId(), agreementId, "Agreement ID should match"); + } + /* solhint-enable graph/func-name-mixedcase */ } + +/// @notice Minimal mock data service that implements cancelIndexingAgreementByPayer +contract MockDataServiceForCancel { + bool public cancelCalled; + bytes16 public canceledAgreementId; + + function cancelIndexingAgreementByPayer(bytes16 agreementId) external { + cancelCalled = true; + canceledAgreementId = agreementId; + } +} diff --git a/packages/horizon/test/unit/staking/coverageGaps.t.sol b/packages/horizon/test/unit/staking/coverageGaps.t.sol new file mode 100644 index 000000000..07dfec2ed --- /dev/null +++ b/packages/horizon/test/unit/staking/coverageGaps.t.sol @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IHorizonStakingTypes } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingTypes.sol"; +import { IHorizonStakingBase } from "@graphprotocol/interfaces/contracts/horizon/internal/IHorizonStakingBase.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; + +import { HorizonStakingTest } from "./HorizonStaking.t.sol"; + +/// @notice Tests targeting uncovered view functions in HorizonStakingBase.sol +contract HorizonStakingCoverageGapsTest is HorizonStakingTest { + /* solhint-disable graph/func-name-mixedcase */ + + // ══════════════════════════════════════════════════════════════════════ + // getSubgraphService (L56-57) + // ══════════════════════════════════════════════════════════════════════ + + function test_GetSubgraphService() public view { + address subgraphService = staking.getSubgraphService(); + assertEq(subgraphService, subgraphDataServiceLegacyAddress); + } + + // ══════════════════════════════════════════════════════════════════════ + // getIdleStake (L76-77) + // ══════════════════════════════════════════════════════════════════════ + + function test_GetIdleStake_NoStake() public view { + uint256 idleStake = staking.getIdleStake(users.indexer); + assertEq(idleStake, 0); + } + + function test_GetIdleStake_WithStake( + uint256 stakeAmount, + uint256 provisionAmount, + uint32 maxVerifierCut, + uint64 thawingPeriod + ) public useIndexer useProvision(stakeAmount, maxVerifierCut, thawingPeriod) { + // All staked tokens are provisioned, so idle = 0 + uint256 idleStake = staking.getIdleStake(users.indexer); + assertEq(idleStake, 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // getDelegation (L98, L103-106) + // ══════════════════════════════════════════════════════════════════════ + + function test_GetDelegation_NoDelegation() public view { + Delegation memory delegation = staking.getDelegation( + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + assertEq(delegation.shares, 0); + } + + function test_GetDelegation_WithDelegation( + uint256 stakeAmount, + uint256 delegationAmount, + uint32 maxVerifierCut, + uint64 thawingPeriod + ) public useIndexer useProvision(stakeAmount, maxVerifierCut, thawingPeriod) useDelegation(delegationAmount) { + Delegation memory delegation = staking.getDelegation( + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + assertGt(delegation.shares, 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // getThawedTokens early return when no thaw requests (L181) + // ══════════════════════════════════════════════════════════════════════ + + function test_GetThawedTokens_ZeroRequests_Delegation( + uint256 stakeAmount, + uint256 delegationAmount, + uint32 maxVerifierCut, + uint64 thawingPeriod + ) public useIndexer useProvision(stakeAmount, maxVerifierCut, thawingPeriod) useDelegation(delegationAmount) { + // Delegator has delegation shares but no thaw requests + uint256 thawedTokens = staking.getThawedTokens( + IHorizonStakingTypes.ThawRequestType.Delegation, + users.indexer, + subgraphDataServiceAddress, + users.delegator + ); + assertEq(thawedTokens, 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol index 19d74c1b0..e58a356cf 100644 --- a/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol +++ b/packages/issuance/test/unit/agreement-manager/offerUpdate.t.sol @@ -225,7 +225,9 @@ contract RecurringAgreementManagerOfferUpdateTest is RecurringAgreementManagerSh 1 ); - vm.expectRevert(abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0))); + vm.expectRevert( + abi.encodeWithSelector(IRecurringAgreementManagement.UnauthorizedDataService.selector, address(0)) + ); vm.prank(operator); agreementManager.offerAgreement(_collector(), OFFER_TYPE_UPDATE, abi.encode(rcau)); } diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index a222a6e0f..6502b1b0a 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -450,10 +450,7 @@ contract SubgraphService is * @param indexer The indexer address * @param agreementId The id of the agreement */ - function cancelIndexingAgreement( - address indexer, - bytes16 agreementId - ) external enforceService(indexer, VALID_PROVISION | REGISTERED) { + function cancelIndexingAgreement(address indexer, bytes16 agreementId) external enforceService(indexer, DEFAULT) { IndexingAgreement._getStorageManager().cancel(indexer, agreementId); } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index 80bcb16c3..0b5463cd4 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -135,7 +135,10 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg subgraphService.cancelIndexingAgreement(indexer, agreementId); } - function test_SubgraphService_CancelIndexingAgreement_Revert_WhenInvalidProvision( + // cancelIndexingAgreement uses enforceService(DEFAULT) — only authorization + pause. + // No VALID_PROVISION or REGISTERED check. Cancel is an exit path. + // With an invalid provision and no agreement, reverts with IndexingAgreementNotActive. + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotActive_WithInvalidProvision( address indexer, bytes16 agreementId, uint256 unboundedTokens @@ -146,17 +149,15 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg _createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD); bytes memory expectedErr = abi.encodeWithSelector( - ProvisionManager.ProvisionManagerInvalidValue.selector, - "tokens", - tokens, - MINIMUM_PROVISION_TOKENS, - MAXIMUM_PROVISION_TOKENS + IndexingAgreement.IndexingAgreementNotActive.selector, + agreementId ); vm.expectRevert(expectedErr); subgraphService.cancelIndexingAgreement(indexer, agreementId); } - function test_SubgraphService_CancelIndexingAgreement_Revert_WhenIndexerNotRegistered( + // With valid provision but no registration or agreement, also reverts with IndexingAgreementNotActive. + function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotActive_WithoutRegistration( address indexer, bytes16 agreementId, uint256 unboundedTokens @@ -166,8 +167,8 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg resetPrank(indexer); _createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD); bytes memory expectedErr = abi.encodeWithSelector( - ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, - indexer + IndexingAgreement.IndexingAgreementNotActive.selector, + agreementId ); vm.expectRevert(expectedErr); subgraphService.cancelIndexingAgreement(indexer, agreementId); @@ -245,5 +246,40 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg IRecurringCollector.CancelAgreementBy.ServiceProvider ); } + + // solhint-disable-next-line graph/func-name-mixedcase + /// @notice An indexer whose provision drops below minimum should still be able + /// to cancel their indexing agreement. Cancel is an exit path. + function test_SubgraphService_CancelIndexingAgreement_OK_WhenProvisionBelowMinimum( + Seed memory seed + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 acceptedAgreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Thaw tokens to bring effective provision below minimum. + // _withIndexer provisions at least MINIMUM_PROVISION_TOKENS, so thawing + // (tokens - MINIMUM_PROVISION_TOKENS + 1) puts us 1 below the floor. + uint256 thawAmount = indexerState.tokens - MINIMUM_PROVISION_TOKENS + 1; + resetPrank(indexerState.addr); + staking.thaw(indexerState.addr, address(subgraphService), thawAmount); + + // Verify provision is now below minimum + uint256 effectiveTokens = indexerState.tokens - thawAmount; + assertLt(effectiveTokens, MINIMUM_PROVISION_TOKENS); + + // Cancel should succeed despite invalid provision + _cancelAgreement( + ctx, + acceptedAgreementId, + acceptedRca.serviceProvider, + acceptedRca.payer, + IRecurringCollector.CancelAgreementBy.ServiceProvider + ); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/testing/foundry.toml b/packages/testing/foundry.toml index 2b44a2bc6..7cae558c3 100644 --- a/packages/testing/foundry.toml +++ b/packages/testing/foundry.toml @@ -11,7 +11,10 @@ remappings = [ # Real contract sources via workspace symlinks "horizon/=node_modules/@graphprotocol/horizon/contracts/", "horizon-mocks/=node_modules/@graphprotocol/horizon/contracts/mocks/", + "horizon-test/=node_modules/@graphprotocol/horizon/test/", "issuance/=node_modules/@graphprotocol/issuance/contracts/", + "subgraph-service/=node_modules/@graphprotocol/subgraph-service/contracts/", + "subgraph-service-test/=node_modules/@graphprotocol/subgraph-service/test/", ] optimizer = true optimizer_runs = 100 diff --git a/packages/testing/package.json b/packages/testing/package.json index 93444e04a..db2cfebe6 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -7,7 +7,8 @@ "scripts": { "build": "pnpm build:dep", "build:dep": "pnpm --filter '@graphprotocol/testing^...' run build:self", - "test": "forge test", + "test": "pnpm build && pnpm test:self", + "test:self": "forge test", "test:gas": "forge test --match-contract Gas -vv" }, "devDependencies": { @@ -15,6 +16,7 @@ "@graphprotocol/horizon": "workspace:^", "@graphprotocol/interfaces": "workspace:^", "@graphprotocol/issuance": "workspace:^", + "@graphprotocol/subgraph-service": "workspace:^", "@openzeppelin/contracts": "^5.4.0", "@openzeppelin/contracts-upgradeable": "^5.4.0", "forge-std": "catalog:" diff --git a/packages/testing/test/harness/FullStackHarness.t.sol b/packages/testing/test/harness/FullStackHarness.t.sol new file mode 100644 index 000000000..842ebe1a1 --- /dev/null +++ b/packages/testing/test/harness/FullStackHarness.t.sol @@ -0,0 +1,536 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { Test } from "forge-std/Test.sol"; + +// -- Real contracts (all on the critical path) -- +import { Controller } from "@graphprotocol/contracts/contracts/governance/Controller.sol"; +import { GraphProxy } from "@graphprotocol/contracts/contracts/upgrades/GraphProxy.sol"; +import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol"; +import { HorizonStaking } from "horizon/staking/HorizonStaking.sol"; +import { GraphPayments } from "horizon/payments/GraphPayments.sol"; +import { PaymentsEscrow } from "horizon/payments/PaymentsEscrow.sol"; +import { RecurringCollector } from "horizon/payments/collectors/RecurringCollector.sol"; +import { SubgraphService } from "subgraph-service/SubgraphService.sol"; +import { DisputeManager } from "subgraph-service/DisputeManager.sol"; +import { IssuanceAllocator } from "issuance/allocate/IssuanceAllocator.sol"; +import { RecurringAgreementManager } from "issuance/agreement/RecurringAgreementManager.sol"; +import { RecurringAgreementHelper } from "issuance/agreement/RecurringAgreementHelper.sol"; + +// -- Interfaces -- +import { IHorizonStaking } from "@graphprotocol/interfaces/contracts/horizon/IHorizonStaking.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; +import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; + +// -- Mocks (only for contracts NOT on the payment/agreement critical path) -- +import { MockGRTToken } from "subgraph-service-test/unit/mocks/MockGRTToken.sol"; +import { MockCuration } from "subgraph-service-test/unit/mocks/MockCuration.sol"; +import { MockEpochManager } from "subgraph-service-test/unit/mocks/MockEpochManager.sol"; +import { MockRewardsManager } from "subgraph-service-test/unit/mocks/MockRewardsManager.sol"; + +// -- Helpers -- +import { IndexingAgreement } from "subgraph-service/libraries/IndexingAgreement.sol"; +import { RecurringCollectorHelper } from "horizon-test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol"; + +/// @title FullStackHarness +/// @notice Deploys the complete protocol stack for cross-package integration tests: +/// +/// Real contracts (on critical path): +/// - Controller, GraphProxyAdmin, HorizonStaking +/// - GraphPayments, PaymentsEscrow +/// - RecurringCollector +/// - SubgraphService, DisputeManager +/// - RecurringAgreementManager, IssuanceAllocator, RecurringAgreementHelper +/// +/// Mocks (not on critical path): +/// - MockGRTToken (ERC20, slightly cheaper than proxied token) +/// - MockCuration (signal tracking for reward calculations) +/// - MockEpochManager (epoch/block tracking) +/// - MockRewardsManager (indexing reward minting) +abstract contract FullStackHarness is Test { + // -- Constants -- + uint256 internal constant MINIMUM_PROVISION_TOKENS = 1000 ether; + uint32 internal constant DELEGATION_RATIO = 16; + uint256 internal constant STAKE_TO_FEES_RATIO = 2; + uint256 internal constant PROTOCOL_PAYMENT_CUT = 10000; // 1% in PPM + uint256 internal constant WITHDRAW_ESCROW_THAWING_PERIOD = 60; + uint64 internal constant DISPUTE_PERIOD = 7 days; + uint256 internal constant DISPUTE_DEPOSIT = 100 ether; + uint32 internal constant FISHERMAN_REWARD_PERCENTAGE = 500000; // 50% + uint32 internal constant MAX_SLASHING_PERCENTAGE = 100000; // 10% + uint64 internal constant MAX_WAIT_PERIOD = 28 days; + uint256 internal constant REVOKE_SIGNER_THAWING_PERIOD = 7 days; + uint256 internal constant REWARDS_PER_SIGNAL = 10000; + uint256 internal constant REWARDS_PER_SUBGRAPH_ALLOCATION_UPDATE = 1000; + uint256 internal constant EPOCH_LENGTH = 1; + uint256 internal constant MAX_POI_STALENESS = 28 days; + uint256 internal constant CURATION_CUT = 10000; + + // -- RAM role constants -- + bytes32 internal constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE"); + bytes32 internal constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); + bytes32 internal constant DATA_SERVICE_ROLE = keccak256("DATA_SERVICE_ROLE"); + bytes32 internal constant COLLECTOR_ROLE = keccak256("COLLECTOR_ROLE"); + bytes32 internal constant AGREEMENT_MANAGER_ROLE = keccak256("AGREEMENT_MANAGER_ROLE"); + + // -- Real contracts -- + Controller internal controller; + GraphProxyAdmin internal proxyAdmin; + IHorizonStaking internal staking; + GraphPayments internal graphPayments; + PaymentsEscrow internal escrow; + RecurringCollector internal recurringCollector; + SubgraphService internal subgraphService; + DisputeManager internal disputeManager; + IssuanceAllocator internal issuanceAllocator; + RecurringAgreementManager internal ram; + RecurringAgreementHelper internal ramHelper; + address internal recurringCollectorProxyAdmin; + + // -- Mocks -- + MockGRTToken internal token; + MockCuration internal curation; + MockEpochManager internal epochManager; + MockRewardsManager internal rewardsManager; + + // -- Helpers -- + RecurringCollectorHelper internal rcHelper; + + // -- Accounts -- + address internal governor; + address internal deployer; + address internal operator; // RAM operator + address internal arbitrator; + address internal pauseGuardian; + + function setUp() public virtual { + governor = makeAddr("governor"); + deployer = makeAddr("deployer"); + operator = makeAddr("operator"); + arbitrator = makeAddr("arbitrator"); + pauseGuardian = makeAddr("pauseGuardian"); + + // Fund accounts with ETH + vm.deal(governor, 100 ether); + vm.deal(deployer, 100 ether); + + _deployProtocol(); + _deployRAMStack(); + _configureProtocol(); + } + + // ── Protocol deployment (follows SubgraphBaseTest pattern) ────────── + + function _deployProtocol() private { + vm.startPrank(governor); + proxyAdmin = new GraphProxyAdmin(); + controller = new Controller(); + vm.stopPrank(); + + vm.startPrank(deployer); + token = new MockGRTToken(); + GraphProxy stakingProxy = new GraphProxy(address(0), address(proxyAdmin)); + rewardsManager = new MockRewardsManager(token, REWARDS_PER_SIGNAL, REWARDS_PER_SUBGRAPH_ALLOCATION_UPDATE); + curation = new MockCuration(); + epochManager = new MockEpochManager(); + + // Predict GraphPayments and PaymentsEscrow addresses using actual creation code. + // We use type(...).creationCode instead of vm.getCode to get the exact bytecode + // that will be used by CREATE2, avoiding metadata hash mismatches across packages. + bytes32 saltGP = keccak256("GraphPaymentsSalt"); + bytes memory gpCreation = type(GraphPayments).creationCode; + address predictedGP = vm.computeCreate2Address( + saltGP, + keccak256(bytes.concat(gpCreation, abi.encode(address(controller), PROTOCOL_PAYMENT_CUT))), + deployer + ); + + bytes32 saltEscrow = keccak256("GraphEscrowSalt"); + bytes memory escrowCreation = type(PaymentsEscrow).creationCode; + address predictedEscrow = vm.computeCreate2Address( + saltEscrow, + keccak256(bytes.concat(escrowCreation, abi.encode(address(controller), WITHDRAW_ESCROW_THAWING_PERIOD))), + deployer + ); + + // Register in controller (GraphDirectory reads immutably at construction) + vm.startPrank(governor); + controller.setContractProxy(keccak256("GraphToken"), address(token)); + controller.setContractProxy(keccak256("Staking"), address(stakingProxy)); + controller.setContractProxy(keccak256("RewardsManager"), address(rewardsManager)); + controller.setContractProxy(keccak256("GraphPayments"), predictedGP); + controller.setContractProxy(keccak256("PaymentsEscrow"), predictedEscrow); + controller.setContractProxy(keccak256("EpochManager"), address(epochManager)); + controller.setContractProxy(keccak256("GraphTokenGateway"), makeAddr("GraphTokenGateway")); + controller.setContractProxy(keccak256("GraphProxyAdmin"), makeAddr("GraphProxyAdmin")); + controller.setContractProxy(keccak256("Curation"), address(curation)); + vm.stopPrank(); + + // Deploy DisputeManager + vm.startPrank(deployer); + address dmImpl = address(new DisputeManager(address(controller))); + address dmProxy = address( + new TransparentUpgradeableProxy( + dmImpl, + governor, + abi.encodeCall( + DisputeManager.initialize, + ( + deployer, + arbitrator, + DISPUTE_PERIOD, + DISPUTE_DEPOSIT, + FISHERMAN_REWARD_PERCENTAGE, + MAX_SLASHING_PERCENTAGE + ) + ) + ) + ); + disputeManager = DisputeManager(dmProxy); + disputeManager.transferOwnership(governor); + + // Deploy RecurringCollector behind proxy + RecurringCollector rcImpl = new RecurringCollector(address(controller), REVOKE_SIGNER_THAWING_PERIOD); + TransparentUpgradeableProxy rcProxy = new TransparentUpgradeableProxy( + address(rcImpl), + governor, + abi.encodeCall(RecurringCollector.initialize, ("RecurringCollector", "1")) + ); + recurringCollector = RecurringCollector(address(rcProxy)); + recurringCollectorProxyAdmin = address(uint160(uint256(vm.load(address(rcProxy), ERC1967Utils.ADMIN_SLOT)))); + + // Deploy SubgraphService + address ssImpl = address( + new SubgraphService( + address(controller), + address(disputeManager), + makeAddr("GraphTallyCollector"), // stub — not needed for indexing fee tests + address(curation), + address(recurringCollector) + ) + ); + address ssProxy = address( + new TransparentUpgradeableProxy( + ssImpl, + governor, + abi.encodeCall( + SubgraphService.initialize, + (deployer, MINIMUM_PROVISION_TOKENS, DELEGATION_RATIO, STAKE_TO_FEES_RATIO) + ) + ) + ); + subgraphService = SubgraphService(ssProxy); + + // Deploy HorizonStaking implementation and wire to proxy + HorizonStaking stakingBase = new HorizonStaking(address(controller), address(subgraphService)); + vm.stopPrank(); + + // Deploy GraphPayments and PaymentsEscrow at predicted addresses + vm.startPrank(deployer); + graphPayments = new GraphPayments{ salt: saltGP }(address(controller), PROTOCOL_PAYMENT_CUT); + escrow = new PaymentsEscrow{ salt: saltEscrow }(address(controller), WITHDRAW_ESCROW_THAWING_PERIOD); + vm.stopPrank(); + + // Wire staking proxy + vm.startPrank(governor); + disputeManager.setSubgraphService(address(subgraphService)); + proxyAdmin.upgrade(stakingProxy, address(stakingBase)); + proxyAdmin.acceptProxy(stakingBase, stakingProxy); + staking = IHorizonStaking(address(stakingProxy)); + vm.stopPrank(); + + // RecurringCollectorHelper + rcHelper = new RecurringCollectorHelper(recurringCollector, recurringCollectorProxyAdmin); + } + + // ── RAM + IssuanceAllocator deployment ────────────────────────────── + + function _deployRAMStack() private { + vm.startPrank(deployer); + + // Deploy IssuanceAllocator behind proxy + IssuanceAllocator allocatorImpl = new IssuanceAllocator(IssuanceIGraphToken(address(token))); + TransparentUpgradeableProxy allocatorProxy = new TransparentUpgradeableProxy( + address(allocatorImpl), + governor, + abi.encodeCall(IssuanceAllocator.initialize, (governor)) + ); + issuanceAllocator = IssuanceAllocator(address(allocatorProxy)); + + // Deploy RecurringAgreementManager behind proxy + RecurringAgreementManager ramImpl = new RecurringAgreementManager( + IssuanceIGraphToken(address(token)), + IPaymentsEscrow(address(escrow)) + ); + TransparentUpgradeableProxy ramProxy = new TransparentUpgradeableProxy( + address(ramImpl), + governor, + abi.encodeCall(RecurringAgreementManager.initialize, (governor)) + ); + ram = RecurringAgreementManager(address(ramProxy)); + + // Deploy RecurringAgreementHelper (stateless, no proxy needed) + ramHelper = new RecurringAgreementHelper(address(ram), IERC20(address(token))); + + vm.stopPrank(); + + // Configure RAM roles and issuance + vm.startPrank(governor); + ram.grantRole(OPERATOR_ROLE, operator); + ram.grantRole(DATA_SERVICE_ROLE, address(subgraphService)); + ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); + ram.setIssuanceAllocator(address(issuanceAllocator)); + + issuanceAllocator.setIssuancePerBlock(1 ether); + issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); + vm.stopPrank(); + + vm.prank(operator); + ram.grantRole(AGREEMENT_MANAGER_ROLE, operator); + } + + // ── Protocol configuration ───────────────────────────────────────── + + function _configureProtocol() private { + vm.startPrank(governor); + staking.setMaxThawingPeriod(MAX_WAIT_PERIOD); + controller.setPaused(false); + vm.stopPrank(); + + vm.startPrank(deployer); + subgraphService.transferOwnership(governor); + vm.stopPrank(); + + vm.startPrank(governor); + epochManager.setEpochLength(EPOCH_LENGTH); + subgraphService.setMaxPOIStaleness(MAX_POI_STALENESS); + subgraphService.setCurationCut(CURATION_CUT); + subgraphService.setPauseGuardian(pauseGuardian, true); + vm.stopPrank(); + + // Labels + vm.label(address(token), "GraphToken"); + vm.label(address(controller), "Controller"); + vm.label(address(staking), "HorizonStaking"); + vm.label(address(graphPayments), "GraphPayments"); + vm.label(address(escrow), "PaymentsEscrow"); + vm.label(address(recurringCollector), "RecurringCollector"); + vm.label(address(subgraphService), "SubgraphService"); + vm.label(address(disputeManager), "DisputeManager"); + vm.label(address(issuanceAllocator), "IssuanceAllocator"); + vm.label(address(ram), "RecurringAgreementManager"); + vm.label(address(ramHelper), "RecurringAgreementHelper"); + } + + // ── Indexer setup helpers ────────────────────────────────────────── + + struct IndexerSetup { + address addr; + address allocationId; + uint256 allocationKey; + bytes32 subgraphDeploymentId; + uint256 provisionTokens; + } + + /// @notice Create a fully provisioned and registered indexer with an open allocation + function _setupIndexer( + string memory label, + bytes32 subgraphDeploymentId, + uint256 provisionTokens + ) internal returns (IndexerSetup memory indexer) { + indexer.addr = makeAddr(label); + (indexer.allocationId, indexer.allocationKey) = makeAddrAndKey(string.concat(label, "-allocation")); + indexer.subgraphDeploymentId = subgraphDeploymentId; + indexer.provisionTokens = provisionTokens; + + // Fund and provision + _mintTokens(indexer.addr, provisionTokens); + vm.startPrank(indexer.addr); + token.approve(address(staking), provisionTokens); + staking.stakeTo(indexer.addr, provisionTokens); + staking.provision( + indexer.addr, + address(subgraphService), + provisionTokens, + FISHERMAN_REWARD_PERCENTAGE, + DISPUTE_PERIOD + ); + + // Register + subgraphService.register(indexer.addr, abi.encode("url", "geoHash", address(0))); + + // Create allocation + bytes32 digest = subgraphService.encodeAllocationProof(indexer.addr, indexer.allocationId); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(indexer.allocationKey, digest); + bytes memory allocationData = abi.encode( + subgraphDeploymentId, + provisionTokens, + indexer.allocationId, + abi.encodePacked(r, s, v) + ); + subgraphService.startService(indexer.addr, allocationData); + + // Set payments destination to indexer address (so tokens flow to indexer.addr) + subgraphService.setPaymentsDestination(indexer.addr); + vm.stopPrank(); + } + + // ── RAM agreement helpers ────────────────────────────────────────── + + /// @notice Build an RCA with RAM as payer, targeting a specific indexer + SS + function _buildRCA( + IndexerSetup memory indexer, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + IndexingAgreement.IndexingAgreementTermsV1 memory terms + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(ram), + dataService: address(subgraphService), + serviceProvider: indexer.addr, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: 60, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: 1, + conditions: 0, + metadata: abi.encode( + IndexingAgreement.AcceptIndexingAgreementMetadata({ + subgraphDeploymentId: indexer.subgraphDeploymentId, + version: IIndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode(terms) + }) + ) + }); + } + + /// @notice Build an RCA with custom nonce and conditions + function _buildRCAEx( + IndexerSetup memory indexer, + uint256 maxInitialTokens, + uint256 maxOngoingTokensPerSecond, + uint32 maxSecondsPerCollection, + IndexingAgreement.IndexingAgreementTermsV1 memory terms, + uint256 nonce, + uint16 conditions + ) internal view returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(ram), + dataService: address(subgraphService), + serviceProvider: indexer.addr, + maxInitialTokens: maxInitialTokens, + maxOngoingTokensPerSecond: maxOngoingTokensPerSecond, + minSecondsPerCollection: 60, + maxSecondsPerCollection: maxSecondsPerCollection, + nonce: nonce, + conditions: conditions, + metadata: abi.encode( + IndexingAgreement.AcceptIndexingAgreementMetadata({ + subgraphDeploymentId: indexer.subgraphDeploymentId, + version: IIndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode(terms) + }) + ) + }); + } + + /// @notice Add tokens to an indexer's provision for stake locking + function _addProvisionTokens(IndexerSetup memory indexer, uint256 amount) internal { + _mintTokens(indexer.addr, amount); + vm.startPrank(indexer.addr); + token.approve(address(staking), amount); + staking.stakeTo(indexer.addr, amount); + staking.addToProvision(indexer.addr, address(subgraphService), amount); + vm.stopPrank(); + } + + /// @notice Fund RAM and offer a new agreement + function _ramOffer( + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16 agreementId) { + _mintTokens(address(ram), 1_000_000 ether); + vm.prank(operator); + agreementId = ram.offerAgreement( + IAgreementCollector(address(recurringCollector)), + OFFER_TYPE_NEW, + abi.encode(rca) + ); + } + + /// @notice Accept an offered agreement via SubgraphService (unsigned/contract-approved path) + function _ssAccept( + IndexerSetup memory indexer, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16 agreementId) { + vm.prank(indexer.addr); + agreementId = subgraphService.acceptIndexingAgreement(indexer.allocationId, rca, ""); + } + + /// @notice Offer via RAM + accept via SS in one call + function _offerAndAccept( + IndexerSetup memory indexer, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16 agreementId) { + _ramOffer(rca); + agreementId = _ssAccept(indexer, rca); + } + + /// @notice Collect indexing fees through SS → RC → GraphPayments → escrow + function _collectIndexingFees( + IndexerSetup memory indexer, + bytes16 agreementId, + uint256 entities, + bytes32 poi, + uint256 poiBlockNumber + ) internal returns (uint256 tokensCollected) { + bytes memory collectData = abi.encode( + agreementId, + abi.encode( + IndexingAgreement.CollectIndexingFeeDataV1({ + entities: entities, + poi: poi, + poiBlockNumber: poiBlockNumber, + metadata: "", + maxSlippage: type(uint256).max + }) + ) + ); + + vm.prank(indexer.addr); + tokensCollected = subgraphService.collect(indexer.addr, IGraphPayments.PaymentTypes.IndexingFee, collectData); + } + + // ── Escrow helpers ───────────────────────────────────────────────── + + // ── Token helpers ────────────────────────────────────────────────── + + function _mintTokens(address to, uint256 amount) internal { + token.mint(to, amount); + } + + // ── Prank helpers ────────────────────────────────────────────────── + + function resetPrank(address msgSender) internal { + vm.stopPrank(); + vm.startPrank(msgSender); + } +} diff --git a/packages/testing/test/integration/AgreementLifecycle.t.sol b/packages/testing/test/integration/AgreementLifecycle.t.sol new file mode 100644 index 000000000..515450460 --- /dev/null +++ b/packages/testing/test/integration/AgreementLifecycle.t.sol @@ -0,0 +1,366 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_UPDATE, + SCOPE_ACTIVE +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; +import { PPMMath } from "horizon/libraries/PPMMath.sol"; + +import { IndexingAgreement } from "subgraph-service/libraries/IndexingAgreement.sol"; + +import { FullStackHarness } from "../harness/FullStackHarness.t.sol"; + +/// @title AgreementLifecycleTest +/// @notice End-to-end integration tests exercising the full indexing agreement lifecycle +/// through real RAM, RecurringCollector, SubgraphService, GraphPayments, and PaymentsEscrow. +contract AgreementLifecycleTest is FullStackHarness { + using PPMMath for uint256; + + bytes32 internal constant SUBGRAPH_DEPLOYMENT = keccak256("test-subgraph-deployment"); + uint256 internal constant INDEXER_TOKENS = 10_000 ether; + + IndexerSetup internal indexer; + + function setUp() public override { + super.setUp(); + indexer = _setupIndexer("indexer1", SUBGRAPH_DEPLOYMENT, INDEXER_TOKENS); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 1: Happy path — Offer → Accept → Collect → Reconcile + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario1_OfferAcceptCollectReconcile() public { + // -- Parameters -- + uint256 maxInitial = 100 ether; + uint256 maxOngoing = 1 ether; // 1 token/sec + uint32 maxSecPerCollection = 3600; // 1 hour + uint256 tokensPerSecond = 0.5 ether; // agreement rate (terms) + uint256 expectedMaxClaim = maxOngoing * maxSecPerCollection + maxInitial; + + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: tokensPerSecond, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA( + indexer, + maxInitial, + maxOngoing, + maxSecPerCollection, + terms + ); + + // -- Step 1: RAM offers agreement -- + bytes16 agreementId = _ramOffer(rca); + + // Verify RAM tracks the agreement with escrow deposited (Full mode) + IRecurringAgreementHelper.ProviderAudit memory pAudit = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertEq(pAudit.sumMaxNextClaim, expectedMaxClaim, "maxNextClaim after offer"); + assertEq(pAudit.escrow.balance, expectedMaxClaim, "escrow deposited in Full mode"); + + // -- Step 2: Accept via SubgraphService -- + bytes16 acceptedId = _ssAccept(indexer, rca); + assertEq(acceptedId, agreementId, "agreement ID matches"); + + // Verify RC stored the agreement + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq(uint8(rcAgreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + assertEq(rcAgreement.payer, address(ram)); + assertEq(rcAgreement.serviceProvider, indexer.addr); + + // Verify SS stored the agreement + IIndexingAgreement.AgreementWrapper memory ssAgreement = subgraphService.getIndexingAgreement(agreementId); + assertEq(uint8(ssAgreement.collectorAgreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + + // -- Step 3: Advance time and collect -- + uint256 collectSeconds = 1800; // 30 minutes + skip(collectSeconds); + + // Add extra tokens to indexer's provision for stake locking + uint256 expectedTokens = tokensPerSecond * collectSeconds; + uint256 tokensToLock = expectedTokens * STAKE_TO_FEES_RATIO; + _mintTokens(indexer.addr, tokensToLock); + vm.startPrank(indexer.addr); + token.approve(address(staking), tokensToLock); + staking.stakeTo(indexer.addr, tokensToLock); + staking.addToProvision(indexer.addr, address(subgraphService), tokensToLock); + vm.stopPrank(); + + uint256 indexerBalanceBefore = token.balanceOf(indexer.addr); + (uint256 escrowBefore, , ) = escrow.escrowAccounts(address(ram), address(recurringCollector), indexer.addr); + + // Advance past allocation creation epoch so POI isn't "too young" + vm.roll(block.number + EPOCH_LENGTH); + + uint256 tokensCollected = _collectIndexingFees( + indexer, + agreementId, + 0, // entities + keccak256("poi1"), + block.number - 1 + ); + + // Verify tokens flowed correctly + assertTrue(tokensCollected > 0, "should collect tokens"); + uint256 indexerBalanceAfter = token.balanceOf(indexer.addr); + uint256 protocolBurn = tokensCollected.mulPPMRoundUp(PROTOCOL_PAYMENT_CUT); + assertEq( + indexerBalanceAfter - indexerBalanceBefore, + tokensCollected - protocolBurn, + "indexer received tokens minus protocol cut" + ); + + // Verify escrow changed (RAM's beforeCollection/afterCollection may adjust balance) + (uint256 escrowAfter, , ) = escrow.escrowAccounts(address(ram), address(recurringCollector), indexer.addr); + assertTrue(escrowAfter < escrowBefore, "escrow balance decreased after collection"); + + // -- Step 4: Reconcile RAM state -- + ram.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + // After first collection, maxInitialTokens drops out + uint256 expectedMaxClaimAfterCollection = maxOngoing * maxSecPerCollection; + assertEq(pAudit.sumMaxNextClaim, expectedMaxClaimAfterCollection, "maxNextClaim reduced after collection"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 2: Update flow — Offer → Accept → Update → Collect + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario2_UpdateFlow() public { + uint256 tokensPerSecond = 0.5 ether; + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: tokensPerSecond, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 2 ether, 3600, terms); + + // Offer + accept + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Build update with higher rate + uint256 newTokensPerSecond = 1 ether; + IndexingAgreement.IndexingAgreementTermsV1 memory newTerms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: newTokensPerSecond, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + maxInitialTokens: 0, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 60, + maxSecondsPerCollection: 3600, + nonce: 1, + conditions: 0, + metadata: abi.encode( + IndexingAgreement.UpdateIndexingAgreementMetadata({ + version: IIndexingAgreement.IndexingAgreementVersion.V1, + terms: abi.encode(newTerms) + }) + ) + }); + + // RAM offers update + vm.prank(operator); + ram.offerAgreement(IAgreementCollector(address(recurringCollector)), OFFER_TYPE_UPDATE, abi.encode(rcau)); + + // SS accepts update + vm.prank(indexer.addr); + subgraphService.updateIndexingAgreement(indexer.addr, rcau, ""); + + // Advance time and collect at new rate + uint256 collectSeconds = 1800; + skip(collectSeconds); + + uint256 expectedTokens = newTokensPerSecond * collectSeconds; + uint256 tokensToLock = expectedTokens * STAKE_TO_FEES_RATIO; + _mintTokens(indexer.addr, tokensToLock); + vm.startPrank(indexer.addr); + token.approve(address(staking), tokensToLock); + staking.stakeTo(indexer.addr, tokensToLock); + staking.addToProvision(indexer.addr, address(subgraphService), tokensToLock); + vm.stopPrank(); + + vm.roll(block.number + EPOCH_LENGTH); + + uint256 tokensCollected = _collectIndexingFees(indexer, agreementId, 0, keccak256("poi2"), block.number - 1); + + // At 1 token/sec for 1800 sec, we expect ~1800 tokens + // (capped by maxOngoingTokensPerSecond * collectSeconds = 2 * 1800 = 3600) + assertTrue(tokensCollected > 0, "should collect tokens at updated rate"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 3: Cancel by indexer → Reconcile → Escrow cleanup + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario3_CancelByIndexerAndCleanup() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA( + indexer, + 100 ether, + 1 ether, + 3600, + terms + ); + uint256 expectedMaxClaim = 1 ether * 3600 + 100 ether; + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Verify escrow deposited + IRecurringAgreementHelper.ProviderAudit memory pAudit = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertEq(pAudit.escrow.balance, expectedMaxClaim, "escrow deposited"); + + // Cancel by indexer via SubgraphService + vm.prank(indexer.addr); + subgraphService.cancelIndexingAgreement(indexer.addr, agreementId); + + // Verify RC state + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "RC: canceled by SP" + ); + + // Reconcile RAM — removes agreement, starts thawing escrow + ram.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + IRecurringAgreementHelper.GlobalAudit memory gAudit = ramHelper.auditGlobal(); + assertEq(gAudit.sumMaxNextClaimAll, 0, "global maxNextClaim zeroed"); + + // Escrow is thawing + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertTrue(pAudit.escrow.tokensThawing > 0, "escrow should be thawing"); + + // Wait for thaw and withdraw + skip(1 days + 1); // WITHDRAW_ESCROW_THAWING_PERIOD is 60s but PaymentsEscrow uses 1 day + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(pAudit.escrow.balance, 0, "escrow drained after thaw"); + assertEq(pAudit.escrow.tokensThawing, 0, "no more thawing"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 4: Cancel by payer (scoped) via RC callback chain + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario4_ScopedCancelByPayer() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA( + indexer, + 100 ether, + 1 ether, + 3600, + terms + ); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Read activeTermsHash for scoped cancel + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + bytes32 activeTermsHash = rcAgreement.activeTermsHash; + assertTrue(activeTermsHash != bytes32(0), "activeTermsHash should be set"); + + // Payer (RAM) calls RC's scoped cancel → triggers SS cancelByPayer callback + // RAM is the payer, so it must make the call + vm.prank(address(ram)); + recurringCollector.cancel(agreementId, activeTermsHash, SCOPE_ACTIVE); + + // Verify RC state: CanceledByPayer + rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByPayer), + "RC: canceled by payer" + ); + + // Verify SS state reflects cancellation + IIndexingAgreement.AgreementWrapper memory ssAgreement = subgraphService.getIndexingAgreement(agreementId); + assertEq( + uint8(ssAgreement.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByPayer), + "SS: reflects payer cancellation" + ); + + // Reconcile RAM + ram.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + + IRecurringAgreementHelper.GlobalAudit memory gAudit = ramHelper.auditGlobal(); + assertEq(gAudit.sumMaxNextClaimAll, 0, "global maxNextClaim zeroed after payer cancel"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 5: JIT top-up — Low escrow → Collect triggers deposit + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario5_JITTopUp() public { + // Switch RAM to JustInTime escrow basis — no proactive deposits + vm.prank(operator); + ram.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // In JIT mode, reconcileProvider should thaw everything + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + // Advance time for collection + uint256 collectSeconds = 600; // 10 minutes + skip(collectSeconds); + + // Add provision tokens for stake locking + uint256 expectedTokens = terms.tokensPerSecond * collectSeconds; + uint256 tokensToLock = expectedTokens * STAKE_TO_FEES_RATIO; + _mintTokens(indexer.addr, tokensToLock); + vm.startPrank(indexer.addr); + token.approve(address(staking), tokensToLock); + staking.stakeTo(indexer.addr, tokensToLock); + staking.addToProvision(indexer.addr, address(subgraphService), tokensToLock); + vm.stopPrank(); + + vm.roll(block.number + EPOCH_LENGTH); + + // Collect — this triggers RC.collect → RAM.beforeCollection (JIT deposit) → payment + uint256 tokensCollected = _collectIndexingFees(indexer, agreementId, 0, keccak256("poi-jit"), block.number - 1); + + // Verify collection succeeded despite JIT mode (beforeCollection topped up escrow) + assertTrue(tokensCollected > 0, "JIT: collection should succeed"); + + // Indexer should have received tokens + uint256 protocolBurn = tokensCollected.mulPPMRoundUp(PROTOCOL_PAYMENT_CUT); + assertTrue(tokensCollected - protocolBurn > 0, "JIT: indexer received tokens"); + } +} diff --git a/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol new file mode 100644 index 000000000..d20a8e347 --- /dev/null +++ b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol @@ -0,0 +1,629 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; +import { IRecurringAgreementHelper } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementHelper.sol"; +import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol"; +import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { PPMMath } from "horizon/libraries/PPMMath.sol"; + +import { IndexingAgreement } from "subgraph-service/libraries/IndexingAgreement.sol"; + +import { FullStackHarness } from "../harness/FullStackHarness.t.sol"; + +/// @title AgreementLifecycleAdvancedTest +/// @notice Advanced integration tests: indexing rewards alongside fees, escrow transitions, +/// multi-agreement isolation, and reward denial scenarios. +contract AgreementLifecycleAdvancedTest is FullStackHarness { + using PPMMath for uint256; + + bytes32 internal constant SUBGRAPH_DEPLOYMENT = keccak256("test-subgraph-deployment"); + uint256 internal constant INDEXER_TOKENS = 10_000 ether; + + IndexerSetup internal indexer; + + function setUp() public override { + super.setUp(); + indexer = _setupIndexer("indexer1", SUBGRAPH_DEPLOYMENT, INDEXER_TOKENS); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 11: Indexing rewards alongside indexing fees + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario11_RewardsAndFeesCoexist() public { + // -- Setup agreement for indexing fees -- + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Advance time for both collection types + uint256 collectSeconds = 1800; + skip(collectSeconds); + vm.roll(block.number + EPOCH_LENGTH); + + // Add provision for stake locking (both fee types lock stake) + uint256 expectedFeeTokens = terms.tokensPerSecond * collectSeconds; + // Estimate rewards roughly — provision * rewardsPerSignal PPM + uint256 estimatedRewards = indexer.provisionTokens.mulPPM(REWARDS_PER_SIGNAL); + uint256 totalToLock = (expectedFeeTokens + estimatedRewards) * STAKE_TO_FEES_RATIO; + _mintTokens(indexer.addr, totalToLock); + vm.startPrank(indexer.addr); + token.approve(address(staking), totalToLock); + staking.stakeTo(indexer.addr, totalToLock); + staking.addToProvision(indexer.addr, address(subgraphService), totalToLock); + vm.stopPrank(); + + uint256 indexerBalanceBefore = token.balanceOf(indexer.addr); + + // -- Collect indexing fees (via RC → RAM → PaymentsEscrow) -- + uint256 feeTokens = _collectIndexingFees(indexer, agreementId, 0, keccak256("poi-fees"), block.number - 1); + assertTrue(feeTokens > 0, "indexing fee collection succeeded"); + + uint256 indexerBalanceAfterFees = token.balanceOf(indexer.addr); + uint256 feeProtocolCut = feeTokens.mulPPMRoundUp(PROTOCOL_PAYMENT_CUT); + assertEq( + indexerBalanceAfterFees - indexerBalanceBefore, + feeTokens - feeProtocolCut, + "indexer received fee tokens minus protocol cut" + ); + + // -- Collect indexing rewards (via RewardsManager → minting) -- + // Advance one more epoch so POI is fresh + vm.roll(block.number + EPOCH_LENGTH); + + bytes memory rewardData = abi.encode( + indexer.allocationId, + keccak256("poi-rewards"), + _getHardcodedPoiMetadata() + ); + + vm.prank(indexer.addr); + uint256 rewardTokens = subgraphService.collect( + indexer.addr, + IGraphPayments.PaymentTypes.IndexingRewards, + rewardData + ); + + // Rewards may be zero if allocation was created in current epoch + // (the mock rewards manager calculates based on allocation tokens * rewardsPerSignal) + uint256 indexerBalanceAfterRewards = token.balanceOf(indexer.addr); + if (rewardTokens > 0) { + assertTrue(indexerBalanceAfterRewards > indexerBalanceAfterFees, "indexer balance increased from rewards"); + } + + // -- Verify agreement state is still active -- + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "agreement still active after both collection types" + ); + + // -- Verify RAM escrow tracking is consistent -- + IRecurringAgreementHelper.ProviderAudit memory pAudit = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertTrue(pAudit.sumMaxNextClaim > 0, "RAM still tracks the agreement"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 12: Reward denial — fees still flow independently + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario12_RewardDenialFeesContinue() public { + // -- Setup agreement for indexing fees -- + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Deny the subgraph in rewards manager + rewardsManager.setDenied(SUBGRAPH_DEPLOYMENT, true); + + // Advance time + skip(1800); + vm.roll(block.number + EPOCH_LENGTH); + + // Add provision for stake locking + uint256 expectedFeeTokens = terms.tokensPerSecond * 1800; + uint256 tokensToLock = expectedFeeTokens * STAKE_TO_FEES_RATIO; + _mintTokens(indexer.addr, tokensToLock); + vm.startPrank(indexer.addr); + token.approve(address(staking), tokensToLock); + staking.stakeTo(indexer.addr, tokensToLock); + staking.addToProvision(indexer.addr, address(subgraphService), tokensToLock); + vm.stopPrank(); + + // -- Indexing fees still work despite subgraph denial -- + uint256 feeTokens = _collectIndexingFees(indexer, agreementId, 0, keccak256("poi-denied"), block.number - 1); + assertTrue(feeTokens > 0, "fees collected despite reward denial"); + + // -- Agreement remains active -- + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "agreement active despite denial" + ); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 6: Escrow basis transitions under active agreement + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario6_EscrowBasisTransitions() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA( + indexer, + 100 ether, + 1 ether, + 3600, + terms + ); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + _offerAndAccept(indexer, rca); + + // Full mode: escrow fully deposited + IRecurringAgreementHelper.ProviderAudit memory pAudit = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertEq(pAudit.escrow.balance, maxClaim, "Full: escrow deposited"); + + // Switch to OnDemand + vm.prank(operator); + ram.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.OnDemand); + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + // OnDemand holds at sumMaxNextClaim level (same as Full when balance == max) + assertEq(pAudit.escrow.balance, maxClaim, "OnDemand: balance unchanged when already at max"); + + // Switch to JustInTime — should start thawing everything + vm.prank(operator); + ram.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.JustInTime); + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(pAudit.escrow.tokensThawing, maxClaim, "JIT: thawing everything"); + + // Switch back to Full — should deposit again after thaw completes + vm.prank(operator); + ram.setEscrowBasis(IRecurringEscrowManagement.EscrowBasis.Full); + + skip(1 days + 1); // wait for thaw + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(pAudit.escrow.balance, maxClaim, "Full (restored): escrow re-deposited"); + assertEq(pAudit.escrow.tokensThawing, 0, "Full (restored): no thawing"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 10: Collect with stake locking verification + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario10_StakeLocking() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + skip(600); + vm.roll(block.number + EPOCH_LENGTH); + + uint256 expectedTokens = terms.tokensPerSecond * 600; + uint256 expectedLocked = expectedTokens * STAKE_TO_FEES_RATIO; + + // Add provision for locking + _mintTokens(indexer.addr, expectedLocked); + vm.startPrank(indexer.addr); + token.approve(address(staking), expectedLocked); + staking.stakeTo(indexer.addr, expectedLocked); + staking.addToProvision(indexer.addr, address(subgraphService), expectedLocked); + vm.stopPrank(); + + uint256 lockedBefore = subgraphService.feesProvisionTracker(indexer.addr); + + uint256 tokensCollected = _collectIndexingFees( + indexer, + agreementId, + 0, + keccak256("poi-lock"), + block.number - 1 + ); + + uint256 lockedAfter = subgraphService.feesProvisionTracker(indexer.addr); + uint256 actualLocked = tokensCollected * STAKE_TO_FEES_RATIO; + + assertEq(lockedAfter - lockedBefore, actualLocked, "stake locked = tokensCollected * stakeToFeesRatio"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 7: Multi-agreement isolation + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario7_MultiAgreementIsolation() public { + // Setup a second indexer with its own allocation + bytes32 subgraph2 = keccak256("test-subgraph-deployment-2"); + IndexerSetup memory indexer2 = _setupIndexer("indexer2", subgraph2, INDEXER_TOKENS); + + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + // Agreement 1: indexer1 + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _buildRCA( + indexer, + 100 ether, + 1 ether, + 3600, + terms + ); + bytes16 agreement1 = _offerAndAccept(indexer, rca1); + + // Agreement 2: indexer2 (different nonce needed since payer+dataService is same) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _buildRCAEx( + indexer2, + 200 ether, + 2 ether, + 7200, + terms, + 2, // nonce + 0 // conditions + ); + _ramOffer(rca2); + bytes16 agreement2 = _ssAccept(indexer2, rca2); + + // Verify both tracked in RAM + IRecurringAgreementHelper.GlobalAudit memory gAudit = ramHelper.auditGlobal(); + assertEq(gAudit.collectorCount, 1, "single collector"); + + uint256 maxClaim1 = 1 ether * 3600 + 100 ether; + uint256 maxClaim2 = 2 ether * 7200 + 200 ether; + + IRecurringAgreementHelper.ProviderAudit memory p1 = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertEq(p1.sumMaxNextClaim, maxClaim1, "indexer1 maxNextClaim"); + + IRecurringAgreementHelper.ProviderAudit memory p2 = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer2.addr + ); + assertEq(p2.sumMaxNextClaim, maxClaim2, "indexer2 maxNextClaim"); + + // Collect on agreement 1 only + skip(600); + vm.roll(block.number + EPOCH_LENGTH); + _addProvisionTokens(indexer, terms.tokensPerSecond * 600 * STAKE_TO_FEES_RATIO); + + uint256 collected = _collectIndexingFees(indexer, agreement1, 0, keccak256("poi-multi"), block.number - 1); + assertTrue(collected > 0, "collection succeeded on agreement 1"); + + // Verify agreement 2 state is completely unaffected + IRecurringCollector.AgreementData memory rc2 = recurringCollector.getAgreement(agreement2); + assertEq(uint8(rc2.state), uint8(IRecurringCollector.AgreementState.Accepted), "agreement 2 still accepted"); + assertEq(rc2.lastCollectionAt, 0, "agreement 2 never collected"); + + // Verify indexer2's escrow unchanged + p2 = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer2.addr); + assertEq(p2.sumMaxNextClaim, maxClaim2, "indexer2 maxNextClaim unchanged after indexer1 collection"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 8: Expired offer cleanup + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario8_ExpiredOfferCleanup() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA( + indexer, + 100 ether, + 1 ether, + 3600, + terms + ); + uint256 maxClaim = 1 ether * 3600 + 100 ether; + + // Offer but DON'T accept + _ramOffer(rca); + + // Verify RAM tracks it + IRecurringAgreementHelper.ProviderAudit memory pAudit = ramHelper.auditProvider( + IAgreementCollector(address(recurringCollector)), + indexer.addr + ); + assertEq(pAudit.sumMaxNextClaim, maxClaim, "tracked after offer"); + assertEq(pAudit.escrow.balance, maxClaim, "escrow deposited for offer"); + + // Before deadline: reconcile should NOT remove + (uint256 removed, ) = ramHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(removed, 0, "not removable before deadline"); + + // Warp past deadline (1 hour) + skip(1 hours + 1); + + // Now reconcile should remove the expired offer + (removed, ) = ramHelper.reconcile(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(removed, 1, "removed after deadline"); + + // maxNextClaim zeroed + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(pAudit.sumMaxNextClaim, 0, "maxNextClaim zeroed"); + + // Escrow should be thawing + assertTrue(pAudit.escrow.tokensThawing > 0, "escrow thawing"); + + // Wait for thaw and drain + skip(1 days + 1); + ram.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + + pAudit = ramHelper.auditProvider(IAgreementCollector(address(recurringCollector)), indexer.addr); + assertEq(pAudit.escrow.balance, 0, "escrow drained"); + assertEq(pAudit.escrow.tokensThawing, 0, "no more thawing"); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 9: Agreement with eligibility check + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario9_EligibilityCheck_Eligible() public { + // RAM implements IProviderEligibility. With no oracle set, isEligible returns true. + // Build RCA with CONDITION_ELIGIBILITY_CHECK flag set. + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + uint16 eligibilityCondition = recurringCollector.CONDITION_ELIGIBILITY_CHECK(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCAEx( + indexer, + 0, + 1 ether, + 3600, + terms, + 1, + eligibilityCondition + ); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Advance time and collect — should succeed (RAM has no oracle, returns eligible) + skip(600); + vm.roll(block.number + EPOCH_LENGTH); + _addProvisionTokens(indexer, terms.tokensPerSecond * 600 * STAKE_TO_FEES_RATIO); + + uint256 collected = _collectIndexingFees(indexer, agreementId, 0, keccak256("poi-elig"), block.number - 1); + assertTrue(collected > 0, "collection succeeded with eligibility check (no oracle = eligible)"); + } + + function test_Scenario9_EligibilityCheck_NotEligible() public { + // Deploy a mock oracle that returns false for our indexer + MockEligibilityOracle oracle = new MockEligibilityOracle(); + oracle.setEligible(indexer.addr, false); + + // Set the oracle on RAM + vm.prank(governor); + ram.setProviderEligibilityOracle(IProviderEligibility(address(oracle))); + + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + uint16 eligibilityCondition = recurringCollector.CONDITION_ELIGIBILITY_CHECK(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCAEx( + indexer, + 0, + 1 ether, + 3600, + terms, + 1, + eligibilityCondition + ); + + bytes16 agreementId = _offerAndAccept(indexer, rca); + + skip(600); + vm.roll(block.number + EPOCH_LENGTH); + _addProvisionTokens(indexer, terms.tokensPerSecond * 600 * STAKE_TO_FEES_RATIO); + + // Collection should revert because eligibility check returns false + bytes memory collectData = abi.encode( + agreementId, + abi.encode( + IndexingAgreement.CollectIndexingFeeDataV1({ + entities: 0, + poi: keccak256("poi-inelig"), + poiBlockNumber: block.number - 1, + metadata: "", + maxSlippage: type(uint256).max + }) + ) + ); + + vm.prank(indexer.addr); + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorCollectionNotEligible.selector, + agreementId, + indexer.addr + ) + ); + subgraphService.collect(indexer.addr, IGraphPayments.PaymentTypes.IndexingFee, collectData); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 13: Close allocation with active agreement + // ═══════════════════════════════════════════════════════════════════ + + function test_Scenario13_CloseAllocationCancelsAgreement() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // blockClosingAllocationWithActiveAgreement is false by default + // Closing allocation should auto-cancel the agreement + + vm.prank(indexer.addr); + subgraphService.stopService(indexer.addr, abi.encode(indexer.allocationId)); + + // Verify agreement is canceled in RC + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "agreement canceled when allocation closed" + ); + + // Verify SS no longer has active agreement for this allocation + IIndexingAgreement.AgreementWrapper memory wrapper = subgraphService.getIndexingAgreement(agreementId); + assertEq( + uint8(wrapper.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "SS reflects cancellation" + ); + } + + function test_Scenario13_CloseAllocationBlockedByActiveAgreement() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Enable the block + vm.prank(governor); + subgraphService.setBlockClosingAllocationWithActiveAgreement(true); + + // Closing allocation should revert + vm.prank(indexer.addr); + vm.expectRevert( + abi.encodeWithSelector( + ISubgraphService.SubgraphServiceAllocationHasActiveAgreement.selector, + indexer.allocationId, + agreementId + ) + ); + subgraphService.stopService(indexer.addr, abi.encode(indexer.allocationId)); + + // Agreement should still be active + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "agreement still active" + ); + } + + // ═══════════════════════════════════════════════════════════════════ + // Scenario 14: Cancel with below-minimum provision (bug repro) + // ═══════════════════════════════════════════════════════════════════ + + /// @notice An indexer whose provision drops below minimum should still be + /// able to cancel their own agreement. Cancel is an exit path and must not + /// be gated by VALID_PROVISION. Currently reverts — this test demonstrates + /// the bug described in CancelAgreementProvisionCheck task. + function test_Scenario14_CancelWithBelowMinimumProvision() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Reduce indexer's provision below minimum by thawing most of it + uint256 tokensToThaw = indexer.provisionTokens - (MINIMUM_PROVISION_TOKENS / 2); + vm.startPrank(indexer.addr); + staking.thaw(indexer.addr, address(subgraphService), tokensToThaw); + vm.stopPrank(); + + // Skip past thawing period + skip(MAX_WAIT_PERIOD + 1); + + // Deprovision the thawed tokens + vm.prank(indexer.addr); + staking.deprovision(indexer.addr, address(subgraphService), 0); + + // Verify provision is below minimum + uint256 available = staking.getProviderTokensAvailable(indexer.addr, address(subgraphService)); + assertTrue(available < MINIMUM_PROVISION_TOKENS, "provision should be below minimum"); + + // Cancel should succeed — it's an exit path + vm.prank(indexer.addr); + subgraphService.cancelIndexingAgreement(indexer.addr, agreementId); + + // Verify agreement is canceled + IRecurringCollector.AgreementData memory rcAgreement = recurringCollector.getAgreement(agreementId); + assertEq( + uint8(rcAgreement.state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "agreement should be canceled despite below-minimum provision" + ); + } + + // ── Helpers ── + + function _getHardcodedPoiMetadata() internal view returns (bytes memory) { + return abi.encode(block.number, bytes32("PUBLIC_POI1"), uint8(0), uint8(0), uint256(0)); + } +} + +/// @notice Mock eligibility oracle for testing +contract MockEligibilityOracle { + mapping(address => bool) private _eligible; + bool private _defaultEligible = true; + + function setEligible(address provider, bool eligible) external { + _eligible[provider] = eligible; + if (!eligible) _defaultEligible = false; + } + + function isEligible(address provider) external view returns (bool) { + if (!_defaultEligible && !_eligible[provider]) return false; + return true; + } + + function supportsInterface(bytes4 interfaceId) external pure returns (bool) { + // IProviderEligibility: isEligible(address) = 0x66e305fd + return interfaceId == 0x66e305fd || interfaceId == 0x01ffc9a7; // IERC165 + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c555202ac..0554d28f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1317,6 +1317,9 @@ importers: '@graphprotocol/issuance': specifier: workspace:^ version: link:../issuance + '@graphprotocol/subgraph-service': + specifier: workspace:^ + version: link:../subgraph-service '@openzeppelin/contracts': specifier: ^5.4.0 version: 5.4.0 From 3bac236b2c620f6c43435ee06cd35b951cb95000 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 09:24:57 +0000 Subject: [PATCH 076/157] feat(contracts): add getIssuanceAllocator to IIssuanceTarget interface Every issuance target should expose its allocator. Add getIssuanceAllocator() returning IIssuanceAllocationDistribution to IIssuanceTarget. Implement in RecurringAgreementManager (reads from storage), DirectAllocation (stores and returns), and RewardsManager (existing impl, moved from IRewardsManager to IIssuanceTarget). Also change IIssuanceTarget.setIssuanceAllocator parameter from address to IIssuanceAllocationDistribution for compile-time type safety. --- .../unit/rewards/rewards-interface.test.ts | 4 +- .../contracts/rewards/RewardsManager.sol | 17 ++++--- packages/deployment/lib/abis.ts | 2 +- .../contracts/rewards/IRewardsManager.sol | 8 --- .../issuance/allocate/IIssuanceTarget.sol | 15 +++++- .../agreement/RecurringAgreementManager.sol | 21 +++++--- .../contracts/allocate/DirectAllocation.sol | 51 +++++++++++++++++-- .../test/allocate/MockNotificationTracker.sol | 8 ++- .../test/allocate/MockReentrantTarget.sol | 9 +++- .../test/allocate/MockRevertingTarget.sol | 10 +++- .../test/allocate/MockSimpleTarget.sol | 8 ++- .../unit/agreement-manager/approver.t.sol | 5 +- .../agreement-manager/branchCoverage.t.sol | 5 +- .../unit/agreement-manager/callbackGas.t.sol | 3 +- .../agreement-manager/ensureDistributed.t.sol | 21 ++++---- .../test/unit/allocator/distribution.t.sol | 3 +- .../unit/allocator/interfaceIdStability.t.sol | 2 +- .../direct-allocation/DirectAllocation.t.sol | 50 ++++++++++++++++-- .../indexing-agreement/cancel.t.sol | 4 +- .../test/harness/FullStackHarness.t.sol | 3 +- .../test/harness/RealStackHarness.t.sol | 3 +- 21 files changed, 189 insertions(+), 63 deletions(-) diff --git a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts index 63280f5e8..7bbfebe6b 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts @@ -54,11 +54,11 @@ describe('RewardsManager interfaces', () => { }) it('IIssuanceTarget should have stable interface ID', () => { - expect(IIssuanceTarget__factory.interfaceId).to.equal('0xaee4dc43') + expect(IIssuanceTarget__factory.interfaceId).to.equal('0x19f6601a') }) it('IRewardsManager should have stable interface ID', () => { - expect(IRewardsManager__factory.interfaceId).to.equal('0x337b092e') + expect(IRewardsManager__factory.interfaceId).to.equal('0x8469b577') }) }) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index a0ca5ca20..f251dc5f8 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -173,24 +173,25 @@ contract RewardsManager is * Note that the IssuanceAllocator can be set to the zero address to disable use of an allocator, and * use the local `issuancePerBlock` variable instead to control issuance. */ - function setIssuanceAllocator(address newIssuanceAllocator) external override onlyGovernor { - if (address(issuanceAllocator) != newIssuanceAllocator) { + function setIssuanceAllocator(IIssuanceAllocationDistribution newIssuanceAllocator) external override onlyGovernor { + if (issuanceAllocator != newIssuanceAllocator) { // Update rewards calculation before changing the issuance allocator updateAccRewardsPerSignal(); // Check that the contract supports the IIssuanceAllocationDistribution interface // Allow zero address to disable the allocator - if (newIssuanceAllocator != address(0)) { + if (address(newIssuanceAllocator) != address(0)) { // solhint-disable-next-line gas-small-strings require( - IERC165(newIssuanceAllocator).supportsInterface(type(IIssuanceAllocationDistribution).interfaceId), + IERC165(address(newIssuanceAllocator)).supportsInterface( + type(IIssuanceAllocationDistribution).interfaceId + ), "Contract does not support IIssuanceAllocationDistribution interface" ); } - address oldIssuanceAllocator = address(issuanceAllocator); - issuanceAllocator = IIssuanceAllocationDistribution(newIssuanceAllocator); - emit IssuanceAllocatorSet(oldIssuanceAllocator, newIssuanceAllocator); + emit IssuanceAllocatorSet(issuanceAllocator, newIssuanceAllocator); + issuanceAllocator = newIssuanceAllocator; } } @@ -325,7 +326,7 @@ contract RewardsManager is } /** - * @inheritdoc IRewardsManager + * @inheritdoc IIssuanceTarget */ function getIssuanceAllocator() external view override returns (IIssuanceAllocationDistribution) { return issuanceAllocator; diff --git a/packages/deployment/lib/abis.ts b/packages/deployment/lib/abis.ts index e9894d213..0e442edbe 100644 --- a/packages/deployment/lib/abis.ts +++ b/packages/deployment/lib/abis.ts @@ -21,7 +21,7 @@ function loadAbi(artifactPath: string): Abi { // Verified by tests: packages/issuance/testing/tests/allocate/InterfaceIdStability.test.ts // and packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts export const IERC165_INTERFACE_ID = '0x01ffc9a7' as const -export const IISSUANCE_TARGET_INTERFACE_ID = '0xaee4dc43' as const +export const IISSUANCE_TARGET_INTERFACE_ID = '0x19f6601a' as const export const IREWARDS_MANAGER_INTERFACE_ID = '0xa0a2f219' as const export const REWARDS_MANAGER_ABI = loadAbi( diff --git a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol index 205bde73c..688c9469d 100644 --- a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol @@ -2,7 +2,6 @@ pragma solidity ^0.7.6 || ^0.8.0; -import { IIssuanceAllocationDistribution } from "../../issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IRewardsIssuer } from "./IRewardsIssuer.sol"; /** @@ -179,13 +178,6 @@ interface IRewardsManager { */ function subgraphService() external view returns (IRewardsIssuer); - /** - * @notice Get the issuance allocator address - * @dev When set, this allocator controls issuance distribution instead of issuancePerBlock - * @return The issuance allocator contract (zero address if not set) - */ - function getIssuanceAllocator() external view returns (IIssuanceAllocationDistribution); - /** * @notice Get the reclaim address for a specific reason * @param reason The reclaim reason identifier diff --git a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol index 90a311556..ed9f60b8f 100644 --- a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol +++ b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol @@ -2,6 +2,8 @@ pragma solidity ^0.7.6 || ^0.8.0; +import { IIssuanceAllocationDistribution } from "./IIssuanceAllocationDistribution.sol"; + /** * @title IIssuanceTarget * @author Edge & Node @@ -13,7 +15,10 @@ interface IIssuanceTarget { * @param oldIssuanceAllocator Old issuance allocator address * @param newIssuanceAllocator New issuance allocator address */ - event IssuanceAllocatorSet(address indexed oldIssuanceAllocator, address indexed newIssuanceAllocator); + event IssuanceAllocatorSet( + IIssuanceAllocationDistribution indexed oldIssuanceAllocator, + IIssuanceAllocationDistribution indexed newIssuanceAllocator + ); /// @notice Emitted before the issuance allocation changes event BeforeIssuanceAllocationChange(); @@ -27,11 +32,17 @@ interface IIssuanceTarget { */ function beforeIssuanceAllocationChange() external; + /** + * @notice Returns the current issuance allocator + * @return The issuance allocator contract (zero address if not set) + */ + function getIssuanceAllocator() external view returns (IIssuanceAllocationDistribution); + /** * @notice Sets the issuance allocator for this target * @dev This function facilitates upgrades by providing a standard way for targets * to change their allocator. Implementations can define their own access control. * @param newIssuanceAllocator Address of the issuance allocator */ - function setIssuanceAllocator(address newIssuanceAllocator) external; + function setIssuanceAllocator(IIssuanceAllocationDistribution newIssuanceAllocator) external; } diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 881208eed..0c56f2185 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -254,6 +254,11 @@ contract RecurringAgreementManager is /// @inheritdoc IIssuanceTarget function beforeIssuanceAllocationChange() external virtual override {} + /// @inheritdoc IIssuanceTarget + function getIssuanceAllocator() external view virtual override returns (IIssuanceAllocationDistribution) { + return _getStorage().issuanceAllocator; + } + /// @inheritdoc IIssuanceTarget /// @dev The allocator is expected to call distributeIssuance() (bringing distribution up to /// the current block) before any configuration change. As a result, the same-block dedup in @@ -262,21 +267,23 @@ contract RecurringAgreementManager is /// in a standalone transaction to avoid interleaving with collection in the same block. /// Even if interleaved, the only effect is a one-block lag before the new allocator's /// distribution is picked up — corrected automatically on the next block. - function setIssuanceAllocator(address newIssuanceAllocator) external virtual override onlyRole(GOVERNOR_ROLE) { + function setIssuanceAllocator( + IIssuanceAllocationDistribution newIssuanceAllocator + ) external virtual override onlyRole(GOVERNOR_ROLE) { RecurringAgreementManagerStorage storage $ = _getStorage(); - if (address($.issuanceAllocator) == newIssuanceAllocator) return; + if (address($.issuanceAllocator) == address(newIssuanceAllocator)) return; - if (newIssuanceAllocator != address(0)) + if (address(newIssuanceAllocator) != address(0)) require( ERC165Checker.supportsInterface( - newIssuanceAllocator, + address(newIssuanceAllocator), type(IIssuanceAllocationDistribution).interfaceId ), - InvalidIssuanceAllocator(newIssuanceAllocator) + InvalidIssuanceAllocator(address(newIssuanceAllocator)) ); - emit IssuanceAllocatorSet(address($.issuanceAllocator), newIssuanceAllocator); - $.issuanceAllocator = IIssuanceAllocationDistribution(newIssuanceAllocator); + emit IssuanceAllocatorSet($.issuanceAllocator, newIssuanceAllocator); + $.issuanceAllocator = newIssuanceAllocator; } // -- IAgreementOwner -- diff --git a/packages/issuance/contracts/allocate/DirectAllocation.sol b/packages/issuance/contracts/allocate/DirectAllocation.sol index 91f153b5e..adecac694 100644 --- a/packages/issuance/contracts/allocate/DirectAllocation.sol +++ b/packages/issuance/contracts/allocate/DirectAllocation.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; @@ -24,6 +25,36 @@ import { ERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/int * @custom:security-contact Please email security+contracts@thegraph.com if you find any bugs. We might have an active bug bounty program. */ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { + // -- Namespaced Storage -- + + /// @notice ERC-7201 storage location for DirectAllocation + bytes32 private constant DIRECT_ALLOCATION_STORAGE_LOCATION = + // solhint-disable-next-line gas-small-strings + keccak256(abi.encode(uint256(keccak256("graphprotocol.storage.DirectAllocation")) - 1)) & + ~bytes32(uint256(0xff)); + + /// @notice Main storage structure for DirectAllocation using ERC-7201 namespaced storage + /// @param issuanceAllocator The issuance allocator that distributes tokens to this contract + /// @custom:storage-location erc7201:graphprotocol.storage.DirectAllocation + struct DirectAllocationData { + IIssuanceAllocationDistribution issuanceAllocator; + } + + /** + * @notice Returns the storage struct for DirectAllocation + * @return $ contract storage + */ + function _getDirectAllocationStorage() private pure returns (DirectAllocationData storage $) { + // solhint-disable-previous-line use-natspec + // Solhint does not support $ return variable in natspec + + bytes32 slot = DIRECT_ALLOCATION_STORAGE_LOCATION; + // solhint-disable-next-line no-inline-assembly + assembly { + $.slot := slot + } + } + // -- Custom Errors -- /// @notice Thrown when token transfer fails @@ -89,9 +120,19 @@ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { */ function beforeIssuanceAllocationChange() external virtual override {} - /** - * @dev No-op for DirectAllocation; issuanceAllocator is not stored. - * @inheritdoc IIssuanceTarget - */ - function setIssuanceAllocator(address issuanceAllocator) external virtual override onlyRole(GOVERNOR_ROLE) {} + /// @inheritdoc IIssuanceTarget + function getIssuanceAllocator() external view virtual override returns (IIssuanceAllocationDistribution) { + return _getDirectAllocationStorage().issuanceAllocator; + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator( + IIssuanceAllocationDistribution newIssuanceAllocator + ) external virtual override onlyRole(GOVERNOR_ROLE) { + DirectAllocationData storage $ = _getDirectAllocationStorage(); + if (address(newIssuanceAllocator) == address($.issuanceAllocator)) return; + + emit IssuanceAllocatorSet($.issuanceAllocator, newIssuanceAllocator); + $.issuanceAllocator = newIssuanceAllocator; + } } diff --git a/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol b/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol index a33212282..2b5fb5aec 100644 --- a/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol +++ b/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -30,7 +31,12 @@ contract MockNotificationTracker is IIssuanceTarget, ERC165 { } /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external pure override {} + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override {} /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { diff --git a/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol b/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol index 484648805..ffa4e5aae 100644 --- a/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol @@ -85,8 +85,13 @@ contract MockReentrantTarget is IIssuanceTarget, ERC165 { } /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external override { - issuanceAllocator = _issuanceAllocator; + function getIssuanceAllocator() external view override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(issuanceAllocator); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external override { + issuanceAllocator = address(_issuanceAllocator); } /// @inheritdoc ERC165 diff --git a/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol b/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol index 27522e5a4..eb0ec1734 100644 --- a/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -23,7 +24,14 @@ contract MockRevertingTarget is IIssuanceTarget, ERC165 { /** * @inheritdoc IIssuanceTarget */ - function setIssuanceAllocator(address _issuanceAllocator) external pure override { + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /** + * @inheritdoc IIssuanceTarget + */ + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override { // No-op } diff --git a/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol b/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol index 311e1f03c..fddaed78b 100644 --- a/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -15,7 +16,12 @@ contract MockSimpleTarget is IIssuanceTarget, ERC165 { function beforeIssuanceAllocationChange() external pure override {} /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external pure override {} + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override {} /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol index f38db6a7c..488b74729 100644 --- a/packages/issuance/test/unit/agreement-manager/approver.t.sol +++ b/packages/issuance/test/unit/agreement-manager/approver.t.sol @@ -8,6 +8,7 @@ import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/ import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IAgreementCollector, OFFER_TYPE_NEW @@ -57,13 +58,13 @@ contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerShare MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.expectRevert(); vm.prank(nonGovernor); - agreementManager.setIssuanceAllocator(address(alloc)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(alloc))); } function test_SetIssuanceAllocator_Governor() public { MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(alloc)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(alloc))); } // -- View Function Tests -- diff --git a/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol index 2b7db27a4..6fd970144 100644 --- a/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol +++ b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol @@ -7,6 +7,7 @@ import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; @@ -36,7 +37,7 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage address(recurringCollector) ) ); - agreementManager.setIssuanceAllocator(address(recurringCollector)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(recurringCollector))); } /// @notice Setting allocator to an EOA (no code) also fails ERC165 check. @@ -44,7 +45,7 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage address eoa = makeAddr("randomEOA"); vm.prank(governor); vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); - agreementManager.setIssuanceAllocator(eoa); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(eoa)); } // ══════════════════════════════════════════════════════════════════════ diff --git a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol index e4870924f..efe2abce6 100644 --- a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol +++ b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; @@ -36,7 +37,7 @@ contract RecurringAgreementManagerCallbackGasTest is RecurringAgreementManagerSh vm.label(address(mockAllocator), "MockIssuanceAllocator"); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } // ==================== beforeCollection gas ==================== diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index d84782d37..ec9542977 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManager } from "contracts/agreement/RecurringAgreementManager.sol"; @@ -23,7 +24,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.label(address(mockAllocator), "MockIssuanceAllocator"); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } // ==================== setIssuanceAllocator ==================== @@ -33,26 +34,26 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.prank(governor); vm.expectEmit(address(agreementManager)); - emit IIssuanceTarget.IssuanceAllocatorSet(address(mockAllocator), address(newAllocator)); - agreementManager.setIssuanceAllocator(address(newAllocator)); + emit IIssuanceTarget.IssuanceAllocatorSet(IIssuanceAllocationDistribution(address(mockAllocator)), IIssuanceAllocationDistribution(address(newAllocator))); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(newAllocator))); } function test_SetIssuanceAllocator_Revert_WhenNotGovernor() public { vm.prank(operator); vm.expectRevert(); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } function test_SetIssuanceAllocator_CanSetToZero() public { vm.prank(governor); - agreementManager.setIssuanceAllocator(address(0)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(0))); // Should not revert — _ensureIncomingDistributionToCurrentBlock is a no-op with zero address } function test_SetIssuanceAllocator_NoopWhenUnchanged() public { vm.prank(governor); vm.recordLogs(); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); Vm.Log[] memory logs = vm.getRecordedLogs(); assertEq(logs.length, 0, "should not emit when address unchanged"); } @@ -201,7 +202,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan function test_EnsureDistributed_NoopWhenAllocatorNotSet() public { // Clear allocator vm.prank(governor); - agreementManager.setIssuanceAllocator(address(0)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(0))); (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, @@ -309,14 +310,14 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.expectRevert( abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, notAllocator) ); - agreementManager.setIssuanceAllocator(notAllocator); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(notAllocator)); } function test_SetIssuanceAllocator_Revert_WhenEOA() public { address eoa = makeAddr("eoa"); vm.prank(governor); vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); - agreementManager.setIssuanceAllocator(eoa); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(eoa)); } // ==================== setIssuanceAllocator switches allocator ==================== @@ -334,7 +335,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan // Switch allocator MockIssuanceAllocator newAllocator = new MockIssuanceAllocator(token, address(agreementManager)); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(newAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(newAllocator))); // Next block: new allocator should be called via _updateEscrow vm.roll(block.number + 1); diff --git a/packages/issuance/test/unit/allocator/distribution.t.sol b/packages/issuance/test/unit/allocator/distribution.t.sol index fb94737de..196317dcf 100644 --- a/packages/issuance/test/unit/allocator/distribution.t.sol +++ b/packages/issuance/test/unit/allocator/distribution.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { TargetIssuancePerBlock, DistributionState, @@ -487,7 +488,7 @@ contract IssuanceAllocatorDistributionTest is IssuanceAllocatorSharedTest { _setIssuanceRate(ISSUANCE_PER_BLOCK); // Set up reentrant target - reentrantTarget.setIssuanceAllocator(address(allocator)); + reentrantTarget.setIssuanceAllocator(IIssuanceAllocationDistribution(address(allocator))); reentrantTarget.setReentrantAction(MockReentrantTarget.ReentrantAction.SetTargetAllocation1Param); // Adding the target should fail due to reentrancy in notification callback diff --git a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol index 463416bbd..aee42df80 100644 --- a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol +++ b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol @@ -40,7 +40,7 @@ contract AllocateInterfaceIdStabilityTest is Test { // -- DirectAllocation / shared interfaces -- function test_InterfaceId_IIssuanceTarget() public pure { - assertEq(type(IIssuanceTarget).interfaceId, bytes4(0xaee4dc43)); + assertEq(type(IIssuanceTarget).interfaceId, bytes4(0x19f6601a)); } function test_InterfaceId_ISendTokens() public pure { diff --git a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol index 112126a38..e318b05de 100644 --- a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol +++ b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol @@ -8,6 +8,7 @@ import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.so import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; @@ -133,15 +134,58 @@ contract DirectAllocationTest is Test { directAlloc.beforeIssuanceAllocationChange(); } - function test_SetIssuanceAllocator_NoOp() public { + function test_GetIssuanceAllocator_InitiallyZero() public view { + assertEq(address(directAlloc.getIssuanceAllocator()), address(0)); + } + + function test_SetIssuanceAllocator_UpdatesGetter() public { + address allocator = makeAddr("allocator"); + vm.prank(governor); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(allocator)); + assertEq(address(directAlloc.getIssuanceAllocator()), allocator); + } + + function test_SetIssuanceAllocator_EmitsEvent() public { + address allocator = makeAddr("allocator"); + vm.prank(governor); + vm.expectEmit(address(directAlloc)); + emit IIssuanceTarget.IssuanceAllocatorSet( + IIssuanceAllocationDistribution(address(0)), + IIssuanceAllocationDistribution(allocator) + ); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(allocator)); + } + + function test_SetIssuanceAllocator_EmitsEventWithOldValue() public { + address first = makeAddr("first"); + address second = makeAddr("second"); + vm.prank(governor); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(first)); + + vm.prank(governor); + vm.expectEmit(address(directAlloc)); + emit IIssuanceTarget.IssuanceAllocatorSet( + IIssuanceAllocationDistribution(first), + IIssuanceAllocationDistribution(second) + ); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(second)); + } + + function test_SetIssuanceAllocator_SkipsWhenSameValue() public { + address allocator = makeAddr("allocator"); + vm.prank(governor); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(allocator)); + vm.prank(governor); - directAlloc.setIssuanceAllocator(makeAddr("allocator")); + vm.recordLogs(); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(allocator)); + assertEq(vm.getRecordedLogs().length, 0); } function test_Revert_SetIssuanceAllocator_NonGovernor() public { vm.expectRevert(); vm.prank(unauthorized); - directAlloc.setIssuanceAllocator(makeAddr("allocator")); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(makeAddr("allocator"))); } // ==================== ERC-165 Interface Support ==================== diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index 0b5463cd4..3a8d0340f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -250,9 +250,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg // solhint-disable-next-line graph/func-name-mixedcase /// @notice An indexer whose provision drops below minimum should still be able /// to cancel their indexing agreement. Cancel is an exit path. - function test_SubgraphService_CancelIndexingAgreement_OK_WhenProvisionBelowMinimum( - Seed memory seed - ) public { + function test_SubgraphService_CancelIndexingAgreement_OK_WhenProvisionBelowMinimum(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); ( diff --git a/packages/testing/test/harness/FullStackHarness.t.sol b/packages/testing/test/harness/FullStackHarness.t.sol index 842ebe1a1..d095804f0 100644 --- a/packages/testing/test/harness/FullStackHarness.t.sol +++ b/packages/testing/test/harness/FullStackHarness.t.sol @@ -27,6 +27,7 @@ import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -291,7 +292,7 @@ abstract contract FullStackHarness is Test { ram.grantRole(OPERATOR_ROLE, operator); ram.grantRole(DATA_SERVICE_ROLE, address(subgraphService)); ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); - ram.setIssuanceAllocator(address(issuanceAllocator)); + ram.setIssuanceAllocator(IIssuanceAllocationDistribution(address(issuanceAllocator))); issuanceAllocator.setIssuancePerBlock(1 ether); issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); diff --git a/packages/testing/test/harness/RealStackHarness.t.sol b/packages/testing/test/harness/RealStackHarness.t.sol index db99ace6c..1d7cf6bcd 100644 --- a/packages/testing/test/harness/RealStackHarness.t.sol +++ b/packages/testing/test/harness/RealStackHarness.t.sol @@ -9,6 +9,7 @@ import { RecurringCollector } from "horizon/payments/collectors/RecurringCollect import { IssuanceAllocator } from "issuance/allocate/IssuanceAllocator.sol"; import { RecurringAgreementManager } from "issuance/agreement/RecurringAgreementManager.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; // Use the issuance IGraphToken for RAM/allocator (IERC20 + mint) import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; @@ -123,7 +124,7 @@ abstract contract RealStackHarness is Test { ram.grantRole(OPERATOR_ROLE, operator); ram.grantRole(DATA_SERVICE_ROLE, dataService); ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); - ram.setIssuanceAllocator(address(issuanceAllocator)); + ram.setIssuanceAllocator(IIssuanceAllocationDistribution(address(issuanceAllocator))); // Configure allocator: set total issuance rate, then allocate to RAM issuanceAllocator.setIssuancePerBlock(1 ether); issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); From a1af8b6f5394d9924107cd3e434872f1f36e4030 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:59:42 +0000 Subject: [PATCH 077/157] refactor(data-edge): upgrade to ethers v6 and @nomicfoundation plugins --- packages/data-edge/hardhat.config.ts | 31 ++---------- packages/data-edge/package.json | 45 ++++++----------- packages/data-edge/tasks/craft-calldata.ts | 6 +-- packages/data-edge/tasks/deploy.ts | 20 ++++---- packages/data-edge/tasks/post-calldata.ts | 18 +++---- packages/data-edge/test/dataedge.test.ts | 40 +++++---------- .../data-edge/test/eventful-dataedge.test.ts | 50 +++++++------------ 7 files changed, 68 insertions(+), 142 deletions(-) diff --git a/packages/data-edge/hardhat.config.ts b/packages/data-edge/hardhat.config.ts index 807580f49..de31cf40a 100644 --- a/packages/data-edge/hardhat.config.ts +++ b/packages/data-edge/hardhat.config.ts @@ -1,15 +1,12 @@ import '@typechain/hardhat' -// Plugins -import '@nomiclabs/hardhat-ethers' -import '@nomiclabs/hardhat-etherscan' -import '@nomiclabs/hardhat-waffle' +import '@nomicfoundation/hardhat-ethers' +import '@nomicfoundation/hardhat-chai-matchers' +import '@nomicfoundation/hardhat-verify' import 'hardhat-abi-exporter' import 'hardhat-gas-reporter' import 'hardhat-contract-sizer' -import '@openzeppelin/hardhat-upgrades' import 'solidity-coverage' -import '@tenderly/hardhat-tenderly' -import 'hardhat-secure-accounts' // for graph config +import 'hardhat-secure-accounts' // Tasks import './tasks/craft-calldata' import './tasks/post-calldata' @@ -29,20 +26,12 @@ interface NetworkConfig { const networkConfigs: NetworkConfig[] = [ { network: 'mainnet', chainId: 1 }, - { network: 'ropsten', chainId: 3 }, - { network: 'rinkeby', chainId: 4 }, - { network: 'kovan', chainId: 42 }, { network: 'sepolia', chainId: 11155111 }, { network: 'arbitrum-one', chainId: 42161, url: 'https://arb1.arbitrum.io/rpc', }, - { - network: 'arbitrum-goerli', - chainId: 421613, - url: 'https://goerli-rollup.arbitrum.io/rpc', - }, { network: 'arbitrum-sepolia', chainId: 421614, @@ -89,10 +78,6 @@ task('accounts', 'Prints the list of accounts', async (_, bre) => { // Config const config: HardhatUserConfig = { - graph: { - addressBook: process.env.ADDRESS_BOOK || 'addresses.json', - disableSecureAccounts: true, - }, paths: { sources: './contracts', tests: './test', @@ -140,10 +125,8 @@ const config: HardhatUserConfig = { etherscan: { apiKey: { mainnet: process.env.ETHERSCAN_API_KEY, - goerli: process.env.ETHERSCAN_API_KEY, sepolia: process.env.ETHERSCAN_API_KEY, arbitrumOne: process.env.ARBISCAN_API_KEY, - arbitrumGoerli: process.env.ARBISCAN_API_KEY, arbitrumSepolia: process.env.ARBISCAN_API_KEY, }, }, @@ -155,17 +138,13 @@ const config: HardhatUserConfig = { }, typechain: { outDir: 'build/types', - target: 'ethers-v5', + target: 'ethers-v6', }, abiExporter: { path: './build/abis', clear: false, flat: true, }, - tenderly: { - project: process.env.TENDERLY_PROJECT, - username: process.env.TENDERLY_USERNAME, - }, contractSizer: { alphaSort: true, runOnCompile: false, diff --git a/packages/data-edge/package.json b/packages/data-edge/package.json index c97514031..15b97d050 100644 --- a/packages/data-edge/package.json +++ b/packages/data-edge/package.json @@ -7,8 +7,6 @@ "license": "GPL-2.0-or-later", "main": "index.js", "scripts": { - "prepare": "cd ../.. && husky install packages/contracts/.husky", - "prepublishOnly": "scripts/prepublish", "build": "pnpm build:self", "build:self": "scripts/build", "clean": "rm -rf build/ cache/ dist/ reports/ artifacts/", @@ -35,43 +33,30 @@ "LICENSE" ], "devDependencies": { - "@ethersproject/abi": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/providers": "^5.7.0", - "@nomiclabs/hardhat-ethers": "^2.0.2", - "@nomiclabs/hardhat-etherscan": "^3.1.2", - "@nomiclabs/hardhat-waffle": "^2.0.1", - "@openzeppelin/contracts": "^4.5.0", - "@openzeppelin/hardhat-upgrades": "^1.8.2", - "@tenderly/api-client": "^1.0.13", - "@tenderly/hardhat-tenderly": "^1.0.13", - "@typechain/ethers-v5": "^10.2.1", - "@typechain/hardhat": "^6.1.6", + "@nomicfoundation/hardhat-chai-matchers": "catalog:", + "@nomicfoundation/hardhat-ethers": "catalog:", + "@nomicfoundation/hardhat-verify": "catalog:", + "@typechain/ethers-v6": "^0.5.0", + "@typechain/hardhat": "catalog:", "@types/mocha": "^9.0.0", - "@types/node": "^20.17.50", + "@types/node": "catalog:", "@types/sinon-chai": "^3.2.12", - "chai": "^4.2.0", - "dotenv": "^16.0.0", + "chai": "catalog:", + "dotenv": "catalog:", "eslint": "catalog:", - "ethereum-waffle": "^3.0.2", - "ethers": "^5.7.2", - "ethlint": "^1.2.5", + "ethers": "catalog:", "hardhat": "catalog:", "hardhat-abi-exporter": "^2.2.0", - "hardhat-contract-sizer": "^2.0.3", - "hardhat-gas-reporter": "^1.0.4", - "hardhat-secure-accounts": "0.0.6", - "husky": "^7.0.4", - "lint-staged": "^12.3.5", - "lodash": "^4.17.21", - "markdownlint-cli": "0.45.0", + "hardhat-contract-sizer": "catalog:", + "hardhat-gas-reporter": "catalog:", + "hardhat-secure-accounts": "catalog:", + "markdownlint-cli": "catalog:", "prettier": "catalog:", "prettier-plugin-solidity": "catalog:", "solhint": "catalog:", "solidity-coverage": "^0.8.16", - "truffle-flattener": "^1.4.4", - "ts-node": ">=8.0.0", - "typechain": "^8.3.0", + "ts-node": "catalog:", + "typechain": "catalog:", "typescript": "catalog:" } } diff --git a/packages/data-edge/tasks/craft-calldata.ts b/packages/data-edge/tasks/craft-calldata.ts index 8e285886c..855478f68 100644 --- a/packages/data-edge/tasks/craft-calldata.ts +++ b/packages/data-edge/tasks/craft-calldata.ts @@ -1,5 +1,3 @@ -import '@nomiclabs/hardhat-ethers' - import { Contract } from 'ethers' import { task } from 'hardhat/config' @@ -35,15 +33,13 @@ task('data:craft', 'Build calldata') .addParam('selector', 'Selector name') .addParam('data', 'Call data to post') .setAction(async (taskArgs, hre) => { - // parse input const edgeAddress = taskArgs.edge const calldata = taskArgs.data const selector = taskArgs.selector - // build data const abi = getAbiForSelector(selector) const contract = getContract(edgeAddress, abi, hre.ethers.provider) - const tx = await contract.populateTransaction[selector](calldata) + const tx = await contract[selector].populateTransaction(calldata) const txData = tx.data console.log(txData) }) diff --git a/packages/data-edge/tasks/deploy.ts b/packages/data-edge/tasks/deploy.ts index 0ad97d194..ca142b1e2 100644 --- a/packages/data-edge/tasks/deploy.ts +++ b/packages/data-edge/tasks/deploy.ts @@ -1,5 +1,3 @@ -import '@nomiclabs/hardhat-ethers' - import { promises as fs } from 'fs' import { task } from 'hardhat/config' @@ -31,25 +29,25 @@ task('data-edge:deploy', 'Deploy a DataEdge contract') console.log(`Deploying contract...`) const contract = await factory.deploy() - const tx = contract.deployTransaction + const tx = contract.deploymentTransaction()! - // The address the Contract WILL have once mined - console.log(`> deployer: ${await contract.signer.getAddress()}`) - console.log(`> contract: ${contract.address}`) + const contractAddress = await contract.getAddress() + const [signer] = await hre.ethers.getSigners() + console.log(`> deployer: ${await signer.getAddress()}`) + console.log(`> contract: ${contractAddress}`) console.log( - `> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`, + `> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${Number(tx.gasPrice) / 1e9} (gwei)`, ) - // The contract is NOT deployed yet; we must wait until it is mined - await contract.deployed() + await contract.waitForDeployment() console.log(`Done!`) // Update addresses.json - const chainId = hre.network.config.chainId.toString() + const chainId = hre.network.config.chainId!.toString() if (!addresses[chainId]) { addresses[chainId] = {} } const deployName = `${taskArgs.deployName}${taskArgs.contract}` - addresses[chainId][deployName] = contract.address + addresses[chainId][deployName] = contractAddress return fs.writeFile('addresses.json', JSON.stringify(addresses, null, 2) + '\n') }) diff --git a/packages/data-edge/tasks/post-calldata.ts b/packages/data-edge/tasks/post-calldata.ts index fbededfbc..edd455511 100644 --- a/packages/data-edge/tasks/post-calldata.ts +++ b/packages/data-edge/tasks/post-calldata.ts @@ -1,30 +1,28 @@ -import '@nomiclabs/hardhat-ethers' - import { task } from 'hardhat/config' task('data:post', 'Post calldata') .addParam('edge', 'Address of the data edge contract') .addParam('data', 'Call data to post') .setAction(async (taskArgs, hre) => { - // prepare data const edgeAddress = taskArgs.edge const txData = taskArgs.data + const [signer] = await hre.ethers.getSigners() const contract = await hre.ethers.getContractAt('DataEdge', edgeAddress) + const contractAddress = await contract.getAddress() const txRequest = { data: txData, - to: contract.address, + to: contractAddress, } - // send transaction console.log(`Sending data...`) - console.log(`> edge: ${contract.address}`) - console.log(`> sender: ${await contract.signer.getAddress()}`) + console.log(`> edge: ${contractAddress}`) + console.log(`> sender: ${await signer.getAddress()}`) console.log(`> payload: ${txData}`) - const tx = await contract.signer.sendTransaction(txRequest) + const tx = await signer.sendTransaction(txRequest) console.log( - `> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`, + `> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${Number(tx.gasPrice) / 1e9} (gwei)`, ) const rx = await tx.wait() - console.log('> rx: ', rx.status == 1 ? 'success' : 'failed') + console.log('> rx: ', rx!.status == 1 ? 'success' : 'failed') console.log(`Done!`) }) diff --git a/packages/data-edge/test/dataedge.test.ts b/packages/data-edge/test/dataedge.test.ts index 479758881..b96257786 100644 --- a/packages/data-edge/test/dataedge.test.ts +++ b/packages/data-edge/test/dataedge.test.ts @@ -1,57 +1,43 @@ -import '@nomiclabs/hardhat-ethers' - -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import { ethers } from 'hardhat' -import { DataEdge, DataEdge__factory } from '../build/types' - -const { getContractFactory, getSigners } = ethers -const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils +import { DataEdge } from '../build/types' describe('DataEdge', () => { let edge: DataEdge - let me: SignerWithAddress + let me: Awaited>[0] beforeEach(async () => { - ;[me] = await getSigners() + ;[me] = await ethers.getSigners() - const factory = (await getContractFactory('DataEdge', me)) as DataEdge__factory + const factory = await ethers.getContractFactory('DataEdge', me) edge = await factory.deploy() - await edge.deployed() + await edge.waitForDeployment() }) describe('submit data', () => { it('post any arbitrary data as selector', async () => { - // virtual function call const txRequest = { data: '0x123123', - to: edge.address, + to: await edge.getAddress(), } - // send transaction const tx = await me.sendTransaction(txRequest) const rx = await tx.wait() - // transaction must work - it just stores data - expect(rx.status).eq(1) + expect(rx!.status).eq(1) }) it('post long calldata', async () => { - // virtual function call - const selector = id('setEpochBlocksPayload(bytes)').slice(0, 10) - // calldata payload - const messageBlocks = hexlify(randomBytes(1000)) - const txCalldata = defaultAbiCoder.encode(['bytes'], [messageBlocks]) // we abi encode to allow the subgraph to decode it properly - const txData = hexConcat([selector, txCalldata]) - // craft full transaction + const selector = ethers.id('setEpochBlocksPayload(bytes)').slice(0, 10) + const messageBlocks = ethers.hexlify(ethers.randomBytes(1000)) + const txCalldata = ethers.AbiCoder.defaultAbiCoder().encode(['bytes'], [messageBlocks]) + const txData = ethers.concat([selector, txCalldata]) const txRequest = { data: txData, - to: edge.address, + to: await edge.getAddress(), } - // send transaction const tx = await me.sendTransaction(txRequest) const rx = await tx.wait() - // transaction must work - it just stores data - expect(rx.status).eq(1) + expect(rx!.status).eq(1) }) }) }) diff --git a/packages/data-edge/test/eventful-dataedge.test.ts b/packages/data-edge/test/eventful-dataedge.test.ts index 8bdf86a2e..974dde5dc 100644 --- a/packages/data-edge/test/eventful-dataedge.test.ts +++ b/packages/data-edge/test/eventful-dataedge.test.ts @@ -1,63 +1,47 @@ -import '@nomiclabs/hardhat-ethers' - -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import { ethers } from 'hardhat' -import { EventfulDataEdge, EventfulDataEdge__factory } from '../build/types' - -const { getContractFactory, getSigners } = ethers -const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils +import { EventfulDataEdge } from '../build/types' describe('EventfulDataEdge', () => { let edge: EventfulDataEdge - let me: SignerWithAddress + let me: Awaited>[0] beforeEach(async () => { - ;[me] = await getSigners() + ;[me] = await ethers.getSigners() - const factory = (await getContractFactory('EventfulDataEdge', me)) as EventfulDataEdge__factory + const factory = await ethers.getContractFactory('EventfulDataEdge', me) edge = await factory.deploy() - await edge.deployed() + await edge.waitForDeployment() }) describe('submit data', () => { it('post any arbitrary data as selector', async () => { - // virtual function call const txRequest = { data: '0x123123', - to: edge.address, + to: await edge.getAddress(), } - // send transaction const tx = await me.sendTransaction(txRequest) const rx = await tx.wait() - // transaction must work - it just stores data - expect(rx.status).eq(1) - // emit log event - const event = edge.interface.parseLog(rx.logs[0]).args - expect(event.data).eq(txRequest.data) + expect(rx!.status).eq(1) + const event = edge.interface.parseLog({ topics: rx!.logs[0].topics as string[], data: rx!.logs[0].data }) + expect(event!.args.data).eq(txRequest.data) }) it('post long calldata', async () => { - // virtual function call - const selector = id('setEpochBlocksPayload(bytes)').slice(0, 10) - // calldata payload - const messageBlocks = hexlify(randomBytes(1000)) - const txCalldata = defaultAbiCoder.encode(['bytes'], [messageBlocks]) // we abi encode to allow the subgraph to decode it properly - const txData = hexConcat([selector, txCalldata]) - // craft full transaction + const selector = ethers.id('setEpochBlocksPayload(bytes)').slice(0, 10) + const messageBlocks = ethers.hexlify(ethers.randomBytes(1000)) + const txCalldata = ethers.AbiCoder.defaultAbiCoder().encode(['bytes'], [messageBlocks]) + const txData = ethers.concat([selector, txCalldata]) const txRequest = { data: txData, - to: edge.address, + to: await edge.getAddress(), } - // send transaction const tx = await me.sendTransaction(txRequest) const rx = await tx.wait() - // transaction must work - it just stores data - expect(rx.status).eq(1) - // emit log event - const event = edge.interface.parseLog(rx.logs[0]).args - expect(event.data).eq(txRequest.data) + expect(rx!.status).eq(1) + const event = edge.interface.parseLog({ topics: rx!.logs[0].topics as string[], data: rx!.logs[0].data }) + expect(event!.args.data).eq(txRequest.data) }) }) }) From 1ee3f263207e3e37005fd290bdeb143c6d335c81 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:59:46 +0000 Subject: [PATCH 078/157] fix: horizon test and token-distribution compatibility fixes --- package.json | 11 ++++++++++- packages/contracts/hardhat.config.ts | 3 ++- .../unit/payments/recurring-collector/accept.t.sol | 2 ++ .../horizon/test/unit/utilities/Authorizable.t.sol | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b0b15f5ec..1c6e12e86 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,17 @@ "overrides": { "@types/node": "^20.17.50" }, + "packageExtensions": { + "@nomiclabs/hardhat-waffle@*": { + "dependencies": { + "@ethereum-waffle/chai": "*", + "@ethereum-waffle/provider": "*" + } + } + }, "patchedDependencies": { - "typechain@8.3.2": "patches/typechain@8.3.2.patch" + "typechain@8.3.2": "patches/typechain@8.3.2.patch", + "rocketh@0.17.13": "patches/rocketh@0.17.13.patch" } }, "lint-staged": { diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index 86b77d5c5..ba90039ca 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -60,7 +60,8 @@ const config: HardhatUserConfig = { etherscan: { // Use ARBISCAN_API_KEY for Arbitrum networks // For mainnet Ethereum, use ETHERSCAN_API_KEY - apiKey: vars.has('ARBISCAN_API_KEY') ? vars.get('ARBISCAN_API_KEY') : '', + // Check both keystore (vars) and environment variable + apiKey: vars.has('ARBISCAN_API_KEY') ? vars.get('ARBISCAN_API_KEY') : (process.env.ARBISCAN_API_KEY ?? ''), }, sourcify: { enabled: false, diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index d1742b690..7ecda4009 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -25,6 +25,8 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { ) public { // Ensure non-empty signature so the signed path is taken (which checks deadline first) vm.assume(fuzzySignature.length > 0); + // Exclude ProxyAdmin address — TransparentProxy routes admin calls to ProxyAdmin, not implementation + vm.assume(fuzzyRCA.dataService != _proxyAdmin); // Generate deterministic agreement ID for validation bytes16 agreementId = _recurringCollector.generateAgreementId( fuzzyRCA.payer, diff --git a/packages/horizon/test/unit/utilities/Authorizable.t.sol b/packages/horizon/test/unit/utilities/Authorizable.t.sol index 18ed8df54..ecad033c9 100644 --- a/packages/horizon/test/unit/utilities/Authorizable.t.sol +++ b/packages/horizon/test/unit/utilities/Authorizable.t.sol @@ -326,7 +326,8 @@ contract AuthorizableTest is Test, Bounder { authorizable.revokeAuthorizedSigner(signer); } - function test_IsAuthorized_Revert_WhenZero(address signer) public view { + function test_IsAuthorized_Revert_WhenZero(address signer) public { + assumeValidFuzzAddress(signer); authHelper.assertNotAuthorized(address(0), signer); } } From 4ef9bec1dfd834aca2dd1b2f1bf90c20cecd8a72 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:59:51 +0000 Subject: [PATCH 079/157] chore: update addresses, contract registries, and MockREO --- packages/address-book/CHANGELOG.md | 6 + packages/address-book/docs/PublishingGuide.md | 108 ++++++++++++++++++ packages/address-book/package.json | 2 +- .../scripts/copy-addresses-for-publish.js | 4 +- .../address-book/src/issuance/addresses.json | 1 + packages/horizon/addresses.json | 11 +- packages/interfaces/src/types/horizon.ts | 2 + packages/issuance/README.md | 2 +- packages/issuance/addresses.json | 3 - .../mocks/MockRewardsEligibilityOracle.sol | 51 +++++++++ packages/subgraph-service/addresses.json | 11 +- .../src/deployments/horizon/contracts.ts | 3 + .../src/deployments/issuance/contracts.ts | 33 +++--- .../src/hardhat/hardhat.base.config.ts | 9 +- 14 files changed, 211 insertions(+), 35 deletions(-) create mode 100644 packages/address-book/docs/PublishingGuide.md create mode 120000 packages/address-book/src/issuance/addresses.json create mode 100644 packages/issuance/contracts/eligibility/mocks/MockRewardsEligibilityOracle.sol diff --git a/packages/address-book/CHANGELOG.md b/packages/address-book/CHANGELOG.md index 11e71dae2..1427d84c2 100644 --- a/packages/address-book/CHANGELOG.md +++ b/packages/address-book/CHANGELOG.md @@ -1,5 +1,11 @@ # @graphprotocol/address-book +## 1.2.0 + +### Minor Changes + +- Upgraded Rewards Manager and Subgraph Service with Rewards Eligibility Oracle and rewards reclaiming. + ## 1.1.0 ### Minor Changes diff --git a/packages/address-book/docs/PublishingGuide.md b/packages/address-book/docs/PublishingGuide.md new file mode 100644 index 000000000..d4b021783 --- /dev/null +++ b/packages/address-book/docs/PublishingGuide.md @@ -0,0 +1,108 @@ +# Publishing @graphprotocol/address-book + +Step-by-step guide for releasing a new version of the address-book package and deploying it to the network monitor. + +## Prerequisites + +- npm publish access for the `@graphprotocol` scope +- Write access to the [network-monitor](https://github.com/edgeandnode/network-monitor) repo +- Ability to trigger GitHub Actions workflows in both repos + +## Step 1: Update Address Files + +Update the source address files in the contracts monorepo. These live in: + +- `packages/horizon/addresses.json` +- `packages/subgraph-service/addresses.json` +- `packages/issuance/addresses.json` + +The address-book package symlinks to these files during development, so changes here are automatically reflected locally. + +## Step 2: Create a Changeset + +From the monorepo root: + +```bash +pnpm changeset +``` + +- Select `@graphprotocol/address-book` +- Choose the bump type (patch/minor/major) +- Describe what changed (e.g., "update arbitrumSepolia addresses after deployment") + +## Step 3: Version the Package + +```bash +pnpm changeset version +``` + +This consumes the changeset, bumps the version in `packages/address-book/package.json`, and updates `CHANGELOG.md`. + +## Step 4: Commit and Push + +```bash +git add . +git commit -m "chore: release @graphprotocol/address-book vX.Y.Z" +git push +``` + +## Step 5: Publish to npm + +1. Go to the contracts monorepo → Actions → "Publish package to NPM" +2. Select `address-book` as the package +3. Set tag to `latest` (or a pre-release tag) +4. Run workflow + +The workflow automatically: + +- Publishes to npm (symlinks are converted to real files via `prepublishOnly`) +- Creates and pushes a git tag (`@graphprotocol/address-book@X.Y.Z`) + +## Step 6: Verify on npm + +```bash +npm view @graphprotocol/address-book version +``` + +Confirm the new version is live. + +## Step 7: Update the Network Monitor + +In the [network-monitor](https://github.com/edgeandnode/network-monitor) repo: + +1. Update `package.json` to reference the new version: + + ```json + "@graphprotocol/address-book": "X.Y.Z", + ``` + +2. Run `yarn` to update the lockfile +3. Commit and push + +The network monitor imports addresses from: + +- `@graphprotocol/address-book/horizon/addresses.json` (in `src/env.ts`) +- `@graphprotocol/address-book/subgraph-service/addresses.json` (in `src/env.ts`, `src/tests/contracts.ts`) + +## Step 8: Deploy the Network Monitor + +1. Go to the network-monitor repo → Actions → "Deployment" +2. Choose the target cluster: + - **`network`** → production (mainnet) + - **`testnet`** → testnet +3. Run workflow + +This builds a Docker image, pushes it to `ghcr.io/edgeandnode/network-monitor`, and restarts the StatefulSet on GKE. + +## Quick Reference + +| Step | Action | Where | +| ---- | ------------------------------- | ----------------------------- | +| 1 | Update address files | contracts monorepo | +| 2 | `pnpm changeset` | contracts monorepo | +| 3 | `pnpm changeset version` | contracts monorepo | +| 4 | Commit + push | contracts monorepo | +| 5 | Publish to npm (auto-tags) | contracts monorepo GH Actions | +| 6 | Verify on npm | npmjs.com | +| 7 | Bump version in network-monitor | network-monitor repo | +| 8 | Deploy network monitor | network-monitor GH Actions | diff --git a/packages/address-book/package.json b/packages/address-book/package.json index 28664ce0e..471e51052 100644 --- a/packages/address-book/package.json +++ b/packages/address-book/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/address-book", - "version": "1.1.0", + "version": "1.2.0", "publishConfig": { "access": "public" }, diff --git a/packages/address-book/scripts/copy-addresses-for-publish.js b/packages/address-book/scripts/copy-addresses-for-publish.js index 6335f7dc5..75a563d64 100755 --- a/packages/address-book/scripts/copy-addresses-for-publish.js +++ b/packages/address-book/scripts/copy-addresses-for-publish.js @@ -3,8 +3,8 @@ /** * Copy Addresses for Publishing * - * This script copies the actual addresses.json files from horizon and subgraph-service - * packages to replace the symlinks before npm publish. + * This script copies the actual addresses.json files from horizon, issuance, and + * subgraph-service packages to replace the symlinks before npm publish. * * Why we need this: * - Development uses symlinks (committed to git) for convenience diff --git a/packages/address-book/src/issuance/addresses.json b/packages/address-book/src/issuance/addresses.json new file mode 120000 index 000000000..b73ad34ff --- /dev/null +++ b/packages/address-book/src/issuance/addresses.json @@ -0,0 +1 @@ +../../../issuance/addresses.json \ No newline at end of file diff --git a/packages/horizon/addresses.json b/packages/horizon/addresses.json index a7c8437bd..bc91b724c 100644 --- a/packages/horizon/addresses.json +++ b/packages/horizon/addresses.json @@ -92,17 +92,16 @@ "RewardsManager": { "address": "0x1F49caE7669086c8ba53CC35d1E9f80176d67E79", "proxy": "graph", - "implementation": "0xd681431502e7f9780f14576c17f4459074fc2360", + "implementation": "0x4946332c0743a848d66ae10efa65fa226d82bf2f", "proxyDeployment": { "verified": "https://sepolia.arbiscan.io/address/0x1F49caE7669086c8ba53CC35d1E9f80176d67E79#code" }, "implementationDeployment": { - "txHash": "0x09b9cea7f67a55bf81fc92b08d4bb6c7a34f0471d4d1987ef3d914d76ea3f351", + "txHash": "0x48000c64255c968ae765263c4c57b228cc47645897e32fa998107606cf0c4a10", "argsData": "0x", - "bytecodeHash": "0xee210d0ea0a5e1a46622eb4da78d621523e3efcae872d8a844a69b9677c704ef", - "blockNumber": 240022327, - "timestamp": "2026-02-05T19:03:01.000Z", - "verified": "https://sepolia.arbiscan.io/address/0xd681431502e7f9780f14576c17f4459074fc2360#code" + "bytecodeHash": "0x9cee99fc8f8e3ed8ce5a804b519117743d62b42f3cb0b2fd7d9687ccc134bdc4", + "blockNumber": 250570693, + "timestamp": "2026-03-16T09:47:05.000Z" } }, "HorizonStaking": { diff --git a/packages/interfaces/src/types/horizon.ts b/packages/interfaces/src/types/horizon.ts index c2a09abb6..7bd9ca1db 100644 --- a/packages/interfaces/src/types/horizon.ts +++ b/packages/interfaces/src/types/horizon.ts @@ -10,6 +10,7 @@ import type { IL2GNSToolshed, ILegacyRewardsManager, IPaymentsEscrowToolshed, + IRecurringCollector, IRewardsManagerToolshed, IStaking, ISubgraphNFT, @@ -28,6 +29,7 @@ export { ILegacyRewardsManager as LegacyRewardsManager, IStaking as LegacyStaking, IPaymentsEscrowToolshed as PaymentsEscrow, + IRecurringCollector as RecurringCollector, IRewardsManagerToolshed as RewardsManager, ISubgraphNFT as SubgraphNFT, } diff --git a/packages/issuance/README.md b/packages/issuance/README.md index c6def2743..f6c4e4856 100644 --- a/packages/issuance/README.md +++ b/packages/issuance/README.md @@ -10,7 +10,7 @@ The issuance contracts handle token issuance mechanisms for The Graph protocol. - **[IssuanceAllocator](contracts/allocate/IssuanceAllocator.md)** - Central distribution hub for token issuance, allocating tokens to different protocol components based on configured rates - **[RewardsEligibilityOracle](contracts/eligibility/RewardsEligibilityOracle.md)** - Oracle-based eligibility system for indexer rewards with time-based expiration -- **DirectAllocation** - Simple target contract implementation for receiving and distributing allocated tokens (deployed as PilotAllocation and other instances) +- **DirectAllocation** - Simple target contract implementation for receiving and distributing allocated tokens (deployed as ReclaimedRewards) - **[RecurringAgreementManager](contracts/agreement/RecurringAgreementManager.md)** - Funds PaymentsEscrow deposits for RCAs using issuance tokens, tracking max-next-claim per agreement per indexer ## Development diff --git a/packages/issuance/addresses.json b/packages/issuance/addresses.json index ad38aec4e..cddcf9b96 100644 --- a/packages/issuance/addresses.json +++ b/packages/issuance/addresses.json @@ -46,9 +46,6 @@ "blockNumber": 250569166 } }, - "RewardsEligibilityOracleMock": { - "address": "0x5FB23365F8cf643D5f1459E9793EfF7254522400" - }, "IssuanceAllocator": { "address": "0x76a0d75651d4db83f74ac502b86a0ae4e19ac38b", "proxy": "transparent", diff --git a/packages/issuance/contracts/eligibility/mocks/MockRewardsEligibilityOracle.sol b/packages/issuance/contracts/eligibility/mocks/MockRewardsEligibilityOracle.sol new file mode 100644 index 000000000..92e811ce5 --- /dev/null +++ b/packages/issuance/contracts/eligibility/mocks/MockRewardsEligibilityOracle.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.27; + +import { BaseUpgradeable } from "../../common/BaseUpgradeable.sol"; +import { IGraphToken } from "../../common/IGraphToken.sol"; + +/// @title MockRewardsEligibilityOracle +/// @author The Graph Contributors +/// @notice Testnet REO replacement. Indexers control their own eligibility. +/// @dev Everyone starts eligible. Call setEligible(false) to become ineligible. +/// Upgradeable via OZ TransparentUpgradeableProxy for deployment consistency. +contract MockRewardsEligibilityOracle is BaseUpgradeable { + mapping(address indexer => bool isIneligible) private ineligible; + + /// @notice Emitted when an indexer changes their eligibility. + /// @param indexer The indexer address. + /// @param eligible Whether the indexer is now eligible. + event EligibilitySet(address indexed indexer, bool indexed eligible); + + /// @custom:oz-upgrades-unsafe-allow constructor + constructor(IGraphToken graphToken) BaseUpgradeable(graphToken) {} + + /// @notice Initialize the contract. + /// @param governor Address that will have the GOVERNOR_ROLE. + function initialize(address governor) external initializer { + __BaseUpgradeable_init(governor); + } + + /// @notice Toggle the caller's eligibility. + /// @param eligible True to be eligible, false to opt out. + function setEligible(bool eligible) external { + ineligible[msg.sender] = !eligible; + emit EligibilitySet(msg.sender, eligible); + } + + /// @notice Check whether an indexer is eligible for rewards. + /// @dev Called by RewardsManager to check eligibility. + /// @param indexer The indexer address to check. + /// @return True if the indexer is eligible. + function isEligible(address indexer) external view returns (bool) { + return !ineligible[indexer]; + } + + /// @notice ERC165 interface detection. + /// @dev Supports IRewardsEligibility (0x66e305fd) and inherited interfaces. + /// @param interfaceId The interface identifier to check. + /// @return True if the interface is supported. + function supportsInterface(bytes4 interfaceId) public view override returns (bool) { + return interfaceId == 0x66e305fd || super.supportsInterface(interfaceId); + } +} diff --git a/packages/subgraph-service/addresses.json b/packages/subgraph-service/addresses.json index 59eb1a67b..bffbb167c 100644 --- a/packages/subgraph-service/addresses.json +++ b/packages/subgraph-service/addresses.json @@ -37,14 +37,13 @@ "address": "0xc24A3dAC5d06d771f657A48B20cE1a671B78f26b", "proxy": "transparent", "proxyAdmin": "0x15737D9f8635cAcd43e110327c930bd5EC1fe098", - "implementation": "0x8a6361e7355d6936ab17aaacde797d01c0e6c4c4", + "implementation": "0x1e91024a6afc5a6c5cdd3caff900120ac90ae420", "implementationDeployment": { - "txHash": "0x9f3fc372d88a97832eb47bc1f98176532b9a54fa0c110dab8399f9e55ab0aa9d", + "txHash": "0xef8fd7c012cc9d304e118bca035562fbef92aff23252b5b16704dac8b558aa63", "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca69500000000000000000000000096e1b86b2739e8a3d59f40f2532cadf9ce8da088000000000000000000000000382863e7b662027117449bd2c49285582bbbd21b000000000000000000000000de761f075200e75485f4358978fb4d1dc8644fd5", - "bytecodeHash": "0x9c25d2f93e6a2a34cc19d00224872e288a8392d5d99b2df680b7e978d148d450", - "blockNumber": 240040490, - "timestamp": "2026-02-05T20:26:15.000Z", - "verified": "https://sepolia.arbiscan.io/address/0x8a6361e7355d6936ab17aaacde797d01c0e6c4c4#code" + "bytecodeHash": "0x6a936cfc4845d1fefa610aff4f060592a4a0ceb41232c368a089a5aa21efb957", + "blockNumber": 246430101, + "timestamp": "2026-03-02T20:38:09.000Z" }, "proxyDeployment": { "verified": "https://sepolia.arbiscan.io/address/0xc24A3dAC5d06d771f657A48B20cE1a671B78f26b#code" diff --git a/packages/toolshed/src/deployments/horizon/contracts.ts b/packages/toolshed/src/deployments/horizon/contracts.ts index bd852d5f0..9c293b187 100644 --- a/packages/toolshed/src/deployments/horizon/contracts.ts +++ b/packages/toolshed/src/deployments/horizon/contracts.ts @@ -11,6 +11,7 @@ import type { LegacyRewardsManager, LegacyStaking, PaymentsEscrow, + RecurringCollector, RewardsManager, SubgraphNFT, } from '@graphprotocol/interfaces' @@ -36,6 +37,7 @@ export const GraphHorizonContractNameList = [ 'GraphPayments', 'PaymentsEscrow', 'GraphTallyCollector', + 'RecurringCollector', ] as const export interface GraphHorizonContracts extends ContractList { @@ -56,6 +58,7 @@ export interface GraphHorizonContracts extends ContractList { + DefaultAllocation: DirectAllocation DirectAllocation_Implementation: Contract IssuanceAllocator: IssuanceAllocator NetworkOperator: Contract // Address holder for network operator (not an actual contract) - PilotAllocation: DirectAllocation - ReclaimedRewardsForCloseAllocation: DirectAllocation - ReclaimedRewardsForIndexerIneligible: DirectAllocation - ReclaimedRewardsForStalePoi: DirectAllocation - ReclaimedRewardsForSubgraphDenied: DirectAllocation - ReclaimedRewardsForZeroPoi: DirectAllocation - RewardsEligibilityOracle: RewardsEligibilityOracle + ReclaimedRewards: DirectAllocation + RecurringAgreementManager: RecurringAgreementManager + RewardsEligibilityOracleA: RewardsEligibilityOracle + RewardsEligibilityOracleB: RewardsEligibilityOracle + RewardsEligibilityOracleMock: Contract } diff --git a/packages/toolshed/src/hardhat/hardhat.base.config.ts b/packages/toolshed/src/hardhat/hardhat.base.config.ts index a97f9d29c..702484fdc 100644 --- a/packages/toolshed/src/hardhat/hardhat.base.config.ts +++ b/packages/toolshed/src/hardhat/hardhat.base.config.ts @@ -58,8 +58,15 @@ export const projectPathsUserConfig: ProjectPathsUserConfig = { // Etherscan v2 API uses a single API key for all networks // See: https://docs.etherscan.io/etherscan-v2/getting-started/creating-an-account +// Check keystore first (vars), then environment variables +// Support both ETHERSCAN_API_KEY and ARBISCAN_API_KEY for compatibility +const getEtherscanApiKey = (): string => { + if (vars.has('ETHERSCAN_API_KEY')) return vars.get('ETHERSCAN_API_KEY') + if (vars.has('ARBISCAN_API_KEY')) return vars.get('ARBISCAN_API_KEY') + return process.env.ETHERSCAN_API_KEY ?? process.env.ARBISCAN_API_KEY ?? '' +} export const etherscanUserConfig: Partial = { - apiKey: vars.has('ETHERSCAN_API_KEY') ? vars.get('ETHERSCAN_API_KEY') : '', + apiKey: getEtherscanApiKey(), } // In general: From fa69c7a36db1ef70ddd441479f4a1d72fd42526a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:59:56 +0000 Subject: [PATCH 080/157] docs: REO testing plans and rewards behaviour documentation --- .github/workflows/publish.yml | 12 + docs/RewardsBehaviourChanges.md | 175 +++ .../docs/testing/reo/BaselineTestPlan.md | 811 ++++++++++++ .../docs/testing/reo/IndexerTestGuide.md | 542 ++++++++ .../docs/testing/reo/MainnetDetails.md | 38 + packages/issuance/docs/testing/reo/README.md | 156 +++ .../issuance/docs/testing/reo/ReoTestPlan.md | 1103 +++++++++++++++++ .../testing/reo/RewardsConditionsTestPlan.md | 781 ++++++++++++ .../testing/reo/SubgraphDenialTestPlan.md | 680 ++++++++++ .../docs/testing/reo/TestnetDetails.md | 65 + .../reo/support/IssuanceAllocatorTestPlan.md | 98 ++ .../docs/testing/reo/support/NotionSetup.md | 70 ++ .../testing/reo/support/NotionTracker.csv | 77 ++ .../testing/reo/support/indexer-status.sh | 75 ++ 14 files changed, 4683 insertions(+) create mode 100644 docs/RewardsBehaviourChanges.md create mode 100644 packages/issuance/docs/testing/reo/BaselineTestPlan.md create mode 100644 packages/issuance/docs/testing/reo/IndexerTestGuide.md create mode 100644 packages/issuance/docs/testing/reo/MainnetDetails.md create mode 100644 packages/issuance/docs/testing/reo/README.md create mode 100644 packages/issuance/docs/testing/reo/ReoTestPlan.md create mode 100644 packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md create mode 100644 packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md create mode 100644 packages/issuance/docs/testing/reo/TestnetDetails.md create mode 100644 packages/issuance/docs/testing/reo/support/IssuanceAllocatorTestPlan.md create mode 100644 packages/issuance/docs/testing/reo/support/NotionSetup.md create mode 100644 packages/issuance/docs/testing/reo/support/NotionTracker.csv create mode 100755 packages/issuance/docs/testing/reo/support/indexer-status.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ea8d80315..2348142fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,7 @@ on: required: true type: choice options: + - address-book - contracts - sdk tag: @@ -29,8 +30,19 @@ jobs: uses: ./.github/actions/setup - name: Set npm token for publishing run: pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.GRAPHPROTOCOL_NPM_TOKEN }} + - name: Read package info + id: pkg + shell: bash + run: | + PKG_NAME=$(node -p "require('./packages/${{ inputs.package }}/package.json').name") + PKG_VERSION=$(node -p "require('./packages/${{ inputs.package }}/package.json').version") + echo "tag=${PKG_NAME}@${PKG_VERSION}" >> $GITHUB_OUTPUT - name: Publish 🚀 shell: bash run: | pushd packages/${{ inputs.package }} pnpm publish --tag ${{ inputs.tag }} --access public --no-git-checks + - name: Tag release + run: | + git tag ${{ steps.pkg.outputs.tag }} + git push origin ${{ steps.pkg.outputs.tag }} diff --git a/docs/RewardsBehaviourChanges.md b/docs/RewardsBehaviourChanges.md new file mode 100644 index 000000000..63c17c4c2 --- /dev/null +++ b/docs/RewardsBehaviourChanges.md @@ -0,0 +1,175 @@ +# Rewards Behaviour Changes + +Functional summary of how reward behaviour changed between the Horizon mainnet baseline and the current issuance upgrade. + +## Activation Overview + +Changes fall into two categories: + +- **Automatic on upgrade:** New logic that activates immediately when the upgraded contracts are deployed behind their proxies. No governance action required. These include: zero-signal detection, zero-allocated-tokens reclaim, POI presentation paths (claim/reclaim/defer), allocation resize staleness check, allocation close reclaim, and the `POIPresented` event. + +- **Governance-gated:** Features that require explicit governance transactions after upgrade. Until configured, the system preserves legacy behaviour (rewards are dropped, not reclaimed). These include: setting the issuance allocator, configuring reclaim addresses (per-condition and default), setting the eligibility oracle, and changing the minimum subgraph signal threshold. + +This two-phase approach allows a safe upgrade with the new infrastructure in place, while governance coordinates separate activation steps for each optional feature. + +## Issuance Rate + +**Before:** A single `issuancePerBlock` storage variable, set by governance via `setIssuancePerBlock()`, determined all reward issuance. + +**After:** An optional `issuanceAllocator` contract can be set by governance. When set, the effective issuance rate comes from the allocator (which can distribute issuance across multiple targets). When unset, the legacy `issuancePerBlock` value is used as a fallback. The allocator calls `beforeIssuanceAllocationChange()` on the RewardsManager before changing rates, ensuring accumulators are snapshotted first. + +**Activates:** Governance-gated — requires `setIssuanceAllocator()`. Until called, the legacy `issuancePerBlock` value continues to apply. + +## Reward Conditions + +A new `RewardsCondition` library defines typed `bytes32` identifiers for every situation where rewards cannot be distributed normally: + +| Condition | Trigger | +| ---------------------- | ---------------------------------------------------- | +| `NO_SIGNAL` | Zero total curation signal globally | +| `SUBGRAPH_DENIED` | Subgraph is on the denylist | +| `BELOW_MINIMUM_SIGNAL` | Subgraph signal below `minimumSubgraphSignal` | +| `NO_ALLOCATED_TOKENS` | Subgraph has signal but zero allocated tokens | +| `INDEXER_INELIGIBLE` | Indexer fails eligibility oracle check at claim time | +| `STALE_POI` | POI presented after staleness deadline | +| `ZERO_POI` | POI is `bytes32(0)` | +| `ALLOCATION_TOO_YOUNG` | Allocation created in the current epoch | +| `CLOSE_ALLOCATION` | Allocation being closed with uncollected rewards | + +**Activates:** Automatic on upgrade — the library and all condition checks are available immediately once the upgraded contracts are deployed. + +## Reclaim System + +**Before:** When rewards could not be distributed (denied subgraph, below-signal subgraph, stale POI, etc.), the tokens were silently lost -- never minted to anyone. + +**After:** Undistributable rewards are _reclaimed_ by minting them to a configurable address. Governance can set a per-condition address via `setReclaimAddress(condition, address)` and a catch-all fallback via `setDefaultReclaimAddress(address)`. If neither is configured for a given condition, rewards are still not minted (preserving the old drop behaviour). Every reclaim emits a `RewardsReclaimed` event with the condition, amount, indexer, allocation, and subgraph. + +**Activates:** Governance-gated — requires `setReclaimAddress()` and/or `setDefaultReclaimAddress()` for each condition. Until configured, rewards are dropped (preserving legacy behaviour). + +## Zero Global Signal + +**Before:** Issuance during periods with zero total curation signal was silently lost. + +**After:** Detected in `updateAccRewardsPerSignal()` and reclaimed as `NO_SIGNAL`. + +**Activates:** Automatic on upgrade — detection is built into the accumulator update. Reclaim requires a configured address for `NO_SIGNAL`. + +## Subgraph-Level Denial + +**Before:** Denial was a binary gate checked only at `takeRewards()` time. When a subgraph was denied, `takeRewards()` returned 0 and emitted `RewardsDenied`. The calling AllocationManager still advanced the allocation's reward snapshot, permanently dropping those rewards. + +**After:** Denial is handled at two levels: + +- **RewardsManager (accumulator level):** When `onSubgraphSignalUpdate` or `onSubgraphAllocationUpdate` is called for a denied subgraph, `accRewardsForSubgraph` and `accRewardsPerAllocatedToken` freeze (stop increasing). New rewards accruing during the denial period are reclaimed immediately rather than accumulated. `setDenied()` now snapshots accumulators before changing denial state so the boundary is clean. + +- **AllocationManager (claim level):** POI presentation for a denied subgraph is _deferred_ -- returns 0 **without advancing the allocation's snapshot**. This preserves uncollected pre-denial rewards. When the subgraph is later un-denied, those preserved rewards become claimable again. + +**Activates:** Automatic on upgrade — the accumulator-level freeze and claim-level deferral apply immediately. Denial state itself is set via `setDenied()` (Governor or SubgraphAvailabilityOracle). + +## Below-Minimum Signal + +**Before:** `getAccRewardsForSubgraph()` silently excluded rewards for subgraphs below `minimumSubgraphSignal`. Those rewards were lost. + +**After:** The same exclusion occurs, but excluded rewards are reclaimed to the `BELOW_MINIMUM_SIGNAL` address instead of being lost. Changes to `minimumSubgraphSignal` apply retroactively to all pending rewards at the next accumulator update, so governance should call `onSubgraphSignalUpdate()` on affected subgraphs before changing the threshold. + +**Activates:** Automatic on upgrade for the reclaim path. Threshold changes via `setMinimumSubgraphSignal()` are retroactive — governance should call `onSubgraphSignalUpdate()` on affected subgraphs before changing the threshold. + +## Zero Allocated Tokens + +**Before:** When a subgraph had signal but no allocations, `getAccRewardsPerAllocatedToken()` returned 0 for per-token rewards. The subgraph-level accumulator still grew, but the rewards were stranded -- distributable to no one. + +**After:** Detected as `NO_ALLOCATED_TOKENS` and reclaimed. When allocations resume, `accRewardsPerAllocatedToken` resumes from its stored value rather than resetting to zero. + +**Activates:** Automatic on upgrade — detection is built into the accumulator update. + +## Indexer Eligibility + +**Before:** No per-indexer eligibility checks existed. + +**After:** An optional `rewardsEligibilityOracle` can be set by governance. When set, `takeRewards()` checks `isEligible(indexer)` at claim time. If the indexer is ineligible, rewards are denied (emitting `RewardsDeniedDueToEligibility`) and reclaimed to the `INDEXER_INELIGIBLE` address. Subgraph denial takes precedence: if a subgraph is denied, eligibility is not checked. + +**Activates:** Governance-gated — requires `setRewardsEligibilityOracle()`. Until called, no eligibility checks are performed. + +## POI Presentation (AllocationManager) + +**Before:** A single conditional expression decided whether `takeRewards()` was called. If any condition failed (stale, zero POI, too young, altruistic), rewards were set to 0. The allocation's reward snapshot always advanced and pending rewards were always cleared, permanently dropping any undistributable rewards. + +**After:** Three distinct paths based on the determined condition: + +1. **Claim** (`NONE`): `takeRewards()` mints tokens, distributed to indexer and delegators. Snapshot advances. +2. **Reclaim** (`STALE_POI`, `ZERO_POI`): `reclaimRewards()` mints tokens to the reclaim address. Snapshot advances and pending rewards are cleared. +3. **Defer** (`ALLOCATION_TOO_YOUNG`, `SUBGRAPH_DENIED`): Returns 0 **without advancing the snapshot or clearing pending rewards**. Rewards are preserved for later collection. Accumulators are still updated via `onSubgraphAllocationUpdate()` to keep reclaim tracking current. + +The POI presentation timestamp is now recorded immediately on entry (before condition evaluation), so the staleness clock resets regardless of reward outcome. Over-delegation force-close is skipped on the deferred path to avoid closing allocations with preserved uncollected rewards. + +**Activates:** Automatic on upgrade — the three-path logic applies to all POI presentations immediately. + +## Allocation Resize + +**Before:** Resizing always accumulated pending rewards for the delta period, regardless of allocation staleness. + +**After:** If the allocation is stale at resize time, pending rewards are reclaimed as `STALE_POI` and cleared. This prevents stale allocations from silently accumulating pending rewards through repeated resizes. + +**Activates:** Automatic on upgrade — applies to all resize operations immediately. + +## Allocation Close + +**Before:** Closing an allocation advanced the snapshot and closed it. Any uncollected rewards were permanently lost. + +**After:** Before closing, `reclaimRewards(CLOSE_ALLOCATION, allocationId)` is called to mint uncollected rewards to the reclaim address. + +**Activates:** Automatic on upgrade — applies to all close operations immediately. + +## Observability + +A new `POIPresented` event is emitted on every POI presentation, including the determined `condition` as a `bytes32` field. This provides off-chain visibility into why a given presentation did or did not result in rewards, which was previously invisible. + +**Activates:** Automatic on upgrade — emitted on every POI presentation immediately. + +## View Functions + +Several view functions were added or changed to expose the new reward state. + +### Accumulator Views Freeze for Non-Claimable Subgraphs + +The existing accumulator view functions now exclude rewards for subgraphs that are not claimable (denied, below minimum signal, or with zero allocated tokens). Previously these accumulators always grew; callers reading them as continuously-increasing counters need to account for the new freeze behaviour. + +**`getAccRewardsForSubgraph()`** — Previously always returned a growing value regardless of subgraph state. Now returns a frozen value when the subgraph is not claimable: the internal helper `_getSubgraphRewardsState()` determines a `RewardsCondition`, and when the condition is anything other than `NONE`, new rewards are excluded from the returned total. The accumulator resumes growing when the subgraph becomes claimable again. + +**`getAccRewardsPerAllocatedToken()`** — Derives from `getAccRewardsForSubgraph()`, so it inherits the freeze. When the subgraph is not claimable, new per-token rewards are zero because the subgraph-level delta is zero. At snapshot points the implementation zeroes `undistributedRewards` and reclaims them instead of adding them to `accRewardsPerAllocatedToken`. + +**`getRewards()`** — Returns the claimable reward estimate for an allocation. Because it reads `getAccRewardsPerAllocatedToken()`, it now returns a frozen value for allocations on non-claimable subgraphs. Pre-existing `accRewardsPending` from prior resizes is still included. Note: indexer eligibility is _not_ checked here (only at `takeRewards()` time), so the view does not reflect eligibility-based denial. + +**`getNewRewardsPerSignal()`** — No visible change in return value. Internally it now separates claimable from unclaimable issuance (zero-signal periods), but the public view still returns only the claimable portion. The unclaimable portion is reclaimed as `NO_SIGNAL` at the next `updateAccRewardsPerSignal()` call. + +### New Getters on IRewardsManager + +| Function | Returns | Purpose | +| ----------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `getIssuanceAllocator()` | `IIssuanceAllocationDistribution` | Current allocator contract (zero if unset) | +| `getReclaimAddress(bytes32 reason)` | `address` | Per-condition reclaim address (zero if unconfigured) | +| `getDefaultReclaimAddress()` | `address` | Fallback reclaim address | +| `getRewardsEligibilityOracle()` | `IRewardsEligibility` | Current eligibility oracle (zero if unset) | +| `getAllocatedIssuancePerBlock()` | `uint256` | Effective issuance rate — returns the allocator rate when set, otherwise falls back to storage. Replaces the legacy `getRewardsIssuancePerBlock()` for callers that need the protocol rate | +| `getRawIssuancePerBlock()` | `uint256` | Raw storage value, ignoring the allocator. Useful for debugging allocator configuration | + +### Changed Return Semantics + +**`getAllocationData()`** (IRewardsIssuer, implemented by SubgraphService) now returns a sixth value, `accRewardsPending`, representing accumulated rewards from allocation resizing that have not yet been claimed. Callers that destructure the return tuple need updating. + +**`IAllocation.State`** struct adds two fields: `accRewardsPending` (pending rewards from resize) and `createdAtEpoch` (epoch when the allocation was created). Both affect the return value of `getAllocation()`. + +## Provenance + +Merge commits into `main` that introduced the changes described above, in chronological order. + +| Date | Merge | PR | Scope | +| ---------- | ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 2025-12-16 | `ff2f00a62` | #1265 | Eligibility oracle audit doc fixes (TRST-L-1, TRST-L-2) | +| 2025-12-16 | `48be37a20` | #1267 | Issuance allocator audit fix — default allocation, `setReclaimAddress` | +| 2025-12-31 | `89f1321c4` | #1272 | Issuance allocator audit fix v3 — forced reclaim, PPM-to-absolute migration | +| 2026-01-08 | `3d274a4f1` | #1255 | Issuance baseline — RewardsManager extensions, eligibility interface, test suites | +| 2026-01-08 | `363924149` | #1256 | Rewards Eligibility Oracle — full oracle implementation | +| 2026-01-08 | `cdef9b5fd` | #1257 | Issuance Allocator — full allocator, RewardsReclaim library, allocation close reclaim | +| 2026-02-17 | `ada315500` | #1279 | Rewards reclaiming (audited) — RewardsCondition rename, `setDefaultReclaimAddress`, subgraph denial accumulator handling, zero-signal reclaim, POI three-path logic, `POIPresented` event | +| 2026-02-19 | `127b7ef6f` | #1280 | Issuance umbrella merge — all prior work plus stale-allocation-resize reclaim (TRST-R-1) | diff --git a/packages/issuance/docs/testing/reo/BaselineTestPlan.md b/packages/issuance/docs/testing/reo/BaselineTestPlan.md new file mode 100644 index 000000000..7c4377e6a --- /dev/null +++ b/packages/issuance/docs/testing/reo/BaselineTestPlan.md @@ -0,0 +1,811 @@ +# Indexer Baseline Test Plan: Post-Upgrade Verification + +> **Navigation**: [← Back to REO Testing](README.md) + +This test plan validates that indexers can perform standard operational cycles on The Graph Network after a protocol upgrade. It is upgrade-agnostic and covers the core indexer workflows that must function correctly regardless of what changed. + +Each test includes CLI commands, GraphQL verification queries against the network subgraph, and pass/fail criteria. + +> All GraphQL queries run against the network subgraph. All addresses must be **lowercase**. + +--- + +## Prerequisites + +- ETH and GRT on the target network (testnet or mainnet) +- Indexer stack running (graph-node, indexer-agent, indexer-service, tap-agent) +- Minimum indexer stake met (100k GRT on testnet) +- Access to Explorer UI and network subgraph + +### Recommended log verbosity for troubleshooting + +``` +tap-agent: RUST_LOG=info,indexer_tap_agent=trace +indexer-service: RUST_LOG=info,indexer_service_rs=trace +indexer-agent: INDEXER_AGENT_LOG_LEVEL=trace +``` + +--- + +## Test Sequence Overview + +The tests are organized into 7 cycles. Cycles 1-6 cover individual operations; Cycle 7 ties them together in an end-to-end workflow. + +| Cycle | Area | Tests | +| ----- | ------------------------------ | --------- | +| 1 | Indexer Setup and Registration | 1.1 - 1.3 | +| 2 | Stake Management | 2.1 - 2.2 | +| 3 | Provision Management | 3.1 - 3.4 | +| 4 | Allocation Management | 4.1 - 4.5 | +| 5 | Query Serving and Revenue | 5.1 - 5.4 | +| 6 | Network Health | 6.1 - 6.3 | +| 7 | End-to-End Workflow | 7.1 | + +--- + +## Cycle 1: Indexer Setup and Registration + +### 1.1 Setup indexer via Explorer + +**Objective**: Stake GRT and set delegation parameters through Explorer UI. + +**Steps**: + +1. Navigate to Explorer +2. Stake GRT to your indexer address +3. Set delegation parameters (query fee cut, indexing reward cut) +4. Wait for transaction confirmation + +**Verification Query**: + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + createdAt + stakedTokens + queryFeeCut + indexingRewardCut + } +} +``` + +**Pass Criteria**: + +- Indexer entity exists with correct `stakedTokens` +- `queryFeeCut` and `indexingRewardCut` reflect configured values +- Transaction visible in Explorer history + +--- + +### 1.2 Register indexer URL and GEO coordinates + +**Objective**: Verify indexer metadata registration via the indexer agent. + +**Steps**: + +1. Configure `indexer-agent` with URL and GEO coordinates +2. Start or restart the agent +3. Confirm the agent logs show successful registration + +**Verification Query**: + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + url + geoHash + } +} +``` + +**Pass Criteria**: + +- `url` matches configured value +- `geoHash` is populated +- Agent logs show `Successfully registered indexer` + +--- + +### 1.3 Validate Subgraph Service provision and registration + +**Objective**: Confirm the indexer agent automatically creates a provision and registers with SubgraphService. + +**Steps**: + +1. Ensure indexer has sufficient unallocated stake +2. Start indexer agent +3. Monitor logs for provision creation and registration + +**Verification Query**: + +```graphql +{ + provisions(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + indexer { + id + url + geoHash + } + tokensProvisioned + tokensAllocated + tokensThawing + thawingPeriod + maxVerifierCut + dataService { + id + } + } +} +``` + +**Pass Criteria**: + +- Provision exists for SubgraphService +- `url` and `geoHash` populated in indexer registration +- `tokensProvisioned` is non-zero +- Agent logs show `Successfully provisioned to the Subgraph Service` and `Successfully registered indexer` + +--- + +## Cycle 2: Stake Management + +### 2.1 Add stake via Explorer + +**Objective**: Verify indexers can increase their stake. + +**Steps**: + +1. Navigate to Explorer +2. Add stake to your indexer +3. Wait for transaction confirmation + +**Verification Query**: + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + stakedTokens + allocatedTokens + availableStake + } +} +``` + +**Pass Criteria**: + +- `stakedTokens` increases by the added amount +- Transaction visible in Explorer history + +--- + +### 2.2 Unstake tokens and withdraw after thawing + +**Objective**: Verify the unstake and thawing period workflow. + +**Steps**: + +1. Unstake tokens via Explorer +2. Note the thawing period end time +3. Wait for thawing period to complete +4. Withdraw thawed tokens + +**Verification Query**: + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + stakedTokens + availableStake + } + thawRequests(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + tokens + thawingUntil + type + } +} +``` + +**Pass Criteria**: + +- Thaw request appears with correct token amount +- After thawing period, tokens withdraw successfully +- `stakedTokens` decreases by withdrawn amount + +--- + +## Cycle 3: Provision Management + +### 3.1 View current provision + +**Objective**: Check current Subgraph Service provision status. + +**Command**: + +```bash +graph indexer provisions get +``` + +**Verification Query**: + +```graphql +{ + provisions(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + tokensProvisioned + tokensThawing + tokensAllocated + thawingPeriod + maxVerifierCut + } +} +``` + +**Pass Criteria**: + +- CLI output matches subgraph data +- `tokensProvisioned` shows provisioned stake + +--- + +### 3.2 Add stake to provision + +**Objective**: Increase provision without creating a new one. + +**Command**: + +```bash +graph indexer provisions add +``` + +**Verification Query**: + +```graphql +{ + provisions(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + tokensProvisioned + tokensAllocated + indexer { + stakedTokens + availableStake + } + } +} +``` + +**Pass Criteria**: + +- `tokensProvisioned` increases by the added amount +- `availableStake` decreases correspondingly + +--- + +### 3.3 Thaw stake from provision + +**Objective**: Initiate thawing process to remove stake from provision. + +**Command**: + +```bash +graph indexer provisions thaw +``` + +**Verification Query**: + +```graphql +{ + provisions(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + tokensProvisioned + tokensThawing + } + thawRequests(where: { indexer_: { id: "INDEXER_ADDRESS" }, type: Provision }) { + id + tokens + thawingUntil + } +} +``` + +**Pass Criteria**: + +- `tokensThawing` increases by the thawed amount +- Thaw request created with future `thawingUntil` timestamp + +--- + +### 3.4 Remove thawed stake from provision + +**Objective**: Complete the provision reduction after thawing period. + +**Command**: + +```bash +graph indexer provisions remove +``` + +**Verification Query**: + +```graphql +{ + provisions(where: { indexer_: { id: "INDEXER_ADDRESS" } }) { + id + tokensProvisioned + tokensThawing + } + indexers(where: { id: "INDEXER_ADDRESS" }) { + availableStake + } +} +``` + +**Pass Criteria**: + +- `tokensThawing` decreases to 0 +- `tokensProvisioned` decreases by the removed amount +- `availableStake` increases correspondingly + +--- + +## Cycle 4: Allocation Management + +### 4.1 Find subgraph deployments with rewards + +**Objective**: Identify eligible deployments for allocation. + +**Query**: + +```graphql +{ + subgraphDeployments(where: { deniedAt: 0, signalledTokens_not: 0, indexingRewardAmount_not: 0 }) { + ipfsHash + stakedTokens + signalledTokens + indexingRewardAmount + manifest { + network + } + } +} +``` + +**Action**: Filter results by chains your graph-node can index. + +--- + +### 4.2 Create allocation manually + +**Objective**: Open an allocation for a specific deployment. + +**Command**: + +```bash +graph indexer allocations create +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { indexer_: { id: "INDEXER_ADDRESS" }, status: "Active" }) { + id + allocatedTokens + createdAtEpoch + subgraphDeployment { + ipfsHash + } + } +} +``` + +**Pass Criteria**: + +- Allocation appears with status `Active` +- `allocatedTokens` matches specified amount +- `createdAtEpoch` is current epoch + +--- + +### 4.3 Create allocation via actions queue + +**Objective**: Test the actions queue workflow for allocation management. + +**Commands**: + +```bash +graph indexer actions queue allocate +graph indexer actions execute approve +``` + +**Verification**: Same as 4.2. + +**Pass Criteria**: + +- Action queued successfully +- After approval, allocation appears with status `Active` + +--- + +### 4.4 Create allocation via deployment rules + +**Objective**: Test automated allocation management through rules. + +**Command**: + +```bash +graph indexer rules set allocationAmount allocationLifetime +``` + +**Verification**: Same as 4.2. + +**Pass Criteria**: + +- Indexer agent picks up the rule and creates the allocation automatically +- Set `allocationLifetime` to a small value for quicker testing + +--- + +### 4.5 Reallocate a deployment + +**Objective**: Close and recreate allocation in one operation. + +**Command**: + +```bash +graph indexer allocations reallocate +``` + +**Verification Query**: + +```graphql +{ + allocations( + where: { indexer_: { id: "INDEXER_ADDRESS" }, subgraphDeployment_: { ipfsHash: "DEPLOYMENT_IPFS_HASH" } } + ) { + id + status + allocatedTokens + createdAtEpoch + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- Old allocation shows status `Closed` +- New allocation created with status `Active` +- New `allocatedTokens` matches specified amount + +--- + +## Cycle 5: Query Serving and Revenue Collection + +> **Cross-reference**: Allocations opened in Cycles 4-5 may also serve as setup for [ReoTestPlan Cycle 6](./ReoTestPlan.md#cycle-6-integration-with-rewards), which tests reward denial/recovery with mature allocations. If running both plans, keep extra allocations open for the REO reward integration tests. + +### 5.1 Send test queries + +**Objective**: Verify the indexer serves queries through the gateway. + +**Script** (save as `query_test.sh`): + +```bash +#!/bin/bash +subgraph_id=${1} +count=${2:-25} +api_key=${3:-"$GRAPH_API_KEY"} +gateway=${4:-"https://gateway.thegraph.com"} + +for ((i=0; i 50 +``` + +**Verification**: + +1. Queries return valid JSON with block data +2. Check indexer-service logs for query processing +3. Check database for TAP receipts: + +```sql +SELECT COUNT(*) FROM tap_horizon_receipts +WHERE allocation_id = ''; +``` + +**Pass Criteria**: + +- Queries succeed with 200 responses +- TAP receipts generated in database + +--- + +### 5.2 Close allocation and collect indexing rewards + +**Objective**: Verify rewards collection on allocation closure. + +**Prerequisites**: Allocation must be several epochs old. Check first: + +```graphql +{ + graphNetworks { + currentEpoch + } + allocations(where: { indexer_: { id: "INDEXER_ADDRESS" }, status: "Active" }) { + id + allocatedTokens + createdAtEpoch + } +} +``` + +**Command**: + +```bash +graph indexer allocations close +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + allocatedTokens + indexingRewards + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- Status changes to `Closed` +- `indexingRewards` is non-zero (for deployments with rewards) +- `closedAtEpoch` is current epoch + +--- + +### 5.3 Verify query fee collection + +**Objective**: Confirm query fees collected after allocation closure. + +> Query fee collection happens asynchronously after closure and may take minutes to hours. + +**Verification Query**: + +```graphql +{ + allocations(where: { indexer_: { id: "INDEXER_ADDRESS" }, status: "Closed" }) { + id + queryFeesCollected + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- `queryFeesCollected` is non-zero for allocations that served queries + +--- + +### 5.4 Close allocation with explicit POI + +**Objective**: Test POI override and reward eligibility. + +**Prerequisites**: Allocation is several epochs old. + +**Command**: + +```bash +graph indexer allocations close --poi +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + poi + } +} +``` + +**Pass Criteria**: + +- `indexingRewards` is non-zero +- `poi` matches the submitted value + +--- + +## Cycle 6: Network Health + +### 6.1 Monitor indexer health + +**Objective**: Verify indexer appears healthy in the network. + +**Query**: + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + url + geoHash + stakedTokens + allocatedTokens + availableStake + delegatedTokens + queryFeesCollected + rewardsEarned + allocations(where: { status: "Active" }) { + id + subgraphDeployment { + ipfsHash + } + } + } +} +``` + +**Pass Criteria**: + +- All expected fields populated +- Active allocations visible +- Accumulated rewards and fees present + +--- + +### 6.2 Check epoch progression + +**Objective**: Verify the network is progressing normally. + +**Query**: + +```graphql +{ + graphNetworks { + id + currentEpoch + totalTokensStaked + totalTokensAllocated + totalQueryFees + totalIndexingRewards + } +} +``` + +**Pass Criteria**: + +- `currentEpoch` increments at the expected rate +- Network totals accumulate over time + +--- + +### 6.3 Verify no unexpected errors in logs + +**Objective**: Confirm clean operation across all indexer components. + +**Steps**: + +1. Review indexer-agent logs for unexpected errors or reverts +2. Review indexer-service logs for query handling issues +3. Review tap-agent logs for receipt/RAV issues +4. Review graph-node logs for indexing errors + +**Pass Criteria**: + +- No unexpected `ERROR` level log entries +- No transaction reverts +- No stuck or looping operations + +--- + +## Cycle 7: End-to-End Workflow + +### 7.1 Full operational cycle + +Run these operations in sequence to validate a complete indexer lifecycle: + +| Step | Operation | Reference | +| ---- | ---------------------------------- | --------- | +| 1 | Check provision status | 3.1 | +| 2 | Find a rewarded deployment | 4.1 | +| 3 | Create allocation | 4.2 | +| 4 | Send test queries (50-100) | 5.1 | +| 5 | Wait 2-3 epochs | - | +| 6 | Close allocation | 5.2 | +| 7 | Verify indexing rewards (non-zero) | 5.2 | +| 8 | Verify query fees collected | 5.3 | +| 9 | Repeat with a different deployment | 4.2 | + +**Pass Criteria**: All individual pass criteria met across the full sequence. + +--- + +## Post-Upgrade Validation Checklist + +### Core functionality + +- [ ] Indexer stack components compatible with upgraded contracts +- [ ] Existing allocations continue to function +- [ ] New allocations can be created +- [ ] Query serving works through gateway +- [ ] Indexing rewards collected correctly +- [ ] Query fees collected correctly +- [ ] Provision management operations succeed + +### Network health + +- [ ] Network subgraph indexes the upgrade correctly +- [ ] Epoch progression continues normally +- [ ] Explorer displays correct data +- [ ] No unexpected reverts or errors in logs + +### Upgrade-specific (fill in per upgrade) + +- [ ] Contract address changes updated in indexer configuration +- [ ] New protocol parameters match expected values +- [ ] Schema changes (if any) reflected correctly +- [ ] _[Add upgrade-specific items here]_ + +--- + +## Troubleshooting + +**Allocation creation fails**: + +- Check `availableStake` is sufficient +- Verify graph-node is syncing the target deployment +- Ensure provision has enough tokens + +**Query fees not collected**: + +- Wait longer (can take several hours) +- Check TAP receipts in database +- Verify queries actually hit your indexer (check service logs) + +**Zero indexing rewards**: + +- Confirm allocation was open for the required number of epochs +- Verify POI was submitted correctly +- Confirm deployment has rewards enabled (`indexingRewardAmount_not: 0`) + +--- + +## Network Configuration Reference + +- [Arbitrum Sepolia (testnet)](TestnetDetails.md) +- [Arbitrum One (mainnet)](MainnetDetails.md) + +--- + +## Related Documentation + +- [← Back to REO Testing](README.md) + +--- + +_Extracted from Horizon upgrade test plans._ diff --git a/packages/issuance/docs/testing/reo/IndexerTestGuide.md b/packages/issuance/docs/testing/reo/IndexerTestGuide.md new file mode 100644 index 000000000..6b1423a36 --- /dev/null +++ b/packages/issuance/docs/testing/reo/IndexerTestGuide.md @@ -0,0 +1,542 @@ +# Indexer Eligibility Test Plan + +> **Navigation**: [← Back to REO Testing](README.md) | [BaselineTestPlan](BaselineTestPlan.md) | [ReoTestPlan](ReoTestPlan.md) + +Tests for indexers to verify correct eligibility handling on Arbitrum Sepolia. This is a focused subset of [ReoTestPlan.md](ReoTestPlan.md), covering per-indexer eligibility flows (renew, expire, recover). The full ReoTestPlan covers additional areas: deployment verification, oracle operations, timeout fail-open, emergency operations, and UI verification. + +Each indexer controls their own eligibility via the ORACLE_ROLE granted to their address. + +Each test includes CLI commands, verification queries against the network subgraph, and pass/fail criteria. + +> All GraphQL queries run against the network subgraph. All addresses must be **lowercase**. + +--- + +## Prerequisites + +- Completed [BaselineTestPlan](BaselineTestPlan.md) Cycles 1-4 (indexer staked, provisioned, can allocate) +- `cast` (Foundry) installed for contract interaction +- Indexer private key available for signing transactions + +### Environment Configuration (set by coordinator) + +- **Eligibility validation**: enabled +- **Eligibility period**: short (e.g. 10-15 minutes) +- **Oracle timeout**: very high (no fail-open during testing) +- **ORACLE_ROLE**: granted to each participating indexer + +### Environment Variables + +```bash +export RPC="https://sepolia-rollup.arbitrum.io/rpc" +export INDEXER= # lowercase +export INDEXER_KEY= + +# Contract addresses (Arbitrum Sepolia) +export REO=0x62c2305739cc75f19a3a6d52387ceb3690d99a99 +export MOCK_REO=0x5FB23365F8cf643D5f1459E9793EfF7254522400 +export REWARDS_MANAGER=0x1f49cae7669086c8ba53cc35d1e9f80176d67e79 +``` + +### Mock REO Option + +A `MockRewardsEligibilityOracle` is deployed at `0x5FB23365F8cf643D5f1459E9793EfF7254522400`. When RewardsManager is pointed at the mock (by the coordinator), you can directly toggle your eligibility without oracle roles, renewal periods, or timeout logic: + +```bash +# Check your eligibility +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC + +# Toggle ineligible (signed by your indexer key) +cast send $MOCK_REO "setEligible(bool)" false --rpc-url $RPC --private-key $INDEXER_KEY + +# Toggle eligible again +cast send $MOCK_REO "setEligible(bool)" true --rpc-url $RPC --private-key $INDEXER_KEY +``` + +If the coordinator has pointed RewardsManager at the mock, you can use Sets 2m-4m below instead of Sets 2-4 for faster testing. Ask the coordinator which REO is active: + +```bash +cast call $REWARDS_MANAGER "getRewardsEligibilityOracle()(address)" --rpc-url $RPC +``` + +### Verify Environment + +```bash +# Validation must be enabled +cast call $REO "getEligibilityValidation()(bool)" --rpc-url $RPC +# Expected: true + +# Confirm you have ORACLE_ROLE +ORACLE_ROLE=$(cast keccak "ORACLE_ROLE") +cast call $REO "hasRole(bytes32,address)(bool)" $ORACLE_ROLE $INDEXER --rpc-url $RPC +# Expected: true + +# Note the eligibility period (seconds) +cast call $REO "getEligibilityPeriod()(uint256)" --rpc-url $RPC +``` + +--- + +## Test Sequence Overview + +| Set | Area | Tests | +| --- | ------------------------------ | --------- | +| 1 | Prepare Allocations | 1.1 | +| 2 | Eligible — Receive Rewards | 2.1 - 2.2 | +| 3 | Ineligible — Verify Denial | 3.1 - 3.2 | +| 4 | Optimistic Recovery | 4.1 - 4.2 | +| 5 | Validation Disabled | 5.1 | +| 2m | Eligible — Mock REO | 2m.1 | +| 3m | Ineligible — Mock REO | 3m.1 | +| 4m | Optimistic Recovery — Mock REO | 4m.1 | + +**Timing**: Set 1 opens allocations that need epoch maturity. Sets 2-4 use the production REO (sequential: renew → eligible close → wait for expiry → ineligible close → re-renew → recovery close). Sets 2m-4m use the mock REO for instant eligibility control -- no waiting for expiry. Set 5 requires coordinator to toggle validation. + +--- + +## Set 1: Prepare Allocations + +### 1.1 Open allocations for eligibility tests + +**Objective**: Open 3+ allocations on different deployments. These need to mature across epochs before they can be closed in Sets 2-4. + +**Prerequisites**: Indexer is staked, provisioned, and registered (BaselineTestPlan Cycles 1-3). Subgraph deployments with signal exist. + +**Steps**: + +1. Find subgraph deployments with signal +2. Open allocations on 3+ different deployments +3. Record allocation IDs and current epoch + +**Command**: + +```bash +graph indexer actions queue allocate +graph indexer actions queue allocate +graph indexer actions queue allocate +graph indexer actions approve +``` + +**Verification Query**: + +```graphql +{ + indexer(id: "INDEXER_ADDRESS") { + allocations(where: { status: "Active" }) { + id + subgraphDeployment { + ipfsHash + } + allocatedTokens + createdAtEpoch + } + } + graphNetwork(id: "1") { + currentEpoch + } +} +``` + +**Pass Criteria**: + +- 3+ active allocations visible in subgraph +- `createdAtEpoch` recorded (need at least 1 epoch to pass before closing) + +> While waiting for epoch maturity, proceed to Set 2 to renew eligibility. + +--- + +## Set 2: Eligible — Receive Rewards + +### 2.1 Renew eligibility + +**Objective**: Renew your own eligibility and confirm the REO reflects it. + +**Prerequisites**: ORACLE_ROLE confirmed in environment check. + +**Command**: + +```bash +cast send $REO "renewIndexerEligibility(address[],bytes)" "[$INDEXER]" "0x" \ + --rpc-url $RPC --private-key $INDEXER_KEY +``` + +**Verification**: + +```bash +cast call $REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true + +cast call $REO "getEligibilityRenewalTime(address)(uint256)" $INDEXER --rpc-url $RPC +# Record this timestamp — eligibility expires at: renewal_time + eligibility_period +``` + +**Pass Criteria**: + +- `isEligible` returns `true` +- `getEligibilityRenewalTime` returns a recent timestamp + +--- + +### 2.2 Close allocation while eligible + +**Objective**: Verify that an eligible indexer receives indexing rewards when closing an allocation. + +**Prerequisites**: `isEligible` returns `true`. Allocation from Set 1 is at least 1 epoch old. + +**Command**: + +```bash +graph indexer actions queue close +graph indexer actions approve +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- Status changes to `Closed` +- `indexingRewards` is non-zero +- `closedAtEpoch` is current epoch + +--- + +## Set 3: Ineligible — Verify Denial + +### 3.1 Wait for eligibility expiry + +**Objective**: Confirm that eligibility expires after the configured period. + +**Prerequisites**: Renewal timestamp and eligibility period recorded from Set 2.1. + +**Steps**: + +1. Calculate expiry time: `renewal_timestamp + eligibility_period` +2. Wait until current block time exceeds expiry +3. Verify eligibility has expired + +**Verification**: + +```bash +cast call $REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# Confirm by comparing timestamps: +cast call $REO "getEligibilityRenewalTime(address)(uint256)" $INDEXER --rpc-url $RPC +cast call $REO "getEligibilityPeriod()(uint256)" --rpc-url $RPC +cast block latest --field timestamp --rpc-url $RPC +# block_timestamp > renewal_time + period +``` + +**Pass Criteria**: + +- `isEligible` returns `false` +- Block timestamp exceeds renewal time + eligibility period + +--- + +### 3.2 Close allocation while ineligible + +**Objective**: Verify that an ineligible indexer receives zero indexing rewards when closing an allocation. Denied rewards are routed to the reclaim contract. + +**Prerequisites**: `isEligible` returns `false`. Allocation from Set 1 is at least 1 epoch old. + +**Steps**: + +1. Confirm ineligibility +2. Close an allocation +3. Verify zero rewards + +**Command**: + +```bash +# Confirm ineligible +cast call $REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- Status changes to `Closed` +- `indexingRewards` is `0` +- Contrast with Set 2.2 where `indexingRewards` was non-zero + +--- + +## Set 4: Optimistic Recovery + +Eligibility denial is **optimistic**: rewards accrue to allocations during ineligible periods and are paid in full when the indexer closes while eligible. This is the key behavioral difference from subgraph denial. + +### 4.1 Re-renew eligibility + +**Objective**: Restore eligibility after expiry and confirm the REO reflects it. + +**Prerequisites**: Eligibility expired (Set 3.1). Do this promptly after Set 3. + +**Command**: + +```bash +cast send $REO "renewIndexerEligibility(address[],bytes)" "[$INDEXER]" "0x" \ + --rpc-url $RPC --private-key $INDEXER_KEY +``` + +**Verification**: + +```bash +cast call $REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true +``` + +**Pass Criteria**: + +- `isEligible` returns `true` after re-renewal + +--- + +### 4.2 Close allocation — full rewards after re-renewal + +**Objective**: Verify that an allocation closed after re-renewal receives full rewards for its entire duration, including the ineligible period. + +**Prerequisites**: `isEligible` returns `true`. Active allocation from Set 1 has been open across multiple epochs including the ineligible period. + +**Command**: + +```bash +graph indexer actions queue close +graph indexer actions approve +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + createdAtEpoch + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- Status changes to `Closed` +- `indexingRewards` is non-zero +- Rewards reflect the full allocation duration (`closedAtEpoch - createdAtEpoch`), not reduced by the ineligible period +- Compare with Set 2.2: this allocation was open longer and should have proportionally more rewards + +--- + +## Set 5: Validation Disabled + +### 5.1 Verify eligibility when validation is off + +**Objective**: Confirm that all indexers are eligible when validation is disabled, regardless of renewal status. This is the default state and the emergency fallback. + +**Prerequisites**: Coordinator has disabled validation (`setEligibilityValidation(false)`). + +**Verification**: + +```bash +cast call $REO "getEligibilityValidation()(bool)" --rpc-url $RPC +# Expected: false + +cast call $REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true +``` + +**Pass Criteria**: + +- `getEligibilityValidation` returns `false` +- `isEligible` returns `true` even without a recent renewal + +--- + +## Mock REO Test Sets (2m - 4m) + +These sets use the `MockRewardsEligibilityOracle` for direct eligibility control. The coordinator must have pointed RewardsManager at the mock. These replace Sets 2-4 when the mock is active. + +### 2m.1 Close allocation while eligible (mock) + +**Objective**: Verify rewards when eligible (the default mock state). + +**Prerequisites**: Allocation from Set 1 is at least 1 epoch old. + +```bash +# Confirm eligible (default) +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: `indexingRewards` is non-zero. + +--- + +### 3m.1 Toggle ineligible and close allocation (mock) + +**Objective**: Verify reward denial after toggling ineligible. + +```bash +# Toggle ineligible +cast send $MOCK_REO "setEligible(bool)" false --rpc-url $RPC --private-key $INDEXER_KEY + +# Confirm +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: `indexingRewards` = `0`. Allocation still transitions to `Closed`. + +--- + +### 4m.1 Re-enable and close allocation -- full rewards (mock) + +**Objective**: Verify optimistic recovery: toggle eligible again and receive full rewards. + +**Prerequisites**: Active allocation open across multiple epochs, including time while ineligible. + +```bash +# Toggle eligible +cast send $MOCK_REO "setEligible(bool)" true --rpc-url $RPC --private-key $INDEXER_KEY + +# Confirm +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: + +- `indexingRewards` is non-zero +- Rewards reflect the full allocation duration (not reduced by the ineligible period) +- Compare with 2m.1: longer-open allocation should have proportionally more rewards + +--- + +## Indexer Awareness: Denial and Reward Conditions + +These situations are managed by the coordinator, not the indexer. No indexer action is needed — but indexers should understand the expected behaviour. + +### During subgraph denial + +If a coordinator denies a subgraph you have allocations on: + +- **Continue presenting POIs** — deferred presentations reset the staleness clock, preventing STALE_POI reclaim when the subgraph is later undenied +- `getRewards()` returns a frozen value (pre-denial uncollected rewards are preserved) +- Closing an allocation on a denied subgraph returns 0 rewards but preserves the pre-denial amount + +**Verification during denial:** + +```bash +cast call $REWARDS_MANAGER "isDenied(bytes32)(bool)" --rpc-url $RPC +# Expected: true (if coordinator denied it) + +cast call $REWARDS_MANAGER "getRewards(address,address)(uint256)" --rpc-url $RPC +# Returns frozen pre-denial rewards (non-zero if you had uncollected rewards) +``` + +### After subgraph undeny + +After a coordinator undenies a subgraph: + +- Accumulators resume growing +- Close allocation normally — rewards include pre-denial + post-undeny amounts +- Denial-period rewards were reclaimed to the protocol (not included in your claim) + +**Verification after undeny:** + +```bash +cast call $REWARDS_MANAGER "isDenied(bytes32)(bool)" --rpc-url $RPC +# Expected: false + +cast call $REWARDS_MANAGER "getRewards(address,address)(uint256)" --rpc-url $RPC +# Should be growing again (pre-denial + post-undeny rewards) +``` + +### POI staleness + +If an allocation goes without POI presentation for longer than `maxPOIStaleness`, rewards are reclaimed as STALE_POI instead of being paid to the indexer. + +```bash +cast call "maxPOIStaleness()(uint256)" --rpc-url $RPC +# Note this value — present POIs more frequently than this +``` + +**Action**: Ensure your indexer agent is healthy and presenting POIs regularly. + +### Signal-related conditions + +Rewards require curation signal above the minimum threshold. If signal drops below `minimumSubgraphSignal`, rewards freeze and are reclaimed. This is not actionable by indexers — it depends on curators. + +```bash +cast call $REWARDS_MANAGER "minimumSubgraphSignal()(uint256)" --rpc-url $RPC +``` + +**Related**: [RewardsConditionsTestPlan.md](RewardsConditionsTestPlan.md) | [SubgraphDenialTestPlan.md](SubgraphDenialTestPlan.md) + +--- + +## Troubleshooting + +**`isEligible` returns `false` unexpectedly:** + +- Check if validation is enabled: `getEligibilityValidation()` +- Check your renewal time: `getEligibilityRenewalTime(address)` +- Check the eligibility period: `getEligibilityPeriod()` +- Your renewal may have expired: compare `renewal_time + period` with current block time + +**Renewal transaction reverts:** + +- Confirm you have ORACLE_ROLE: `hasRole(ORACLE_ROLE, address)` +- Confirm the REO is not paused: `paused()` + +**Zero rewards on close despite being eligible:** + +- Check allocation maturity: must have been open for at least 1 full epoch +- Check if subgraph deployment has signal (no signal = no rewards) +- Verify RewardsManager points to the REO: `getRewardsEligibilityOracle()` + +--- + +**Related**: [BaselineTestPlan.md](BaselineTestPlan.md) | [ReoTestPlan.md](ReoTestPlan.md) diff --git a/packages/issuance/docs/testing/reo/MainnetDetails.md b/packages/issuance/docs/testing/reo/MainnetDetails.md new file mode 100644 index 000000000..590c3b134 --- /dev/null +++ b/packages/issuance/docs/testing/reo/MainnetDetails.md @@ -0,0 +1,38 @@ +# Arbitrum One — Mainnet Details + +## Network Parameters + +| Parameter | Value | +| ----------------- | ---------------------------------------------- | +| Explorer | | +| Gateway | | +| Network subgraph | `DZz4kDTdmzWLWsV373w2bSmoar3umKKH9y82SUKr5qmp` | +| Epoch length | ~6,646 blocks (~24 hours) | +| Min indexer stake | 100k GRT | + +## Network Subgraph + +**Query via Graph Explorer**: [Graph Network Arbitrum](https://thegraph.com/explorer/subgraphs/DZz4kDTdmzWLWsV373w2bSmoar3umKKH9y82SUKr5qmp?view=Query&chain=arbitrum-one) + +Or query directly: + +```bash +export GRAPH_API_KEY= +curl "https://gateway.thegraph.com/api/$GRAPH_API_KEY/subgraphs/id/DZz4kDTdmzWLWsV373w2bSmoar3umKKH9y82SUKr5qmp" \ + -H 'content-type: application/json' \ + -d '{"query": "{ _meta { block { number } } }"}' +``` + +## Contract Addresses + +| Contract | Address | +| ------------------------ | -------------------------------------------- | +| RewardsEligibilityOracle | TBD | +| RewardsManager | `0x971b9d3d0ae3eca029cab5ea1fb0f72c85e6a525` | +| SubgraphService | `0xb2bb92d0de618878e438b55d5846cfecd9301105` | +| GraphToken (L2) | `0x9623063377ad1b27544c965ccd7342f7ea7e88c7` | +| Controller | `0x0a8491544221dd212964fbb96487467291b2c97e` | + +--- + +- [← Back to REO Testing](README.md) diff --git a/packages/issuance/docs/testing/reo/README.md b/packages/issuance/docs/testing/reo/README.md new file mode 100644 index 000000000..666885c68 --- /dev/null +++ b/packages/issuance/docs/testing/reo/README.md @@ -0,0 +1,156 @@ +# Issuance Upgrade Testing Documentation + +Comprehensive test plans for validating The Graph Network after an upgrade. Three-layer approach: baseline indexer operations (upgrade-agnostic), REO-specific eligibility and oracle tests, and reward condition tests covering denial, reclaim, signal, POI paths, and allocation lifecycle changes. + +## Quick Start + +1. **Indexers start here** → Follow [IndexerTestGuide.md](IndexerTestGuide.md) +2. **Detailed baseline reference** → [BaselineTestPlan.md](BaselineTestPlan.md) +3. **REO eligibility tests** → [ReoTestPlan.md](ReoTestPlan.md) +4. **Subgraph denial tests** → [SubgraphDenialTestPlan.md](SubgraphDenialTestPlan.md) +5. **Reward conditions tests** → [RewardsConditionsTestPlan.md](RewardsConditionsTestPlan.md) + +**Mock REO available**: A `MockRewardsEligibilityOracle` at `0x5FB23365F8cf643D5f1459E9793EfF7254522400` (Arbitrum Sepolia) provides instant eligibility control for integration testing. See the mock-based test paths in [ReoTestPlan](ReoTestPlan.md#mock-reo-quick-test-path) and [IndexerTestGuide](IndexerTestGuide.md#mock-reo-option). + +## Reading Order + +1. **[BaselineTestPlan.md](BaselineTestPlan.md)** -- Upgrade-agnostic indexer operations (run first) +2. **[ReoTestPlan.md](ReoTestPlan.md)** -- REO-specific eligibility, oracle, and rewards tests (run after baseline passes) +3. **[RewardsConditionsTestPlan.md](RewardsConditionsTestPlan.md)** -- Reclaim system, signal conditions, POI paths, allocation lifecycle (run after baseline passes; Cycle 1 configures reclaim addresses needed by other plans) +4. **[SubgraphDenialTestPlan.md](SubgraphDenialTestPlan.md)** -- Subgraph denial two-level handling, accumulator freeze, deferral, deny/undeny lifecycle (run after reclaim setup) +5. **[IndexerTestGuide.md](IndexerTestGuide.md)** -- Condensed guide for indexers running eligibility tests (subset of ReoTestPlan) + +``` +BaselineTestPlan (7 cycles, 22 tests) + │ Covers: setup, staking, provisions, allocations, queries, health + │ + ├──▶ ReoTestPlan (8 cycles + mock path, 36 tests) + │ Covers: deployment, eligibility, oracle, rewards, emergency, UI + │ Depends on: Baseline Cycles 1-7 pass first + │ Cycle 2.3 opens allocations reused in Cycle 6 + │ Cycle 6m: mock REO path for fast integration testing + │ + ├──▶ RewardsConditionsTestPlan (7 cycles, 26 tests) + │ Covers: reclaim config, below-minimum signal, zero allocated tokens, + │ POI paths (stale/zero/too-young), allocation resize/close, observability + │ Depends on: Baseline Cycles 1-7 pass first + │ Cycle 1 configures reclaim addresses used by all reclaim tests + │ + ├──▶ SubgraphDenialTestPlan (6 cycles, 18 tests) + │ Covers: deny/undeny state, accumulator freeze, allocation deferral, + │ pre-denial reward recovery, edge cases + │ Depends on: Baseline + RewardsConditionsTestPlan Cycle 1 (reclaim setup) + │ + └──▶ IndexerTestGuide (5 sets + 3 mock sets, 11 tests) + Covers: eligible/ineligible/recovery flows + Depends on: Baseline Cycles 1-4 (staked, provisioned, can allocate) + Subset of ReoTestPlan focused on per-indexer eligibility + Sets 2m-4m: mock REO alternative for instant eligibility control +``` + +## Documentation + +### Test Plans + +| Document | Purpose | +| ------------------------------------------------------------ | --------------------------------------------------------------------------------------- | +| [BaselineTestPlan.md](BaselineTestPlan.md) | Detailed baseline indexer operational tests (7 cycles, 22 tests) | +| [ReoTestPlan.md](ReoTestPlan.md) | REO eligibility, oracle, and rewards integration (8 cycles + mock path, 36 tests) | +| [RewardsConditionsTestPlan.md](RewardsConditionsTestPlan.md) | Reclaim system, signal conditions, POI paths, allocation lifecycle (7 cycles, 26 tests) | +| [SubgraphDenialTestPlan.md](SubgraphDenialTestPlan.md) | Subgraph denial: accumulator freeze, deferral, recovery (6 cycles, 18 tests) | +| [IndexerTestGuide.md](IndexerTestGuide.md) | Condensed indexer eligibility tests (5 sets + 3 mock sets, 11 tests) | + +## Test Coverage + +### Baseline Tests (7 Cycles) + +1. **Cycle 1: Indexer Setup and Registration** (3 tests) + - Setup via Explorer, register URL/GEO, validate SubgraphService provision + +2. **Cycle 2: Stake Management** (2 tests) + - Add stake, unstake and withdraw after thawing + +3. **Cycle 3: Provision Management** (4 tests) + - View provision, add stake, thaw stake, remove thawed stake + +4. **Cycle 4: Allocation Management** (5 tests) + - Find rewarded deployments, create allocations (manual/queue/rules), reallocate + +5. **Cycle 5: Query Serving and Revenue** (4 tests) + - Send test queries, close allocations, verify rewards and fees + +6. **Cycle 6: Network Health** (3 tests) + - Monitor indexer health, check epoch progression, verify logs + +7. **Cycle 7: End-to-End Workflow** (1 test) + - Complete operational cycle from allocation to revenue collection + +### REO-Specific Tests (ReoTestPlan) + +1. **Eligibility State Transitions** + - Validation toggle, renewals, expiry, oracle timeout fail-open + +2. **Role-Based Operations** + - Governor, Operator, Oracle, Pause role actions and access control + +3. **Integration with RewardsManager** + - Eligible indexer rewards, ineligible indexer denial, reclaim flows + +4. **Edge Cases** + - Large eligibility period, same-block re-renewal, configuration races + +5. **Deployment Verification** + - Post-deploy role checks, parameter validation, proxy consistency + +### Reward Conditions Tests (RewardsConditionsTestPlan) + +1. **Reclaim System Configuration** + - Per-condition addresses, default fallback, routing verification, access control + +2. **Below-Minimum Signal** + - Threshold changes, accumulator freeze, reclaim, restoration + +3. **Zero Allocated Tokens** + - Detection, reclaim, allocation resumption from stored baseline + +4. **POI Presentation Paths** + - Normal claim (NONE), stale POI reclaim, zero POI reclaim, too-young deferral + +5. **Allocation Lifecycle** + - Stale resize reclaim, non-stale resize pass-through, close allocation reclaim + +6. **Observability** + - POIPresented event on every presentation, RewardsReclaimed event context, view function freeze + +### Subgraph Denial Tests (SubgraphDenialTestPlan) + +1. **Denial State Management** + - setDenied, isDenied, idempotent deny, access control + +2. **Accumulator Freeze** + - accRewardsForSubgraph freeze, getRewards freeze, reclaim during denial + +3. **Allocation-Level Deferral** + - POI defers (preserves rewards), multiple defers safe, continued POI presentation + +4. **Undeny and Recovery** + - Accumulator resumption, pre-denial rewards claimable, denial-period exclusion + +5. **Edge Cases** + - New allocation while denied, all-close-while-denied, rapid deny/undeny, denial vs eligibility precedence + +See also: [IssuanceAllocatorTestPlan](support/IssuanceAllocatorTestPlan.md) (independent of REO, pending deployment) + +## Network Configuration + +- [Arbitrum Sepolia (testnet)](TestnetDetails.md) — Explorer, Gateway, network subgraph, RPC, contract addresses +- [Arbitrum One (mainnet)](MainnetDetails.md) — Explorer, Gateway, network subgraph, contract addresses + +> **GraphQL note**: All addresses in queries must be lowercase. Invisible Unicode characters are sometimes introduced when copying queries from GitHub or chat tools and will inexplicably cause empty results. + +## Testing Approach + +1. **Testnet first** - All tests validated on Arbitrum Sepolia before mainnet +2. **Reusable baseline** - Upgrade-agnostic tests reused across protocol upgrades +3. **Incremental** - Baseline confidence first, then upgrade-specific scenarios +4. **Three-layer validation** - Standard operations + REO eligibility + reward conditions/denial diff --git a/packages/issuance/docs/testing/reo/ReoTestPlan.md b/packages/issuance/docs/testing/reo/ReoTestPlan.md new file mode 100644 index 000000000..d2ecf28a0 --- /dev/null +++ b/packages/issuance/docs/testing/reo/ReoTestPlan.md @@ -0,0 +1,1103 @@ +# REO Test Plan: Rewards Eligibility Oracle + +> **Navigation**: [← Back to REO Testing](README.md) | [BaselineTestPlan](BaselineTestPlan.md) + +Tests specific to the Rewards Eligibility Oracle upgrade. Run these **after** the [baseline tests](./BaselineTestPlan.md) pass to confirm standard indexer operations are unaffected. + +> All contract reads use `cast call`. All addresses must be **lowercase**. Replace placeholder addresses with actual deployed addresses for your network. + +## Contract Addresses + +| Contract | Arbitrum Sepolia | Arbitrum One | +| -------------------------------- | -------------------------------------------- | ------------ | +| RewardsEligibilityOracle (proxy) | `0x62c2305739cc75f19a3a6d52387ceb3690d99a99` | TBD | +| MockRewardsEligibilityOracle | `0x5FB23365F8cf643D5f1459E9793EfF7254522400` | N/A | +| RewardsManager (proxy) | `0x1f49cae7669086c8ba53cc35d1e9f80176d67e79` | TBD | +| GraphToken (L2) | `0xf8c05dcf59e8b28bfd5eed176c562bebcfc7ac04` | TBD | + +**Address sources**: `packages/issuance/addresses.json` (REO), `packages/horizon/addresses.json` (RewardsManager, GraphToken) in the `post-audit` worktree. + +### RPC + +| Network | RPC URL | +| ---------------- | ---------------------------------------- | +| Arbitrum Sepolia | `https://sepolia-rollup.arbitrum.io/rpc` | + +### Hardhat Tasks + +The deployment package provides Hardhat tasks that read from the address books and handle governance workflow automatically. Run from `packages/deployment` in the `post-audit` worktree: + +```bash +npx hardhat reo:status --network arbitrumSepolia # Full status: config, oracle activity, role holders +npx hardhat reo:enable --network arbitrumSepolia # Enable eligibility validation (requires OPERATOR_ROLE) +npx hardhat reo:disable --network arbitrumSepolia # Disable eligibility validation (requires OPERATOR_ROLE) +``` + +These are alternatives to the raw `cast` commands used below. `reo:status` in particular is useful as a quick check at any point during testing. + +--- + +## Testing Approach + +**Multi-indexer cycling**: Three indexers cycle through eligibility states individually (not simultaneously). Each indexer transitions through eligible/ineligible states in sequence, allowing controlled observation of each transition. + +| Phase | Indexer A | Indexer B | Indexer C | +| ----- | -------------------- | -------------------- | -------------------- | +| 1 | Eligible | -- | -- | +| 2 | Ineligible (expired) | Eligible | -- | +| 3 | Re-renewed | Ineligible (expired) | Eligible | +| 4 | Eligible | Re-renewed | Ineligible (expired) | + +**Oracle control**: Use a dedicated test oracle account (fake oracle) to manually control eligibility state transitions rather than relying on the actual reporting software. Grant ORACLE_ROLE to this account in Cycle 3. + +**Testnet parameter acceleration**: Reduce time-dependent parameters for practical testing: + +| Parameter | Default | Test Value | Purpose | +| --------------------- | -------------------- | ----------------------- | ------------------------------------------ | +| Eligibility period | 14 days (1,209,600s) | 5-10 minutes (300-600s) | Allow expiration within a test session | +| Oracle update timeout | 7 days (604,800s) | 5-10 minutes (300-600s) | Allow fail-open testing without long waits | + +> Testnet epochs are ~554 blocks (~110 minutes) vs ~6,646 blocks (~24h) on mainnet. Issuance rates are adjusted proportionally. + +**Stakeholder coordination**: Discord channel for testing. UI/Explorer team and network subgraph team monitor throughout for display accuracy during denial scenarios. + +--- + +## Execution Phases + +| Phase | Cycles | Activity | +| ----------- | ------ | -------------------------------------------------------------------------------------------------------- | +| Setup | — | Run [BaselineTestPlan](BaselineTestPlan.md) Cycles 1-7, confirm testnet environment | +| REO Phase 1 | 1-3 | Deployment verification, default state, oracle setup | +| REO Phase 2 | 4-5 | Validation enabled, timeout fail-open, begin indexer cycling | +| REO Phase 3 | 6/6m | Integration with rewards -- use mock REO (6m) for fast iteration, production REO (6) for full validation | +| REO Phase 4 | 7-8 | Emergency ops, UI/subgraph verification | +| Wrap-up | — | Results review, cleanup checklist, mainnet readiness assessment | + +--- + +## Execution Notes + +### Roles needed + +Testing requires access to three roles on the REO contract. On Arbitrum Sepolia: + +| Role | Needed for | Current holder | +| ------------- | --------------------------------------------------------- | ------------------------------------------------------------- | +| OPERATOR_ROLE | Enable/disable validation, set periods, grant ORACLE_ROLE | NetworkOperator: `0xade6b8eb69a49b56929c1d4f4b428d791861db6f` | +| ORACLE_ROLE | Renew indexer eligibility | Not yet assigned -- must be granted in Cycle 3 | +| PAUSE_ROLE | Pause/unpause (Cycle 8) | Check with `reo:status` | + +The tester needs the NetworkOperator key (or governance access) to execute Cycles 3-5 and 8. If the tester doesn't hold OPERATOR_ROLE directly, the Hardhat tasks generate governance TX files for Safe multisig execution. + +### Advance planning for Cycle 6 + +Cycle 6 tests reward integration with live indexers. These tests take multiple epochs (~110 minutes each on Sepolia) and require allocations that were opened **before** validation was enabled. Plan ahead: + +1. During **Cycle 2** (validation still disabled): open allocations for at least two indexers on rewarded deployments -- one that will be renewed (for test 6.1) and one that will NOT be renewed (for test 6.2) +2. These allocations need to mature for 2-3 epochs before they can be closed in Cycle 6 +3. When you enable validation in **Cycle 4**, the non-renewed indexer becomes ineligible while their allocation is still open -- this is the setup for test 6.2 + +### Parameter changes during testing + +Tests 4.4, 5.1, and 8.1 temporarily modify live parameters (eligibility period, oracle timeout, pause state). Each test includes a restore step. If a session is interrupted: + +```bash +# Verify and restore defaults +npx hardhat reo:status --network arbitrumSepolia + +# If needed, restore manually (as operator): +cast send "setEligibilityPeriod(uint256)" 1209600 --rpc-url --private-key +cast send "setOracleUpdateTimeout(uint256)" 604800 --rpc-url --private-key +cast send "unpause()" --rpc-url --private-key +``` + +--- + +## Test Sequence Overview + +| Cycle | Area | Tests | Notes | +| ----- | ------------------------------------------------ | ----------- | -------------------------------------------- | +| 1 | Deployment Verification | 1.1 - 1.5 | Read-only, no role access needed | +| 2 | Eligibility: Default State (Validation Disabled) | 2.1 - 2.3 | Open allocations here for Cycle 6 | +| 3 | Oracle Operations | 3.1 - 3.5 | Requires OPERATOR_ROLE + ORACLE_ROLE | +| 4 | Eligibility: Validation Enabled | 4.1 - 4.4 | Requires OPERATOR_ROLE; 4.4 changes params | +| 5 | Eligibility: Timeout Fail-Open | 5.1 - 5.2 | Requires OPERATOR_ROLE; 5.1 changes params | +| 6 | Integration with Rewards | 6.1 - 6.6 | Requires mature allocations from Cycle 2 | +| 6m | Integration with Rewards (Mock REO) | 6.1m - 6.5m | Uses mock REO for direct eligibility control | +| 7 | Emergency Operations | 7.1 - 7.3 | Requires PAUSE_ROLE; changes live state | +| 8 | UI and Subgraph Verification | 8.1 - 8.3 | Coordinate with Explorer and subgraph teams | + +--- + +## Cycle 1: Deployment Verification + +> Tests 1.2, 1.3, and 1.5 can be checked in one step with `npx hardhat reo:status --network arbitrumSepolia`, which displays role holders, configuration, and contract state. The individual `cast` commands below are useful for scripted or more granular verification. + +### 1.1 Verify proxy and implementation + +**Objective**: Confirm the REO proxy points to the correct implementation and bytecode matches expectations. + +**Steps**: + +1. Query the proxy's implementation address +2. Compare deployed bytecode hash against expected artifact + +```bash +# Get implementation address from proxy admin +cast call "getProxyImplementation(address)" --rpc-url + +# Get deployed bytecode hash +cast keccak $(cast code --rpc-url ) +``` + +**Pass Criteria**: + +- Implementation address matches address book (`0x4eb1de98440a39339817bdeeb3b3fff410b0b924` on Sepolia) +- Bytecode hash matches expected artifact hash + +--- + +### 1.2 Verify role assignments + +**Objective**: Confirm the correct accounts hold each role and the deployer has been removed. + +**Steps**: + +```bash +# Role constants +GOVERNOR_ROLE=0x0000... # DEFAULT_ADMIN_ROLE = 0x00 +OPERATOR_ROLE=$(cast keccak "OPERATOR_ROLE") +ORACLE_ROLE=$(cast keccak "ORACLE_ROLE") +PAUSE_ROLE=$(cast keccak "PAUSE_ROLE") + +# Check role assignments +cast call "hasRole(bytes32,address)(bool)" $GOVERNOR_ROLE --rpc-url +cast call "hasRole(bytes32,address)(bool)" $OPERATOR_ROLE --rpc-url +cast call "hasRole(bytes32,address)(bool)" $PAUSE_ROLE --rpc-url + +# Verify deployer does NOT have governor role +cast call "hasRole(bytes32,address)(bool)" $GOVERNOR_ROLE --rpc-url +``` + +**Pass Criteria**: + +- Governor address has GOVERNOR_ROLE: `true` +- Operator address has OPERATOR_ROLE: `true` +- Pause guardian has PAUSE_ROLE: `true` +- Deployer does NOT have GOVERNOR_ROLE: `false` + +--- + +### 1.3 Verify default parameters + +**Objective**: Confirm the REO is deployed with expected default configuration. + +**Steps**: + +```bash +cast call "getEligibilityPeriod()(uint256)" --rpc-url +cast call "getOracleUpdateTimeout()(uint256)" --rpc-url +cast call "getEligibilityValidation()(bool)" --rpc-url +cast call "getLastOracleUpdateTime()(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `eligibilityPeriod` = `1209600` (14 days in seconds) +- `oracleUpdateTimeout` = `604800` (7 days in seconds) +- `eligibilityValidation` = `false` (disabled by default) +- `lastOracleUpdateTime` = `0` (no oracle updates yet) or reflects actual oracle activity + +--- + +### 1.4 Verify RewardsManager integration + +**Objective**: Confirm the RewardsManager is configured to use the REO for eligibility checks. + +**Steps**: + +```bash +cast call "getRewardsEligibilityOracle()(address)" --rpc-url +``` + +**Pass Criteria**: + +- Returns the REO proxy address + +--- + +### 1.5 Verify contract is not paused + +**Objective**: Confirm the REO is operational. + +**Steps**: + +```bash +cast call "paused()(bool)" --rpc-url +``` + +**Pass Criteria**: + +- Returns `false` + +--- + +## Cycle 2: Eligibility -- Default State (Validation Disabled) + +### 2.1 All indexers eligible when validation disabled + +**Objective**: With validation disabled (default), every indexer should be eligible regardless of renewal status. + +**Steps**: + +1. Confirm validation is disabled +2. Check eligibility for a known indexer +3. Check eligibility for a random address that has never been renewed + +```bash +# Confirm validation disabled +cast call "getEligibilityValidation()(bool)" --rpc-url + +# Known indexer +cast call "isEligible(address)(bool)" --rpc-url + +# Random/never-renewed address +cast call "isEligible(address)(bool)" 0x0000000000000000000000000000000000000001 --rpc-url +``` + +**Pass Criteria**: + +- `getEligibilityValidation()` = `false` +- Both addresses return `isEligible` = `true` + +--- + +### 2.2 Indexer with no renewal history is eligible + +**Objective**: Confirm that an indexer with zero renewal timestamp is still eligible when validation is disabled. + +**Steps**: + +```bash +cast call "getEligibilityRenewalTime(address)(uint256)" --rpc-url +cast call "isEligible(address)(bool)" --rpc-url +``` + +**Pass Criteria**: + +- `getEligibilityRenewalTime` = `0` +- `isEligible` = `true` + +--- + +### 2.3 Rewards still flow with validation disabled + +**Objective**: Confirm the baseline rewards flow is unaffected by the REO when validation is off. + +**Prerequisites**: Indexer has an active allocation on a rewarded deployment, open for at least 2 epochs. This should already exist from running [Baseline Cycle 4](./BaselineTestPlan.md#cycle-4-allocation-management). + +> **Cross-reference**: The allocations opened here (and in [Baseline Cycles 4-5](./BaselineTestPlan.md#cycle-4-allocation-management)) serve as setup for [Cycle 6](#cycle-6-integration-with-rewards) reward integration tests. Open extra allocations now for the indexers you plan to cycle through eligibility states. + +**Steps**: Close the allocation per [Baseline 5.2](./BaselineTestPlan.md#52-close-allocation-and-collect-indexing-rewards) and verify rewards. + +> **Advance setup for Cycle 6**: Before moving to Cycle 3, open allocations for the indexers you plan to use in Cycle 6. You need at least: +> +> - One allocation for a **renewed** indexer (test 6.1 -- will receive rewards) +> - One allocation for a **non-renewed** indexer (test 6.2 -- will be denied rewards) +> +> These allocations must mature for 2-3 epochs before Cycle 6. Since validation is still disabled, both will accrue potential rewards. Use [Baseline 4.2](./BaselineTestPlan.md#42-create-allocation-manually) to create them. + +**Pass Criteria**: + +- Indexing rewards are non-zero on allocation closure +- No change in behavior from baseline + +--- + +## Cycle 3: Oracle Operations + +### 3.1 Grant oracle role + +**Objective**: Verify an operator can grant ORACLE_ROLE to an oracle address. + +**Prerequisites**: Transaction signed by OPERATOR_ROLE holder. + +**Steps**: + +```bash +# Grant oracle role (as operator) +cast send "grantRole(bytes32,address)" $ORACLE_ROLE --rpc-url --private-key + +# Verify +cast call "hasRole(bytes32,address)(bool)" $ORACLE_ROLE --rpc-url +``` + +**Pass Criteria**: + +- Transaction succeeds +- `hasRole` returns `true` for the oracle address + +--- + +### 3.2 Renew single indexer eligibility + +**Objective**: Verify an oracle can renew eligibility for a single indexer. + +**Prerequisites**: Caller has ORACLE_ROLE. + +**Steps**: + +```bash +# Renew eligibility for one indexer +cast send "renewIndexerEligibility(address[],bytes)" "[]" "0x" --rpc-url --private-key + +# Check renewal timestamp +cast call "getEligibilityRenewalTime(address)(uint256)" --rpc-url + +# Check last oracle update time +cast call "getLastOracleUpdateTime()(uint256)" --rpc-url +``` + +**Verification**: Check for emitted events: + +- `IndexerEligibilityRenewed(indexer, oracle)` +- `IndexerEligibilityData(oracle, data)` + +**Pass Criteria**: + +- Transaction succeeds, returns count `1` +- `getEligibilityRenewalTime` is approximately `block.timestamp` of the renewal tx +- `lastOracleUpdateTime` updated to the same timestamp +- Events emitted correctly + +--- + +### 3.3 Renew multiple indexers in batch + +**Objective**: Verify batch renewal works correctly. + +**Steps**: + +```bash +cast send "renewIndexerEligibility(address[],bytes)" "[,,]" "0x" --rpc-url --private-key +``` + +**Verification**: Check renewal timestamps for all three indexers. + +**Pass Criteria**: + +- Transaction succeeds, returns count `3` +- All three indexers have updated renewal timestamps +- One `IndexerEligibilityRenewed` event per indexer + +--- + +### 3.4 Zero addresses skipped in renewal + +**Objective**: Verify zero addresses in the renewal array are silently skipped. + +**Steps**: + +```bash +cast send "renewIndexerEligibility(address[],bytes)" "[0x0000000000000000000000000000000000000000,]" "0x" --rpc-url --private-key +``` + +**Pass Criteria**: + +- Transaction succeeds, returns count `1` (not 2) +- Only the non-zero indexer has a `IndexerEligibilityRenewed` event + +--- + +### 3.5 Unauthorized renewal reverts + +**Objective**: Verify that accounts without ORACLE_ROLE cannot renew eligibility. + +**Steps**: + +```bash +# Attempt renewal from a non-oracle account +cast send "renewIndexerEligibility(address[],bytes)" "[]" "0x" --rpc-url --private-key +``` + +**Pass Criteria**: + +- Transaction reverts with AccessControl error + +--- + +## Cycle 4: Eligibility -- Validation Enabled + +### 4.1 Enable eligibility validation + +**Objective**: Verify an operator can enable validation, switching from "all eligible" to oracle-based eligibility. + +**Prerequisites**: OPERATOR_ROLE holder. Some indexers should have been renewed (Cycle 3), others not. + +> **Before enabling**: Confirm the allocations you opened during Cycle 2 for Cycle 6 testing are still active. Once validation is enabled, any non-renewed indexer with an open allocation becomes ineligible for rewards -- this is the intended setup for test 6.2. + +**Steps**: + +```bash +# Enable validation (alternative: npx hardhat reo:enable --network arbitrumSepolia) +cast send "setEligibilityValidation(bool)" true --rpc-url --private-key + +# Verify +cast call "getEligibilityValidation()(bool)" --rpc-url +``` + +**Verification**: Check for `EligibilityValidationUpdated(true)` event. + +**Pass Criteria**: + +- Transaction succeeds +- `getEligibilityValidation()` = `true` + +--- + +### 4.2 Renewed indexer is eligible + +**Objective**: After enabling validation, a recently renewed indexer should still be eligible. + +**Prerequisites**: Indexer was renewed in Cycle 3. Validation is enabled (4.1). + +**Steps**: + +```bash +cast call "isEligible(address)(bool)" --rpc-url +cast call "getEligibilityRenewalTime(address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `isEligible` = `true` +- `getEligibilityRenewalTime` is within the last `eligibilityPeriod` (14 days) + +--- + +### 4.3 Non-renewed indexer is NOT eligible + +**Objective**: An indexer that was never renewed should be ineligible when validation is enabled. + +**Steps**: + +```bash +cast call "isEligible(address)(bool)" --rpc-url +cast call "getEligibilityRenewalTime(address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `isEligible` = `false` +- `getEligibilityRenewalTime` = `0` + +--- + +### 4.4 Eligibility expires after period + +**Objective**: Verify that an indexer's eligibility expires when the eligibility period has passed since their last renewal. + +**Approach**: This is easiest to test by temporarily reducing the eligibility period to a short duration. + +**Steps**: + +1. Renew an indexer's eligibility +2. Reduce eligibility period to a short value (e.g., 60 seconds) +3. Wait for the period to elapse +4. Check eligibility + +```bash +# Renew indexer +cast send "renewIndexerEligibility(address[],bytes)" "[]" "0x" --rpc-url --private-key + +# Reduce period to 60 seconds (as operator) +cast send "setEligibilityPeriod(uint256)" 60 --rpc-url --private-key + +# Immediately check -- should still be eligible +cast call "isEligible(address)(bool)" --rpc-url + +# Wait 60+ seconds, then check again +sleep 65 +cast call "isEligible(address)(bool)" --rpc-url + +# IMPORTANT: Restore eligibility period to default +cast send "setEligibilityPeriod(uint256)" 1209600 --rpc-url --private-key +``` + +**Pass Criteria**: + +- First check (immediately after renewal): `isEligible` = `true` +- Second check (after period elapsed): `isEligible` = `false` +- Eligibility period restored to default + +--- + +## Cycle 5: Eligibility -- Timeout Fail-Open + +### 5.1 Oracle timeout makes all indexers eligible + +**Objective**: Verify the fail-open mechanism: if no oracle updates occur for longer than `oracleUpdateTimeout`, all indexers become eligible. + +**Approach**: Reduce the oracle timeout to a short duration and wait. + +**Prerequisites**: Validation enabled (4.1). At least one indexer is NOT renewed (should be ineligible). + +**Steps**: + +```bash +# Confirm non-renewed indexer is currently ineligible +cast call "isEligible(address)(bool)" --rpc-url +# Expected: false + +# Reduce oracle timeout to 60 seconds (as operator) +cast send "setOracleUpdateTimeout(uint256)" 60 --rpc-url --private-key + +# Wait for timeout to elapse +sleep 65 + +# Check -- should now be eligible due to fail-open +cast call "isEligible(address)(bool)" --rpc-url + +# IMPORTANT: Restore oracle timeout to default +cast send "setOracleUpdateTimeout(uint256)" 604800 --rpc-url --private-key +``` + +**Pass Criteria**: + +- Before timeout: `isEligible` = `false` +- After timeout: `isEligible` = `true` +- Timeout restored to default + +--- + +### 5.2 Oracle renewal resets timeout + +**Objective**: Verify that an oracle renewal resets the `lastOracleUpdateTime`, closing the fail-open window. + +**Steps**: + +```bash +# Record current lastOracleUpdateTime +cast call "getLastOracleUpdateTime()(uint256)" --rpc-url + +# Renew any indexer +cast send "renewIndexerEligibility(address[],bytes)" "[]" "0x" --rpc-url --private-key + +# Check lastOracleUpdateTime again +cast call "getLastOracleUpdateTime()(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `lastOracleUpdateTime` updated to the block timestamp of the renewal transaction + +--- + +## Cycle 6: Integration with Rewards + +These tests verify the end-to-end interaction between the REO and the rewards system using live indexers. + +> **Timing**: These tests require allocations that have been open for 2-3 epochs (~3.5-5.5 hours on Sepolia). The allocations should have been opened during Cycle 2, before validation was enabled. If they weren't, you'll need to open them now and wait before proceeding. Cycles 7 and 8 can be run while waiting. + +### Mock REO Quick-Test Path + +A `MockRewardsEligibilityOracle` is deployed at `0x5FB23365F8cf643D5f1459E9793EfF7254522400` on Arbitrum Sepolia. This provides direct, instant control over eligibility without oracle roles, renewal periods, or timeout logic. Use it for faster iteration on the Cycle 6 integration tests. + +**How the mock works**: Everyone starts eligible. Indexers call `setEligible(false)` from their own address to become ineligible, and `setEligible(true)` to restore eligibility. No roles or expiry -- just a toggle. + +**Setup**: Point RewardsManager at the mock (requires Governor): + +```bash +MOCK_REO=0x5FB23365F8cf643D5f1459E9793EfF7254522400 + +# Point RewardsManager to mock REO +cast send $REWARDS_MANAGER "setRewardsEligibilityOracle(address)" $MOCK_REO \ + --rpc-url $RPC --private-key $GOVERNOR_KEY + +# Verify +cast call $REWARDS_MANAGER "getRewardsEligibilityOracle()(address)" --rpc-url $RPC +# Expected: 0x5FB23365F8cf643D5f1459E9793EfF7254522400 +``` + +**Control eligibility**: + +```bash +# Query eligibility for any address +cast call $MOCK_REO "isEligible(address)(bool)" --rpc-url $RPC + +# Make yourself ineligible (signed by the indexer) +cast send $MOCK_REO "setEligible(bool)" false --rpc-url $RPC --private-key $INDEXER_KEY + +# Restore eligibility +cast send $MOCK_REO "setEligible(bool)" true --rpc-url $RPC --private-key $INDEXER_KEY +``` + +**After testing**: Restore the production REO on RewardsManager: + +```bash +cast send $REWARDS_MANAGER "setRewardsEligibilityOracle(address)" 0x62c2305739cc75f19a3a6d52387ceb3690d99a99 \ + --rpc-url $RPC --private-key $GOVERNOR_KEY +``` + +> The mock-based tests below (6.1m-6.5m) are equivalents of tests 6.1-6.5 using the mock for eligibility control. They can be run instead of or in addition to the production REO tests. The mock path eliminates time-dependent waits and simplifies the setup, making it the recommended approach for initial integration validation. + +### 6.1 Eligible indexer receives indexing rewards + +**Objective**: Confirm that a renewed (eligible) indexer receives rewards when closing an allocation. + +**Prerequisites**: Validation enabled (Cycle 4). Indexer renewed by oracle (Cycle 3). Indexer has an active allocation open for several epochs on a rewarded deployment (opened during Cycle 2). + +**Steps**: + +1. Confirm eligibility: `isEligible(indexer)` = `true` +2. Close allocation per [Baseline 5.2](./BaselineTestPlan.md#52-close-allocation-and-collect-indexing-rewards) +3. Check rewards + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- `indexingRewards` is non-zero +- Rewards amount is consistent with allocation size and epoch duration + +--- + +### 6.2 Ineligible indexer denied rewards + +**Objective**: Confirm that a non-renewed (ineligible) indexer receives zero rewards when closing an allocation. + +**Prerequisites**: Validation enabled (Cycle 4). Indexer has NOT been renewed by the oracle. Indexer has an active allocation on a rewarded deployment that was opened during Cycle 2 (before validation was enabled). + +**Steps**: + +1. Confirm ineligibility: `isEligible(indexer)` = `false` +2. Close allocation +3. Check rewards + +**Pass Criteria**: + +- `indexingRewards` = `0` +- Allocation still transitions to `Closed` status (closure succeeds, just no rewards) + +--- + +### 6.3 Reclaimed rewards flow to reclaim contract + +**Objective**: When an ineligible indexer is denied rewards, verify the denied rewards are routed to the `ReclaimedRewards` contract (default reclaim address). + +**Prerequisites**: Same as 6.2. + +**Steps**: + +1. Close allocation for ineligible indexer +2. Check the reclaim contract balance or events + +```bash +# Check for RewardsDeniedDueToEligibility event on RewardsManager +# (implementation detail -- exact event name may vary) +cast logs --from-block --to-block --address --rpc-url +``` + +**Pass Criteria**: + +- Denied rewards event emitted +- Reclaim contract receives the tokens that would have been the indexer's rewards + +--- + +### 6.4 Re-renewal restores reward eligibility + +**Objective**: After an indexer's eligibility expires and they are denied rewards, verify that a new oracle renewal restores their ability to earn rewards. + +> **Timing**: This test requires opening a new allocation and waiting 2-3 epochs (~3.5-5.5 hours). It can be run as the final validation step, or skipped on testnet if time is constrained and covered by the combination of 6.2 + Cycle 3 (which together demonstrate the renewal mechanism works). + +**Steps**: + +1. Confirm indexer is currently ineligible (the indexer from test 6.2) +2. Renew the indexer via oracle (as in test 3.2) +3. Confirm eligibility restored: `isEligible` = `true` +4. Open new allocation, wait 2-3 epochs, close, check rewards + +**Pass Criteria**: + +- After renewal: `isEligible` = `true` +- New allocation closure yields non-zero `indexingRewards` + +--- + +### 6.5 View functions reflect zero for ineligible indexer + +**Objective**: Verify that RewardsManager view functions do not over-report claimable rewards for an ineligible indexer. Previously, view functions could show unclaimable balances, misleading indexers into thinking they had earned rewards. + +**Prerequisites**: Validation enabled. Indexer is ineligible. Indexer has an active allocation that has been open several epochs. + +**Steps**: + +1. Confirm ineligibility: `isEligible(indexer)` = `false` +2. Query the view function for pending rewards on the allocation + +```bash +# Check pending rewards for an active allocation +cast call "getRewards(bytes32)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Returns `0` (or near-zero), not the full accumulated amount +- This prevents the UI from displaying rewards the indexer cannot actually claim + +--- + +### 6.6 Eligibility denial is optimistic -- full rewards after re-renewal + +**Objective**: Verify that rewards continue accumulating during an ineligible period (optimistic model). After re-renewal, closing the allocation yields the full accumulated amount including epochs where the indexer was ineligible. This differs from subgraph denial, which permanently stops accumulation. + +**Prerequisites**: Indexer has an active allocation open for several epochs. Indexer was eligible when allocation was opened. + +**Steps**: + +1. Confirm indexer is currently eligible with an active allocation +2. Let eligibility expire (or reduce eligibility period as in test 4.4) +3. Confirm `isEligible(indexer)` = `false` +4. Wait 1-2 additional epochs while ineligible +5. Re-renew the indexer via oracle +6. Confirm `isEligible(indexer)` = `true` +7. Close allocation and check rewards + +**Pass Criteria**: + +- `indexingRewards` reflects the full allocation lifetime (eligible + ineligible epochs) +- Amount is comparable to what a continuously-eligible indexer would earn for the same period +- Temporary ineligibility does not cause permanent reward loss + +--- + +### Mock-Based Integration Tests (6.1m - 6.5m) + +These tests use the `MockRewardsEligibilityOracle` at `0x5FB23365F8cf643D5f1459E9793EfF7254522400` for direct eligibility control. See [Mock REO Quick-Test Path](#mock-reo-quick-test-path) above for setup. + +**Prerequisites**: RewardsManager pointed at the mock REO. Indexer has active allocations open for at least 1 epoch. + +#### 6.1m Eligible indexer receives rewards (mock) + +**Objective**: Confirm that an eligible indexer receives rewards when closing an allocation. + +**Steps**: + +```bash +MOCK_REO=0x5FB23365F8cf643D5f1459E9793EfF7254522400 + +# Confirm eligible (default state) +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: + +- `indexingRewards` is non-zero + +--- + +#### 6.2m Ineligible indexer denied rewards (mock) + +**Objective**: Confirm that toggling eligibility off causes reward denial. + +**Steps**: + +```bash +# Make indexer ineligible +cast send $MOCK_REO "setEligible(bool)" false --rpc-url $RPC --private-key $INDEXER_KEY + +# Confirm +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: + +- `indexingRewards` = `0` +- Allocation still transitions to `Closed` status + +--- + +#### 6.3m Reclaimed rewards flow to reclaim contract (mock) + +**Objective**: When the mock makes an indexer ineligible, denied rewards are routed to the reclaim contract. + +**Prerequisites**: Indexer set to ineligible via mock (6.2m). + +**Steps**: + +```bash +# Check for denial event on the close transaction from 6.2m +cast logs --from-block --to-block --address $REWARDS_MANAGER --rpc-url $RPC +``` + +**Pass Criteria**: + +- Denied rewards event emitted +- Reclaim contract receives the denied tokens + +--- + +#### 6.4m View functions reflect zero for ineligible indexer (mock) + +**Objective**: Verify pending rewards show zero while ineligible. + +**Prerequisites**: Indexer ineligible via mock. Active allocation open for several epochs. + +**Steps**: + +```bash +# Confirm ineligible +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# Check pending rewards +cast call $REWARDS_MANAGER "getRewards(bytes32)(uint256)" --rpc-url $RPC +``` + +**Pass Criteria**: + +- Returns `0` (or near-zero), not the full accumulated amount + +--- + +#### 6.5m Optimistic recovery -- full rewards after re-enabling (mock) + +**Objective**: Verify the optimistic model: toggle ineligible, wait, toggle back, and confirm full rewards on close. + +**Steps**: + +```bash +# Ensure indexer has an active allocation open across multiple epochs + +# 1. Toggle ineligible +cast send $MOCK_REO "setEligible(bool)" false --rpc-url $RPC --private-key $INDEXER_KEY +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: false + +# 2. Wait 1-2 epochs while ineligible (~110-220 min on Sepolia) + +# 3. Toggle eligible again +cast send $MOCK_REO "setEligible(bool)" true --rpc-url $RPC --private-key $INDEXER_KEY +cast call $MOCK_REO "isEligible(address)(bool)" $INDEXER --rpc-url $RPC +# Expected: true + +# 4. Close allocation +graph indexer actions queue close +graph indexer actions approve +``` + +**Pass Criteria**: + +- `indexingRewards` reflects the full allocation lifetime (eligible + ineligible epochs) +- Temporary ineligibility does not cause permanent reward loss +- Compare with 6.1m: this allocation was open longer and should have proportionally more rewards + +--- + +## Cycle 7: Emergency Operations + +### 7.1 Pause REO + +**Objective**: Verify the pause guardian can pause the REO. + +**Prerequisites**: Caller has PAUSE_ROLE. + +**Steps**: + +```bash +# Pause +cast send "pause()" --rpc-url --private-key + +# Verify paused +cast call "paused()(bool)" --rpc-url + +# View functions should still work +cast call "isEligible(address)(bool)" --rpc-url + +# IMPORTANT: Unpause when done +cast send "unpause()" --rpc-url --private-key +``` + +**Pass Criteria**: + +- Pause succeeds, `paused()` = `true` +- View functions (`isEligible`) still return results +- Oracle write operations (`renewIndexerEligibility`) revert while paused +- Unpause succeeds, `paused()` = `false` + +--- + +### 7.2 Disable eligibility validation (emergency override) + +**Objective**: Verify an operator can disable validation to immediately make all indexers eligible. + +**Steps**: + +```bash +# Disable validation (alternative: npx hardhat reo:disable --network arbitrumSepolia) +cast send "setEligibilityValidation(bool)" false --rpc-url --private-key + +# Previously ineligible indexer should now be eligible +cast call "isEligible(address)(bool)" --rpc-url +``` + +**Pass Criteria**: + +- Transaction succeeds +- All indexers return `isEligible` = `true` + +--- + +### 7.3 Access control prevents unauthorized configuration + +**Objective**: Verify that only authorized roles can perform privileged operations. + +**Steps** (all should revert): + +```bash +# Non-operator tries to set eligibility period +cast send "setEligibilityPeriod(uint256)" 100 --rpc-url --private-key + +# Non-operator tries to enable validation +cast send "setEligibilityValidation(bool)" true --rpc-url --private-key + +# Non-pause-role tries to pause +cast send "pause()" --rpc-url --private-key +``` + +**Pass Criteria**: + +- All three transactions revert with AccessControl errors + +--- + +## Cycle 8: UI and Subgraph Verification + +These tests verify that the Graph Explorer and network subgraph correctly reflect eligibility states and denial scenarios. Run these in coordination with the Explorer and subgraph teams. + +### 8.1 Explorer displays correct rewards during denial + +**Objective**: Verify that the Graph Explorer does not show incorrect indexing reward amounts when an indexer is ineligible and claims are denied. + +**Prerequisites**: At least one indexer is ineligible with an active allocation. Explorer team monitoring. + +**Steps**: + +1. Open Explorer to the ineligible indexer's profile +2. Check displayed pending rewards for active allocations +3. Close allocation (will be denied rewards) +4. Verify Explorer updates to reflect the actual outcome (zero rewards) + +**Pass Criteria**: + +- Explorer does not display inflated or false pending rewards for ineligible indexers +- After allocation closure with denial, Explorer shows `0` indexing rewards for that allocation +- No discrepancy between on-chain state and Explorer display + +--- + +### 8.2 Network subgraph reflects eligibility transitions + +**Objective**: Verify the network subgraph correctly indexes eligibility renewal events and displays accurate stake/delegation amounts through state transitions. + +**Steps**: + +1. Renew indexer eligibility via oracle +2. Query network subgraph for the indexer +3. Let eligibility expire +4. Query again and compare + +```graphql +{ + indexers(where: { id: "INDEXER_ADDRESS" }) { + id + stakedTokens + delegatedTokens + allocatedTokens + rewardsEarned + } +} +``` + +**Pass Criteria**: + +- `stakedTokens` and `delegatedTokens` remain accurate regardless of eligibility state +- Subgraph does not show incorrect amounts during eligibility transitions +- No indexing errors in the subgraph during REO-related transactions + +--- + +### 8.3 Denied transaction appears correct in Explorer history + +**Objective**: When an ineligible indexer closes an allocation and rewards are denied, the transaction should not appear "successful" in a way that misleads the indexer. + +**Steps**: + +1. Close allocation for an ineligible indexer +2. Check the transaction in Explorer's history view +3. Verify the displayed outcome matches reality (0 rewards) + +**Pass Criteria**: + +- Transaction status is clear (not misleadingly shown as a successful reward claim) +- Reward amount displayed is `0` or clearly indicates denial +- Explorer team confirms no confusing UX for the indexer + +--- + +## Post-Testing Cleanup Checklist + +Run `npx hardhat reo:status --network arbitrumSepolia` to verify. Ensure the REO is left in the expected state: + +- [ ] `eligibilityValidation` set to intended value (disabled or enabled per rollout plan) +- [ ] `eligibilityPeriod` = `1209600` (14 days) +- [ ] `oracleUpdateTimeout` = `604800` (7 days) +- [ ] Contract is NOT paused +- [ ] Oracle roles assigned to intended oracle addresses only +- [ ] No test accounts retain elevated roles +- [ ] If mock REO was used: RewardsManager points back to the production REO (`0x62c2305739cc75f19a3a6d52387ceb3690d99a99`) + +--- + +## Monitoring Checklist + +After the upgrade is live, continuously monitor: + +- [ ] `IndexerEligibilityRenewed` events flowing regularly from oracles +- [ ] `lastOracleUpdateTime` advancing (oracles are active) +- [ ] No `RewardsDeniedDueToEligibility` events for indexers that should be eligible +- [ ] Epoch progression and total rewards issuance unchanged from pre-upgrade baseline + +--- + +## Related Documentation + +- [← Back to REO Testing](README.md) +- [BaselineTestPlan.md](BaselineTestPlan.md) - Baseline operational tests (run first) + +--- + +_Derived from REO contract specification and audit reports. Source contracts: `/packages/issuance/contracts/eligibility/`_ diff --git a/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md b/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md new file mode 100644 index 000000000..b665e0b58 --- /dev/null +++ b/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md @@ -0,0 +1,781 @@ +# Rewards Conditions Test Plan + +> **Status: Complete** — Local network automation validates Cycles 1-4 and 6. Cycles 5 (resize) and 7 (zero signal) need testnet or special setup. +> +> **Navigation**: [← Back to REO Testing](README.md) | [BaselineTestPlan](BaselineTestPlan.md) | [SubgraphDenialTestPlan](SubgraphDenialTestPlan.md) + +Tests for the reclaim system, signal-related conditions, POI presentation paths, allocation lifecycle changes, and observability improvements introduced in the issuance upgrade. + +These tests cover all reward conditions **except** `INDEXER_INELIGIBLE` (covered by [ReoTestPlan](ReoTestPlan.md)) and `SUBGRAPH_DENIED` (covered by [SubgraphDenialTestPlan](SubgraphDenialTestPlan.md)). + +> All contract reads use `cast call`. All addresses must be **lowercase**. Replace placeholder addresses with actual deployed addresses for your network. + +## Contract Addresses + +| Contract | Arbitrum Sepolia | Arbitrum One | +| ----------------------- | -------------------------------------------- | -------------------------------------------- | +| RewardsManager (proxy) | `0x1f49cae7669086c8ba53cc35d1e9f80176d67e79` | `0x971b9d3d0ae3eca029cab5ea1fb0f72c85e6a525` | +| SubgraphService (proxy) | `0xc24a3dac5d06d771f657a48b20ce1a671b78f26b` | `0xb2bb92d0de618878e438b55d5846cfecd9301105` | +| GraphToken (L2) | `0xf8c05dcf59e8b28bfd5eed176c562bebcfc7ac04` | `0x9623063377ad1b27544c965ccd7342f7ea7e88c7` | +| Controller | `0x9db3ee191681f092607035d9bda6e59fbeaca695` | `0x0a8491544221dd212964fbb96487467291b2c97e` | + +### RPC + +| Network | RPC URL | +| ---------------- | ---------------------------------------- | +| Arbitrum Sepolia | `https://sepolia-rollup.arbitrum.io/rpc` | + +--- + +## Background + +The issuance upgrade introduces a `RewardsCondition` system that classifies every situation where rewards cannot be distributed normally. Instead of silently dropping undistributable rewards, each condition has a defined handling path: + +- **Reclaim**: Mint to a configured address (per-condition or default fallback) +- **Defer**: Preserve for later collection (snapshot not advanced) + +This test plan validates the reclaim infrastructure, each condition's handling, and the new observability features. + +--- + +## Prerequisites + +- [Baseline tests](BaselineTestPlan.md) Cycles 1-7 pass +- Governor access for reclaim address configuration +- SAO or Governor access for `setMinimumSubgraphSignal()` +- At least two indexers with active allocations +- Access to subgraph deployments with varying signal levels + +--- + +## Test Sequence Overview + +| Cycle | Area | Tests | Notes | +| ----- | ---------------------------- | --------- | -------------------------------------------------- | +| 1 | Reclaim System Configuration | 1.1 - 1.5 | Governor access needed | +| 2 | Below-Minimum Signal | 2.1 - 2.4 | Governor/SAO access; signal threshold changes | +| 3 | Zero Allocated Tokens | 3.1 - 3.3 | Requires subgraph with signal but no allocations | +| 4 | POI Presentation Paths | 4.1 - 4.5 | Requires mature and young allocations | +| 5 | Allocation Lifecycle | 5.1 - 5.3 | Resize and close operations | +| 6 | Observability | 6.1 - 6.3 | Event and view function verification | +| 7 | Zero Global Signal | 7.1 - 7.2 | Difficult on shared testnet; may be unit-test only | + +--- + +## Cycle 1: Reclaim System Configuration + +### 1.1 Configure per-condition reclaim addresses + +**Objective**: Set reclaim addresses for each condition and verify the routing. + +**Steps**: + +```bash +# Compute condition identifiers +NO_SIGNAL=$(cast keccak "NO_SIGNAL") +SUBGRAPH_DENIED=$(cast keccak "SUBGRAPH_DENIED") +BELOW_MINIMUM_SIGNAL=$(cast keccak "BELOW_MINIMUM_SIGNAL") +NO_ALLOCATED_TOKENS=$(cast keccak "NO_ALLOCATED_TOKENS") +STALE_POI=$(cast keccak "STALE_POI") +ZERO_POI=$(cast keccak "ZERO_POI") +CLOSE_ALLOCATION=$(cast keccak "CLOSE_ALLOCATION") +INDEXER_INELIGIBLE=$(cast keccak "INDEXER_INELIGIBLE") + +# Set per-condition reclaim addresses (as Governor) +# Using a single address for simplicity; in production these may differ +cast send "setReclaimAddress(bytes32,address)" $NO_SIGNAL --rpc-url --private-key + +cast send "setReclaimAddress(bytes32,address)" $BELOW_MINIMUM_SIGNAL --rpc-url --private-key + +cast send "setReclaimAddress(bytes32,address)" $NO_ALLOCATED_TOKENS --rpc-url --private-key + +cast send "setReclaimAddress(bytes32,address)" $STALE_POI --rpc-url --private-key + +cast send "setReclaimAddress(bytes32,address)" $ZERO_POI --rpc-url --private-key + +cast send "setReclaimAddress(bytes32,address)" $CLOSE_ALLOCATION --rpc-url --private-key + +# Verify each +cast call "getReclaimAddress(bytes32)(address)" $STALE_POI --rpc-url +cast call "getReclaimAddress(bytes32)(address)" $ZERO_POI --rpc-url +cast call "getReclaimAddress(bytes32)(address)" $CLOSE_ALLOCATION --rpc-url +``` + +**Pass Criteria**: + +- Each `setReclaimAddress` transaction succeeds +- `ReclaimAddressSet` event emitted for each +- `getReclaimAddress()` returns the correct address for each condition + +--- + +### 1.2 Configure default reclaim address + +**Objective**: Set the fallback reclaim address used when no per-condition address is configured. + +**Steps**: + +```bash +# Set default reclaim address (as Governor) +cast send "setDefaultReclaimAddress(address)" --rpc-url --private-key + +# Verify +cast call "getDefaultReclaimAddress()(address)" --rpc-url +``` + +**Pass Criteria**: + +- Transaction succeeds +- `DefaultReclaimAddressSet` event emitted +- `getDefaultReclaimAddress()` returns the configured address + +--- + +### 1.3 Verify fallback routing: unconfigured condition uses default + +**Objective**: A condition with no per-condition address should route to the default address. + +**Steps**: + +```bash +# Use a condition that does NOT have a per-condition address set +# (e.g., skip setting ALTRUISTIC_ALLOCATION in test 1.1) +ALTRUISTIC=$(cast keccak "ALTRUISTIC_ALLOCATION") + +# Verify no per-condition address +cast call "getReclaimAddress(bytes32)(address)" $ALTRUISTIC --rpc-url +# Expected: 0x0000... + +# The default address should catch this (verified by observing reclaim events when triggered) +cast call "getDefaultReclaimAddress()(address)" --rpc-url +``` + +**Pass Criteria**: + +- Per-condition address = `0x0` (not set) +- Default address is configured (non-zero) +- When this condition is triggered, `RewardsReclaimed` event shows tokens going to default address + +--- + +### 1.4 Unauthorized reclaim address change reverts + +**Objective**: Only the Governor can set reclaim addresses. + +**Steps**: + +```bash +# Non-governor attempts to set reclaim address +cast send "setReclaimAddress(bytes32,address)" $STALE_POI --rpc-url --private-key + +# Non-governor attempts to set default reclaim address +cast send "setDefaultReclaimAddress(address)" --rpc-url --private-key +``` + +**Pass Criteria**: + +- Both transactions revert + +--- + +### 1.5 Record baseline balances + +**Objective**: Record GRT balances of all reclaim addresses for comparison during later tests. + +**Steps**: + +```bash +cast call "balanceOf(address)(uint256)" --rpc-url +cast call "balanceOf(address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Balances recorded for comparison + +--- + +## Cycle 2: Below-Minimum Signal + +### 2.1 Verify current minimum signal threshold + +**Objective**: Check the current `minimumSubgraphSignal` value and identify subgraphs near the threshold. + +**Steps**: + +```bash +# Check current threshold +cast call "minimumSubgraphSignal()(uint256)" --rpc-url +``` + +**Verification Query** (find subgraphs near the threshold): + +```graphql +{ + subgraphDeployments(orderBy: signalledTokens, orderDirection: asc, where: { signalledTokens_gt: 0 }) { + ipfsHash + signalledTokens + stakedTokens + indexingRewardAmount + } +} +``` + +**Pass Criteria**: + +- Threshold value known +- At least one subgraph identified that is close to (or can be made to fall below) the threshold + +--- + +### 2.2 Raise threshold to trigger BELOW_MINIMUM_SIGNAL + +**Objective**: Increase `minimumSubgraphSignal` so that a target subgraph falls below the threshold, then verify rewards are reclaimed. + +> **Important**: Before changing the threshold, call `onSubgraphSignalUpdate()` on affected subgraphs to snapshot accumulators under the current rules. This prevents retroactive application over a long period. + +**Steps**: + +```bash +# Record accumulator for target subgraph +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +# Snapshot accumulators before threshold change +cast send "onSubgraphSignalUpdate(bytes32)" --rpc-url --private-key + +# Raise threshold (as Governor or SAO) +cast send "setMinimumSubgraphSignal(uint256)" --rpc-url --private-key + +# Verify threshold changed +cast call "minimumSubgraphSignal()(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Threshold changed successfully +- Target subgraph signal is now below the new threshold + +--- + +### 2.3 Accumulator freezes for below-threshold subgraph + +**Objective**: After the threshold increase, the below-threshold subgraph's accumulators should freeze and new rewards should be reclaimed. + +**Steps**: + +```bash +# Wait some time, then check accumulators +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +# Trigger accumulator update to process reclaim +cast send "onSubgraphSignalUpdate(bytes32)" --rpc-url --private-key + +# Check for RewardsReclaimed events +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") +cast logs --from-block --to-block latest --address --topic0 $RECLAIM_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `accRewardsForSubgraph` frozen (not increasing) +- `RewardsReclaimed` event with reason = `BELOW_MINIMUM_SIGNAL` +- Reclaim address balance increased + +--- + +### 2.4 Restore threshold and verify resumption + +**Objective**: Lower the threshold back so the subgraph is above minimum. Accumulators should resume. + +**Steps**: + +```bash +# Snapshot before change +cast send "onSubgraphSignalUpdate(bytes32)" --rpc-url --private-key + +# Restore threshold +cast send "setMinimumSubgraphSignal(uint256)" --rpc-url --private-key + +# Wait, then check accumulators +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Threshold restored to original value +- `accRewardsForSubgraph` resumes increasing +- Allocations on this subgraph can claim rewards again + +--- + +## Cycle 3: Zero Allocated Tokens + +### 3.1 Identify subgraph with signal but no allocations + +**Objective**: Find or create a subgraph deployment that has curation signal but zero allocated tokens. + +**Verification Query**: + +```graphql +{ + subgraphDeployments(where: { signalledTokens_gt: 0, stakedTokens: 0 }) { + ipfsHash + signalledTokens + stakedTokens + } +} +``` + +Alternatively, close all allocations on a test subgraph while leaving signal intact. + +**Pass Criteria**: + +- Subgraph deployment identified with `signalledTokens > 0` and `stakedTokens = 0` + +--- + +### 3.2 Verify NO_ALLOCATED_TOKENS reclaim + +**Objective**: When a subgraph has signal but no allocations, rewards for that signal share are reclaimed as `NO_ALLOCATED_TOKENS`. + +**Steps**: + +```bash +# Trigger accumulator update for the zero-allocation subgraph +cast send "onSubgraphAllocationUpdate(bytes32)" --rpc-url --private-key + +# Check for RewardsReclaimed events +NO_ALLOCATED_TOKENS=$(cast keccak "NO_ALLOCATED_TOKENS") +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") +cast logs --from-block --to-block --address --topic0 $RECLAIM_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `RewardsReclaimed` event with reason = `NO_ALLOCATED_TOKENS` +- Reclaim address received tokens + +--- + +### 3.3 Allocations resume from stored baseline + +**Objective**: When a new allocation is created on a subgraph that previously had zero allocations, `accRewardsPerAllocatedToken` resumes from its stored value rather than resetting to zero. + +**Steps**: + +```bash +# Record current accRewardsPerAllocatedToken +cast call "getAccRewardsPerAllocatedToken(bytes32)(uint256,uint256)" --rpc-url + +# Create allocation +graph indexer allocations create + +# Check accRewardsPerAllocatedToken after creation +cast call "getAccRewardsPerAllocatedToken(bytes32)(uint256,uint256)" --rpc-url +``` + +**Pass Criteria**: + +- New allocation created successfully +- `accRewardsPerAllocatedToken` not reset to zero (maintains stored value) +- New allocation starts accruing from current accumulator value + +--- + +## Cycle 4: POI Presentation Paths + +The issuance upgrade introduces three distinct POI presentation outcomes: **claim**, **reclaim**, and **defer**. Each condition routes to one of these paths. + +### 4.1 Normal claim path (NONE condition) + +**Objective**: Verify that a valid POI on a non-denied, signal-above-threshold, non-stale allocation claims rewards normally. The `POIPresented` event should show `condition = bytes32(0)`. + +**Prerequisites**: Active allocation, open 2+ epochs, not stale, on a non-denied subgraph with signal above threshold. + +**Steps**: + +```bash +# Confirm allocation is healthy +cast call "getRewards(address,address)(uint256)" --rpc-url +# Expected: non-zero + +# Close allocation (presents POI and claims) +graph indexer allocations close +``` + +**Verification**: Check transaction for `POIPresented` event: + +```bash +POI_EVENT_SIG=$(cast sig-event "POIPresented(address,address,bytes32,bytes32,bytes,bytes32)") +cast logs --from-block --to-block --address --topic0 $POI_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `POIPresented` event emitted with `condition = 0x00...00` (NONE) +- `indexingRewards` non-zero +- Normal `HorizonRewardsAssigned` event emitted + +--- + +### 4.2 Reclaim path: STALE_POI + +**Objective**: When an allocation is stale (no POI presented within `maxPOIStaleness`), presenting a POI reclaims rewards instead of claiming them. + +**Prerequisites**: An allocation that has not had a POI presented for longer than `maxPOIStaleness`. + +**Steps**: + +```bash +# Check maxPOIStaleness +cast call "maxPOIStaleness()(uint256)" --rpc-url + +# Find or wait for a stale allocation +# (Let an allocation go without POI presentation for maxPOIStaleness seconds) + +# Close the stale allocation +graph indexer allocations close +``` + +**Pass Criteria**: + +- `POIPresented` event emitted with `condition = keccak256("STALE_POI")` +- `indexingRewards` = 0 (rewards not claimed by indexer) +- `RewardsReclaimed` event with reason = `STALE_POI` +- Reclaim address received the tokens +- Allocation snapshot advanced (pending rewards cleared) + +--- + +### 4.3 Reclaim path: ZERO_POI + +**Objective**: Submitting a zero POI (`bytes32(0)`) reclaims rewards. + +**Prerequisites**: Active allocation, mature (2+ epochs). + +**Steps**: + +```bash +# Close allocation with explicit zero POI +graph indexer allocations close --poi 0x0000000000000000000000000000000000000000000000000000000000000000 +``` + +**Pass Criteria**: + +- `POIPresented` event emitted with `condition = keccak256("ZERO_POI")` +- `indexingRewards` = 0 +- `RewardsReclaimed` event with reason = `ZERO_POI` +- Reclaim address received the tokens +- Allocation snapshot advanced (pending rewards cleared) + +--- + +### 4.4 Defer path: ALLOCATION_TOO_YOUNG + +**Objective**: Presenting a POI for an allocation created in the current epoch defers — returns 0 without advancing the snapshot, preserving rewards for later. + +**Prerequisites**: Create a new allocation and attempt POI presentation in the same epoch. + +**Steps**: + +```bash +# Create allocation +graph indexer allocations create + +# Immediately attempt POI presentation (same epoch) +# (via manual cast send or indexer agent action) +``` + +**Pass Criteria**: + +- `POIPresented` event emitted with `condition = keccak256("ALLOCATION_TOO_YOUNG")` +- Returns 0 rewards +- **Critical**: Allocation snapshot NOT advanced (rewards preserved for later) +- Allocation remains open and healthy +- After waiting for epoch boundary: normal claim succeeds + +--- + +### 4.5 POI presentation always updates timestamp + +**Objective**: Verify that the POI presentation timestamp is recorded regardless of the condition outcome. This means even reclaimed or deferred presentations reset the staleness clock. + +**Steps**: + +1. Present a POI that results in a defer (e.g., too young) +2. Check that the staleness timer reset +3. Present a POI that results in a reclaim (e.g., zero POI) +4. Check that the staleness timer reset + +**Pass Criteria**: + +- Staleness timer resets on every POI presentation, regardless of outcome +- An allocation that regularly presents POIs (even deferred ones) does not become stale + +--- + +## Cycle 5: Allocation Lifecycle + +### 5.1 Allocation resize reclaims stale rewards + +**Objective**: Resizing a stale allocation reclaims pending rewards as `STALE_POI` and clears them. This prevents stale allocations from silently accumulating rewards through repeated resizes. + +**Prerequisites**: An allocation that is stale (no POI for `maxPOIStaleness`). The allocation has pending rewards from before it went stale. + +**Steps**: + +```bash +# Confirm allocation is stale +# (Check last POI timestamp vs maxPOIStaleness) + +# Check pending rewards before resize +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Resize the allocation +graph indexer allocations reallocate +``` + +**Pass Criteria**: + +- `RewardsReclaimed` event with reason = `STALE_POI` +- Pending rewards cleared (not carried forward through resize) +- Reclaim address received the stale rewards +- New allocation starts fresh (no carried-over stale rewards) + +--- + +### 5.2 Allocation resize does NOT reclaim for non-stale allocation + +**Objective**: Resizing a healthy (non-stale) allocation should accumulate pending rewards normally, not reclaim them. + +**Prerequisites**: Active, non-stale allocation with pending rewards. + +**Steps**: + +```bash +# Check pending rewards +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Resize +graph indexer allocations reallocate + +# Check that no STALE_POI reclaim event occurred +``` + +**Pass Criteria**: + +- No `RewardsReclaimed` event with reason = `STALE_POI` +- Pending rewards accumulated into `accRewardsPending` (carried through resize) +- New allocation can claim accumulated rewards on next close + +--- + +### 5.3 Allocation close reclaims uncollected rewards + +**Objective**: When an allocation is closed, any uncollected rewards are reclaimed as `CLOSE_ALLOCATION` before the allocation is finalized. This prevents rewards from being permanently lost on close. + +**Prerequisites**: An allocation with uncollected rewards (e.g., the indexer has not presented a POI recently, or rewards accumulated since last POI). + +**Steps**: + +```bash +# Record reclaim address balance +cast call "balanceOf(address)(uint256)" --rpc-url + +# Close allocation +graph indexer allocations close + +# Check for CLOSE_ALLOCATION reclaim +CLOSE_ALLOC=$(cast keccak "CLOSE_ALLOCATION") +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") +cast logs --from-block --to-block --address --topic0 $RECLAIM_EVENT_SIG --rpc-url + +# Check reclaim address balance increased +cast call "balanceOf(address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `RewardsReclaimed` event with reason = `CLOSE_ALLOCATION` +- Reclaim address balance increased +- Rewards not permanently lost (either claimed by indexer via POI or reclaimed to protocol) + +--- + +## Cycle 6: Observability + +### 6.1 POIPresented event emitted on every presentation + +**Objective**: Verify that every POI presentation emits a `POIPresented` event with the determined condition, regardless of outcome. + +**Steps**: + +Collect events across multiple scenarios from previous cycles: + +```bash +POI_EVENT_SIG=$(cast sig-event "POIPresented(address,address,bytes32,bytes32,bytes,bytes32)") + +# Query all POIPresented events from the test session +cast logs --from-block --to-block latest --address --topic0 $POI_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- Every POI presentation (from Cycles 4-5) has a corresponding `POIPresented` event +- Each event contains: + - `indexer`: correct indexer address + - `allocationId`: correct allocation + - `subgraphDeploymentId`: correct deployment + - `poi`: the submitted POI value + - `condition`: matches the expected outcome (NONE, STALE_POI, ZERO_POI, ALLOCATION_TOO_YOUNG, SUBGRAPH_DENIED) + +--- + +### 6.2 RewardsReclaimed events include full context + +**Objective**: Verify that `RewardsReclaimed` events contain all necessary context for off-chain accounting. + +**Steps**: + +```bash +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") + +# Query all RewardsReclaimed events from the test session +cast logs --from-block --to-block latest --address --topic0 $RECLAIM_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- Each `RewardsReclaimed` event contains: + - `reason`: valid `RewardsCondition` identifier (not zero) + - `amount`: non-zero GRT amount + - `indexer`: address of the affected indexer (or zero for subgraph-level reclaims) + - `allocationID`: address of the affected allocation (or zero for subgraph-level reclaims) + - `subgraphDeploymentID`: deployment hash + +--- + +### 6.3 View functions reflect frozen state accurately + +**Objective**: Verify that `getAccRewardsForSubgraph()`, `getAccRewardsPerAllocatedToken()`, and `getRewards()` correctly return frozen values for non-claimable subgraphs and growing values for claimable ones. + +**Steps**: + +```bash +# For a denied subgraph (if one is still denied from SubgraphDenialTestPlan) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +# Wait, read again — should be unchanged + +# For a below-threshold subgraph (if one is still below from Cycle 2) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +# Wait, read again — should be unchanged + +# For a healthy subgraph (control) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +# Wait, read again — should have increased + +# getRewards for allocation on non-claimable subgraph +cast call "getRewards(address,address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Non-claimable subgraphs: view functions return frozen (non-increasing) values +- Claimable subgraphs: view functions return growing values +- `getRewards()` for allocations on non-claimable subgraphs returns a frozen value +- Pre-existing `accRewardsPending` from prior resizes is still included in `getRewards()` even for non-claimable subgraphs + +--- + +## Cycle 7: Zero Global Signal + +> **Note**: These tests require zero total curation signal across the entire network, which is impractical on a shared testnet. They are documented here for completeness and should be validated via Foundry unit tests or on a dedicated test network. + +### 7.1 NO_SIGNAL detection + +**Objective**: When total curation signal across all subgraphs is zero, issuance during that period should be reclaimed as `NO_SIGNAL`. + +**Steps** (dedicated testnet only): + +```bash +# Remove all curation signal from all subgraphs +# (Only feasible on a private testnet) + +# Wait for blocks to pass (issuance accrues to nobody) + +# Trigger accumulator update +cast send "updateAccRewardsPerSignal()" --rpc-url --private-key + +# Check for RewardsReclaimed with NO_SIGNAL +NO_SIGNAL=$(cast keccak "NO_SIGNAL") +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") +cast logs --from-block --to-block --address --topic0 $RECLAIM_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `RewardsReclaimed` event with reason = `NO_SIGNAL` +- Reclaimed amount corresponds to issuance during zero-signal period +- `getNewRewardsPerSignal()` still returns claimable portion only (unchanged from legacy behavior) + +--- + +### 7.2 Signal restoration resumes normal distribution + +**Objective**: After signal is restored, rewards distribution resumes normally. + +**Steps** (dedicated testnet only): + +1. Add curation signal to a subgraph +2. Verify `getNewRewardsPerSignal()` returns non-zero +3. Verify accumulators resume growing + +**Pass Criteria**: + +- Rewards flow normally after signal restoration +- No rewards from the zero-signal period leak into the normal distribution + +--- + +## Post-Testing Checklist + +- [ ] Reclaim addresses verified for all conditions +- [ ] `minimumSubgraphSignal` restored to original value +- [ ] No subgraphs left in unintended denied state +- [ ] Reclaim address balances reconciled with expected amounts +- [ ] All `POIPresented` events collected and categorized +- [ ] Results documented in test tracker + +--- + +## Test Summary + +| Condition | Test(s) | Cycle | Testnet Feasibility | +| ------------------------ | --------- | ----- | ---------------------- | +| Reclaim infrastructure | 1.1 - 1.5 | 1 | Full | +| `BELOW_MINIMUM_SIGNAL` | 2.1 - 2.4 | 2 | Full | +| `NO_ALLOCATED_TOKENS` | 3.1 - 3.3 | 3 | Full | +| `NONE` (normal claim) | 4.1 | 4 | Full | +| `STALE_POI` | 4.2 | 4 | Full (wait needed) | +| `ZERO_POI` | 4.3 | 4 | Full | +| `ALLOCATION_TOO_YOUNG` | 4.4 | 4 | Full | +| POI timestamp behavior | 4.5 | 4 | Full | +| Stale resize reclaim | 5.1 - 5.2 | 5 | Full (wait needed) | +| `CLOSE_ALLOCATION` | 5.3 | 5 | Full | +| `POIPresented` event | 6.1 | 6 | Full | +| `RewardsReclaimed` event | 6.2 | 6 | Full | +| View function freeze | 6.3 | 6 | Full | +| `NO_SIGNAL` | 7.1 - 7.2 | 7 | Dedicated testnet only | + +--- + +## Related Documentation + +- [← Back to REO Testing](README.md) +- [SubgraphDenialTestPlan.md](SubgraphDenialTestPlan.md) — Subgraph denial behavior tests +- [BaselineTestPlan.md](BaselineTestPlan.md) — Baseline operational tests (run first) +- [ReoTestPlan.md](ReoTestPlan.md) — REO eligibility tests + +--- + +_Derived from issuance upgrade behavior changes. Source: [RewardsBehaviourChanges.md](/docs/RewardsBehaviourChanges.md), [RewardConditions.md](/docs/RewardConditions.md). Contracts: `packages/contracts/contracts/rewards/RewardsManager.sol`, `packages/subgraph-service/contracts/utilities/AllocationManager.sol`._ diff --git a/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md b/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md new file mode 100644 index 000000000..cc03a7d7d --- /dev/null +++ b/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md @@ -0,0 +1,680 @@ +# Subgraph Denial Test Plan + +> **Status: Complete** — Local network automation validates Cycles 2, 3, 5, and 6 (edge cases). Cycle 4 (allocation-level deferral) needs direct POI presentation. +> +> **Navigation**: [← Back to REO Testing](README.md) | [BaselineTestPlan](BaselineTestPlan.md) | [RewardsConditionsTestPlan](RewardsConditionsTestPlan.md) + +Tests for the subgraph denial behavior changes introduced in the issuance upgrade. Denial handling changed significantly: accumulators now freeze during denial (reclaiming new rewards), while uncollected pre-denial rewards are preserved and become claimable after undeny. + +> All contract reads use `cast call`. All addresses must be **lowercase**. Replace placeholder addresses with actual deployed addresses for your network. + +## Contract Addresses + +| Contract | Arbitrum Sepolia | Arbitrum One | +| ----------------------- | -------------------------------------------- | -------------------------------------------- | +| RewardsManager (proxy) | `0x1f49cae7669086c8ba53cc35d1e9f80176d67e79` | `0x971b9d3d0ae3eca029cab5ea1fb0f72c85e6a525` | +| SubgraphService (proxy) | `0xc24a3dac5d06d771f657a48b20ce1a671b78f26b` | `0xb2bb92d0de618878e438b55d5846cfecd9301105` | +| GraphToken (L2) | `0xf8c05dcf59e8b28bfd5eed176c562bebcfc7ac04` | `0x9623063377ad1b27544c965ccd7342f7ea7e88c7` | +| Controller | `0x9db3ee191681f092607035d9bda6e59fbeaca695` | `0x0a8491544221dd212964fbb96487467291b2c97e` | + +**Address sources**: `packages/horizon/addresses.json` (RewardsManager, GraphToken, Controller), `packages/subgraph-service/addresses.json` (SubgraphService). + +### RPC + +| Network | RPC URL | +| ---------------- | ---------------------------------------- | +| Arbitrum Sepolia | `https://sepolia-rollup.arbitrum.io/rpc` | + +--- + +## Background + +### What Changed + +**Before (Horizon baseline):** Denial was a binary gate at `takeRewards()` time. When a subgraph was denied, rewards were returned as 0 and the allocation snapshot advanced, permanently dropping those rewards. + +**After (issuance upgrade):** Denial is handled at two levels: + +1. **RewardsManager (accumulator level):** When accumulator updates encounter a denied subgraph, `accRewardsForSubgraph` and `accRewardsPerAllocatedToken` freeze. New rewards during denial are reclaimed instead of accumulated. `setDenied()` snapshots accumulators before changing state so the boundary is clean. + +2. **AllocationManager (claim level):** POI presentation for a denied subgraph is _deferred_ — returns 0 **without advancing the allocation snapshot**. Uncollected pre-denial rewards are preserved and become claimable after undeny. + +### Key Invariants + +- Accumulators never decrease (they freeze during denial, not decrease) +- Pre-denial uncollected rewards are preserved through the deny/undeny cycle +- Denial-period rewards are reclaimed (or dropped if no reclaim address) +- `setDenied()` snapshots accumulators before state change (clean boundary) +- Redundant deny/undeny calls are idempotent (no state change) + +--- + +## Prerequisites + +- [Baseline tests](BaselineTestPlan.md) Cycles 1-7 pass +- [Reclaim system configured](RewardsConditionsTestPlan.md#cycle-1-reclaim-system-configuration) (Cycle 1 of RewardsConditionsTestPlan) — or configure inline during Cycle 1 below +- At least two indexers with active allocations on rewarded subgraph deployments +- Access to the Governor or SubgraphAvailabilityOracle (SAO) account that can call `setDenied()` +- Allocations must be mature (open for 2+ epochs) before denial tests + +### Roles Needed + +| Role | Needed For | Holder | +| --------------- | --------------------------------------------- | -------------------------------- | +| Governor or SAO | `setDenied()` calls | Check Controller configuration | +| Governor | `setReclaimAddress()` (if not yet configured) | Council/NetworkOperator multisig | + +### Identifying the SAO + +```bash +# The SAO is stored in the Controller as the subgraphAvailabilityOracle +# Alternatively, check who can call setDenied on RewardsManager +cast call "getContractProxy(bytes32)(address)" $(cast keccak "SubgraphAvailabilityOracle") --rpc-url +``` + +--- + +## Testing Approach + +**Dedicated test subgraph**: Use a subgraph deployment that is not critical to other testing. The deployment should have: + +- Non-zero curation signal +- At least two active allocations from different indexers +- Signal above `minimumSubgraphSignal` (to isolate denial behavior from signal threshold behavior) + +**Epoch timing**: Many tests require waiting for epoch boundaries. On Sepolia, epochs are ~554 blocks (~110 minutes). Plan sessions accordingly. + +**Reclaim address monitoring**: Before starting, configure a reclaim address for `SUBGRAPH_DENIED` so reclaimed tokens are observable. If no reclaim address is set, denial-period rewards are silently dropped. + +--- + +## Test Sequence Overview + +| Cycle | Area | Tests | Notes | +| ----- | ------------------------------- | --------- | -------------------------------------------------- | +| 1 | Reclaim Setup for Denial | 1.1 - 1.2 | Governor access needed; skip if already configured | +| 2 | Denial State Management | 2.1 - 2.4 | SAO or Governor access needed | +| 3 | Accumulator Freeze Verification | 3.1 - 3.4 | Read-only after denial; wait for epochs | +| 4 | Allocation-Level Deferral | 4.1 - 4.3 | Requires active allocations on denied subgraph | +| 5 | Undeny and Reward Recovery | 5.1 - 5.4 | Full deny→undeny→claim lifecycle | +| 6 | Edge Cases | 6.1 - 6.4 | Advanced scenarios | + +--- + +## Cycle 1: Reclaim Setup for Denial + +> Skip this cycle if reclaim addresses are already configured (verify with tests 1.1 reads). + +### 1.1 Configure SUBGRAPH_DENIED reclaim address + +**Objective**: Set a reclaim address for `SUBGRAPH_DENIED` so that denial-period rewards are minted to a trackable address instead of being silently dropped. + +**Steps**: + +```bash +# Compute the SUBGRAPH_DENIED condition identifier +SUBGRAPH_DENIED=$(cast keccak "SUBGRAPH_DENIED") + +# Check current reclaim address (expect zero if unconfigured) +cast call "getReclaimAddress(bytes32)(address)" $SUBGRAPH_DENIED --rpc-url + +# Set reclaim address (as Governor) +cast send "setReclaimAddress(bytes32,address)" $SUBGRAPH_DENIED --rpc-url --private-key + +# Verify +cast call "getReclaimAddress(bytes32)(address)" $SUBGRAPH_DENIED --rpc-url +``` + +**Pass Criteria**: + +- `ReclaimAddressSet` event emitted with correct reason and address +- `getReclaimAddress(SUBGRAPH_DENIED)` returns the configured address + +--- + +### 1.2 Record reclaim address GRT balance + +**Objective**: Record the starting GRT balance of the reclaim address so we can measure tokens reclaimed during denial. + +**Steps**: + +```bash +cast call "balanceOf(address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Balance recorded for later comparison + +--- + +## Cycle 2: Denial State Management + +### 2.1 Verify subgraph is not denied (pre-test) + +**Objective**: Confirm the test subgraph deployment is currently not denied and accumulators are growing. + +**Steps**: + +```bash +# Check denial status +cast call "isDenied(bytes32)(bool)" --rpc-url + +# Record current accumulator values +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +cast call "getAccRewardsPerAllocatedToken(bytes32)(uint256,uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `isDenied` = `false` +- Accumulator values recorded as baseline + +--- + +### 2.2 Deny subgraph deployment + +**Objective**: Deny a subgraph and verify the state transition. Confirm `setDenied()` snapshots accumulators before applying denial. + +**Steps**: + +```bash +# Deny the subgraph (as SAO or Governor) +cast send "setDenied(bytes32,bool)" true --rpc-url --private-key + +# Verify denial +cast call "isDenied(bytes32)(bool)" --rpc-url +``` + +**Verification**: Check for `RewardsDenylistUpdated` event: + +```bash +# Check the transaction receipt for RewardsDenylistUpdated event +cast receipt --rpc-url +``` + +**Pass Criteria**: + +- Transaction succeeds +- `isDenied` = `true` +- `RewardsDenylistUpdated(subgraphDeploymentID, sinceBlock)` event emitted with `sinceBlock` = block number of the transaction + +--- + +### 2.3 Redundant deny is idempotent + +**Objective**: Calling `setDenied(true)` on an already-denied subgraph should not change state or emit new events. + +**Steps**: + +```bash +# Deny again (already denied) +cast send "setDenied(bytes32,bool)" true --rpc-url --private-key + +# Verify still denied +cast call "isDenied(bytes32)(bool)" --rpc-url +``` + +**Pass Criteria**: + +- Transaction succeeds (does not revert) +- `isDenied` still = `true` +- No additional `RewardsDenylistUpdated` event (or event has unchanged `sinceBlock`) + +--- + +### 2.4 Unauthorized deny reverts + +**Objective**: Only the SAO or Governor can deny subgraphs. + +**Steps**: + +```bash +# Attempt deny from unauthorized account +cast send "setDenied(bytes32,bool)" true --rpc-url --private-key +``` + +**Pass Criteria**: + +- Transaction reverts + +--- + +## Cycle 3: Accumulator Freeze Verification + +> **Timing**: These tests require waiting for time to pass after denial. At minimum, wait for part of an epoch (~30-60 minutes on Sepolia) between reads to observe that accumulators have stopped growing. + +### 3.1 Accumulators freeze after denial + +**Objective**: Verify that `accRewardsForSubgraph` and `accRewardsPerAllocatedToken` stop growing for a denied subgraph. + +**Prerequisites**: Subgraph denied in test 2.2. Wait at least 30 minutes. + +**Steps**: + +```bash +# Read accumulators (should match or be very close to values recorded at denial time) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +cast call "getAccRewardsPerAllocatedToken(bytes32)(uint256,uint256)" --rpc-url + +# Compare with a non-denied subgraph (should be growing) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Denied subgraph: `accRewardsForSubgraph` has NOT increased since denial +- Denied subgraph: `accRewardsPerAllocatedToken` has NOT increased since denial +- Non-denied subgraph: accumulators continue to increase normally (control) + +--- + +### 3.2 getRewards returns frozen value for allocations on denied subgraph + +**Objective**: Verify that `getRewards()` for an allocation on a denied subgraph returns a frozen value (no new rewards accumulate). + +**Steps**: + +```bash +# Check pending rewards for allocation on denied subgraph +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Wait some time, check again +# (wait 30+ minutes) +cast call "getRewards(address,address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Both reads return the same value (frozen — no new rewards accruing) +- The value represents pre-denial uncollected rewards (may be non-zero) + +--- + +### 3.3 Denial-period rewards reclaimed + +**Objective**: Verify that rewards that would have gone to the denied subgraph are being reclaimed to the configured address. + +**Prerequisites**: Reclaim address configured in Cycle 1. Some time has passed since denial. + +**Steps**: + +```bash +# Trigger an accumulator update that processes the denied subgraph +# This happens automatically on signal/allocation changes, but can be forced: +cast send "onSubgraphSignalUpdate(bytes32)" --rpc-url --private-key + +# Check reclaim address balance +cast call "balanceOf(address)(uint256)" --rpc-url +``` + +**Verification**: Check for `RewardsReclaimed` events: + +```bash +RECLAIM_EVENT_SIG=$(cast sig-event "RewardsReclaimed(bytes32,uint256,address,address,bytes32)") +cast logs --from-block --to-block latest --address --topic0 $RECLAIM_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `RewardsReclaimed` event(s) emitted with reason = `SUBGRAPH_DENIED` +- Reclaim address GRT balance has increased from the Cycle 1 baseline +- Reclaimed amount is proportional to the denied subgraph's signal share and denial duration + +--- + +### 3.4 Non-denied subgraphs unaffected + +**Objective**: Confirm that denying one subgraph does not affect reward accumulation for other subgraphs. + +**Steps**: + +```bash +# Check a non-denied subgraph's accumulator +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +# Check allocation rewards on non-denied subgraph +cast call "getRewards(address,address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Non-denied subgraph accumulators continue increasing +- Allocation rewards on non-denied subgraph continue accruing + +--- + +## Cycle 4: Allocation-Level Deferral + +### 4.1 POI presentation on denied subgraph defers (returns 0, preserves state) + +**Objective**: When an indexer presents a POI for a denied subgraph, the allocation should return 0 rewards WITHOUT advancing the snapshot. The `POIPresented` event should show `condition = SUBGRAPH_DENIED`. + +**Prerequisites**: Indexer has an active allocation on the denied subgraph. Allocation is mature (open 2+ epochs). + +**Steps**: + +1. Record the allocation's current reward snapshot (via view functions) +2. Close or present POI for the allocation on the denied subgraph + +```bash +# Check pending rewards before POI presentation +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Present POI (via indexer agent or manual close attempt) +# The exact mechanism depends on your indexer setup +graph indexer allocations close +``` + +**Verification**: Check transaction logs for `POIPresented` event: + +```bash +POI_EVENT_SIG=$(cast sig-event "POIPresented(address,address,bytes32,bytes32,bytes,bytes32)") +cast logs --from-block --to-block --address --topic0 $POI_EVENT_SIG --rpc-url +``` + +**Pass Criteria**: + +- `POIPresented` event emitted with `condition` = `keccak256("SUBGRAPH_DENIED")` +- Rewards returned = 0 +- **Critical**: Allocation snapshot NOT advanced (pre-denial rewards preserved) +- Allocation remains open if this was a POI presentation (not a force-close) + +--- + +### 4.2 Multiple POI presentations while denied do not lose rewards + +**Objective**: An indexer can present POIs multiple times while a subgraph is denied without losing any pre-denial rewards. Each presentation should defer without advancing the snapshot. + +**Steps**: + +```bash +# First POI presentation (while denied) +# Record getRewards value +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Present POI +# (use indexer agent or cast send to SubgraphService) + +# Second POI presentation (still denied, next epoch) +# Wait one epoch +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Present POI again +``` + +**Pass Criteria**: + +- `getRewards()` returns the same frozen value across all presentations +- No `RewardsReclaimed` events for the allocation's pre-denial rewards +- Pre-denial rewards remain preserved through multiple POI cycles + +--- + +### 4.3 Indexers should continue presenting POIs during denial + +**Objective**: Document that continuing POI presentation during denial prevents staleness. The POI timestamp is updated even on deferred presentations. + +**Steps**: + +1. Confirm the denied subgraph has active allocations +2. Present POI normally (via indexer agent) +3. Verify the allocation's last POI timestamp is updated + +**Pass Criteria**: + +- POI presentation succeeds (transaction does not revert) +- Allocation does not become stale during denial period +- When subgraph is later undenied, the allocation is still healthy (not stale) + +--- + +## Cycle 5: Undeny and Reward Recovery + +### 5.1 Undeny subgraph deployment + +**Objective**: Remove denial and verify accumulators resume growing. + +**Steps**: + +```bash +# Record accumulators just before undeny +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +# Undeny +cast send "setDenied(bytes32,bool)" false --rpc-url --private-key + +# Verify +cast call "isDenied(bytes32)(bool)" --rpc-url +``` + +**Verification**: Check for `RewardsDenylistUpdated` event with `sinceBlock = 0`. + +**Pass Criteria**: + +- `isDenied` = `false` +- `RewardsDenylistUpdated(subgraphDeploymentID, 0)` event emitted + +--- + +### 5.2 Accumulators resume after undeny + +**Objective**: Verify that accumulators start growing again after undeny. + +**Prerequisites**: Subgraph undenied in test 5.1. Wait at least 30 minutes. + +**Steps**: + +```bash +# Read accumulators (should now be growing again) +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +cast call "getAccRewardsPerAllocatedToken(bytes32)(uint256,uint256)" --rpc-url +``` + +**Pass Criteria**: + +- `accRewardsForSubgraph` has increased since undeny +- `accRewardsPerAllocatedToken` has increased since undeny +- Growth rate is consistent with the subgraph's signal proportion + +--- + +### 5.3 Pre-denial rewards claimable after undeny + +**Objective**: Verify that uncollected rewards from before the denial period are now claimable. This is the critical test: the new behavior preserves these rewards rather than dropping them. + +**Prerequisites**: Indexer has allocation that was open before denial and still active. Subgraph is now undenied. Wait 1-2 epochs after undeny. + +**Steps**: + +```bash +# Check pending rewards (should include pre-denial uncollected + post-undeny new rewards) +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Close allocation to claim +graph indexer allocations close +``` + +**Verification Query**: + +```graphql +{ + allocations(where: { id: "ALLOCATION_ID" }) { + id + status + indexingRewards + closedAtEpoch + } +} +``` + +**Pass Criteria**: + +- `indexingRewards` is non-zero +- Reward amount includes: + - Pre-denial uncollected rewards (accumulated before deny) + - Post-undeny rewards (accumulated after undeny) +- Reward amount does NOT include denial-period rewards (those were reclaimed in Cycle 3) +- `POIPresented` event shows `condition = NONE` (normal claim) + +--- + +### 5.4 Denial-period rewards are NOT included in claim + +**Objective**: Verify that the claimed rewards exclude the denial period. Compare the claimed amount against what a continuously-active allocation would have earned. + +**Steps**: + +1. Calculate expected rewards: + - Pre-denial period: from allocation creation to deny block + - Post-undeny period: from undeny block to close block + - Denial period: from deny block to undeny block (should be excluded) +2. Compare actual `indexingRewards` from test 5.3 + +**Pass Criteria**: + +- Claimed rewards approximate (pre-denial + post-undeny) only +- Denial-period rewards were reclaimed (verified in Cycle 3) +- Total of (claimed + reclaimed) approximately equals what would have been earned with no denial + +--- + +## Cycle 6: Edge Cases + +### 6.1 New allocation created while subgraph is denied + +**Objective**: An allocation opened on a denied subgraph starts with a frozen baseline. It should only earn rewards after undeny. + +**Prerequisites**: Subgraph currently denied. + +**Steps**: + +```bash +# Create allocation on denied subgraph +graph indexer allocations create + +# Check rewards immediately +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Wait some time (still denied) +# Check rewards again +cast call "getRewards(address,address)(uint256)" --rpc-url + +# Undeny +cast send "setDenied(bytes32,bool)" false --rpc-url --private-key + +# Wait 1-2 epochs after undeny +# Check rewards again +cast call "getRewards(address,address)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- While denied: `getRewards()` returns 0 (no rewards accumulate) +- After undeny: `getRewards()` starts increasing (rewards resume from undeny point) +- Allocation only earns post-undeny rewards + +--- + +### 6.2 All allocations close while denied, then new allocation after undeny + +**Objective**: When all allocations close during denial, the frozen accumulator state is preserved. A new allocation after undeny should use that preserved baseline. + +**Steps**: + +1. Deny subgraph (if not already denied) +2. Close all allocations on the denied subgraph +3. Undeny subgraph +4. Create new allocation +5. Wait 1-2 epochs, close, check rewards + +**Pass Criteria**: + +- New allocation earns rewards only for the post-undeny period +- Frozen state was correctly preserved through the "no allocations" period +- No rewards are double-counted or lost at the transition + +--- + +### 6.3 Deny and undeny in rapid succession + +**Objective**: A quick deny→undeny cycle correctly handles the boundary. Accumulators are snapshotted on each transition. + +**Steps**: + +```bash +# Record accumulators +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url + +# Deny +cast send "setDenied(bytes32,bool)" true --rpc-url --private-key + +# Undeny (in next block or shortly after) +cast send "setDenied(bytes32,bool)" false --rpc-url --private-key + +# Check accumulators +cast call "getAccRewardsForSubgraph(bytes32)(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Both transactions succeed +- Accumulators resume growing after undeny +- Minimal reward loss (only the few blocks between deny and undeny) +- No contract reverts or unexpected state + +--- + +### 6.4 Denial interaction with indexer eligibility + +**Objective**: Subgraph denial takes precedence over indexer eligibility. When a subgraph is denied, POI presentation defers regardless of eligibility status — ensuring pre-denial rewards are preserved even for ineligible indexers. + +**Prerequisites**: REO validation enabled, one indexer ineligible, subgraph denied. + +**Steps**: + +```bash +# Confirm indexer is ineligible +cast call "isEligible(address)(bool)" --rpc-url +# Expected: false + +# Confirm subgraph is denied +cast call "isDenied(bytes32)(bool)" --rpc-url +# Expected: true + +# Present POI for ineligible indexer on denied subgraph +# (via indexer agent or manual) +``` + +**Pass Criteria**: + +- POI presentation defers (not reclaimed as INDEXER_INELIGIBLE) +- `POIPresented` event shows `condition = SUBGRAPH_DENIED` (denial takes precedence) +- Pre-denial rewards preserved (not reclaimed due to ineligibility) +- After undeny + re-renewal: rewards become claimable + +--- + +## Post-Testing Checklist + +- [ ] All denied subgraphs undenied (or left in intended state) +- [ ] Reclaim addresses verified +- [ ] No allocations stuck in unexpected state +- [ ] Reclaim address balance increase accounted for +- [ ] Results documented in test tracker + +--- + +## Related Documentation + +- [← Back to REO Testing](README.md) +- [RewardsConditionsTestPlan.md](RewardsConditionsTestPlan.md) — Signal, POI, and allocation lifecycle conditions +- [BaselineTestPlan.md](BaselineTestPlan.md) — Baseline operational tests (run first) +- [ReoTestPlan.md](ReoTestPlan.md) — REO eligibility tests + +--- + +_Derived from issuance upgrade behavior changes. Source: [RewardsBehaviourChanges.md](/docs/RewardsBehaviourChanges.md), [RewardConditions.md](/docs/RewardConditions.md). Contract: `packages/contracts/contracts/rewards/RewardsManager.sol`, `packages/subgraph-service/contracts/utilities/AllocationManager.sol`._ diff --git a/packages/issuance/docs/testing/reo/TestnetDetails.md b/packages/issuance/docs/testing/reo/TestnetDetails.md new file mode 100644 index 000000000..88ceffd34 --- /dev/null +++ b/packages/issuance/docs/testing/reo/TestnetDetails.md @@ -0,0 +1,65 @@ +# Arbitrum Sepolia — Testnet Details + +## Network Parameters + +| Parameter | Value | +| ----------------------- | ---------------------------------------------- | +| Explorer | | +| Gateway | | +| Network subgraph | `3xQHhMudr1oh69ut36G2mbzpYmYxwqCeU6wwqyCDCnqV` | +| RPC | | +| Epoch length | ~554 blocks (~110 minutes) | +| Max allocation lifetime | 8 epochs (~15 hours) | +| Min indexer stake | 100k GRT | +| Thawing period | Shortened for faster testing | + +## Network Subgraph + +**Query via Graph Explorer**: [Graph Network Arbitrum Sepolia](https://thegraph.com/explorer/subgraphs/3xQHhMudr1oh69ut36G2mbzpYmYxwqCeU6wwqyCDCnqV?view=Query&chain=arbitrum-one) + +Or query directly: + +```bash +export GRAPH_API_KEY= +curl "https://gateway.thegraph.com/api/$GRAPH_API_KEY/subgraphs/id/3xQHhMudr1oh69ut36G2mbzpYmYxwqCeU6wwqyCDCnqV" \ + -H 'content-type: application/json' \ + -d '{"query": "{ _meta { block { number } } }"}' +``` + +## Contract Addresses + +| Contract | Address | +| ---------------------------- | -------------------------------------------- | +| RewardsEligibilityOracle | `0x62c2305739cc75f19a3a6d52387ceb3690d99a99` | +| MockRewardsEligibilityOracle | `0x5FB23365F8cf643D5f1459E9793EfF7254522400` | +| RewardsManager | `0x1f49cae7669086c8ba53cc35d1e9f80176d67e79` | +| SubgraphService | `0xc24a3dac5d06d771f657a48b20ce1a671b78f26b` | +| GraphToken (L2) | `0xf8c05dcf59e8b28bfd5eed176c562bebcfc7ac04` | +| Controller | `0x9db3ee191681f092607035d9bda6e59fbeaca695` | + +## Mock REO (Testnet) + +The testnet RewardsManager is configured to use the `MockRewardsEligibilityOracle` rather than the real REO, to allow indexers to control their own eligibility during testing. + +The mock uses `msg.sender` as the indexer address, so each indexer controls their own eligibility by sending transactions from their own key. + +Check what the mock reports to RewardsManager for an address: + +```bash +cast call --rpc-url https://sepolia-rollup.arbitrum.io/rpc \ + 0x5FB23365F8cf643D5f1459E9793EfF7254522400 \ + "isEligible(address)(bool)"

+``` + +Set your own eligibility (send from the indexer key): + +```bash +cast send --rpc-url https://sepolia-rollup.arbitrum.io/rpc \ + --private-key $PRIVATE_KEY \ + 0x5FB23365F8cf643D5f1459E9793EfF7254522400 \ + "setEligible(bool)" +``` + +--- + +- [← Back to REO Testing](README.md) diff --git a/packages/issuance/docs/testing/reo/support/IssuanceAllocatorTestPlan.md b/packages/issuance/docs/testing/reo/support/IssuanceAllocatorTestPlan.md new file mode 100644 index 000000000..d8ab63f85 --- /dev/null +++ b/packages/issuance/docs/testing/reo/support/IssuanceAllocatorTestPlan.md @@ -0,0 +1,98 @@ +# IssuanceAllocator Test Plan + +> **Navigation**: [← Back to REO Testing](../README.md) + +Separated from the REO test plan — IssuanceAllocator is independent of the Rewards Eligibility Oracle. Test when deployed. + +## Contract Addresses + +| Contract | Arbitrum Sepolia | Arbitrum One | +| ------------------------- | -------------------------------------------- | ------------ | +| IssuanceAllocator (proxy) | Not yet deployed | TBD | +| RewardsManager (proxy) | `0x1f49cae7669086c8ba53cc35d1e9f80176d67e79` | TBD | +| GraphToken (L2) | `0xf8c05dcf59e8b28bfd5eed176c562bebcfc7ac04` | TBD | + +--- + +## Tests + +### 1. Verify IssuanceAllocator configuration + +**Objective**: Confirm the IssuanceAllocator is correctly configured with RewardsManager as a self-minting target. + +**Steps**: + +```bash +# Check issuance rate +cast call "getIssuancePerBlock()(uint256)" --rpc-url + +# Check RewardsManager target allocation +cast call "getTargetIssuancePerBlock(address)(uint256,uint256)" --rpc-url + +# Check if IssuanceAllocator is minter +cast call "isMinter(address)(bool)" --rpc-url + +# Check RewardsManager knows about IssuanceAllocator +cast call "getIssuanceAllocator()(address)" --rpc-url +``` + +**Pass Criteria**: + +- `getIssuancePerBlock` returns the expected issuance rate +- RewardsManager has self-minting allocation = 100% of issuance +- IssuanceAllocator is a minter on GraphToken +- RewardsManager points to IssuanceAllocator + +--- + +### 2. Distribute issuance + +**Objective**: Verify `distributeIssuance()` executes correctly. + +**Steps**: + +```bash +# Anyone can call this +cast send "distributeIssuance()" --rpc-url --private-key +``` + +**Pass Criteria**: + +- Transaction succeeds +- No unexpected reverts + +--- + +### 3. Verify issuance rate matches RewardsManager + +**Objective**: Confirm the issuance rate in IssuanceAllocator matches what RewardsManager expects. + +**Steps**: + +```bash +# IssuanceAllocator rate +cast call "getIssuancePerBlock()(uint256)" --rpc-url + +# RewardsManager effective rate +cast call "issuancePerBlock()(uint256)" --rpc-url +``` + +**Pass Criteria**: + +- Both values are identical + +--- + +### 4. IssuanceAllocator not paused + +**Objective**: Confirm the IssuanceAllocator is operational. + +**Steps**: + +```bash +cast call "paused()(bool)" --rpc-url +``` + +**Pass Criteria**: + +- Returns `false` diff --git a/packages/issuance/docs/testing/reo/support/NotionSetup.md b/packages/issuance/docs/testing/reo/support/NotionSetup.md new file mode 100644 index 000000000..2ebcc8e6c --- /dev/null +++ b/packages/issuance/docs/testing/reo/support/NotionSetup.md @@ -0,0 +1,70 @@ +# Notion Tracker Setup + +> **Navigation**: [← Back to REO Testing](../README.md) + +Instructions for setting up the Notion-based test tracker from [NotionTracker.csv](NotionTracker.csv). + +## Import into Notion + +1. Open Notion, navigate to the workspace where you want the tracker +2. Click **Import** (sidebar → Import, or `...` menu → Import) +3. Select **CSV** and upload `NotionTracker.csv` +4. Notion creates a database from the CSV + +## Configure Column Types + +After import, change these column types in the database: + +| Column | Change to | Notes | +| --------- | ------------ | --------------------------------------------------------------- | +| Indexer A | **Checkbox** | Indexer marks when they've completed the test | +| Indexer B | **Checkbox** | Same | +| Indexer C | **Checkbox** | Same | +| Status | **Select** | Options: Not Started, In Progress, Pass, Fail, Blocked, Skipped | +| Link | **URL** | Links are already full GitHub URLs | +| Plan | **Select** | Enables grouping by test plan (Baseline / Eligibility) | + +### Add Indexer Columns + +If you have more than 3 indexers, add additional checkbox columns. Rename the generic "Indexer A/B/C" columns to the actual indexer names or addresses. + +## Recommended Views + +### 1. Main Tracker (Table) + +Default view — all tests in sequence. Sort by **Test ID**. + +### 2. By Plan (Board) + +Board view grouped by **Plan**. Shows progress through Baseline vs Eligibility at a glance. + +### 3. Per-Indexer (Filtered Tables) + +Create a filtered table for each indexer showing their checkbox and status columns. + +### 4. Blocked / Failed + +Filter: Status = Fail or Blocked. Use during testing to track issues. + +## Workflow + +1. **Before testing**: Share the Notion page with participating indexers (edit access) +2. **During testing**: Indexers check their checkbox when they complete a test. Update Status column. +3. **Coordinator**: Updates Status and Notes columns as tests progress +4. **After each session**: Review blocked/failed tests, update Notes with details + +## Column Reference + +| Column | Purpose | +| ----------- | -------------------------------------------------- | +| Test ID | Unique identifier (e.g. B-3.2 = Baseline test 3.2) | +| Plan | Test plan: Baseline or Eligibility | +| Test Name | Short test title | +| Link | Link to detailed test steps in IndexerTestGuide.md | +| Indexer A-C | Checkboxes for each indexer to confirm completion | +| Status | Current test status | +| Notes | Free text for issues, observations, tx hashes | + +--- + +**Related**: [NotionTracker.csv](NotionTracker.csv) | [IndexerTestGuide.md](../IndexerTestGuide.md) diff --git a/packages/issuance/docs/testing/reo/support/NotionTracker.csv b/packages/issuance/docs/testing/reo/support/NotionTracker.csv new file mode 100644 index 000000000..c8ad3a5be --- /dev/null +++ b/packages/issuance/docs/testing/reo/support/NotionTracker.csv @@ -0,0 +1,77 @@ +Test ID,Plan,Test Name,Link,Indexer A,Indexer B,Indexer C,Status,Notes +B-1.1,Baseline,Setup indexer via Explorer,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#11-setup-indexer-via-explorer,,,,Not Started, +B-1.2,Baseline,Register indexer URL and GEO coordinates,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#12-register-indexer-url-and-geo-coordinates,,,,Not Started, +B-1.3,Baseline,Validate Subgraph Service provision and registration,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#13-validate-subgraph-service-provision-and-registration,,,,Not Started, +B-2.1,Baseline,Add stake via Explorer,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#21-add-stake-via-explorer,,,,Not Started, +B-2.2,Baseline,Unstake tokens and withdraw after thawing,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#22-unstake-tokens-and-withdraw-after-thawing,,,,Not Started, +B-3.1,Baseline,View current provision,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#31-view-current-provision,,,,Not Started, +B-3.2,Baseline,Add stake to provision,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#32-add-stake-to-provision,,,,Not Started, +B-3.3,Baseline,Thaw stake from provision,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#33-thaw-stake-from-provision,,,,Not Started, +B-3.4,Baseline,Remove thawed stake from provision,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#34-remove-thawed-stake-from-provision,,,,Not Started, +B-4.1,Baseline,Find subgraph deployments with rewards,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#41-find-subgraph-deployments-with-rewards,,,,Not Started, +B-4.2,Baseline,Create allocation manually,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#42-create-allocation-manually,,,,Not Started, +B-4.3,Baseline,Create allocation via actions queue,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#43-create-allocation-via-actions-queue,,,,Not Started, +B-4.4,Baseline,Create allocation via deployment rules,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#44-create-allocation-via-deployment-rules,,,,Not Started, +B-4.5,Baseline,Reallocate a deployment,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#45-reallocate-a-deployment,,,,Not Started, +B-5.1,Baseline,Send test queries,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#51-send-test-queries,,,,Not Started, +B-5.2,Baseline,Close allocation and collect indexing rewards,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#52-close-allocation-and-collect-indexing-rewards,,,,Not Started, +B-5.3,Baseline,Verify query fee collection,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#53-verify-query-fee-collection,,,,Not Started, +B-5.4,Baseline,Close allocation with explicit POI,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#54-close-allocation-with-explicit-poi,,,,Not Started, +B-6.1,Baseline,Monitor indexer health,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#61-monitor-indexer-health,,,,Not Started, +B-6.2,Baseline,Check epoch progression,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#62-check-epoch-progression,,,,Not Started, +B-6.3,Baseline,Verify no unexpected errors in logs,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#63-verify-no-unexpected-errors-in-logs,,,,Not Started, +B-7.1,Baseline,Full operational cycle,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/BaselineTestPlan.md#71-full-operational-cycle,,,,Not Started, +E-1.1,Eligibility,Open 3+ allocations for eligibility tests,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#11-open-allocations-for-eligibility-tests,,,,Not Started,Need epoch maturity before Set 2 +E-2.1,Eligibility,Renew eligibility,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#21-renew-eligibility,,,,Not Started, +E-2.2,Eligibility,Close allocation while eligible,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#22-close-allocation-while-eligible,,,,Not Started,Requires epoch maturity from Set 1 +E-3.1,Eligibility,Wait for eligibility expiry,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#31-wait-for-eligibility-expiry,,,,Not Started, +E-3.2,Eligibility,Close allocation while ineligible,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#32-close-allocation-while-ineligible,,,,Not Started,Confirm indexingRewards is 0 +E-4.1,Eligibility,Re-renew eligibility,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#41-re-renew-eligibility,,,,Not Started,Do promptly after Set 3 +E-4.2,Eligibility,Close allocation — full rewards after re-renewal,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#42-close-allocation--full-rewards-after-re-renewal,,,,Not Started,Key test: rewards include ineligible period +E-5.1,Eligibility,Verify eligibility when validation is off,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/IndexerTestGuide.md#51-verify-eligibility-when-validation-is-off,,,,Not Started,Coordinator toggles validation +D-1.1,Denial,Configure SUBGRAPH_DENIED reclaim address,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#11-configure-subgraph_denied-reclaim-address,,,,Not Started,Governor access needed +D-1.2,Denial,Record reclaim address GRT balance,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#12-record-reclaim-address-grt-balance,,,,Not Started, +D-2.1,Denial,Verify subgraph is not denied (pre-test),https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#21-verify-subgraph-is-not-denied-pre-test,,,,Not Started,Record accumulator baseline +D-2.2,Denial,Deny subgraph deployment,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#22-deny-subgraph-deployment,,,,Not Started,SAO or Governor access needed +D-2.3,Denial,Redundant deny is idempotent,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#23-redundant-deny-is-idempotent,,,,Not Started, +D-2.4,Denial,Unauthorized deny reverts,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#24-unauthorized-deny-reverts,,,,Not Started, +D-3.1,Denial,Accumulators freeze after denial,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#31-accumulators-freeze-after-denial,,,,Not Started,Wait 30+ min after denial +D-3.2,Denial,getRewards returns frozen value for denied subgraph,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#32-getrewards-returns-frozen-value-for-allocations-on-denied-subgraph,,,,Not Started, +D-3.3,Denial,Denial-period rewards reclaimed,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#33-denial-period-rewards-reclaimed,,,,Not Started,Check RewardsReclaimed events +D-3.4,Denial,Non-denied subgraphs unaffected,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#34-non-denied-subgraphs-unaffected,,,,Not Started,Control test +D-4.1,Denial,POI on denied subgraph defers,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#41-poi-presentation-on-denied-subgraph-defers-returns-0-preserves-state,,,,Not Started,Critical: snapshot NOT advanced +D-4.2,Denial,Multiple POI presentations while denied safe,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#42-multiple-poi-presentations-while-denied-do-not-lose-rewards,,,,Not Started, +D-4.3,Denial,Continue presenting POIs during denial,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#43-indexers-should-continue-presenting-pois-during-denial,,,,Not Started,Prevents staleness +D-5.1,Denial,Undeny subgraph deployment,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#51-undeny-subgraph-deployment,,,,Not Started, +D-5.2,Denial,Accumulators resume after undeny,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#52-accumulators-resume-after-undeny,,,,Not Started,Wait 30+ min after undeny +D-5.3,Denial,Pre-denial rewards claimable after undeny,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#53-pre-denial-rewards-claimable-after-undeny,,,,Not Started,Critical: preserved rewards claimable +D-5.4,Denial,Denial-period rewards excluded from claim,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#54-denial-period-rewards-are-not-included-in-claim,,,,Not Started, +D-6.1,Denial,New allocation while denied,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#61-new-allocation-created-while-subgraph-is-denied,,,,Not Started,Only earns post-undeny rewards +D-6.2,Denial,All allocations close while denied then resume,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#62-all-allocations-close-while-denied-then-new-allocation-after-undeny,,,,Not Started, +D-6.3,Denial,Rapid deny/undeny cycle,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#63-deny-and-undeny-in-rapid-succession,,,,Not Started, +D-6.4,Denial,Denial vs eligibility precedence,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/SubgraphDenialTestPlan.md#64-denial-interaction-with-indexer-eligibility,,,,Not Started,Denial takes precedence over REO +RC-1.1,Conditions,Configure per-condition reclaim addresses,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#11-configure-per-condition-reclaim-addresses,,,,Not Started,Governor access needed +RC-1.2,Conditions,Configure default reclaim address,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#12-configure-default-reclaim-address,,,,Not Started, +RC-1.3,Conditions,Verify fallback routing,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#13-verify-fallback-routing-unconfigured-condition-uses-default,,,,Not Started, +RC-1.4,Conditions,Unauthorized reclaim address change reverts,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#14-unauthorized-reclaim-address-change-reverts,,,,Not Started, +RC-1.5,Conditions,Record baseline balances,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#15-record-baseline-balances,,,,Not Started, +RC-2.1,Conditions,Verify current minimum signal threshold,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#21-verify-current-minimum-signal-threshold,,,,Not Started, +RC-2.2,Conditions,Raise threshold to trigger BELOW_MINIMUM_SIGNAL,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#22-raise-threshold-to-trigger-below_minimum_signal,,,,Not Started,Snapshot accumulators first +RC-2.3,Conditions,Accumulator freezes for below-threshold subgraph,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#23-accumulator-freezes-for-below-threshold-subgraph,,,,Not Started, +RC-2.4,Conditions,Restore threshold and verify resumption,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#24-restore-threshold-and-verify-resumption,,,,Not Started, +RC-3.1,Conditions,Identify subgraph with signal but no allocations,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#31-identify-subgraph-with-signal-but-no-allocations,,,,Not Started, +RC-3.2,Conditions,Verify NO_ALLOCATED_TOKENS reclaim,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#32-verify-no_allocated_tokens-reclaim,,,,Not Started, +RC-3.3,Conditions,Allocations resume from stored baseline,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#33-allocations-resume-from-stored-baseline,,,,Not Started, +RC-4.1,Conditions,Normal claim path (NONE condition),https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#41-normal-claim-path-none-condition,,,,Not Started, +RC-4.2,Conditions,Reclaim path: STALE_POI,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#42-reclaim-path-stale_poi,,,,Not Started,Wait for maxPOIStaleness +RC-4.3,Conditions,Reclaim path: ZERO_POI,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#43-reclaim-path-zero_poi,,,,Not Started, +RC-4.4,Conditions,Defer path: ALLOCATION_TOO_YOUNG,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#44-defer-path-allocation_too_young,,,,Not Started,Same-epoch POI attempt +RC-4.5,Conditions,POI presentation always updates timestamp,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#45-poi-presentation-always-updates-timestamp,,,,Not Started, +RC-5.1,Conditions,Allocation resize reclaims stale rewards,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#51-allocation-resize-reclaims-stale-rewards,,,,Not Started,Wait for staleness +RC-5.2,Conditions,Non-stale resize does not reclaim,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#52-allocation-resize-does-not-reclaim-for-non-stale-allocation,,,,Not Started, +RC-5.3,Conditions,Allocation close reclaims uncollected rewards,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#53-allocation-close-reclaims-uncollected-rewards,,,,Not Started, +RC-6.1,Conditions,POIPresented event on every presentation,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#61-poipresented-event-emitted-on-every-presentation,,,,Not Started,Cross-check all Cycle 4-5 events +RC-6.2,Conditions,RewardsReclaimed events include full context,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#62-rewardsreclaimed-events-include-full-context,,,,Not Started, +RC-6.3,Conditions,View functions reflect frozen state accurately,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#63-view-functions-reflect-frozen-state-accurately,,,,Not Started, +RC-7.1,Conditions,NO_SIGNAL detection,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#71-no_signal-detection,,,,Not Started,Dedicated testnet only +RC-7.2,Conditions,Signal restoration resumes normal distribution,https://github.com/graphprotocol/contracts/blob/reo-testing/packages/issuance/docs/testing/reo/RewardsConditionsTestPlan.md#72-signal-restoration-resumes-normal-distribution,,,,Not Started,Dedicated testnet only diff --git a/packages/issuance/docs/testing/reo/support/indexer-status.sh b/packages/issuance/docs/testing/reo/support/indexer-status.sh new file mode 100755 index 000000000..c914580be --- /dev/null +++ b/packages/issuance/docs/testing/reo/support/indexer-status.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# Query basic indexer status from the network subgraph. +# +# Usage: +# ./indexer-status.sh [mainnet] +# +# Environment: +# GRAPH_API_KEY Required. Your Graph API key. +# +# Examples: +# GRAPH_API_KEY=abc123 ./indexer-status.sh 0xdeadbeef... +# GRAPH_API_KEY=abc123 ./indexer-status.sh 0xdeadbeef... mainnet + +set -euo pipefail + +INDEXER=${1:-} +NETWORK=${2:-testnet} + +if [[ -z "$INDEXER" ]]; then + echo "Usage: $0 [mainnet]" >&2 + exit 1 +fi + +if [[ -z "${GRAPH_API_KEY:-}" ]]; then + echo "Error: GRAPH_API_KEY is not set" >&2 + exit 1 +fi + +# Addresses must be lowercase for the subgraph +INDEXER=$(echo "$INDEXER" | tr '[:upper:]' '[:lower:]') + +if [[ "$NETWORK" == "mainnet" ]]; then + SUBGRAPH_URL="https://gateway.thegraph.com/api/$GRAPH_API_KEY/subgraphs/id/DZz4kDTdmzWLWsV373w2bSmoar3umKKH9y82SUKr5qmp" +else + SUBGRAPH_URL="https://gateway.thegraph.com/api/$GRAPH_API_KEY/subgraphs/id/3xQHhMudr1oh69ut36G2mbzpYmYxwqCeU6wwqyCDCnqV" +fi + +QUERY=$(cat < Date: Fri, 10 Apr 2026 12:00:00 +0000 Subject: [PATCH 081/157] feat(deployment): GIP-0088 deployment infrastructure --- packages/deployment/.gitignore | 1 + packages/deployment/CLAUDE.md | 3 +- packages/deployment/README.md | 64 +- packages/deployment/config/arbitrumOne.json5 | 22 + .../deployment/config/arbitrumSepolia.json5 | 22 + .../deploy/agreement/manager/01_deploy.ts | 16 + .../deploy/agreement/manager/02_upgrade.ts | 4 + .../deploy/agreement/manager/04_configure.ts | 225 + .../manager/05_transfer_governance.ts | 60 + .../deploy/agreement/manager/09_end.ts | 4 + .../deploy/agreement/manager/10_status.ts | 4 + .../deploy/allocate/allocator/01_deploy.ts | 59 +- .../deploy/allocate/allocator/02_upgrade.ts | 26 +- .../deploy/allocate/allocator/03_deploy.ts | 30 - .../deploy/allocate/allocator/04_configure.ts | 293 +- .../allocator/05_verify_governance.ts | 189 - .../allocator/06_transfer_governance.ts | 137 +- .../deploy/allocate/allocator/07_activate.ts | 129 - .../allocate/allocator/08_allocation.ts | 70 - .../deploy/allocate/allocator/09_end.ts | 4 + .../deploy/allocate/allocator/10_status.ts | 4 + .../deploy/allocate/default/01_deploy.ts | 39 + .../deploy/allocate/default/02_upgrade.ts | 27 + .../deploy/allocate/default/04_configure.ts | 119 + .../default/05_transfer_governance.ts | 51 + .../deploy/allocate/default/09_end.ts | 4 + .../deploy/allocate/default/10_status.ts | 10 + .../deploy/allocate/direct/01_impl.ts | 98 +- .../deploy/allocate/pilot/01_deploy.ts | 45 - .../deploy/allocate/pilot/02_upgrade.ts | 32 - .../deploy/allocate/pilot/04_configure.ts | 91 - .../deploy/allocate/pilot/09_end.ts | 28 - packages/deployment/deploy/common/00_sync.ts | 134 +- packages/deployment/deploy/gip/0088/09_end.ts | 97 + .../deployment/deploy/gip/0088/10_status.ts | 208 + .../deploy/gip/0088/eligibility_integrate.ts | 74 + .../deploy/gip/0088/eligibility_revert.ts | 90 + .../deploy/gip/0088/issuance_allocate.ts | 194 + .../deploy/gip/0088/issuance_close_guard.ts | 81 + .../deploy/gip/0088/issuance_connect.ts | 247 + .../deploy/gip/0088/upgrade/01_deploy.ts | 47 + .../deploy/gip/0088/upgrade/02_configure.ts | 40 + .../deploy/gip/0088/upgrade/03_transfer.ts | 39 + .../deploy/gip/0088/upgrade/04_upgrade.ts | 426 ++ .../deploy/gip/0088/upgrade/10_status.ts | 324 + .../deploy/horizon/curation/01_deploy.ts | 4 + .../deploy/horizon/curation/02_upgrade.ts | 4 + .../deploy/horizon/curation/09_end.ts | 4 + .../deploy/horizon/curation/10_status.ts | 4 + .../horizon/payments-escrow/01_deploy.ts | 58 + .../horizon/payments-escrow/02_upgrade.ts | 4 + .../deploy/horizon/payments-escrow/09_end.ts | 4 + .../horizon/payments-escrow/10_status.ts | 4 + .../horizon/recurring-collector/01_deploy.ts | 51 + .../horizon/recurring-collector/02_upgrade.ts | 4 + .../recurring-collector/04_configure.ts | 62 + .../05_transfer_governance.ts | 69 + .../horizon/recurring-collector/09_end.ts | 4 + .../horizon/recurring-collector/10_status.ts | 4 + .../deploy/horizon/staking/01_deploy.ts | 15 + .../deploy/horizon/staking/02_upgrade.ts | 4 + .../deploy/horizon/staking/09_end.ts | 4 + .../deploy/horizon/staking/10_status.ts | 4 + .../deploy/rewards/eligibility/01_deploy.ts | 32 - .../deploy/rewards/eligibility/02_upgrade.ts | 25 - .../rewards/eligibility/04_configure.ts | 33 - .../eligibility/05_transfer_governance.ts | 41 - .../rewards/eligibility/06_integrate.ts | 33 - .../deploy/rewards/eligibility/09_complete.ts | 32 - .../deploy/rewards/eligibility/a/01_deploy.ts | 12 + .../rewards/eligibility/a/02_upgrade.ts | 4 + .../rewards/eligibility/a/04_configure.ts | 39 + .../eligibility/a/05_transfer_governance.ts | 45 + .../deploy/rewards/eligibility/a/09_end.ts | 4 + .../deploy/rewards/eligibility/a/10_status.ts | 4 + .../deploy/rewards/eligibility/b/01_deploy.ts | 12 + .../rewards/eligibility/b/02_upgrade.ts | 4 + .../rewards/eligibility/b/04_configure.ts | 39 + .../eligibility/b/05_transfer_governance.ts | 45 + .../deploy/rewards/eligibility/b/09_end.ts | 4 + .../deploy/rewards/eligibility/b/10_status.ts | 4 + .../rewards/eligibility/mock/01_deploy.ts | 12 + .../rewards/eligibility/mock/02_upgrade.ts | 4 + .../mock/05_transfer_governance.ts | 39 + .../rewards/eligibility/mock/06_integrate.ts | 36 + .../deploy/rewards/eligibility/mock/09_end.ts | 4 + .../rewards/eligibility/mock/10_status.ts | 4 + .../deploy/rewards/manager/01_deploy.ts | 23 +- .../deploy/rewards/manager/02_upgrade.ts | 26 +- .../deploy/rewards/manager/09_end.ts | 21 +- .../deploy/rewards/manager/10_status.ts | 4 + .../deploy/rewards/reclaim/01_deploy.ts | 57 +- .../deploy/rewards/reclaim/02_upgrade.ts | 41 +- .../deploy/rewards/reclaim/04_configure.ts | 247 +- .../rewards/reclaim/05_transfer_governance.ts | 56 + .../deploy/rewards/reclaim/09_end.ts | 34 +- .../deploy/rewards/reclaim/10_status.ts | 14 + .../deploy/service/dispute/01_deploy.ts | 12 + .../deploy/service/dispute/02_upgrade.ts | 4 + .../deploy/service/dispute/09_end.ts | 4 + .../deploy/service/dispute/10_status.ts | 4 + .../deploy/service/subgraph/01_deploy.ts | 142 +- .../deploy/service/subgraph/02_upgrade.ts | 26 +- .../deploy/service/subgraph/04_configure.ts | 22 + .../deploy/service/subgraph/09_end.ts | 24 +- .../deploy/service/subgraph/10_status.ts | 4 + packages/deployment/docs/Architecture.md | 37 +- packages/deployment/docs/DeploymentSetup.md | 61 + packages/deployment/docs/Design.md | 154 +- packages/deployment/docs/Gip0088.md | 241 + .../deployment/docs/GovernanceWorkflow.md | 57 +- packages/deployment/docs/LocalForkTesting.md | 65 +- .../docs/SyncBytecodeDetectionFix.md | 149 + .../docs/deploy/ImplementationPrinciples.md | 178 +- .../deploy/IssuanceAllocatorDeployment.md | 188 +- .../RewardsEligibilityOracleDeployment.md | 39 +- packages/deployment/hardhat.config.ts | 142 +- packages/deployment/lib/abis.ts | 150 +- packages/deployment/lib/address-book-utils.ts | 168 +- .../deployment/lib/apply-configuration.ts | 8 +- packages/deployment/lib/artifact-loaders.ts | 96 +- packages/deployment/lib/bytecode-utils.ts | 118 +- packages/deployment/lib/contract-checks.ts | 93 +- packages/deployment/lib/contract-registry.ts | 178 +- packages/deployment/lib/controller-utils.ts | 16 + .../deployment/lib/deploy-implementation.ts | 74 +- packages/deployment/lib/deploy-standalone.ts | 79 + packages/deployment/lib/deployment-config.ts | 66 + packages/deployment/lib/deployment-tags.ts | 201 +- .../deployment/lib/deployment-validation.ts | 10 +- packages/deployment/lib/execute-governance.ts | 66 +- packages/deployment/lib/format.ts | 10 + .../deployment/lib/issuance-deploy-utils.ts | 179 +- packages/deployment/lib/oz-proxy-verify.ts | 39 + packages/deployment/lib/preconditions.ts | 354 ++ packages/deployment/lib/script-factories.ts | 384 ++ packages/deployment/lib/status-detail.ts | 1131 ++++ packages/deployment/lib/sync-utils.ts | 674 +- packages/deployment/lib/task-utils.ts | 139 + .../deployment/lib/upgrade-implementation.ts | 217 +- packages/deployment/package.json | 5 +- packages/deployment/rocketh/config.ts | 10 + packages/deployment/rocketh/deploy.ts | 61 +- packages/deployment/scripts/check-bytecode.ts | 54 + .../scripts/check-rocketh-bytecode.ts | 34 + .../deployment/scripts/debug-deploy-state.ts | 27 + packages/deployment/scripts/generate-abis.ts | 264 + packages/deployment/scripts/tag-deployment.sh | 287 + packages/deployment/tasks/check-deployer.ts | 38 +- .../deployment/tasks/deployment-status.ts | 661 +- packages/deployment/tasks/eth-tasks.ts | 208 + .../deployment/tasks/execute-governance.ts | 60 +- packages/deployment/tasks/grant-role.ts | 86 +- packages/deployment/tasks/grt-tasks.ts | 449 ++ .../tasks/list-pending-implementations.ts | 4 + packages/deployment/tasks/list-roles.ts | 52 +- packages/deployment/tasks/reo-tasks.ts | 597 ++ packages/deployment/tasks/reset-fork.ts | 4 +- packages/deployment/tasks/revoke-role.ts | 86 +- packages/deployment/tasks/ss-tasks.ts | 306 + packages/deployment/tasks/sync.ts | 37 + packages/deployment/tasks/verify-contract.ts | 197 +- .../test/bytecode-comparison.test.ts | 56 +- .../test/chain-id-resolution.test.ts | 158 +- packages/deployment/tsconfig.json | 2 +- packages/deployment/types/rocketh.d.ts | 24 + .../toolshed/src/deployments/address-book.ts | 4 +- patches/rocketh@0.17.13.patch | 33 + pnpm-lock.yaml | 5642 +---------------- 169 files changed, 11976 insertions(+), 8725 deletions(-) create mode 100644 packages/deployment/config/arbitrumOne.json5 create mode 100644 packages/deployment/config/arbitrumSepolia.json5 create mode 100644 packages/deployment/deploy/agreement/manager/01_deploy.ts create mode 100644 packages/deployment/deploy/agreement/manager/02_upgrade.ts create mode 100644 packages/deployment/deploy/agreement/manager/04_configure.ts create mode 100644 packages/deployment/deploy/agreement/manager/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/agreement/manager/09_end.ts create mode 100644 packages/deployment/deploy/agreement/manager/10_status.ts delete mode 100644 packages/deployment/deploy/allocate/allocator/03_deploy.ts delete mode 100644 packages/deployment/deploy/allocate/allocator/05_verify_governance.ts delete mode 100644 packages/deployment/deploy/allocate/allocator/07_activate.ts delete mode 100644 packages/deployment/deploy/allocate/allocator/08_allocation.ts create mode 100644 packages/deployment/deploy/allocate/allocator/09_end.ts create mode 100644 packages/deployment/deploy/allocate/allocator/10_status.ts create mode 100644 packages/deployment/deploy/allocate/default/01_deploy.ts create mode 100644 packages/deployment/deploy/allocate/default/02_upgrade.ts create mode 100644 packages/deployment/deploy/allocate/default/04_configure.ts create mode 100644 packages/deployment/deploy/allocate/default/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/allocate/default/09_end.ts create mode 100644 packages/deployment/deploy/allocate/default/10_status.ts delete mode 100644 packages/deployment/deploy/allocate/pilot/01_deploy.ts delete mode 100644 packages/deployment/deploy/allocate/pilot/02_upgrade.ts delete mode 100644 packages/deployment/deploy/allocate/pilot/04_configure.ts delete mode 100644 packages/deployment/deploy/allocate/pilot/09_end.ts create mode 100644 packages/deployment/deploy/gip/0088/09_end.ts create mode 100644 packages/deployment/deploy/gip/0088/10_status.ts create mode 100644 packages/deployment/deploy/gip/0088/eligibility_integrate.ts create mode 100644 packages/deployment/deploy/gip/0088/eligibility_revert.ts create mode 100644 packages/deployment/deploy/gip/0088/issuance_allocate.ts create mode 100644 packages/deployment/deploy/gip/0088/issuance_close_guard.ts create mode 100644 packages/deployment/deploy/gip/0088/issuance_connect.ts create mode 100644 packages/deployment/deploy/gip/0088/upgrade/01_deploy.ts create mode 100644 packages/deployment/deploy/gip/0088/upgrade/02_configure.ts create mode 100644 packages/deployment/deploy/gip/0088/upgrade/03_transfer.ts create mode 100644 packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts create mode 100644 packages/deployment/deploy/gip/0088/upgrade/10_status.ts create mode 100644 packages/deployment/deploy/horizon/curation/01_deploy.ts create mode 100644 packages/deployment/deploy/horizon/curation/02_upgrade.ts create mode 100644 packages/deployment/deploy/horizon/curation/09_end.ts create mode 100644 packages/deployment/deploy/horizon/curation/10_status.ts create mode 100644 packages/deployment/deploy/horizon/payments-escrow/01_deploy.ts create mode 100644 packages/deployment/deploy/horizon/payments-escrow/02_upgrade.ts create mode 100644 packages/deployment/deploy/horizon/payments-escrow/09_end.ts create mode 100644 packages/deployment/deploy/horizon/payments-escrow/10_status.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/02_upgrade.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/04_configure.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/09_end.ts create mode 100644 packages/deployment/deploy/horizon/recurring-collector/10_status.ts create mode 100644 packages/deployment/deploy/horizon/staking/01_deploy.ts create mode 100644 packages/deployment/deploy/horizon/staking/02_upgrade.ts create mode 100644 packages/deployment/deploy/horizon/staking/09_end.ts create mode 100644 packages/deployment/deploy/horizon/staking/10_status.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/01_deploy.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/02_upgrade.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/04_configure.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/05_transfer_governance.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/06_integrate.ts delete mode 100644 packages/deployment/deploy/rewards/eligibility/09_complete.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/01_deploy.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/02_upgrade.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/04_configure.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/09_end.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/a/10_status.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/01_deploy.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/02_upgrade.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/04_configure.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/09_end.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/b/10_status.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/01_deploy.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/02_upgrade.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/06_integrate.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/09_end.ts create mode 100644 packages/deployment/deploy/rewards/eligibility/mock/10_status.ts create mode 100644 packages/deployment/deploy/rewards/manager/10_status.ts create mode 100644 packages/deployment/deploy/rewards/reclaim/05_transfer_governance.ts create mode 100644 packages/deployment/deploy/rewards/reclaim/10_status.ts create mode 100644 packages/deployment/deploy/service/dispute/01_deploy.ts create mode 100644 packages/deployment/deploy/service/dispute/02_upgrade.ts create mode 100644 packages/deployment/deploy/service/dispute/09_end.ts create mode 100644 packages/deployment/deploy/service/dispute/10_status.ts create mode 100644 packages/deployment/deploy/service/subgraph/04_configure.ts create mode 100644 packages/deployment/deploy/service/subgraph/10_status.ts create mode 100644 packages/deployment/docs/Gip0088.md create mode 100644 packages/deployment/docs/SyncBytecodeDetectionFix.md create mode 100644 packages/deployment/lib/deploy-standalone.ts create mode 100644 packages/deployment/lib/deployment-config.ts create mode 100644 packages/deployment/lib/format.ts create mode 100644 packages/deployment/lib/preconditions.ts create mode 100644 packages/deployment/lib/script-factories.ts create mode 100644 packages/deployment/lib/status-detail.ts create mode 100644 packages/deployment/lib/task-utils.ts create mode 100644 packages/deployment/scripts/check-bytecode.ts create mode 100644 packages/deployment/scripts/check-rocketh-bytecode.ts create mode 100644 packages/deployment/scripts/debug-deploy-state.ts create mode 100644 packages/deployment/scripts/generate-abis.ts create mode 100755 packages/deployment/scripts/tag-deployment.sh create mode 100644 packages/deployment/tasks/eth-tasks.ts create mode 100644 packages/deployment/tasks/grt-tasks.ts create mode 100644 packages/deployment/tasks/reo-tasks.ts create mode 100644 packages/deployment/tasks/ss-tasks.ts create mode 100644 packages/deployment/tasks/sync.ts create mode 100644 packages/deployment/types/rocketh.d.ts create mode 100644 patches/rocketh@0.17.13.patch diff --git a/packages/deployment/.gitignore b/packages/deployment/.gitignore index 1c6b1095e..d48c62c73 100644 --- a/packages/deployment/.gitignore +++ b/packages/deployment/.gitignore @@ -1,3 +1,4 @@ deployments/ fork/ txs/ +lib/generated/ diff --git a/packages/deployment/CLAUDE.md b/packages/deployment/CLAUDE.md index 89458a18c..598c3baf4 100644 --- a/packages/deployment/CLAUDE.md +++ b/packages/deployment/CLAUDE.md @@ -10,8 +10,9 @@ Before modifying any deployment scripts in `deploy/`, read: ## Key Rules (from principles) -- **`process.exit(1)` after generating governance TXs** - never return, always exit +- **`saveGovernanceTx` returns** - governance TX generation returns (not exit), downstream scripts check their own preconditions - **Idempotent scripts** - check on-chain state, skip if already done +- **Shared precondition checks** - use `lib/preconditions.ts` for configure/transfer checks, not inline copies - **Package imports** - use `@graphprotocol/deployment/...` not relative paths - **Contract registry** - use `Contracts.X` not string literals - **Standard numbering** - `01_deploy`, `02_upgrade`, ..., `09_end` diff --git a/packages/deployment/README.md b/packages/deployment/README.md index bf0968669..cce3d1c89 100644 --- a/packages/deployment/README.md +++ b/packages/deployment/README.md @@ -7,41 +7,54 @@ Unified deployment package for Graph Protocol contracts. ```bash cd packages/deployment -# Deploy and upgrade specific contracts -npx hardhat deploy --tags rewards-manager --network arbitrumSepolia -npx hardhat deploy --tags subgraph-service --network arbitrumSepolia - -# Deploy issuance contracts (full lifecycle with verification) -npx hardhat deploy --tags issuance-allocation --network arbitrumSepolia - -# Check status +# Read-only status (no --tags = no mutations) npx hardhat deploy:status --network arbitrumSepolia +npx hardhat deploy --tags GIP-0088 --network arbitrumSepolia + +# Component lifecycle (single contract) +npx hardhat deploy --tags IssuanceAllocator,deploy --network arbitrumSepolia +npx hardhat deploy --tags IssuanceAllocator,configure --network arbitrumSepolia +npx hardhat deploy --tags IssuanceAllocator,transfer --network arbitrumSepolia + +# Goal-driven (full GIP-0088 deployment) +npx hardhat deploy --tags GIP-0088:upgrade,deploy --network arbitrumSepolia +npx hardhat deploy --tags GIP-0088:upgrade,configure --network arbitrumSepolia +npx hardhat deploy --tags GIP-0088:upgrade,transfer --network arbitrumSepolia +npx hardhat deploy --tags GIP-0088:upgrade,upgrade --network arbitrumSepolia ``` +See [docs/Gip0088.md](./docs/Gip0088.md) for the full GIP-0088 workflow. + ## Deployment Flow +Each script is idempotent and goal-seeking: it checks on-chain state and either does what's needed or returns. Scripts that need governance authority build a TX batch and either execute it directly (deployer has permission) or save it for the Safe (`saveGovernanceTx` returns — does not exit). + ``` -sync → deploy → upgrade - │ │ │ - │ │ └─► Generate TX, try execute, sync if success - │ └─► Deploy impl if bytecode changed, store pending - └─► Check executed pendings, import from address books +sync → deploy → configure → transfer → upgrade (governance batch) + │ │ │ │ │ + │ │ │ │ └─► Bundle proxy upgrades + deferred config + │ │ │ └─► Revoke deployer role + transfer ProxyAdmin + │ │ └─► Deployer-only role grants and params + │ └─► Deploy impl + proxy if needed; store pendingImplementation + └─► Import on-chain state into address books ``` -**Stops at governance boundary** - if deployer lacks permission, stops with TX file path for Safe upload. - ## Structure ``` packages/deployment/ -├── deploy/ # hardhat-deploy scripts -│ ├── common/ # 00_sync.ts -│ ├── contracts/ # RewardsManager -│ ├── subgraph-service/ # SubgraphService -│ └── issuance/ # Issuance contracts -├── tasks/ # Hardhat tasks (deploy:*) -├── governance/ # Safe TX builders -└── test/ # Integration tests +├── deploy/ # rocketh deploy scripts (numbered per component) +│ ├── common/ # 00_sync.ts +│ ├── horizon/ # RM, HS, PE, L2Curation, RC +│ ├── service/ # SubgraphService, DisputeManager +│ ├── allocate/ # IssuanceAllocator, DefaultAllocation, DirectAllocation +│ ├── agreement/ # RecurringAgreementManager +│ ├── rewards/ # RewardsEligibilityOracle, Reclaim +│ └── gip/0088/ # GIP-0088 goal orchestration +├── lib/ # Shared utilities (preconditions, registry, tags, ABIs) +├── tasks/ # Hardhat tasks (deploy:*) +├── docs/ # Documentation +└── test/ # Unit tests ``` ## Available Tasks @@ -64,7 +77,8 @@ FORK_NETWORK=arbitrumSepolia ARBITRUM_SEPOLIA_RPC= pnpm test ## See Also -- [docs/DeploymentDesignPrinciples.md](./docs/DeploymentDesignPrinciples.md) - Core design principles and patterns +- [docs/deploy/ImplementationPrinciples.md](./docs/deploy/ImplementationPrinciples.md) - Core design principles and patterns - [docs/Architecture.md](./docs/Architecture.md) - Package structure and tags - [docs/GovernanceWorkflow.md](./docs/GovernanceWorkflow.md) - Detailed governance workflow -- [Design.md](./docs/Design.md) - Technical design documentation +- [docs/Design.md](./docs/Design.md) - Technical design documentation +- [docs/LocalForkTesting.md](./docs/LocalForkTesting.md) - Fork-based and local network testing diff --git a/packages/deployment/config/arbitrumOne.json5 b/packages/deployment/config/arbitrumOne.json5 new file mode 100644 index 000000000..15ebcfdb1 --- /dev/null +++ b/packages/deployment/config/arbitrumOne.json5 @@ -0,0 +1,22 @@ +{ + // Deployment configuration for Arbitrum One (mainnet) + // Values here are committed for reference and reproducibility. + + "IssuanceAllocator": { + // RAM allocation: how much issuance flows to RecurringAgreementManager + // ramAllocatorMintingGrtPerBlock: GRT per block minted by IA and sent to RAM + // ramSelfMintingGrtPerBlock: 0 (RAM does not self-mint) + "ramAllocatorMintingGrtPerBlock": "6", + "ramSelfMintingGrtPerBlock": "0" + }, + + "RewardsManager": { + // Revert reward claims for ineligible indexers + "revertOnIneligible": true + }, + + "RecurringCollector": { + // Pause guardian is read from Controller.pauseGuardian() at deploy time + // (same as all other protocol contracts) + } +} diff --git a/packages/deployment/config/arbitrumSepolia.json5 b/packages/deployment/config/arbitrumSepolia.json5 new file mode 100644 index 000000000..ee99ac660 --- /dev/null +++ b/packages/deployment/config/arbitrumSepolia.json5 @@ -0,0 +1,22 @@ +{ + // Deployment configuration for Arbitrum Sepolia (testnet) + // Values here are committed for reference and reproducibility. + + "IssuanceAllocator": { + // RAM allocation: how much issuance flows to RecurringAgreementManager + // ramAllocatorMintingGrtPerBlock: GRT per block minted by IA and sent to RAM + // ramSelfMintingGrtPerBlock: GRT per block (0 = RAM does not self-mint) + "ramAllocatorMintingGrtPerBlock": "0.5", + "ramSelfMintingGrtPerBlock": "0" + }, + + "RewardsManager": { + // Revert reward claims for ineligible indexers + "revertOnIneligible": false + }, + + "RecurringCollector": { + // Pause guardian is read from Controller.pauseGuardian() at deploy time + // (same as all other protocol contracts) + } +} diff --git a/packages/deployment/deploy/agreement/manager/01_deploy.ts b/packages/deployment/deploy/agreement/manager/01_deploy.ts new file mode 100644 index 000000000..dabd71cfb --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/01_deploy.ts @@ -0,0 +1,16 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { requireDeployer, requireGraphToken } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createProxyDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createProxyDeployModule( + Contracts.issuance.RecurringAgreementManager, + (env) => { + const paymentsEscrow = env.getOrNull('PaymentsEscrow') + if (!paymentsEscrow) throw new Error('Missing PaymentsEscrow deployment after sync.') + return { + constructorArgs: [requireGraphToken(env).address, paymentsEscrow.address], + initializeArgs: [requireDeployer(env)], + } + }, + { prerequisites: [Contracts.horizon.L2GraphToken, Contracts.horizon.PaymentsEscrow] }, +) diff --git a/packages/deployment/deploy/agreement/manager/02_upgrade.ts b/packages/deployment/deploy/agreement/manager/02_upgrade.ts new file mode 100644 index 000000000..70b140182 --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.issuance.RecurringAgreementManager) diff --git a/packages/deployment/deploy/agreement/manager/04_configure.ts b/packages/deployment/deploy/agreement/manager/04_configure.ts new file mode 100644 index 000000000..0d0d7b1a2 --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/04_configure.ts @@ -0,0 +1,225 @@ +import { ACCESS_CONTROL_ENUMERABLE_ABI, ISSUANCE_TARGET_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { supportsInterface } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkRAMConfigured } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData, keccak256, toHex } from 'viem' + +/** + * Configure RecurringAgreementManager + * + * Grants: + * - COLLECTOR_ROLE to RecurringCollector + * - DATA_SERVICE_ROLE to SubgraphService + * - GOVERNOR_ROLE to protocol governor + * - PAUSE_ROLE to pause guardian + * + * Sets: + * - IssuanceAllocator as RAM's issuance source + * + * Idempotent: checks on-chain state, skips if already configured. + * + * Usage: + * pnpm hardhat deploy --tags RecurringAgreementManager:configure --network + */ +export default createActionModule( + Contracts.issuance.RecurringAgreementManager, + DeploymentActions.CONFIGURE, + async (env) => { + const client = graph.getPublicClient(env) as PublicClient + const governor = await getGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + + const ram = requireContract(env, Contracts.issuance.RecurringAgreementManager) + const rc = requireContract(env, Contracts.horizon.RecurringCollector) + const ss = requireContract(env, Contracts['subgraph-service'].SubgraphService) + const ia = requireContract(env, Contracts.issuance.IssuanceAllocator) + + env.showMessage(`\n========== Configure ${Contracts.issuance.RecurringAgreementManager.name} ==========`) + env.showMessage(`RAM: ${ram.address}`) + env.showMessage(`RC: ${rc.address}`) + env.showMessage(`SS: ${ss.address}`) + env.showMessage(`IA: ${ia.address}`) + + // Check if already configured (shared precondition check) + const precondition = await checkRAMConfigured( + client, + ram.address, + rc.address, + ss.address, + ia.address, + governor, + pauseGuardian, + ) + if (precondition.done) { + env.showMessage(`\n✅ ${Contracts.issuance.RecurringAgreementManager.name} already configured\n`) + return + } + + // Role constants + const COLLECTOR_ROLE = keccak256(toHex('COLLECTOR_ROLE')) + const DATA_SERVICE_ROLE = keccak256(toHex('DATA_SERVICE_ROLE')) + const GOVERNOR_ROLE = keccak256(toHex('GOVERNOR_ROLE')) + const PAUSE_ROLE = keccak256(toHex('PAUSE_ROLE')) + + // Check what still needs configuring + env.showMessage('\n📋 Checking current configuration...\n') + + const rcHasCollectorRole = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [COLLECTOR_ROLE, rc.address as `0x${string}`], + })) as boolean + env.showMessage(` RC COLLECTOR_ROLE: ${rcHasCollectorRole ? '✓' : '✗'}`) + + const ssHasDataServiceRole = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [DATA_SERVICE_ROLE, ss.address as `0x${string}`], + })) as boolean + env.showMessage(` SS DATA_SERVICE_ROLE: ${ssHasDataServiceRole ? '✓' : '✗'}`) + + // Check role grants + const governorHasRole = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + })) as boolean + env.showMessage(` Governor GOVERNOR_ROLE: ${governorHasRole ? '✓' : '✗'}`) + + const pauseGuardianHasRole = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + })) as boolean + env.showMessage(` PauseGuardian PAUSE_ROLE: ${pauseGuardianHasRole ? '✓' : '✗'}`) + + // Determine executor: deployer (fresh) or governor (prod) + const deployer = requireDeployer(env) + const deployerIsGovernor = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, deployer as `0x${string}`], + })) as boolean + + if (!deployerIsGovernor) { + env.showMessage(`\n ○ Deployer does not have GOVERNOR_ROLE — skipping (governance TX in upgrade step)\n`) + return + } + + // Build TX list for missing configuration + const txs: Array<{ to: string; data: `0x${string}`; label: string }> = [] + + if (!rcHasCollectorRole) { + txs.push({ + to: ram.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [COLLECTOR_ROLE, rc.address as `0x${string}`], + }), + label: `grantRole(COLLECTOR_ROLE, ${rc.address})`, + }) + } + + if (!ssHasDataServiceRole) { + txs.push({ + to: ram.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [DATA_SERVICE_ROLE, ss.address as `0x${string}`], + }), + label: `grantRole(DATA_SERVICE_ROLE, ${ss.address})`, + }) + } + + if (!governorHasRole) { + txs.push({ + to: ram.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + }), + label: `grantRole(GOVERNOR_ROLE, ${governor})`, + }) + } + + if (!pauseGuardianHasRole) { + txs.push({ + to: ram.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + }), + label: `grantRole(PAUSE_ROLE, ${pauseGuardian})`, + }) + } + + // Check issuance allocator — skip if IA doesn't support the interface yet (pending upgrade) + let iaConfigured = false + try { + const currentIA = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + iaConfigured = currentIA.toLowerCase() === ia.address.toLowerCase() + env.showMessage(` IssuanceAllocator: ${iaConfigured ? '✓' : '✗'} (current: ${currentIA})`) + } catch { + env.showMessage(` IssuanceAllocator: ✗ (getter not available)`) + } + + if (!iaConfigured) { + const IISSUANCE_ALLOCATION_DISTRIBUTION_ID = '0x79da37fc' // type(IIssuanceAllocationDistribution).interfaceId + const iaSupported = await supportsInterface(client, ia.address, IISSUANCE_ALLOCATION_DISTRIBUTION_ID) + if (iaSupported) { + txs.push({ + to: ram.address, + data: encodeFunctionData({ + abi: ISSUANCE_TARGET_ABI, + functionName: 'setIssuanceAllocator', + args: [ia.address as `0x${string}`], + }), + label: `setIssuanceAllocator(${ia.address})`, + }) + } else { + env.showMessage(` ○ IA does not yet support IIssuanceAllocationDistribution — skipping setIssuanceAllocator`) + } + } + + if (txs.length === 0) return + + env.showMessage('\n🔨 Executing configuration as deployer...\n') + const txFn = tx(env) + for (const t of txs) { + await txFn({ account: deployer, to: t.to as `0x${string}`, data: t.data }) + env.showMessage(` ✓ ${t.label}`) + } + env.showMessage(`\n✅ ${Contracts.issuance.RecurringAgreementManager.name} configuration complete!\n`) + }, + { + extraDependencies: [ + ComponentTags.RECURRING_COLLECTOR, + ComponentTags.SUBGRAPH_SERVICE, + ComponentTags.ISSUANCE_ALLOCATOR, + ], + prerequisites: [ + Contracts.horizon.RecurringCollector, + Contracts['subgraph-service'].SubgraphService, + Contracts.issuance.IssuanceAllocator, + ], + }, +) diff --git a/packages/deployment/deploy/agreement/manager/05_transfer_governance.ts b/packages/deployment/deploy/agreement/manager/05_transfer_governance.ts new file mode 100644 index 000000000..50d3f7582 --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/05_transfer_governance.ts @@ -0,0 +1,60 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContract, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkDeployerRevoked } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { execute, graph, read } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer RecurringAgreementManager governance from deployer + * + * - Revoke GOVERNOR_ROLE from deployment account + * - Transfer ProxyAdmin ownership to governor + * + * Role grants (GOVERNOR_ROLE, PAUSE_ROLE, COLLECTOR_ROLE, DATA_SERVICE_ROLE) + * happen in 04_configure.ts. This script only revokes deployer access. + * + * Idempotent: checks on-chain state, skips if already transferred. + * + * Usage: + * pnpm hardhat deploy --tags RecurringAgreementManager,transfer --network + */ +export default createActionModule( + Contracts.issuance.RecurringAgreementManager, + DeploymentActions.TRANSFER, + async (env) => { + const readFn = read(env) + const executeFn = execute(env) + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + const ram = requireContract(env, Contracts.issuance.RecurringAgreementManager) + + env.showMessage(`\n========== Transfer ${Contracts.issuance.RecurringAgreementManager.name} ==========`) + + // Check if deployer GOVERNOR_ROLE already revoked (shared precondition check) + const precondition = await checkDeployerRevoked(client, ram.address, deployer) + if (precondition.done) { + env.showMessage(`✓ Deployer GOVERNOR_ROLE already revoked`) + } else { + const GOVERNOR_ROLE = (await readFn(ram, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + + env.showMessage(`🔨 Revoking deployer GOVERNOR_ROLE...`) + await executeFn(ram, { + account: deployer, + functionName: 'revokeRole', + args: [GOVERNOR_ROLE, deployer], + }) + env.showMessage(` ✓ revokeRole(GOVERNOR_ROLE) executed`) + } + + // Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.RecurringAgreementManager) + + env.showMessage(`\n✅ ${Contracts.issuance.RecurringAgreementManager.name} governance transferred!\n`) + }, +) diff --git a/packages/deployment/deploy/agreement/manager/09_end.ts b/packages/deployment/deploy/agreement/manager/09_end.ts new file mode 100644 index 000000000..c68c1db6a --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.RecurringAgreementManager) diff --git a/packages/deployment/deploy/agreement/manager/10_status.ts b/packages/deployment/deploy/agreement/manager/10_status.ts new file mode 100644 index 000000000..d7e3f98bc --- /dev/null +++ b/packages/deployment/deploy/agreement/manager/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.issuance.RecurringAgreementManager) diff --git a/packages/deployment/deploy/allocate/allocator/01_deploy.ts b/packages/deployment/deploy/allocate/allocator/01_deploy.ts index 0db712c63..58bd3ca30 100644 --- a/packages/deployment/deploy/allocate/allocator/01_deploy.ts +++ b/packages/deployment/deploy/allocate/allocator/01_deploy.ts @@ -1,49 +1,12 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { deployProxyContract, requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Deploy IssuanceAllocator - Token allocation contract with transparent proxy - * - * This deploys IssuanceAllocator as an upgradeable contract using OpenZeppelin v5's - * TransparentUpgradeableProxy pattern. The contract is initialized atomically - * during proxy deployment to prevent front-running attacks. - * - * Architecture: - * - Implementation: IssuanceAllocator contract with GRT token constructor arg - * - Proxy: OZ v5 TransparentUpgradeableProxy with atomic initialization - * - Admin: Per-proxy ProxyAdmin (created by OZ v5 proxy, owned by governor) - * - * Initial Setup (IssuanceAllocator.md Step 1): - * - Governor receives initial GOVERNOR_ROLE for configuration - * - Per-proxy ProxyAdmin owned by governor (controls upgrades) - * - Default target set to address(0) (no minting until configured) - * - Governance transfer happens in separate script - * - * Deployment strategy: - * - First run: Deploy implementation + proxy (creates per-proxy ProxyAdmin) - * - Subsequent runs: - * - If implementation unchanged: No-op (reuse existing) - * - If implementation changed: Deploy new implementation, store as pending - * - Upgrades must be done via governance - * - * Usage: - * pnpm hardhat deploy --tags issuance-allocator-deploy --network - */ - -const func: DeployScriptModule = async (env) => { - const graphToken = requireContract(env, Contracts.horizon.L2GraphToken).address - - env.showMessage(`\n📦 Deploying ${Contracts.issuance.IssuanceAllocator.name} with GraphToken: ${graphToken}`) - - await deployProxyContract(env, { - contract: Contracts.issuance.IssuanceAllocator, - constructorArgs: [graphToken], - }) -} - -func.tags = Tags.issuanceAllocatorDeploy -func.dependencies = [SpecialTags.SYNC] - -export default func +import { requireContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createProxyDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createProxyDeployModule( + Contracts.issuance.IssuanceAllocator, + (env) => ({ + constructorArgs: [requireContract(env, Contracts.horizon.L2GraphToken).address], + initializeArgs: [requireDeployer(env)], + }), + { prerequisites: [Contracts.horizon.L2GraphToken] }, +) diff --git a/packages/deployment/deploy/allocate/allocator/02_upgrade.ts b/packages/deployment/deploy/allocate/allocator/02_upgrade.ts index 66cab6a8d..8f012a025 100644 --- a/packages/deployment/deploy/allocate/allocator/02_upgrade.ts +++ b/packages/deployment/deploy/allocate/allocator/02_upgrade.ts @@ -1,26 +1,4 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' -// IssuanceAllocator Upgrade -// -// Generates governance TX batch and executes upgrade via per-proxy ProxyAdmin. -// -// Workflow: -// 1. Check for pending implementation in address book -// 2. Generate governance TX (upgradeAndCall to per-proxy ProxyAdmin) -// 3. Fork mode: execute via governor impersonation -// 4. Production: output TX file for Safe execution -// -// Usage: -// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags issuance-allocator-upgrade --network localhost - -const func: DeployScriptModule = async (env) => { - await upgradeImplementation(env, Contracts.issuance.IssuanceAllocator) -} - -func.tags = Tags.issuanceAllocatorUpgrade -func.dependencies = [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.DEPLOY)] - -export default func +export default createUpgradeModule(Contracts.issuance.IssuanceAllocator) diff --git a/packages/deployment/deploy/allocate/allocator/03_deploy.ts b/packages/deployment/deploy/allocate/allocator/03_deploy.ts deleted file mode 100644 index a3a1c6cb9..000000000 --- a/packages/deployment/deploy/allocate/allocator/03_deploy.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * IssuanceAllocator end state - deployed, upgraded, configured, and governance transferred - * - * Full lifecycle (steps 1-6 from IssuanceAllocator.md): - * 1. Deploy and initialize with deployer as GOVERNOR_ROLE - * 2-3. Configure issuance rate and RewardsManager allocation - * 4-5. (Optional upgrade steps) - * 6. Transfer governance to protocol governance multisig - * - * Usage: - * pnpm hardhat deploy --tags issuance-allocator --network - */ -const func: DeployScriptModule = async (env) => { - requireUpgradeExecuted(env, 'IssuanceAllocator') - env.showMessage(`\n✓ IssuanceAllocator ready (governance transferred)`) -} - -func.tags = Tags.issuanceAllocator -func.dependencies = [ - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.DEPLOY), - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.UPGRADE), - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.CONFIGURE), - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.TRANSFER), -] - -export default func diff --git a/packages/deployment/deploy/allocate/allocator/04_configure.ts b/packages/deployment/deploy/allocate/allocator/04_configure.ts index 32076684f..d46243e74 100644 --- a/packages/deployment/deploy/allocate/allocator/04_configure.ts +++ b/packages/deployment/deploy/allocate/allocator/04_configure.ts @@ -1,157 +1,168 @@ -import { REWARDS_MANAGER_DEPRECATED_ABI, SET_TARGET_ALLOCATION_ABI } from '@graphprotocol/deployment/lib/abis.js' -import { requireRewardsManagerUpgraded } from '@graphprotocol/deployment/lib/contract-checks.js' +import { ACCESS_CONTROL_ENUMERABLE_ABI, REWARDS_MANAGER_DEPRECATED_ABI } from '@graphprotocol/deployment/lib/abis.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { execute, graph, read, tx } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { checkIAConfigured } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, read, tx } from '@graphprotocol/deployment/rocketh/deploy.js' import type { PublicClient } from 'viem' import { encodeFunctionData } from 'viem' /** - * Configure ${Contracts.issuance.IssuanceAllocator.name} initial state (deployer account) + * Configure IssuanceAllocator * - * Configuration steps (IssuanceAllocator.md steps 2-3): - * 2. Set issuance rate to match RewardsManager - * 3. Configure RM as 100% self-minting target + * - Sets issuance rate to match RewardsManager + * - Configures RM as 100% self-minting target + * - Grants GOVERNOR_ROLE to protocol governor + * - Grants PAUSE_ROLE to pause guardian + * + * If deployer has GOVERNOR_ROLE (fresh deploy), executes directly. + * If governance transferred, generates governance TX or executes via governor. * - * Requires deployer to have GOVERNOR_ROLE (granted during initialization in step 1). - * PAUSE_ROLE will be granted in step 6 (transfer governance script). * Idempotent: checks on-chain state, skips if already configured. * * Usage: - * pnpm hardhat deploy --tags issuance-allocator-configure --network + * pnpm hardhat deploy --tags IssuanceAllocator,configure --network */ -const func: DeployScriptModule = async (env) => { - const readFn = read(env) - const executeFn = execute(env) - - const deployer = requireDeployer(env) - - const [issuanceAllocator, rewardsManager] = requireContracts(env, [ - Contracts.issuance.IssuanceAllocator, - Contracts.horizon.RewardsManager, - ]) - - // Create viem client for direct contract calls - const client = graph.getPublicClient(env) - - // Check if RewardsManager supports IIssuanceTarget (has been upgraded) - // Throws error if not upgraded - await requireRewardsManagerUpgraded(client as PublicClient, rewardsManager.address, env) - - env.showMessage(`\n========== Configure ${Contracts.issuance.IssuanceAllocator.name} ==========`) - env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${issuanceAllocator.address}`) - env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rewardsManager.address}`) - env.showMessage(`Deployer: ${deployer}\n`) - - // Get role constants - const GOVERNOR_ROLE = (await readFn(issuanceAllocator, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` - - // Check current state - env.showMessage('📋 Checking current configuration...\n') - - const checks = { - issuanceRate: false, - rmAllocation: false, - } - - // Check issuance rate - // Note: Use viem directly for RM because synced deployment has empty ABI - const rmIssuanceRate = (await client.readContract({ - address: rewardsManager.address as `0x${string}`, - abi: REWARDS_MANAGER_DEPRECATED_ABI, - functionName: 'issuancePerBlock', - })) as bigint - const iaIssuanceRate = (await readFn(issuanceAllocator, { functionName: 'getIssuancePerBlock' })) as bigint - checks.issuanceRate = iaIssuanceRate === rmIssuanceRate && iaIssuanceRate > 0n - env.showMessage(` Issuance rate: ${checks.issuanceRate ? '✓' : '✗'} (IA: ${iaIssuanceRate}, RM: ${rmIssuanceRate})`) - - // Check RM allocation (should be 100% self-minting) - try { - const rmAllocation = (await readFn(issuanceAllocator, { - functionName: 'getTargetAllocation', - args: [rewardsManager.address], - })) as { totalAllocationRate: bigint; allocatorMintingRate: bigint; selfMintingRate: bigint } - const expectedSelfMinting = iaIssuanceRate > 0n ? iaIssuanceRate : rmIssuanceRate - checks.rmAllocation = - rmAllocation.allocatorMintingRate === 0n && rmAllocation.selfMintingRate === expectedSelfMinting - env.showMessage( - ` RM allocation: ${checks.rmAllocation ? '✓' : '✗'} (allocator: ${rmAllocation.allocatorMintingRate}, self: ${rmAllocation.selfMintingRate})`, +export default createActionModule( + Contracts.issuance.IssuanceAllocator, + DeploymentActions.CONFIGURE, + async (env) => { + const readFn = read(env) + const deployer = requireDeployer(env) + const governor = await getGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + + const [issuanceAllocator, rewardsManager] = requireContracts(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.horizon.RewardsManager, + ]) + + const client = graph.getPublicClient(env) as PublicClient + + env.showMessage(`\n========== Configure ${Contracts.issuance.IssuanceAllocator.name} ==========`) + env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${issuanceAllocator.address}`) + env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rewardsManager.address}`) + + // Check if already configured (shared precondition check) + const precondition = await checkIAConfigured( + client, + issuanceAllocator.address, + rewardsManager.address, + governor, + pauseGuardian, ) - } catch (error) { - env.showMessage(` RM allocation: ✗ (error reading: ${error})`) - } - - // Check deployer role (informational - determines who can execute missing config) - const deployerHasGovernorRole = (await readFn(issuanceAllocator, { - functionName: 'hasRole', - args: [GOVERNOR_ROLE, deployer], - })) as boolean - env.showMessage(` Deployer GOVERNOR_ROLE: ${deployerHasGovernorRole ? '✓' : '✗'} (${deployer})`) - - // Note: PAUSE_ROLE will be granted in step 6 (transfer governance) - - // Configuration complete? - const configurationComplete = Object.values(checks).every(Boolean) - if (configurationComplete) { - env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} already configured\n`) - return - } - - // Check if deployer has permission to execute missing configuration - // If governance has been transferred, configuration must be done via governance TX - if (!deployerHasGovernorRole) { - env.showMessage('\n❌ Configuration incomplete but deployer does not have GOVERNOR_ROLE') - env.showMessage(' Governance has been transferred - this configuration must be done via governance TX') - env.showMessage(` Missing configuration:`) - if (!checks.issuanceRate) { - env.showMessage(` - Issuance rate (currently: ${iaIssuanceRate})`) + if (precondition.done) { + env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} already configured\n`) + return + } + + // Get RM issuance rate (target for IA) + const rmIssuanceRate = (await client.readContract({ + address: rewardsManager.address as `0x${string}`, + abi: REWARDS_MANAGER_DEPRECATED_ABI, + functionName: 'issuancePerBlock', + })) as bigint + + if (rmIssuanceRate === 0n) { + env.showMessage(`\n ○ RM.issuancePerBlock is 0 — skipping IA configure\n`) + return + } + + // Determine what still needs configuring + env.showMessage('\n📋 Checking current configuration...\n') + + const iaIssuanceRate = (await readFn(issuanceAllocator, { functionName: 'getIssuancePerBlock' })) as bigint + const rateOk = iaIssuanceRate === rmIssuanceRate && iaIssuanceRate > 0n + env.showMessage(` Issuance rate: ${rateOk ? '✓' : '✗'} (IA: ${iaIssuanceRate}, RM: ${rmIssuanceRate})`) + + // Check role grants + const GOVERNOR_ROLE = (await readFn(issuanceAllocator, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + const PAUSE_ROLE = (await readFn(issuanceAllocator, { functionName: 'PAUSE_ROLE' })) as `0x${string}` + + const governorHasRole = (await readFn(issuanceAllocator, { + functionName: 'hasRole', + args: [GOVERNOR_ROLE, governor], + })) as boolean + env.showMessage(` Governor GOVERNOR_ROLE: ${governorHasRole ? '✓' : '✗'}`) + + const pauseGuardianHasRole = (await readFn(issuanceAllocator, { + functionName: 'hasRole', + args: [PAUSE_ROLE, pauseGuardian], + })) as boolean + env.showMessage(` PauseGuardian PAUSE_ROLE: ${pauseGuardianHasRole ? '✓' : '✗'}`) + + // Determine executor: deployer if has GOVERNOR_ROLE, else protocol governor + const deployerHasRole = (await readFn(issuanceAllocator, { + functionName: 'hasRole', + args: [GOVERNOR_ROLE, deployer], + })) as boolean + + // Build TX data for missing configuration + const txs: Array<{ to: string; data: `0x${string}`; label: string }> = [] + + if (!rateOk) { + txs.push({ + to: issuanceAllocator.address, + data: encodeFunctionData({ + abi: [ + { + inputs: [{ type: 'uint256' }], + name: 'setIssuancePerBlock', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + ], + functionName: 'setIssuancePerBlock', + args: [rmIssuanceRate], + }), + label: `setIssuancePerBlock(${rmIssuanceRate})`, + }) + } + + if (!governorHasRole) { + txs.push({ + to: issuanceAllocator.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + }), + label: `grantRole(GOVERNOR_ROLE, ${governor})`, + }) + } + + if (!pauseGuardianHasRole) { + txs.push({ + to: issuanceAllocator.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + }), + label: `grantRole(PAUSE_ROLE, ${pauseGuardian})`, + }) } - if (!checks.rmAllocation) { - env.showMessage(` - RM allocation (not configured)`) + + if (!deployerHasRole) { + env.showMessage(`\n ○ Deployer does not have GOVERNOR_ROLE — skipping (governance TX in upgrade step)\n`) + return } - env.showMessage(`\n This should not happen in normal deployment flow.`) - env.showMessage(` Configuration (step 5) should complete before governance transfer (step 6).\n`) - process.exit(1) - } - - // Execute configuration as deployer - env.showMessage('\n🔨 Executing configuration...\n') - - // Step 2: Set issuance rate - if (!checks.issuanceRate) { - env.showMessage(` Setting issuance rate to ${rmIssuanceRate}...`) - await executeFn(issuanceAllocator, { - account: deployer, - functionName: 'setIssuancePerBlock', - args: [rmIssuanceRate], - }) - env.showMessage(' ✓ setIssuancePerBlock executed') - } - - // Step 3: Configure RM allocation (3-arg version: target, allocatorMintingRate, selfMintingRate) - // Note: Use tx() with encoded data to select the 3-arg overload (rocketh picks wrong one) - if (!checks.rmAllocation) { + + if (txs.length === 0) return + + env.showMessage('\n🔨 Executing configuration as deployer...\n') const txFn = tx(env) - const rate = iaIssuanceRate > 0n ? iaIssuanceRate : rmIssuanceRate - env.showMessage(` Setting RM allocation (0, ${rate})...`) - const data = encodeFunctionData({ - abi: SET_TARGET_ALLOCATION_ABI, - functionName: 'setTargetAllocation', - args: [rewardsManager.address as `0x${string}`, 0n, rate], - }) - await txFn({ account: deployer, to: issuanceAllocator.address, data }) - env.showMessage(' ✓ setTargetAllocation executed') - } - - env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} configuration complete!\n`) -} - -func.tags = Tags.issuanceAllocatorConfigure -func.dependencies = [ - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.DEPLOY), - ComponentTags.REWARDS_MANAGER_UPGRADE, -] - -export default func + for (const t of txs) { + await txFn({ account: deployer, to: t.to as `0x${string}`, data: t.data }) + env.showMessage(` ✓ ${t.label}`) + } + env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} configuration complete!\n`) + }, + { + extraDependencies: [ComponentTags.REWARDS_MANAGER], + prerequisites: [Contracts.horizon.RewardsManager], + }, +) diff --git a/packages/deployment/deploy/allocate/allocator/05_verify_governance.ts b/packages/deployment/deploy/allocate/allocator/05_verify_governance.ts deleted file mode 100644 index 3674ffdd7..000000000 --- a/packages/deployment/deploy/allocate/allocator/05_verify_governance.ts +++ /dev/null @@ -1,189 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { getProxyAdminAddress, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph, read } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Verify governance and configuration for all issuance contracts - * - * This implements Step 7 from IssuanceAllocator.md: - * - Bytecode verification (deployment bytecode matches expected contract) - * - Access control: - * - Governor has GOVERNOR_ROLE on all contracts - * - Deployment account does NOT have GOVERNOR_ROLE - * - Pause guardian has PAUSE_ROLE on pausable contracts - * - Off-chain: Review all RoleGranted events since deployment - * - Pause state: Verify contract is not paused - * - Issuance rate: Verify matches RewardsManager rate exactly - * - Target configuration: Verify only expected targets exist - * - Proxy configuration: Verify ProxyAdmin controls proxy and is owned by governance - * - * The issuance contracts use role-based access control (OpenZeppelin AccessControl) - * rather than ownership patterns. - * - * This script is idempotent and runs after governance transfer (step 6) to ensure - * proper access control configuration before activation (steps 8-10). - * - * Usage: - * pnpm hardhat deploy --tags verify-governance --network - * - * Or as part of full deployment: - * pnpm hardhat deploy --tags issuance-allocation --network - */ -const func: DeployScriptModule = async (env) => { - const readFn = read(env) - - const deployer = requireDeployer(env) - - // Get protocol governor and pause guardian from Controller - const governor = await getGovernor(env) - const pauseGuardian = await getPauseGuardian(env) - - const contracts = [ - Contracts.issuance.IssuanceAllocator.name, - Contracts.issuance.PilotAllocation.name, - Contracts.issuance.RewardsEligibilityOracle.name, - ] - - env.showMessage('\n========== Governance and Configuration Verification ==========\n') - - // 1. Verify GOVERNOR_ROLE (governor has, deployer does not) - env.showMessage('1. Verifying GOVERNOR_ROLE assignment...') - for (const contractName of contracts) { - const deployment = env.getOrNull(contractName) - if (!deployment) { - env.showMessage(` Skipping ${contractName} - not deployed`) - continue - } - - try { - const governorRole = (await readFn(deployment, { functionName: 'GOVERNOR_ROLE' })) as string - - // Check governor has role - const governorHasRole = (await readFn(deployment, { - functionName: 'hasRole', - args: [governorRole, governor], - })) as boolean - - // Check deployer does NOT have role - const deployerHasRole = (await readFn(deployment, { - functionName: 'hasRole', - args: [governorRole, deployer], - })) as boolean - - if (governorHasRole && !deployerHasRole) { - env.showMessage(` ✓ ${contractName}: Governor has GOVERNOR_ROLE, deployer revoked`) - } else if (governorHasRole && deployerHasRole) { - env.showMessage(` ⚠ ${contractName}: Governor has GOVERNOR_ROLE but deployer NOT revoked`) - } else if (!governorHasRole && deployerHasRole) { - env.showMessage(` ⚠ ${contractName}: Deployer has GOVERNOR_ROLE but governance NOT transferred`) - } else { - env.showMessage(` ✗ ${contractName}: WARNING - Neither governor nor deployer has GOVERNOR_ROLE`) - } - } catch (error) { - env.showMessage(` ✗ ${contractName}: Error verifying governance: ${error}`) - } - } - - // 2. Verify PAUSE_ROLE - env.showMessage('\n2. Verifying PAUSE_ROLE assignment...') - const pausableContracts = [ - Contracts.issuance.IssuanceAllocator.name, - Contracts.issuance.PilotAllocation.name, - Contracts.issuance.RewardsEligibilityOracle.name, - ] - for (const contractName of pausableContracts) { - const deployment = env.getOrNull(contractName) - if (!deployment) continue - - try { - const pauseRole = (await readFn(deployment, { functionName: 'PAUSE_ROLE' })) as string - const hasPauseRole = (await readFn(deployment, { - functionName: 'hasRole', - args: [pauseRole, pauseGuardian], - })) as boolean - - if (hasPauseRole) { - env.showMessage(` ✓ ${contractName}: Pause guardian has PAUSE_ROLE`) - } else { - env.showMessage( - ` ⚠ ${contractName}: Pause guardian does NOT have PAUSE_ROLE (will be granted in 06_transfer_governance)`, - ) - } - } catch (error) { - env.showMessage(` ⚠ ${contractName}: Cannot verify PAUSE_ROLE: ${error}`) - } - } - - // 3. Verify IssuanceAllocator configuration - env.showMessage('\n3. Verifying IssuanceAllocator configuration...') - const iaDeployment = env.getOrNull(Contracts.issuance.IssuanceAllocator.name) - if (iaDeployment) { - try { - const issuanceRate = (await readFn(iaDeployment, { functionName: 'getIssuancePerBlock' })) as bigint - const isPaused = (await readFn(iaDeployment, { functionName: 'paused' })) as boolean - - env.showMessage(` Issuance rate: ${issuanceRate} tokens/block`) - env.showMessage(` Paused: ${isPaused}`) - - if (issuanceRate === 0n) { - env.showMessage(` ⚠ Issuance rate is 0 (will be configured in step 5)`) - } else { - env.showMessage(` ✓ Issuance rate configured`) - } - - if (isPaused) { - env.showMessage(` ✗ WARNING: Contract is PAUSED`) - } else { - env.showMessage(` ✓ Contract is not paused`) - } - } catch (error) { - env.showMessage(` ✗ Error verifying IssuanceAllocator configuration: ${error}`) - } - } - - // 4. Verify per-proxy ProxyAdmin ownership (OZ v5 pattern) - env.showMessage('\n4. Verifying per-proxy ProxyAdmin ownership...') - const client = graph.getPublicClient(env) - const proxiedContracts = [ - Contracts.issuance.IssuanceAllocator.name, - Contracts.issuance.PilotAllocation.name, - Contracts.issuance.RewardsEligibilityOracle.name, - ] - for (const contractName of proxiedContracts) { - const proxyDeployment = env.getOrNull(`${contractName}_Proxy`) - if (!proxyDeployment) { - env.showMessage(` Skipping ${contractName} - proxy not deployed`) - continue - } - - try { - // Read per-proxy ProxyAdmin address from ERC1967 slot - const proxyAdminAddress = await getProxyAdminAddress(client, proxyDeployment.address) - - // Read owner from ProxyAdmin - const owner = (await client.readContract({ - address: proxyAdminAddress as `0x${string}`, - abi: [{ name: 'owner', type: 'function', inputs: [], outputs: [{ type: 'address' }] }], - functionName: 'owner', - })) as string - - if (owner.toLowerCase() === governor.toLowerCase()) { - env.showMessage(` ✓ ${contractName}: ProxyAdmin (${proxyAdminAddress}) owned by governor`) - } else { - env.showMessage(` ✗ ${contractName}: ProxyAdmin owned by ${owner}, expected ${governor}`) - } - } catch (error) { - env.showMessage(` ✗ ${contractName}: Error verifying ProxyAdmin ownership: ${error}`) - } - } - - env.showMessage('\n========== Verification Complete ==========\n') -} - -func.tags = Tags.verifyGovernance -func.dependencies = [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.TRANSFER)] // Run after governance transfer (step 6) - -export default func diff --git a/packages/deployment/deploy/allocate/allocator/06_transfer_governance.ts b/packages/deployment/deploy/allocate/allocator/06_transfer_governance.ts index eba857f27..b960839b7 100644 --- a/packages/deployment/deploy/allocate/allocator/06_transfer_governance.ts +++ b/packages/deployment/deploy/allocate/allocator/06_transfer_governance.ts @@ -1,132 +1,61 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { execute, read } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContracts, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkDeployerRevoked } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { execute, graph, read } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' /** - * Transfer governance of ${Contracts.issuance.IssuanceAllocator.name} from deployer to protocol governor (deployer account) + * Transfer IssuanceAllocator governance from deployer to protocol governor * - * Step 6 from IssuanceAllocator.md: - * - Grant PAUSE_ROLE to pause guardian (from Controller) - * - Grant GOVERNOR_ROLE to protocol governor (from Controller.getGovernor()) - * - Revoke GOVERNOR_ROLE from deployment account (MUST grant to governance first, then revoke) + * - Revoke GOVERNOR_ROLE from deployment account + * - Transfer ProxyAdmin ownership to governor * - * This is a critical security step that transfers control from the deployment account - * to the protocol governance multisig. After this step, only governance can modify - * issuance allocations and rates. + * Role grants (GOVERNOR_ROLE to governor, PAUSE_ROLE to pauseGuardian) happen + * in 04_configure.ts. This script only revokes deployer access. * - * Requires deployer to have GOVERNOR_ROLE (granted during initialization in step 1). * Idempotent: checks on-chain state, skips if already transferred. * * Usage: - * pnpm hardhat deploy --tags issuance-transfer-governance --network + * pnpm hardhat deploy --tags IssuanceAllocator,transfer --network */ -const func: DeployScriptModule = async (env) => { +export default createActionModule(Contracts.issuance.IssuanceAllocator, DeploymentActions.TRANSFER, async (env) => { const readFn = read(env) const executeFn = execute(env) + const client = graph.getPublicClient(env) as PublicClient const deployer = requireDeployer(env) - - // Get protocol governor and pause guardian from Controller const governor = await getGovernor(env) - const pauseGuardian = await getPauseGuardian(env) - const [issuanceAllocator] = requireContracts(env, [Contracts.issuance.IssuanceAllocator]) - env.showMessage(`\n========== Transfer Governance of ${Contracts.issuance.IssuanceAllocator.name} ==========`) - env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${issuanceAllocator.address}`) + env.showMessage(`\n========== Transfer ${Contracts.issuance.IssuanceAllocator.name} ==========`) env.showMessage(`Deployer: ${deployer}`) - env.showMessage(`Protocol Governor (from Controller): ${governor}`) - env.showMessage(`Pause Guardian: ${pauseGuardian}\n`) - - // Get role constants - const GOVERNOR_ROLE = (await readFn(issuanceAllocator, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` - const PAUSE_ROLE = (await readFn(issuanceAllocator, { functionName: 'PAUSE_ROLE' })) as `0x${string}` - - // Check current state - env.showMessage('📋 Checking current governance state...\n') - - const checks = { - pauseRole: false, - governorHasRole: false, - deployerRevoked: false, - } - - // Check pause role - checks.pauseRole = (await readFn(issuanceAllocator, { - functionName: 'hasRole', - args: [PAUSE_ROLE, pauseGuardian], - })) as boolean - env.showMessage(` Pause guardian has PAUSE_ROLE: ${checks.pauseRole ? '✓' : '✗'} (${pauseGuardian})`) - - // Check governor has GOVERNOR_ROLE - checks.governorHasRole = (await readFn(issuanceAllocator, { - functionName: 'hasRole', - args: [GOVERNOR_ROLE, governor], - })) as boolean - env.showMessage(` Governor has GOVERNOR_ROLE: ${checks.governorHasRole ? '✓' : '✗'} (${governor})`) - - // Check deployer no longer has GOVERNOR_ROLE - const deployerHasRole = (await readFn(issuanceAllocator, { - functionName: 'hasRole', - args: [GOVERNOR_ROLE, deployer], - })) as boolean - checks.deployerRevoked = !deployerHasRole - env.showMessage(` Deployer GOVERNOR_ROLE revoked: ${checks.deployerRevoked ? '✓' : '✗'} (${deployer})`) - - // All checks passed? - const allPassed = Object.values(checks).every(Boolean) - if (allPassed) { - env.showMessage(`\n✅ Governance already transferred to ${governor}\n`) - return - } + env.showMessage(`Governor: ${governor}\n`) - // Execute governance transfer - // CRITICAL: Must grant to governance BEFORE revoking from deployer - env.showMessage('\n🔨 Executing governance transfer...\n') + // Check if deployer GOVERNOR_ROLE already revoked (shared precondition check) + const precondition = await checkDeployerRevoked(client, issuanceAllocator.address, deployer) + if (precondition.done) { + env.showMessage(`✓ Deployer GOVERNOR_ROLE already revoked`) + } else { + const GOVERNOR_ROLE = (await readFn(issuanceAllocator, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` - // Step 1: Grant PAUSE_ROLE to pause guardian - if (!checks.pauseRole) { - env.showMessage(` Granting PAUSE_ROLE to ${pauseGuardian}...`) - await executeFn(issuanceAllocator, { - account: deployer, - functionName: 'grantRole', - args: [PAUSE_ROLE, pauseGuardian], - }) - env.showMessage(' ✓ grantRole(PAUSE_ROLE) executed') - } - - // Step 2: Grant GOVERNOR_ROLE to governor - if (!checks.governorHasRole) { - env.showMessage(` Granting GOVERNOR_ROLE to ${governor}...`) - await executeFn(issuanceAllocator, { - account: deployer, - functionName: 'grantRole', - args: [GOVERNOR_ROLE, governor], - }) - env.showMessage(' ✓ grantRole(GOVERNOR_ROLE) executed') - } - - // Step 3: Revoke GOVERNOR_ROLE from deployer (ONLY after governance has the role) - if (!checks.deployerRevoked) { - env.showMessage(` Revoking GOVERNOR_ROLE from deployer ${deployer}...`) + env.showMessage(`🔨 Revoking deployer GOVERNOR_ROLE...`) await executeFn(issuanceAllocator, { account: deployer, functionName: 'revokeRole', args: [GOVERNOR_ROLE, deployer], }) - env.showMessage(' ✓ revokeRole(GOVERNOR_ROLE) executed') + env.showMessage(` ✓ revokeRole(GOVERNOR_ROLE) executed`) } - env.showMessage(`\n✅ Governance transferred to ${governor}!\n`) - env.showMessage( - `⚠️ IMPORTANT: Deployer no longer has control. Only governance can modify ${Contracts.issuance.IssuanceAllocator.name}.\n`, - ) -} - -func.tags = Tags.issuanceTransfer -func.dependencies = [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.CONFIGURE)] + // Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.IssuanceAllocator) -export default func + env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} governance transferred!\n`) +}) diff --git a/packages/deployment/deploy/allocate/allocator/07_activate.ts b/packages/deployment/deploy/allocate/allocator/07_activate.ts deleted file mode 100644 index 4d189166e..000000000 --- a/packages/deployment/deploy/allocate/allocator/07_activate.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { GRAPH_TOKEN_ABI, ISSUANCE_TARGET_ABI, REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' -import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' -import { requireRewardsManagerUpgraded } from '@graphprotocol/deployment/lib/contract-checks.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { ComponentTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { createGovernanceTxBuilder, saveGovernanceTxAndExit } from '@graphprotocol/deployment/lib/execute-governance.js' -import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' -import { encodeFunctionData } from 'viem' - -/** - * Activate ${Contracts.issuance.IssuanceAllocator.name} in the protocol (governance account) - * - * Steps 8-10 from IssuanceAllocator.md: - * - Configure RewardsManager to use IssuanceAllocator - * - Grant minter role to IssuanceAllocator on GraphToken - * - (Optional) Set default target for unallocated issuance - * - * Idempotent: checks on-chain state, skips if already activated. - * Generates Safe TX batch for governance execution. - * Does NOT execute - governance must execute via Safe or deploy:execute-governance. - * - * Usage: - * pnpm hardhat deploy --tags issuance-activation --network - */ -const func: DeployScriptModule = async (env) => { - const deployer = requireDeployer(env) - - // Get protocol governor from Controller - const governor = await getGovernor(env) - - const [issuanceAllocator, rewardsManager, graphToken] = requireContracts(env, [ - Contracts.issuance.IssuanceAllocator, - Contracts.horizon.RewardsManager, - Contracts.horizon.L2GraphToken, - ]) - - const iaAddress = issuanceAllocator.address - const rmAddress = rewardsManager.address - const gtAddress = graphToken.address - - // Create viem client for direct contract calls - const client = graph.getPublicClient(env) as PublicClient - - // Check if RewardsManager supports IIssuanceTarget (has been upgraded) - // Throws error if not upgraded - await requireRewardsManagerUpgraded(client, rmAddress, env) - - const targetChainId = await getTargetChainIdFromEnv(env) - - env.showMessage(`\n========== Activate ${Contracts.issuance.IssuanceAllocator.name} ==========`) - env.showMessage(`Network: ${env.name} (chainId=${targetChainId})`) - env.showMessage(`Deployer: ${deployer}`) - env.showMessage(`Protocol Governor (from Controller): ${governor}`) - env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${iaAddress}`) - env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rmAddress}`) - env.showMessage(`${Contracts.horizon.L2GraphToken.name}: ${gtAddress}\n`) - - // Check current state - env.showMessage('📋 Checking current activation state...\n') - - const checks = { - iaIntegrated: false, - iaMinter: false, - } - - // Step 8: Check RM.getIssuanceAllocator() == IA - // Note: Use viem directly because synced deployments have empty ABIs - const currentIA = (await client.readContract({ - address: rmAddress as `0x${string}`, - abi: REWARDS_MANAGER_ABI, - functionName: 'getIssuanceAllocator', - })) as string - checks.iaIntegrated = currentIA.toLowerCase() === iaAddress.toLowerCase() - env.showMessage(` IA integrated: ${checks.iaIntegrated ? '✓' : '✗'} (current: ${currentIA})`) - - // Step 9: Check GraphToken.isMinter(IA) - checks.iaMinter = (await client.readContract({ - address: gtAddress as `0x${string}`, - abi: GRAPH_TOKEN_ABI, - functionName: 'isMinter', - args: [iaAddress as `0x${string}`], - })) as boolean - env.showMessage(` IA minter: ${checks.iaMinter ? '✓' : '✗'}`) - - // All checks passed? - const allPassed = Object.values(checks).every(Boolean) - if (allPassed) { - env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} already activated\n`) - return - } - - // Build TX batch for missing activation steps - env.showMessage('\n🔨 Building activation TX batch...\n') - - const builder = await createGovernanceTxBuilder(env, `activate-${Contracts.issuance.IssuanceAllocator.name}`) - - // Step 8: RM.setIssuanceAllocator(IA) - if (!checks.iaIntegrated) { - const data = encodeFunctionData({ - abi: ISSUANCE_TARGET_ABI, - functionName: 'setIssuanceAllocator', - args: [iaAddress as `0x${string}`], - }) - builder.addTx({ to: rmAddress, value: '0', data }) - env.showMessage(` + RewardsManager.setIssuanceAllocator(${iaAddress})`) - } - - // Step 9: GraphToken.addMinter(IA) - if (!checks.iaMinter) { - const data = encodeFunctionData({ - abi: GRAPH_TOKEN_ABI, - functionName: 'addMinter', - args: [iaAddress as `0x${string}`], - }) - builder.addTx({ to: gtAddress, value: '0', data }) - env.showMessage(` + GraphToken.addMinter(${iaAddress})`) - } - - saveGovernanceTxAndExit(env, builder, `${Contracts.issuance.IssuanceAllocator.name} activation`) -} - -func.tags = Tags.issuanceActivation -func.dependencies = [ComponentTags.VERIFY_GOVERNANCE, ComponentTags.REWARDS_MANAGER_DEPLOY] // Run after governance transfer and verification (steps 6-7) - -export default func diff --git a/packages/deployment/deploy/allocate/allocator/08_allocation.ts b/packages/deployment/deploy/allocate/allocator/08_allocation.ts deleted file mode 100644 index 9b18ae5c8..000000000 --- a/packages/deployment/deploy/allocate/allocator/08_allocation.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { - checkIssuanceAllocatorActivation, - isRewardsManagerUpgraded, -} from '@graphprotocol/deployment/lib/contract-checks.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { ComponentTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' - -/** - * Full IssuanceAllocator deployment - deploy, configure, transfer governance, verify, and activate - * - * This is the aggregate tag for complete IssuanceAllocator setup (IssuanceAllocator.md steps 1-10): - * 1. Deploy IssuanceAllocator proxy and implementation (deployer has initial GOVERNOR_ROLE) - * 2-3. Configure: set rate, RM allocation (deployer executes) - * 4-5. (Optional upgrade steps via governance) - * 6. Transfer governance: grant roles to governance, revoke from deployer (deployer executes) - * 7. Verify: bytecode, access control, configuration (automated verification) - * 8-10. Generate governance TX for activation: RM integration, minter role (governance must execute) - * - * Requires: - * - RewardsManager to be upgraded first (supports IIssuanceTarget) - * - Governance to execute activation TX (steps 8-10) via Safe or deploy:execute-governance - * - * Usage: - * pnpm hardhat deploy --tags issuance-allocation --network - */ -const func: DeployScriptModule = async (env) => { - const [issuanceAllocator, rewardsManager, graphToken] = requireContracts(env, [ - Contracts.issuance.IssuanceAllocator, - Contracts.horizon.RewardsManager, - Contracts.horizon.L2GraphToken, - ]) - - // Verify RM has been upgraded (supports IERC165) - const client = graph.getPublicClient(env) as PublicClient - const upgraded = await isRewardsManagerUpgraded(client, rewardsManager.address) - if (!upgraded) { - env.showMessage( - `\n❌ ${Contracts.horizon.RewardsManager.name} not upgraded - run deploy:execute-governance first\n`, - ) - process.exit(1) - } - - // Verify activation state - const activation = await checkIssuanceAllocatorActivation( - client, - issuanceAllocator.address, - rewardsManager.address, - graphToken.address, - ) - - if (!activation.iaIntegrated || !activation.iaMinter) { - env.showMessage(`\n❌ ${Contracts.issuance.IssuanceAllocator.name} not fully activated`) - env.showMessage( - ` IA integrated with ${Contracts.horizon.RewardsManager.name}: ${activation.iaIntegrated ? '✓' : '✗'}`, - ) - env.showMessage(` IA has minter role: ${activation.iaMinter ? '✓' : '✗'}\n`) - process.exit(1) - } - - env.showMessage(`\n✅ ${Contracts.issuance.IssuanceAllocator.name} fully deployed, configured, and activated\n`) -} - -func.tags = Tags.issuanceAllocation -func.dependencies = [ComponentTags.REWARDS_MANAGER, ComponentTags.ISSUANCE_ALLOCATOR, ComponentTags.ISSUANCE_ACTIVATION] - -export default func diff --git a/packages/deployment/deploy/allocate/allocator/09_end.ts b/packages/deployment/deploy/allocate/allocator/09_end.ts new file mode 100644 index 000000000..272c2915e --- /dev/null +++ b/packages/deployment/deploy/allocate/allocator/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.IssuanceAllocator) diff --git a/packages/deployment/deploy/allocate/allocator/10_status.ts b/packages/deployment/deploy/allocate/allocator/10_status.ts new file mode 100644 index 000000000..23df5d817 --- /dev/null +++ b/packages/deployment/deploy/allocate/allocator/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.issuance.IssuanceAllocator) diff --git a/packages/deployment/deploy/allocate/default/01_deploy.ts b/packages/deployment/deploy/allocate/default/01_deploy.ts new file mode 100644 index 000000000..311c11b1b --- /dev/null +++ b/packages/deployment/deploy/allocate/default/01_deploy.ts @@ -0,0 +1,39 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { deployProxyContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +/** + * Deploy DefaultAllocation proxy — IA's default target for unallocated issuance + * + * Uses the shared DirectAllocation_Implementation. + * Initialized with deployer as governor (transferred in transfer step). + * + * Usage: + * pnpm hardhat deploy --tags DefaultAllocation,deploy --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [ + Contracts.issuance.DirectAllocation_Implementation, + Contracts.issuance.DefaultAllocation, + ]) + + env.showMessage(`\n📦 Deploying DefaultAllocation proxy...`) + env.showMessage(` Shared implementation: ${Contracts.issuance.DirectAllocation_Implementation.name}`) + + await deployProxyContract(env, { + contract: Contracts.issuance.DefaultAllocation, + sharedImplementation: Contracts.issuance.DirectAllocation_Implementation, + initializeArgs: [requireDeployer(env)], + }) + + env.showMessage('\n✓ DefaultAllocation deployment complete') +} + +func.tags = [ComponentTags.DEFAULT_ALLOCATION] +func.dependencies = [ComponentTags.DIRECT_ALLOCATION_IMPL] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) + +export default func diff --git a/packages/deployment/deploy/allocate/default/02_upgrade.ts b/packages/deployment/deploy/allocate/default/02_upgrade.ts new file mode 100644 index 000000000..2bb15a1da --- /dev/null +++ b/packages/deployment/deploy/allocate/default/02_upgrade.ts @@ -0,0 +1,27 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +// DefaultAllocation Upgrade +// +// Upgrades DefaultAllocation proxy to DirectAllocation implementation via per-proxy ProxyAdmin. + +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.UPGRADE)) return + await syncComponentsFromRegistry(env, [ + Contracts.issuance.DirectAllocation_Implementation, + Contracts.issuance.DefaultAllocation, + ]) + await upgradeImplementation(env, Contracts.issuance.DefaultAllocation, { + implementationName: 'DirectAllocation', + }) + await syncComponentsFromRegistry(env, [Contracts.issuance.DefaultAllocation]) +} + +func.tags = [ComponentTags.DEFAULT_ALLOCATION] +func.dependencies = [ComponentTags.DIRECT_ALLOCATION_IMPL] +func.skip = async () => shouldSkipAction(DeploymentActions.UPGRADE) + +export default func diff --git a/packages/deployment/deploy/allocate/default/04_configure.ts b/packages/deployment/deploy/allocate/default/04_configure.ts new file mode 100644 index 000000000..528531ff6 --- /dev/null +++ b/packages/deployment/deploy/allocate/default/04_configure.ts @@ -0,0 +1,119 @@ +import { ACCESS_CONTROL_ENUMERABLE_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkDefaultAllocationConfigured } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, read, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * Configure DefaultAllocation + * + * - Grants GOVERNOR_ROLE to protocol governor + * - Grants PAUSE_ROLE to pause guardian + * + * Note: IA.setDefaultTarget(DA) is an activation step in issuance-connect, + * not a configure step (requires IA to have minter role). + * + * Idempotent: checks on-chain state, skips if already configured. + * + * Usage: + * pnpm hardhat deploy --tags DefaultAllocation,configure --network + */ +export default createActionModule(Contracts.issuance.DefaultAllocation, DeploymentActions.CONFIGURE, async (env) => { + const client = graph.getPublicClient(env) as PublicClient + const readFn = read(env) + const deployer = requireDeployer(env) + const governor = await getGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + + const defaultAllocation = requireContract(env, Contracts.issuance.DefaultAllocation) + + env.showMessage(`\n========== Configure ${Contracts.issuance.DefaultAllocation.name} ==========`) + env.showMessage(`DefaultAllocation: ${defaultAllocation.address}`) + + // Check if already configured (shared precondition check) + const precondition = await checkDefaultAllocationConfigured( + client, + defaultAllocation.address, + governor, + pauseGuardian, + ) + if (precondition.done) { + env.showMessage(`\n✅ ${Contracts.issuance.DefaultAllocation.name} already configured\n`) + return + } + + env.showMessage('\n📋 Checking current configuration...\n') + + const GOVERNOR_ROLE = (await readFn(defaultAllocation, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + const PAUSE_ROLE = (await readFn(defaultAllocation, { functionName: 'PAUSE_ROLE' })) as `0x${string}` + + const governorHasRole = (await client.readContract({ + address: defaultAllocation.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + })) as boolean + env.showMessage(` Governor GOVERNOR_ROLE: ${governorHasRole ? '✓' : '✗'}`) + + const pauseGuardianHasRole = (await client.readContract({ + address: defaultAllocation.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + })) as boolean + env.showMessage(` PauseGuardian PAUSE_ROLE: ${pauseGuardianHasRole ? '✓' : '✗'}`) + + const deployerHasRole = (await client.readContract({ + address: defaultAllocation.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, deployer as `0x${string}`], + })) as boolean + + const txs: Array<{ to: string; data: `0x${string}`; label: string }> = [] + + if (!governorHasRole) { + txs.push({ + to: defaultAllocation.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + }), + label: `grantRole(GOVERNOR_ROLE, ${governor})`, + }) + } + + if (!pauseGuardianHasRole) { + txs.push({ + to: defaultAllocation.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + }), + label: `grantRole(PAUSE_ROLE, ${pauseGuardian})`, + }) + } + + if (!deployerHasRole) { + env.showMessage(`\n ○ Deployer does not have GOVERNOR_ROLE — skipping (governance TX in upgrade step)\n`) + return + } + + if (txs.length === 0) return + + env.showMessage('\n🔨 Executing role grants as deployer...\n') + const txFn = tx(env) + for (const t of txs) { + await txFn({ account: deployer, to: t.to as `0x${string}`, data: t.data }) + env.showMessage(` ✓ ${t.label}`) + } + + env.showMessage(`\n✅ ${Contracts.issuance.DefaultAllocation.name} configuration complete!\n`) +}) diff --git a/packages/deployment/deploy/allocate/default/05_transfer_governance.ts b/packages/deployment/deploy/allocate/default/05_transfer_governance.ts new file mode 100644 index 000000000..af5bcd8e6 --- /dev/null +++ b/packages/deployment/deploy/allocate/default/05_transfer_governance.ts @@ -0,0 +1,51 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContract, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkDeployerRevoked } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { execute, graph, read } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer DefaultAllocation governance from deployer + * + * - Revoke GOVERNOR_ROLE from deployment account + * - Transfer ProxyAdmin ownership to governor + * + * Role grants happen in 04_configure.ts. + * + * Usage: + * pnpm hardhat deploy --tags DefaultAllocation,transfer --network + */ +export default createActionModule(Contracts.issuance.DefaultAllocation, DeploymentActions.TRANSFER, async (env) => { + const readFn = read(env) + const executeFn = execute(env) + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + const da = requireContract(env, Contracts.issuance.DefaultAllocation) + + env.showMessage(`\n========== Transfer ${Contracts.issuance.DefaultAllocation.name} ==========`) + + const precondition = await checkDeployerRevoked(client, da.address, deployer) + if (precondition.done) { + env.showMessage(`✓ Deployer GOVERNOR_ROLE already revoked`) + } else { + const GOVERNOR_ROLE = (await readFn(da, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + + env.showMessage(`🔨 Revoking deployer GOVERNOR_ROLE...`) + await executeFn(da, { + account: deployer, + functionName: 'revokeRole', + args: [GOVERNOR_ROLE, deployer], + }) + env.showMessage(` ✓ revokeRole(GOVERNOR_ROLE) executed`) + } + + await transferProxyAdminOwnership(env, Contracts.issuance.DefaultAllocation) + + env.showMessage(`\n✅ ${Contracts.issuance.DefaultAllocation.name} governance transferred!\n`) +}) diff --git a/packages/deployment/deploy/allocate/default/09_end.ts b/packages/deployment/deploy/allocate/default/09_end.ts new file mode 100644 index 000000000..cacd93b61 --- /dev/null +++ b/packages/deployment/deploy/allocate/default/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.DefaultAllocation) diff --git a/packages/deployment/deploy/allocate/default/10_status.ts b/packages/deployment/deploy/allocate/default/10_status.ts new file mode 100644 index 000000000..012cc8be3 --- /dev/null +++ b/packages/deployment/deploy/allocate/default/10_status.ts @@ -0,0 +1,10 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +/** + * DefaultAllocation status — show detailed state of the default allocation proxy + * + * Usage: + * pnpm hardhat deploy --tags DefaultAllocation --network + */ +export default createStatusModule(Contracts.issuance.DefaultAllocation) diff --git a/packages/deployment/deploy/allocate/direct/01_impl.ts b/packages/deployment/deploy/allocate/direct/01_impl.ts index 413fff317..ca465ae66 100644 --- a/packages/deployment/deploy/allocate/direct/01_impl.ts +++ b/packages/deployment/deploy/allocate/direct/01_impl.ts @@ -1,82 +1,78 @@ -import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' -import { loadDirectAllocationArtifact } from '@graphprotocol/deployment/lib/artifact-loaders.js' +import { getLibraryResolver, loadDirectAllocationArtifact } from '@graphprotocol/deployment/lib/artifact-loaders.js' +import { computeBytecodeHash } from '@graphprotocol/deployment/lib/bytecode-utils.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' import { requireDeployer, requireGraphToken, showDeploymentStatus, } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' import { deploy, graph } from '@graphprotocol/deployment/rocketh/deploy.js' import type { DeployScriptModule } from '@rocketh/core/types' /** * Deploy shared DirectAllocation implementation * - * This implementation is shared by all DirectAllocation proxies: - * - PilotAllocation - * - ReclaimAddress_Treasury - * - (other ReclaimAddress_* instances) + * This implementation is shared by all DirectAllocation proxies + * (DefaultAllocation, ReclaimedRewards). Runs during both deploy AND upgrade + * actions — deploying the implementation is a prerequisite for proxy upgrades. * - * Deploying once and sharing reduces gas costs and ensures all instances - * are on the same version. + * Rocketh handles idempotency: if bytecode is unchanged, no redeployment occurs. * * Usage: - * pnpm hardhat deploy --tags direct-allocation-impl --network + * pnpm hardhat deploy --tags DirectAllocation_Implementation,deploy --network */ - const func: DeployScriptModule = async (env) => { - const deployFn = deploy(env) + // Run for both deploy and upgrade actions + if (shouldSkipAction(DeploymentActions.DEPLOY) && shouldSkipAction(DeploymentActions.UPGRADE)) return - const deployer = requireDeployer(env) + await syncComponentsFromRegistry(env, [ + Contracts.issuance.DirectAllocation_Implementation, + Contracts.horizon.L2GraphToken, + ]) - // Require L2GraphToken from deployments JSON (Graph Token on L2) + const deployFn = deploy(env) + const deployer = requireDeployer(env) const graphTokenDep = requireGraphToken(env) env.showMessage(`\n📦 Deploying shared ${Contracts.issuance.DirectAllocation_Implementation.name}...`) const artifact = loadDirectAllocationArtifact() - const result = await deployFn( - Contracts.issuance.DirectAllocation_Implementation.name, - { - account: deployer, - artifact, - args: [graphTokenDep.address], - }, - { - skipIfAlreadyDeployed: true, - }, - ) + const result = await deployFn(Contracts.issuance.DirectAllocation_Implementation.name, { + account: deployer, + artifact, + args: [graphTokenDep.address], + }) - showDeploymentStatus(env, Contracts.issuance.DirectAllocation_Implementation, result) - - // Set pendingImplementation for all proxies that use DirectAllocation - // This allows the upgrade scripts to read from address book instead of deployment records - const targetChainId = await getTargetChainIdFromEnv(env) - const addressBook = graph.getIssuanceAddressBook(targetChainId) + // Persist to address book — only write metadata on new deployments + // to avoid overwriting stored hash with current artifact when deploy was a no-op + if (result.newlyDeployed) { + const resolver = getLibraryResolver('issuance') + const bytecodeHash = computeBytecodeHash( + artifact.deployedBytecode ?? '0x', + artifact.deployedLinkReferences, + resolver, + ) - const proxiesToUpdate = [Contracts.issuance.PilotAllocation.name] - for (const proxyName of proxiesToUpdate) { - try { - const entry = addressBook.getEntry(proxyName as Parameters[0]) - if (entry) { - addressBook.setPendingImplementation( - proxyName as Parameters[0], - result.address, - { - txHash: result.transaction?.hash, - }, - ) - env.showMessage(` ✓ Set pendingImplementation for ${proxyName}`) - } - } catch { - // Entry doesn't exist yet - will be created by deploy script - env.showMessage(` - ${proxyName} not in address book yet, skipping`) - } + await graph.updateIssuanceAddressBook(env, { + name: Contracts.issuance.DirectAllocation_Implementation.name, + address: result.address, + deployment: { + txHash: result.transaction?.hash ?? '', + argsData: result.argsData, + bytecodeHash, + }, + }) } + + showDeploymentStatus(env, Contracts.issuance.DirectAllocation_Implementation, result) + + await syncComponentsFromRegistry(env, [Contracts.issuance.DirectAllocation_Implementation]) } -func.tags = Tags.directAllocationImpl -func.dependencies = [SpecialTags.SYNC] +func.tags = [ComponentTags.DIRECT_ALLOCATION_IMPL] +func.dependencies = [] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) && shouldSkipAction(DeploymentActions.UPGRADE) export default func diff --git a/packages/deployment/deploy/allocate/pilot/01_deploy.ts b/packages/deployment/deploy/allocate/pilot/01_deploy.ts deleted file mode 100644 index b59104f8e..000000000 --- a/packages/deployment/deploy/allocate/pilot/01_deploy.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { - actionTag, - ComponentTags, - DeploymentActions, - SpecialTags, - Tags, -} from '@graphprotocol/deployment/lib/deployment-tags.js' -import { deployProxyContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Deploy PilotAllocation proxy using shared DirectAllocation implementation - * - * This deploys PilotAllocation as an OZ v5 TransparentUpgradeableProxy pointing to - * the shared DirectAllocation_Implementation. All DirectAllocation proxies - * share one implementation for efficiency. - * - * Architecture: - * - Implementation: Shared DirectAllocation_Implementation - * - Proxy: OZ v5 TransparentUpgradeableProxy with atomic initialization - * - Admin: Per-proxy ProxyAdmin (created by OZ v5 proxy, owned by governor) - * - * Usage: - * pnpm hardhat deploy --tags pilot-allocation-deploy --network - */ - -const func: DeployScriptModule = async (env) => { - env.showMessage(`\n📦 Deploying ${Contracts.issuance.PilotAllocation.name}...`) - - await deployProxyContract(env, { - contract: Contracts.issuance.PilotAllocation, - sharedImplementation: Contracts.issuance.DirectAllocation_Implementation, - // initializeArgs defaults to [governor] - }) -} - -func.tags = Tags.pilotAllocationDeploy -func.dependencies = [ - SpecialTags.SYNC, - ComponentTags.DIRECT_ALLOCATION_IMPL, - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.DEPLOY), -] - -export default func diff --git a/packages/deployment/deploy/allocate/pilot/02_upgrade.ts b/packages/deployment/deploy/allocate/pilot/02_upgrade.ts deleted file mode 100644 index 37e3aa593..000000000 --- a/packages/deployment/deploy/allocate/pilot/02_upgrade.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -// PilotAllocation Upgrade -// -// Upgrades PilotAllocation proxy to DirectAllocation implementation via per-proxy ProxyAdmin. -// The implementation is shared across multiple allocation proxies. -// -// Workflow: -// 1. Check for pending implementation in address book (set by direct-allocation-impl) -// 2. Generate governance TX (upgradeAndCall to per-proxy ProxyAdmin) -// 3. Fork mode: execute via governor impersonation -// 4. Production: output TX file for Safe execution -// -// Usage: -// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags pilot-allocation-upgrade --network localhost - -const func: DeployScriptModule = async (env) => { - await upgradeImplementation(env, Contracts.issuance.PilotAllocation, { - implementationName: 'DirectAllocation', - }) -} - -func.tags = Tags.pilotAllocationUpgrade -func.dependencies = [ - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.DEPLOY), - ComponentTags.DIRECT_ALLOCATION_IMPL, -] - -export default func diff --git a/packages/deployment/deploy/allocate/pilot/04_configure.ts b/packages/deployment/deploy/allocate/pilot/04_configure.ts deleted file mode 100644 index 780ca72da..000000000 --- a/packages/deployment/deploy/allocate/pilot/04_configure.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { execute, read } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Configure PilotAllocation as IssuanceAllocator target - * - * Sets up PilotAllocation to receive tokens via allocator-minting from IssuanceAllocator. - * This requires IssuanceAllocator to be configured (deployer has GOVERNOR_ROLE or governance). - * - * Idempotent: checks if already configured, skips if so. - * - * Usage: - * pnpm hardhat deploy --tags pilot-allocation-configure --network - */ -const func: DeployScriptModule = async (env) => { - const readFn = read(env) - const executeFn = execute(env) - - // Get protocol governor from Controller - const governor = await getGovernor(env) - - const [pilotAllocation, issuanceAllocator] = requireContracts(env, [ - Contracts.issuance.PilotAllocation, - Contracts.issuance.IssuanceAllocator, - ]) - - env.showMessage(`\n========== Configure ${Contracts.issuance.PilotAllocation.name} ==========`) - env.showMessage(`${Contracts.issuance.PilotAllocation.name}: ${pilotAllocation.address}`) - env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${issuanceAllocator.address}`) - - // Check current allocation - try { - const allocation = (await readFn(issuanceAllocator, { - functionName: 'getTargetAllocation', - args: [pilotAllocation.address], - })) as [bigint, bigint, bigint] - - if (allocation[1] > 0n || allocation[2] > 0n) { - env.showMessage(`\n✓ ${Contracts.issuance.PilotAllocation.name} already configured as target`) - env.showMessage(` allocatorMintingRate: ${allocation[1]}`) - env.showMessage(` selfMintingRate: ${allocation[2]}`) - return - } - } catch { - // Not configured yet - } - - // Get current issuance rate to determine allocation - const issuancePerBlock = (await readFn(issuanceAllocator, { functionName: 'getIssuancePerBlock' })) as bigint - if (issuancePerBlock === 0n) { - env.showMessage( - `\n⚠️ ${Contracts.issuance.IssuanceAllocator.name} rate is 0, cannot configure ${Contracts.issuance.PilotAllocation.name} allocation`, - ) - env.showMessage(` Configure ${Contracts.issuance.IssuanceAllocator.name} first with setIssuancePerBlock()`) - return - } - - // Configure PilotAllocation with allocator-minting (IA mints to it) - // Default: small allocation for pilot testing - const pilotRate = issuancePerBlock / 100n // 1% of total issuance - - env.showMessage(`\n🔨 Configuring ${Contracts.issuance.PilotAllocation.name}...`) - env.showMessage(` Setting allocatorMintingRate: ${pilotRate} (1% of ${issuancePerBlock})`) - - try { - await executeFn(issuanceAllocator, { - account: governor, - functionName: 'setTargetAllocation', - args: [pilotAllocation.address, pilotRate, 0n], // allocatorMintingRate, selfMintingRate (PA doesn't self-mint) - }) - env.showMessage( - `\n✅ ${Contracts.issuance.PilotAllocation.name} configured as ${Contracts.issuance.IssuanceAllocator.name} target`, - ) - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - env.showMessage(`\n⚠️ Configuration failed: ${errorMessage.slice(0, 100)}...`) - env.showMessage(` This may require governance execution if deployer no longer has GOVERNOR_ROLE`) - } -} - -func.tags = Tags.pilotAllocationConfigure -func.dependencies = [ - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.UPGRADE), - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.CONFIGURE), -] - -export default func diff --git a/packages/deployment/deploy/allocate/pilot/09_end.ts b/packages/deployment/deploy/allocate/pilot/09_end.ts deleted file mode 100644 index 750e34f17..000000000 --- a/packages/deployment/deploy/allocate/pilot/09_end.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * PilotAllocation end state - deployed, upgraded, and configured - * - * Aggregate tag that ensures PilotAllocation is fully ready: - * - Proxy and implementation deployed - * - Proxy upgraded to latest implementation - * - Configured as IssuanceAllocator target - * - * Usage: - * pnpm hardhat deploy --tags pilot-allocation --network - */ -const func: DeployScriptModule = async (env) => { - requireUpgradeExecuted(env, 'PilotAllocation') - env.showMessage(`\n✓ PilotAllocation ready`) -} - -func.tags = Tags.pilotAllocation -func.dependencies = [ - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.DEPLOY), - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.UPGRADE), - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.CONFIGURE), -] - -export default func diff --git a/packages/deployment/deploy/common/00_sync.ts b/packages/deployment/deploy/common/00_sync.ts index 25be17d3e..de4ff446f 100644 --- a/packages/deployment/deploy/common/00_sync.ts +++ b/packages/deployment/deploy/common/00_sync.ts @@ -1,131 +1,25 @@ -import { existsSync } from 'node:fs' - -import { - getForkNetwork, - getForkStateDir, - getIssuanceAddressBookPath, -} from '@graphprotocol/deployment/lib/address-book-utils.js' -import { - type AddressBookType, - getContractMetadata, - getContractsByAddressBook, -} from '@graphprotocol/deployment/lib/contract-registry.js' import { SpecialTags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { - type AddressBookGroup, - buildContractSpec, - type ContractSpec, - syncContractGroups, -} from '@graphprotocol/deployment/lib/sync-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import { runFullSync } from '@graphprotocol/deployment/lib/sync-utils.js' import type { DeployScriptModule } from '@rocketh/core/types' -// Sync - Synchronization between on-chain state and address books +// Sync — full reconciliation between on-chain state and address books. // -// For each address book (Horizon, SubgraphService, Issuance): -// - Sync proxy implementations with on-chain state +// For every deployable contract in every address book (Horizon, SubgraphService, +// Issuance): +// - Reconcile proxy implementations with on-chain state // - Import contract addresses into rocketh deployment records // - Validate prerequisites exist on-chain - -// Helper to filter deployable contracts from registry -function getDeployableContracts(addressBook: AddressBookType) { - return getContractsByAddressBook(addressBook) - .filter(([_, metadata]) => metadata.deployable !== false) - .map(([name]) => name) -} +// +// This script is the only one tagged with `SpecialTags.SYNC`. It runs when: +// - The user invokes `npx hardhat deploy --tags sync` directly +// - The `deploy:sync` Hardhat task is run (which delegates to the above) +// +// Per-component actions sync the contracts they touch immediately before and +// after their work, so this full sync is no longer required as an automatic +// dependency on every deployment script. const func: DeployScriptModule = async (env) => { - // Get chainId from provider (will be 31337 in fork mode) - const chainIdHex = await env.network.provider.request({ method: 'eth_chainId' }) - const providerChainId = Number(chainIdHex) - - // Determine target chain ID for address book lookups - const forkNetwork = getForkNetwork() - const isForking = graph.isForkMode() - const forkChainId = graph.getForkTargetChainId() - const targetChainId = forkChainId ?? providerChainId - - // Check for common misconfiguration: localhost without FORK_NETWORK - if (providerChainId === 31337 && !forkNetwork) { - throw new Error( - `Running on localhost (chainId 31337) without FORK_NETWORK set.\n\n` + - `If you're testing against a forked network, set the environment variable:\n` + - ` export FORK_NETWORK=arbitrumSepolia\n` + - ` npx hardhat deploy --tags sync --network localhost\n\n` + - `Or use ephemeral fork mode:\n` + - ` HARDHAT_FORK=arbitrumSepolia npx hardhat deploy --tags sync`, - ) - } - - if (forkNetwork) { - const forkStateDir = getForkStateDir(env.name, forkNetwork) - env.showMessage(`\n🔄 Sync: ${forkNetwork} fork (chainId: ${targetChainId})`) - env.showMessage(` Using fork-local address books (${forkStateDir}/)`) - } else { - env.showMessage(`\n🔄 Sync: ${env.name} (chainId: ${providerChainId})`) - } - - // Get address books (automatically uses fork-local copies in fork mode) - const horizonAddressBook = graph.getHorizonAddressBook(targetChainId) - const ssAddressBook = graph.getSubgraphServiceAddressBook(targetChainId) - - // Build contract groups - const groups: AddressBookGroup[] = [] - - // --- Horizon contracts --- - const horizonContracts: ContractSpec[] = getDeployableContracts('horizon').map((name) => { - const metadata = getContractMetadata('horizon', name) - if (!metadata) throw new Error(`Contract ${name} not found in horizon registry`) - return buildContractSpec('horizon', name, metadata, horizonAddressBook, targetChainId) - }) - groups.push({ label: 'Horizon', contracts: horizonContracts, addressBook: horizonAddressBook }) - - // --- SubgraphService contracts --- - const ssContracts: ContractSpec[] = getDeployableContracts('subgraph-service').map((name) => { - const metadata = getContractMetadata('subgraph-service', name) - if (!metadata) throw new Error(`Contract ${name} not found in subgraph-service registry`) - return buildContractSpec('subgraph-service', name, metadata, ssAddressBook, targetChainId) - }) - groups.push({ label: 'SubgraphService', contracts: ssContracts, addressBook: ssAddressBook }) - - // --- Issuance contracts --- - // Show all issuance contracts from registry (even if not deployed yet) - const issuanceBookPath = getIssuanceAddressBookPath() - const issuanceAddressBook = existsSync(issuanceBookPath) ? graph.getIssuanceAddressBook(targetChainId) : null - - if (issuanceAddressBook) { - // Show all deployable issuance contracts from registry (even if not deployed yet) - const issuanceContracts: ContractSpec[] = getDeployableContracts('issuance').map((name) => { - const metadata = getContractMetadata('issuance', name) - if (!metadata) throw new Error(`Contract ${name} not found in issuance registry`) - return buildContractSpec('issuance', name, metadata, issuanceAddressBook, targetChainId) - }) - - if (issuanceContracts.length > 0) { - groups.push({ label: 'Issuance', contracts: issuanceContracts, addressBook: issuanceAddressBook }) - } - } - - // Sync all contract groups - const result = await syncContractGroups(env, groups) - - if (!result.success) { - env.showMessage(`\n❌ Sync failed: address book does not match chain state.\n`) - env.showMessage(`The following contracts are in address book but have no code on-chain:`) - env.showMessage(` ${result.failures.join(', ')}\n`) - if (isForking) { - env.showMessage(`This is likely because the fork was restarted.\n`) - env.showMessage(`To fix, reset fork state and re-run:`) - env.showMessage(` npx hardhat deploy:reset-fork --network localhost`) - } else { - env.showMessage(`Possible causes:`) - env.showMessage(` 1. Address book has incorrect addresses for this network`) - env.showMessage(` 2. Running against wrong network`) - } - process.exit(1) - } - - env.showMessage(`\n✅ Sync complete: ${result.totalSynced} contracts synced\n`) + await runFullSync(env) } func.tags = [SpecialTags.SYNC] diff --git a/packages/deployment/deploy/gip/0088/09_end.ts b/packages/deployment/deploy/gip/0088/09_end.ts new file mode 100644 index 000000000..85addeb08 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/09_end.ts @@ -0,0 +1,97 @@ +import { PROVIDER_ELIGIBILITY_MANAGEMENT_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { + addressEquals, + checkIssuanceAllocatorActivation, + isRewardsManagerUpgraded, +} from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions, GoalTags, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule } from '@rocketh/core/types' +import type { PublicClient } from 'viem' + +/** + * GIP-0088,all — Full GIP-0088 deployment verification + * + * Verifies all non-optional phases are complete: + * - Upgrade: RM upgraded (supports IIssuanceTarget) + * - Eligibility: REO integrated with RM + * - Issuance: IA connected to RM, minter role granted + * + * Does NOT verify optional goals (eligibility-revert, issuance-close-guard). + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088,all --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.ALL)) return + await syncComponentsFromRegistry(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.horizon.RewardsManager, + Contracts.horizon.L2GraphToken, + Contracts.issuance.RewardsEligibilityOracleA, + ]) + const [issuanceAllocator, rewardsManager, graphToken] = requireContracts(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.horizon.RewardsManager, + Contracts.horizon.L2GraphToken, + ]) + + const client = graph.getPublicClient(env) as PublicClient + const failures: string[] = [] + + // Verify RM has been upgraded (supports IERC165) + const upgraded = await isRewardsManagerUpgraded(client, rewardsManager.address) + if (!upgraded) { + env.showMessage(`\n❌ ${Contracts.horizon.RewardsManager.name} not upgraded - run GIP-0088:upgrade,upgrade first\n`) + process.exit(1) + } + + // Verify IA activation state (issuance phase) + const activation = await checkIssuanceAllocatorActivation( + client, + issuanceAllocator.address, + rewardsManager.address, + graphToken.address, + ) + + if (!activation.iaIntegrated) failures.push('IA not integrated with RM') + if (!activation.iaMinter) failures.push('IA missing minter role') + + // Verify REO integration (eligibility phase) + const reo = env.getOrNull(Contracts.issuance.RewardsEligibilityOracleA.name) + if (reo) { + const currentOracle = (await client.readContract({ + address: rewardsManager.address as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + if (!addressEquals(currentOracle, reo.address)) { + failures.push('REO not integrated with RM') + } + } else { + failures.push('RewardsEligibilityOracleA not deployed') + } + + if (failures.length > 0) { + env.showMessage(`\n❌ GIP-0088 incomplete:`) + for (const f of failures) env.showMessage(` - ${f}`) + env.showMessage('') + process.exit(1) + } + + env.showMessage(`\n✅ GIP-0088 complete: all contracts deployed, upgraded, and configured\n`) +} + +func.tags = [GoalTags.GIP_0088] +func.dependencies = [ + GoalTags.GIP_0088_UPGRADE, + GoalTags.GIP_0088_ELIGIBILITY_INTEGRATE, + GoalTags.GIP_0088_ISSUANCE_CONNECT, + GoalTags.GIP_0088_ISSUANCE_ALLOCATE, +] +func.skip = async () => shouldSkipAction(DeploymentActions.ALL) + +export default func diff --git a/packages/deployment/deploy/gip/0088/10_status.ts b/packages/deployment/deploy/gip/0088/10_status.ts new file mode 100644 index 000000000..8810b054d --- /dev/null +++ b/packages/deployment/deploy/gip/0088/10_status.ts @@ -0,0 +1,208 @@ +import { + IISSUANCE_TARGET_INTERFACE_ID, + IREWARDS_MANAGER_INTERFACE_ID, + ISSUANCE_TARGET_ABI, + PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + REWARDS_MANAGER_ABI, + SUBGRAPH_SERVICE_CLOSE_GUARD_ABI, +} from '@graphprotocol/deployment/lib/abis.js' +import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' +import { + addressEquals, + isRewardsManagerUpgraded, + supportsInterface, +} from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts, type RegistryEntry } from '@graphprotocol/deployment/lib/contract-registry.js' +import { GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { showDetailedComponentStatus, showPendingGovernanceTxs } from '@graphprotocol/deployment/lib/status-detail.js' +import { getContractStatusLine, syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * GIP-0088 Status — Phase-structured deployment state display + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088 --network + */ +export default createStatusModule(GoalTags.GIP_0088, async (env) => { + // Sync the contracts this status touches via env.getOrNull so the read paths + // work without depending on a separate global sync run. + await syncComponentsFromRegistry(env, [ + Contracts.horizon.RewardsManager, + Contracts.horizon.L2GraphToken, + Contracts['subgraph-service'].SubgraphService, + Contracts.issuance.IssuanceAllocator, + Contracts.issuance.RewardsEligibilityOracleA, + Contracts.issuance.RecurringAgreementManager, + ]) + + const client = graph.getPublicClient(env) as PublicClient + const targetChainId = await getTargetChainIdFromEnv(env) + + env.showMessage('\n========== GIP-0088: Full Deployment Status ==========') + + // --- Upgrade phase --- + env.showMessage('\nUpgrade:') + + const upgradeContracts: RegistryEntry[] = [ + Contracts.horizon.RewardsManager, + Contracts.horizon.HorizonStaking, + Contracts['subgraph-service'].SubgraphService, + Contracts['subgraph-service'].DisputeManager, + Contracts.horizon.PaymentsEscrow, + Contracts.horizon.L2Curation, + Contracts.horizon.RecurringCollector, + ] + + const rm = env.getOrNull('RewardsManager') + + for (const contract of upgradeContracts) { + const ab = + contract.addressBook === 'subgraph-service' + ? graph.getSubgraphServiceAddressBook(targetChainId) + : graph.getHorizonAddressBook(targetChainId) + + const result = await getContractStatusLine(client, contract.addressBook, ab, contract.name) + env.showMessage(` ${result.line}`) + + // RM: semantic check — does the on-chain code support IIssuanceTarget? + if (contract === Contracts.horizon.RewardsManager && result.exists && rm) { + const upgraded = await isRewardsManagerUpgraded(client, rm.address) + env.showMessage(` ${upgraded ? '✓' : '✗'} implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})`) + } + } + + // --- Eligibility phase --- + env.showMessage('\nEligibility:') + await showDetailedComponentStatus(env, Contracts.issuance.RewardsEligibilityOracleA, { showHints: false }) + + // --- Issuance phase --- + env.showMessage('\nIssuance:') + await showDetailedComponentStatus(env, Contracts.issuance.IssuanceAllocator, { showHints: false }) + + const ram = env.getOrNull('RecurringAgreementManager') + if (ram) { + await showDetailedComponentStatus(env, Contracts.issuance.RecurringAgreementManager, { showHints: false }) + } else { + env.showMessage(` ○ RecurringAgreementManager not deployed`) + } + + // --- Activation status --- + env.showMessage('\n--- Activation ---') + + // eligibility-integrate: RM.providerEligibilityOracle == REO_A + if (rm) { + const upgraded = await isRewardsManagerUpgraded(client, rm.address) + if (upgraded) { + const reo = env.getOrNull(Contracts.issuance.RewardsEligibilityOracleA.name) + const currentOracle = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + + if (reo) { + const integrated = addressEquals(currentOracle, reo.address) + env.showMessage(` ${integrated ? '✓' : '✗'} eligibility-integrate: RM.providerEligibilityOracle == REO_A`) + } else { + env.showMessage(` ○ eligibility-integrate: REO_A not deployed`) + } + + // issuance-connect: RM.issuanceAllocator == IA + minter role + const ia = env.getOrNull('IssuanceAllocator') + if (ia) { + const currentIA = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + const iaConnected = addressEquals(currentIA, ia.address) + + const gt = env.getOrNull('L2GraphToken') + let isMinter = false + if (gt) { + const { GRAPH_TOKEN_ABI } = await import('@graphprotocol/deployment/lib/abis.js') + isMinter = (await client.readContract({ + address: gt.address as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'isMinter', + args: [ia.address as `0x${string}`], + })) as boolean + } + + env.showMessage( + ` ${iaConnected && isMinter ? '✓' : '✗'} issuance-connect: RM ↔ IA${!iaConnected ? ' (not connected)' : ''}${!isMinter ? ' (no minter role)' : ''}`, + ) + } else { + env.showMessage(` ○ issuance-connect: IA not deployed`) + } + + // issuance-allocate: IA.getTargetAllocation(RAM) configured + if (ram) { + env.showMessage(` ○ issuance-allocate: check via --tags ${GoalTags.GIP_0088_ISSUANCE_ALLOCATE}`) + } else { + env.showMessage(` ○ issuance-allocate: RAM not deployed`) + } + } else { + env.showMessage(' ○ RM not upgraded (activation blocked)') + } + } else { + env.showMessage(' ○ RM not in address book') + } + + // --- Optional status --- + env.showMessage('\n--- Optional (not planned) ---') + + // eligibility-revert + if (rm) { + const supportsLatestRM = await supportsInterface(client, rm.address, IREWARDS_MANAGER_INTERFACE_ID) + if (supportsLatestRM) { + const revertOnIneligible = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getRevertOnIneligible', + })) as boolean + env.showMessage( + ` ${revertOnIneligible ? '✓' : '○'} eligibility-revert: revertOnIneligible = ${revertOnIneligible}`, + ) + } else { + env.showMessage(` ○ eligibility-revert: RM not upgraded`) + } + } else { + env.showMessage(` ○ eligibility-revert: RM not deployed`) + } + + // issuance-close-guard + const ss = env.getOrNull('SubgraphService') + if (ss) { + try { + const closeGuard = (await client.readContract({ + address: ss.address as `0x${string}`, + abi: SUBGRAPH_SERVICE_CLOSE_GUARD_ABI, + functionName: 'getBlockClosingAllocationWithActiveAgreement', + })) as boolean + env.showMessage(` ${closeGuard ? '✓' : '○'} issuance-close-guard: blockClosingAllocation = ${closeGuard}`) + } catch { + env.showMessage(` ○ issuance-close-guard: SS not upgraded`) + } + } else { + env.showMessage(` ○ issuance-close-guard: SS not deployed`) + } + + // --- Actions --- + env.showMessage('\n--- Actions ---') + env.showMessage(' Deploy & upgrade:') + env.showMessage(' --tags GIP-0088:upgrade,') + env.showMessage(' Activation (after upgrades executed):') + env.showMessage(' --tags GIP-0088:eligibility-integrate') + env.showMessage(' --tags GIP-0088:issuance-connect') + env.showMessage(' --tags GIP-0088:issuance-allocate') + env.showMessage(' Optional:') + env.showMessage(' --tags GIP-0088:eligibility-revert') + env.showMessage(' --tags GIP-0088:issuance-close-guard') + + showPendingGovernanceTxs(env) + env.showMessage('') +}) diff --git a/packages/deployment/deploy/gip/0088/eligibility_integrate.ts b/packages/deployment/deploy/gip/0088/eligibility_integrate.ts new file mode 100644 index 000000000..47bd81f7b --- /dev/null +++ b/packages/deployment/deploy/gip/0088/eligibility_integrate.ts @@ -0,0 +1,74 @@ +import { PROVIDER_ELIGIBILITY_MANAGEMENT_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { createRMIntegrationCondition } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' + +/** + * GIP-0088:eligibility-integrate — Set RewardsEligibilityOracle on RewardsManager + * + * Governance TX: RM.setProviderEligibilityOracle(REO_A) + * + * Skips if oracle already set (any value, not just REO_A) to avoid + * accidentally overriding a live oracle configuration. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:eligibility-integrate --network + */ +export default createActionModule( + GoalTags.GIP_0088_ELIGIBILITY_INTEGRATE, + async (env) => { + await syncComponentsFromRegistry(env, [ + Contracts.issuance.RewardsEligibilityOracleA, + Contracts.horizon.RewardsManager, + ]) + const [reo, rm] = requireContracts(env, [ + Contracts.issuance.RewardsEligibilityOracleA, + Contracts.horizon.RewardsManager, + ]) + const client = graph.getPublicClient(env) as PublicClient + + // Check if oracle already set — skip if any oracle configured (don't override) + try { + const currentOracle = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + + if (currentOracle !== ZERO_ADDRESS) { + const isTarget = currentOracle.toLowerCase() === reo.address.toLowerCase() + env.showMessage(`\n ${isTarget ? '✓' : '○'} RM.providerEligibilityOracle already set: ${currentOracle}`) + if (!isTarget) { + env.showMessage(` (not REO_A — skipping to avoid override)`) + } + env.showMessage('') + return + } + } catch { + // Function not available — RM not upgraded, skip + env.showMessage(`\n ○ RM does not support getProviderEligibilityOracle — skipping\n`) + return + } + + const { governor, canSign } = await canSignAsGovernor(env) + + await applyConfiguration(env, client, [createRMIntegrationCondition(reo.address)], { + contractName: `${Contracts.horizon.RewardsManager.name}-REO`, + contractAddress: rm.address, + canExecuteDirectly: canSign, + executor: governor, + }) + }, + { + dependencies: [ComponentTags.REWARDS_MANAGER, ComponentTags.REWARDS_ELIGIBILITY_A], + }, +) diff --git a/packages/deployment/deploy/gip/0088/eligibility_revert.ts b/packages/deployment/deploy/gip/0088/eligibility_revert.ts new file mode 100644 index 000000000..0d99b2e95 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/eligibility_revert.ts @@ -0,0 +1,90 @@ +import { REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, GoalTags, shouldSkipOptionalGoal } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule } from '@rocketh/core/types' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * GIP-0088:eligibility-revert — Enable revert on ineligible indexers + * + * Optional governance TX: RM.setRevertOnIneligible(true) + * + * Not activated by `all` — requires explicit `--tags GIP-0088:eligibility-revert`. + * + * Idempotent: reads on-chain revertOnIneligible, skips if already true. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:eligibility-revert --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipOptionalGoal(GoalTags.GIP_0088_ELIGIBILITY_REVERT)) return + await syncComponentsFromRegistry(env, [Contracts.horizon.RewardsManager]) + + const client = graph.getPublicClient(env) as PublicClient + const rm = requireContract(env, Contracts.horizon.RewardsManager) + + env.showMessage(`\n========== GIP-0088: Eligibility Revert ==========`) + env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rm.address}`) + + // Check current state + env.showMessage('\n📋 Checking current configuration...\n') + + let revertOnIneligible: boolean + try { + revertOnIneligible = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getRevertOnIneligible', + })) as boolean + } catch { + // Function not available — RM not upgraded, skip (matches eligibility_integrate) + env.showMessage( + `\n ○ ${Contracts.horizon.RewardsManager.name} does not support getRevertOnIneligible — skipping\n`, + ) + return + } + env.showMessage(` revertOnIneligible: ${revertOnIneligible ? '✓ true' : '✗ false'}`) + + if (revertOnIneligible) { + env.showMessage(`\n✅ ${Contracts.horizon.RewardsManager.name} already configured\n`) + return + } + + const { governor, canSign } = await canSignAsGovernor(env) + + env.showMessage('\n🔨 Building configuration TX batch...\n') + + const builder = await createGovernanceTxBuilder(env, `gip-0088-eligibility-revert`) + + const data = encodeFunctionData({ + abi: REWARDS_MANAGER_ABI, + functionName: 'setRevertOnIneligible', + args: [true], + }) + builder.addTx({ to: rm.address, value: '0', data }) + env.showMessage(` + setRevertOnIneligible(true)`) + + if (canSign) { + env.showMessage('\n🔨 Executing configuration TX batch...\n') + await executeTxBatchDirect(env, builder, governor) + env.showMessage(`\n✅ GIP-0088: revertOnIneligible enabled\n`) + } else { + saveGovernanceTx(env, builder, `GIP-0088: revertOnIneligible`) + } +} + +func.tags = [GoalTags.GIP_0088_ELIGIBILITY_REVERT] +func.dependencies = [ComponentTags.REWARDS_MANAGER] +func.skip = async () => shouldSkipOptionalGoal(GoalTags.GIP_0088_ELIGIBILITY_REVERT) + +export default func diff --git a/packages/deployment/deploy/gip/0088/issuance_allocate.ts b/packages/deployment/deploy/gip/0088/issuance_allocate.ts new file mode 100644 index 000000000..689146b82 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/issuance_allocate.ts @@ -0,0 +1,194 @@ +import { ACCESS_CONTROL_ENUMERABLE_ABI, SET_TARGET_ALLOCATION_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' +import { ComponentTags, GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { formatGRT } from '@graphprotocol/deployment/lib/format.js' +import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph, read, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData, keccak256, parseUnits, toHex } from 'viem' + +/** + * GIP-0088:issuance-allocate — Allocate issuance to Recurring Agreement Manager + * + * Calls setTargetAllocation(RAM, allocatorMintingRate, selfMintingRate) so IA + * distributes minted GRT to RAM for agreement-based payments. + * + * Rates are read from config/.json5 (committed per-chain config). + * Skips if rate is 0 (not yet decided). + * + * Idempotent: checks on-chain state, skips if already configured. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:issuance-allocate --network + */ +export default createActionModule( + GoalTags.GIP_0088_ISSUANCE_ALLOCATE, + async (env) => { + await syncComponentsFromRegistry(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.issuance.RecurringAgreementManager, + Contracts.horizon.RewardsManager, + ]) + + const client = graph.getPublicClient(env) as PublicClient + const readFn = read(env) + + const iaDep = env.getOrNull(Contracts.issuance.IssuanceAllocator.name) + const ramDep = env.getOrNull(Contracts.issuance.RecurringAgreementManager.name) + if (!iaDep || !ramDep) { + const missing = [!iaDep && 'IssuanceAllocator', !ramDep && 'RecurringAgreementManager'].filter(Boolean) + env.showMessage(`\n ○ Skipping RAM allocation — not deployed: ${missing.join(', ')}\n`) + return + } + const ia = iaDep + const ram = ramDep + + env.showMessage(`\n========== GIP-0088: Issuance Allocate ==========`) + env.showMessage(`IA: ${ia.address}`) + env.showMessage(`RAM: ${ram.address}`) + + // Load config + const config = await loadDeploymentConfig(env) + const iaConfig = config.IssuanceAllocator ?? {} + const allocatorMintingRate = parseUnits(iaConfig.ramAllocatorMintingGrtPerBlock ?? '0', 18) + const selfMintingRate = parseUnits(iaConfig.ramSelfMintingGrtPerBlock ?? '0', 18) + + if (allocatorMintingRate === 0n && selfMintingRate === 0n) { + env.showMessage('\n⚠️ RAM allocation rates not configured (both 0).') + env.showMessage(' Set ramAllocatorMintingGrtPerBlock in config/.json5') + env.showMessage(' Skipping RAM allocation configuration.\n') + return + } + + // Check current state + env.showMessage('\n📋 Checking current configuration...\n') + env.showMessage( + ` Config: allocatorMintingRate=${formatGRT(allocatorMintingRate)}, selfMintingRate=${formatGRT(selfMintingRate)}`, + ) + + let currentRamAlloc = 0n + let currentRamSelf = 0n + let ramAllocated = false + try { + const allocation = (await readFn(ia, { + functionName: 'getTargetAllocation', + args: [ram.address], + })) as { totalAllocationRate: bigint; allocatorMintingRate: bigint; selfMintingRate: bigint } + currentRamAlloc = allocation.allocatorMintingRate + currentRamSelf = allocation.selfMintingRate + ramAllocated = currentRamAlloc === allocatorMintingRate && currentRamSelf === selfMintingRate + env.showMessage( + ` On-chain: allocator=${formatGRT(currentRamAlloc)}, self=${formatGRT(currentRamSelf)} ${ramAllocated ? '✓' : '✗'}`, + ) + } catch { + env.showMessage(` RAM allocation: ✗ (not configured)`) + } + + if (ramAllocated) { + env.showMessage(`\n✅ RAM allocation already matches config\n`) + return + } + + // The allocator enforces a 100% invariant (sum of all targets == issuancePerBlock). + // RewardsManager was given 100% as self-minting in issuance-connect, so we must + // atomically rebalance: take from RM's self-minting and give to RAM, in the same batch. + const [rewardsManager] = requireContracts(env, [Contracts.horizon.RewardsManager]) + const rmAddress = rewardsManager.address as `0x${string}` + const rmAllocation = (await readFn(ia, { + functionName: 'getTargetAllocation', + args: [rmAddress], + })) as { totalAllocationRate: bigint; allocatorMintingRate: bigint; selfMintingRate: bigint } + env.showMessage( + ` RM on-chain: allocator=${formatGRT(rmAllocation.allocatorMintingRate)}, self=${formatGRT(rmAllocation.selfMintingRate)}`, + ) + + const newRamTotal = allocatorMintingRate + selfMintingRate + const currentRamTotal = currentRamAlloc + currentRamSelf + const delta = newRamTotal - currentRamTotal // signed: >0 RAM grows, <0 RAM shrinks + if (delta > 0n && rmAllocation.selfMintingRate < delta) { + env.showMessage( + `\n❌ Insufficient RM self-minting (${formatGRT(rmAllocation.selfMintingRate)}) to fund RAM increase (${formatGRT(delta)})\n`, + ) + process.exit(1) + } + const newRmSelf = rmAllocation.selfMintingRate - delta + + // Determine executor + const deployer = requireDeployer(env) + const GOVERNOR_ROLE = keccak256(toHex('GOVERNOR_ROLE')) + let deployerIsGovernor = false + try { + deployerIsGovernor = (await client.readContract({ + address: ia.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, deployer as `0x${string}`], + })) as boolean + } catch { + // Storage not available (stale fork) — fall through to governor path + } + + const setRamData = encodeFunctionData({ + abi: SET_TARGET_ALLOCATION_ABI, + functionName: 'setTargetAllocation', + args: [ram.address as `0x${string}`, allocatorMintingRate, selfMintingRate], + }) + const setRmData = encodeFunctionData({ + abi: SET_TARGET_ALLOCATION_ABI, + functionName: 'setTargetAllocation', + args: [rmAddress, rmAllocation.allocatorMintingRate, newRmSelf], + }) + const ramLabel = `setTargetAllocation(RAM, ${formatGRT(allocatorMintingRate)}, ${formatGRT(selfMintingRate)})` + const rmLabel = `setTargetAllocation(RM, ${formatGRT(rmAllocation.allocatorMintingRate)}, ${formatGRT(newRmSelf)})` + + // Order matters: free budget first, then consume. + // delta > 0 (RAM grows): reduce RM first so default target absorbs the slack. + // delta < 0 (RAM shrinks): reduce RAM first so default target absorbs the slack. + const txs = + delta > 0n + ? [ + { data: setRmData, label: rmLabel }, + { data: setRamData, label: ramLabel }, + ] + : [ + { data: setRamData, label: ramLabel }, + { data: setRmData, label: rmLabel }, + ] + + if (deployerIsGovernor) { + env.showMessage('\n🔨 Executing as deployer...\n') + const txFn = tx(env) + for (const t of txs) { + await txFn({ account: deployer, to: ia.address, data: t.data }) + env.showMessage(` ✓ ${t.label}`) + } + env.showMessage(`\n✅ GIP-0088: Issuance Allocate — RAM allocation configured!\n`) + } else { + const { governor, canSign } = await canSignAsGovernor(env) + + const builder = await createGovernanceTxBuilder(env, `gip-0088-issuance-allocate`) + for (const t of txs) { + builder.addTx({ to: ia.address, value: '0', data: t.data }) + env.showMessage(` + ${t.label}`) + } + + if (canSign) { + env.showMessage('\n🔨 Executing configuration TX batch...\n') + await executeTxBatchDirect(env, builder, governor) + env.showMessage(`\n✅ GIP-0088: Issuance Allocate — RAM allocation configured!\n`) + } else { + saveGovernanceTx(env, builder, `GIP-0088: issuance-allocate`) + } + } + }, + { dependencies: [GoalTags.GIP_0088_ISSUANCE_CONNECT, ComponentTags.RECURRING_AGREEMENT_MANAGER] }, +) diff --git a/packages/deployment/deploy/gip/0088/issuance_close_guard.ts b/packages/deployment/deploy/gip/0088/issuance_close_guard.ts new file mode 100644 index 000000000..55f33040a --- /dev/null +++ b/packages/deployment/deploy/gip/0088/issuance_close_guard.ts @@ -0,0 +1,81 @@ +import { SUBGRAPH_SERVICE_CLOSE_GUARD_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, GoalTags, shouldSkipOptionalGoal } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule } from '@rocketh/core/types' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * GIP-0088:issuance-close-guard — Prevent closing allocations with active agreements + * + * Optional governance TX: SS.setBlockClosingAllocationWithActiveAgreement(true) + * + * Not activated by `all` — requires explicit `--tags GIP-0088:issuance-close-guard`. + * + * Idempotent: reads on-chain state, skips if already enabled. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:issuance-close-guard --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipOptionalGoal(GoalTags.GIP_0088_ISSUANCE_CLOSE_GUARD)) return + await syncComponentsFromRegistry(env, [Contracts['subgraph-service'].SubgraphService]) + + const client = graph.getPublicClient(env) as PublicClient + const ss = requireContract(env, Contracts['subgraph-service'].SubgraphService) + + env.showMessage(`\n========== GIP-0088: Issuance Close Guard ==========`) + env.showMessage(`${Contracts['subgraph-service'].SubgraphService.name}: ${ss.address}`) + + // Check current state + env.showMessage('\n📋 Checking current configuration...\n') + + const enabled = (await client.readContract({ + address: ss.address as `0x${string}`, + abi: SUBGRAPH_SERVICE_CLOSE_GUARD_ABI, + functionName: 'getBlockClosingAllocationWithActiveAgreement', + })) as boolean + env.showMessage(` blockClosingAllocationWithActiveAgreement: ${enabled ? '✓ true' : '✗ false'}`) + + if (enabled) { + env.showMessage(`\n✅ ${Contracts['subgraph-service'].SubgraphService.name} close guard already enabled\n`) + return + } + + const { governor, canSign } = await canSignAsGovernor(env) + + env.showMessage('\n🔨 Building configuration TX batch...\n') + + const builder = await createGovernanceTxBuilder(env, `gip-0088-issuance-close-guard`) + + const data = encodeFunctionData({ + abi: SUBGRAPH_SERVICE_CLOSE_GUARD_ABI, + functionName: 'setBlockClosingAllocationWithActiveAgreement', + args: [true], + }) + builder.addTx({ to: ss.address, value: '0', data }) + env.showMessage(` + setBlockClosingAllocationWithActiveAgreement(true)`) + + if (canSign) { + env.showMessage('\n🔨 Executing configuration TX batch...\n') + await executeTxBatchDirect(env, builder, governor) + env.showMessage(`\n✅ GIP-0088: allocation close guard enabled\n`) + } else { + saveGovernanceTx(env, builder, `GIP-0088: allocation close guard`) + } +} + +func.tags = [GoalTags.GIP_0088_ISSUANCE_CLOSE_GUARD] +func.dependencies = [ComponentTags.SUBGRAPH_SERVICE] +func.skip = async () => shouldSkipOptionalGoal(GoalTags.GIP_0088_ISSUANCE_CLOSE_GUARD) + +export default func diff --git a/packages/deployment/deploy/gip/0088/issuance_connect.ts b/packages/deployment/deploy/gip/0088/issuance_connect.ts new file mode 100644 index 000000000..30f8c170d --- /dev/null +++ b/packages/deployment/deploy/gip/0088/issuance_connect.ts @@ -0,0 +1,247 @@ +import { + GRAPH_TOKEN_ABI, + ISSUANCE_ALLOCATOR_ABI, + ISSUANCE_TARGET_ABI, + REWARDS_MANAGER_DEPRECATED_ABI, + SET_TARGET_ALLOCATION_ABI, +} from '@graphprotocol/deployment/lib/abis.js' +import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' +import { requireRewardsManagerUpgraded } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { formatGRT } from '@graphprotocol/deployment/lib/format.js' +import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * GIP-0088:issuance-connect — Connect Rewards Manager to Issuance Allocator + * + * - Configure RewardsManager to use IssuanceAllocator + * - Grant minter role to IssuanceAllocator on GraphToken + * + * Idempotent: checks on-chain state, skips if already activated. + * If the provider has access to the governor key, executes directly. + * Otherwise generates governance TX file. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:issuance-connect --network + */ +export default createActionModule( + GoalTags.GIP_0088_ISSUANCE_CONNECT, + async (env) => { + await syncComponentsFromRegistry(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.horizon.RewardsManager, + Contracts.horizon.L2GraphToken, + Contracts.issuance.DefaultAllocation, + ]) + + const deployer = requireDeployer(env) + + // Check if the provider can sign as the protocol governor + const { governor, canSign } = await canSignAsGovernor(env) + + const [issuanceAllocator, rewardsManager, graphToken, defaultAllocation] = requireContracts(env, [ + Contracts.issuance.IssuanceAllocator, + Contracts.horizon.RewardsManager, + Contracts.horizon.L2GraphToken, + Contracts.issuance.DefaultAllocation, + ]) + + const iaAddress = issuanceAllocator.address + const rmAddress = rewardsManager.address + const gtAddress = graphToken.address + const daAddress = defaultAllocation.address + + // Create viem client for direct contract calls + const client = graph.getPublicClient(env) as PublicClient + + // Check if RewardsManager supports IIssuanceTarget (has been upgraded) + // Throws error if not upgraded + await requireRewardsManagerUpgraded(client, rmAddress, env) + + const targetChainId = await getTargetChainIdFromEnv(env) + + env.showMessage(`\n========== GIP-0088: Issuance Connect ==========`) + env.showMessage(`Network: ${env.name} (chainId=${targetChainId})`) + env.showMessage(`Deployer: ${deployer}`) + env.showMessage(`Protocol Governor (from Controller): ${governor}`) + env.showMessage(`${Contracts.issuance.IssuanceAllocator.name}: ${iaAddress}`) + env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rmAddress}`) + env.showMessage(`${Contracts.horizon.L2GraphToken.name}: ${gtAddress}\n`) + + // Check current state + env.showMessage('📋 Checking current activation state...\n') + + const checks = { + iaIntegrated: false, + iaMinter: false, + } + + // Check RM.getIssuanceAllocator() == IA + const currentIA = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + checks.iaIntegrated = currentIA.toLowerCase() === iaAddress.toLowerCase() + env.showMessage(` IA integrated: ${checks.iaIntegrated ? '✓' : '✗'} (current: ${currentIA})`) + + // Check GraphToken.isMinter(IA) + checks.iaMinter = (await client.readContract({ + address: gtAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'isMinter', + args: [iaAddress as `0x${string}`], + })) as boolean + env.showMessage(` IA minter: ${checks.iaMinter ? '✓' : '✗'}`) + + // Check RM allocation on IA + let rmAllocationOk = false + try { + const rmAllocation = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getTargetAllocation', + args: [rmAddress as `0x${string}`], + })) as { totalAllocationRate: bigint; allocatorMintingRate: bigint; selfMintingRate: bigint } + const iaRate = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + rmAllocationOk = + rmAllocation.allocatorMintingRate === 0n && rmAllocation.selfMintingRate === iaRate && iaRate > 0n + env.showMessage( + ` RM allocation: ${rmAllocationOk ? '✓' : '✗'} (self: ${formatGRT(rmAllocation.selfMintingRate)}, allocator: ${formatGRT(rmAllocation.allocatorMintingRate)})`, + ) + } catch { + env.showMessage(` RM allocation: ✗ (not set)`) + } + + // All checks passed? + if (checks.iaIntegrated && checks.iaMinter && rmAllocationOk) { + env.showMessage(`\n✅ RM already connected to IssuanceAllocator\n`) + return + } + + // Migration invariant: IA rate must match RM rate before connection + if (!checks.iaIntegrated) { + const rmRate = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_DEPRECATED_ABI, + functionName: 'issuancePerBlock', + })) as bigint + + const iaRate = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + + if (iaRate !== rmRate) { + env.showMessage( + `\n❌ Migration invariant failed: IA.issuancePerBlock (${formatGRT(iaRate)}) != RM.issuancePerBlock (${formatGRT(rmRate)})`, + ) + env.showMessage(` IA must have the same overall rate as RM before connection.\n`) + process.exit(1) + } + + env.showMessage(` Migration invariant: ✓ IA rate == RM rate (${formatGRT(iaRate)})`) + } + + // Build TX batch — order: + // 1. IA.setTargetAllocation(RM, 0, rate) — register RM in IA first + // 2. RM.setIssuanceAllocator(IA) — flip RM to read from a fully-configured IA + // 3. GraphToken.addMinter(IA) — grant IA the minter role + // 4. IA.setDefaultTarget(DA) — install safety-net default + // Conceptually: configure IA's view of RM before RM starts reading from IA. Atomic + // within the batch either way, but this avoids a transient where RM is wired to an + // IA that has no allocation entry for it. + env.showMessage('\n🔨 Building activation TX batch...\n') + + const builder = await createGovernanceTxBuilder(env, `gip-0088-issuance-connect`) + + // 1. IA.setTargetAllocation(RM, 0, rate) — RM as 100% self-minting target + if (!rmAllocationOk) { + const iaRate = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + const data = encodeFunctionData({ + abi: SET_TARGET_ALLOCATION_ABI, + functionName: 'setTargetAllocation', + args: [rmAddress as `0x${string}`, 0n, iaRate], + }) + builder.addTx({ to: iaAddress, value: '0', data }) + env.showMessage(` + IA.setTargetAllocation(RM, 0, ${formatGRT(iaRate)})`) + } + + // 2. RM.setIssuanceAllocator(IA) — RM accepts IA as its allocator + if (!checks.iaIntegrated) { + const data = encodeFunctionData({ + abi: ISSUANCE_TARGET_ABI, + functionName: 'setIssuanceAllocator', + args: [iaAddress as `0x${string}`], + }) + builder.addTx({ to: rmAddress, value: '0', data }) + env.showMessage(` + RewardsManager.setIssuanceAllocator(${iaAddress})`) + } + + // 3. GraphToken.addMinter(IA) — IA needs minter role for allocator-minting + if (!checks.iaMinter) { + const data = encodeFunctionData({ + abi: GRAPH_TOKEN_ABI, + functionName: 'addMinter', + args: [iaAddress as `0x${string}`], + }) + builder.addTx({ to: gtAddress, value: '0', data }) + env.showMessage(` + GraphToken.addMinter(${iaAddress})`) + } + + // 4. IA.setDefaultTarget(DA) — safety net for unallocated issuance + let defaultTargetOk = false + try { + const currentDefault = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getTargetAt', + args: [0n], + })) as string + defaultTargetOk = currentDefault.toLowerCase() === daAddress.toLowerCase() + } catch { + // No targets yet + } + env.showMessage(` DA default target: ${defaultTargetOk ? '✓' : '✗'}`) + + if (!defaultTargetOk) { + const data = encodeFunctionData({ + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'setDefaultTarget', + args: [daAddress as `0x${string}`], + }) + builder.addTx({ to: iaAddress, value: '0', data }) + env.showMessage(` + IA.setDefaultTarget(${daAddress})`) + } + + if (canSign) { + env.showMessage('\n🔨 Executing activation TX batch...\n') + await executeTxBatchDirect(env, builder, governor) + env.showMessage(`\n✅ GIP-0088: Issuance Connect — RM connected to IssuanceAllocator!\n`) + } else { + saveGovernanceTx(env, builder, `GIP-0088: issuance-connect`) + } + }, + { dependencies: [ComponentTags.ISSUANCE_ALLOCATOR, ComponentTags.DEFAULT_ALLOCATION, ComponentTags.REWARDS_MANAGER] }, +) diff --git a/packages/deployment/deploy/gip/0088/upgrade/01_deploy.ts b/packages/deployment/deploy/gip/0088/upgrade/01_deploy.ts new file mode 100644 index 000000000..010564515 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/upgrade/01_deploy.ts @@ -0,0 +1,47 @@ +import { + ComponentTags, + DeploymentActions, + GoalTags, + shouldSkipAction, +} from '@graphprotocol/deployment/lib/deployment-tags.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +/** + * GIP-0088:upgrade — Deploy ALL contracts and implementations + * + * Deploys everything required for GIP-0088 in one step: + * - New implementations for existing proxies (RM, HS, SS, DM, PE, L2Curation) + * - New contracts (RC, IA, DA, Reclaim, RAM, REO A/B) + * + * The eligibility and issuance phases start from configure, not deploy. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:upgrade,deploy --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + env.showMessage('\n✓ GIP-0088 upgrade: all contracts and implementations deployed\n') +} + +func.tags = [GoalTags.GIP_0088_UPGRADE] +func.dependencies = [ + // New implementations for existing proxies + ComponentTags.REWARDS_MANAGER, + ComponentTags.HORIZON_STAKING, + ComponentTags.SUBGRAPH_SERVICE, + ComponentTags.DISPUTE_MANAGER, + ComponentTags.PAYMENTS_ESCROW, + ComponentTags.L2_CURATION, + // New contracts (proxy + implementation) + ComponentTags.RECURRING_COLLECTOR, + ComponentTags.ISSUANCE_ALLOCATOR, + ComponentTags.DIRECT_ALLOCATION_IMPL, + ComponentTags.DEFAULT_ALLOCATION, + ComponentTags.REWARDS_RECLAIM, + ComponentTags.RECURRING_AGREEMENT_MANAGER, + ComponentTags.REWARDS_ELIGIBILITY_A, + ComponentTags.REWARDS_ELIGIBILITY_B, +] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) + +export default func diff --git a/packages/deployment/deploy/gip/0088/upgrade/02_configure.ts b/packages/deployment/deploy/gip/0088/upgrade/02_configure.ts new file mode 100644 index 000000000..94e431e52 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/upgrade/02_configure.ts @@ -0,0 +1,40 @@ +import { + ComponentTags, + DeploymentActions, + GoalTags, + shouldSkipAction, +} from '@graphprotocol/deployment/lib/deployment-tags.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +/** + * GIP-0088:upgrade — Configure all contracts (deployer-only) + * + * Checkpoint: component 04_configure scripts do the work. + * + * Only items the deployer can perform run here. Items that require GOVERNOR_ROLE + * on contracts the deployer doesn't yet control (e.g. RC.setPauseGuardian, RM + * integration with Reclaim, deferred role grants on new contracts) are bundled + * into the upgrade governance batch by `04_upgrade.ts`. RC's `04_configure` + * is read-only — it just reports state. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:upgrade,configure --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.CONFIGURE)) return + env.showMessage('\n✓ GIP-0088 upgrade: contracts configured\n') +} + +func.tags = [GoalTags.GIP_0088_UPGRADE] +func.dependencies = [ + ComponentTags.RECURRING_COLLECTOR, + ComponentTags.ISSUANCE_ALLOCATOR, + ComponentTags.DEFAULT_ALLOCATION, + ComponentTags.REWARDS_RECLAIM, + ComponentTags.RECURRING_AGREEMENT_MANAGER, + ComponentTags.REWARDS_ELIGIBILITY_A, + ComponentTags.REWARDS_ELIGIBILITY_B, +] +func.skip = async () => shouldSkipAction(DeploymentActions.CONFIGURE) + +export default func diff --git a/packages/deployment/deploy/gip/0088/upgrade/03_transfer.ts b/packages/deployment/deploy/gip/0088/upgrade/03_transfer.ts new file mode 100644 index 000000000..272aa8f8c --- /dev/null +++ b/packages/deployment/deploy/gip/0088/upgrade/03_transfer.ts @@ -0,0 +1,39 @@ +import { + ComponentTags, + DeploymentActions, + GoalTags, + shouldSkipAction, +} from '@graphprotocol/deployment/lib/deployment-tags.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +/** + * GIP-0088:upgrade — Transfer governance of all new contracts to protocol governor + * + * Checkpoint: component transfer scripts do the work. + * Covers all new contracts that were deployed with deployer as governor. + * + * Must run AFTER configure (deployer needs GOVERNOR_ROLE to configure) + * and BEFORE upgrade (governance must own proxies before upgrade TXs). + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:upgrade,transfer --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.TRANSFER)) return + env.showMessage('\n✓ GIP-0088 upgrade: governance transferred\n') +} + +func.tags = [GoalTags.GIP_0088_UPGRADE] +func.dependencies = [ + ComponentTags.RECURRING_COLLECTOR, + ComponentTags.ISSUANCE_ALLOCATOR, + ComponentTags.DEFAULT_ALLOCATION, + ComponentTags.RECURRING_AGREEMENT_MANAGER, + ComponentTags.REWARDS_RECLAIM, + ComponentTags.REWARDS_ELIGIBILITY_A, + ComponentTags.REWARDS_ELIGIBILITY_B, + ComponentTags.REWARDS_ELIGIBILITY_MOCK, +] +func.skip = async () => shouldSkipAction(DeploymentActions.TRANSFER) + +export default func diff --git a/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts b/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts new file mode 100644 index 000000000..4f333f0c7 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts @@ -0,0 +1,426 @@ +import { + ACCESS_CONTROL_ENUMERABLE_ABI, + ISSUANCE_ALLOCATOR_ABI, + ISSUANCE_TARGET_ABI, + RECURRING_COLLECTOR_PAUSE_ABI, + REWARDS_MANAGER_ABI, + REWARDS_MANAGER_DEPRECATED_ABI, +} from '@graphprotocol/deployment/lib/abis.js' +import type { AnyAddressBookOps } from '@graphprotocol/deployment/lib/address-book-ops.js' +import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' +import { checkConfigurationStatus } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { getREOConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { + type AddressBookType, + CONTRACT_REGISTRY, + type ContractMetadata, + Contracts, +} from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { DeploymentActions, GoalTags, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { formatGRT } from '@graphprotocol/deployment/lib/format.js' +import { + checkDefaultAllocationConfigured, + checkIAConfigured, + checkRAMConfigured, + checkReclaimRMIntegration, + checkReclaimRoles, +} from '@graphprotocol/deployment/lib/preconditions.js' +import { runFullSync } from '@graphprotocol/deployment/lib/sync-utils.js' +import type { TxBuilder } from '@graphprotocol/deployment/lib/tx-builder.js' +import { buildUpgradeTxs } from '@graphprotocol/deployment/lib/upgrade-implementation.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule, Environment } from '@rocketh/core/types' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * GIP-0088:upgrade — Build the governance batch + * + * Single goal: assemble one TX batch that advances the deployment past the + * governance boundary. The batch contains three groups, each of which skips + * items already on-chain: + * + * 1. Proxy upgrades — every deployable proxy with a pendingImplementation + * 2. Existing-contract config — RC.setPauseGuardian, RM.setDefaultReclaimAddress + * 3. Deferred new-contract config — IA/DA/RAM/Reclaim/REO role grants and + * params that the deployer couldn't perform (no GOVERNOR_ROLE) or that + * depend on RM being upgraded + * + * Each helper takes the builder, adds zero or more TXs, and returns the count + * it added. The orchestrator just sums them, prints the result, and either + * executes or saves the batch. + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:upgrade,upgrade --network + * pnpm hardhat deploy:execute-governance --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.UPGRADE)) return + + // The orchestration batch reads every deployable contract across all three + // address books, so we need a full sync first rather than a per-component one. + await runFullSync(env) + + const targetChainId = await getTargetChainIdFromEnv(env) + const { governor, canSign } = await canSignAsGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + const client = graph.getPublicClient(env) as PublicClient + + env.showMessage('\n========== GIP-0088 Upgrade: Proxy Upgrades ==========\n') + + const builder = await createGovernanceTxBuilder(env, 'gip-0088-upgrades', { + name: 'GIP-0088 Proxy Upgrades', + description: 'Upgrade all proxy contracts with pending implementations', + }) + + const proxyCount = await collectProxyUpgrades(env, builder, targetChainId) + + env.showMessage('\nOutstanding configuration:') + const existingCount = await collectExistingContractConfig(env, builder, client, pauseGuardian) + const newCount = await collectDeferredNewContractConfig(env, builder, client, targetChainId, governor, pauseGuardian) + + const total = proxyCount + existingCount + newCount + if (total === 0) { + env.showMessage(' No pending upgrades found\n') + return + } + + if (canSign) { + env.showMessage('\n🔨 Executing upgrade TX batch...\n') + await executeTxBatchDirect(env, builder, governor) + env.showMessage('\n✅ GIP-0088 Upgrade: All proxy upgrades executed\n') + } else { + saveGovernanceTx(env, builder, 'GIP-0088 Proxy Upgrades') + } +} + +func.tags = [GoalTags.GIP_0088_UPGRADE] +func.skip = async () => shouldSkipAction(DeploymentActions.UPGRADE) + +export default func + +// ============================================================================ +// Group 1 — Proxy upgrades +// ============================================================================ + +/** + * Iterate every deployable proxy in the registry. For each one with a + * pendingImplementation in its address book, add the proxy upgrade TX. + */ +async function collectProxyUpgrades(env: Environment, builder: TxBuilder, targetChainId: number): Promise { + let added = 0 + const addressBooks: AddressBookType[] = ['horizon', 'subgraph-service', 'issuance'] + for (const abType of addressBooks) { + const bookRegistry = CONTRACT_REGISTRY[abType] + const ab: AnyAddressBookOps = + abType === 'subgraph-service' + ? graph.getSubgraphServiceAddressBook(targetChainId) + : abType === 'issuance' + ? graph.getIssuanceAddressBook(targetChainId) + : graph.getHorizonAddressBook(targetChainId) + + for (const [name, metadata] of Object.entries(bookRegistry)) { + const meta = metadata as ContractMetadata + if (!meta.deployable || !meta.proxyType) continue + if (!ab.entryExists(name)) continue + const entry = ab.getEntry(name) + + // Skip contracts with no pending implementation unless they have a + // shared implementation that might have changed (auto-detected by buildUpgradeTxs) + if (!entry?.pendingImplementation?.address && !meta.sharedImplementation) continue + + // Derive implementationName from sharedImplementation (e.g. 'DirectAllocation_Implementation' → 'DirectAllocation') + const implementationName = meta.sharedImplementation?.replace(/_Implementation$/, '') + + const result = await buildUpgradeTxs( + env, + { + contractName: name, + proxyType: meta.proxyType, + proxyAdminName: meta.proxyAdminName, + addressBook: abType, + implementationName, + }, + builder, + ) + if (result.upgraded) added++ + } + } + return added +} + +// ============================================================================ +// Group 2 — Existing contract config (RC, RM) +// ============================================================================ + +/** + * Bundle the few governance-only configure items on contracts that already + * existed before this deployment (deployer never had GOVERNOR_ROLE on them): + * + * - RC.setPauseGuardian + * - RM.setDefaultReclaimAddress (only when RM has been upgraded) + */ +async function collectExistingContractConfig( + env: Environment, + builder: TxBuilder, + client: PublicClient, + pauseGuardian: string, +): Promise { + let added = 0 + + // RC.setPauseGuardian + const rc = env.getOrNull(Contracts.horizon.RecurringCollector.name) + if (rc) { + const isGuardian = (await client.readContract({ + address: rc.address as `0x${string}`, + abi: RECURRING_COLLECTOR_PAUSE_ABI, + functionName: 'pauseGuardians', + args: [pauseGuardian as `0x${string}`], + })) as boolean + if (!isGuardian) { + builder.addTx({ + to: rc.address, + value: '0', + data: encodeFunctionData({ + abi: RECURRING_COLLECTOR_PAUSE_ABI, + functionName: 'setPauseGuardian', + args: [pauseGuardian as `0x${string}`, true], + }), + }) + env.showMessage(` + ${Contracts.horizon.RecurringCollector.name}.setPauseGuardian(${pauseGuardian})`) + added++ + } + } + + // RM.setDefaultReclaimAddress — only after RM upgrade lands in the same batch + const reclaim = env.getOrNull(Contracts.issuance.ReclaimedRewards.name) + const rm = env.getOrNull(Contracts.horizon.RewardsManager.name) + if (reclaim && rm) { + const reclaimRMCheck = await checkReclaimRMIntegration(client, rm.address, reclaim.address) + if (!reclaimRMCheck.done && reclaimRMCheck.reason !== 'RM not upgraded') { + builder.addTx({ + to: rm.address, + value: '0', + data: encodeFunctionData({ + abi: REWARDS_MANAGER_ABI, + functionName: 'setDefaultReclaimAddress', + args: [reclaim.address as `0x${string}`], + }), + }) + env.showMessage(` + ${Contracts.horizon.RewardsManager.name}.setDefaultReclaimAddress(${reclaim.address})`) + added++ + } + } + + return added +} + +// ============================================================================ +// Group 3 — Deferred new-contract config (IA, DA, RAM, Reclaim, REO A/B) +// ============================================================================ + +/** + * Bundle the configure items on new contracts that the deployer couldn't + * perform during `02_configure` because it lacks `GOVERNOR_ROLE` on the + * proxy (typical when forking an existing deployment whose proxies were + * already transferred). + */ +async function collectDeferredNewContractConfig( + env: Environment, + builder: TxBuilder, + client: PublicClient, + targetChainId: number, + governor: string, + pauseGuardian: string, +): Promise { + const grantHelper = createRoleGrantHelper(env, builder, client) + let added = 0 + + // IA: rate + roles + const ia = env.getOrNull(Contracts.issuance.IssuanceAllocator.name) + const rm = env.getOrNull(Contracts.horizon.RewardsManager.name) + if (ia && rm) { + const iaCheck = await checkIAConfigured(client, ia.address, rm.address, governor, pauseGuardian) + if (!iaCheck.done && iaCheck.reason !== 'RM.issuancePerBlock is 0') { + const rmRate = (await client.readContract({ + address: rm.address as `0x${string}`, + abi: REWARDS_MANAGER_DEPRECATED_ABI, + functionName: 'issuancePerBlock', + })) as bigint + const iaRate = (await client.readContract({ + address: ia.address as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + // The outer iaCheck already returns when RM rate is 0, so rmRate > 0n here. + if (iaRate !== rmRate) { + builder.addTx({ + to: ia.address, + value: '0', + data: encodeFunctionData({ + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'setIssuancePerBlock', + args: [rmRate], + }), + }) + env.showMessage(` + IA.setIssuancePerBlock(${formatGRT(rmRate)})`) + added++ + } + added += await grantHelper(ia.address, 'IA', 'GOVERNOR_ROLE', governor, 'governor') + added += await grantHelper(ia.address, 'IA', 'PAUSE_ROLE', pauseGuardian, 'pauseGuardian') + } + } + + // DA: roles + const da = env.getOrNull(Contracts.issuance.DefaultAllocation.name) + if (da) { + const daCheck = await checkDefaultAllocationConfigured(client, da.address, governor, pauseGuardian) + if (!daCheck.done) { + added += await grantHelper(da.address, 'DA', 'GOVERNOR_ROLE', governor, 'governor') + added += await grantHelper(da.address, 'DA', 'PAUSE_ROLE', pauseGuardian, 'pauseGuardian') + } + } + + // RAM: roles + setIssuanceAllocator + const ram = env.getOrNull(Contracts.issuance.RecurringAgreementManager.name) + const rcDep = env.getOrNull(Contracts.horizon.RecurringCollector.name) + const ss = env.getOrNull(Contracts['subgraph-service'].SubgraphService.name) + if (ram && rcDep && ss) { + const ramCheck = await checkRAMConfigured( + client, + ram.address, + rcDep.address, + ss.address, + ia?.address ?? '', + governor, + pauseGuardian, + ) + if (!ramCheck.done) { + added += await grantHelper(ram.address, 'RAM', 'COLLECTOR_ROLE', rcDep.address, 'RC') + added += await grantHelper(ram.address, 'RAM', 'DATA_SERVICE_ROLE', ss.address, 'SS') + added += await grantHelper(ram.address, 'RAM', 'GOVERNOR_ROLE', governor, 'governor') + added += await grantHelper(ram.address, 'RAM', 'PAUSE_ROLE', pauseGuardian, 'pauseGuardian') + if (ia) { + try { + const currentIA = (await client.readContract({ + address: ram.address as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + if (currentIA.toLowerCase() !== ia.address.toLowerCase()) { + builder.addTx({ + to: ram.address, + value: '0', + data: encodeFunctionData({ + abi: ISSUANCE_TARGET_ABI, + functionName: 'setIssuanceAllocator', + args: [ia.address as `0x${string}`], + }), + }) + env.showMessage(` + RAM.setIssuanceAllocator(${ia.address})`) + added++ + } + } catch { + /* getter not available */ + } + } + } + } + + // Reclaim: roles only — RM integration is handled by collectExistingContractConfig + const reclaim = env.getOrNull(Contracts.issuance.ReclaimedRewards.name) + if (reclaim) { + const reclaimRoles = await checkReclaimRoles(client, reclaim.address, governor, pauseGuardian) + if (!reclaimRoles.done) { + added += await grantHelper(reclaim.address, 'Reclaim', 'GOVERNOR_ROLE', governor, 'governor') + added += await grantHelper(reclaim.address, 'Reclaim', 'PAUSE_ROLE', pauseGuardian, 'pauseGuardian') + } + } + + // REO A/B: params + roles. Driven by the same condition list as `04_configure`. + const issuanceBook = graph.getIssuanceAddressBook(targetChainId) + if (issuanceBook.entryExists('NetworkOperator')) { + const reoConditions = await getREOConditions(env) + for (const [label, entry] of [ + ['REO-A', Contracts.issuance.RewardsEligibilityOracleA], + ['REO-B', Contracts.issuance.RewardsEligibilityOracleB], + ] as const) { + const reoDep = env.getOrNull(entry.name) + if (!reoDep) continue + const reoConfig = await checkConfigurationStatus(client, reoDep.address, reoConditions) + if (reoConfig.allOk) continue + for (let i = 0; i < reoConditions.length; i++) { + if (reoConfig.conditions[i].ok) continue + const cond = reoConditions[i] + if (cond.type === 'role') { + added += await grantHelper(reoDep.address, label, cond.roleGetter, cond.targetAccount, cond.description) + } else { + builder.addTx({ + to: reoDep.address, + value: '0', + data: encodeFunctionData({ + abi: cond.abi as readonly unknown[], + functionName: cond.setter, + args: [cond.target], + }), + }) + env.showMessage(` + ${label}.${cond.setter}(${cond.target})`) + added++ + } + } + } + } + + return added +} + +/** + * Returns a closure that, when called, adds a `grantRole` TX if the role is + * not already held. Returns 1 if a TX was added, 0 otherwise. + */ +function createRoleGrantHelper(env: Environment, builder: TxBuilder, client: PublicClient) { + return async function addRoleGrantIfNeeded( + contractAddr: string, + contractName: string, + roleName: string, + account: string, + accountLabel: string, + ): Promise { + try { + const role = (await client.readContract({ + address: contractAddr as `0x${string}`, + abi: [ + { inputs: [], name: roleName, outputs: [{ type: 'bytes32' }], stateMutability: 'view', type: 'function' }, + ], + functionName: roleName, + })) as `0x${string}` + const has = (await client.readContract({ + address: contractAddr as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [role, account as `0x${string}`], + })) as boolean + if (has) return 0 + builder.addTx({ + to: contractAddr, + value: '0', + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [role, account as `0x${string}`], + }), + }) + env.showMessage(` + ${contractName}.grantRole(${roleName}, ${accountLabel})`) + return 1 + } catch { + /* role getter not available — skip */ + return 0 + } + } +} diff --git a/packages/deployment/deploy/gip/0088/upgrade/10_status.ts b/packages/deployment/deploy/gip/0088/upgrade/10_status.ts new file mode 100644 index 000000000..0107b3eb9 --- /dev/null +++ b/packages/deployment/deploy/gip/0088/upgrade/10_status.ts @@ -0,0 +1,324 @@ +import { IISSUANCE_TARGET_INTERFACE_ID } from '@graphprotocol/deployment/lib/abis.js' +import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' +import { checkConfigurationStatus } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { + getREOConditions, + getREOTransferGovernanceConditions, + isRewardsManagerUpgraded, +} from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts, type RegistryEntry } from '@graphprotocol/deployment/lib/contract-registry.js' +import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, GoalTags, noTagsRequested } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { getDeployer, getProxyAdminAddress } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { + checkDefaultAllocationConfigured, + checkDeployerRevoked, + checkIAConfigured, + checkProxyAdminTransferred, + checkRAMConfigured, + checkReclaimRMIntegration, + checkReclaimRoles, +} from '@graphprotocol/deployment/lib/preconditions.js' +import { showDetailedComponentStatus, showPendingGovernanceTxs } from '@graphprotocol/deployment/lib/status-detail.js' +import { checkAllProxyStates, getContractStatusLine, runFullSync } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule } from '@rocketh/core/types' +import type { PublicClient } from 'viem' + +/** + * GIP-0088:upgrade status — full deployment state with next-step guidance + * + * Usage: + * pnpm hardhat deploy --tags GIP-0088:upgrade --network + */ +const func: DeployScriptModule = async (env) => { + if (noTagsRequested()) return + + // The upgrade status reads every contract in every address book — easier to + // run a full sync than to enumerate them. + await runFullSync(env) + + const client = graph.getPublicClient(env) as PublicClient + const targetChainId = await getTargetChainIdFromEnv(env) + + env.showMessage('\n========== GIP-0088 Upgrade ==========') + + // --- Proxy upgrades --- + env.showMessage('\nProxy upgrades:') + + const upgradeContracts: RegistryEntry[] = [ + Contracts.horizon.RewardsManager, + Contracts.horizon.HorizonStaking, + Contracts['subgraph-service'].SubgraphService, + Contracts['subgraph-service'].DisputeManager, + Contracts.horizon.PaymentsEscrow, + Contracts.horizon.L2Curation, + ] + + const rm = env.getOrNull('RewardsManager') + + for (const contract of upgradeContracts) { + const ab = + contract.addressBook === 'subgraph-service' + ? graph.getSubgraphServiceAddressBook(targetChainId) + : graph.getHorizonAddressBook(targetChainId) + + const result = await getContractStatusLine(client, contract.addressBook, ab, contract.name) + env.showMessage(` ${result.line}`) + + if (contract === Contracts.horizon.RewardsManager && result.exists && rm) { + const upgraded = await isRewardsManagerUpgraded(client, rm.address) + env.showMessage(` ${upgraded ? '✓' : '✗'} implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})`) + } + } + + const { anyCodeChanged, anyPending } = checkAllProxyStates(targetChainId) + + // --- New contracts --- + env.showMessage('\nNew contracts:') + await showDetailedComponentStatus(env, Contracts.horizon.RecurringCollector, { showHints: false }) + await showDetailedComponentStatus(env, Contracts.issuance.IssuanceAllocator, { showHints: false }) + await showDetailedComponentStatus(env, Contracts.issuance.DefaultAllocation, { showHints: false }) + await showDetailedComponentStatus(env, Contracts.issuance.RecurringAgreementManager, { showHints: false }) + await showDetailedComponentStatus(env, Contracts.issuance.ReclaimedRewards, { showHints: false }) + await showDetailedComponentStatus(env, Contracts.issuance.RewardsEligibilityOracleA, { showHints: false }) + + // --- Next step --- + // Uses the same precondition checks as the action scripts (shared code, not copies) + const ia = env.getOrNull('IssuanceAllocator') + const da = env.getOrNull('DefaultAllocation') + const reoA = env.getOrNull('RewardsEligibilityOracleA') + const reoB = env.getOrNull('RewardsEligibilityOracleB') + const ram = env.getOrNull('RecurringAgreementManager') + const reclaim = env.getOrNull('ReclaimedRewards') + const rc = env.getOrNull('RecurringCollector') + const ss = env.getOrNull('SubgraphService') + + const anyNewContractMissing = !ia || !da || !reoA || !reoB || !ram || !reclaim + + if (anyNewContractMissing || !rm || (anyCodeChanged && !anyPending)) { + env.showMessage(`\n → Next: --tags GIP-0088:upgrade,deploy`) + const missing = [ + !ia && 'IssuanceAllocator', + !da && 'DefaultAllocation', + !reoA && 'REO-A', + !reoB && 'REO-B', + !ram && 'RAM', + !reclaim && 'Reclaim', + !rm && 'RM', + ].filter(Boolean) + if (missing.length > 0) env.showMessage(` Missing: ${missing.join(', ')}`) + if (anyCodeChanged && !anyPending) env.showMessage(` Code changed without pending implementation`) + } else { + const governor = await getGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + + // Deployer address: from namedAccounts when key is loaded, otherwise infer + // from ProxyAdmin owner — if not governor, it's the deployer. + let deployer = getDeployer(env) + if (!deployer) { + try { + const proxyAdminAddr = await getProxyAdminAddress(client, ia.address) + const owner = (await client.readContract({ + address: proxyAdminAddr as `0x${string}`, + abi: [ + { inputs: [], name: 'owner', outputs: [{ type: 'address' }], stateMutability: 'view', type: 'function' }, + ], + functionName: 'owner', + })) as string + if (owner.toLowerCase() !== governor.toLowerCase()) deployer = owner + } catch { + // ProxyAdmin not readable — deployer stays undefined + } + } + + // Check configure state + // When deployer is available, classify issues as deployer-fixable vs deferred. + // When not (status-only run without deploy key), all issues are unclassified. + const configIssues: string[] = [] + const deferredIssues: string[] = [] + + // Helper: check if deployer has GOVERNOR_ROLE on a contract + // Returns false when deployer is not configured (status-only run without deploy key) + async function deployerHasGovernorRole(contractAddress: string): Promise { + if (!deployer) return false + try { + const role = (await client.readContract({ + address: contractAddress as `0x${string}`, + abi: [ + { + inputs: [], + name: 'GOVERNOR_ROLE', + outputs: [{ type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'GOVERNOR_ROLE', + })) as `0x${string}` + return (await client.readContract({ + address: contractAddress as `0x${string}`, + abi: [ + { + inputs: [{ type: 'bytes32' }, { type: 'address' }], + name: 'hasRole', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'hasRole', + args: [role, deployer as `0x${string}`], + })) as boolean + } catch { + return false + } + } + + // Helper: classify a failing config check + async function classifyConfigIssue(label: string, reason: string, contractAddress: string): Promise { + if (await deployerHasGovernorRole(contractAddress)) { + configIssues.push(`${label}: ${reason}`) + } else { + deferredIssues.push(`${label}: ${reason}`) + } + } + + // Check each new contract + const iaConfig = await checkIAConfigured(client, ia.address, rm.address, governor, pauseGuardian) + if (!iaConfig.done && iaConfig.reason !== 'RM.issuancePerBlock is 0') { + await classifyConfigIssue('IA', iaConfig.reason!, ia.address) + } + + const daConfig = await checkDefaultAllocationConfigured(client, da.address, governor, pauseGuardian) + if (!daConfig.done) { + await classifyConfigIssue('DA', daConfig.reason!, da.address) + } + + if (rc && ss) { + const ramConfig = await checkRAMConfigured( + client, + ram.address, + rc.address, + ss.address, + ia.address, + governor, + pauseGuardian, + ) + if (!ramConfig.done) { + await classifyConfigIssue('RAM', ramConfig.reason!, ram.address) + } + } + + const reclaimRolesCheck = await checkReclaimRoles(client, reclaim.address, governor, pauseGuardian) + if (!reclaimRolesCheck.done) { + await classifyConfigIssue('Reclaim', reclaimRolesCheck.reason!, reclaim.address) + } + + // RM.setDefaultReclaimAddress — governance-only (target is RM, not Reclaim). + // Always deferred to the upgrade governance batch, never blocks configure/transfer. + const reclaimRMCheck = await checkReclaimRMIntegration(client, rm.address, reclaim.address) + if (!reclaimRMCheck.done && reclaimRMCheck.reason !== 'RM not upgraded') { + deferredIssues.push(`Reclaim: ${reclaimRMCheck.reason}`) + } + + // REO configure + const issuanceBook = graph.getIssuanceAddressBook(targetChainId) + const hasNetworkOperator = issuanceBook.entryExists('NetworkOperator') + if (hasNetworkOperator) { + const reoConditions = await getREOConditions(env) + for (const [label, addr] of [ + ['REO-A', reoA.address], + ['REO-B', reoB.address], + ] as const) { + const reoConfig = await checkConfigurationStatus(client, addr, reoConditions) + if (!reoConfig.allOk) { + const failing = reoConfig.conditions.filter((c) => !c.ok).map((c) => c.name) + await classifyConfigIssue(label, failing.join(', '), addr) + } + } + } else { + deferredIssues.push('NetworkOperator not configured') + } + + const anyConfigIssues = configIssues.length > 0 || deferredIssues.length > 0 + + // Check transfer state + // ProxyAdmin ownership is deployer-independent (checks owner vs governor). + // Deployer GOVERNOR_ROLE revocation needs the deployer address — checked + // when available, skipped otherwise (ProxyAdmin transfer is the primary signal). + let proxyAdminsTransferred = true + + for (const contract of [ia, da, ram, reclaim, reoA, reoB]) { + try { + const proxyAdminAddr = await getProxyAdminAddress(client, contract.address) + const paCheck = await checkProxyAdminTransferred(client, proxyAdminAddr, governor) + if (!paCheck.done) proxyAdminsTransferred = false + } catch { + // ProxyAdmin not readable — skip + } + } + + let deployerRolesRevoked = true + if (deployer) { + for (const contract of [ia, da, ram, reclaim]) { + const revoked = await checkDeployerRevoked(client, contract.address, deployer) + if (!revoked.done) deployerRolesRevoked = false + } + if (hasNetworkOperator) { + const reoTransferConds = getREOTransferGovernanceConditions(deployer) + const reoATransfer = await checkConfigurationStatus(client, reoA.address, reoTransferConds) + if (!reoATransfer.allOk) deployerRolesRevoked = false + const reoBTransfer = await checkConfigurationStatus(client, reoB.address, reoTransferConds) + if (!reoBTransfer.allOk) deployerRolesRevoked = false + } + } + + const needsTransfer = !proxyAdminsTransferred || !deployerRolesRevoked + + // Next-step guidance + // Lifecycle: deploy → configure → transfer → upgrade + // ProxyAdmin not transferred ⇒ deployer still has control ⇒ configure/transfer phase + // ProxyAdmin transferred ⇒ remaining issues need governance ⇒ upgrade phase + if (anyConfigIssues && !proxyAdminsTransferred) { + env.showMessage(`\n → Next: --tags GIP-0088:upgrade,configure`) + for (const issue of configIssues) env.showMessage(` ${issue}`) + if (deferredIssues.length > 0) { + env.showMessage(` Deferred (governance TX):`) + for (const issue of deferredIssues) env.showMessage(` ${issue}`) + } + } else if (needsTransfer) { + env.showMessage(`\n → Next: --tags GIP-0088:upgrade,transfer`) + } else if (anyPending || anyConfigIssues) { + env.showMessage(`\n → Next: --tags GIP-0088:upgrade,upgrade`) + if (deferredIssues.length > 0) { + env.showMessage(` Deferred config (governance TX):`) + for (const issue of deferredIssues) env.showMessage(` ${issue}`) + } + } + } + + showPendingGovernanceTxs(env) + env.showMessage(`\n Actions: --tags GIP-0088:upgrade,`) + env.showMessage('') +} + +func.tags = [GoalTags.GIP_0088_UPGRADE] +func.dependencies = [ + // Upgrade contracts + ComponentTags.RECURRING_COLLECTOR, + ComponentTags.REWARDS_MANAGER, + ComponentTags.HORIZON_STAKING, + ComponentTags.SUBGRAPH_SERVICE, + ComponentTags.DISPUTE_MANAGER, + ComponentTags.PAYMENTS_ESCROW, + ComponentTags.L2_CURATION, + // New contracts (shown in status) + ComponentTags.ISSUANCE_ALLOCATOR, + ComponentTags.DEFAULT_ALLOCATION, + ComponentTags.RECURRING_AGREEMENT_MANAGER, + ComponentTags.REWARDS_ELIGIBILITY_A, +] +func.skip = async () => noTagsRequested() + +export default func diff --git a/packages/deployment/deploy/horizon/curation/01_deploy.ts b/packages/deployment/deploy/horizon/curation/01_deploy.ts new file mode 100644 index 000000000..1a0d9c9b0 --- /dev/null +++ b/packages/deployment/deploy/horizon/curation/01_deploy.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createImplementationDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createImplementationDeployModule(Contracts.horizon.L2Curation) diff --git a/packages/deployment/deploy/horizon/curation/02_upgrade.ts b/packages/deployment/deploy/horizon/curation/02_upgrade.ts new file mode 100644 index 000000000..efb44379c --- /dev/null +++ b/packages/deployment/deploy/horizon/curation/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.horizon.L2Curation) diff --git a/packages/deployment/deploy/horizon/curation/09_end.ts b/packages/deployment/deploy/horizon/curation/09_end.ts new file mode 100644 index 000000000..bd06ed9ad --- /dev/null +++ b/packages/deployment/deploy/horizon/curation/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.horizon.L2Curation) diff --git a/packages/deployment/deploy/horizon/curation/10_status.ts b/packages/deployment/deploy/horizon/curation/10_status.ts new file mode 100644 index 000000000..8a6d9f944 --- /dev/null +++ b/packages/deployment/deploy/horizon/curation/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.horizon.L2Curation) diff --git a/packages/deployment/deploy/horizon/payments-escrow/01_deploy.ts b/packages/deployment/deploy/horizon/payments-escrow/01_deploy.ts new file mode 100644 index 000000000..91d2db38b --- /dev/null +++ b/packages/deployment/deploy/horizon/payments-escrow/01_deploy.ts @@ -0,0 +1,58 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { deployImplementation, getImplementationConfig } from '@graphprotocol/deployment/lib/deploy-implementation.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +// PaymentsEscrow Implementation Deployment +// +// Deploys a new PaymentsEscrow implementation if artifact bytecode differs from on-chain. +// +// Workflow: +// 1. Read current immutable values from on-chain contract +// 2. Compare artifact bytecode with on-chain bytecode (accounting for immutables) +// 3. If different, deploy new implementation +// 4. Store as "pendingImplementation" in horizon/addresses.json +// 5. Upgrade task (separate) handles TX generation and execution + +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [Contracts.horizon.Controller, Contracts.horizon.PaymentsEscrow]) + + const controllerDep = env.getOrNull('Controller') + const escrowDep = env.getOrNull('PaymentsEscrow') + + if (!controllerDep || !escrowDep) { + throw new Error('Missing required contract deployments (Controller, PaymentsEscrow) after sync.') + } + + // Read current immutable value from on-chain contract + const client = graph.getPublicClient(env) + const thawingPeriod = await client.readContract({ + address: escrowDep.address as `0x${string}`, + abi: [ + { + name: 'WITHDRAW_ESCROW_THAWING_PERIOD', + type: 'function', + inputs: [], + outputs: [{ name: '', type: 'uint256' }], + stateMutability: 'view', + }, + ], + functionName: 'WITHDRAW_ESCROW_THAWING_PERIOD', + }) + + env.showMessage(` PaymentsEscrow WITHDRAW_ESCROW_THAWING_PERIOD: ${thawingPeriod}`) + + await deployImplementation( + env, + getImplementationConfig('horizon', 'PaymentsEscrow', { + constructorArgs: [controllerDep.address, thawingPeriod], + }), + ) +} + +func.tags = [ComponentTags.PAYMENTS_ESCROW] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) +export default func diff --git a/packages/deployment/deploy/horizon/payments-escrow/02_upgrade.ts b/packages/deployment/deploy/horizon/payments-escrow/02_upgrade.ts new file mode 100644 index 000000000..25c8f13e1 --- /dev/null +++ b/packages/deployment/deploy/horizon/payments-escrow/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.horizon.PaymentsEscrow) diff --git a/packages/deployment/deploy/horizon/payments-escrow/09_end.ts b/packages/deployment/deploy/horizon/payments-escrow/09_end.ts new file mode 100644 index 000000000..95272ed2d --- /dev/null +++ b/packages/deployment/deploy/horizon/payments-escrow/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.horizon.PaymentsEscrow) diff --git a/packages/deployment/deploy/horizon/payments-escrow/10_status.ts b/packages/deployment/deploy/horizon/payments-escrow/10_status.ts new file mode 100644 index 000000000..267692139 --- /dev/null +++ b/packages/deployment/deploy/horizon/payments-escrow/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.horizon.PaymentsEscrow) diff --git a/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts b/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts new file mode 100644 index 000000000..d85c02f99 --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts @@ -0,0 +1,51 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { deployProxyContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import type { DeployScriptModule } from '@rocketh/core/types' + +/** + * Deploy RecurringCollector proxy and implementation + * + * Deploys OZ v5 TransparentUpgradeableProxy with atomic initialization. + * Deployer is the initial ProxyAdmin owner; ownership is transferred to + * the protocol governor in a separate governance step. + * + * RecurringCollector constructor takes (controller, revokeSignerThawingPeriod). + * initialize(eip712Name, eip712Version) sets up EIP-712 domain and pausability. + * + * On subsequent runs (proxy already deployed), deploys new implementation + * and stores it as pendingImplementation for governance upgrade. + * + * Usage: + * pnpm hardhat deploy --tags RecurringCollector:deploy --network + */ +const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [Contracts.horizon.Controller, Contracts.horizon.RecurringCollector]) + + const controllerDep = env.getOrNull('Controller') + if (!controllerDep) { + throw new Error('Missing Controller deployment after sync.') + } + + const config = await loadDeploymentConfig(env) + const rcConfig = config.RecurringCollector ?? {} + const revokeSignerThawingPeriod = rcConfig.revokeSignerThawingPeriod ?? '28800' // ~1 day at 3s blocks + const eip712Name = rcConfig.eip712Name ?? 'RecurringCollector' + const eip712Version = rcConfig.eip712Version ?? '1' + + env.showMessage(`\n📦 Deploying ${Contracts.horizon.RecurringCollector.name}`) + + await deployProxyContract(env, { + contract: Contracts.horizon.RecurringCollector, + constructorArgs: [controllerDep.address, revokeSignerThawingPeriod], + initializeArgs: [eip712Name, eip712Version], + }) +} + +func.tags = [ComponentTags.RECURRING_COLLECTOR] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) + +export default func diff --git a/packages/deployment/deploy/horizon/recurring-collector/02_upgrade.ts b/packages/deployment/deploy/horizon/recurring-collector/02_upgrade.ts new file mode 100644 index 000000000..f58136aad --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.horizon.RecurringCollector) diff --git a/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts b/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts new file mode 100644 index 000000000..0513c788f --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts @@ -0,0 +1,62 @@ +import { RECURRING_COLLECTOR_PAUSE_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * Configure RecurringCollector — set pause guardian + * + * RC uses Controller-based access control: setPauseGuardian requires + * msg.sender == Controller.getGovernor(). If the deployer is the + * Controller governor (e.g. testnet), this script sets it directly. + * Otherwise it reports the gap — the upgrade step (04_upgrade.ts) + * bundles it as a governance TX. + * + * Idempotent: checks on-chain state, skips if already set. + * + * Usage: + * pnpm hardhat deploy --tags RecurringCollector:configure --network + */ +export default createActionModule(Contracts.horizon.RecurringCollector, DeploymentActions.CONFIGURE, async (env) => { + const client = graph.getPublicClient(env) as PublicClient + const rc = requireContract(env, Contracts.horizon.RecurringCollector) + const pauseGuardian = await getPauseGuardian(env) + + env.showMessage(`\n========== Configure ${Contracts.horizon.RecurringCollector.name} ==========`) + + const isGuardian = (await client.readContract({ + address: rc.address as `0x${string}`, + abi: RECURRING_COLLECTOR_PAUSE_ABI, + functionName: 'pauseGuardians', + args: [pauseGuardian as `0x${string}`], + })) as boolean + + if (isGuardian) { + env.showMessage(` ✓ Pause guardian already set\n`) + return + } + + const { governor, canSign } = await canSignAsGovernor(env) + if (!canSign) { + env.showMessage(` ○ Pause guardian not set — will be configured in upgrade step (governance TX)\n`) + return + } + + env.showMessage('\n🔨 Setting pause guardian as governor...\n') + const txFn = tx(env) + await txFn({ + account: governor as `0x${string}`, + to: rc.address as `0x${string}`, + data: encodeFunctionData({ + abi: RECURRING_COLLECTOR_PAUSE_ABI, + functionName: 'setPauseGuardian', + args: [pauseGuardian as `0x${string}`, true], + }), + }) + env.showMessage(` ✓ setPauseGuardian(${pauseGuardian})\n`) +}) diff --git a/packages/deployment/deploy/horizon/recurring-collector/05_transfer_governance.ts b/packages/deployment/deploy/horizon/recurring-collector/05_transfer_governance.ts new file mode 100644 index 000000000..672cc47d5 --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/05_transfer_governance.ts @@ -0,0 +1,69 @@ +import { OZ_PROXY_ADMIN_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + getProxyAdminAddress, + requireContract, + requireDeployer, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' +import { encodeFunctionData } from 'viem' + +/** + * Transfer RecurringCollector ProxyAdmin to protocol governor + * + * RC doesn't use BaseUpgradeable GOVERNOR_ROLE — only ProxyAdmin needs transfer. + * + * Idempotent: checks current owner, skips if already governor. + * + * Usage: + * pnpm hardhat deploy --tags RecurringCollector,transfer --network + */ +export default createActionModule(Contracts.horizon.RecurringCollector, DeploymentActions.TRANSFER, async (env) => { + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + const governor = await getGovernor(env) + const rc = requireContract(env, Contracts.horizon.RecurringCollector) + + env.showMessage(`\n========== Transfer ${Contracts.horizon.RecurringCollector.name} ==========`) + + // Read ProxyAdmin from ERC1967 slot + const proxyAdminAddress = await getProxyAdminAddress(client, rc.address) + + const currentOwner = (await client.readContract({ + address: proxyAdminAddress as `0x${string}`, + abi: OZ_PROXY_ADMIN_ABI, + functionName: 'owner', + })) as string + + if (currentOwner.toLowerCase() === governor.toLowerCase()) { + env.showMessage(` ✓ ProxyAdmin already owned by governor\n`) + return + } + + if (currentOwner.toLowerCase() !== deployer.toLowerCase()) { + env.showMessage(` ○ ProxyAdmin owned by ${currentOwner}, not deployer — skipping\n`) + return + } + + env.showMessage(` Transferring ProxyAdmin ownership to governor...`) + env.showMessage(` ProxyAdmin: ${proxyAdminAddress}`) + env.showMessage(` From: ${deployer}`) + env.showMessage(` To: ${governor}`) + + const txFn = tx(env) + await txFn({ + account: deployer, + to: proxyAdminAddress as `0x${string}`, + data: encodeFunctionData({ + abi: OZ_PROXY_ADMIN_ABI, + functionName: 'transferOwnership', + args: [governor as `0x${string}`], + }), + }) + + env.showMessage(` ✓ ProxyAdmin ownership transferred to governor\n`) +}) diff --git a/packages/deployment/deploy/horizon/recurring-collector/09_end.ts b/packages/deployment/deploy/horizon/recurring-collector/09_end.ts new file mode 100644 index 000000000..5240c729c --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.horizon.RecurringCollector) diff --git a/packages/deployment/deploy/horizon/recurring-collector/10_status.ts b/packages/deployment/deploy/horizon/recurring-collector/10_status.ts new file mode 100644 index 000000000..da1ecafc3 --- /dev/null +++ b/packages/deployment/deploy/horizon/recurring-collector/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.horizon.RecurringCollector) diff --git a/packages/deployment/deploy/horizon/staking/01_deploy.ts b/packages/deployment/deploy/horizon/staking/01_deploy.ts new file mode 100644 index 000000000..3b9f1c9d4 --- /dev/null +++ b/packages/deployment/deploy/horizon/staking/01_deploy.ts @@ -0,0 +1,15 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createImplementationDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createImplementationDeployModule( + Contracts.horizon.HorizonStaking, + (env) => { + const controller = env.getOrNull('Controller') + const subgraphService = env.getOrNull('SubgraphService') + if (!controller || !subgraphService) { + throw new Error('Missing required contract deployments (Controller, SubgraphService) after sync.') + } + return [controller.address, subgraphService.address] + }, + { prerequisites: [Contracts.horizon.Controller, Contracts['subgraph-service'].SubgraphService] }, +) diff --git a/packages/deployment/deploy/horizon/staking/02_upgrade.ts b/packages/deployment/deploy/horizon/staking/02_upgrade.ts new file mode 100644 index 000000000..d7abe8bbe --- /dev/null +++ b/packages/deployment/deploy/horizon/staking/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.horizon.HorizonStaking) diff --git a/packages/deployment/deploy/horizon/staking/09_end.ts b/packages/deployment/deploy/horizon/staking/09_end.ts new file mode 100644 index 000000000..d374f7e79 --- /dev/null +++ b/packages/deployment/deploy/horizon/staking/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.horizon.HorizonStaking) diff --git a/packages/deployment/deploy/horizon/staking/10_status.ts b/packages/deployment/deploy/horizon/staking/10_status.ts new file mode 100644 index 000000000..22c2a940d --- /dev/null +++ b/packages/deployment/deploy/horizon/staking/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.horizon.HorizonStaking) diff --git a/packages/deployment/deploy/rewards/eligibility/01_deploy.ts b/packages/deployment/deploy/rewards/eligibility/01_deploy.ts deleted file mode 100644 index 11dd554a8..000000000 --- a/packages/deployment/deploy/rewards/eligibility/01_deploy.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { deployProxyContract, requireGraphToken } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Deploy RewardsEligibilityOracle proxy and implementation - * - * Deploys OZ v5 TransparentUpgradeableProxy with atomic initialization. - * Deployer receives GOVERNOR_ROLE (temporary, for configuration). - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - * - * Usage: - * pnpm hardhat deploy --tags rewards-eligibility-deploy --network - */ - -const func: DeployScriptModule = async (env) => { - const graphToken = requireGraphToken(env).address - - env.showMessage(`\n📦 Deploying ${Contracts.issuance.RewardsEligibilityOracle.name} with GraphToken: ${graphToken}`) - - await deployProxyContract(env, { - contract: Contracts.issuance.RewardsEligibilityOracle, - constructorArgs: [graphToken], - }) -} - -func.tags = Tags.rewardsEligibilityDeploy -func.dependencies = [SpecialTags.SYNC] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/02_upgrade.ts b/packages/deployment/deploy/rewards/eligibility/02_upgrade.ts deleted file mode 100644 index 4432d7391..000000000 --- a/packages/deployment/deploy/rewards/eligibility/02_upgrade.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * Upgrade RewardsEligibilityOracle to pending implementation - * - * Generates governance TX batch for proxy upgrade, then exits. - * Execute separately via: pnpm hardhat deploy:execute-governance - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - * - * Usage: - * pnpm hardhat deploy --tags rewards-eligibility-upgrade --network - */ - -const func: DeployScriptModule = async (env) => { - await upgradeImplementation(env, Contracts.issuance.RewardsEligibilityOracle) -} - -func.tags = Tags.rewardsEligibilityUpgrade -func.dependencies = [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.DEPLOY)] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/04_configure.ts b/packages/deployment/deploy/rewards/eligibility/04_configure.ts deleted file mode 100644 index 849675917..000000000 --- a/packages/deployment/deploy/rewards/eligibility/04_configure.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' -import { checkREORole, getREOConditions } from '@graphprotocol/deployment/lib/contract-checks.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' - -/** - * Configure RewardsEligibilityOracle (params + roles) - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - */ -const func: DeployScriptModule = async (env) => { - const deployer = requireDeployer(env) - const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracle]) - const client = graph.getPublicClient(env) as PublicClient - - const canExecuteDirectly = (await checkREORole(client, reo.address, 'GOVERNOR_ROLE', deployer)).hasRole - - await applyConfiguration(env, client, await getREOConditions(env), { - contractName: Contracts.issuance.RewardsEligibilityOracle.name, - contractAddress: reo.address, - canExecuteDirectly, - executor: deployer, - }) -} - -func.tags = Tags.rewardsEligibilityConfigure -func.dependencies = [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.DEPLOY)] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/05_transfer_governance.ts b/packages/deployment/deploy/rewards/eligibility/05_transfer_governance.ts deleted file mode 100644 index e19688c81..000000000 --- a/packages/deployment/deploy/rewards/eligibility/05_transfer_governance.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { applyConfiguration, checkConfigurationStatus } from '@graphprotocol/deployment/lib/apply-configuration.js' -import { getREOConditions, getREOTransferGovernanceConditions } from '@graphprotocol/deployment/lib/contract-checks.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' - -/** - * Transfer governance of RewardsEligibilityOracle - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - */ -const func: DeployScriptModule = async (env) => { - const deployer = requireDeployer(env) - const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracle]) - const client = graph.getPublicClient(env) as PublicClient - - // 1. Verify preconditions (same conditions as step 4) - env.showMessage(`\n📋 Verifying ${Contracts.issuance.RewardsEligibilityOracle.name} configuration...\n`) - const status = await checkConfigurationStatus(client, reo.address, await getREOConditions(env)) - for (const r of status.conditions) env.showMessage(` ${r.message}`) - if (!status.allOk) { - env.showMessage('\n❌ Configuration incomplete - run configure step first\n') - process.exit(1) - } - - // 2. Apply: revoke deployer's GOVERNOR_ROLE - await applyConfiguration(env, client, getREOTransferGovernanceConditions(deployer), { - contractName: `${Contracts.issuance.RewardsEligibilityOracle.name}-transfer-governance`, - contractAddress: reo.address, - canExecuteDirectly: true, - executor: deployer, - }) -} - -func.tags = Tags.rewardsEligibilityTransfer -func.dependencies = [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.CONFIGURE)] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/06_integrate.ts b/packages/deployment/deploy/rewards/eligibility/06_integrate.ts deleted file mode 100644 index 3773c6982..000000000 --- a/packages/deployment/deploy/rewards/eligibility/06_integrate.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' -import { createRMIntegrationCondition } from '@graphprotocol/deployment/lib/contract-checks.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { ComponentTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' - -/** - * Integrate RewardsEligibilityOracle with RewardsManager - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - */ -const func: DeployScriptModule = async (env) => { - const [reo, rm] = requireContracts(env, [ - Contracts.issuance.RewardsEligibilityOracle, - Contracts.horizon.RewardsManager, - ]) - const client = graph.getPublicClient(env) as PublicClient - - // Apply: RM.providerEligibilityOracle = REO (always governance TX) - await applyConfiguration(env, client, [createRMIntegrationCondition(reo.address)], { - contractName: `${Contracts.horizon.RewardsManager.name}-REO`, - contractAddress: rm.address, - canExecuteDirectly: false, - }) -} - -func.tags = Tags.rewardsEligibilityIntegrate -func.dependencies = [Tags.rewardsEligibilityTransfer[0], ComponentTags.REWARDS_MANAGER] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/09_complete.ts b/packages/deployment/deploy/rewards/eligibility/09_complete.ts deleted file mode 100644 index 0a97f6795..000000000 --- a/packages/deployment/deploy/rewards/eligibility/09_complete.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' - -/** - * RewardsEligibilityOracle complete - verifies full deployment - * - * Aggregate tag: runs deploy, upgrade, configure steps. - * Transfer-governance is separate (explicit action to relinquish control). - * - * See: docs/deploy/RewardsEligibilityOracleDeployment.md - * - * Usage: - * pnpm hardhat deploy --tags rewards-eligibility --network - */ -const func: DeployScriptModule = async (env) => { - requireUpgradeExecuted(env, Contracts.issuance.RewardsEligibilityOracle.name) - env.showMessage(`\n✓ ${Contracts.issuance.RewardsEligibilityOracle.name} ready`) -} - -func.tags = Tags.rewardsEligibility -func.dependencies = [ - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.DEPLOY), - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.UPGRADE), - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.CONFIGURE), - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.TRANSFER), - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.INTEGRATE), - actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.VERIFY), -] - -export default func diff --git a/packages/deployment/deploy/rewards/eligibility/a/01_deploy.ts b/packages/deployment/deploy/rewards/eligibility/a/01_deploy.ts new file mode 100644 index 000000000..1bde8305b --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/01_deploy.ts @@ -0,0 +1,12 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { requireDeployer, requireGraphToken } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createProxyDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createProxyDeployModule( + Contracts.issuance.RewardsEligibilityOracleA, + (env) => ({ + constructorArgs: [requireGraphToken(env).address], + initializeArgs: [requireDeployer(env)], + }), + { prerequisites: [Contracts.horizon.L2GraphToken] }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/a/02_upgrade.ts b/packages/deployment/deploy/rewards/eligibility/a/02_upgrade.ts new file mode 100644 index 000000000..063a33cae --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.issuance.RewardsEligibilityOracleA) diff --git a/packages/deployment/deploy/rewards/eligibility/a/04_configure.ts b/packages/deployment/deploy/rewards/eligibility/a/04_configure.ts new file mode 100644 index 000000000..26bb1e7c7 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/04_configure.ts @@ -0,0 +1,39 @@ +import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { checkREORole, getREOConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Configure RewardsEligibilityOracleA (params + roles) + * + * Deployer executes directly (has GOVERNOR_ROLE from deploy). + * If deployer doesn't have the role, skips — upgrade step handles it. + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleA, + DeploymentActions.CONFIGURE, + async (env) => { + const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracleA]) + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + + const deployerRole = await checkREORole(client, reo.address, 'GOVERNOR_ROLE', deployer) + if (!deployerRole.hasRole) { + env.showMessage( + `\n ○ ${Contracts.issuance.RewardsEligibilityOracleA.name}: deployer does not have GOVERNOR_ROLE — skipping\n`, + ) + return + } + + await applyConfiguration(env, client, await getREOConditions(env), { + contractName: Contracts.issuance.RewardsEligibilityOracleA.name, + contractAddress: reo.address, + canExecuteDirectly: true, + executor: deployer, + }) + }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/a/05_transfer_governance.ts b/packages/deployment/deploy/rewards/eligibility/a/05_transfer_governance.ts new file mode 100644 index 000000000..e09593859 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/05_transfer_governance.ts @@ -0,0 +1,45 @@ +import { applyConfiguration, checkConfigurationStatus } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { getREOConditions, getREOTransferGovernanceConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContracts, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer governance of RewardsEligibilityOracleA + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleA, + DeploymentActions.TRANSFER, + async (env) => { + const deployer = requireDeployer(env) + const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracleA]) + const client = graph.getPublicClient(env) as PublicClient + + // 1. Verify preconditions (same conditions as step 4) + env.showMessage(`\n📋 Verifying ${Contracts.issuance.RewardsEligibilityOracleA.name} configuration...\n`) + const status = await checkConfigurationStatus(client, reo.address, await getREOConditions(env)) + for (const r of status.conditions) env.showMessage(` ${r.message}`) + if (!status.allOk) { + env.showMessage('\n ○ Configuration incomplete — skipping transfer\n') + return + } + + // 2. Apply: revoke deployer's GOVERNOR_ROLE + await applyConfiguration(env, client, getREOTransferGovernanceConditions(deployer), { + contractName: `${Contracts.issuance.RewardsEligibilityOracleA.name}-transfer-governance`, + contractAddress: reo.address, + canExecuteDirectly: true, + executor: deployer, + }) + + // 3. Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.RewardsEligibilityOracleA) + }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/a/09_end.ts b/packages/deployment/deploy/rewards/eligibility/a/09_end.ts new file mode 100644 index 000000000..dd53f54ec --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.RewardsEligibilityOracleA) diff --git a/packages/deployment/deploy/rewards/eligibility/a/10_status.ts b/packages/deployment/deploy/rewards/eligibility/a/10_status.ts new file mode 100644 index 000000000..a42b58304 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/a/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.issuance.RewardsEligibilityOracleA) diff --git a/packages/deployment/deploy/rewards/eligibility/b/01_deploy.ts b/packages/deployment/deploy/rewards/eligibility/b/01_deploy.ts new file mode 100644 index 000000000..c360d882a --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/01_deploy.ts @@ -0,0 +1,12 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { requireDeployer, requireGraphToken } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createProxyDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createProxyDeployModule( + Contracts.issuance.RewardsEligibilityOracleB, + (env) => ({ + constructorArgs: [requireGraphToken(env).address], + initializeArgs: [requireDeployer(env)], + }), + { prerequisites: [Contracts.horizon.L2GraphToken] }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/b/02_upgrade.ts b/packages/deployment/deploy/rewards/eligibility/b/02_upgrade.ts new file mode 100644 index 000000000..1863d2847 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.issuance.RewardsEligibilityOracleB) diff --git a/packages/deployment/deploy/rewards/eligibility/b/04_configure.ts b/packages/deployment/deploy/rewards/eligibility/b/04_configure.ts new file mode 100644 index 000000000..e06307f45 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/04_configure.ts @@ -0,0 +1,39 @@ +import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { checkREORole, getREOConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContracts, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Configure RewardsEligibilityOracleB (params + roles) + * + * Deployer executes directly (has GOVERNOR_ROLE from deploy). + * If deployer doesn't have the role, skips — upgrade step handles it. + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleB, + DeploymentActions.CONFIGURE, + async (env) => { + const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracleB]) + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + + const deployerRole = await checkREORole(client, reo.address, 'GOVERNOR_ROLE', deployer) + if (!deployerRole.hasRole) { + env.showMessage( + `\n ○ ${Contracts.issuance.RewardsEligibilityOracleB.name}: deployer does not have GOVERNOR_ROLE — skipping\n`, + ) + return + } + + await applyConfiguration(env, client, await getREOConditions(env), { + contractName: Contracts.issuance.RewardsEligibilityOracleB.name, + contractAddress: reo.address, + canExecuteDirectly: true, + executor: deployer, + }) + }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/b/05_transfer_governance.ts b/packages/deployment/deploy/rewards/eligibility/b/05_transfer_governance.ts new file mode 100644 index 000000000..87bcb281e --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/05_transfer_governance.ts @@ -0,0 +1,45 @@ +import { applyConfiguration, checkConfigurationStatus } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { getREOConditions, getREOTransferGovernanceConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContracts, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer governance of RewardsEligibilityOracleB + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleB, + DeploymentActions.TRANSFER, + async (env) => { + const deployer = requireDeployer(env) + const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracleB]) + const client = graph.getPublicClient(env) as PublicClient + + // 1. Verify preconditions (same conditions as step 4) + env.showMessage(`\n📋 Verifying ${Contracts.issuance.RewardsEligibilityOracleB.name} configuration...\n`) + const status = await checkConfigurationStatus(client, reo.address, await getREOConditions(env)) + for (const r of status.conditions) env.showMessage(` ${r.message}`) + if (!status.allOk) { + env.showMessage('\n ○ Configuration incomplete — skipping transfer\n') + return + } + + // 2. Apply: revoke deployer's GOVERNOR_ROLE + await applyConfiguration(env, client, getREOTransferGovernanceConditions(deployer), { + contractName: `${Contracts.issuance.RewardsEligibilityOracleB.name}-transfer-governance`, + contractAddress: reo.address, + canExecuteDirectly: true, + executor: deployer, + }) + + // 3. Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.RewardsEligibilityOracleB) + }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/b/09_end.ts b/packages/deployment/deploy/rewards/eligibility/b/09_end.ts new file mode 100644 index 000000000..3a11b891a --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.RewardsEligibilityOracleB) diff --git a/packages/deployment/deploy/rewards/eligibility/b/10_status.ts b/packages/deployment/deploy/rewards/eligibility/b/10_status.ts new file mode 100644 index 000000000..f8a4d48a8 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/b/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.issuance.RewardsEligibilityOracleB) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/01_deploy.ts b/packages/deployment/deploy/rewards/eligibility/mock/01_deploy.ts new file mode 100644 index 000000000..0d687127c --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/01_deploy.ts @@ -0,0 +1,12 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { requireDeployer, requireGraphToken } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createProxyDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createProxyDeployModule( + Contracts.issuance.RewardsEligibilityOracleMock, + (env) => ({ + constructorArgs: [requireGraphToken(env).address], + initializeArgs: [requireDeployer(env)], + }), + { prerequisites: [Contracts.horizon.L2GraphToken] }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/02_upgrade.ts b/packages/deployment/deploy/rewards/eligibility/mock/02_upgrade.ts new file mode 100644 index 000000000..74e2374b8 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts.issuance.RewardsEligibilityOracleMock) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/05_transfer_governance.ts b/packages/deployment/deploy/rewards/eligibility/mock/05_transfer_governance.ts new file mode 100644 index 000000000..6be92ce32 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/05_transfer_governance.ts @@ -0,0 +1,39 @@ +import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { getREOTransferGovernanceConditions } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContracts, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer governance of MockRewardsEligibilityOracle + * + * Revokes deployer's GOVERNOR_ROLE and transfers ProxyAdmin ownership + * to the protocol governor. + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleMock, + DeploymentActions.TRANSFER, + async (env) => { + const deployer = requireDeployer(env) + const [reo] = requireContracts(env, [Contracts.issuance.RewardsEligibilityOracleMock]) + const client = graph.getPublicClient(env) as PublicClient + + // Revoke deployer's GOVERNOR_ROLE + await applyConfiguration(env, client, getREOTransferGovernanceConditions(deployer), { + contractName: `${Contracts.issuance.RewardsEligibilityOracleMock.name}-transfer-governance`, + contractAddress: reo.address, + canExecuteDirectly: true, + executor: deployer, + }) + + // Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.RewardsEligibilityOracleMock) + }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/06_integrate.ts b/packages/deployment/deploy/rewards/eligibility/mock/06_integrate.ts new file mode 100644 index 000000000..f611f30c9 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/06_integrate.ts @@ -0,0 +1,36 @@ +import { applyConfiguration } from '@graphprotocol/deployment/lib/apply-configuration.js' +import { createRMIntegrationCondition } from '@graphprotocol/deployment/lib/contract-checks.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Integrate MockRewardsEligibilityOracle with RewardsManager (testnet only) + * + * Points RewardsManager at the mock so indexers can control their own eligibility. + */ +export default createActionModule( + Contracts.issuance.RewardsEligibilityOracleMock, + DeploymentActions.INTEGRATE, + async (env) => { + const [reo, rm] = requireContracts(env, [ + Contracts.issuance.RewardsEligibilityOracleMock, + Contracts.horizon.RewardsManager, + ]) + const client = graph.getPublicClient(env) as PublicClient + + const { governor, canSign } = await canSignAsGovernor(env) + + await applyConfiguration(env, client, [createRMIntegrationCondition(reo.address)], { + contractName: `${Contracts.horizon.RewardsManager.name}-REO`, + contractAddress: rm.address, + canExecuteDirectly: canSign, + executor: governor, + }) + }, + { extraDependencies: [ComponentTags.REWARDS_MANAGER] }, +) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/09_end.ts b/packages/deployment/deploy/rewards/eligibility/mock/09_end.ts new file mode 100644 index 000000000..98cacd97f --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts.issuance.RewardsEligibilityOracleMock) diff --git a/packages/deployment/deploy/rewards/eligibility/mock/10_status.ts b/packages/deployment/deploy/rewards/eligibility/mock/10_status.ts new file mode 100644 index 000000000..611316b02 --- /dev/null +++ b/packages/deployment/deploy/rewards/eligibility/mock/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.issuance.RewardsEligibilityOracleMock) diff --git a/packages/deployment/deploy/rewards/manager/01_deploy.ts b/packages/deployment/deploy/rewards/manager/01_deploy.ts index 3d72bc314..2223ce0ed 100644 --- a/packages/deployment/deploy/rewards/manager/01_deploy.ts +++ b/packages/deployment/deploy/rewards/manager/01_deploy.ts @@ -1,21 +1,4 @@ -import { deployImplementation, getImplementationConfig } from '@graphprotocol/deployment/lib/deploy-implementation.js' -import { SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createImplementationDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' -// RewardsManager Implementation Deployment -// -// Deploys a new RewardsManager implementation if artifact bytecode differs from on-chain. -// -// Workflow: -// 1. Compare artifact bytecode with on-chain bytecode (accounting for immutables) -// 2. If different, deploy new implementation -// 3. Store as "pendingImplementation" in horizon/addresses.json -// 4. Upgrade task (separate) handles TX generation and execution - -const func: DeployScriptModule = async (env) => { - await deployImplementation(env, getImplementationConfig('horizon', 'RewardsManager')) -} - -func.tags = Tags.rewardsManagerDeploy -func.dependencies = [SpecialTags.SYNC] -export default func +export default createImplementationDeployModule(Contracts.horizon.RewardsManager) diff --git a/packages/deployment/deploy/rewards/manager/02_upgrade.ts b/packages/deployment/deploy/rewards/manager/02_upgrade.ts index effed5fe9..5c888723b 100644 --- a/packages/deployment/deploy/rewards/manager/02_upgrade.ts +++ b/packages/deployment/deploy/rewards/manager/02_upgrade.ts @@ -1,26 +1,4 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { ComponentTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' -// RewardsManager Upgrade -// -// Generates governance TX batch and executes upgrade. -// -// Workflow: -// 1. Check for pending implementation in address book -// 2. Generate governance TX (upgrade + acceptProxy) -// 3. Fork mode: execute via governor impersonation -// 4. Production: output TX file for Safe execution -// -// Usage: -// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags rewards-manager-upgrade --network localhost - -const func: DeployScriptModule = async (env) => { - await upgradeImplementation(env, Contracts.horizon.RewardsManager) -} - -func.tags = Tags.rewardsManagerUpgrade -func.dependencies = [ComponentTags.REWARDS_MANAGER_DEPLOY] - -export default func +export default createUpgradeModule(Contracts.horizon.RewardsManager) diff --git a/packages/deployment/deploy/rewards/manager/09_end.ts b/packages/deployment/deploy/rewards/manager/09_end.ts index d07b4cee5..ae4996ffd 100644 --- a/packages/deployment/deploy/rewards/manager/09_end.ts +++ b/packages/deployment/deploy/rewards/manager/09_end.ts @@ -1,19 +1,4 @@ -import { ComponentTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' -/** - * RewardsManager end state - deployed and upgraded - * - * Usage: - * pnpm hardhat deploy --tags rewards-manager --network - */ -const func: DeployScriptModule = async (env) => { - requireUpgradeExecuted(env, 'RewardsManager') - env.showMessage(`\n✓ RewardsManager ready`) -} - -func.tags = Tags.rewardsManager -func.dependencies = [ComponentTags.REWARDS_MANAGER_DEPLOY, ComponentTags.REWARDS_MANAGER_UPGRADE] - -export default func +export default createEndModule(Contracts.horizon.RewardsManager) diff --git a/packages/deployment/deploy/rewards/manager/10_status.ts b/packages/deployment/deploy/rewards/manager/10_status.ts new file mode 100644 index 000000000..4b47d40bb --- /dev/null +++ b/packages/deployment/deploy/rewards/manager/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts.horizon.RewardsManager) diff --git a/packages/deployment/deploy/rewards/reclaim/01_deploy.ts b/packages/deployment/deploy/rewards/reclaim/01_deploy.ts index 520eef497..3ee161636 100644 --- a/packages/deployment/deploy/rewards/reclaim/01_deploy.ts +++ b/packages/deployment/deploy/rewards/reclaim/01_deploy.ts @@ -1,50 +1,45 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { ComponentTags, SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { deployProxyContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { deployProxyContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' import type { DeployScriptModule } from '@rocketh/core/types' /** - * Deploy DirectAllocation proxies as reclaim addresses + * Deploy DirectAllocation proxy as default reclaim address * - * This script deploys DirectAllocation proxy instances for each reclaim reason. - * All proxies share the DirectAllocation_Implementation deployed by direct-allocation-impl. + * This script deploys a single DirectAllocation proxy instance used as the + * default reclaim address on RewardsManager for all reclaim reasons. + * The proxy uses the DirectAllocation_Implementation deployed by direct-allocation-impl. * * Deployed contracts: - * - ReclaimedRewardsForIndexerIneligible - * - ReclaimedRewardsForSubgraphDenied - * - ReclaimedRewardsForStalePoi - * - ReclaimedRewardsForZeroPoi - * - ReclaimedRewardsForCloseAllocation + * - ReclaimedRewards * * Usage: - * pnpm hardhat deploy --tags rewards-reclaim-deploy --network + * pnpm hardhat deploy --tags RewardsReclaim:deploy --network */ -// Reclaim contracts that share DirectAllocation implementation -const RECLAIM_CONTRACTS = [ - Contracts.issuance.ReclaimedRewardsForIndexerIneligible, - Contracts.issuance.ReclaimedRewardsForSubgraphDenied, - Contracts.issuance.ReclaimedRewardsForStalePoi, - Contracts.issuance.ReclaimedRewardsForZeroPoi, - Contracts.issuance.ReclaimedRewardsForCloseAllocation, -] as const - const func: DeployScriptModule = async (env) => { - env.showMessage(`\n📦 Deploying DirectAllocation reclaim address proxies...`) + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [ + Contracts.issuance.DirectAllocation_Implementation, + Contracts.horizon.RewardsManager, + Contracts.issuance.ReclaimedRewards, + ]) + + env.showMessage(`\n📦 Deploying DirectAllocation reclaim address proxy...`) env.showMessage(` Shared implementation: ${Contracts.issuance.DirectAllocation_Implementation.name}`) - for (const contract of RECLAIM_CONTRACTS) { - await deployProxyContract(env, { - contract, - sharedImplementation: Contracts.issuance.DirectAllocation_Implementation, - // initializeArgs defaults to [governor] - }) - } + await deployProxyContract(env, { + contract: Contracts.issuance.ReclaimedRewards, + sharedImplementation: Contracts.issuance.DirectAllocation_Implementation, + initializeArgs: [requireDeployer(env)], + }) - env.showMessage('\n✓ Reclaim addresses deployment complete') + env.showMessage('\n✓ Reclaim address deployment complete') } -func.tags = Tags.rewardsReclaimDeploy -func.dependencies = [SpecialTags.SYNC, ComponentTags.DIRECT_ALLOCATION_IMPL, ComponentTags.REWARDS_MANAGER] +func.tags = [ComponentTags.REWARDS_RECLAIM] +func.dependencies = [ComponentTags.DIRECT_ALLOCATION_IMPL, ComponentTags.REWARDS_MANAGER] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) export default func diff --git a/packages/deployment/deploy/rewards/reclaim/02_upgrade.ts b/packages/deployment/deploy/rewards/reclaim/02_upgrade.ts index 7fa17437f..bc27987a0 100644 --- a/packages/deployment/deploy/rewards/reclaim/02_upgrade.ts +++ b/packages/deployment/deploy/rewards/reclaim/02_upgrade.ts @@ -1,43 +1,36 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' import type { DeployScriptModule } from '@rocketh/core/types' // ReclaimedRewards Upgrade // -// Upgrades ReclaimedRewardsFor* proxies to DirectAllocation implementation via per-proxy ProxyAdmin. -// The implementation is shared across multiple allocation proxies. +// Upgrades ReclaimedRewards proxy to DirectAllocation implementation via per-proxy ProxyAdmin. // // Workflow: // 1. Check for pending implementation in address book (set by direct-allocation-impl) -// 2. Generate governance TX (upgradeAndCall to per-proxy ProxyAdmin) for each proxy +// 2. Generate governance TX (upgradeAndCall to per-proxy ProxyAdmin) // 3. Fork mode: execute via governor impersonation // 4. Production: output TX file for Safe execution // // Usage: -// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags rewards-reclaim-upgrade --network localhost - -// Reclaim contracts that share DirectAllocation implementation -const RECLAIM_CONTRACTS = [ - Contracts.issuance.ReclaimedRewardsForIndexerIneligible, - Contracts.issuance.ReclaimedRewardsForSubgraphDenied, - Contracts.issuance.ReclaimedRewardsForStalePoi, - Contracts.issuance.ReclaimedRewardsForZeroPoi, - Contracts.issuance.ReclaimedRewardsForCloseAllocation, -] as const +// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags RewardsReclaim:upgrade --network localhost const func: DeployScriptModule = async (env) => { - for (const contract of RECLAIM_CONTRACTS) { - await upgradeImplementation(env, contract, { - implementationName: 'DirectAllocation', - }) - } + if (shouldSkipAction(DeploymentActions.UPGRADE)) return + await syncComponentsFromRegistry(env, [ + Contracts.issuance.DirectAllocation_Implementation, + Contracts.issuance.ReclaimedRewards, + ]) + await upgradeImplementation(env, Contracts.issuance.ReclaimedRewards, { + implementationName: 'DirectAllocation', + }) + await syncComponentsFromRegistry(env, [Contracts.issuance.ReclaimedRewards]) } -func.tags = Tags.rewardsReclaimUpgrade -func.dependencies = [ - actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.DEPLOY), - ComponentTags.DIRECT_ALLOCATION_IMPL, -] +func.tags = [ComponentTags.REWARDS_RECLAIM] +func.dependencies = [ComponentTags.DIRECT_ALLOCATION_IMPL] +func.skip = async () => shouldSkipAction(DeploymentActions.UPGRADE) export default func diff --git a/packages/deployment/deploy/rewards/reclaim/04_configure.ts b/packages/deployment/deploy/rewards/reclaim/04_configure.ts index e545cd970..ad1afee4d 100644 --- a/packages/deployment/deploy/rewards/reclaim/04_configure.ts +++ b/packages/deployment/deploy/rewards/reclaim/04_configure.ts @@ -1,145 +1,144 @@ -import { REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' -import { - getReclaimAddress, - RECLAIM_CONTRACT_NAMES, - RECLAIM_REASONS, - type ReclaimReasonKey, -} from '@graphprotocol/deployment/lib/contract-checks.js' +import { ACCESS_CONTROL_ENUMERABLE_ABI, REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { createGovernanceTxBuilder } from '@graphprotocol/deployment/lib/execute-governance.js' -import { requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { execute, graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { ComponentTags, DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { requireContract, requireDeployer } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkReclaimConfigured } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { graph, read, tx } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' import { encodeFunctionData } from 'viem' /** - * Configure RewardsManager with reclaim addresses + * Configure ReclaimedRewards — role grants only * - * Sets the reclaim addresses on RewardsManager for token recovery. - * This requires RewardsManager to be upgraded (governance operation). + * Grants GOVERNOR_ROLE to protocol governor and PAUSE_ROLE to pause guardian. + * Deployer executes directly (has GOVERNOR_ROLE from deploy). + * If deployer doesn't have the role, skips — upgrade step handles it. * - * Configured reasons: - * - INDEXER_INELIGIBLE → ReclaimedRewardsForIndexerIneligible - * - SUBGRAPH_DENIED → ReclaimedRewardsForSubgraphDenied - * - STALE_POI → ReclaimedRewardsForStalePoi - * - ZERO_POI → ReclaimedRewardsForZeroPoi - * - CLOSE_ALLOCATION → ReclaimedRewardsForCloseAllocation - * - * Idempotent: checks if already configured, skips if so. - * Generates Safe TX batch if direct execution fails. + * RM.setDefaultReclaimAddress is a governance TX bundled in the upgrade step. * * Usage: - * pnpm hardhat deploy --tags rewards-reclaim-configure --network + * pnpm hardhat deploy --tags RewardsReclaim:configure --network */ -const func: DeployScriptModule = async (env) => { - const executeFn = execute(env) - const client = graph.getPublicClient(env) - - // Get protocol governor from Controller - const governor = await getGovernor(env) - - const rewardsManager = requireContract(env, Contracts.horizon.RewardsManager) - - env.showMessage(`\n========== Configure ${Contracts.horizon.RewardsManager.name} Reclaim ==========`) - env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rewardsManager.address}`) - - // Find deployed reclaim addresses - const reclaimAddresses: { name: string; address: string; reasonKey: ReclaimReasonKey }[] = [] - - for (const [reasonKey, contractName] of Object.entries(RECLAIM_CONTRACT_NAMES)) { - const deployment = env.getOrNull(contractName) - if (deployment) { - reclaimAddresses.push({ - name: contractName, - address: deployment.address, - reasonKey: reasonKey as ReclaimReasonKey, - }) - } - } - - if (reclaimAddresses.length === 0) { - env.showMessage(`\n⚠️ No reclaim addresses deployed, skipping configuration`) - return - } - - env.showMessage(`\nFound ${reclaimAddresses.length} reclaim address(es):`) - for (const { name, address } of reclaimAddresses) { - env.showMessage(` ${name}: ${address}`) - } - - // Check current configuration - const needsConfiguration: typeof reclaimAddresses = [] - - for (const reclaim of reclaimAddresses) { - const reason = RECLAIM_REASONS[reclaim.reasonKey] - - // Check if RM has this reclaim address configured for this reason - const currentReclaim = await getReclaimAddress(client, rewardsManager.address, reason) - if (currentReclaim && currentReclaim.toLowerCase() === reclaim.address.toLowerCase()) { - env.showMessage(`\n✓ ${reclaim.name} already configured on RewardsManager`) - continue +export default createActionModule( + Contracts.issuance.ReclaimedRewards, + DeploymentActions.CONFIGURE, + async (env) => { + const client = graph.getPublicClient(env) as PublicClient + const readFn = read(env) + const deployer = requireDeployer(env) + const governor = await getGovernor(env) + const pauseGuardian = await getPauseGuardian(env) + + const rewardsManager = requireContract(env, Contracts.horizon.RewardsManager) + const reclaimedRewards = requireContract(env, Contracts.issuance.ReclaimedRewards) + + env.showMessage(`\n========== Configure ${Contracts.issuance.ReclaimedRewards.name} ==========`) + env.showMessage(`ReclaimedRewards: ${reclaimedRewards.address}`) + + // Check if fully configured (shared precondition check) + const precondition = await checkReclaimConfigured( + client, + rewardsManager.address, + reclaimedRewards.address, + governor, + pauseGuardian, + ) + if (precondition.done) { + env.showMessage(`\n✅ ${Contracts.issuance.ReclaimedRewards.name} already configured\n`) + return } - needsConfiguration.push(reclaim) - } - - if (needsConfiguration.length === 0) { - env.showMessage(`\n✓ All reclaim addresses already configured`) - return - } - - // Build TX batch - env.showMessage(`\n🔨 Building configuration TX batch...`) - - const builder = await createGovernanceTxBuilder(env, `configure-${Contracts.horizon.RewardsManager.name}-Reclaim`) - - for (const reclaim of needsConfiguration) { - const reason = RECLAIM_REASONS[reclaim.reasonKey] + // Check role grants + env.showMessage('\n📋 Checking configuration...\n') + + const GOVERNOR_ROLE = (await readFn(reclaimedRewards, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + const PAUSE_ROLE = (await readFn(reclaimedRewards, { functionName: 'PAUSE_ROLE' })) as `0x${string}` + + const governorHasRole = (await client.readContract({ + address: reclaimedRewards.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + })) as boolean + env.showMessage(` Governor GOVERNOR_ROLE: ${governorHasRole ? '✓' : '✗'}`) + + const pauseGuardianHasRole = (await client.readContract({ + address: reclaimedRewards.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + })) as boolean + env.showMessage(` PauseGuardian PAUSE_ROLE: ${pauseGuardianHasRole ? '✓' : '✗'}`) + + // RM integration status (informational — handled by upgrade step) try { - const data = encodeFunctionData({ + const currentDefault = (await client.readContract({ + address: rewardsManager.address as `0x${string}`, abi: REWARDS_MANAGER_ABI, - functionName: 'setReclaimAddress', - args: [reason as `0x${string}`, reclaim.address as `0x${string}`], - }) - builder.addTx({ to: rewardsManager.address, value: '0', data }) - env.showMessage(` + setReclaimAddress(${reclaim.reasonKey}, ${reclaim.address})`) + functionName: 'getDefaultReclaimAddress', + })) as string + const rmOk = currentDefault.toLowerCase() === reclaimedRewards.address.toLowerCase() + env.showMessage(` RM default reclaim: ${rmOk ? '✓' : '○ will be set in upgrade step (governance TX)'}`) } catch { - env.showMessage(` ⚠️ setReclaimAddress not available on RewardsManager interface`) - return + env.showMessage(` RM default reclaim: ○ RM not upgraded — will be set in upgrade step`) } - } - const txFile = builder.saveToFile() - env.showMessage(`\n✓ TX batch saved: ${txFile}`) + // Execute role grants as deployer + const deployerHasRole = (await client.readContract({ + address: reclaimedRewards.address as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [GOVERNOR_ROLE, deployer as `0x${string}`], + })) as boolean + + if (!deployerHasRole) { + env.showMessage( + `\n ○ Deployer does not have GOVERNOR_ROLE — skipping role grants (governance TX in upgrade step)\n`, + ) + return + } - // Try direct execution - env.showMessage(`\n🔐 Attempting direct execution...`) - try { - for (const reclaim of needsConfiguration) { - const reason = RECLAIM_REASONS[reclaim.reasonKey] + const txs: Array<{ to: string; data: `0x${string}`; label: string }> = [] + + if (!governorHasRole) { + txs.push({ + to: reclaimedRewards.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [GOVERNOR_ROLE, governor as `0x${string}`], + }), + label: `grantRole(GOVERNOR_ROLE, ${governor})`, + }) + } - await executeFn(rewardsManager, { - account: governor, - functionName: 'setReclaimAddress', - args: [reason, reclaim.address], + if (!pauseGuardianHasRole) { + txs.push({ + to: reclaimedRewards.address, + data: encodeFunctionData({ + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'grantRole', + args: [PAUSE_ROLE, pauseGuardian as `0x${string}`], + }), + label: `grantRole(PAUSE_ROLE, ${pauseGuardian})`, }) - env.showMessage(` ✓ setReclaimAddress(${reclaim.reasonKey}, ${reclaim.address}) executed`) } - env.showMessage(`\n✅ ${Contracts.horizon.RewardsManager.name} reclaim configuration complete!`) - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - env.showMessage(`\n⚠️ Direct execution failed: ${errorMessage.slice(0, 100)}...`) - env.showMessage(`\n📋 GOVERNANCE ACTION REQUIRED:`) - env.showMessage(` The ${Contracts.horizon.RewardsManager.name} reclaim configuration must be executed via Safe.`) - env.showMessage(` TX batch file: ${txFile}`) - env.showMessage(` Import this file into Safe Transaction Builder.`) - } -} - -func.tags = Tags.rewardsReclaimConfigure -func.dependencies = [actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.UPGRADE), ComponentTags.REWARDS_MANAGER] - -export default func + if (txs.length > 0) { + env.showMessage('\n🔨 Executing role grants as deployer...\n') + const txFn = tx(env) + for (const t of txs) { + await txFn({ account: deployer, to: t.to as `0x${string}`, data: t.data }) + env.showMessage(` ✓ ${t.label}`) + } + } + + env.showMessage(`\n✅ ${Contracts.issuance.ReclaimedRewards.name} role grants complete\n`) + }, + { + extraDependencies: [ComponentTags.REWARDS_MANAGER], + prerequisites: [Contracts.horizon.RewardsManager], + }, +) diff --git a/packages/deployment/deploy/rewards/reclaim/05_transfer_governance.ts b/packages/deployment/deploy/rewards/reclaim/05_transfer_governance.ts new file mode 100644 index 000000000..bdcd728b2 --- /dev/null +++ b/packages/deployment/deploy/rewards/reclaim/05_transfer_governance.ts @@ -0,0 +1,56 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { + requireContract, + requireDeployer, + transferProxyAdminOwnership, +} from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' +import { checkDeployerRevoked } from '@graphprotocol/deployment/lib/preconditions.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { execute, graph, read } from '@graphprotocol/deployment/rocketh/deploy.js' +import type { PublicClient } from 'viem' + +/** + * Transfer ReclaimedRewards governance from deployer + * + * - Revoke GOVERNOR_ROLE from deployment account + * - Transfer ProxyAdmin ownership to governor + * + * Role grants (GOVERNOR_ROLE, PAUSE_ROLE) happen in 04_configure.ts. + * This script only revokes deployer access. + * + * Idempotent: checks on-chain state, skips if already transferred. + * + * Usage: + * pnpm hardhat deploy --tags RewardsReclaim,transfer --network + */ +export default createActionModule(Contracts.issuance.ReclaimedRewards, DeploymentActions.TRANSFER, async (env) => { + const readFn = read(env) + const executeFn = execute(env) + const client = graph.getPublicClient(env) as PublicClient + const deployer = requireDeployer(env) + const reclaim = requireContract(env, Contracts.issuance.ReclaimedRewards) + + env.showMessage(`\n========== Transfer ${Contracts.issuance.ReclaimedRewards.name} ==========`) + + // Check if deployer GOVERNOR_ROLE already revoked (shared precondition check) + const precondition = await checkDeployerRevoked(client, reclaim.address, deployer) + if (precondition.done) { + env.showMessage(`✓ Deployer GOVERNOR_ROLE already revoked`) + } else { + const GOVERNOR_ROLE = (await readFn(reclaim, { functionName: 'GOVERNOR_ROLE' })) as `0x${string}` + + env.showMessage(`🔨 Revoking deployer GOVERNOR_ROLE...`) + await executeFn(reclaim, { + account: deployer, + functionName: 'revokeRole', + args: [GOVERNOR_ROLE, deployer], + }) + env.showMessage(` ✓ revokeRole(GOVERNOR_ROLE) executed`) + } + + // Transfer ProxyAdmin ownership to governor + await transferProxyAdminOwnership(env, Contracts.issuance.ReclaimedRewards) + + env.showMessage(`\n✅ ${Contracts.issuance.ReclaimedRewards.name} governance transferred!\n`) +}) diff --git a/packages/deployment/deploy/rewards/reclaim/09_end.ts b/packages/deployment/deploy/rewards/reclaim/09_end.ts index 5043dfde4..46d6aa2dc 100644 --- a/packages/deployment/deploy/rewards/reclaim/09_end.ts +++ b/packages/deployment/deploy/rewards/reclaim/09_end.ts @@ -1,32 +1,4 @@ -import { RECLAIM_CONTRACT_NAMES } from '@graphprotocol/deployment/lib/contract-checks.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' -/** - * RewardsReclaim end state - deployed, upgraded, and configured - * - * Aggregate tag that ensures ReclaimedRewardsFor* contracts are fully ready: - * - Proxies and shared implementation deployed - * - Proxies upgraded to latest implementation - * - Configured on RewardsManager - * - * Usage: - * pnpm hardhat deploy --tags rewards-reclaim --network - */ -const func: DeployScriptModule = async (env) => { - // Check all reclaim address proxies for pending upgrades - for (const contractName of Object.values(RECLAIM_CONTRACT_NAMES)) { - requireUpgradeExecuted(env, contractName) - } - env.showMessage(`\n✓ RewardsReclaim ready`) -} - -func.tags = Tags.rewardsReclaim -func.dependencies = [ - actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.DEPLOY), - actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.UPGRADE), - actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.CONFIGURE), -] - -export default func +export default createEndModule(Contracts.issuance.ReclaimedRewards) diff --git a/packages/deployment/deploy/rewards/reclaim/10_status.ts b/packages/deployment/deploy/rewards/reclaim/10_status.ts new file mode 100644 index 000000000..c5f778ac9 --- /dev/null +++ b/packages/deployment/deploy/rewards/reclaim/10_status.ts @@ -0,0 +1,14 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { ComponentTags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' +import { showDetailedComponentStatus } from '@graphprotocol/deployment/lib/status-detail.js' + +/** + * RewardsReclaim status - show detailed state of reclaim contract + * + * Usage: + * pnpm hardhat deploy --tags RewardsReclaim --network + */ +export default createStatusModule(ComponentTags.REWARDS_RECLAIM, async (env) => { + await showDetailedComponentStatus(env, Contracts.issuance.ReclaimedRewards) +}) diff --git a/packages/deployment/deploy/service/dispute/01_deploy.ts b/packages/deployment/deploy/service/dispute/01_deploy.ts new file mode 100644 index 000000000..3158750b9 --- /dev/null +++ b/packages/deployment/deploy/service/dispute/01_deploy.ts @@ -0,0 +1,12 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createImplementationDeployModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createImplementationDeployModule( + Contracts['subgraph-service'].DisputeManager, + (env) => { + const controller = env.getOrNull('Controller') + if (!controller) throw new Error('Missing Controller deployment after sync.') + return [controller.address] + }, + { prerequisites: [Contracts.horizon.Controller] }, +) diff --git a/packages/deployment/deploy/service/dispute/02_upgrade.ts b/packages/deployment/deploy/service/dispute/02_upgrade.ts new file mode 100644 index 000000000..99c75d9e3 --- /dev/null +++ b/packages/deployment/deploy/service/dispute/02_upgrade.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createUpgradeModule(Contracts['subgraph-service'].DisputeManager) diff --git a/packages/deployment/deploy/service/dispute/09_end.ts b/packages/deployment/deploy/service/dispute/09_end.ts new file mode 100644 index 000000000..5a1afb1a4 --- /dev/null +++ b/packages/deployment/deploy/service/dispute/09_end.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createEndModule(Contracts['subgraph-service'].DisputeManager) diff --git a/packages/deployment/deploy/service/dispute/10_status.ts b/packages/deployment/deploy/service/dispute/10_status.ts new file mode 100644 index 000000000..1039074c0 --- /dev/null +++ b/packages/deployment/deploy/service/dispute/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts['subgraph-service'].DisputeManager) diff --git a/packages/deployment/deploy/service/subgraph/01_deploy.ts b/packages/deployment/deploy/service/subgraph/01_deploy.ts index e90a2dbef..ff1b46b95 100644 --- a/packages/deployment/deploy/service/subgraph/01_deploy.ts +++ b/packages/deployment/deploy/service/subgraph/01_deploy.ts @@ -1,44 +1,146 @@ -import { deployImplementation, getImplementationConfig } from '@graphprotocol/deployment/lib/deploy-implementation.js' -import { SpecialTags, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { linkArtifactLibraries } from '@graphprotocol/deployment/lib/artifact-loaders.js' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { + deployImplementation, + getImplementationConfig, + loadArtifactFromSource, +} from '@graphprotocol/deployment/lib/deploy-implementation.js' +import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' +import { deploy } from '@graphprotocol/deployment/rocketh/deploy.js' import type { DeployScriptModule } from '@rocketh/core/types' // SubgraphService Implementation Deployment // -// Deploys a new SubgraphService implementation if artifact bytecode differs from on-chain. +// SubgraphService uses external Solidity libraries that must be deployed first +// and linked into the implementation bytecode before deployment. +// +// Library dependency order: +// 1. StakeClaims (standalone, from horizon) +// 2. AllocationHandler (standalone) +// 3. IndexingAgreementDecoderRaw (standalone) +// 4. IndexingAgreementDecoder (links IndexingAgreementDecoderRaw) +// 5. IndexingAgreement (links IndexingAgreementDecoder) +// 6. SubgraphService (links all above) // // Workflow: -// 1. Compare artifact bytecode with on-chain bytecode (accounting for immutables) -// 2. If different, deploy new implementation +// 1. Deploy libraries in dependency order +// 2. Deploy SS implementation with linked libraries // 3. Store as "pendingImplementation" in subgraph-service/addresses.json // 4. Upgrade task (separate) handles TX generation and execution const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [ + Contracts.horizon.Controller, + Contracts['subgraph-service'].DisputeManager, + Contracts.horizon.GraphTallyCollector, + Contracts.horizon.L2Curation, + Contracts.horizon.RecurringCollector, + Contracts['subgraph-service'].SubgraphService, + ]) + // Get constructor args from imported deployments const controllerDep = env.getOrNull('Controller') const disputeManagerDep = env.getOrNull('DisputeManager') const graphTallyCollectorDep = env.getOrNull('GraphTallyCollector') const curationDep = env.getOrNull('L2Curation') + const recurringCollectorDep = env.getOrNull('RecurringCollector') - if (!controllerDep || !disputeManagerDep || !graphTallyCollectorDep || !curationDep) { + if (!controllerDep || !disputeManagerDep || !graphTallyCollectorDep || !curationDep || !recurringCollectorDep) { throw new Error( - 'Missing required contract deployments (Controller, DisputeManager, GraphTallyCollector, L2Curation). ' + - 'The sync step should have imported these.', + 'Missing required contract deployments after sync ' + + '(Controller, DisputeManager, GraphTallyCollector, L2Curation, RecurringCollector).', ) } - await deployImplementation( - env, - getImplementationConfig('subgraph-service', 'SubgraphService', { - constructorArgs: [ - controllerDep.address, - disputeManagerDep.address, - graphTallyCollectorDep.address, - curationDep.address, - ], - }), + // Deploy libraries in dependency order + const deployFn = deploy(env) + const deployer = env.namedAccounts.deployer + if (!deployer) throw new Error('No deployer account configured') + + env.showMessage('\n📚 Deploying SubgraphService libraries...') + + // 1. StakeClaims (from horizon, standalone) + const stakeClaimsArtifact = loadArtifactFromSource({ + type: 'horizon', + path: 'contracts/data-service/libraries/StakeClaims.sol/StakeClaims', + }) + const stakeClaims = await deployFn('StakeClaims', { + account: deployer, + artifact: stakeClaimsArtifact, + args: [], + }) + env.showMessage(` StakeClaims: ${stakeClaims.address}`) + + // 2. AllocationHandler (standalone) + const allocationHandlerArtifact = loadArtifactFromSource({ + type: 'subgraph-service', + name: 'libraries/AllocationHandler', + }) + const allocationHandler = await deployFn('AllocationHandler', { + account: deployer, + artifact: allocationHandlerArtifact, + args: [], + }) + env.showMessage(` AllocationHandler: ${allocationHandler.address}`) + + // 3. IndexingAgreementDecoderRaw (standalone) + const decoderRawArtifact = loadArtifactFromSource({ + type: 'subgraph-service', + name: 'libraries/IndexingAgreementDecoderRaw', + }) + const decoderRaw = await deployFn('IndexingAgreementDecoderRaw', { + account: deployer, + artifact: decoderRawArtifact, + args: [], + }) + env.showMessage(` IndexingAgreementDecoderRaw: ${decoderRaw.address}`) + + // 4. IndexingAgreementDecoder (links IndexingAgreementDecoderRaw) + // Pre-link libraries into artifact so rocketh stores linked bytecode + // (rocketh's bytecode comparison breaks for unlinked artifacts — see linkArtifactLibraries) + const decoderArtifact = linkArtifactLibraries( + loadArtifactFromSource({ type: 'subgraph-service', name: 'libraries/IndexingAgreementDecoder' }), + { IndexingAgreementDecoderRaw: decoderRaw.address as `0x${string}` }, + ) + const decoder = await deployFn('IndexingAgreementDecoder', { account: deployer, artifact: decoderArtifact, args: [] }) + env.showMessage(` IndexingAgreementDecoder: ${decoder.address}`) + + // 5. IndexingAgreement (links IndexingAgreementDecoder) + const indexingAgreementArtifact = linkArtifactLibraries( + loadArtifactFromSource({ type: 'subgraph-service', name: 'libraries/IndexingAgreement' }), + { IndexingAgreementDecoder: decoder.address as `0x${string}` }, ) + const indexingAgreement = await deployFn('IndexingAgreement', { + account: deployer, + artifact: indexingAgreementArtifact, + args: [], + }) + env.showMessage(` IndexingAgreement: ${indexingAgreement.address}`) + + env.showMessage(' ✓ Libraries deployed\n') + + // 6. Deploy SubgraphService implementation with all libraries linked + const config = getImplementationConfig('subgraph-service', 'SubgraphService', { + constructorArgs: [ + controllerDep.address, + disputeManagerDep.address, + graphTallyCollectorDep.address, + curationDep.address, + recurringCollectorDep.address, + ], + }) + + await deployImplementation(env, config, { + StakeClaims: stakeClaims.address, + AllocationHandler: allocationHandler.address, + IndexingAgreement: indexingAgreement.address, + IndexingAgreementDecoder: decoder.address, + }) } -func.tags = Tags.subgraphServiceDeploy -func.dependencies = [SpecialTags.SYNC] +func.tags = [ComponentTags.SUBGRAPH_SERVICE] +func.dependencies = [ComponentTags.RECURRING_COLLECTOR] +func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) export default func diff --git a/packages/deployment/deploy/service/subgraph/02_upgrade.ts b/packages/deployment/deploy/service/subgraph/02_upgrade.ts index 6f4ece5d9..1395af76c 100644 --- a/packages/deployment/deploy/service/subgraph/02_upgrade.ts +++ b/packages/deployment/deploy/service/subgraph/02_upgrade.ts @@ -1,26 +1,4 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { upgradeImplementation } from '@graphprotocol/deployment/lib/upgrade-implementation.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' -// SubgraphService Upgrade -// -// Generates governance TX batch and executes upgrade. -// -// Workflow: -// 1. Check for pending implementation in address book -// 2. Generate governance TX (upgradeAndCall) -// 3. Fork mode: execute via governor impersonation -// 4. Production: output TX file for Safe execution -// -// Usage: -// FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags subgraph-service-upgrade --network localhost - -const func: DeployScriptModule = async (env) => { - await upgradeImplementation(env, Contracts['subgraph-service'].SubgraphService) -} - -func.tags = Tags.subgraphServiceUpgrade -func.dependencies = [actionTag(ComponentTags.SUBGRAPH_SERVICE, DeploymentActions.DEPLOY)] - -export default func +export default createUpgradeModule(Contracts['subgraph-service'].SubgraphService) diff --git a/packages/deployment/deploy/service/subgraph/04_configure.ts b/packages/deployment/deploy/service/subgraph/04_configure.ts new file mode 100644 index 000000000..61dfc3f17 --- /dev/null +++ b/packages/deployment/deploy/service/subgraph/04_configure.ts @@ -0,0 +1,22 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { DeploymentActions } from '@graphprotocol/deployment/lib/deployment-tags.js' +import { createActionModule } from '@graphprotocol/deployment/lib/script-factories.js' + +/** + * Configure SubgraphService + * + * In the current contract version, RecurringCollector is set as an immutable + * constructor argument — no runtime authorization is needed. + * + * This script is a no-op placeholder for future configuration needs. + * + * Usage: + * pnpm hardhat deploy --tags SubgraphService:configure --network + */ +export default createActionModule( + Contracts['subgraph-service'].SubgraphService, + DeploymentActions.CONFIGURE, + async (env) => { + env.showMessage(`\n✅ SubgraphService: RecurringCollector is set at construction time, no configuration needed\n`) + }, +) diff --git a/packages/deployment/deploy/service/subgraph/09_end.ts b/packages/deployment/deploy/service/subgraph/09_end.ts index 0a34b344e..786490018 100644 --- a/packages/deployment/deploy/service/subgraph/09_end.ts +++ b/packages/deployment/deploy/service/subgraph/09_end.ts @@ -1,22 +1,4 @@ -import { actionTag, ComponentTags, DeploymentActions, Tags } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { requireUpgradeExecuted } from '@graphprotocol/deployment/lib/execute-governance.js' -import type { DeployScriptModule } from '@rocketh/core/types' +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createEndModule } from '@graphprotocol/deployment/lib/script-factories.js' -/** - * SubgraphService end state - deployed and upgraded - * - * Usage: - * pnpm hardhat deploy --tags subgraph-service --network - */ -const func: DeployScriptModule = async (env) => { - requireUpgradeExecuted(env, 'SubgraphService') - env.showMessage(`\n✓ SubgraphService ready`) -} - -func.tags = Tags.subgraphService -func.dependencies = [ - actionTag(ComponentTags.SUBGRAPH_SERVICE, DeploymentActions.DEPLOY), - actionTag(ComponentTags.SUBGRAPH_SERVICE, DeploymentActions.UPGRADE), -] - -export default func +export default createEndModule(Contracts['subgraph-service'].SubgraphService) diff --git a/packages/deployment/deploy/service/subgraph/10_status.ts b/packages/deployment/deploy/service/subgraph/10_status.ts new file mode 100644 index 000000000..aa66de54e --- /dev/null +++ b/packages/deployment/deploy/service/subgraph/10_status.ts @@ -0,0 +1,4 @@ +import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' + +export default createStatusModule(Contracts['subgraph-service'].SubgraphService) diff --git a/packages/deployment/docs/Architecture.md b/packages/deployment/docs/Architecture.md index 4486b7afb..2704a722f 100644 --- a/packages/deployment/docs/Architecture.md +++ b/packages/deployment/docs/Architecture.md @@ -12,27 +12,32 @@ Unified deployment package for Graph Protocol contracts. ``` packages/deployment/ -├── deploy/ # hardhat-deploy scripts -│ ├── common/ # Validation, imports -│ ├── issuance/ # Issuance contracts -│ ├── contracts/ # Core protocol (RewardsManager) -│ └── subgraph-service/ # SubgraphService +├── deploy/ # hardhat-deploy / rocketh scripts +│ ├── common/ # 00_sync.ts +│ ├── horizon/ # RM, HS, PE, L2Curation, RC +│ ├── service/ # SubgraphService, DisputeManager +│ ├── allocate/ # IssuanceAllocator, DefaultAllocation, DirectAllocation +│ ├── agreement/ # RecurringAgreementManager +│ ├── rewards/ # RewardsEligibilityOracle (A/B/mock), Reclaim +│ └── gip/0088/ # GIP-0088 goal orchestration (upgrade phase + activation) +├── lib/ # Shared utilities (preconditions, contract registry, tags, ABIs, ...) ├── tasks/ # Hardhat tasks (deploy:*) -├── governance/ # Safe TX builders -├── deployments/ # Per-network artifacts -└── test/ # Integration tests +├── docs/ # This documentation +└── test/ # Unit tests (bytecode, registry, tx-builder, ...) ``` ## Tags -| Tag | Deploys | -| ---------------------- | ------------------------------------ | -| `sync` | Sync address books, import contracts | -| `rewards-manager` | RewardsManager implementation | -| `subgraph-service` | SubgraphService implementation | -| `upgrade` | Generate TX, execute upgrades | -| `issuance-proxy-admin` | GraphIssuanceProxyAdmin | -| `issuance-core` | All issuance contracts | +Two-dimensional tag model. See [`lib/deployment-tags.ts`](../lib/deployment-tags.ts) for the source of truth. + +| Kind | Examples | Purpose | +| --------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | +| Special | `sync` | Sync address books, import contracts | +| Component | `IssuanceAllocator`, `RewardsManager`, `RecurringAgreementManager`, `RewardsEligibilityOracleA`, ... | One per deployable contract | +| Action verb | `deploy`, `upgrade`, `configure`, `transfer`, `integrate`, `all` | Combined with a component or goal tag to gate work | +| Goal scope | `GIP-0088`, `GIP-0088:upgrade` | Multi-component orchestration for a deployment | +| Activation goal | `GIP-0088:eligibility-integrate`, `GIP-0088:issuance-connect`, `GIP-0088:issuance-allocate` | Per-step governance TX for the activation phases | +| Optional goal | `GIP-0088:eligibility-revert`, `GIP-0088:issuance-close-guard` | Excluded from `--tags ...,all` — must be requested explicitly | ## External Artifacts diff --git a/packages/deployment/docs/DeploymentSetup.md b/packages/deployment/docs/DeploymentSetup.md index c9a2534f3..4b4fd4f4d 100644 --- a/packages/deployment/docs/DeploymentSetup.md +++ b/packages/deployment/docs/DeploymentSetup.md @@ -124,6 +124,7 @@ npx hardhat deploy --skip-prompts --network arbitrumSepolia --tags | Network | Chain ID | RPC (default) | | --------------- | -------- | ---------------------------------------- | +| localNetwork | 1337 | `http://chain:8545` | | arbitrumSepolia | 421614 | | | arbitrumOne | 42161 | | @@ -157,6 +158,66 @@ export ARBISCAN_API_KEY=$(npx hardhat keystore get ARBISCAN_API_KEY) npx hardhat deploy --skip-prompts --network arbitrumSepolia --tags ``` +## Tagging Deployments (WIP) + +> This convention is a work in progress — feedback and changes welcome. + +After a deployment is committed, create an annotated git tag to record the deployment. +Tags use `deploy/{mainnet|testnet}/YYYY-MM-DD` format. The annotation is auto-generated +from address book diffs, listing which contracts changed. + +**Requires:** `jq` (`sudo apt install jq` / `brew install jq`) + +### Usage + +```bash +# Preview first +./scripts/tag-deployment.sh \ + --deployer "packages/deployment --tags RewardsManager" \ + --network arbitrumSepolia \ + --base main \ + --dry-run + +# Create the tag +./scripts/tag-deployment.sh \ + --deployer "packages/deployment --tags RewardsManager" \ + --network arbitrumSepolia \ + --base main + +# Push +git push origin deploy/testnet/2026-03-02 +``` + +The `--deployer` argument is free-form — describe what performed the deployment: + +- `"packages/deployment --tags RewardsManager,SubgraphService"` +- `"packages/horizon ignition migrate"` +- `"manual: forge script DeployFoo"` + +### Workflow + +1. Deploy contracts and update address books +2. Commit the address book changes +3. Run `tag-deployment.sh` (tag must point to a finalized commit) +4. Push branch and tag + +### Options + +| Option | Description | +| ------------------- | --------------------------------------------- | +| `--deployer ` | What performed the deployment (required) | +| `--network ` | `arbitrumOne` or `arbitrumSepolia` (required) | +| `--base ` | Git ref to diff against (default: `HEAD~1`) | +| `--dry-run` | Preview without creating tag | +| `--sign` | Force-sign the tag with `-s` | + +### Viewing tags + +```bash +git tag -l 'deploy/*' # List all deployment tags +git show --no-patch deploy/testnet/... # View tag annotation +``` + ## See Also - [LocalForkTesting.md](./LocalForkTesting.md) - Fork-based testing workflow diff --git a/packages/deployment/docs/Design.md b/packages/deployment/docs/Design.md index d53d22125..6eec92811 100644 --- a/packages/deployment/docs/Design.md +++ b/packages/deployment/docs/Design.md @@ -5,7 +5,7 @@ High-level architecture for the unified deployment system. **See also:** - [Architecture.md](./Architecture.md) - Package structure and organization -- [../deploy/ImplementationPrinciples.md](../deploy/ImplementationPrinciples.md) - Deploy script patterns and conventions +- [deploy/ImplementationPrinciples.md](./deploy/ImplementationPrinciples.md) - Deploy script patterns and conventions ## Components @@ -13,8 +13,8 @@ High-level architecture for the unified deployment system. - IssuanceAllocator - Upgradeable proxy managing issuance distribution - RewardsEligibilityOracle - Upgradeable proxy for eligibility verification -- PilotAllocation - Upgradeable proxy for allocation testing -- GraphIssuanceProxyAdmin - Shared proxy admin for issuance contracts +- ReclaimedRewards (DirectAllocation) - Upgradeable proxy for default reclaim address +- RecurringAgreementManager - Upgradeable proxy for agreement-based payments **Referenced contracts** (already deployed): @@ -26,16 +26,19 @@ High-level architecture for the unified deployment system. ``` packages/deployment/ -├── deploy/ # Numbered deployment scripts -│ ├── admin/ # GraphIssuanceProxyAdmin -│ ├── allocate/ # IssuanceAllocator, PilotAllocation -│ ├── common/ # Validation, external imports -│ ├── rewards/ # RewardsManager, RewardsEligibilityOracle -│ ├── service/ # SubgraphService -│ └── ImplementationPrinciples.md # Script patterns -├── lib/ # Shared utilities, Safe TX builder -├── tasks/ # Hardhat tasks -└── docs/ # Architecture documentation +├── deploy/ # Numbered deployment scripts (rocketh + hardhat-deploy) +│ ├── common/ # 00_sync.ts +│ ├── horizon/ # RewardsManager, HorizonStaking, PaymentsEscrow, L2Curation, RecurringCollector +│ ├── service/ # SubgraphService, DisputeManager +│ ├── allocate/ # IssuanceAllocator, DefaultAllocation, DirectAllocation impl +│ ├── agreement/ # RecurringAgreementManager +│ ├── rewards/ # RewardsEligibilityOracle (A/B/mock), Reclaim +│ └── gip/0088/ # GIP-0088 goal orchestration +├── lib/ # Shared utilities (preconditions, registry, tags, ABIs, governance) +├── tasks/ # Hardhat tasks (deploy:*) +├── docs/ # Architecture and operational documentation +│ └── deploy/ # Deploy-script principles and per-component design notes +└── test/ # Unit tests ``` ## Governance Model @@ -48,54 +51,46 @@ packages/deployment/ ### Proxy Administration -```mermaid -graph TB - Gov[Governance Multi-sig] - ExistingAdmin[GraphProxyAdmin] - NewAdmin[GraphIssuanceProxyAdmin] - - Gov -->|owns| ExistingAdmin - Gov -->|owns| NewAdmin - - LegacyContracts[Staking, Curation, EpochManager, RewardsManager] - IssuanceContracts[IssuanceAllocator, RewardsEligibilityOracle, PilotAllocation] - - ExistingAdmin -->|manages| LegacyContracts - NewAdmin -->|manages| IssuanceContracts -``` - -**Key principle:** Separate proxy admins for legacy vs new issuance contracts, both governance-owned. +Two distinct proxy patterns coexist: -### Component Administration +- **Legacy `GraphProxy`** (custom Graph Protocol pattern) — used by RewardsManager, HorizonStaking, L2Curation, EpochManager. A single shared `GraphProxyAdmin` (owned by governance) controls upgrades for all of them. +- **OZ v5 `TransparentUpgradeableProxy`** — used by every new contract this package deploys (IssuanceAllocator, DefaultAllocation, ReclaimedRewards, RecurringAgreementManager, RewardsEligibilityOracle A/B, RecurringCollector, SubgraphService, DisputeManager, PaymentsEscrow). Each proxy gets its own per-proxy `ProxyAdmin` created by the proxy constructor; ownership is transferred to governance in the transfer step. ```mermaid graph TB - ProxyAdmin[GraphIssuanceProxyAdmin] - - subgraph "Issuance Allocation" - IA[IssuanceAllocator] - IA_Impl[IssuanceAllocatorImplementation] - end + Gov[Governance Multi-sig] + GraphAdmin[GraphProxyAdmin] - subgraph "Allocation Instances" - PA[PilotAllocation] - PA_Impl[DirectAllocation shared impl] + subgraph "Legacy GraphProxy" + RM[RewardsManager] + HS[HorizonStaking] + L2C[L2Curation] end - subgraph "Rewards Eligibility" - REO[RewardsEligibilityOracle] - REO_Impl[RewardsEligibilityOracleImplementation] + subgraph "OZ v5 TransparentUpgradeableProxy
(per-proxy admin)" + IA[IssuanceAllocator] + DA[DefaultAllocation] + Reclaim[ReclaimedRewards] + RAM[RecurringAgreementManager] + REO[RewardsEligibilityOracle A/B] + RC[RecurringCollector] end - ProxyAdmin -->|upgrades| IA - ProxyAdmin -->|upgrades| PA - ProxyAdmin -->|upgrades| REO - - IA -.->|delegates to| IA_Impl - PA -.->|delegates to| PA_Impl - REO -.->|delegates to| REO_Impl + Gov -->|owns| GraphAdmin + GraphAdmin -->|upgrades| RM + GraphAdmin -->|upgrades| HS + GraphAdmin -->|upgrades| L2C + + Gov -.->|owns each per-proxy admin| IA + Gov -.->|owns each per-proxy admin| DA + Gov -.->|owns each per-proxy admin| Reclaim + Gov -.->|owns each per-proxy admin| RAM + Gov -.->|owns each per-proxy admin| REO + Gov -.->|owns each per-proxy admin| RC ``` +**Key principle:** Every proxy admin is governance-owned. Legacy contracts share a single `GraphProxyAdmin`; new contracts each have their own per-proxy admin created at construction. + ## Contract Integration ### RewardsEligibilityOracle Integration @@ -120,7 +115,7 @@ graph TB IA[IssuanceAllocator] subgraph "Allocator Minting" - PA[PilotAllocation] + RAM[RecurringAgreementManager] end subgraph "Self Minting" @@ -128,7 +123,7 @@ graph TB end GT -->|minting authority| IA - IA -->|distributes to| PA + IA -->|distributes to| RAM IA -->|allocates to| RM ``` @@ -146,13 +141,13 @@ graph TD RewardsEligibilityOracle[RewardsEligibilityOracle] IssuanceAllocator[IssuanceAllocator] - PilotAllocation[PilotAllocation] + RecurringAgreementManager[RecurringAgreementManager] RewardsManager -.->|queries| RewardsEligibilityOracle IssuanceAllocator -.->|integrates with| RewardsManager IssuanceAllocator -.->|mints from| GraphToken - IssuanceAllocator -.->|distributes to| PilotAllocation - PilotAllocation -.->|holds| GraphToken + IssuanceAllocator -.->|distributes to| RecurringAgreementManager + RecurringAgreementManager -.->|funds| PaymentsEscrow ``` ## Address Book Management @@ -206,41 +201,44 @@ sequenceDiagram ```mermaid sequenceDiagram participant Deployer - participant Deploy as hardhat-deploy - participant Admin as GraphIssuanceProxyAdmin + participant Deploy as rocketh + participant Admin as ProxyAdmin (per-proxy) participant Impl as Implementation participant Proxy as TransparentUpgradeableProxy participant Gov as Governance Note over Deployer,Gov: Initial Deployment - Deployer->>Deploy: Run deployment scripts - Deploy->>Impl: Deploy contract bytecode - Deploy->>Proxy: Deploy proxy with init - Proxy->>Impl: Initialize + Deployer->>Deploy: --tags Component,deploy + Deploy->>Impl: Deploy implementation + Deploy->>Proxy: Deploy proxy (constructor creates per-proxy Admin) + Proxy->>Impl: Initialize with deployer as governor - Note over Deployer,Gov: Configuration - Deploy->>Proxy: Perform initial configuration - Deploy->>Proxy: Grant GOVERNOR_ROLE to governance + Note over Deployer,Gov: Configure + Deployer->>Deploy: --tags Component,configure + Deploy->>Proxy: Set params, grant roles to gov + pause guardian - Note over Deployer,Gov: Governance Update - Deployer->>Deploy: Generate update proposal - Gov->>Proxy: Execute configuration update + Note over Deployer,Gov: Transfer + Deployer->>Deploy: --tags Component,transfer + Deploy->>Proxy: Revoke deployer GOVERNOR_ROLE + Deploy->>Admin: Transfer ProxyAdmin ownership to Gov Note over Deployer,Gov: Implementation Upgrade - Deployer->>Deploy: Deploy new implementation - Deploy->>Deploy: Generate upgrade proposal - Gov->>Admin: Execute upgrade - Admin->>Proxy: Upgrade to new implementation - - Note over Deployer,Gov: Verification - Deployer->>Deploy: Run sync (--tags sync) - Deploy->>Proxy: Check current implementation - Deploy->>Deploy: Update address book + Deployer->>Deploy: --tags Component,upgrade + Deploy->>Impl: Deploy new implementation + Deploy->>Deploy: Save governance TX batch + Gov->>Admin: Execute upgrade TX + Admin->>Proxy: upgradeAndCall(newImpl) + + Note over Deployer,Gov: Sync + Deployer->>Deploy: --tags sync + Deploy->>Proxy: Read current implementation + Deploy->>Deploy: Update address book (pending → active) ``` ## Conventions - TypeScript throughout (.ts) - TitleCase for documentation -- Deploy script patterns: [ImplementationPrinciples.md](../deploy/ImplementationPrinciples.md) -- All 01_deploy.ts scripts MUST depend on SpecialTags.SYNC +- Deploy script patterns: [ImplementationPrinciples.md](./deploy/ImplementationPrinciples.md) +- Deploy scripts sync the contracts they touch immediately before/after their action via `syncComponentFromRegistry`/`syncComponentsFromRegistry`. The full + global sync is opt-in via `npx hardhat deploy:sync` and is no longer an automatic dependency of every component script. diff --git a/packages/deployment/docs/Gip0088.md b/packages/deployment/docs/Gip0088.md new file mode 100644 index 000000000..3afd7d815 --- /dev/null +++ b/packages/deployment/docs/Gip0088.md @@ -0,0 +1,241 @@ +# GIP-0088: Deployment Guide + +Protocol upgrade deploying the Issuance Allocator, Rewards Eligibility Oracle, and on-chain indexing agreements, as specified by [GIP-0088](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0088.md). + +## Related GIPs + +| GIP | Title | What it specifies | +| ----------------------------------------------------------------------------------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| [GIP-0076](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0076.md) | Issuance Allocator | Contract spec: governance-controlled issuance distribution across self-minting and allocator-minting targets | +| [GIP-0079](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0079.md) | Rewards Eligibility Oracle | Contract spec: quality-of-service gating on indexing rewards via authorized oracle | +| [GIP-0086](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0086.md) | RM and SS Upgrade | Contract upgrades: RM gains eligibility oracle hook + issuance allocator integration; SS gains agreement support | +| [GIP-0087](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0087.md) | On-Chain Indexing Agreements | Contract spec: RecurringCollector, RecurringAgreementManager, indexing agreement lifecycle in SubgraphService | +| [GIP-0088](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/gips/0088.md) | IA Deployment and IP Config | **Deployment proposal**: deploy IA (0076), connect to upgraded RM (0086), allocate to RAM (0087) | + +## Contracts + +### New contracts (deploy) + +| Contract | Package | GIP | Purpose | +| ------------------------------ | -------- | ---- | ----------------------------------------------------------- | +| IssuanceAllocator | issuance | 0076 | Governance-managed issuance distribution across targets | +| DefaultAllocation | issuance | 0076 | Default target safety net for unallocated issuance | +| ReclaimedRewards | issuance | 0076 | Default reclaim destination for reclaimed rewards | +| RecurringCollector | horizon | 0087 | EIP-712 collector for recurring payment agreement lifecycle | +| RecurringAgreementManager | issuance | 0087 | Protocol-funded indexing agreements and escrow management | +| RewardsEligibilityOracle (A/B) | issuance | 0079 | Quality-of-service gating on indexing rewards | + +### Existing contracts (upgrade implementation) + +| Contract | Package | GIP | Key changes | +| --------------- | ---------------- | --------- | ------------------------------------------------------------------------------------------------- | +| RewardsManager | contracts | 0086 | `setIssuanceAllocator()`, `IProviderEligibility` integration, `revertOnIneligible`, reclaim infra | +| SubgraphService | subgraph-service | 0086/0087 | Indexing agreement lifecycle, `enforceService`, `recurringCollector` integration | +| DisputeManager | subgraph-service | 0086/0087 | `createIndexingFeeDisputeV1()`, removes legacy dispute creation | +| HorizonStaking | horizon | 0086 | Removes HorizonStakingExtension, consolidates functionality | +| PaymentsEscrow | horizon | 0087 | `adjustThaw()` for payer thaw modification | +| L2Curation | contracts | 0086 | Removes staking as authorized `collect()` caller | + +## Deploy Scripts + +### GIP-0088 scripts (`deploy/gip/0088/`) + +**Upgrade phase** (`upgrade/`) — deploys, configures, transfers, and upgrades ALL contracts: + +| Script | `--tags` | What it does | +| -------------- | ---------------------------- | ------------------------------------------------------------------------------------- | +| `01_deploy` | `GIP-0088:upgrade,deploy` | Deploy all new contracts + implementations | +| `02_configure` | `GIP-0088:upgrade,configure` | Deployer-only configure: role grants and params on contracts where deployer is gov | +| `03_transfer` | `GIP-0088:upgrade,transfer` | Transfer governance of new contracts (revoke deployer role + ProxyAdmin to gov) | +| `04_upgrade` | `GIP-0088:upgrade,upgrade` | Bundle proxy upgrades + all deferred configure into one governance TX batch (details) | +| `10_status` | `GIP-0088:upgrade` | Show upgrade state and next step | + +`04_upgrade` builds a single governance TX batch containing: + +| Group | Items | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Proxy upgrades | Iterates registry; for any deployable proxy with `pendingImplementation`, adds the proxy upgrade TX | +| Existing-contract config | `RC.setPauseGuardian`, `RM.setDefaultReclaimAddress` | +| Deferred new-contract config | IA: `setIssuancePerBlock`, role grants. DA: role grants. RAM: role grants + `setIssuanceAllocator`. Reclaim: role grants. REO A/B: params + role grants | + +Items in groups 2 and 3 are added only when not already on-chain. The bundle exists because configure runs as the deployer and skips anything that requires `GOVERNOR_ROLE` on contracts the deployer doesn't yet control (or that depend on RM being upgraded). + +**Activation goals** — governance TXs that change protocol behaviour (after upgrade complete): + +| Script | `--tags` | What it does | +| ----------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `eligibility_integrate` | `GIP-0088:eligibility-integrate` | `RM.setProviderEligibilityOracle(REO_A)` | +| `issuance_connect` | `GIP-0088:issuance-connect` | `GraphToken.addMinter(IA)` → `RM.setIssuanceAllocator(IA)` → `IA.setTargetAllocation(RM, 0, rate)` (RM as 100% self-minting target) → `IA.setDefaultTarget(DA)` (safety net) | +| `issuance_allocate` | `GIP-0088:issuance-allocate` | `IA.setTargetAllocation(RAM, allocatorRate, selfRate)` (rates from `config/.json5`) | + +**Optional goals** — not planned for initial deployment: + +| Script | `--tags` | What it does | +| ---------------------- | ------------------------------- | ------------------------------------------------------- | +| `eligibility_revert` | `GIP-0088:eligibility-revert` | `RM.setRevertOnIneligible(true)` | +| `issuance_close_guard` | `GIP-0088:issuance-close-guard` | `SS.setBlockClosingAllocationWithActiveAgreement(true)` | + +**Overall** — `09_end` (`GIP-0088,all`) verifies all non-optional goals. `10_status` (`GIP-0088`) shows full deployment state. + +### Component lifecycle scripts + +Each contract has its own lifecycle scripts under `deploy/`. The GIP-0088 upgrade phase depends on component tags — it orchestrates the component scripts rather than duplicating their logic. + +## Deployment Process + +### How `--tags` drives the deployment + +The upgrade phase tag (`GIP-0088:upgrade`) combined with an action verb (`deploy`, `configure`, `transfer`, `upgrade`) selects which lifecycle step runs. Activation goals have their own tags. + +- `--tags GIP-0088:upgrade,deploy` — deploy all contracts +- `--tags GIP-0088:upgrade,configure` — configure all contracts +- `--tags GIP-0088:upgrade,transfer` — transfer to governance control +- `--tags GIP-0088:upgrade,upgrade` — generate proxy upgrade TX batch +- `--tags GIP-0088:upgrade` — show status and next step +- `--tags GIP-0088:eligibility-integrate` — integrate REO with RM (governance TX) +- `--tags GIP-0088:issuance-connect` — connect IA to RM + minter role (governance TX) +- `--tags GIP-0088:issuance-allocate` — allocate issuance to RAM (governance TX) +- `--tags GIP-0088` — overall status + +All scripts are idempotent — they check on-chain state and skip if already done. Scripts do not presume a particular starting state. + +Sync runs automatically as a dependency of all scripts. + +### Deployment sequence + +```bash +# Deploy and configure all contracts +pnpm hardhat deploy --tags GIP-0088:upgrade,deploy --network +pnpm hardhat deploy --tags GIP-0088:upgrade,configure --network + +# Check status before transferring governance +pnpm hardhat deploy --tags GIP-0088:upgrade --network + +# Transfer governance — after this, deployer has no special access +pnpm hardhat deploy --tags GIP-0088:upgrade,transfer --network + +# Generate proxy upgrade governance TX batch +pnpm hardhat deploy --tags GIP-0088:upgrade,upgrade --network +# → execute governance TXs (see Environments below) + +# Activation goals (each generates governance TXs independently) +pnpm hardhat deploy --tags GIP-0088:eligibility-integrate --network +pnpm hardhat deploy --tags GIP-0088:issuance-connect --network +pnpm hardhat deploy --tags GIP-0088:issuance-allocate --network +# → execute governance TXs + +# Verify +pnpm hardhat deploy --tags GIP-0088 --network +``` + +### Preconditions + +Each script checks its own preconditions and skips if not met. Scripts do not presume a particular starting state — they are goal-seeking, not sequential steps. + +#### Deploy (`GIP-0088:upgrade,deploy`) + +| Contract | Precondition | Notes | +| ------------------------------------------ | ------------ | ----------------------------------------------------- | +| RC | — | No dependencies | +| SS implementation | RC deployed | SS has RC address baked into bytecode via `Directory` | +| RM, HS, DM, PE, L2Curation implementations | — | No deploy-time dependencies | +| IA, DefaultAllocation, Reclaim | — | Independent | +| RAM | — | Independent | +| REO A, REO B | — | Independent | + +#### Configure (`GIP-0088:upgrade,configure`) + +| Contract | Precondition | Notes | +| -------- | --------------------------------- | ---------------------------------------------------------------------------------------------- | +| RC | Deployed | setPauseGuardian | +| IA | Deployed, 0 < RM.issuancePerBlock | Rates, RM as 100% self-minting target, grant governor/pause roles | +| DA | Deployed (+ IA deployed) | Grant governor/pause roles, set as IA default target | +| REO A/B | Deployed | Grant governor/pause/operator roles. Validation enabled by operator post-deploy. | +| RAM | Deployed (+ RC, SS, IA deployed) | Grant governor/pause/collector/data-service roles, set issuance allocator | +| Reclaim | Deployed | Grant governor/pause roles | +| Reclaim | RM upgraded | Sets RM.defaultReclaimAddress — skips if RM not yet upgraded (handled by `04_upgrade` instead) | + +#### Transfer (`GIP-0088:upgrade,transfer`) + +| Contract | Precondition | Notes | +| -------- | ------------------------------- | --------------------------------------------------------------------------- | +| RC | Deployed | ProxyAdmin only — RC has no `GOVERNOR_ROLE`. Skips if owner is not deployer | +| IA | Configured | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | +| DA | Configured | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | +| RAM | Configured | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | +| Reclaim | Configured | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | +| REO A | Configured (all conditions met) | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | +| REO B | Configured (all conditions met) | Revokes deployer GOVERNOR_ROLE, transfers ProxyAdmin | + +#### Upgrade (`GIP-0088:upgrade,upgrade`) + +State-driven: builds a single governance TX batch from three groups. Each group skips items already on-chain. + +| Group | Items | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Proxy upgrades | Iterates registry; for any deployable proxy with `pendingImplementation`, adds proxy upgrade TX | +| Existing-contract config | `RC.setPauseGuardian(pauseGuardian)`; `RM.setDefaultReclaimAddress(reclaim)` (only after RM upgrade — bundle order means RM upgrade executes first in the same batch) | +| Deferred new-contract config | IA: `setIssuancePerBlock`, `grantRole(GOVERNOR/PAUSE)`. DA: `grantRole(GOVERNOR/PAUSE)`. RAM: `grantRole(COLLECTOR/DATA_SERVICE/GOVERNOR/PAUSE)` + `setIssuanceAllocator`. Reclaim: `grantRole(GOVERNOR/PAUSE)`. REO A/B: param setters + role grants. | + +These deferred items exist because configure runs as the deployer and skips items requiring `GOVERNOR_ROLE` on contracts the deployer doesn't yet control, or items that depend on RM being upgraded. + +#### Activation goals + +| Goal | Precondition | Notes | +| ----------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `eligibility-integrate` | RM upgraded, REO A deployed, oracle not already set | `RM.setProviderEligibilityOracle(REO_A)`. Skips if any oracle already set (does not override). | +| `issuance-connect` | RM upgraded, IA deployed + configured (rate matches RM) | Builds TX batch in order: `GraphToken.addMinter(IA)` → `RM.setIssuanceAllocator(IA)` → `IA.setTargetAllocation(RM, 0, rate)` → `IA.setDefaultTarget(DA)`. Order matters: `setTargetAllocation` calls `RM.onIssuanceChange` which requires the allocator already be set. **Exits on invariant failure** (IA rate ≠ RM rate). | +| `issuance-allocate` | IA deployed, RAM deployed, issuance-connect done | `IA.setTargetAllocation(RAM, allocatorMintingRate, selfMintingRate)`. Rates from `config/.json5`, skips if both are 0. | + +#### Optional goals + +| Goal | Precondition | Notes | +| ---------------------- | -------------------------------------- | ----------------------------------------------------- | +| `eligibility-revert` | RM upgraded (supports IRewardsManager) | RM.setRevertOnIneligible(true) | +| `issuance-close-guard` | SS upgraded | SS.setBlockClosingAllocationWithActiveAgreement(true) | + +### Environments + +The same commands apply to all environments. What differs is how governance TXs are executed. + +| Environment | Governance execution | Speed | +| ----------------- | ------------------------------------------------- | -------- | +| Fork (localhost) | `deploy:execute-governance` impersonates governor | Instant | +| Testnet (Sepolia) | `deploy:execute-governance` signs with EOA key | ~minutes | +| Mainnet (Arb One) | TX batch uploaded to Safe for council multisig | ~days | + +#### Fork testing + +Validates the full flow using account impersonation. See [LocalForkTesting.md](LocalForkTesting.md). + +```bash +anvil --fork-url --chain-id 31337 +pnpm hardhat deploy:reset-fork --network localhost + +# Deploy, configure, transfer +pnpm hardhat deploy --tags GIP-0088:upgrade,deploy --network localhost --skip-prompts +pnpm hardhat deploy --tags GIP-0088:upgrade,configure --network localhost --skip-prompts +pnpm hardhat deploy --tags GIP-0088:upgrade,transfer --network localhost --skip-prompts + +# Proxy upgrades +pnpm hardhat deploy --tags GIP-0088:upgrade,upgrade --network localhost --skip-prompts +pnpm hardhat deploy:execute-governance --network localhost + +# Activation +pnpm hardhat deploy --tags GIP-0088:eligibility-integrate --network localhost --skip-prompts +pnpm hardhat deploy:execute-governance --network localhost +pnpm hardhat deploy --tags GIP-0088:issuance-connect --network localhost --skip-prompts +pnpm hardhat deploy:execute-governance --network localhost +pnpm hardhat deploy --tags GIP-0088:issuance-allocate --network localhost --skip-prompts +pnpm hardhat deploy:execute-governance --network localhost + +# Verify +pnpm hardhat deploy --tags GIP-0088 --network localhost --skip-prompts +``` + +## See Also + +- [GovernanceWorkflow.md](GovernanceWorkflow.md) — governance TX generation and execution across environments +- [LocalForkTesting.md](LocalForkTesting.md) — fork mode testing setup and workflow +- [Architecture.md](Architecture.md) — deployment package architecture +- [deploy/ImplementationPrinciples.md](deploy/ImplementationPrinciples.md) — patterns and rules for deploy scripts diff --git a/packages/deployment/docs/GovernanceWorkflow.md b/packages/deployment/docs/GovernanceWorkflow.md index cceb117a0..7b4ade2ed 100644 --- a/packages/deployment/docs/GovernanceWorkflow.md +++ b/packages/deployment/docs/GovernanceWorkflow.md @@ -13,12 +13,11 @@ In fork mode, governance transactions can be executed automatically via account ### Setup ```bash -# Start a fork of arbitrumSepolia -FORK_NETWORK=arbitrumSepolia npx hardhat node --network fork +# Ephemeral: run deployment directly (state lost on exit) +FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags IssuanceAllocator:deploy --network fork -# In another terminal, run deployments -export FORK_NETWORK=arbitrumSepolia -npx hardhat deploy --tags issuance-allocator-deploy --network fork +# Or persistent: start anvil in Terminal 1, run deploys in Terminal 2 +# See LocalForkTesting.md for persistent fork setup ``` ### Execution @@ -26,15 +25,15 @@ npx hardhat deploy --tags issuance-allocator-deploy --network fork When a deployment generates a governance TX batch: 1. The TX batch is saved to `fork/fork/arbitrumSepolia/txs/*.json` -2. The deployment exits with code 1 (expected state - waiting for governance) -3. Execute the governance TXs automatically: +2. The script returns (it does **not** exit) — subsequent scripts in the run keep going and check their own preconditions, so a single command can produce several TX batches +3. Execute the saved governance TXs: ```bash npx hardhat deploy:execute-governance --network fork ``` 4. This uses `hardhat_impersonateAccount` to execute as the governor -5. Continue with deployments +5. Re-run the deployment command to continue past the governance boundary ## Testnet Mode with EOA Governor @@ -93,14 +92,14 @@ On mainnet (and testnets where Safe is deployed), governance transactions with S ```bash export DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY -npx hardhat deploy --tags issuance-allocator-deploy --network arbitrumSepolia +npx hardhat deploy --tags IssuanceAllocator:deploy --network arbitrumSepolia ``` When governance action is required, the deployment will: - Generate a TX batch file in `txs/arbitrumSepolia/*.json` - Display the file path -- Exit with code 1 +- Return (not exit) — the run continues and other scripts check their own preconditions #### 2. Review the TX Batch @@ -156,7 +155,7 @@ This updates the address books with the new on-chain state. Re-run the original deployment command: ```bash -npx hardhat deploy --tags issuance-allocator-deploy --network arbitrumSepolia +npx hardhat deploy --tags IssuanceAllocator:deploy --network arbitrumSepolia ``` The deployment will detect that governance has executed and continue to the next steps. @@ -167,7 +166,7 @@ The deployment will detect that governance has executed and continue to the next ```bash # 1. Deploy new implementation -npx hardhat deploy --tags rewards-manager-deploy --network arbitrumSepolia +npx hardhat deploy --tags RewardsManager:deploy --network arbitrumSepolia # This generates: txs/arbitrumSepolia/upgrade-RewardsManager.json @@ -181,7 +180,7 @@ npx hardhat deploy --tags sync --network arbitrumSepolia ```bash # Deploy and configure (generates governance TX if needed) -npx hardhat deploy --tags issuance-activation --network arbitrumSepolia +npx hardhat deploy --tags IssuanceActivation --network arbitrumSepolia # Execute via Safe UI @@ -223,15 +222,16 @@ txs//executed/*.json | **EOA Direct** | Testnet with EOA governor | Automatic with private key | `GOVERNOR_PRIVATE_KEY=0x...` | | **Safe Multisig** | Production/mainnet | Manual via Safe Transaction Builder | None (auto-detected) | +**Fork mode is network-aware**: `FORK_NETWORK` is automatically ignored on real networks (arbitrumSepolia, arbitrumOne). Fork mode only activates on local networks (localhost, fork, hardhat), so you don't need to unset it when switching to real deployments. + **Transaction batch files** (Safe Transaction Builder JSON format) are always created in `txs//*.json` regardless of execution mode. ### Usage Examples -**Local fork testing:** +**Local fork testing (ephemeral):** ```bash -FORK_NETWORK=arbitrumSepolia npx hardhat node --network fork -npx hardhat deploy:execute-governance --network fork +FORK_NETWORK=arbitrumSepolia npx hardhat deploy:execute-governance --network fork ``` **Fast testnet iteration (EOA):** @@ -287,13 +287,15 @@ npx hardhat deploy:execute-governance --network arbitrumSepolia # Governor: 0x... (EOA) ``` -### Exit Code 1 +### No Exit on Governance Save + +When a script generates a governance TX batch, it **returns** rather than exiting. This: -When a deployment generates a governance TX batch, it exits with code 1. This: +- Lets a single command produce multiple governance TX batches in one run (one per script that needs governance authority) +- Avoids implicit ordering coupling — every script checks its own on-chain preconditions and skips if they aren't met +- Is normal flow, not an error condition -- Signals to CI/CD that manual intervention is required -- Prevents subsequent deployment steps from running -- Is not an error - it's expected state when waiting for governance +To detect "needs governance" in CI/CD, check whether any files exist under `txs//` after a run, or use the goal status scripts (`--tags GIP-0088`). ## Troubleshooting @@ -355,18 +357,17 @@ npx hardhat deploy:execute-governance --network arbitrumSepolia Before executing on mainnet, always test in fork mode: ```bash -# 1. Fork mainnet -FORK_NETWORK=arbitrumOne npx hardhat node --network fork - -# 2. Deploy (generates governance TXs) +# 1. Deploy (generates governance TXs) export FORK_NETWORK=arbitrumOne -npx hardhat deploy --tags issuance-allocator-deploy --network fork +npx hardhat deploy --tags IssuanceAllocator:deploy --network fork -# 3. Execute governance TXs automatically +# 2. Execute governance TXs automatically npx hardhat deploy:execute-governance --network fork -# 4. Verify state +# 3. Verify state npx hardhat deploy:status --network fork ``` +For persistent fork testing (state survives across commands), see [LocalForkTesting.md](./LocalForkTesting.md). + This tests the full governance workflow without touching real funds or requiring actual Safe signatures. diff --git a/packages/deployment/docs/LocalForkTesting.md b/packages/deployment/docs/LocalForkTesting.md index 7e7d70fe6..d6dbcdc09 100644 --- a/packages/deployment/docs/LocalForkTesting.md +++ b/packages/deployment/docs/LocalForkTesting.md @@ -8,7 +8,7 @@ State is lost when the command exits. Good for quick testing. ```bash # Run full deployment flow against forked arbitrumSepolia -FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags sync,rewards-manager-deploy --network fork +FORK_NETWORK=arbitrumSepolia npx hardhat deploy --tags sync,RewardsManager:deploy --network fork ``` ## Persistent Fork (multiple sessions) @@ -23,12 +23,10 @@ anvil --fork-url https://sepolia-rollup.arbitrum.io/rpc --chain-id 31337 ```bash # Terminal 2 - run deploys against it -# FORK_NETWORK tells deploy scripts which address books to use -export FORK_NETWORK=arbitrumSepolia npx hardhat deploy:reset-fork --network localhost npx hardhat deploy:status --network localhost npx hardhat deploy --network localhost --skip-prompts --tags sync -npx hardhat deploy --network localhost --skip-prompts --tags rewards-manager +npx hardhat deploy --network localhost --skip-prompts --tags RewardsManager npx hardhat deploy:execute-governance --network localhost ``` @@ -38,18 +36,22 @@ Or for Arbitrum One: anvil --fork-url https://arb1.arbitrum.io/rpc --chain-id 31337 ``` -```bash -export FORK_NETWORK=arbitrumOne -# ... -``` - **Important**: - Terminal 1: Use anvil (from Foundry) instead of `hardhat node` - Hardhat v3's node command doesn't properly support the `--fork` flag - Terminal 1: Use `--chain-id 31337` - anvil defaults to the forked chain's ID (421614) but hardhat's localhost expects 31337 -- Terminal 2: Set `FORK_NETWORK` env var - tells deploy scripts to: - - Load the correct network's address books (not localhost's empty ones) - - Generate Safe TX files with the correct chainId (421614, not 31337) + +### Fork Network Detection + +The fork network (which chain is being forked) is **auto-detected** from anvil's RPC metadata. When you run against localhost, deploy scripts query `anvil_nodeInfo` to get the fork URL and match it against known network RPC hostnames. + +You can also set `FORK_NETWORK` explicitly to override auto-detection: + +```bash +export FORK_NETWORK=arbitrumSepolia +``` + +**Safe on real networks**: `FORK_NETWORK` is automatically ignored when running against real networks (`--network arbitrumSepolia`, `--network arbitrumOne`). Fork mode only activates on local networks (localhost, fork, hardhat), so you don't need to unset `FORK_NETWORK` when switching between fork testing and real deployments. ## Architecture @@ -80,12 +82,12 @@ deployments/ # Managed by rocketh (deployment records, .chain f ## Key Points -| Setting | Value | Purpose | -| --------------------- | ---------------------------------- | -------------------------------- | -| `FORK_NETWORK` | `arbitrumSepolia` or `arbitrumOne` | Which network to fork | -| `SHOW_ADDRESSES` | `0`, `1` (default), or `2` | Address display: none/short/full | -| `--network fork` | in-process EDR | Ephemeral, fast startup | -| `--network localhost` | external node | Persistent state | +| Setting | Value | Purpose | +| --------------------- | ---------------------------------- | -------------------------------------------------------------- | +| `FORK_NETWORK` | `arbitrumSepolia` or `arbitrumOne` | Override auto-detected fork network (ignored on real networks) | +| `SHOW_ADDRESSES` | `0`, `1` (default), or `2` | Address display: none/short/full | +| `--network fork` | in-process EDR | Ephemeral, fast startup | +| `--network localhost` | external node | Persistent state | ## Configuration @@ -136,6 +138,33 @@ npx hardhat deploy:reset-fork --network fork - **Foundry**: Install via `curl -L https://foundry.paradigm.xyz | bash && foundryup` +## Local Network (rem-local-network) + +The `localNetwork` network targets the Graph local network docker-compose stack (chain ID 1337). +Unlike fork mode, contracts are deployed fresh from scratch. + +```bash +# Deploy a single contract via its component lifecycle +npx hardhat deploy --tags IssuanceAllocator,deploy --network localNetwork + +# Or run the full GIP-0088 upgrade phase +npx hardhat deploy --tags GIP-0088:upgrade,deploy --network localNetwork +``` + +**Key differences from fork mode:** + +- Chain ID 1337 (not 31337) +- No `FORK_NETWORK` env var needed +- Address books use `addresses-local-network.json` files (symlinked to mounted config) +- Deployer is also governor (direct execution, no governance batch files) +- Uses standard test mnemonic (`test test test ... junk`) + +**Environment:** + +- RPC: `http://chain:8545` (override with `LOCAL_NETWORK_RPC`) +- Address books are populated by Phase 1 (hardhat-graph-protocol deploys Horizon + SubgraphService) +- Phase 2+ deployment scripts use this package to deploy additional contracts (e.g., issuance) + ## See Also - [GovernanceWorkflow.md](./GovernanceWorkflow.md) - Production deployment flow diff --git a/packages/deployment/docs/SyncBytecodeDetectionFix.md b/packages/deployment/docs/SyncBytecodeDetectionFix.md new file mode 100644 index 000000000..5c4498fd1 --- /dev/null +++ b/packages/deployment/docs/SyncBytecodeDetectionFix.md @@ -0,0 +1,149 @@ +# Sync Bytecode Detection Fix + +## Issues Identified + +### Issue 1: Local Bytecode Changes Ignored + +**Problem**: Deploy incorrectly reported "implementation unchanged" when local bytecode had actually changed. + +**Evidence**: + +``` +Local artifact: 0x9c25d2f93e6a2a34cc19d00224872e288a8392d5d99b2df680b7e978d148d450 +On-chain: 0xfafdeb48fae37e277e007e7b977f3cd124065ac1c27ed5208982c2965cf07008 +Address book: 0x4805a902756c8f4421c2a2710dcc76885ffd01d7777bbe6cab010fe9748b7efa +``` + +All three hashes are different, yet deploy said "unchanged", meaning local changes would be ignored. + +### Issue 2: Confusing Sync Behavior + +**Problem**: Sync showed "code changed" but didn't handle the state appropriately: + +1. Showed △ (code changed) indicator +2. But didn't sync implementation to rocketh +3. Saved proxy record with wrong bytecode +4. This confused rocketh's change detection + +## Root Causes + +### Cause 1: Missing/Stale Bytecode Hash + +When the address book had no bytecode hash (or wrong hash): + +- Sync detected "code changed" ([sync-utils.ts:475-477](../lib/sync-utils.ts#L475-L477)) +- But only synced to rocketh if hash matched ([sync-utils.ts:653](../lib/sync-utils.ts#L653)) +- This left rocketh with incomplete/wrong state + +### Cause 2: Wrong Bytecode Stored for Proxy + +The sync step saved the **implementation's bytecode** under the **proxy's deployment record**: + +- Lines 508-532: Created proxy record with implementation artifact bytecode +- This is wrong - proxy should have its own bytecode (or none) +- Rocketh then compared wrong bytecode and gave incorrect results + +## Fixes Applied + +### Fix 1: Hash Comparison and Stale Record Cleanup ([sync-utils.ts:645-679](../lib/sync-utils.ts#L645-L679)) + +When sync processes an implementation: + +1. **Compare local artifact hash to address-book-stored hash** +2. **If hashes match**: sync the implementation record to rocketh normally +3. **If hashes don't match**: overwrite any stale rocketh record with empty bytecode, forcing a fresh deployment + + ```typescript + if (storedHash && localHash) { + hashMatches = storedHash === localHash + } + + // Clean up stale rocketh record if hash doesn't match + if (!hashMatches && existingImpl) { + // Overwrite stale record with empty bytecode - forces fresh deployment + await env.save(`${spec.name}_Implementation`, { + address: existingImpl.address, + bytecode: '0x', + deployedBytecode: undefined, + ... + }) + } + ``` + +This ensures rocketh correctly detects when local code has changed and triggers a new deployment. + +### Fix 2: Don't Store Wrong Bytecode for Proxy ([sync-utils.ts:508-532](../lib/sync-utils.ts#L508-L532)) + +Changed proxy record creation to **NOT include implementation bytecode**: + +```typescript +// Before: +bytecode: artifact.bytecode // ← Wrong! This is implementation bytecode +deployedBytecode: artifact.deployedBytecode + +// After: +bytecode: '0x' // ← Correct! Proxy record doesn't need bytecode +deployedBytecode: undefined +``` + +This ensures rocketh only uses implementation bytecode for the actual implementation record. + +## Expected Behavior After Fix + +### Scenario 1: Local Matches Address Book + +When local artifact hash matches the stored hash, sync proceeds normally and rocketh +correctly reports the implementation as unchanged. + +### Scenario 2: Local Code Changed + +**Before**: + +``` +△ SubgraphService @ 0xc24A3dAC... → 0x2af1b0ed... (code changed) +✓ SubgraphService implementation unchanged ← WRONG! +``` + +**After**: + +``` +△ SubgraphService @ 0xc24A3dAC... → 0x2af1b0ed... (local code changed) +📋 New SubgraphService implementation deployed: 0x... ← NEW! + Storing as pending implementation... +``` + +Deploy correctly detects the change and deploys new implementation. + +### Scenario 3: Stale Rocketh Record + +When the hash doesn't match and a stale rocketh record exists, sync overwrites it +with empty bytecode. This forces the next deploy to create a fresh implementation +record rather than incorrectly reporting "unchanged". + +## Testing + +To verify the fix works: + +```bash +# Clean build +cd packages/deployment +pnpm build + +# Run sync - should now show clearer messages +npx hardhat deploy --skip-prompts --network arbitrumSepolia --tags sync + +# Run deploy - should correctly detect local changes +npx hardhat deploy --skip-prompts --network arbitrumSepolia --tags SubgraphService +``` + +## Migration Notes + +- **No manual migration needed** - stale rocketh records are cleaned up automatically +- First sync after fix will detect hash mismatches and clear stale records +- Subsequent deploys will create fresh implementation records + +## Related Files + +- [sync-utils.ts](../lib/sync-utils.ts) - Main fix implementation +- [deploy-implementation.ts](../lib/deploy-implementation.ts) - Deploy logic (unchanged, now works correctly) +- [check-bytecode.ts](../scripts/check-bytecode.ts) - Diagnostic script for manual verification diff --git a/packages/deployment/docs/deploy/ImplementationPrinciples.md b/packages/deployment/docs/deploy/ImplementationPrinciples.md index 1c3134e2e..9226611a9 100644 --- a/packages/deployment/docs/deploy/ImplementationPrinciples.md +++ b/packages/deployment/docs/deploy/ImplementationPrinciples.md @@ -16,104 +16,134 @@ This document defines the core principles and patterns for writing deployment sc **Standard step objectives:** -- **01_deploy.ts** - Deploy proxy + implementation, initialize with deployer or governor - - MUST explicitly depend on `SpecialTags.SYNC` (even if also available transitively through other dependencies) +- **01_deploy.ts** - Deploy proxy + implementation, initialize with deployer + - Sync the contract being deployed (and any contracts it reads) immediately + before acting via `syncComponentFromRegistry` / + `syncComponentsFromRegistry`. The script factories + (`createProxyDeployModule`, `createImplementationDeployModule`, + `createUpgradeModule`, etc.) handle this automatically. + - For a global pre-deploy reconciliation, use `npx hardhat deploy:sync` + explicitly — it is no longer pulled in as an automatic dependency. - Each script should declare its own prerequisites explicitly, not rely on transitive dependencies - **02_upgrade.ts** - Handle proxy upgrades via governance (generates TX batch) -- **03-08 (flexible)** - Intermediate steps vary by component: - - Configure integration with other contracts - - Verify governance state - - Transfer governance roles - - Generate activation TX batches - - Deploy shared implementations +- **04_configure.ts** - Deployer-only configure: role grants and params on contracts where the deployer is governor +- **05_transfer_governance.ts** - Revoke deployer GOVERNOR_ROLE; transfer ProxyAdmin to protocol governor +- **06_integrate.ts** (optional) - Wire the contract into the rest of the protocol - **09_end.ts** - End state aggregate (only has dependencies and verification, no execution) +- **10_status.ts** - Read-only status display (see below) + +The `03_*` slot is intentionally left empty so that `02_upgrade` can be inserted as a clearly distinct phase without renumbering. The `04_configure` numbering is the actual convention used throughout the tree. + +### Principle: Status Scripts Are Read-Only + +**Rule**: `10_status.ts` scripts MUST be purely read-only. They MUST NOT make on-chain changes, write transactions, or modify any state. + +**Why**: When `--tags ` is run without an action verb, only status scripts execute. Users rely on this for safe inspection of deployment state at any time — during planning, mid-deployment, and in production. Any mutation in a status script would violate this trust and could cause unintended state changes. + +**How it works**: + +1. Status scripts use `createStatusModule()`, which gates on `noTagsRequested()` — they only run when tags are present but no action verb is included +2. Stage scripts (01-08) use `shouldSkipAction(verb)` — they skip when their action verb is absent from `--tags` +3. Combined: `--tags GIP-0088` alone runs only `10_status.ts` (status reads on-chain directly and does not need a global sync first) + +**Pattern**: + +```typescript +// Component status — delegates to showDetailedComponentStatus (reads only) +export default createStatusModule(Contracts.issuance.IssuanceAllocator) + +// Goal status — custom handler, must only use readContract/getCode +export default createStatusModule(GoalTags.GIP_0088, async (env) => { + const client = graph.getPublicClient(env) as PublicClient + // ✅ Read on-chain state and display + const value = await client.readContract({ ... }) + env.showMessage(` ${value ? '✓' : '✗'} check description`) + // ❌ NEVER: execute(), tx(), deploy(), process.exit(1), TxBuilder +}) +``` + +**Invariant**: If a script is named `10_status.ts`, it contains zero writes. No exceptions. #### Example: RewardsEligibilityOracle (simple - 4 steps) ``` -01_deploy.ts - Deploy proxy + implementation, initialize with governor -02_upgrade.ts - Handle upgrades -03_configure.ts - Integrate with RewardsManager +01_deploy.ts - Deploy proxy + implementation +02_upgrade.ts - Handle proxy upgrades (governance TX batch) +04_configure.ts - Deployer-only configure (params, role grants) 09_end.ts - End state aggregate +10_status.ts - Read-only status display ``` -#### Example: IssuanceAllocator (complex - 8 steps) +#### Example: RewardsEligibilityOracle (full lifecycle) ``` 01_deploy.ts - Deploy proxy + implementation -02_upgrade.ts - Handle upgrades -03_deploy.ts - Deploy DirectAllocation implementation -04_configure.ts - Configure issuance rate and allocations -05_verify_governance.ts - Verify governance state -06_transfer_governance.ts - Transfer roles to governance -07_activate.ts - Generate activation TX batch +02_upgrade.ts - Handle proxy upgrades +04_configure.ts - Configure params + role grants +05_transfer_governance.ts - Revoke deployer role + transfer ProxyAdmin +06_integrate.ts - Wire into RewardsManager (governance TX) 09_end.ts - End state aggregate +10_status.ts - Read-only status display ``` -**Note:** Steps 04-08 are flexible and vary by component. Always use `09_end.ts` for the final aggregate. +**Note:** Step `03_*` is intentionally left empty so `02_upgrade` stays a clearly separate phase. Steps 04-08 are flexible and vary by component. Always use `09_end.ts` for the aggregate and `10_status.ts` for read-only status. #### Tag structure in deployment-tags.ts ```typescript -// Example: RewardsEligibilityOracle lifecycle -rewardsEligibilityDeploy: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.DEPLOY)], -rewardsEligibilityUpgrade: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.UPGRADE)], -rewardsEligibilityConfigure: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.CONFIGURE)], -rewardsEligibility: [ComponentTags.REWARDS_ELIGIBILITY], // Aggregate end state +// Component tags are PascalCase contract names matching the registry +ComponentTags = { + REWARDS_ELIGIBILITY_A: 'RewardsEligibilityOracleA', + // ... +} + +// Action verbs are appended via --tags Component,verb +// e.g. --tags RewardsEligibilityOracleA,deploy ``` ## Exit Codes and Flow Control -### Principle: Clean Exits for Expected Prerequisites +### Principle: Scripts Are Goal-Seeking, Not Sequential Steps -**Rule**: When a deployment step cannot complete due to an expected prerequisite state (NOT an exception), it MUST exit with code 1 to prevent subsequent steps from running. +**Rule**: Each script checks its own preconditions and skips if not met. Scripts return (not exit) when work cannot proceed — subsequent scripts check their own state independently. -**Rationale**: Steps should be able to rely on prerequisite steps stopping if not complete. This prevents cascading failures and incorrect state. +**Rationale**: Scripts run in sequence but must not assume a particular starting state. Each script is idempotent and goal-seeking: it checks on-chain state, does what's needed, and returns. **Examples**: ```typescript -// CORRECT: Exit with code 1 when prerequisite not met -export async function requireRewardsManagerUpgraded( - client: PublicClient, - rmAddress: string, - env: Environment, -): Promise { - const upgraded = await isRewardsManagerUpgraded(client, rmAddress) - if (!upgraded) { - env.showMessage(`\n❌ RewardsManager has not been upgraded yet`) - env.showMessage(` Run: npx hardhat deploy:execute-governance --network ${env.name}`) - process.exit(1) // Clean exit - prevents next steps - } -} - -// CORRECT: Exit after generating governance TX -const txFile = builder.saveToFile() -env.showMessage(`\n✓ TX batch saved: ${txFile}`) -env.showMessage('\n📋 GOVERNANCE ACTION REQUIRED') -process.exit(1) // Prevents next steps until governance TX executed +// CORRECT: Save governance TX and return (allows subsequent scripts to run) +saveGovernanceTx(env, builder, `ContractName activation`) +// Returns — subsequent scripts check their own preconditions -// WRONG: Returning allows next steps to run +// CORRECT: Skip when precondition not met if (!prerequisiteMet) { - env.showMessage('⚠️ Prerequisite not met') - return // ❌ Next step will still run! + env.showMessage(' ○ Prerequisite not met — skipping') + return +} + +// CORRECT: Use shared precondition check to skip if done +const precondition = await checkIAConfigured(client, ia.address, rm.address) +if (precondition.done) { + env.showMessage('✅ Already configured') + return } ``` ### When to Use Exit Code 1 -Use `process.exit(1)` when: +Use `process.exit(1)` only for: -- Waiting for a governance TX to be executed -- Waiting for a contract upgrade to complete -- Checking a required prerequisite state -- External action needed before continuing +- **Migration invariant violations** (data corruption risk, e.g. IA rate != RM rate before connection) +- **Verification failures** in `09_end` scripts +- **Sync failures** (can't proceed without address books) -Do NOT use `process.exit(1)` when: +Do NOT use `process.exit(1)` for: +- Governance TX generation (use `saveGovernanceTx` which returns) +- Preconditions not met (return/skip, let subsequent scripts check their own preconditions) - Configuration already correct (idempotent check passed) - Script successfully completed its work -- Skipping optional steps ### When to Throw Exceptions @@ -274,15 +304,17 @@ const value = (await client.readContract({ **Pattern**: ```typescript -import { createGovernanceTxBuilder, saveGovernanceTxAndExit } from '@graphprotocol/deployment/lib/execute-governance.js' -import { getGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { + createGovernanceTxBuilder, + executeTxBatchDirect, + saveGovernanceTx, +} from '@graphprotocol/deployment/lib/execute-governance.js' +import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -// Get protocol governor -const governor = await getGovernor(env) +const { governor, canSign } = await canSignAsGovernor(env) // Create TX builder (handles chainId, outputDir, template automatically) -const builder = createGovernanceTxBuilder(env, `action-${Contracts.ContractName.name}`, { +const builder = await createGovernanceTxBuilder(env, `action-${contractName}`, { name: 'Human Readable Name', description: 'What this TX batch does', }) @@ -291,9 +323,13 @@ const builder = createGovernanceTxBuilder(env, `action-${Contracts.ContractName. builder.addTx({ to: contractAddress, value: '0', data: encodedCalldata }) env.showMessage(` + ContractName.functionName(args)`) -// Save and exit using utility -saveGovernanceTxAndExit(env, builder, `${Contracts.ContractName.name} activation`) -// Never returns - exits with code 1 to prevent next steps +// Execute directly if possible, otherwise save for governance +if (canSign) { + await executeTxBatchDirect(env, builder, governor) +} else { + saveGovernanceTx(env, builder, `${contractName} activation`) +} +// Returns — does NOT exit. Subsequent scripts check their own preconditions. ``` ### Metadata Standards @@ -485,7 +521,7 @@ const contract = requireContract(env, 'RewardsManager') ``` deploy/ docs/deploy/ allocate/ IssuanceAllocatorDeployment.md - allocator/ PilotAllocationDeployment.md + allocator/ DirectAllocationDeployment.md 01_deploy.ts rewards/ 02_upgrade.ts RewardsEligibilityOracleDeployment.md 09_end.ts @@ -541,7 +577,7 @@ For contract architecture and technical details, see [IssuanceAllocator.md](../. For every deployment script: -- [ ] Uses `process.exit(1)` for expected prerequisite states +- [ ] Uses `return` (not `process.exit`) for precondition skips and governance TX saves - [ ] Throws exceptions only for unexpected errors - [ ] Is idempotent (checks state, skips if done) - [ ] Uses package imports (`@graphprotocol/deployment`) not relative paths @@ -551,13 +587,15 @@ For every deployment script: - [ ] Works in both fork and production modes - [ ] Has clear, actionable error messages with dynamic values - [ ] Includes comprehensive documentation -- [ ] Follows standard script structure (01_deploy, 02_upgrade, ..., 09_end) +- [ ] Follows standard script structure (01_deploy, 02_upgrade, ..., 09_end, 10_status) - [ ] Properly configures tags and dependencies - [ ] End state script is always `09_end.ts` with only dependencies +- [ ] `10_status.ts` is purely read-only (zero writes, zero TXs, zero exits) ### Anti-Patterns to Avoid -❌ Returning early without exit code when prerequisite not met +❌ Using `process.exit(1)` for precondition skips or governance TX saves (use `return`) +❌ Duplicating precondition checks instead of using shared functions from `lib/preconditions.ts` ❌ Duplicating code instead of using shared utilities ❌ Using relative imports (`../../lib/`) instead of package imports ❌ Using string literals instead of `Contracts` registry @@ -568,5 +606,5 @@ For every deployment script: ❌ Direct address book imports instead of `graph.get*AddressBook()` ❌ Vague error messages without actionable next steps ❌ Non-idempotent scripts that fail on re-run -❌ Generating governance TXs without exiting with code 1 ❌ Using non-standard end script numbering (use `09_end.ts` always) +❌ Any mutation (write, TX, deploy, exit) in a `10_status.ts` script diff --git a/packages/deployment/docs/deploy/IssuanceAllocatorDeployment.md b/packages/deployment/docs/deploy/IssuanceAllocatorDeployment.md index 553157fbd..60a110de5 100644 --- a/packages/deployment/docs/deploy/IssuanceAllocatorDeployment.md +++ b/packages/deployment/docs/deploy/IssuanceAllocatorDeployment.md @@ -1,160 +1,82 @@ # IssuanceAllocator Deployment -This document describes the deployment sequence for IssuanceAllocator. For contract architecture, behavior, and technical details, see [IssuanceAllocator.md](../../../../issuance/contracts/allocate/IssuanceAllocator.md). +This document describes how `IssuanceAllocator` is deployed by this package. For contract architecture, behaviour, and technical details, see [IssuanceAllocator.md](../../../issuance/contracts/allocate/IssuanceAllocator.md). -## Prerequisites +For the goal-level GIP-0088 workflow that orchestrates IA together with the rest of the upgrade, see [Gip0088.md](../Gip0088.md). -- GraphToken contract deployed -- RewardsManager upgraded with `setIssuanceAllocator()` function -- GraphIssuanceProxyAdmin deployed with protocol governance as owner +## Component overview -## Deployment Overview +`IssuanceAllocator` is a deployable proxy in the `issuance` address book: -The deployment strategy safely replicates existing issuance configuration during RewardsManager migration: +- Pattern: OpenZeppelin v5 `TransparentUpgradeableProxy` with a per-proxy `ProxyAdmin` created in the constructor. +- Access control: `BaseUpgradeable` (`GOVERNOR_ROLE`, `PAUSE_ROLE`). +- Component tag: `IssuanceAllocator`. Lifecycle actions: `deploy`, `upgrade`, `configure`, `transfer`. +- Default target: a separate `DefaultAllocation` proxy ([../../deploy/allocate/default/](../../deploy/allocate/default/)) that holds any unallocated issuance as a safety net. -- Default target starts as `address(0)` (that will not be minted to), allowing initial configuration without minting to any targets -- Deployment uses atomic initialization via proxy constructor (prevents front-running) -- Deployment account performs initial configuration, then transfers control to governance -- Granting of minter role can be delayed until replication of initial configuration with upgraded RewardsManager is verified to allow seamless transition to use of IssuanceAllocator -- **Governance control**: This contract uses OpenZeppelin's TransparentUpgradeableProxy pattern (not custom GraphProxy). GraphIssuanceProxyAdmin (owned by protocol governance) controls upgrades, while GOVERNOR_ROLE controls operations. The same governance address should have both roles. +## Lifecycle scripts -For the general governance-gated upgrade workflow, see [GovernanceWorkflow.md](../../../docs/GovernanceWorkflow.md). +| Script | Tag | Actor | Purpose | +| -------------------------------------------------------------------------------------- | ----------------------------- | ---------- | -------------------------------------------------------------------------- | +| [01_deploy.ts](../../deploy/allocate/allocator/01_deploy.ts) | `IssuanceAllocator,deploy` | Deployer | Deploy proxy + implementation, initialize with deployer as governor | +| [02_upgrade.ts](../../deploy/allocate/allocator/02_upgrade.ts) | `IssuanceAllocator,upgrade` | Governance | Build governance TX batch upgrading the proxy to its pendingImplementation | +| [04_configure.ts](../../deploy/allocate/allocator/04_configure.ts) | `IssuanceAllocator,configure` | Deployer | Set issuance rate (matches RM), grant `GOVERNOR_ROLE` and `PAUSE_ROLE` | +| [06_transfer_governance.ts](../../deploy/allocate/allocator/06_transfer_governance.ts) | `IssuanceAllocator,transfer` | Deployer | Revoke deployer `GOVERNOR_ROLE`, transfer per-proxy ProxyAdmin to gov | +| [09_end.ts](../../deploy/allocate/allocator/09_end.ts) | `IssuanceAllocator,all` | - | Aggregate end state — verifies upgrade has been executed | +| [10_status.ts](../../deploy/allocate/allocator/10_status.ts) | `IssuanceAllocator` | - | Read-only status display | -## Deployment Sequence +`03_*`, `05_*`, and `07_08_*` slots are intentionally empty (per [ImplementationPrinciples.md](ImplementationPrinciples.md)). -### Step 1: Deploy and Initialize (deployment account) +## What does NOT happen here -**Script:** [01_deploy.ts](./01_deploy.ts) +The following operations are part of GIP-0088 activation, not the IA component lifecycle. They live in [../../deploy/gip/0088/](../../deploy/gip/0088/) and are governance TXs: -- Deploy IssuanceAllocator implementation with GraphToken address -- Deploy TransparentUpgradeableProxy with implementation, GraphIssuanceProxyAdmin, and initialization data -- **Atomic initialization**: `initialize(deploymentAccountAddress)` called via proxy constructor -- Deployment account receives GOVERNOR_ROLE (temporary, for configuration) -- Automatically creates default target at `targetAddresses[0] = address(0)` -- Sets `lastDistributionBlock = block.number` -- **Security**: Front-running prevented by atomic deployment + initialization +- `IA.setTargetAllocation(RM, 0, rate)` — registers RM as the 100% self-minting target +- `IA.setDefaultTarget(DA)` — wires the safety net +- `RM.setIssuanceAllocator(IA)` — RM starts querying IA for its issuance rate +- `GraphToken.addMinter(IA)` — gives IA minter authority (only needed for allocator-minting targets) +- `IA.setTargetAllocation(RAM, allocatorRate, selfRate)` — distributes issuance to `RecurringAgreementManager` -### Step 2: Set Issuance Rate (deployment account) +These are bundled into the `GIP-0088:upgrade,upgrade` and `GIP-0088:issuance-connect` / `GIP-0088:issuance-allocate` governance batches. See [Gip0088.md](../Gip0088.md) for the full picture. -**Script:** [02_configure.ts](./02_configure.ts) +## Single-component usage -- Query current rate from RewardsManager: `rate = rewardsManager.issuancePerBlock()` -- Call `setIssuancePerBlock(rate)` to replicate existing rate -- All issuance allocated to default target (`address(0)`) -- No tokens minted (default target cannot receive mints) +```bash +# Read-only status +pnpm hardhat deploy --tags IssuanceAllocator --network -### Step 3: Assign RewardsManager Allocation (deployment account) +# Lifecycle steps +pnpm hardhat deploy --tags IssuanceAllocator,deploy --network +pnpm hardhat deploy --tags IssuanceAllocator,configure --network +pnpm hardhat deploy --tags IssuanceAllocator,transfer --network +pnpm hardhat deploy --tags IssuanceAllocator,upgrade --network +``` -**Script:** [02_configure.ts](./02_configure.ts) +The same scripts run as part of the goal-level GIP-0088 flow when invoked via `--tags GIP-0088:upgrade,`. -- Call `setTargetAllocation(rewardsManagerAddress, 0, issuancePerBlock)` -- `allocatorMintingRate = 0` (RewardsManager will self-mint) -- `selfMintingRate = issuancePerBlock` (RewardsManager receives 100% allocation) -- Default target automatically adjusts to zero allocation +## Verification checklist -### Step 4: Verify Configuration Before Transfer (deployment account) +Run `--tags IssuanceAllocator` (component status) or `--tags GIP-0088:upgrade` (goal status) to inspect on-chain state. The status output already covers everything below — this list is for reviewing a finished deployment by hand. -**Script:** [02_configure.ts](./02_configure.ts) +### Bytecode -- Verify contract is not paused (`paused()` returns false) -- Verify `getIssuancePerBlock()` returns expected rate (matches RewardsManager) -- Verify `getTargetAllocation(rewardsManager)` shows correct self-minting configuration -- Verify only two targets exist: `targetAddresses[0] = address(0)` and `targetAddresses[1] = rewardsManager` -- Verify default target is `address(0)` with zero allocation -- Contract is ready to transfer control to governance +- Implementation bytecode matches the expected `IssuanceAllocator` contract -### Step 5: Distribute Issuance (anyone - no role required) +### Access control -**Script:** [02_configure.ts](./02_configure.ts) +- Protocol governor holds `GOVERNOR_ROLE` +- Pause guardian holds `PAUSE_ROLE` +- Deployer does **not** hold `GOVERNOR_ROLE` (asserted by `checkDeployerRevoked` in the transfer step) +- Per-proxy `ProxyAdmin` is owned by the protocol governor -- Call `distributeIssuance()` to bring contract to fully current state -- Updates `lastDistributionBlock` to current block -- Verifies distribution mechanism is functioning correctly -- No tokens minted (no minter role yet, all allocation to self-minting RM) +### Configuration -### Step 6: Set Pause Controls and Transfer Governance (deployment account) +- `getIssuancePerBlock()` matches `RewardsManager.issuancePerBlock()` +- `paused()` is `false` -**Script:** [03_transfer_governance.ts](./03_transfer_governance.ts) +### Activation (GIP-0088) -- Grant PAUSE_ROLE to pause guardian (same account as used for RewardsManager pause control) -- Grant GOVERNOR_ROLE to actual governor address (protocol governance multisig) -- Revoke GOVERNOR_ROLE from deployment account (MUST grant to governance first, then revoke) -- **Note**: Upgrade control (via GraphIssuanceProxyAdmin) is separate from GOVERNOR_ROLE - -### Step 7: Verify Deployment and Configuration (governor) - -**Script:** [04_verify.ts](./04_verify.ts) - -**Bytecode verification:** - -- Verify deployed implementation bytecode matches expected contract - -**Access control:** - -- Verify governance address has GOVERNOR_ROLE -- Verify deployment account does NOT have GOVERNOR_ROLE -- Verify pause guardian has PAUSE_ROLE -- **Off-chain**: Review all RoleGranted events since deployment to verify no other addresses have GOVERNOR_ROLE or PAUSE_ROLE - -**Pause state:** - -- Verify contract is not paused (`paused()` returns false) - -**Issuance rate:** - -- Verify `getIssuancePerBlock()` matches RewardsManager rate exactly - -**Target configuration:** - -- Verify only two targets exist: `targetAddresses[0] = address(0)` and `targetAddresses[1] = rewardsManager` -- Verify default target is `address(0)` with zero allocation -- Verify `getTargetAllocation(rewardsManager)` shows correct self-minting allocation (100%) - -**Proxy configuration:** - -- Verify GraphIssuanceProxyAdmin controls the proxy -- Verify GraphIssuanceProxyAdmin owner is protocol governance - -### Step 8: Configure RewardsManager (governor) - -**Script:** [05_configure_rewards_manager.ts](./05_configure_rewards_manager.ts) - -- Call `rewardsManager.setIssuanceAllocator(issuanceAllocatorAddress)` -- RewardsManager will now query IssuanceAllocator for its issuance rate -- RewardsManager continues to mint tokens itself (self-minting) - -### Step 9: Grant Minter Role (governor, only when configuration verified) - -**Script:** [06_grant_minter.ts](./06_grant_minter.ts) - -- Grant minter role to IssuanceAllocator on Graph Token - -### Step 10: Set Default Target (governor, optional, recommended) - -**Script:** [07_set_default_target.ts](./07_set_default_target.ts) - -- Call `setDefaultTarget()` to receive future unallocated issuance - -## Normal Operation - -After deployment: - -1. Targets or external actors call `distributeIssuance()` periodically -2. Governor adjusts issuance rates as needed via `setIssuancePerBlock()` -3. Governor adds/removes/modifies targets via `setTargetAllocation()` overloads -4. Self-minting targets query their allocation via `getTargetIssuancePerBlock()` - -## Emergency Scenarios - -- **Gas limit issues**: Use pause, individual notifications, and `minDistributedBlock` parameters with `distributePendingIssuance()` -- **Target failures**: Use `forceTargetNoChangeNotificationBlock()` to skip notification, then remove problematic targets by setting both rates to 0 -- **Configuration while paused**: Call `distributePendingIssuance(blockNumber)` first, then use `minDistributedBlock` parameter in setter functions - -## L1 Bridge Integration - -When `setIssuancePerBlock()` is called, the L1GraphTokenGateway's `updateL2MintAllowance()` function must be called to ensure the bridge can mint the correct amount of tokens on L2. - -## See Also - -- [IssuanceAllocator.md](../../../../issuance/contracts/allocate/IssuanceAllocator.md) - Contract architecture and technical details -- [GovernanceWorkflow.md](../../../docs/GovernanceWorkflow.md) - General governance-gated upgrade workflow +- `RewardsManager.getIssuanceAllocator()` returns the IA address +- `GraphToken.isMinter(IA)` is `true` (only when allocator-minting targets exist) +- `getTargetAllocation(RM)` shows `selfMintingRate == issuancePerBlock`, `allocatorMintingRate == 0` +- `getTargetAllocation(RAM)` matches `config/.json5` rates +- Default target points at `DefaultAllocation` diff --git a/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md b/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md index 9a5c1bfde..50f6592c8 100644 --- a/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md +++ b/packages/deployment/docs/deploy/RewardsEligibilityOracleDeployment.md @@ -5,7 +5,7 @@ Deployment guide for RewardsEligibilityOracle (REO). **Related:** - [Contract specification](../../../issuance/contracts/eligibility/RewardsEligibilityOracle.md) - architecture, operations, troubleshooting -- [GovernanceWorkflow.md](./GovernanceWorkflow.md) - Safe TX execution +- [GovernanceWorkflow.md](../GovernanceWorkflow.md) - Safe TX execution ## Prerequisites @@ -17,26 +17,35 @@ Deployment guide for RewardsEligibilityOracle (REO). All scripts are idempotent. -| Script | Tag | Actor | Purpose | -| --------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------- | -------------------------------------- | -| [01_deploy.ts](../../deploy/rewards/eligibility/01_deploy.ts) | `rewards-eligibility-deploy` | Deployer | Deploy proxy + implementation | -| [02_upgrade.ts](../../deploy/rewards/eligibility/02_upgrade.ts) | `rewards-eligibility-upgrade` | Governance | Upgrade implementation | -| [04_configure.ts](../../deploy/rewards/eligibility/04_configure.ts) | `rewards-eligibility-configure` | Deployer/Governance | Set parameters | -| [05_transfer_governance.ts](../../deploy/rewards/eligibility/05_transfer_governance.ts) | `rewards-eligibility-transfer-governance` | Deployer | Grant roles, transfer to governance | -| [06_integrate.ts](../../deploy/rewards/eligibility/06_integrate.ts) | `rewards-eligibility-integrate` | Governance | Connect to RewardsManager | -| [09_complete.ts](../../deploy/rewards/eligibility/09_complete.ts) | `rewards-eligibility` | - | Aggregate (deploy, upgrade, configure) | +| Script | Tag | Actor | Purpose | +| --------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------- | ----------------------------------------- | +| [01_deploy.ts](../../deploy/rewards/eligibility/01_deploy.ts) | `RewardsEligibilityOracle{A,B}:deploy` | Deployer | Deploy proxy + implementation | +| [02_upgrade.ts](../../deploy/rewards/eligibility/02_upgrade.ts) | `RewardsEligibilityOracle{A,B}:upgrade` | Governance | Upgrade implementation | +| [04_configure.ts](../../deploy/rewards/eligibility/04_configure.ts) | `RewardsEligibilityOracle{A,B}:configure` | Deployer/Governance | Set parameters | +| [05_transfer_governance.ts](../../deploy/rewards/eligibility/05_transfer_governance.ts) | `RewardsEligibilityOracle{A,B}:transfer` | Deployer | Revoke deployer role, transfer ProxyAdmin | +| [09_end.ts](../../deploy/rewards/eligibility/09_end.ts) | `RewardsEligibilityOracle{A,B}` | - | Aggregate (deploy, upgrade, configure) | + +Integration with `RewardsManager` is **not** a per-component lifecycle action. Only one of REO-A or REO-B is integrated at a time, which is a goal-level decision. Use the GIP-0088 activation tag instead: + +```bash +pnpm hardhat deploy --tags GIP-0088:eligibility-integrate --network +``` + +The testnet `MockRewardsEligibilityOracle` does have its own `06_integrate.ts` because it has no goal-tag equivalent. ### Quick Start ```bash -# Full deployment (new install) -pnpm hardhat deploy --tags rewards-eligibility --network +# Read-only status (no --tags = no mutations) +pnpm hardhat deploy --tags RewardsEligibilityOracleA --network # Individual steps -pnpm hardhat deploy --tags rewards-eligibility-deploy --network -pnpm hardhat deploy --tags rewards-eligibility-configure --network -pnpm hardhat deploy --tags rewards-eligibility-transfer-governance --network -pnpm hardhat deploy --tags rewards-eligibility-integrate --network +pnpm hardhat deploy --tags RewardsEligibilityOracleA,deploy --network +pnpm hardhat deploy --tags RewardsEligibilityOracleA,configure --network +pnpm hardhat deploy --tags RewardsEligibilityOracleA,transfer --network + +# Integrate (only one of A/B at a time — goal-level) +pnpm hardhat deploy --tags GIP-0088:eligibility-integrate --network ``` ## Verification Checklist diff --git a/packages/deployment/hardhat.config.ts b/packages/deployment/hardhat.config.ts index 08b85b027..2be1995ba 100644 --- a/packages/deployment/hardhat.config.ts +++ b/packages/deployment/hardhat.config.ts @@ -11,12 +11,17 @@ import hardhatDeploy from 'hardhat-deploy' import checkDeployerTask from './tasks/check-deployer.js' // Import tasks (HH v3 task API) import deploymentStatusTask from './tasks/deployment-status.js' +import { ethBalanceTask, ethCheckKeyTask, ethFundTask } from './tasks/eth-tasks.js' import executeGovernanceTask from './tasks/execute-governance.js' import grantRoleTask from './tasks/grant-role.js' +import { grtBalanceTask, grtMintTask, grtStatusTask, grtTransferTask } from './tasks/grt-tasks.js' import listPendingTask from './tasks/list-pending-implementations.js' import listRolesTask from './tasks/list-roles.js' +import { reoDisableTask, reoEnableTask, reoIndexersTask, reoStatusTask } from './tasks/reo-tasks.js' import resetForkTask from './tasks/reset-fork.js' import revokeRoleTask from './tasks/revoke-role.js' +import { ssStatusTask } from './tasks/ss-tasks.js' +import syncTask from './tasks/sync.js' import verifyContractTask from './tasks/verify-contract.js' // ESM compatibility @@ -26,6 +31,14 @@ const __dirname = path.dirname(__filename) // Package paths const packageRoot = __dirname +// Hardhat v3 does not auto-set HARDHAT_NETWORK (v2 did). +// isLocalNetworkMode() in address-book-utils.ts relies on this env var to +// select addresses-local-network.json over addresses.json. +const networkArg = process.argv.find((_, i, a) => a[i - 1] === '--network') +if (networkArg === 'localNetwork') { + process.env.HARDHAT_NETWORK = 'localNetwork' +} + // RPC URLs with defaults const ARBITRUM_ONE_RPC = process.env.ARBITRUM_ONE_RPC || 'https://arb1.arbitrum.io/rpc' const ARBITRUM_SEPOLIA_RPC = process.env.ARBITRUM_SEPOLIA_RPC || 'https://sepolia-rollup.arbitrum.io/rpc' @@ -50,10 +63,94 @@ function getDeployerKeyName(networkName: string): string { } /** - * Get accounts config for a network using configVariable for lazy resolution + * Parse --tags from process.argv. + * Returns null when --tags is not present. + */ +function parseTagsFromArgv(): string[] | null { + const argv = process.argv + for (let i = 0; i < argv.length; i++) { + const a = argv[i] + if (a === '--tags') { + if (i + 1 >= argv.length) return null + return argv[i + 1].split(',') + } + if (a.startsWith('--tags=')) { + return a.slice('--tags='.length).split(',') + } + } + return null +} + +/** + * Detect whether the current invocation needs a deployer account. + * + * The deployer key is only needed when the `deploy` task is invoked with + * action verbs in `--tags` that perform mutations (deploy, upgrade, configure, + * transfer, integrate, all). Status-only runs (`--tags Component` without + * action verbs) are read-only and don't need the deployer key. + * + * Other tasks (reo:enable, grant-role, eth:fund, ...) resolve keys at + * execution time via resolveConfigVar(), and read-only tasks need no key + * at all. + * + * Gating configVariable() on this lets the hardhat-keystore plugin prompt for + * the password only when the user actually runs a mutating deploy action, + * instead of on every `deploy` invocation. + */ +function getTaskName(): string | null { + for (const arg of process.argv.slice(2)) { + if (arg.startsWith('-')) continue + return arg + } + return null +} + +function needsDeployerAccount(): boolean { + // Non-deploy tasks resolve keys at runtime; deploy:sync is read-only + if (getTaskName() !== 'deploy') return false + + // Status-only runs (no action verbs in --tags) don't need a signer + const tags = parseTagsFromArgv() + if (!tags) return false + + const ACTION_VERBS = ['deploy', 'upgrade', 'configure', 'transfer', 'integrate', 'all'] + return tags.some((tag) => ACTION_VERBS.includes(tag)) +} + +/** + * Dummy private key used when no real deployer key is needed. + * + * Rocketh requires at least one account to resolve namedAccounts.deployer. + * For status-only runs we provide this throwaway key so environment creation + * succeeds without prompting the keystore. The resulting address + * (0x7E5F...95Bdf) is filtered out by getDeployer() — status scripts infer + * the real deployer from the ProxyAdmin owner on-chain. + */ +const DUMMY_DEPLOYER_KEY = '0x0000000000000000000000000000000000000000000000000000000000000001' + +/** + * Get accounts config for a network. + * + * When the deploy task is invoked with action verbs (deploy, upgrade, etc.), + * returns a configVariable so the hardhat-keystore plugin resolves the + * deployer key from the keystore (with env-var fallback). + * + * For status-only deploy runs and all other tasks, returns a dummy key so + * rocketh can initialise namedAccounts without a keystore prompt. Signing + * tasks resolve keys themselves via resolveConfigVar(). + * + * Set the key via either: + * npx hardhat keystore set ARBITRUM_SEPOLIA_DEPLOYER_KEY + * export ARBITRUM_SEPOLIA_DEPLOYER_KEY=0x... */ const getNetworkAccounts = (networkName: string) => { - return [configVariable(getDeployerKeyName(networkName))] + if (!needsDeployerAccount()) return [DUMMY_DEPLOYER_KEY] + const keyName = getDeployerKeyName(networkName) + if (networkName === networkArg && !process.env[keyName]) { + console.log(`\n Deployer key: ${keyName}`) + console.log(` Set via: npx hardhat keystore set ${keyName}\n`) + } + return [configVariable(keyName)] } // Fork network detection (HARDHAT_FORK is the standard for hardhat-deploy v2) @@ -67,10 +164,23 @@ const config: HardhatUserConfig = { tasks: [ checkDeployerTask, deploymentStatusTask, + ethBalanceTask, + ethCheckKeyTask, + ethFundTask, executeGovernanceTask, grantRoleTask, + grtBalanceTask, + grtMintTask, + grtStatusTask, + grtTransferTask, listPendingTask, listRolesTask, + reoDisableTask, + reoEnableTask, + reoIndexersTask, + reoStatusTask, + ssStatusTask, + syncTask, resetForkTask, revokeRoleTask, verifyContractTask, @@ -78,6 +188,17 @@ const config: HardhatUserConfig = { // Chain descriptors for fork execution and local development chainDescriptors: { + // Graph Local Network (rem-local-network, docker-compose stack) + 1337: { + name: 'Graph Local Network', + hardforkHistory: { + berlin: { blockNumber: 0 }, + london: { blockNumber: 0 }, + merge: { blockNumber: 0 }, + shanghai: { blockNumber: 0 }, + cancun: { blockNumber: 0 }, + }, + }, // Local hardhat network (for non-fork runs) 31337: { name: 'Hardhat Local', @@ -155,6 +276,17 @@ const config: HardhatUserConfig = { } : undefined, }, + // Graph Local Network (rem-local-network docker-compose stack) + // Contracts deployed fresh with hardhat-graph-protocol (Phase 1) + // Address books use addresses-local-network.json files + localNetwork: { + type: 'http', + url: process.env.LOCAL_NETWORK_RPC || 'http://chain:8545', + chainId: 1337, + accounts: { + mnemonic: 'test test test test test test test test test test test junk', + }, + }, arbitrumOne: { type: 'http', chainId: 42161, @@ -172,11 +304,11 @@ const config: HardhatUserConfig = { // External artifacts are loaded via direct imports in deploy scripts // Contract verification config (hardhat-verify v3) - // API key resolves from keystore or env: npx hardhat keystore set ARBISCAN_API_KEY - // Sourcify and Blockscout disabled - they don't work reliably for Arbitrum + // API key from keystore, gated to deploy:verify to avoid prompting on every task. + // Set via: npx hardhat keystore set ARBISCAN_API_KEY verify: { etherscan: { - apiKey: configVariable('ARBISCAN_API_KEY'), + apiKey: getTaskName() === 'deploy:verify' ? configVariable('ARBISCAN_API_KEY') : '', }, sourcify: { enabled: false, diff --git a/packages/deployment/lib/abis.ts b/packages/deployment/lib/abis.ts index 0e442edbe..ece524796 100644 --- a/packages/deployment/lib/abis.ts +++ b/packages/deployment/lib/abis.ts @@ -1,86 +1,86 @@ /** * Shared ABI definitions for contract interactions * - * These ABIs are loaded from @graphprotocol/interfaces artifacts to ensure they stay in sync - * with the actual contract interfaces. The interfaces package is the canonical source for ABIs. + * Generated ABIs are produced by `pnpm generate:abis` from contract artifacts. + * The contract registry drives which ABIs and interface IDs are generated. + * Only ACCESS_CONTROL_ENUMERABLE_ABI is hand-maintained (generic role queries). */ -import { readFileSync } from 'node:fs' -import { createRequire } from 'node:module' -import type { Abi } from 'viem' +// Re-export all generated typed ABIs, aliases, and interface IDs +export { + CONTROLLER_ABI, + DIRECT_ALLOCATION_ABI, + GRAPH_PROXY_ADMIN_ABI, + GRAPH_TOKEN_ABI, + IERC165_ABI, + IERC165_INTERFACE_ID, + IISSUANCE_TARGET_INTERFACE_ID, + INITIALIZE_GOVERNOR_ABI, + IREWARDS_MANAGER_INTERFACE_ID, + ISSUANCE_ALLOCATOR_ABI, + ISSUANCE_TARGET_ABI, + OZ_PROXY_ADMIN_ABI, + PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + REWARDS_ELIGIBILITY_ORACLE_ABI, + REWARDS_MANAGER_ABI, + REWARDS_MANAGER_DEPRECATED_ABI, + SET_TARGET_ALLOCATION_ABI, +} from './generated/abis.js' -const require = createRequire(import.meta.url) - -// Helper to load ABI from interface artifact -function loadAbi(artifactPath: string): Abi { - const artifact = JSON.parse(readFileSync(require.resolve(artifactPath), 'utf-8')) - return artifact.abi as Abi -} - -// Interface IDs - these match the generated values from TypeChain factories -// Verified by tests: packages/issuance/testing/tests/allocate/InterfaceIdStability.test.ts -// and packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts -export const IERC165_INTERFACE_ID = '0x01ffc9a7' as const -export const IISSUANCE_TARGET_INTERFACE_ID = '0x19f6601a' as const -export const IREWARDS_MANAGER_INTERFACE_ID = '0xa0a2f219' as const - -export const REWARDS_MANAGER_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/contracts/rewards/IRewardsManager.sol/IRewardsManager.json', -) - -// Deprecated interface includes legacy functions like issuancePerBlock() -export const REWARDS_MANAGER_DEPRECATED_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/contracts/rewards/IRewardsManagerDeprecated.sol/IRewardsManagerDeprecated.json', -) - -export const CONTROLLER_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/toolshed/IControllerToolshed.sol/IControllerToolshed.json', -) - -// Core interfaces -export const GRAPH_TOKEN_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/contracts/token/IGraphToken.sol/IGraphToken.json', -) - -export const GRAPH_PROXY_ADMIN_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/contracts/upgrades/IGraphProxyAdmin.sol/IGraphProxyAdmin.json', -) - -export const IERC165_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/@openzeppelin/contracts/introspection/IERC165.sol/IERC165.json', -) - -// Issuance interfaces -export const ISSUANCE_TARGET_ABI = loadAbi( - '@graphprotocol/interfaces/artifacts/contracts/issuance/allocate/IIssuanceTarget.sol/IIssuanceTarget.json', -) - -// --- ABIs loaded from @graphprotocol/horizon (OZ contracts) --- -// These are not in interfaces package, load from horizon build - -export const OZ_PROXY_ADMIN_ABI = loadAbi( - '@graphprotocol/horizon/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json', -) - -// --- ABIs loaded from @graphprotocol/issuance --- -// Full contract ABIs for deployment operations that need access to all methods - -export const ISSUANCE_ALLOCATOR_ABI = loadAbi( - '@graphprotocol/issuance/artifacts/contracts/allocate/IssuanceAllocator.sol/IssuanceAllocator.json', -) - -export const DIRECT_ALLOCATION_ABI = loadAbi( - '@graphprotocol/issuance/artifacts/contracts/allocate/DirectAllocation.sol/DirectAllocation.json', -) +// ============================================================================ +// Hand-rolled minimal ABIs (not in @graphprotocol/interfaces) +// ============================================================================ -export const REWARDS_ELIGIBILITY_ORACLE_ABI = loadAbi( - '@graphprotocol/issuance/artifacts/contracts/eligibility/RewardsEligibilityOracle.sol/RewardsEligibilityOracle.json', -) +/** + * Minimal ABI for RecurringCollector pause guardian management + * + * RC's pause guardian functions are not part of an interface in + * @graphprotocol/interfaces. Used by RC configure and the GIP-0088 upgrade + * batch to manage `setPauseGuardian` / `pauseGuardians`. + */ +export const RECURRING_COLLECTOR_PAUSE_ABI = [ + { + inputs: [{ name: '_pauseGuardian', type: 'address' }], + name: 'pauseGuardians', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { name: '_pauseGuardian', type: 'address' }, + { name: '_allowed', type: 'bool' }, + ], + name: 'setPauseGuardian', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const -// Convenience re-exports for specific function subsets -// These reference the full ABIs above - viem will find the right function by name -export { ISSUANCE_ALLOCATOR_ABI as SET_TARGET_ALLOCATION_ABI } -export { DIRECT_ALLOCATION_ABI as INITIALIZE_GOVERNOR_ABI } +/** + * Minimal ABI for SubgraphService allocation close guard + * + * `blockClosingAllocationWithActiveAgreement` is part of the SS interface but + * not generated yet. Used by `GIP-0088:issuance-close-guard` and the goal + * status display. + */ +export const SUBGRAPH_SERVICE_CLOSE_GUARD_ABI = [ + { + inputs: [], + name: 'getBlockClosingAllocationWithActiveAgreement', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ name: 'enabled', type: 'bool' }], + name: 'setBlockClosingAllocationWithActiveAgreement', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const // ============================================================================ // Generic ABIs for role enumeration diff --git a/packages/deployment/lib/address-book-utils.ts b/packages/deployment/lib/address-book-utils.ts index 0de0db016..1ab196ac7 100644 --- a/packages/deployment/lib/address-book-utils.ts +++ b/packages/deployment/lib/address-book-utils.ts @@ -32,24 +32,150 @@ import { AddressBookOps } from './address-book-ops.js' const require = createRequire(import.meta.url) +// ============================================================================ +// Fork Auto-Detection +// ============================================================================ + +/** + * Build a map from RPC URL hostname to network name using rocketh config. + * Used by autoDetectForkNetwork() to match anvil's forkUrl. + */ +function buildRpcHostToNetworkMap(): Map { + const map = new Map() + const environments = rockethConfig.environments + const chains = rockethConfig.chains + if (!environments || !chains) return map + + for (const [envName, envConfig] of Object.entries(environments)) { + const chainId = (envConfig as { chain: number }).chain + const chainConfig = (chains as Record)[chainId] as + | { info?: { rpcUrls?: { default?: { http?: readonly string[] } } } } + | undefined + const rpcUrls = chainConfig?.info?.rpcUrls?.default?.http + if (!rpcUrls) continue + + for (const rpcUrl of rpcUrls) { + try { + const hostname = new URL(rpcUrl).hostname + map.set(hostname, { name: envName, chainId }) + } catch { + // Skip invalid URLs + } + } + } + return map +} + +/** + * Auto-detect the fork network by querying anvil's `anvil_nodeInfo` RPC method. + * + * If FORK_NETWORK is already set, this is a no-op. + * If the provider is an anvil fork, extracts the fork URL and matches it + * against known network RPC hostnames from rocketh config. + * + * On success, sets process.env.FORK_NETWORK so all downstream synchronous + * functions (isForkMode, getForkNetwork, etc.) work without changes. + * + * @param rpcUrl - The RPC URL to query (default: http://127.0.0.1:8545) + * @returns The detected network name, or null if not a fork / not detectable + */ +export async function autoDetectForkNetwork(rpcUrl = 'http://127.0.0.1:8545'): Promise { + // Already set — nothing to do + if (process.env.FORK_NETWORK || process.env.HARDHAT_FORK) { + return process.env.FORK_NETWORK || process.env.HARDHAT_FORK || null + } + + try { + const response = await fetch(rpcUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ jsonrpc: '2.0', method: 'anvil_nodeInfo', params: [], id: 1 }), + }) + const json = (await response.json()) as { + result?: { forkConfig?: { forkUrl?: string } } + } + const forkUrl = json.result?.forkConfig?.forkUrl + if (!forkUrl) return null + + // Match fork URL hostname against known networks + const hostMap = buildRpcHostToNetworkMap() + const forkHostname = new URL(forkUrl).hostname + const match = hostMap.get(forkHostname) + if (!match) return null + + // Set env var so all synchronous fork detection works downstream + process.env.FORK_NETWORK = match.name + return match.name + } catch { + // Not reachable or not anvil — not a fork + return null + } +} + // ============================================================================ // Fork Mode Detection // ============================================================================ +/** Network names that are local/test and support fork mode */ +const LOCAL_NETWORKS = new Set(['localhost', 'fork', 'hardhat']) + +/** + * Check if the current network is a local network. + * Uses explicit networkName if provided, falls back to HARDHAT_NETWORK env var. + * Returns true if network is unknown (preserves existing behavior for callers + * that don't pass context). + */ +function isLocalNetwork(networkName?: string): boolean { + const name = networkName ?? process.env.HARDHAT_NETWORK + if (name === undefined) return true + return LOCAL_NETWORKS.has(name) +} + /** - * Check if running in fork mode + * Check if running in fork mode. + * + * Fork mode requires both: + * 1. FORK_NETWORK or HARDHAT_FORK env var is set + * 2. The current network is local (localhost, fork, hardhat) + * + * This prevents fork mode from activating when running against real networks + * even if FORK_NETWORK is still set in the environment. + * + * @param networkName - Optional network name for explicit check (e.g., env.name). + * Falls back to HARDHAT_NETWORK env var if not provided. */ -export function isForkMode(): boolean { +export function isForkMode(networkName?: string): boolean { + if (!isLocalNetwork(networkName)) return false return !!(process.env.HARDHAT_FORK || process.env.FORK_NETWORK) } /** - * Get the fork network name from environment + * Get the fork network name from environment. + * Returns null if not in fork mode or if running on a real network. + * + * @param networkName - Optional network name for explicit check. + * Falls back to HARDHAT_NETWORK env var if not provided. */ -export function getForkNetwork(): string | null { +export function getForkNetwork(networkName?: string): string | null { + if (!isLocalNetwork(networkName)) return null return process.env.HARDHAT_FORK || process.env.FORK_NETWORK || null } +// ============================================================================ +// Local Network Detection +// ============================================================================ + +/** + * Check if running against the Graph local network (rem-local-network). + * + * The local network uses chainId 1337 and deploys contracts from scratch. + * Address books use addresses-local-network.json files which are symlinked + * to mounted config files in the Docker container (populated by Phase 1). + */ +export function isLocalNetworkMode(): boolean { + return process.env.HARDHAT_NETWORK === 'localNetwork' +} + /** * Get the fork state directory for a given network. * All fork-related state (address books, governance TXs) is stored here. @@ -75,8 +201,8 @@ export function getForkStateDir(envName: string, forkNetwork: string): string { * const forkChainId = getForkTargetChainId() * const targetChainId = forkChainId ?? providerChainId */ -export function getForkTargetChainId(): number | null { - const forkNetwork = getForkNetwork() +export function getForkTargetChainId(networkName?: string): number | null { + const forkNetwork = getForkNetwork(networkName) if (!forkNetwork) return null // Look up chain ID from rocketh config environments @@ -117,14 +243,28 @@ export function getForkTargetChainId(): number | null { * const addressBook = getIssuanceAddressBook(targetChainId) */ export async function getTargetChainIdFromEnv(env: Environment): Promise { - const forkChainId = getForkTargetChainId() + const forkChainId = getForkTargetChainId(env.name) if (forkChainId !== null) { return forkChainId } // Not in fork mode - get actual chain ID from provider const chainIdHex = await env.network.provider.request({ method: 'eth_chainId' }) - return Number(chainIdHex) + const providerChainId = Number(chainIdHex) + + // If we're on local chain 31337 without FORK_NETWORK set, the user is most + // likely running against an anvil fork. Try auto-detecting once so callers + // (per-component sync, status scripts) can resolve the right address book + // without requiring the global sync script to have run first. + if (providerChainId === 31337 && !getForkNetwork(env.name)) { + const detected = await autoDetectForkNetwork() + if (detected) { + const detectedForkChainId = getForkTargetChainId(env.name) + if (detectedForkChainId !== null) return detectedForkChainId + } + } + + return providerChainId } // ============================================================================ @@ -206,6 +346,7 @@ export function ensureForkAddressBooks(): { /** * Get the path to the Horizon address book. * In fork mode, returns path to fork-local copy. + * In local network mode, returns path to addresses-local-network.json. * In normal mode, returns path to package address book. */ export function getHorizonAddressBookPath(): string { @@ -213,12 +354,16 @@ export function getHorizonAddressBookPath(): string { const { horizonPath } = ensureForkAddressBooks() return horizonPath } + if (isLocalNetworkMode()) { + return require.resolve('@graphprotocol/horizon/addresses-local-network.json') + } return require.resolve('@graphprotocol/horizon/addresses.json') } /** * Get the path to the SubgraphService address book. * In fork mode, returns path to fork-local copy. + * In local network mode, returns path to addresses-local-network.json. * In normal mode, returns path to package address book. */ export function getSubgraphServiceAddressBookPath(): string { @@ -226,12 +371,16 @@ export function getSubgraphServiceAddressBookPath(): string { const { subgraphServicePath } = ensureForkAddressBooks() return subgraphServicePath } + if (isLocalNetworkMode()) { + return require.resolve('@graphprotocol/subgraph-service/addresses-local-network.json') + } return require.resolve('@graphprotocol/subgraph-service/addresses.json') } /** * Get the path to the Issuance address book. * In fork mode, returns path to fork-local copy. + * In local network mode, returns path to addresses-local-network.json. * In normal mode, returns path to package address book. */ export function getIssuanceAddressBookPath(): string { @@ -239,6 +388,9 @@ export function getIssuanceAddressBookPath(): string { const { issuancePath } = ensureForkAddressBooks() return issuancePath } + if (isLocalNetworkMode()) { + return require.resolve('@graphprotocol/issuance/addresses-local-network.json') + } return require.resolve('@graphprotocol/issuance/addresses.json') } diff --git a/packages/deployment/lib/apply-configuration.ts b/packages/deployment/lib/apply-configuration.ts index b7615b844..8bc4e14a1 100644 --- a/packages/deployment/lib/apply-configuration.ts +++ b/packages/deployment/lib/apply-configuration.ts @@ -17,7 +17,7 @@ import { type RoleCondition, checkConditions, } from './contract-checks.js' -import { createGovernanceTxBuilder, executeTxBatchDirect, saveGovernanceTxAndExit } from './execute-governance.js' +import { createGovernanceTxBuilder, executeTxBatchDirect, saveGovernanceTx } from './execute-governance.js' /** * Options for applyConfiguration @@ -145,10 +145,8 @@ export async function applyConfiguration( env.showMessage(`\n✅ ${contractName} configuration updated\n`) return { status, changesNeeded: true, executedDirectly: true } } else { - // Never returns - exits with code 1 - saveGovernanceTxAndExit(env, builder, `${contractName} configuration`) - // TypeScript doesn't know saveGovernanceTxAndExit never returns - throw new Error('unreachable') + saveGovernanceTx(env, builder, `${contractName} configuration`) + return { status, changesNeeded: true, executedDirectly: false } } } diff --git a/packages/deployment/lib/artifact-loaders.ts b/packages/deployment/lib/artifact-loaders.ts index 786f47773..e48c6e587 100644 --- a/packages/deployment/lib/artifact-loaders.ts +++ b/packages/deployment/lib/artifact-loaders.ts @@ -3,6 +3,8 @@ import { createRequire } from 'node:module' import type { Artifact } from '@rocketh/core/types' +import type { LibraryArtifactResolver, LinkReferences } from './bytecode-utils.js' + // Create require for JSON imports in ESM const require = createRequire(import.meta.url) @@ -31,8 +33,10 @@ export function loadContractsArtifact(contractPath: string, contractName: string * @param contractName - Contract name (e.g., 'SubgraphService') */ export function loadSubgraphServiceArtifact(contractName: string): Artifact { + // Support subdirectory names like 'libraries/IndexingAgreement' + const baseName = contractName.includes('/') ? contractName.split('/').pop()! : contractName const artifactPath = require.resolve( - `@graphprotocol/subgraph-service/artifacts/contracts/${contractName}.sol/${contractName}.json`, + `@graphprotocol/subgraph-service/artifacts/contracts/${contractName}.sol/${baseName}.json`, ) const artifact = JSON.parse(readFileSync(artifactPath, 'utf-8')) @@ -41,6 +45,8 @@ export function loadSubgraphServiceArtifact(contractName: string): Artifact { bytecode: artifact.bytecode as `0x${string}`, deployedBytecode: artifact.deployedBytecode as `0x${string}`, metadata: artifact.metadata || '', + linkReferences: artifact.linkReferences, + deployedLinkReferences: artifact.deployedLinkReferences, } } @@ -57,6 +63,8 @@ export function loadIssuanceArtifact(artifactSubpath: string): Artifact { bytecode: artifact.bytecode as `0x${string}`, deployedBytecode: artifact.deployedBytecode as `0x${string}`, metadata: artifact.metadata || '', + linkReferences: artifact.linkReferences, + deployedLinkReferences: artifact.deployedLinkReferences, } } @@ -66,13 +74,15 @@ export function loadIssuanceArtifact(artifactSubpath: string): Artifact { * @param artifactSubpath - Path within build/contracts/ (e.g., '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin') */ export function loadHorizonBuildArtifact(artifactSubpath: string): Artifact { - const artifactPath = require.resolve(`@graphprotocol/horizon/build/contracts/${artifactSubpath}.json`) + const artifactPath = require.resolve(`@graphprotocol/horizon/artifacts/${artifactSubpath}.json`) const artifact = JSON.parse(readFileSync(artifactPath, 'utf-8')) return { abi: artifact.abi, bytecode: artifact.bytecode as `0x${string}`, deployedBytecode: artifact.deployedBytecode as `0x${string}`, metadata: artifact.metadata || '', + linkReferences: artifact.linkReferences, + deployedLinkReferences: artifact.deployedLinkReferences, } } @@ -92,6 +102,88 @@ export function loadOpenZeppelinArtifact(contractName: string): Artifact { } } +/** + * Create a library artifact resolver for a given package. + * + * Library artifacts live at /artifacts//.json, + * mirroring the linkReferences source paths from Hardhat compilation. + */ +function createPackageLibraryResolver(packagePrefix: string): LibraryArtifactResolver { + return (sourcePath: string, libraryName: string) => { + try { + const libPath = require.resolve(`${packagePrefix}/${sourcePath}/${libraryName}.json`) + const artifact = JSON.parse(readFileSync(libPath, 'utf-8')) + return { + deployedBytecode: artifact.deployedBytecode as string, + deployedLinkReferences: artifact.deployedLinkReferences as LinkReferences | undefined, + } + } catch { + return undefined + } + } +} + +/** + * Get a library artifact resolver for the given artifact source type. + * Returns undefined if the source type doesn't support library resolution. + */ +export function getLibraryResolver(sourceType: string): LibraryArtifactResolver | undefined { + switch (sourceType) { + case 'subgraph-service': + return createPackageLibraryResolver('@graphprotocol/subgraph-service/artifacts') + case 'horizon': + return createPackageLibraryResolver('@graphprotocol/horizon/artifacts') + case 'issuance': + return createPackageLibraryResolver('@graphprotocol/issuance/artifacts') + case 'contracts': + return createPackageLibraryResolver('@graphprotocol/contracts/artifacts') + default: + return undefined + } +} + +/** + * Pre-link library addresses into an artifact's creation bytecode. + * + * Rocketh's deploy() stores the artifact's bytecode verbatim but compares + * against linked bytecode on subsequent runs. For artifacts with library + * references this causes a permanent mismatch (unlinked placeholders vs + * resolved addresses), triggering a redeploy every time. + * + * Call this before passing the artifact to rocketh's deploy(). The returned + * artifact has fully resolved bytecode and cleared linkReferences, so + * rocketh stores what it will compare against next run. + * + * @param artifact - Artifact with unlinked bytecode and linkReferences + * @param libraries - Map of library name → deployed address + */ +export function linkArtifactLibraries(artifact: Artifact, libraries: Record): Artifact { + let bytecode = artifact.bytecode as string + + if (artifact.linkReferences) { + for (const [, fileReferences] of Object.entries( + artifact.linkReferences as Record>>, + )) { + for (const [libName, fixups] of Object.entries(fileReferences)) { + const addr = libraries[libName] + if (!addr) continue + for (const fixup of fixups) { + bytecode = + bytecode.substring(0, 2 + fixup.start * 2) + + addr.substring(2) + + bytecode.substring(2 + (fixup.start + fixup.length) * 2) + } + } + } + } + + return { + ...artifact, + bytecode: bytecode as `0x${string}`, + linkReferences: undefined, + } +} + /** * Load OpenZeppelin TransparentUpgradeableProxy artifact (v5) */ diff --git a/packages/deployment/lib/bytecode-utils.ts b/packages/deployment/lib/bytecode-utils.ts index 38825df29..f08795b48 100644 --- a/packages/deployment/lib/bytecode-utils.ts +++ b/packages/deployment/lib/bytecode-utils.ts @@ -1,16 +1,31 @@ -import { keccak256 } from 'ethers' +import { keccak256, toUtf8Bytes } from 'ethers' /** * Bytecode utilities for smart contract deployment. * * These utilities handle bytecode hashing for change detection: * - Strip Solidity CBOR metadata (varies between compilations) + * - Resolve library placeholders using actual library bytecode * - Compute stable bytecode hash for comparison * * This allows detecting when local artifact code has changed by comparing * stored bytecodeHash with the current artifact's hash. */ +/** + * Hardhat artifact link references: sourcePath → libraryName → offsets[] + */ +export type LinkReferences = Record>> + +/** + * Resolves a library artifact given its source path and name. + * Returns the artifact's deployedBytecode and its own linkReferences (for recursion). + */ +export type LibraryArtifactResolver = ( + sourcePath: string, + libraryName: string, +) => { deployedBytecode: string; deployedLinkReferences?: LinkReferences } | undefined + /** * Strip Solidity metadata from bytecode. * Metadata is CBOR-encoded at the end, with last 2 bytes indicating length. @@ -33,19 +48,102 @@ export function stripMetadata(bytecode: string): string { } /** - * Compute a stable hash of bytecode for change detection. + * Compute the Solidity library placeholder hash for a given source path and name. + * This is keccak256("sourcePath:libraryName") truncated to 34 hex chars (17 bytes). + */ +function libraryPlaceholderHash(sourcePath: string, libraryName: string): string { + return keccak256(toUtf8Bytes(`${sourcePath}:${libraryName}`)).slice(2, 36) +} + +/** + * Resolve library placeholders in bytecode using actual library bytecode hashes. * - * Strips CBOR metadata suffix before hashing to ensure the hash is stable - * across recompilations that don't change the actual contract logic. + * For each library in deployedLinkReferences, computes its bytecode hash + * (recursively resolving its own library deps) and substitutes that hash + * (truncated to 20 bytes / 40 hex chars) into the placeholder slots. * - * Use this to detect when local artifact bytecode has changed since deployment. + * This means the final hash reflects both the contract's code and all + * transitive library code. If any library changes, the hash changes. + */ +function resolveLibraryPlaceholders( + bytecode: string, + linkReferences: LinkReferences | undefined, + resolver: LibraryArtifactResolver | undefined, +): string { + if (!linkReferences || !resolver) { + // No link references or no resolver — zero out any remaining placeholders + return bytecode.replace(/__\$[0-9a-fA-F]{34}\$__/g, '0'.repeat(40)) + } + + let result = bytecode + for (const [sourcePath, libraries] of Object.entries(linkReferences)) { + for (const libraryName of Object.keys(libraries)) { + const placeholderHash = libraryPlaceholderHash(sourcePath, libraryName) + const placeholder = `__\\$${placeholderHash}\\$__` + + const libArtifact = resolver(sourcePath, libraryName) + let replacement: string + if (libArtifact) { + // Recursively compute the library's bytecode hash (handles nested deps) + const libHash = computeBytecodeHashWithLibraries( + libArtifact.deployedBytecode, + libArtifact.deployedLinkReferences, + resolver, + ) + // Use first 40 hex chars (20 bytes) of the hash as the replacement + replacement = libHash.slice(2, 42) + } else { + // Library artifact not available — zero fill + replacement = '0'.repeat(40) + } + + result = result.replace(new RegExp(placeholder, 'g'), replacement) + } + } + + // Zero any remaining unresolved placeholders (shouldn't happen but defensive) + return result.replace(/__\$[0-9a-fA-F]{34}\$__/g, '0'.repeat(40)) +} + +/** + * Compute a stable hash of bytecode for change detection, with library resolution. * - * @param bytecode - The bytecode to hash (typically artifact.deployedBytecode) - * @returns keccak256 hash of the bytecode with metadata stripped + * Normalizations applied before hashing: + * - Strip CBOR metadata suffix (varies between compilations) + * - Resolve library placeholders with actual library bytecode hashes + * + * @param bytecode - The bytecode to hash + * @param linkReferences - Artifact's deployedLinkReferences (optional) + * @param resolver - Function to load library artifacts (optional) + * @returns keccak256 hash of the normalized bytecode */ -export function computeBytecodeHash(bytecode: string): string { +function computeBytecodeHashWithLibraries( + bytecode: string, + linkReferences: LinkReferences | undefined, + resolver: LibraryArtifactResolver | undefined, +): string { const stripped = stripMetadata(bytecode) - // Ensure 0x prefix for keccak256 - const prefixed = stripped.startsWith('0x') ? stripped : `0x${stripped}` + const resolved = resolveLibraryPlaceholders(stripped, linkReferences, resolver) + const prefixed = resolved.startsWith('0x') ? resolved : `0x${resolved}` return keccak256(prefixed) } + +/** + * Compute a stable hash of bytecode for change detection. + * + * For simple contracts (no library references), pass just the bytecode. + * For contracts with external libraries, pass linkReferences and a resolver + * to include transitive library code in the hash. + * + * @param bytecode - The bytecode to hash (typically artifact.deployedBytecode) + * @param linkReferences - Artifact's deployedLinkReferences (optional) + * @param resolver - Function to load library artifacts for recursive resolution (optional) + * @returns keccak256 hash of the bytecode with metadata stripped + */ +export function computeBytecodeHash( + bytecode: string, + linkReferences?: LinkReferences, + resolver?: LibraryArtifactResolver, +): string { + return computeBytecodeHashWithLibraries(bytecode, linkReferences, resolver) +} diff --git a/packages/deployment/lib/contract-checks.ts b/packages/deployment/lib/contract-checks.ts index 412b5243e..74e446779 100644 --- a/packages/deployment/lib/contract-checks.ts +++ b/packages/deployment/lib/contract-checks.ts @@ -1,5 +1,5 @@ import type { Environment } from '@rocketh/core/types' -import type { PublicClient } from 'viem' +import type { Abi, PublicClient } from 'viem' import { ACCESS_CONTROL_ENUMERABLE_ABI, @@ -7,6 +7,8 @@ import { IERC165_ABI, IERC165_INTERFACE_ID, IISSUANCE_TARGET_INTERFACE_ID, + ISSUANCE_TARGET_ABI, + PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, REWARDS_ELIGIBILITY_ORACLE_ABI, REWARDS_MANAGER_ABI, REWARDS_MANAGER_DEPRECATED_ABI, @@ -100,7 +102,7 @@ export async function checkIssuanceAllocatorActivation( // Check RM.issuanceAllocator() == IA const currentIA = (await client.readContract({ address: rmAddress as `0x${string}`, - abi: REWARDS_MANAGER_ABI, + abi: ISSUANCE_TARGET_ABI, functionName: 'getIssuanceAllocator', })) as string @@ -136,58 +138,6 @@ export async function isIssuanceAllocatorActivated( return status.iaIntegrated && status.iaMinter } -// Well-known reclaim reasons (bytes32) -// These correspond to the condition identifiers in RewardsCondition.sol (keccak256 of condition string) -// Each reason maps to a contract: ReclaimedRewardsFor -export const RECLAIM_REASONS = { - indexerIneligible: '0xfcadc72cad493def76767524554db9da829b6aca9457c0187f63000dba3c9439', - subgraphDenied: '0xc0f4a5620db2f97e7c3a4ba7058497eaa0d497538b2666d66bd6932f25345c88', - stalePoi: '0xe677423ace949fe7684efc4b33b0b10dc0f71b38c22370d74dad5ff6bec3e311', - zeroPoi: '0xf067261e30ea99a11911c4e98249a1645a4870b3ef56b8aa8b8967e15a543095', - closeAllocation: '0x3021a5ea86e7115dadc0819121dc2b1f58b45c2372d2e93b593567f0dd797df8', -} as const - -// Mapping from reclaim reason keys to deployed contract names -export const RECLAIM_CONTRACT_NAMES = { - indexerIneligible: 'ReclaimedRewardsForIndexerIneligible', - subgraphDenied: 'ReclaimedRewardsForSubgraphDenied', - stalePoi: 'ReclaimedRewardsForStalePoi', - zeroPoi: 'ReclaimedRewardsForZeroPoi', - closeAllocation: 'ReclaimedRewardsForCloseAllocation', -} as const - -export type ReclaimReasonKey = keyof typeof RECLAIM_REASONS - -/** - * Get the reclaim address for a given reason from RewardsManager - * - * @param client - Viem public client - * @param rmAddress - RewardsManager address - * @param reason - The reason identifier (bytes32) - * @returns The reclaim address for that reason, or null if not set or function doesn't exist - */ -export async function getReclaimAddress( - client: PublicClient, - rmAddress: string, - reason: string, -): Promise { - try { - const reclaimAddress = (await client.readContract({ - address: rmAddress as `0x${string}`, - abi: REWARDS_MANAGER_ABI, - functionName: 'getReclaimAddress', - args: [reason as `0x${string}`], - })) as string - // Zero address means not set - if (reclaimAddress === '0x0000000000000000000000000000000000000000') { - return null - } - return reclaimAddress - } catch { - return null - } -} - /** * Get issuancePerBlock from RewardsManager */ @@ -201,11 +151,11 @@ export async function getRewardsManagerRawIssuanceRate(client: PublicClient, rmA } // ============================================================================ -// RewardsEligibilityOracle Role Checks +// REO Role Checks // ============================================================================ /** - * Result of checking OPERATOR_ROLE assignment on RewardsEligibilityOracle + * Result of checking OPERATOR_ROLE assignment on an REO instance */ export interface OperatorRoleCheckResult { /** Whether the check passed (correct assignment state) */ @@ -221,7 +171,7 @@ export interface OperatorRoleCheckResult { } /** - * Check OPERATOR_ROLE assignment on RewardsEligibilityOracle + * Check OPERATOR_ROLE assignment on an REO instance * * This is the SINGLE authoritative check for OPERATOR_ROLE correctness. * Used by both deployment scripts and status checks. @@ -231,7 +181,7 @@ export interface OperatorRoleCheckResult { * - If expectedOperator is null: exactly 0 holders * * @param client - Viem public client - * @param reoAddress - RewardsEligibilityOracle address + * @param reoAddress - REO instance address * @param expectedOperator - Expected operator address (from address book), or null if not configured * @returns Check result with pass/fail status and details */ @@ -359,7 +309,7 @@ export interface ParamCondition { description: string /** ABI for contract reads/writes */ - abi: readonly unknown[] + abi: Abi /** Function name to read current value */ getter: string @@ -391,7 +341,7 @@ export interface RoleCondition { description: string /** ABI for contract reads/writes */ - abi: readonly unknown[] + abi: Abi /** Function name to get role bytes32 (e.g., 'PAUSE_ROLE') */ roleGetter: string @@ -519,7 +469,7 @@ export async function checkConditions( } // ============================================================================ -// RewardsEligibilityOracle Conditions +// REO Conditions // ============================================================================ /** Default REO configuration values */ @@ -558,11 +508,6 @@ export function createREOParamConditions( ] } -/** - * @deprecated Use createREOParamConditions for param-only or createREOConditions for all - */ -export const createREOConditions = createREOParamConditions - /** * REO role condition targets */ @@ -620,7 +565,10 @@ export function createREORoleConditions(targets: REORoleTargets): RoleCondition[ export function createAllREOConditions( paramTargets: { eligibilityPeriod?: bigint; oracleUpdateTimeout?: bigint } = {}, roleTargets: REORoleTargets, -): ConfigCondition[] { + // eslint-disable-next-line @typescript-eslint/no-explicit-any +): ConfigCondition[] { + // Note: setEligibilityValidation requires OPERATOR_ROLE, not GOVERNOR_ROLE. + // It is enabled by the network operator after deployment, not in the configure step. return [...createREOParamConditions(paramTargets), ...createREORoleConditions(roleTargets)] } @@ -653,7 +601,8 @@ export function createREODeployerRevokeCondition(deployer: string): RoleConditio * * Requires NetworkOperator to be configured in the issuance address book. */ -export async function getREOConditions(env: Environment): Promise[]> { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export async function getREOConditions(env: Environment): Promise[]> { const governor = await getGovernor(env) const pauseGuardian = await getPauseGuardian(env) const ab = graph.getIssuanceAddressBook(await getTargetChainIdFromEnv(env)) @@ -678,7 +627,7 @@ export function getREOTransferGovernanceConditions(deployer: string): ConfigCond } // ============================================================================ -// RewardsEligibilityOracle Role Checks +// REO Role Checks // ============================================================================ /** @@ -696,7 +645,7 @@ export interface RoleCheckResult { } /** - * Check if an account has a specific role on RewardsEligibilityOracle + * Check if an account has a specific role on an REO instance */ export async function checkREORole( client: PublicClient, @@ -751,8 +700,8 @@ export function formatAddress(address: string): string { export function createRMIntegrationCondition(reoAddress: string): ParamCondition { return { name: 'providerEligibilityOracle', - description: 'RewardsEligibilityOracle', - abi: REWARDS_MANAGER_ABI, + description: 'REO instance', + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, getter: 'getProviderEligibilityOracle', setter: 'setProviderEligibilityOracle', target: reoAddress, diff --git a/packages/deployment/lib/contract-registry.ts b/packages/deployment/lib/contract-registry.ts index cb2271885..06b2f640a 100644 --- a/packages/deployment/lib/contract-registry.ts +++ b/packages/deployment/lib/contract-registry.ts @@ -8,12 +8,15 @@ * the same contract name appears in multiple address books. */ +import { ComponentTags } from './deployment-tags.js' + /** * Artifact source configuration - where to load contract ABI and bytecode from */ export type ArtifactSource = | { type: 'contracts'; path: string; name: string } | { type: 'subgraph-service'; name: string } + | { type: 'horizon'; path: string } | { type: 'issuance'; path: string } | { type: 'openzeppelin'; name: string } @@ -30,6 +33,17 @@ export type ProxyType = 'graph' | 'transparent' */ export type AddressBookType = 'horizon' | 'subgraph-service' | 'issuance' +/** + * Interface ABI configuration for typed ABI generation. + * Maps an export name to an interface in @graphprotocol/interfaces. + */ +export interface InterfaceAbiConfig { + /** Export name for the generated ABI constant (e.g. 'REWARDS_MANAGER_ABI') */ + name: string + /** Interface name in @graphprotocol/interfaces artifacts (e.g. 'IRewardsManager') */ + interface: string +} + /** * Contract metadata specification * Note: addressBook is no longer a field - it's implied by the registry namespace @@ -69,6 +83,53 @@ export interface ContractMetadata { * Used by roles:list task to enumerate role holders. */ roles?: readonly string[] + + /** + * Component tag for deployment lifecycle management. + * Used by script factories to derive action tags (deploy, upgrade, etc.) + * and dependencies without per-script boilerplate. + * + * Must match the PascalCase contract name in deployment-tags.ts ComponentTags. + * Example: 'PaymentsEscrow' → tags: 'PaymentsEscrow:upgrade', deps: 'PaymentsEscrow:deploy' + * + * Multiple contracts may share a componentTag when they form a single + * deployment unit (e.g., REO A/B instances share 'RewardsEligibility'). + */ + componentTag?: string + + /** + * Lifecycle actions available for this component beyond the standard deploy+upgrade. + * Used by status modules to show available `--tags` actions. + * + * When omitted, defaults to ['deploy', 'upgrade'] for deployable proxy contracts, + * or ['deploy'] for non-proxy deployable contracts. + * Always includes 'all' implicitly. + */ + lifecycleActions?: readonly string[] + + /** + * Interface ABIs to generate for this contract. + * Used by the ABI codegen script to produce typed `as const` exports. + * Each entry maps to an interface artifact in @graphprotocol/interfaces. + * The codegen also extracts the interfaceId from the factory class. + */ + interfaces?: readonly InterfaceAbiConfig[] + + /** + * Generate a typed ABI from the contract's full artifact. + * Value is the export name (e.g. 'ISSUANCE_ALLOCATOR_ABI'). + * Requires `artifact` to be set on this entry. + */ + generateAbi?: string + + /** + * Name of the shared implementation entry when this proxy uses an + * implementation deployed separately (e.g. DirectAllocation_Implementation). + * + * Used by the upgrade pipeline to auto-detect when the shared implementation + * has been redeployed and set pendingImplementation accordingly. + */ + sharedImplementation?: string } // ============================================================================ @@ -78,34 +139,71 @@ export interface ContractMetadata { const HORIZON_CONTRACTS = { RewardsManager: { artifact: { type: 'contracts', path: 'rewards', name: 'RewardsManager' }, + interfaces: [ + { name: 'REWARDS_MANAGER_ABI', interface: 'IRewardsManager' }, + { name: 'REWARDS_MANAGER_DEPRECATED_ABI', interface: 'IRewardsManagerDeprecated' }, + { name: 'PROVIDER_ELIGIBILITY_MANAGEMENT_ABI', interface: 'IProviderEligibilityManagement' }, + ], proxyType: 'graph', proxyAdminName: 'GraphProxyAdmin', prerequisite: true, deployable: true, + componentTag: ComponentTags.REWARDS_MANAGER, + lifecycleActions: ['deploy', 'upgrade'], }, GraphProxyAdmin: { + interfaces: [{ name: 'GRAPH_PROXY_ADMIN_ABI', interface: 'IGraphProxyAdmin' }], prerequisite: true, }, L2GraphToken: { artifact: { type: 'contracts', path: 'l2/token', name: 'L2GraphToken' }, + interfaces: [{ name: 'GRAPH_TOKEN_ABI', interface: 'IGraphToken' }], prerequisite: true, }, Controller: { + interfaces: [{ name: 'CONTROLLER_ABI', interface: 'IControllerToolshed' }], prerequisite: true, }, GraphTallyCollector: { prerequisite: true, }, + RecurringCollector: { + artifact: { type: 'horizon', path: 'contracts/payments/collectors/RecurringCollector.sol/RecurringCollector' }, + proxyType: 'transparent', + deployable: true, + componentTag: ComponentTags.RECURRING_COLLECTOR, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], + }, L2Curation: { + artifact: { type: 'contracts', path: 'l2/curation', name: 'L2Curation' }, + proxyType: 'graph', + proxyAdminName: 'GraphProxyAdmin', prerequisite: true, + deployable: true, + componentTag: ComponentTags.L2_CURATION, + }, + HorizonStaking: { + artifact: { type: 'horizon', path: 'contracts/staking/HorizonStaking.sol/HorizonStaking' }, + proxyType: 'graph', + proxyAdminName: 'GraphProxyAdmin', + prerequisite: true, + deployable: true, + componentTag: ComponentTags.HORIZON_STAKING, + }, + GraphPayments: { + prerequisite: true, + }, + PaymentsEscrow: { + artifact: { type: 'horizon', path: 'contracts/payments/PaymentsEscrow.sol/PaymentsEscrow' }, + proxyType: 'transparent', + prerequisite: true, + deployable: true, + componentTag: ComponentTags.PAYMENTS_ESCROW, }, // Contracts deployed by other systems (placeholders for address book type completeness) EpochManager: {}, - GraphPayments: {}, - HorizonStaking: {}, L2GNS: {}, L2GraphTokenGateway: {}, - PaymentsEscrow: {}, SubgraphNFT: {}, } as const satisfies Record @@ -122,6 +220,8 @@ const SUBGRAPH_SERVICE_CONTRACTS = { proxyType: 'transparent', // proxyAdminName omitted - auto-generates as DisputeManager_ProxyAdmin prerequisite: true, + deployable: true, + componentTag: ComponentTags.DISPUTE_MANAGER, }, SubgraphService: { artifact: { type: 'subgraph-service', name: 'SubgraphService' }, @@ -129,6 +229,8 @@ const SUBGRAPH_SERVICE_CONTRACTS = { // proxyAdminName omitted - auto-generates as SubgraphService_ProxyAdmin prerequisite: true, deployable: true, + componentTag: ComponentTags.SUBGRAPH_SERVICE, + lifecycleActions: ['deploy', 'upgrade', 'configure'], }, // Contracts deployed by other systems (placeholders for address book type completeness) // These exist in the subgraph-service address book but are managed elsewhere @@ -144,7 +246,9 @@ const SUBGRAPH_SERVICE_CONTRACTS = { // ============================================================================ // NOTE: Issuance contracts use OZ v5 TransparentUpgradeableProxy which creates -// a per-proxy ProxyAdmin in the constructor. The ProxyAdmin address is stored +// a per-proxy ProxyAdmin in the constructor. The deployer is the initial ProxyAdmin +// owner to allow post-deployment configuration; ownership is transferred to the +// protocol governor in the transfer-governance step. The ProxyAdmin address is stored // inline in each contract's address book entry (proxyAdmin field), similar to // subgraph-service contracts. @@ -158,54 +262,84 @@ const ISSUANCE_CONTRACTS = { IssuanceAllocator: { artifact: { type: 'issuance', path: 'contracts/allocate/IssuanceAllocator.sol/IssuanceAllocator' }, + generateAbi: 'ISSUANCE_ALLOCATOR_ABI', proxyType: 'transparent', // Per-proxy ProxyAdmin - address stored in address book entry's proxyAdmin field deployable: true, roles: BASE_ROLES, + componentTag: ComponentTags.ISSUANCE_ALLOCATOR, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, - PilotAllocation: { - artifact: { type: 'issuance', path: 'contracts/allocate/PilotAllocation.sol/PilotAllocation' }, + RecurringAgreementManager: { + artifact: { + type: 'issuance', + path: 'contracts/agreement/RecurringAgreementManager.sol/RecurringAgreementManager', + }, proxyType: 'transparent', deployable: true, - roles: BASE_ROLES, + roles: [...BASE_ROLES, 'DATA_SERVICE_ROLE', 'COLLECTOR_ROLE', 'AGREEMENT_MANAGER_ROLE'] as const, + componentTag: ComponentTags.RECURRING_AGREEMENT_MANAGER, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, - RewardsEligibilityOracle: { + // A/B instances of RewardsEligibilityOracle - both share the same contract artifact + // but deploy as independent proxies. Only one is active (integrated with RewardsManager) at a time. + RewardsEligibilityOracleA: { artifact: { type: 'issuance', path: 'contracts/eligibility/RewardsEligibilityOracle.sol/RewardsEligibilityOracle' }, + generateAbi: 'REWARDS_ELIGIBILITY_ORACLE_ABI', proxyType: 'transparent', deployable: true, roles: [...BASE_ROLES, 'ORACLE_ROLE'] as const, + componentTag: ComponentTags.REWARDS_ELIGIBILITY_A, + // Integration with RewardsManager is a goal-level activation + // (--tags GIP-0088:eligibility-integrate), not a per-component lifecycle action. + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, - DirectAllocation_Implementation: { - artifact: { type: 'issuance', path: 'contracts/allocate/DirectAllocation.sol/DirectAllocation' }, - deployable: true, - roles: BASE_ROLES, - }, - // Reclaim addresses for different reward reclaim reasons - // All share DirectAllocation implementation (per-proxy ProxyAdmin for each) - ReclaimedRewardsForIndexerIneligible: { + RewardsEligibilityOracleB: { + artifact: { type: 'issuance', path: 'contracts/eligibility/RewardsEligibilityOracle.sol/RewardsEligibilityOracle' }, proxyType: 'transparent', deployable: true, - roles: BASE_ROLES, + roles: [...BASE_ROLES, 'ORACLE_ROLE'] as const, + componentTag: ComponentTags.REWARDS_ELIGIBILITY_B, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, - ReclaimedRewardsForSubgraphDenied: { + // Testnet mock REO - indexers control own eligibility, upgradeable for deployment consistency + RewardsEligibilityOracleMock: { + artifact: { + type: 'issuance', + path: 'contracts/eligibility/mocks/MockRewardsEligibilityOracle.sol/MockRewardsEligibilityOracle', + }, proxyType: 'transparent', deployable: true, roles: BASE_ROLES, + componentTag: ComponentTags.REWARDS_ELIGIBILITY_MOCK, + lifecycleActions: ['deploy', 'upgrade', 'transfer', 'integrate'], }, - ReclaimedRewardsForStalePoi: { - proxyType: 'transparent', + DirectAllocation_Implementation: { + artifact: { type: 'issuance', path: 'contracts/allocate/DirectAllocation.sol/DirectAllocation' }, + generateAbi: 'DIRECT_ALLOCATION_ABI', deployable: true, roles: BASE_ROLES, + componentTag: ComponentTags.DIRECT_ALLOCATION_IMPL, }, - ReclaimedRewardsForZeroPoi: { + // Default target for IA — safety net for unallocated issuance + // Uses DirectAllocation implementation (per-proxy ProxyAdmin) + DefaultAllocation: { proxyType: 'transparent', + sharedImplementation: 'DirectAllocation_Implementation', deployable: true, roles: BASE_ROLES, + componentTag: ComponentTags.DEFAULT_ALLOCATION, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, - ReclaimedRewardsForCloseAllocation: { + // Default reclaim address — receives reclaimed rewards for all reasons + // Uses DirectAllocation implementation (per-proxy ProxyAdmin) + ReclaimedRewards: { proxyType: 'transparent', + sharedImplementation: 'DirectAllocation_Implementation', deployable: true, roles: BASE_ROLES, + componentTag: ComponentTags.REWARDS_RECLAIM, + lifecycleActions: ['deploy', 'upgrade', 'configure', 'transfer'], }, } as const satisfies Record diff --git a/packages/deployment/lib/controller-utils.ts b/packages/deployment/lib/controller-utils.ts index 7180a8872..5a058e9cc 100644 --- a/packages/deployment/lib/controller-utils.ts +++ b/packages/deployment/lib/controller-utils.ts @@ -6,6 +6,22 @@ import { Contracts } from './contract-registry.js' import { requireContract } from './issuance-deploy-utils.js' import { graph } from '../rocketh/deploy.js' +/** + * Check if the provider can sign as the protocol governor + * + * With a mnemonic (local network), all derived accounts are available via eth_accounts. + * With explicit keys (production), only configured accounts are available. + * + * @param env - Deployment environment + * @returns Governor address and whether the provider can sign as governor + */ +export async function canSignAsGovernor(env: Environment): Promise<{ governor: string; canSign: boolean }> { + const governor = await getGovernor(env) + const accounts = (await env.network.provider.request({ method: 'eth_accounts' })) as string[] + const canSign = accounts.some((a) => a.toLowerCase() === governor.toLowerCase()) + return { governor, canSign } +} + /** * Get the protocol governor address from the Controller contract * diff --git a/packages/deployment/lib/deploy-implementation.ts b/packages/deployment/lib/deploy-implementation.ts index f08c4398a..e5702ef4c 100644 --- a/packages/deployment/lib/deploy-implementation.ts +++ b/packages/deployment/lib/deploy-implementation.ts @@ -1,10 +1,13 @@ import type { Artifact, Environment } from '@rocketh/core/types' -import { getAddress } from 'viem' +import { encodeAbiParameters, getAddress } from 'viem' import { getTargetChainIdFromEnv } from './address-book-utils.js' import type { AnyAddressBookOps } from './address-book-ops.js' import { + getLibraryResolver, + linkArtifactLibraries, loadContractsArtifact, + loadHorizonBuildArtifact, loadIssuanceArtifact, loadOpenZeppelinArtifact, loadSubgraphServiceArtifact, @@ -100,11 +103,11 @@ export interface ImplementationDeployConfig { /** * Name of the proxy admin deployment record. - * e.g., 'GraphProxyAdmin', 'GraphIssuanceProxyAdmin' + * e.g., 'GraphProxyAdmin' for legacy GraphProxy contracts. * * Optional: If omitted, defaults to `${contractName}_ProxyAdmin`. - * This allows contracts with inline proxy admin addresses (stored in address book entry) - * to work without explicitly specifying the deployment record name. + * Per-proxy admins (OZ v5 TransparentUpgradeableProxy contracts) follow this + * default and store the admin address inline in their address book entry. */ proxyAdminName?: string @@ -144,6 +147,8 @@ export function loadArtifactFromSource(source: ArtifactSource): Artifact { return loadContractsArtifact(source.path, source.name) case 'subgraph-service': return loadSubgraphServiceArtifact(source.name) + case 'horizon': + return loadHorizonBuildArtifact(source.path) case 'issuance': return loadIssuanceArtifact(source.path) case 'openzeppelin': @@ -236,6 +241,7 @@ export function hasImplementationConfig(addressBook: AddressBookType, contractNa export async function deployImplementation( env: Environment, config: ImplementationDeployConfig, + libraries?: Record, ): Promise { const { contractName, proxyAdminName, constructorArgs = [], proxyType = 'graph', addressBook = 'horizon' } = config @@ -270,8 +276,11 @@ export async function deployImplementation( throw new Error(`${proxyAdminDeploymentName} not imported. Run sync step first.`) } - // 2) Load artifact - const artifact = loadArtifactFromSource(artifactSource) + // 2) Load artifact (pre-link libraries so rocketh stores linked bytecode) + const rawArtifact = loadArtifactFromSource(artifactSource) + const artifact = libraries + ? linkArtifactLibraries(rawArtifact, libraries as Record) + : rawArtifact const implDeploymentName = `${contractName}_Implementation` // Get address book to check pending implementation @@ -284,16 +293,53 @@ export async function deployImplementation( : graph.getHorizonAddressBook(targetChainId) // Compute local artifact bytecode hash (for storing with deployment) - const localBytecodeHash = computeBytecodeHash(artifact.deployedBytecode ?? '0x') + const resolver = getLibraryResolver(artifactSource.type) + const localBytecodeHash = computeBytecodeHash( + artifact.deployedBytecode ?? '0x', + artifact.deployedLinkReferences, + resolver, + ) + + // 3) Pre-check: skip deployment if bytecodeHash and constructor args match + // Rocketh's comparison can false-positive when sync creates bare records (e.g., wrong + // argsData, unlinked library bytecodes). The content-aware bytecodeHash handles both + // cases — it strips CBOR metadata and resolves library references by content hash. + const contractEntry = addressBookInstance.entryExists(contractName) ? addressBookInstance.getEntry(contractName) : null + const pendingImpl = contractEntry?.pendingImplementation + const storedMetadata = pendingImpl?.deployment ?? addressBookInstance.getDeploymentMetadata(contractName) + + if (storedMetadata?.bytecodeHash && storedMetadata.bytecodeHash === localBytecodeHash) { + // Bytecode matches — also verify constructor args (immutable values) + let argsMatch = !storedMetadata.argsData // no stored args = can't compare, assume match + if (storedMetadata.argsData) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const constructorDef = (artifact.abi as any[])?.find((item: any) => item.type === 'constructor') + const localArgsData = + constructorDef?.inputs?.length && constructorArgs.length + ? encodeAbiParameters(constructorDef.inputs, constructorArgs as readonly unknown[]) + : '0x' + argsMatch = localArgsData === storedMetadata.argsData + } - // 3) Deploy implementation - let rocketh decide based on its own records + if (argsMatch) { + const existingAddress = pendingImpl?.address ?? contractEntry?.implementation + if (existingAddress) { + env.showMessage(`\n✓ ${contractName} implementation unchanged`) + return { + deployed: false, + address: existingAddress, + bytecodeChanged: false, + } + } + } + } + + // 4) Deploy implementation - let rocketh decide based on its own records // Sync handles pending: if pending hash matches local, rocketh has bytecode to compare // If pending hash differs, sync skipped bytecode so rocketh will deploy fresh - const impl = await deployFn(implDeploymentName, { - account: deployer, - artifact, - args: constructorArgs, - }) + // Libraries are pre-linked into the artifact (step 2) so rocketh stores linked + // bytecode — its CBOR-stripping comparison then matches on subsequent runs. + const impl = await deployFn(implDeploymentName, { account: deployer, artifact, args: constructorArgs }) if (!impl.newlyDeployed) { env.showMessage(`\n✓ ${contractName} implementation unchanged`) @@ -335,7 +381,7 @@ export async function deployImplementation( // Store with full deployment metadata for verification and reconstruction addressBookInstance.setPendingImplementationWithMetadata(contractName, impl.address, { txHash: impl.transaction?.hash ?? '', - argsData: impl.argsData ?? '0x', + argsData: impl.argsData, bytecodeHash: localBytecodeHash, ...(blockNumber !== undefined && { blockNumber }), ...(timestamp && { timestamp }), diff --git a/packages/deployment/lib/deploy-standalone.ts b/packages/deployment/lib/deploy-standalone.ts new file mode 100644 index 000000000..0b7b2c9fd --- /dev/null +++ b/packages/deployment/lib/deploy-standalone.ts @@ -0,0 +1,79 @@ +import type { Environment } from '@rocketh/core/types' + +import type { RegistryEntry } from './contract-registry.js' +import { loadArtifactFromSource } from './deploy-implementation.js' +import { requireDeployer } from './issuance-deploy-utils.js' +import { deploy, graph } from '../rocketh/deploy.js' + +/** + * Configuration for deploying a standalone (non-proxy) contract + */ +export interface StandaloneDeployConfig { + /** Contract registry entry (provides addressBook and artifact config) */ + contract: RegistryEntry + /** Constructor arguments */ + constructorArgs?: unknown[] +} + +/** + * Deploy a standalone (non-proxy) contract and update the address book + * + * This utility handles the common pattern for deploying contracts that + * are not behind a proxy (e.g., helper contracts). + * + * - Loads artifact from registry metadata + * - Deploys via rocketh (idempotent - skips if bytecode unchanged) + * - Updates the appropriate address book (horizon or issuance) + * + * @example + * ```typescript + * await deployStandaloneContract(env, { + * contract: Contracts.horizon.GraphTallyCollector, + * constructorArgs: [controllerAddress], + * }) + * ``` + */ +export async function deployStandaloneContract( + env: Environment, + config: StandaloneDeployConfig, +): Promise<{ address: string; newlyDeployed: boolean }> { + const { contract, constructorArgs = [] } = config + + if (!contract.artifact) { + throw new Error(`No artifact configured for ${contract.name} in registry`) + } + + const deployer = requireDeployer(env) + const artifact = loadArtifactFromSource(contract.artifact) + const deployFn = deploy(env) + + const result = await deployFn(contract.name, { + account: deployer, + artifact, + args: constructorArgs, + }) + + if (result.newlyDeployed) { + env.showMessage(`\n✓ ${contract.name} deployed at ${result.address}`) + } else { + env.showMessage(`\n✓ ${contract.name} unchanged at ${result.address}`) + } + + // Update address book based on which book the contract belongs to + if (contract.addressBook === 'horizon') { + await graph.updateHorizonAddressBook(env, { + name: contract.name, + address: result.address, + }) + } else if (contract.addressBook === 'issuance') { + await graph.updateIssuanceAddressBook(env, { + name: contract.name, + address: result.address, + }) + } + + return { + address: result.address, + newlyDeployed: !!result.newlyDeployed, + } +} diff --git a/packages/deployment/lib/deployment-config.ts b/packages/deployment/lib/deployment-config.ts new file mode 100644 index 000000000..96cea017c --- /dev/null +++ b/packages/deployment/lib/deployment-config.ts @@ -0,0 +1,66 @@ +import { readFileSync } from 'node:fs' +import { resolve, dirname } from 'node:path' +import { fileURLToPath } from 'node:url' +import type { Environment } from '@rocketh/core/types' + +import { getTargetChainIdFromEnv } from './address-book-utils.js' + +const __dirname = dirname(fileURLToPath(import.meta.url)) + +/** Chain ID to config file name mapping */ +const CHAIN_CONFIG_MAP: Record = { + 1337: 'localNetwork', + 42161: 'arbitrumOne', + 421614: 'arbitrumSepolia', +} + +export interface DeploymentConfig { + IssuanceAllocator?: { + ramAllocatorMintingGrtPerBlock?: string + ramSelfMintingGrtPerBlock?: string + } + RewardsManager?: { + revertOnIneligible?: boolean + } + RecurringCollector?: { + revokeSignerThawingPeriod?: string + eip712Name?: string + eip712Version?: string + } +} + +/** + * Strip single-line // comments from JSON5-style content so it can be parsed + * by JSON.parse. Preserves strings containing //. + */ +function stripComments(text: string): string { + return text.replace(/^\s*\/\/.*$/gm, '').replace(/,(\s*[}\]])/g, '$1') +} + +/** + * Load deployment configuration for the target network. + * + * Reads from packages/deployment/config/.json5. + * Falls back to empty config if file not found (local/fork mode). + */ +export async function loadDeploymentConfig(env: Environment): Promise { + const chainId = await getTargetChainIdFromEnv(env) + const networkName = CHAIN_CONFIG_MAP[chainId] + + if (!networkName) { + env.showMessage(` No deployment config for chain ${chainId}, using defaults`) + return {} + } + + const configPath = resolve(__dirname, '..', 'config', `${networkName}.json5`) + + try { + const raw = readFileSync(configPath, 'utf-8') + const config = JSON.parse(stripComments(raw)) as DeploymentConfig + env.showMessage(` Loaded config from config/${networkName}.json5`) + return config + } catch (e) { + env.showMessage(` Config file not found or invalid: config/${networkName}.json5, using defaults`) + return {} + } +} diff --git a/packages/deployment/lib/deployment-tags.ts b/packages/deployment/lib/deployment-tags.ts index 26bf286b6..6d2c4f6aa 100644 --- a/packages/deployment/lib/deployment-tags.ts +++ b/packages/deployment/lib/deployment-tags.ts @@ -1,15 +1,13 @@ /** - * Deployment Tag Library - Standardized tags for deployment scripts + * Deployment Tag Library * - * This module provides: - * - Constants for all deployment tags - * - Utilities to generate action-specific tags - * - Type safety for tag usage + * Tags select components, skip functions gate actions: + * - Component tags: PascalCase contract name (e.g., 'IssuanceAllocator') + * - Action verbs: deploy, upgrade, configure, transfer, integrate, all + * - Phase scopes: GIP-NNNN:phase (e.g., 'GIP-0088:upgrade') + * - Activation goals: GIP-NNNN:phase-action (e.g., 'GIP-0088:eligibility-integrate') * - * Tag Patterns: - * - Component tags: Base identifier (e.g., 'issuance-allocator') - * - Action tags: Component + suffix (e.g., 'issuance-allocator-deploy') - * - Category tags: Grouping tags (e.g., 'issuance-core') + * Usage: --tags IssuanceAllocator,deploy → matches component, deploy runs, others skip */ /** @@ -21,42 +19,67 @@ export const DeploymentActions = { CONFIGURE: 'configure', TRANSFER: 'transfer', INTEGRATE: 'integrate', - VERIFY: 'verify', + ALL: 'all', } as const /** - * Core component tags (base identifiers) + * Core component tags (PascalCase contract names matching the registry) */ export const ComponentTags = { // Core contracts with full lifecycle (deploy + upgrade + configure) - ISSUANCE_ALLOCATOR: 'issuance-allocator', - PILOT_ALLOCATION: 'pilot-allocation', - REWARDS_RECLAIM: 'rewards-reclaim', + ISSUANCE_ALLOCATOR: 'IssuanceAllocator', + DEFAULT_ALLOCATION: 'DefaultAllocation', + REWARDS_RECLAIM: 'RewardsReclaim', // Implementations and support contracts - DIRECT_ALLOCATION_IMPL: 'direct-allocation-impl', - REWARDS_ELIGIBILITY: 'rewards-eligibility', + DIRECT_ALLOCATION_IMPL: 'DirectAllocation_Implementation', + REWARDS_ELIGIBILITY_A: 'RewardsEligibilityOracleA', + REWARDS_ELIGIBILITY_B: 'RewardsEligibilityOracleB', + REWARDS_ELIGIBILITY_MOCK: 'RewardsEligibilityOracleMock', - // Process tags (not contract deployments) - ISSUANCE_ACTIVATION: 'issuance-activation', - VERIFY_GOVERNANCE: 'verify-governance', - - // External dependencies (Horizon contracts) - REWARDS_MANAGER: 'rewards-manager', - REWARDS_MANAGER_DEPLOY: 'rewards-manager-deploy', - REWARDS_MANAGER_UPGRADE: 'rewards-manager-upgrade', + // Horizon contracts + RECURRING_COLLECTOR: 'RecurringCollector', + REWARDS_MANAGER: 'RewardsManager', + HORIZON_STAKING: 'HorizonStaking', + PAYMENTS_ESCROW: 'PaymentsEscrow', // SubgraphService contracts - SUBGRAPH_SERVICE: 'subgraph-service', + SUBGRAPH_SERVICE: 'SubgraphService', + DISPUTE_MANAGER: 'DisputeManager', + + // Legacy contracts (graph proxy, upgrade only) + L2_CURATION: 'L2Curation', + + // Issuance agreement contracts + RECURRING_AGREEMENT_MANAGER: 'RecurringAgreementManager', } as const /** - * Category tags for grouping deployments + * Goal tags - deployment goals that orchestrate component lifecycles + * + * Two-dimensional: phase scope × action verbs. + * - Phase scopes select which contracts (`GIP-0088:upgrade`, `GIP-0088:eligibility`, etc.) + * - Action verbs select which lifecycle step (`deploy`, `configure`, `transfer`, `upgrade`) + * - Activation goals are phase-scoped governance TXs (`GIP-0088:eligibility-integrate`) + * - Optional goals bypass the `all` wildcard + * + * Combined: `--tags GIP-0088:issuance,deploy` */ -export const CategoryTags = { - ISSUANCE_CORE: 'issuance-core', - ISSUANCE_GOVERNANCE: 'issuance-governance', - ISSUANCE: 'issuance', +export const GoalTags = { + // Overall GIP scope (status + verification) + GIP_0088: 'GIP-0088', + + // Upgrade phase (deploy, configure, transfer, upgrade — combined with action verbs) + GIP_0088_UPGRADE: 'GIP-0088:upgrade', + + // Activation goals (governance TXs — after upgrade complete) + GIP_0088_ELIGIBILITY_INTEGRATE: 'GIP-0088:eligibility-integrate', + GIP_0088_ISSUANCE_CONNECT: 'GIP-0088:issuance-connect', + GIP_0088_ISSUANCE_ALLOCATE: 'GIP-0088:issuance-allocate', + + // Optional goals (not activated by `all`) + GIP_0088_ELIGIBILITY_REVERT: 'GIP-0088:eligibility-revert', + GIP_0088_ISSUANCE_CLOSE_GUARD: 'GIP-0088:issuance-close-guard', } as const /** @@ -67,74 +90,62 @@ export const SpecialTags = { } as const /** - * Generate action tag from component and action + * Parse the value of --tags from argv. + * + * Supports both `--tags foo,bar` (space) and `--tags=foo,bar` (equals). + * Returns null when not present or when the space form has no following arg. + */ +function parseTagsArg(): string[] | null { + const argv = process.argv + for (let i = 0; i < argv.length; i++) { + const a = argv[i] + if (a === '--tags') { + if (i + 1 >= argv.length) return null + return argv[i + 1].split(',') + } + if (a.startsWith('--tags=')) { + return a.slice('--tags='.length).split(',') + } + } + return null +} + +/** + * Check whether --tags was specified on the command line. + * + * Returns true (skip) when no --tags are present. Used by status modules + * to skip when the user didn't request any specific component. */ -export function actionTag( - component: string, - action: (typeof DeploymentActions)[keyof typeof DeploymentActions], -): string { - return `${component}-${action}` +export function noTagsRequested(): boolean { + return parseTagsArg() === null } /** - * Common tag patterns for deployment scripts - * Note: Arrays are not readonly to match DeployScriptModule.tags type (string[]) + * Check whether a deploy script should skip based on action verbs in --tags. + * + * Returns true (skip) when: + * - No --tags specified at all (safety: require explicit tags for mutations) + * - The verb is not present in the requested tags + * + * The 'all' verb is a wildcard: `--tags Component,all` activates every action + * (deploy, upgrade, configure, transfer, integrate) plus the end verification. + * + * Used by script factories and custom deploy scripts to gate mutations. + */ +export function shouldSkipAction(verb: string): boolean { + const tags = parseTagsArg() + if (tags === null) return true + return !tags.includes(verb) && !tags.includes(DeploymentActions.ALL) +} + +/** + * Check whether an optional goal should skip. + * + * Unlike `shouldSkipAction`, this does NOT respond to the `all` wildcard. + * Optional goals only run when their specific tag is explicitly requested. */ -export const Tags = { - // IssuanceAllocator lifecycle - issuanceAllocatorDeploy: [ - actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.DEPLOY), - CategoryTags.ISSUANCE_CORE, - ] as string[], - issuanceAllocatorUpgrade: [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.UPGRADE)] as string[], - issuanceAllocatorConfigure: [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.CONFIGURE)] as string[], - issuanceTransfer: [actionTag(ComponentTags.ISSUANCE_ALLOCATOR, DeploymentActions.TRANSFER)] as string[], - issuanceAllocator: [ComponentTags.ISSUANCE_ALLOCATOR] as string[], // Aggregate - - // PilotAllocation lifecycle - pilotAllocationDeploy: [ - actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.DEPLOY), - CategoryTags.ISSUANCE_CORE, - ] as string[], - pilotAllocationUpgrade: [actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.UPGRADE)] as string[], - pilotAllocationConfigure: [actionTag(ComponentTags.PILOT_ALLOCATION, DeploymentActions.CONFIGURE)] as string[], - pilotAllocation: [ComponentTags.PILOT_ALLOCATION] as string[], // Aggregate - - // Rewards reclaim lifecycle - rewardsReclaimDeploy: [actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.DEPLOY)] as string[], - rewardsReclaimUpgrade: [actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.UPGRADE)] as string[], - rewardsReclaimConfigure: [actionTag(ComponentTags.REWARDS_RECLAIM, DeploymentActions.CONFIGURE)] as string[], - rewardsReclaim: [ComponentTags.REWARDS_RECLAIM] as string[], // Aggregate - - // RewardsEligibilityOracle lifecycle - rewardsEligibilityDeploy: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.DEPLOY)] as string[], - rewardsEligibilityUpgrade: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.UPGRADE)] as string[], - rewardsEligibilityConfigure: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.CONFIGURE)] as string[], - rewardsEligibilityTransfer: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.TRANSFER)] as string[], - rewardsEligibilityIntegrate: [actionTag(ComponentTags.REWARDS_ELIGIBILITY, DeploymentActions.INTEGRATE)] as string[], - rewardsEligibility: [ComponentTags.REWARDS_ELIGIBILITY] as string[], // Aggregate - - // Support contracts - directAllocationImpl: [ComponentTags.DIRECT_ALLOCATION_IMPL] as string[], - - // Process steps - issuanceActivation: [ComponentTags.ISSUANCE_ACTIVATION] as string[], - verifyGovernance: [ - ComponentTags.VERIFY_GOVERNANCE, - CategoryTags.ISSUANCE_GOVERNANCE, - CategoryTags.ISSUANCE, - ] as string[], - - // Top-level aggregate - issuanceAllocation: ['issuance-allocation'] as string[], - - // Horizon RewardsManager lifecycle - rewardsManagerDeploy: [ComponentTags.REWARDS_MANAGER_DEPLOY] as string[], - rewardsManagerUpgrade: [ComponentTags.REWARDS_MANAGER_UPGRADE] as string[], - rewardsManager: [ComponentTags.REWARDS_MANAGER] as string[], - - // SubgraphService lifecycle - subgraphServiceDeploy: [actionTag(ComponentTags.SUBGRAPH_SERVICE, DeploymentActions.DEPLOY)] as string[], - subgraphServiceUpgrade: [actionTag(ComponentTags.SUBGRAPH_SERVICE, DeploymentActions.UPGRADE)] as string[], - subgraphService: [ComponentTags.SUBGRAPH_SERVICE] as string[], +export function shouldSkipOptionalGoal(goalTag: string): boolean { + const tags = parseTagsArg() + if (tags === null) return true + return !tags.includes(goalTag) } diff --git a/packages/deployment/lib/deployment-validation.ts b/packages/deployment/lib/deployment-validation.ts index 9c53c4bdb..e811b3f8e 100644 --- a/packages/deployment/lib/deployment-validation.ts +++ b/packages/deployment/lib/deployment-validation.ts @@ -11,6 +11,7 @@ import type { AnyAddressBookOps } from './address-book-ops.js' import type { ArtifactSource } from './contract-registry.js' import { computeBytecodeHash } from './bytecode-utils.js' import { + getLibraryResolver, loadContractsArtifact, loadIssuanceArtifact, loadOpenZeppelinArtifact, @@ -141,7 +142,12 @@ export async function validateContract( } if (loadedArtifact?.deployedBytecode && metadata?.bytecodeHash) { - const localHash = computeBytecodeHash(loadedArtifact.deployedBytecode) + const libResolver = getLibraryResolver(artifact.type) + const localHash = computeBytecodeHash( + loadedArtifact.deployedBytecode, + loadedArtifact.deployedLinkReferences, + libResolver, + ) if (metadata.bytecodeHash !== localHash) { return { contract: contractName, @@ -178,7 +184,7 @@ export async function validateContract( } // Optional: Verify argsData matches transaction - if (options.verifyArgsData && metadata?.txHash && loadedArtifact?.bytecode) { + if (options.verifyArgsData && metadata?.txHash && metadata?.argsData && loadedArtifact?.bytecode) { try { const tx = await client.getTransaction({ hash: metadata.txHash as `0x${string}` }) if (tx?.input) { diff --git a/packages/deployment/lib/execute-governance.ts b/packages/deployment/lib/execute-governance.ts index 0b9733103..e39cde9cc 100644 --- a/packages/deployment/lib/execute-governance.ts +++ b/packages/deployment/lib/execute-governance.ts @@ -35,7 +35,7 @@ interface SafeTxBatch { * @param networkName - Network name (e.g., 'fork', 'localhost', 'arbitrumSepolia') */ export function getGovernanceTxDir(networkName: string): string { - const forkNetwork = getForkNetwork() + const forkNetwork = getForkNetwork(networkName) if (forkNetwork) { return path.join(getForkStateDir(networkName, forkNetwork), 'txs') } @@ -117,41 +117,42 @@ export async function createGovernanceTxBuilder( * Save governance TX batch and exit with code 1 * * Standard completion pattern for scripts that generate governance TX batches. - * This function: - * 1. Saves the TX batch to file - * 2. Displays appropriate messages - * 3. Exits with code 1 to prevent subsequent deployment steps + * Saves the TX batch to file and displays a message. + * Returns the saved file path so the caller can continue. + * + * Subsequent scripts that depend on this TX being executed should check + * their own preconditions and exit if not met. * * @param env - Deployment environment * @param builder - TX builder with batched transactions - * @param contractName - Optional contract name for contextual message (e.g., "IssuanceAllocator activation") - * @returns Never returns (exits process) + * @param contractName - Optional contract name for contextual message + * @returns Path to the saved TX file */ -export function saveGovernanceTxAndExit( +export function saveGovernanceTx( env: Environment, builder: { saveToFile: () => string }, contractName?: string, -): never { +): string { const txFile = builder.saveToFile() - env.showMessage(`\n✓ TX batch saved: ${txFile}`) + env.showMessage(` ✓ Governance TX saved: ${txFile}`) - env.showMessage('\n📋 GOVERNANCE ACTION REQUIRED:') if (contractName) { env.showMessage(` ${contractName} requires governance execution`) } - env.showMessage(` TX batch: ${txFile}`) - env.showMessage('\nNext steps:') - env.showMessage(' 1. Execute governance TX (see options below)') - env.showMessage(' 2. Run: npx hardhat deploy --tags sync --network ' + env.name) - env.showMessage(' 3. Continue deployment') - env.showMessage('\nExecution options:') - env.showMessage(' • Fork testing: npx hardhat deploy:execute-governance --network fork') - env.showMessage(' • EOA governor: Set GOVERNOR_PRIVATE_KEY and run deploy:execute-governance') - env.showMessage(' • Safe multisig: https://app.safe.global/ → Transaction Builder → Upload JSON') - env.showMessage('\nSee: packages/deployment/docs/GovernanceWorkflow.md\n') - - // Exit with code 1 to prevent subsequent steps from running until governance TX is executed - // This is expected prerequisite state, not an error + env.showMessage(` Run: npx hardhat deploy:execute-governance --network ${env.name}`) + + return txFile +} + +/** + * @deprecated Use `saveGovernanceTx` instead. This function exits the process. + */ +export function saveGovernanceTxAndExit( + env: Environment, + builder: { saveToFile: () => string }, + contractName?: string, +): never { + saveGovernanceTx(env, builder, contractName) process.exit(1) } @@ -219,12 +220,14 @@ export interface ExecuteGovernanceOptions { name?: string /** Governor private key (from keystore or env var) */ governorPrivateKey?: string + /** Lazy resolver for governor key - defers keystore access until actually needed */ + resolveGovernorKey?: () => Promise } export async function executeGovernanceTxs(env: Environment, options?: ExecuteGovernanceOptions): Promise { - const { name, governorPrivateKey } = options ?? {} + const { name, governorPrivateKey, resolveGovernorKey } = options ?? {} // Determine TX directory - in fork mode, also check source network's TX directory - const forkNetwork = getForkNetwork() + const forkNetwork = getForkNetwork(env.name) let txDir = getGovernanceTxDir(env.name) let sourceNetworkFallback = false @@ -278,8 +281,8 @@ export async function executeGovernanceTxs(env: Environment, options?: ExecuteGo transport: custom(env.network.provider), }) - // Check if in fork mode - const inForkMode = isForkMode() + // Check if in fork mode (network-aware: ignores FORK_NETWORK on real networks) + const inForkMode = isForkMode(env.name) if (!inForkMode) { // Not in fork mode - check if governor is EOA or Safe @@ -310,8 +313,9 @@ export async function executeGovernanceTxs(env: Environment, options?: ExecuteGo return 0 } - // Governor is an EOA - if (!governorPrivateKey) { + // Governor is an EOA - resolve key now (deferred to avoid keystore prompt in fork mode) + const resolvedKey = governorPrivateKey ?? (await resolveGovernorKey?.()) + if (!resolvedKey) { const keyName = `${networkToEnvPrefix(env.name)}_GOVERNOR_KEY` env.showMessage(`\n❌ Cannot execute governance TXs on ${env.name}`) env.showMessage(` Governor address: ${governor} (EOA)`) @@ -333,7 +337,7 @@ export async function executeGovernanceTxs(env: Environment, options?: ExecuteGo // Have private key - execute as EOA env.showMessage(`\n🔓 Executing ${files.length} governance TX batch(es)...`) env.showMessage(` Governor: ${governor} (EOA)`) - return await executeWithEOA(env, publicClient, files, txDir, governorPrivateKey) + return await executeWithEOA(env, publicClient, files, txDir, resolvedKey) } // Fork mode - use impersonation diff --git a/packages/deployment/lib/format.ts b/packages/deployment/lib/format.ts new file mode 100644 index 000000000..fd1bf1359 --- /dev/null +++ b/packages/deployment/lib/format.ts @@ -0,0 +1,10 @@ +/** + * Formatting helpers for human-readable display of on-chain values. + */ + +import { formatEther } from 'viem' + +/** Format a wei amount as GRT (e.g. `6036500000000000000n` → `"6.0365 GRT"`). */ +export function formatGRT(wei: bigint): string { + return `${formatEther(wei)} GRT` +} diff --git a/packages/deployment/lib/issuance-deploy-utils.ts b/packages/deployment/lib/issuance-deploy-utils.ts index bd1b5f486..b41b51af0 100644 --- a/packages/deployment/lib/issuance-deploy-utils.ts +++ b/packages/deployment/lib/issuance-deploy-utils.ts @@ -3,6 +3,7 @@ import type { Environment } from '@rocketh/core/types' import type { PublicClient } from 'viem' import { encodeFunctionData } from 'viem' +import type { AnyAddressBookOps } from './address-book-ops.js' import { Contracts, type RegistryEntry } from './contract-registry.js' import { getGovernor } from './controller-utils.js' import { @@ -12,9 +13,10 @@ import { loadArtifactFromSource, } from './deploy-implementation.js' import { loadTransparentProxyArtifact } from './artifact-loaders.js' -import { INITIALIZE_GOVERNOR_ABI } from './abis.js' +import { INITIALIZE_GOVERNOR_ABI, OZ_PROXY_ADMIN_ABI } from './abis.js' import { computeBytecodeHash } from './bytecode-utils.js' -import { deploy, graph } from '../rocketh/deploy.js' +import { getTargetChainIdFromEnv } from './address-book-utils.js' +import { deploy, execute, graph } from '../rocketh/deploy.js' /** ERC1967 admin slot: keccak256("eip1967.proxy.admin") - 1 */ const ERC1967_ADMIN_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103' @@ -36,6 +38,25 @@ export function requireDeployer(env: Environment): string { return deployer } +/** + * Address derived from the dummy private key (0x…001) used for status-only runs. + * Filtered out so status scripts don't mistake it for the real deployer. + */ +const DUMMY_DEPLOYER_ADDRESS = '0x7e5f4552091a69125d5dfcb7b8c2659029395bdf' + +/** + * Get deployer address if available (non-throwing). + * + * Returns undefined when the deploy key is not loaded (e.g. status-only runs + * where the keystore password is not prompted). Status scripts infer the real + * deployer from the ProxyAdmin owner on-chain instead. + */ +export function getDeployer(env: Environment): string | undefined { + const deployer = env.namedAccounts.deployer + if (!deployer || deployer.toLowerCase() === DUMMY_DEPLOYER_ADDRESS) return undefined + return deployer +} + /** * Require a contract deployment to exist, throwing a helpful error if not found */ @@ -117,7 +138,7 @@ export function showDeploymentStatus( if (result.newlyDeployed) { env.showMessage(`✓ ${contract.name} deployed at ${result.address}`) } else { - env.showMessage(`✓ ${contract.name} deployed at ${result.address}`) + env.showMessage(`✓ ${contract.name} unchanged at ${result.address}`) } } @@ -145,7 +166,8 @@ export function showProxyDeploymentStatus( } /** - * Update issuance address book with proxy deployment information + * Update address book with proxy deployment information. + * Routes to the correct address book based on contract.addressBook. */ export async function updateProxyAddressBook( env: Environment, @@ -156,14 +178,20 @@ export async function updateProxyAddressBook( proxyAdminAddress?: string, implementationDeployment?: DeploymentMetadata, ) { - await graphUtils.updateIssuanceAddressBook(env, { + const update = { name: contract.name, address: proxyAddress, - proxy: 'transparent', + proxy: 'transparent' as const, proxyAdmin: proxyAdminAddress, implementation: implAddress, implementationDeployment, - }) + } + + if (contract.addressBook === 'horizon') { + await graphUtils.updateHorizonAddressBook(env, update) + } else { + await graphUtils.updateIssuanceAddressBook(env, update) + } } /** @@ -234,7 +262,8 @@ export interface ProxyDeployConfig { * * Uses OpenZeppelin v5's per-proxy ProxyAdmin pattern: * - Each proxy creates its own ProxyAdmin in the constructor - * - Governor owns all per-proxy ProxyAdmins + * - Deployer is the initial ProxyAdmin owner (for post-deployment configuration) + * - Ownership is transferred to governor in the transfer-governance step * - No shared ProxyAdmin required * * Deployment scenarios: @@ -270,11 +299,47 @@ export async function deployProxyContract( if (existingProxy) { if (sharedImplementation) { - // Shared implementation - just report status + // Shared implementation — detect if redeployed and set pendingImplementation env.showMessage(`✓ ${contract.name} proxy already deployed at ${existingProxy.address}`) env.showMessage(` Uses shared implementation: ${sharedImplementation.name}`) - // Check current implementation status + const implDep = env.getOrNull(sharedImplementation.name) + if (implDep) { + const client = graph.getPublicClient(env) + const onChainImpl = await getOnChainImplementation(client, existingProxy.address, 'transparent') + + if (onChainImpl.toLowerCase() !== implDep.address.toLowerCase()) { + // Shared implementation changed — store as pending for governance upgrade + const targetChainId = await getTargetChainIdFromEnv(env) + const addressBook: AnyAddressBookOps = contract.addressBook === 'horizon' + ? graph.getHorizonAddressBook(targetChainId) + : graph.getIssuanceAddressBook(targetChainId) + + // Get deployment metadata from the shared implementation's address book entry + const implMetadata = addressBook.getDeploymentMetadata(sharedImplementation.name) + addressBook.setPendingImplementationWithMetadata( + contract.name, + implDep.address, + implMetadata ?? { txHash: '', bytecodeHash: '' }, + ) + + env.showMessage(``) + env.showMessage(`⚠️ UPGRADE REQUIRED`) + env.showMessage(` Proxy: ${existingProxy.address}`) + env.showMessage(` Current (on-chain): ${onChainImpl}`) + env.showMessage(` New implementation: ${implDep.address}`) + env.showMessage(``) + env.showMessage(` Stored as pending — run upgrade task to generate governance TX.`) + + return { + address: existingProxy.address, + newlyDeployed: false, + upgraded: true, + } + } + } + + // No change — check existing pending status const client = graph.getPublicClient(env) await checkPendingUpgrade(env, client, contract, existingProxy.address, 'transparent') @@ -315,10 +380,10 @@ export async function deployProxyContract( // Fresh deployment - deploy implementation first, then OZ v5 proxy if (sharedImplementation) { - return deployProxyWithSharedImpl(env, contract, sharedImplementation, governor, actualInitializeArgs, deployer) + return deployProxyWithSharedImpl(env, contract, sharedImplementation, actualInitializeArgs, deployer) } - return deployProxyWithOwnImpl(env, contract, governor, constructorArgs, actualInitializeArgs, deployer) + return deployProxyWithOwnImpl(env, contract, constructorArgs, actualInitializeArgs, deployer) } /** @@ -327,7 +392,6 @@ export async function deployProxyContract( async function deployProxyWithOwnImpl( env: Environment, contract: RegistryEntry, - governor: string, constructorArgs: unknown[], initializeArgs: unknown[], deployer: string, @@ -348,16 +412,17 @@ async function deployProxyWithOwnImpl( env.showMessage(` Implementation deployed at ${implResult.address}`) - // Encode initialize call + // Encode initialize call using the contract's own ABI const initCalldata = encodeFunctionData({ - abi: INITIALIZE_GOVERNOR_ABI, + abi: implArtifact.abi, functionName: 'initialize', args: initializeArgs as [`0x${string}`], }) // Deploy OZ v5 TransparentUpgradeableProxy // Constructor: (address _logic, address initialOwner, bytes memory _data) - // The proxy creates its own ProxyAdmin owned by initialOwner (governor) + // Deployer is the initial ProxyAdmin owner to allow post-deployment configuration. + // Ownership is transferred to the protocol governor in the transfer-governance step. // Use issuance-compiled proxy artifact (0.8.34) for consistent verification const proxyArtifact = loadTransparentProxyArtifact() const proxyResult = await deployFn( @@ -365,7 +430,7 @@ async function deployProxyWithOwnImpl( { account: deployer, artifact: proxyArtifact, - args: [implResult.address, governor, initCalldata], + args: [implResult.address, deployer, initCalldata], }, { skipIfAlreadyDeployed: true }, ) @@ -405,7 +470,7 @@ async function deployProxyWithOwnImpl( if (proxyResult.newlyDeployed) { env.showMessage(`✓ ${contract.name} proxy deployed at ${proxyResult.address}`) env.showMessage(` Implementation: ${implResult.address}`) - env.showMessage(` ProxyAdmin (per-proxy): ${proxyAdminAddress}`) + env.showMessage(` ProxyAdmin (per-proxy, deployer-owned): ${proxyAdminAddress}`) } else { env.showMessage(`✓ ${contract.name} already deployed at ${proxyResult.address}`) } @@ -424,7 +489,6 @@ async function deployProxyWithSharedImpl( env: Environment, contract: RegistryEntry, sharedImplementation: RegistryEntry, - governor: string, initializeArgs: unknown[], deployer: string, ): Promise<{ address: string; newlyDeployed: boolean; upgraded: boolean }> { @@ -447,6 +511,8 @@ async function deployProxyWithSharedImpl( // Deploy OZ v5 TransparentUpgradeableProxy // Constructor: (address _logic, address initialOwner, bytes memory _data) + // Deployer is the initial ProxyAdmin owner to allow post-deployment configuration. + // Ownership is transferred to the protocol governor in the transfer-governance step. // Use issuance-compiled proxy artifact (0.8.34) for consistent verification const proxyArtifact = loadTransparentProxyArtifact() const proxyResult = await deployFn( @@ -454,7 +520,7 @@ async function deployProxyWithSharedImpl( { account: deployer, artifact: proxyArtifact, - args: [implDep.address, governor, initCalldata], + args: [implDep.address, deployer, initCalldata], }, { skipIfAlreadyDeployed: true }, ) @@ -475,7 +541,7 @@ async function deployProxyWithSharedImpl( if (proxyResult.newlyDeployed) { env.showMessage(`✓ ${contract.name} proxy deployed at ${proxyResult.address}`) env.showMessage(` Implementation: ${implDep.address}`) - env.showMessage(` ProxyAdmin (per-proxy): ${proxyAdminAddress}`) + env.showMessage(` ProxyAdmin (per-proxy, deployer-owned): ${proxyAdminAddress}`) } else { env.showMessage(`✓ ${contract.name} already deployed at ${proxyResult.address}`) } @@ -486,3 +552,74 @@ async function deployProxyWithSharedImpl( upgraded: false, } } + +/** + * Transfer ProxyAdmin ownership for an issuance contract from deployer to governor. + * + * Reads the per-proxy ProxyAdmin address from the address book entry's proxyAdmin field, + * checks current ownership, and transfers if needed. Idempotent: skips if already owned + * by the target governor. + * + * @param env - Deployment environment + * @param contract - Registry entry for the contract whose ProxyAdmin to transfer + * @returns Whether a transfer was executed + * + * @example + * ```typescript + * await transferProxyAdminOwnership(env, Contracts.issuance.IssuanceAllocator) + * ``` + */ +export async function transferProxyAdminOwnership(env: Environment, contract: RegistryEntry): Promise { + const deployer = requireDeployer(env) + const governor = await getGovernor(env) + const client = graph.getPublicClient(env) as PublicClient + + // Get ProxyAdmin address from address book + const targetChainId = await getTargetChainIdFromEnv(env) + const ab = graph.getIssuanceAddressBook(targetChainId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const entry = ab.getEntry(contract.name as any) + const proxyAdminAddress = entry?.proxyAdmin + + if (!proxyAdminAddress) { + throw new Error(`No proxyAdmin found in address book for ${contract.name}`) + } + + // Check current owner + const currentOwner = (await client.readContract({ + address: proxyAdminAddress as `0x${string}`, + abi: OZ_PROXY_ADMIN_ABI, + functionName: 'owner', + })) as string + + if (currentOwner.toLowerCase() === governor.toLowerCase()) { + env.showMessage(` ProxyAdmin ownership already transferred to governor: ${proxyAdminAddress}`) + return false + } + + if (currentOwner.toLowerCase() !== deployer.toLowerCase()) { + throw new Error( + `ProxyAdmin ${proxyAdminAddress} owned by ${currentOwner}, expected deployer ${deployer}. ` + + `Cannot transfer ownership.`, + ) + } + + // Transfer ownership to governor + env.showMessage(` Transferring ProxyAdmin ownership to governor...`) + env.showMessage(` ProxyAdmin: ${proxyAdminAddress}`) + env.showMessage(` From: ${deployer}`) + env.showMessage(` To: ${governor}`) + + const executeFn = execute(env) + await executeFn( + { address: proxyAdminAddress as `0x${string}`, abi: OZ_PROXY_ADMIN_ABI }, + { + account: deployer, + functionName: 'transferOwnership', + args: [governor as `0x${string}`], + }, + ) + + env.showMessage(` ✓ ProxyAdmin ownership transferred to governor`) + return true +} diff --git a/packages/deployment/lib/oz-proxy-verify.ts b/packages/deployment/lib/oz-proxy-verify.ts index 79c5609d6..2e3b0f305 100644 --- a/packages/deployment/lib/oz-proxy-verify.ts +++ b/packages/deployment/lib/oz-proxy-verify.ts @@ -110,6 +110,39 @@ export function getEtherscanBrowserUrl(chainId: number): string { return url } +/** + * Check if a contract is already verified on Etherscan. + * + * Queries the getsourcecode API — a verified contract has a non-empty + * SourceCode field. Returns the explorer URL if verified, undefined otherwise. + */ +export async function checkEtherscanVerified( + address: string, + apiKey: string, + chainId: number, +): Promise { + const apiUrl = getApiUrl() + const browserUrl = getEtherscanBrowserUrl(chainId) + + const params = new URLSearchParams({ + module: 'contract', + action: 'getsourcecode', + address, + apikey: apiKey, + }) + + try { + const response = await fetch(`${apiUrl}?chainid=${chainId}&${params.toString()}`) + const data = (await response.json()) as { status: string; result: Array<{ SourceCode?: string }> } + if (data.status === '1' && data.result?.[0]?.SourceCode) { + return `${browserUrl}/address/${address}#code` + } + } catch { + // Network error — assume not verified, let the caller proceed + } + return undefined +} + /** * Verify OZ TransparentUpgradeableProxy via Etherscan API * @@ -200,6 +233,12 @@ export async function verifyOZProxy( return { success: true, url } } + // "Already Verified" can appear during polling (not just at submission) + if (checkResult.result?.toLowerCase().includes('already verified')) { + const url = `${browserUrl}/address/${address}#code` + return { success: true, url, message: 'Already verified' } + } + // Verification failed return { success: false, message: checkResult.result } } diff --git a/packages/deployment/lib/preconditions.ts b/packages/deployment/lib/preconditions.ts new file mode 100644 index 000000000..37adc5638 --- /dev/null +++ b/packages/deployment/lib/preconditions.ts @@ -0,0 +1,354 @@ +/** + * Shared Precondition Checks + * + * Each function answers "is this action step done?" for a specific component. + * Used by BOTH action scripts (to skip if done) and status scripts (for next-step hints). + * + * This is the SINGLE SOURCE OF TRUTH for precondition logic. + * Action scripts and status scripts must call the same functions — no copies. + * + * Configure checks: params, integration references, and role GRANTS (PAUSE_ROLE, GOVERNOR_ROLE) + * Transfer checks: deployer GOVERNOR_ROLE REVOKE + ProxyAdmin ownership + */ + +import type { PublicClient } from 'viem' +import { keccak256, toHex } from 'viem' + +import { + ACCESS_CONTROL_ENUMERABLE_ABI, + ISSUANCE_ALLOCATOR_ABI, + ISSUANCE_TARGET_ABI, + OZ_PROXY_ADMIN_ABI, + REWARDS_MANAGER_ABI, + REWARDS_MANAGER_DEPRECATED_ABI, +} from './abis.js' + +// ============================================================================ +// Result type +// ============================================================================ + +/** + * Result of a precondition check + * + * @property done - true if the action step is complete (on-chain state matches target) + * @property reason - why not done (human-readable, for status display) + */ +export interface PreconditionResult { + done: boolean + reason?: string +} + +// ============================================================================ +// Helpers +// ============================================================================ + +// Precomputed role hashes (matches BaseUpgradeable constants) +const GOVERNOR_ROLE = keccak256(toHex('GOVERNOR_ROLE')) +const PAUSE_ROLE = keccak256(toHex('PAUSE_ROLE')) + +/** Check if account has a role on a contract */ +async function hasRole( + client: PublicClient, + contractAddress: string, + role: `0x${string}`, + account: string, +): Promise { + return (await client.readContract({ + address: contractAddress as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [role, account as `0x${string}`], + })) as boolean +} + +/** + * Check role grants common to all deployer-initialized contracts + * + * Configure must grant: + * - GOVERNOR_ROLE to protocol governor + * - PAUSE_ROLE to pause guardian + */ +async function checkRoleGrants( + client: PublicClient, + contractAddress: string, + governor: string, + pauseGuardian: string, +): Promise<{ governorOk: boolean; pauseOk: boolean; reasons: string[] }> { + const governorOk = await hasRole(client, contractAddress, GOVERNOR_ROLE, governor) + const pauseOk = await hasRole(client, contractAddress, PAUSE_ROLE, pauseGuardian) + + const reasons: string[] = [] + if (!governorOk) reasons.push('governor missing GOVERNOR_ROLE') + if (!pauseOk) reasons.push('pauseGuardian missing PAUSE_ROLE') + + return { governorOk, pauseOk, reasons } +} + +// ============================================================================ +// Configure checks +// ============================================================================ + +/** + * Check if IssuanceAllocator is configured + * + * Matches the skip logic in allocate/allocator/04_configure.ts: + * - RM.issuancePerBlock must be > 0 (RM initialized) + * - IA.getIssuancePerBlock() must equal RM rate + * - governor has GOVERNOR_ROLE + * - pauseGuardian has PAUSE_ROLE + * + * Note: RM target allocation (setTargetAllocation) is an activation step + * in issuance-connect, not a configure step. + */ +export async function checkIAConfigured( + client: PublicClient, + iaAddress: string, + rmAddress: string, + governor: string, + pauseGuardian: string, +): Promise { + // Check RM issuance rate + const rmIssuanceRate = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_DEPRECATED_ABI, + functionName: 'issuancePerBlock', + })) as bigint + + if (rmIssuanceRate === 0n) { + return { done: false, reason: 'RM.issuancePerBlock is 0' } + } + + // Check IA rate matches RM + const iaIssuanceRate = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + + const rateOk = iaIssuanceRate === rmIssuanceRate && iaIssuanceRate > 0n + + // Check role grants + const roles = await checkRoleGrants(client, iaAddress, governor, pauseGuardian) + + if (rateOk && roles.governorOk && roles.pauseOk) { + return { done: true } + } + + const reasons: string[] = [] + if (!rateOk) reasons.push('rate mismatch') + reasons.push(...roles.reasons) + return { done: false, reason: reasons.join(', ') } +} + +/** + * Check if RecurringAgreementManager is configured + * + * Matches the skip logic in agreement/manager/04_configure.ts: + * - RC has COLLECTOR_ROLE + * - SS has DATA_SERVICE_ROLE + * - RAM.getIssuanceAllocator() == IA + * - governor has GOVERNOR_ROLE + * - pauseGuardian has PAUSE_ROLE + */ +export async function checkRAMConfigured( + client: PublicClient, + ramAddress: string, + rcAddress: string, + ssAddress: string, + iaAddress: string, + governor: string, + pauseGuardian: string, +): Promise { + const COLLECTOR_ROLE = keccak256(toHex('COLLECTOR_ROLE')) + const DATA_SERVICE_ROLE = keccak256(toHex('DATA_SERVICE_ROLE')) + + const rcHasCollectorRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [COLLECTOR_ROLE, rcAddress as `0x${string}`], + })) as boolean + + const ssHasDataServiceRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [DATA_SERVICE_ROLE, ssAddress as `0x${string}`], + })) as boolean + + let iaConfigured = false + try { + const currentIA = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + iaConfigured = currentIA.toLowerCase() === iaAddress.toLowerCase() + } catch { + // Not set + } + + // Check role grants + const roles = await checkRoleGrants(client, ramAddress, governor, pauseGuardian) + + if (rcHasCollectorRole && ssHasDataServiceRole && iaConfigured && roles.governorOk && roles.pauseOk) { + return { done: true } + } + + const reasons: string[] = [] + if (!rcHasCollectorRole) reasons.push('RC missing COLLECTOR_ROLE') + if (!ssHasDataServiceRole) reasons.push('SS missing DATA_SERVICE_ROLE') + if (!iaConfigured) reasons.push('IssuanceAllocator not set') + reasons.push(...roles.reasons) + return { done: false, reason: reasons.join(', ') } +} + +/** + * Check Reclaim role grants only (governor has GOVERNOR_ROLE, pauseGuardian has PAUSE_ROLE) + * + * Use this when you need to know whether the deployer (with Reclaim GOVERNOR_ROLE) can + * fix the issue. The RM integration is governance-only and should be checked separately + * via checkReclaimRMIntegration. + */ +export async function checkReclaimRoles( + client: PublicClient, + reclaimAddress: string, + governor: string, + pauseGuardian: string, +): Promise { + const roles = await checkRoleGrants(client, reclaimAddress, governor, pauseGuardian) + if (roles.governorOk && roles.pauseOk) { + return { done: true } + } + return { done: false, reason: roles.reasons.join(', ') } +} + +/** + * Check RM integration with Reclaim: RM.getDefaultReclaimAddress() == reclaim address + * + * This is governance-only — only an account with GOVERNOR_ROLE on RM can fix it, + * which the deployer never has. Status logic should always treat a failure here + * as deferred (governance TX), not blocking on configure. + */ +export async function checkReclaimRMIntegration( + client: PublicClient, + rmAddress: string, + reclaimAddress: string, +): Promise { + try { + const currentDefault = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getDefaultReclaimAddress', + })) as string + + if (currentDefault.toLowerCase() === reclaimAddress.toLowerCase()) { + return { done: true } + } + return { done: false, reason: 'default reclaim address not set' } + } catch { + // Function not available — RM not upgraded + return { done: false, reason: 'RM not upgraded' } + } +} + +/** + * Check if ReclaimedRewards is fully configured (roles + RM integration) + * + * Convenience wrapper that combines checkReclaimRoles and checkReclaimRMIntegration. + * Use the split functions when callers need to distinguish deployer-fixable role + * issues from governance-only RM integration issues. + */ +export async function checkReclaimConfigured( + client: PublicClient, + rmAddress: string, + reclaimAddress: string, + governor: string, + pauseGuardian: string, +): Promise { + const roles = await checkReclaimRoles(client, reclaimAddress, governor, pauseGuardian) + const rmIntegration = await checkReclaimRMIntegration(client, rmAddress, reclaimAddress) + + if (roles.done && rmIntegration.done) { + return { done: true } + } + + // If roles are done but RM not upgraded, report that specifically + if (roles.done && rmIntegration.reason === 'RM not upgraded') { + return { done: false, reason: 'RM not upgraded' } + } + + const reasons: string[] = [] + if (!roles.done && roles.reason) reasons.push(roles.reason) + if (!rmIntegration.done && rmIntegration.reason) reasons.push(rmIntegration.reason) + return { done: false, reason: reasons.join(', ') } +} + +/** + * Check if DefaultAllocation is configured + * + * - governor has GOVERNOR_ROLE on DefaultAllocation + * - pauseGuardian has PAUSE_ROLE on DefaultAllocation + * + * Note: IA.setDefaultTarget(DA) is an activation step in issuance-connect. + */ +export async function checkDefaultAllocationConfigured( + client: PublicClient, + daAddress: string, + governor: string, + pauseGuardian: string, +): Promise { + const roles = await checkRoleGrants(client, daAddress, governor, pauseGuardian) + + if (roles.governorOk && roles.pauseOk) { + return { done: true } + } + + return { done: false, reason: roles.reasons.join(', ') } +} + +// ============================================================================ +// Transfer checks +// ============================================================================ + +/** + * Check if deployer GOVERNOR_ROLE is revoked on a contract + * + * Transfer = revoke deployer access. Role grants happen in configure. + * Generic check used for IA, RAM, Reclaim. + */ +export async function checkDeployerRevoked( + client: PublicClient, + contractAddress: string, + deployer: string, +): Promise { + const deployerHasRole = await hasRole(client, contractAddress, GOVERNOR_ROLE, deployer) + + if (!deployerHasRole) { + return { done: true } + } + return { done: false, reason: 'deployer GOVERNOR_ROLE not revoked' } +} + +/** + * Check if ProxyAdmin ownership is transferred to governor + * + * Generic check used for any contract with an OZ v5 per-proxy ProxyAdmin. + * Used by transfer scripts for IA, RAM, Reclaim, REO. + */ +export async function checkProxyAdminTransferred( + client: PublicClient, + proxyAdminAddress: string, + governor: string, +): Promise { + const currentOwner = (await client.readContract({ + address: proxyAdminAddress as `0x${string}`, + abi: OZ_PROXY_ADMIN_ABI, + functionName: 'owner', + })) as string + + if (currentOwner.toLowerCase() === governor.toLowerCase()) { + return { done: true } + } + return { done: false, reason: `ProxyAdmin owned by ${currentOwner}, not governor` } +} diff --git a/packages/deployment/lib/script-factories.ts b/packages/deployment/lib/script-factories.ts new file mode 100644 index 000000000..6c1bb1de5 --- /dev/null +++ b/packages/deployment/lib/script-factories.ts @@ -0,0 +1,384 @@ +/** + * Deploy Script Factories - Create deployment modules with standard framework plumbing + * + * Two flavors: + * + * **Contract-based** (component lifecycle): + * Derive tags from registry componentTag. Action-verb skip gating. + * Post-action sync. Use for standard deploy/upgrade/configure/transfer steps. + * + * **Tag-based** (goals, multi-contract status, standalone actions): + * Accept a tag string directly. Skip when no --tags specified. + * Custom execute callback handles all logic. + * + * Skip gating uses func.skip (checked by rocketh's executor via patch) + * with early returns as a safety net. + */ + +import type { DeployScriptModule, Environment } from '@rocketh/core/types' + +import type { RegistryEntry } from './contract-registry.js' +import { deployImplementation, getImplementationConfig } from './deploy-implementation.js' +import { DeploymentActions, noTagsRequested, shouldSkipAction } from './deployment-tags.js' +import { requireUpgradeExecuted } from './execute-governance.js' +import { deployProxyContract } from './issuance-deploy-utils.js' +import { showDetailedComponentStatus } from './status-detail.js' +import { syncComponentFromRegistry, syncComponentsFromRegistry } from './sync-utils.js' +import type { ImplementationUpgradeOverrides } from './upgrade-implementation.js' +import { upgradeImplementation } from './upgrade-implementation.js' + +/** + * Require that the registry entry has a componentTag, throwing a clear error if not. + */ +function requireComponentTag(contract: RegistryEntry): string { + if (!contract.componentTag) { + throw new Error( + `Contract '${contract.name}' has no componentTag in the registry. ` + + `Add a componentTag to use script factories.`, + ) + } + return contract.componentTag +} + +/** + * Create a standard upgrade deploy script module. + * + * Generates a governance TX to upgrade the contract's proxy to its pending implementation. + * Tags and dependencies are derived from the contract's componentTag. + * + * @example Standard single-contract upgrade: + * ```typescript + * import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' + * import { createUpgradeModule } from '@graphprotocol/deployment/lib/script-factories.js' + * + * export default createUpgradeModule(Contracts.horizon.PaymentsEscrow) + * ``` + * + * @example Upgrade with implementation name override: + * ```typescript + * export default createUpgradeModule(Contracts.issuance.SomeProxy, { + * overrides: { implementationName: 'DifferentImpl' }, + * }) + * ``` + */ +export function createUpgradeModule( + contract: RegistryEntry, + options?: { + overrides?: ImplementationUpgradeOverrides + extraDependencies?: string[] + /** Additional contracts to sync alongside `contract` before the upgrade runs. */ + prerequisites?: RegistryEntry[] + }, +): DeployScriptModule { + const tag = requireComponentTag(contract) + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.UPGRADE)) return + await syncComponentsFromRegistry(env, [contract, ...(options?.prerequisites ?? [])]) + await upgradeImplementation(env, contract, options?.overrides) + await syncComponentFromRegistry(env, contract) + } + + func.tags = [tag] + func.dependencies = options?.extraDependencies ?? [] + func.skip = async () => shouldSkipAction(DeploymentActions.UPGRADE) + + return func +} + +/** + * Create a standard end/complete deploy script module. + * + * Gates on `--tags ...,all`. Verifies the upgrade governance TX has been + * executed and shows a ready message. The actual lifecycle actions a component + * needs are encoded in its dependency chain via the component tag, not in this + * factory. + * + * @example + * ```typescript + * export default createEndModule(Contracts.horizon.PaymentsEscrow) + * ``` + */ +export function createEndModule(contract: RegistryEntry): DeployScriptModule { + const tag = requireComponentTag(contract) + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.ALL)) return + requireUpgradeExecuted(env, contract.name) + env.showMessage(`\n✓ ${contract.name} ready`) + } + + func.tags = [tag] + func.dependencies = [] + func.skip = async () => shouldSkipAction(DeploymentActions.ALL) + + return func +} + +/** + * Create a status deploy script module. + * + * Syncs the component with on-chain state and shows its current status. + * Tagged with the bare component name so `--tags IssuanceAllocator` is a + * safe, read-only operation. + * + * @example Single contract (default status display): + * ```typescript + * export default createStatusModule(Contracts.horizon.PaymentsEscrow) + * ``` + * + * @example Custom status with tag (multi-contract or cross-component): + * ```typescript + * export default createStatusModule(GoalTags.GIP_0088, async (env) => { + * // custom multi-phase status display + * }) + * ``` + */ +export function createStatusModule(contract: RegistryEntry): DeployScriptModule +export function createStatusModule(tag: string, execute: (env: Environment) => Promise): DeployScriptModule +export function createStatusModule( + contractOrTag: RegistryEntry | string, + execute?: (env: Environment) => Promise, +): DeployScriptModule { + const tag = typeof contractOrTag === 'string' ? contractOrTag : requireComponentTag(contractOrTag) + + const func: DeployScriptModule = async (env) => { + if (noTagsRequested()) return + if (execute) { + await execute(env) + } else { + await showDetailedComponentStatus(env, contractOrTag as RegistryEntry) + } + } + + func.tags = [tag] + func.dependencies = [] + func.skip = async () => noTagsRequested() + + return func +} + +// ============================================================================ +// Action Factories (custom logic with standard framework plumbing) +// ============================================================================ + +/** + * Create a deploy script module for a custom action. + * + * Two forms: + * + * **Contract-based** (component lifecycle steps): + * Uses action verb gating (`shouldSkipAction`) and post-action sync. + * Requires both component tag AND action verb in `--tags`. + * + * **Tag-based** (goal scripts, standalone actions): + * Uses tag gating (`noTagsRequested`). The tag in `--tags` is sufficient. + * No post-action sync — the execute callback handles everything. + * + * @example Contract-based configure: + * ```typescript + * export default createActionModule( + * Contracts.horizon.RecurringCollector, + * DeploymentActions.CONFIGURE, + * async (env) => { ... }, + * ) + * ``` + * + * @example Tag-based goal action: + * ```typescript + * export default createActionModule( + * GoalTags.GIP_0088_ISSUANCE_CONNECT, + * async (env) => { ... }, + * { dependencies: [ComponentTags.ISSUANCE_ALLOCATOR] }, + * ) + * ``` + */ +export function createActionModule( + contract: RegistryEntry, + action: (typeof DeploymentActions)[keyof typeof DeploymentActions], + execute: (env: Environment) => Promise, + options?: { extraDependencies?: string[]; prerequisites?: RegistryEntry[] }, +): DeployScriptModule +export function createActionModule( + tag: string, + execute: (env: Environment) => Promise, + options?: { dependencies?: string[] }, +): DeployScriptModule +export function createActionModule( + contractOrTag: RegistryEntry | string, + actionOrExecute: (typeof DeploymentActions)[keyof typeof DeploymentActions] | ((env: Environment) => Promise), + executeOrOptions?: ((env: Environment) => Promise) | { dependencies?: string[] }, + maybeOptions?: { extraDependencies?: string[]; prerequisites?: RegistryEntry[] }, +): DeployScriptModule { + if (typeof contractOrTag === 'string') { + // Tag-based: (tag, execute, options?) + const tag = contractOrTag + const execute = actionOrExecute as (env: Environment) => Promise + const options = executeOrOptions as { dependencies?: string[] } | undefined + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(tag)) return + await execute(env) + } + + func.tags = [tag] + func.dependencies = options?.dependencies ?? [] + func.skip = async () => shouldSkipAction(tag) + + return func + } + + // Contract-based: (contract, action, execute, options?) + const tag = requireComponentTag(contractOrTag) + const action = actionOrExecute as string + const execute = executeOrOptions as (env: Environment) => Promise + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(action)) return + await syncComponentsFromRegistry(env, [contractOrTag, ...(maybeOptions?.prerequisites ?? [])]) + await execute(env) + await syncComponentFromRegistry(env, contractOrTag) + } + + func.tags = [tag] + func.dependencies = maybeOptions?.extraDependencies ?? [] + func.skip = async () => shouldSkipAction(action) + + return func +} + +// ============================================================================ +// Deploy Factories +// ============================================================================ + +/** + * Options shared by deploy factories + */ +interface DeployModuleOptions { + /** Additional tags beyond the derived deploy action tag */ + extraTags?: string[] + /** Additional rocketh dependency tags */ + extraDependencies?: string[] + /** + * Additional registry entries to sync immediately before the action runs. + * Use for contracts read via `env.getOrNull(...)` inside `resolveArgs` / + * `resolveConstructorArgs` (e.g. Controller, shared implementations). + */ + prerequisites?: RegistryEntry[] +} + +/** + * Create a deploy module for prerequisite contracts (existing proxy, new implementation). + * + * Uses `deployImplementation` + `getImplementationConfig` to deploy a new implementation + * and store it as pendingImplementation for governance upgrade. + * + * @param contract - Registry entry (must have prerequisite: true, artifact, proxyType) + * @param resolveConstructorArgs - Optional callback to resolve constructor args from env. + * Called with the deployment environment. Return the args array. + * Omit for contracts with no constructor args (e.g., RewardsManager). + * + * @example No constructor args: + * ```typescript + * export default createImplementationDeployModule(Contracts.horizon.RewardsManager) + * ``` + * + * @example With synced dependency args: + * ```typescript + * export default createImplementationDeployModule( + * Contracts['subgraph-service'].DisputeManager, + * (env) => { + * const controller = env.getOrNull('Controller') + * if (!controller) throw new Error('Missing Controller') + * return [controller.address] + * }, + * ) + * ``` + */ +export function createImplementationDeployModule( + contract: RegistryEntry, + resolveConstructorArgs?: (env: Environment) => Promise | unknown[], + options?: DeployModuleOptions, +): DeployScriptModule { + const tag = requireComponentTag(contract) + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [contract, ...(options?.prerequisites ?? [])]) + const constructorArgs = resolveConstructorArgs ? await resolveConstructorArgs(env) : undefined + await deployImplementation( + env, + getImplementationConfig(contract.addressBook, contract.name, constructorArgs ? { constructorArgs } : undefined), + ) + await syncComponentFromRegistry(env, contract) + } + + func.tags = [tag, ...(options?.extraTags ?? [])] + func.dependencies = options?.extraDependencies ?? [] + func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) + + return func +} + +/** + * Create a deploy module for new contracts (fresh proxy + implementation). + * + * Uses `deployProxyContract` to deploy an OZ v5 TransparentUpgradeableProxy with + * atomic initialization. On subsequent runs, deploys new implementation and stores + * as pendingImplementation. + * + * @param contract - Registry entry (must have deployable: true, artifact, proxyType) + * @param resolveArgs - Optional callback to resolve constructor and initialize args. + * Omit initializeArgs to use default [governor]. + * + * @example With graphToken constructor and deployer init: + * ```typescript + * export default createProxyDeployModule( + * Contracts.issuance.RewardsEligibilityOracleA, + * (env) => ({ + * constructorArgs: [requireGraphToken(env).address], + * initializeArgs: [requireDeployer(env)], + * }), + * ) + * ``` + * + * @example With default initialize args [governor]: + * ```typescript + * export default createProxyDeployModule( + * Contracts.issuance.RecurringAgreementManager, + * (env) => ({ + * constructorArgs: [requireGraphToken(env).address, paymentsEscrow.address], + * }), + * ) + * ``` + */ +export function createProxyDeployModule( + contract: RegistryEntry, + resolveArgs?: (env: Environment) => Promise | ProxyDeployArgs, + options?: DeployModuleOptions, +): DeployScriptModule { + const tag = requireComponentTag(contract) + + const func: DeployScriptModule = async (env) => { + if (shouldSkipAction(DeploymentActions.DEPLOY)) return + await syncComponentsFromRegistry(env, [contract, ...(options?.prerequisites ?? [])]) + const args = resolveArgs ? await resolveArgs(env) : {} + await deployProxyContract(env, { + contract, + constructorArgs: args.constructorArgs, + initializeArgs: args.initializeArgs, + }) + await syncComponentFromRegistry(env, contract) + } + + func.tags = [tag, ...(options?.extraTags ?? [])] + func.dependencies = options?.extraDependencies ?? [] + func.skip = async () => shouldSkipAction(DeploymentActions.DEPLOY) + + return func +} + +interface ProxyDeployArgs { + constructorArgs?: unknown[] + initializeArgs?: unknown[] +} diff --git a/packages/deployment/lib/status-detail.ts b/packages/deployment/lib/status-detail.ts new file mode 100644 index 000000000..5f0d54dc5 --- /dev/null +++ b/packages/deployment/lib/status-detail.ts @@ -0,0 +1,1131 @@ +/** + * Status Detail - Detailed contract status with integration checks + * + * Extracted from deployment-status task so deploy scripts (10_status.ts) + * can show the same detail view. The task delegates to these functions. + */ + +import type { Environment } from '@rocketh/core/types' +import type { PublicClient } from 'viem' + +import { + ACCESS_CONTROL_ENUMERABLE_ABI, + CONTROLLER_ABI, + IISSUANCE_TARGET_INTERFACE_ID, + IREWARDS_MANAGER_INTERFACE_ID, + ISSUANCE_ALLOCATOR_ABI, + ISSUANCE_TARGET_ABI, + PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + REWARDS_ELIGIBILITY_ORACLE_ABI, + REWARDS_MANAGER_ABI, +} from './abis.js' +import type { AddressBookOps } from './address-book-ops.js' +import { getTargetChainIdFromEnv } from './address-book-utils.js' +import { + checkIssuanceAllocatorActivation, + checkOperatorRole, + formatAddress, + supportsInterface, +} from './contract-checks.js' +import type { RegistryEntry } from './contract-registry.js' +import { countPendingGovernanceTxs } from './execute-governance.js' +import { formatGRT } from './format.js' +import { getContractStatusLine, type ContractStatusResult, type ProxyAdminOwnershipContext } from './sync-utils.js' +import { graph } from '../rocketh/deploy.js' + +// ============================================================================ +// Integration Check Types & Helpers +// ============================================================================ + +/** Integration check result */ +export interface IntegrationCheck { + ok: boolean | null // null = not applicable / not deployed + label: string +} + +function formatCheck(check: IntegrationCheck): string { + const icon = check.ok === null ? '○' : check.ok ? '✓' : '✗' + return ` ${icon} ${check.label}` +} + +function formatWarnings(warnings: string[] | undefined): string[] { + if (!warnings) return [] + return warnings.map((w) => ` ⚠ ${w}`) +} + +/** Format proxy admin detail lines */ +function formatProxyAdminDetail(result: ContractStatusResult): string[] { + if (!result.proxyAdminAddress) return [] + const lines: string[] = [] + const ownerIcon = result.proxyAdminOwner === 'governor' ? '✓' : result.proxyAdminOwner === 'unknown' ? '○' : '⚠' + const ownerRole = + result.proxyAdminOwner === 'governor' + ? 'governor' + : result.proxyAdminOwner === 'deployer' + ? 'deployer' + : result.proxyAdminOwner === 'other' + ? 'not governor' + : 'unknown' + const ownerAddr = result.proxyAdminOwnerAddress ? ` ${result.proxyAdminOwnerAddress}` : '' + lines.push(` ProxyAdmin: ${result.proxyAdminAddress}`) + lines.push(` ${ownerIcon} ProxyAdmin owner:${ownerAddr} (${ownerRole})`) + return lines +} + +// ============================================================================ +// Ownership Context Resolution +// ============================================================================ + +/** + * Resolve governor/deployer context for proxy admin ownership checks + */ +export async function resolveOwnershipContext( + client: PublicClient, + env: Environment, + chainId: number, +): Promise { + const horizonAddressBook = graph.getHorizonAddressBook(chainId) + try { + const controllerAddress = horizonAddressBook.entryExists('Controller') + ? horizonAddressBook.getEntry('Controller')?.address + : null + if (!controllerAddress) return undefined + + const governor = (await client.readContract({ + address: controllerAddress as `0x${string}`, + abi: CONTROLLER_ABI, + functionName: 'getGovernor', + })) as string + + if (!governor) return undefined + + // Deployer is best-effort: available when provider has accounts (fork/local) + let deployer: string | undefined + try { + const accounts = (await env.network.provider.request({ method: 'eth_accounts' })) as string[] | undefined + if (accounts && accounts.length > 0) { + deployer = accounts[0] + } + } catch { + // No accounts available (read-only provider) + } + + return { governor, deployer } + } catch { + return undefined + } +} + +// ============================================================================ +// Integration Check Functions +// ============================================================================ + +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' + +export async function getRewardsManagerChecks( + client: PublicClient, + horizonBook: AddressBookOps, + issuanceBook?: AddressBookOps, + ssBook?: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null + + if (!rmAddress) return checks + + // Interface support + const supportsRewardsManager = await supportsInterface(client, rmAddress, IREWARDS_MANAGER_INTERFACE_ID) + checks.push({ ok: supportsRewardsManager, label: `implements IRewardsManager (${IREWARDS_MANAGER_INTERFACE_ID})` }) + + const supportsIssuanceTarget = await supportsInterface(client, rmAddress, IISSUANCE_TARGET_INTERFACE_ID) + checks.push({ ok: supportsIssuanceTarget, label: `implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})` }) + + if (!supportsRewardsManager) return checks + + // Helper: read a contract value, returning null on failure + async function rmRead(functionName: string, abi: readonly unknown[] = REWARDS_MANAGER_ABI): Promise { + try { + return (await client.readContract({ + address: rmAddress as `0x${string}`, + abi, + functionName, + })) as T + } catch { + return null + } + } + + // Issuance rates + const rawRate = await rmRead('getRawIssuancePerBlock') + const allocatedRate = await rmRead('getAllocatedIssuancePerBlock') + if (rawRate !== null) { + checks.push({ ok: rawRate > 0n, label: `issuancePerBlock: ${formatGRT(rawRate)} (raw)` }) + } + if (allocatedRate !== null) { + checks.push({ + ok: allocatedRate > 0n, + label: `issuancePerBlock: ${formatGRT(allocatedRate)} (after IA allocation)`, + }) + } + + // SubgraphService + const ss = await rmRead('subgraphService') + if (ss !== null) { + const expected = ssBook?.entryExists('SubgraphService') + ? (ssBook.getEntry('SubgraphService')?.address ?? null) + : null + const matches = expected ? ss.toLowerCase() === expected.toLowerCase() : null + checks.push({ + ok: ss !== ZERO_ADDRESS ? matches : false, + label: `subgraphService: ${ss}${matches === false && expected ? ` (expected ${expected})` : ''}`, + }) + } + + // IssuanceAllocator + const ia = await rmRead('getIssuanceAllocator', ISSUANCE_TARGET_ABI) + if (ia !== null) { + const iaBook = issuanceBook?.entryExists('IssuanceAllocator') + ? issuanceBook.getEntry('IssuanceAllocator')?.address + : null + const isSet = ia !== ZERO_ADDRESS + const matches = iaBook ? ia.toLowerCase() === iaBook.toLowerCase() : null + checks.push({ + ok: isSet ? matches : null, + label: isSet + ? `issuanceAllocator: ${ia}${matches === false ? ` (expected ${iaBook!})` : ''}` + : 'issuanceAllocator: not set', + }) + } + + // Provider eligibility oracle + const reo = await rmRead('getProviderEligibilityOracle', PROVIDER_ELIGIBILITY_MANAGEMENT_ABI) + if (reo !== null) { + const reoA = issuanceBook?.entryExists('RewardsEligibilityOracleA') + ? issuanceBook.getEntry('RewardsEligibilityOracleA')?.address + : null + const isSet = reo !== ZERO_ADDRESS + const matchesA = reoA ? reo.toLowerCase() === reoA.toLowerCase() : null + checks.push({ + ok: isSet ? matchesA : null, + label: isSet + ? `providerEligibilityOracle: ${reo}${matchesA === false ? ' (not REO-A)' : matchesA ? ' (REO-A)' : ''}` + : 'providerEligibilityOracle: not set', + }) + } else { + checks.push({ ok: null, label: 'providerEligibilityOracle: not set' }) + } + + // Revert on ineligible + const revertOnIneligible = await rmRead('getRevertOnIneligible') + if (revertOnIneligible !== null) { + checks.push({ ok: null, label: `revertOnIneligible: ${revertOnIneligible}` }) + } + + // Default reclaim address + const defaultReclaim = await rmRead('getDefaultReclaimAddress') + if (defaultReclaim !== null) { + const expectedAddr = issuanceBook?.entryExists('ReclaimedRewards') + ? issuanceBook.getEntry('ReclaimedRewards')?.address + : null + const isSet = defaultReclaim !== ZERO_ADDRESS + const matches = isSet && expectedAddr ? defaultReclaim.toLowerCase() === expectedAddr.toLowerCase() : null + checks.push({ + ok: isSet ? (matches ?? true) : null, + label: isSet + ? `defaultReclaimAddress: ${defaultReclaim}${matches === false ? ` (expected ${expectedAddr!})` : ''}` + : 'defaultReclaimAddress: not set', + }) + } + + return checks +} + +export async function getIssuanceAllocatorChecks( + client: PublicClient, + horizonBook: AddressBookOps, + issuanceBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + const iaAddress = issuanceBook.entryExists('IssuanceAllocator') + ? issuanceBook.getEntry('IssuanceAllocator')?.address + : null + const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null + const gtAddress = horizonBook.entryExists('L2GraphToken') ? horizonBook.getEntry('L2GraphToken')?.address : null + + if (!iaAddress || !rmAddress || !gtAddress) return checks + + const rmSupportsTarget = await supportsInterface(client, rmAddress, IISSUANCE_TARGET_INTERFACE_ID) + checks.push({ ok: rmSupportsTarget, label: `RM implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})` }) + + if (rmSupportsTarget) { + const activation = await checkIssuanceAllocatorActivation(client, iaAddress, rmAddress, gtAddress) + checks.push({ ok: activation.iaIntegrated, label: 'RM.issuanceAllocator == this' }) + checks.push({ ok: activation.iaMinter, label: 'GraphToken.MINTER_ROLE granted' }) + } else { + checks.push({ ok: null, label: 'RM.issuanceAllocator == this (RM not upgraded)' }) + checks.push({ ok: null, label: 'GraphToken.MINTER_ROLE granted (RM not upgraded)' }) + } + + try { + const targetCount = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getTargetCount', + })) as bigint + const hasDefaultTarget = targetCount > 0n + checks.push({ ok: hasDefaultTarget, label: 'defaultTarget configured' }) + } catch { + // Function not available + } + + // Confirm 100% allocation: getTotalAllocation().totalAllocationRate == issuancePerBlock. + // Once a real defaultTarget is set (issuance-connect), the contract reports + // exactly issuancePerBlock; if it doesn't, the default is still address(0) + // and some issuance is unallocated (not minted). Skipped (○) when + // issuancePerBlock is 0 — the IA hasn't been configured with a rate yet, + // so the question is not yet meaningful. + try { + const issuancePerBlock = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getIssuancePerBlock', + })) as bigint + const totalAllocation = (await client.readContract({ + address: iaAddress as `0x${string}`, + abi: ISSUANCE_ALLOCATOR_ABI, + functionName: 'getTotalAllocation', + })) as { totalAllocationRate: bigint; allocatorMintingRate: bigint; selfMintingRate: bigint } + if (issuancePerBlock === 0n) { + checks.push({ ok: null, label: '100% allocated (issuancePerBlock not set)' }) + } else { + const fullyAllocated = totalAllocation.totalAllocationRate === issuancePerBlock + checks.push({ + ok: fullyAllocated, + label: `100% allocated (${formatGRT(totalAllocation.totalAllocationRate)} of ${formatGRT(issuancePerBlock)})`, + }) + } + } catch { + // Function not available + } + + return checks +} + +export async function getRewardsEligibilityOracleChecks( + client: PublicClient, + horizonBook: AddressBookOps, + issuanceBook: AddressBookOps, + entryName: string, +): Promise { + const checks: IntegrationCheck[] = [] + + const reoAddress = issuanceBook.entryExists(entryName) ? issuanceBook.getEntry(entryName)?.address : null + const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null + const controllerAddress = horizonBook.entryExists('Controller') ? horizonBook.getEntry('Controller')?.address : null + + if (!reoAddress || !rmAddress) return checks + + let governor: string | null = null + let pauseGuardian: string | null = null + if (controllerAddress) { + try { + governor = (await client.readContract({ + address: controllerAddress as `0x${string}`, + abi: [ + { + inputs: [], + name: 'getGovernor', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'getGovernor', + })) as string + } catch { + // Controller doesn't have getGovernor + } + try { + pauseGuardian = (await client.readContract({ + address: controllerAddress as `0x${string}`, + abi: [ + { + inputs: [], + name: 'pauseGuardian', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'pauseGuardian', + })) as string + } catch { + // Controller doesn't have pauseGuardian + } + } + + try { + const governorRole = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'GOVERNOR_ROLE', + })) as `0x${string}` + + if (governor) { + const governorHasRole = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'hasRole', + args: [governorRole, governor as `0x${string}`], + })) as boolean + checks.push({ ok: governorHasRole, label: 'governor has GOVERNOR_ROLE' }) + } + } catch { + // Role check not available + } + + try { + const pauseRole = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'PAUSE_ROLE', + })) as `0x${string}` + + if (pauseGuardian) { + const pauseGuardianHasRole = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'hasRole', + args: [pauseRole, pauseGuardian as `0x${string}`], + })) as boolean + checks.push({ ok: pauseGuardianHasRole, label: 'pause guardian has PAUSE_ROLE' }) + } + } catch { + // Role check not available + } + + const networkOperator = issuanceBook.entryExists('NetworkOperator') + ? (issuanceBook.getEntry('NetworkOperator')?.address ?? null) + : null + + try { + const operatorCheck = await checkOperatorRole(client, reoAddress, networkOperator) + const statusOk = networkOperator === null ? false : operatorCheck.ok + checks.push({ ok: statusOk, label: operatorCheck.message }) + } catch { + checks.push({ ok: null, label: 'OPERATOR_ROLE (check failed)' }) + } + + try { + const currentREO = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + const configured = currentREO.toLowerCase() === reoAddress.toLowerCase() + checks.push({ ok: configured, label: 'RM.providerEligibilityOracle == this' }) + } catch { + // Function not available on old RM + } + + try { + const enabled = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityValidation', + })) as boolean + checks.push({ ok: enabled, label: 'eligibility validation enabled' }) + } catch { + // Function not available + } + + try { + const lastUpdate = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getLastOracleUpdateTime', + })) as bigint + const hasUpdates = lastUpdate > 0n + checks.push({ ok: hasUpdates, label: 'oracle has processed updates' }) + } catch { + // Function not available + } + + return checks +} + +export async function getReclaimAddressChecks( + client: PublicClient, + horizonBook: AddressBookOps, + issuanceBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null + const reclaimAddress = issuanceBook.entryExists('ReclaimedRewards') + ? issuanceBook.getEntry('ReclaimedRewards')?.address + : null + + if (!rmAddress || !reclaimAddress) return checks + + try { + const defaultReclaim = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getDefaultReclaimAddress', + })) as string + const configured = defaultReclaim.toLowerCase() === reclaimAddress.toLowerCase() + checks.push({ ok: configured, label: 'configured as RM.defaultReclaimAddress' }) + } catch { + checks.push({ ok: false, label: 'configured as RM.defaultReclaimAddress' }) + } + + return checks +} + +// Minimal ABI for RecurringAgreementManager-specific view functions +const RECURRING_AGREEMENT_MANAGER_ABI = [ + { + inputs: [], + name: 'COLLECTOR_ROLE', + outputs: [{ type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DATA_SERVICE_ROLE', + outputs: [{ type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getCollectorCount', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'paused', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, +] as const + +export async function getRecurringAgreementManagerChecks( + client: PublicClient, + horizonBook: AddressBookOps, + issuanceBook: AddressBookOps, + ssBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + const ramAddress = issuanceBook.entryExists('RecurringAgreementManager') + ? issuanceBook.getEntry('RecurringAgreementManager')?.address + : null + if (!ramAddress) return checks + + // COLLECTOR_ROLE → RecurringCollector + const rcAddress = horizonBook.entryExists('RecurringCollector') + ? horizonBook.getEntry('RecurringCollector')?.address + : null + if (rcAddress) { + try { + const collectorRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: RECURRING_AGREEMENT_MANAGER_ABI, + functionName: 'COLLECTOR_ROLE', + })) as `0x${string}` + const hasRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [collectorRole, rcAddress as `0x${string}`], + })) as boolean + checks.push({ ok: hasRole, label: 'RecurringCollector has COLLECTOR_ROLE' }) + } catch { + // Role check not available + } + } + + // DATA_SERVICE_ROLE → SubgraphService + const ssAddress = ssBook?.entryExists('SubgraphService') ? ssBook.getEntry('SubgraphService')?.address : null + if (ssAddress) { + try { + const dataServiceRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: RECURRING_AGREEMENT_MANAGER_ABI, + functionName: 'DATA_SERVICE_ROLE', + })) as `0x${string}` + const hasRole = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ACCESS_CONTROL_ENUMERABLE_ABI, + functionName: 'hasRole', + args: [dataServiceRole, ssAddress as `0x${string}`], + })) as boolean + checks.push({ ok: hasRole, label: 'SubgraphService has DATA_SERVICE_ROLE' }) + } catch { + // Role check not available + } + } + + // IssuanceAllocator + const iaAddress = issuanceBook.entryExists('IssuanceAllocator') + ? issuanceBook.getEntry('IssuanceAllocator')?.address + : null + try { + const currentIA = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: ISSUANCE_TARGET_ABI, + functionName: 'getIssuanceAllocator', + })) as string + const isSet = currentIA !== ZERO_ADDRESS + const matches = iaAddress ? currentIA.toLowerCase() === iaAddress.toLowerCase() : null + checks.push({ + ok: isSet ? matches : false, + label: isSet + ? `issuanceAllocator: ${formatAddress(currentIA)}${matches === false ? ` (expected ${formatAddress(iaAddress!)})` : ''}` + : 'issuanceAllocator: not set', + }) + } catch { + // Function not available + } + + // Provider eligibility oracle + try { + const reo = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + const reoA = issuanceBook.entryExists('RewardsEligibilityOracleA') + ? issuanceBook.getEntry('RewardsEligibilityOracleA')?.address + : null + const isSet = reo !== ZERO_ADDRESS + const matchesA = reoA ? reo.toLowerCase() === reoA.toLowerCase() : null + checks.push({ + ok: isSet ? matchesA : null, + label: isSet + ? `providerEligibilityOracle: ${reo}${matchesA === false ? ' (not REO-A)' : matchesA ? ' (REO-A)' : ''}` + : 'providerEligibilityOracle: not set', + }) + } catch { + // Function not available + } + + // Paused state + try { + const paused = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: RECURRING_AGREEMENT_MANAGER_ABI, + functionName: 'paused', + })) as boolean + checks.push({ ok: !paused, label: paused ? 'PAUSED' : 'not paused' }) + } catch { + // Function not available + } + + // Collector count + try { + const count = (await client.readContract({ + address: ramAddress as `0x${string}`, + abi: RECURRING_AGREEMENT_MANAGER_ABI, + functionName: 'getCollectorCount', + })) as bigint + checks.push({ ok: null, label: `collectors: ${count}` }) + } catch { + // Function not available + } + + return checks +} + +// ============================================================================ +// Horizon / SubgraphService Contract Checks +// ============================================================================ + +// Minimal ABIs for contracts not in the abis.ts module +const PAUSABLE_ABI = [ + { inputs: [], name: 'paused', outputs: [{ type: 'bool' }], stateMutability: 'view', type: 'function' }, +] as const + +const PAUSE_GUARDIAN_ABI = [ + { + inputs: [{ name: '_pauseGuardian', type: 'address' }], + name: 'pauseGuardians', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, +] as const + +const DISPUTE_MANAGER_ABI = [ + { inputs: [], name: 'arbitrator', outputs: [{ type: 'address' }], stateMutability: 'view', type: 'function' }, + { inputs: [], name: 'getDisputePeriod', outputs: [{ type: 'uint64' }], stateMutability: 'view', type: 'function' }, + { inputs: [], name: 'disputeDeposit', outputs: [{ type: 'uint256' }], stateMutability: 'view', type: 'function' }, + { + inputs: [], + name: 'getFishermanRewardCut', + outputs: [{ type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { inputs: [], name: 'maxSlashingCut', outputs: [{ type: 'uint32' }], stateMutability: 'view', type: 'function' }, + { inputs: [], name: 'subgraphService', outputs: [{ type: 'address' }], stateMutability: 'view', type: 'function' }, +] as const + +const SUBGRAPH_SERVICE_ABI = [ + { + inputs: [], + name: 'getProvisionTokensRange', + outputs: [{ type: 'uint256' }, { type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getDelegationRatio', + outputs: [{ type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'stakeToFeesRatio', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'curationFeesCut', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getDisputeManager', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getGraphTallyCollector', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { inputs: [], name: 'getCuration', outputs: [{ type: 'address' }], stateMutability: 'view', type: 'function' }, +] as const + +/** PPM denominator (1,000,000) for percentage display */ +const PPM = 1_000_000 + +export async function getRecurringCollectorChecks( + client: PublicClient, + address: string, + horizonBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + // Pause guardian + try { + const controllerAddress = horizonBook.entryExists('Controller') ? horizonBook.getEntry('Controller')?.address : null + if (controllerAddress) { + // pauseGuardian is a public storage variable auto-getter, not in IControllerToolshed + const pauseGuardian = (await client.readContract({ + address: controllerAddress as `0x${string}`, + abi: [ + { + inputs: [], + name: 'pauseGuardian', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + ] as const, + functionName: 'pauseGuardian', + })) as string + const isGuardian = (await client.readContract({ + address: address as `0x${string}`, + abi: PAUSE_GUARDIAN_ABI, + functionName: 'pauseGuardians', + args: [pauseGuardian as `0x${string}`], + })) as boolean + checks.push({ ok: isGuardian, label: `pauseGuardian: ${pauseGuardian} ${isGuardian ? '' : '(not set)'}` }) + } + } catch { + // Not available + } + + // Paused state + try { + const paused = (await client.readContract({ + address: address as `0x${string}`, + abi: PAUSABLE_ABI, + functionName: 'paused', + })) as boolean + checks.push({ ok: !paused, label: paused ? 'PAUSED' : 'not paused' }) + } catch { + // paused() not available + } + + // Thawing period + try { + const thawing = (await client.readContract({ + address: address as `0x${string}`, + abi: [ + { + inputs: [], + name: 'REVOKE_AUTHORIZATION_THAWING_PERIOD', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'REVOKE_AUTHORIZATION_THAWING_PERIOD', + })) as bigint + checks.push({ ok: null, label: `REVOKE_AUTHORIZATION_THAWING_PERIOD: ${thawing}` }) + } catch { + // Not available + } + + return checks +} + +export async function getDisputeManagerChecks( + client: PublicClient, + address: string, + horizonBook: AddressBookOps, + ssBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + async function dmRead(functionName: (typeof DISPUTE_MANAGER_ABI)[number]['name']): Promise { + try { + return (await client.readContract({ + address: address as `0x${string}`, + abi: DISPUTE_MANAGER_ABI, + functionName, + })) as T + } catch { + return null + } + } + + // Arbitrator + const arbitrator = await dmRead('arbitrator') + if (arbitrator !== null) { + checks.push({ ok: arbitrator !== ZERO_ADDRESS, label: `arbitrator: ${arbitrator}` }) + } + + // SubgraphService reference + const ss = await dmRead('subgraphService') + if (ss !== null) { + const expected = ssBook?.entryExists('SubgraphService') + ? (ssBook.getEntry('SubgraphService')?.address ?? null) + : null + const matches = expected ? ss.toLowerCase() === expected.toLowerCase() : null + checks.push({ + ok: ss !== ZERO_ADDRESS ? matches : false, + label: `subgraphService: ${ss}${matches === false && expected ? ` (expected ${expected})` : ''}`, + }) + } + + // Dispute period + const disputePeriod = await dmRead('getDisputePeriod') + if (disputePeriod !== null) { + checks.push({ ok: disputePeriod > 0n, label: `disputePeriod: ${disputePeriod}s` }) + } + + // Dispute deposit + const disputeDeposit = await dmRead('disputeDeposit') + if (disputeDeposit !== null) { + checks.push({ ok: disputeDeposit > 0n, label: `disputeDeposit: ${formatGRT(disputeDeposit)}` }) + } + + // Fisherman reward cut (PPM) + const fishermanCut = await dmRead('getFishermanRewardCut') + if (fishermanCut !== null) { + checks.push({ + ok: null, + label: `fishermanRewardCut: ${fishermanCut} (${((fishermanCut / PPM) * 100).toFixed(2)}%)`, + }) + } + + // Max slashing cut (PPM) + const maxSlashing = await dmRead('maxSlashingCut') + if (maxSlashing !== null) { + checks.push({ ok: null, label: `maxSlashingCut: ${maxSlashing} (${((maxSlashing / PPM) * 100).toFixed(2)}%)` }) + } + + return checks +} + +export async function getSubgraphServiceChecks( + client: PublicClient, + address: string, + horizonBook: AddressBookOps, + ssBook: AddressBookOps, +): Promise { + const checks: IntegrationCheck[] = [] + + async function ssRead(functionName: (typeof SUBGRAPH_SERVICE_ABI)[number]['name']): Promise { + try { + return (await client.readContract({ + address: address as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName, + })) as T + } catch { + return null + } + } + + // DisputeManager reference + const dm = await ssRead('getDisputeManager') + if (dm !== null) { + const expected = ssBook?.entryExists('DisputeManager') ? (ssBook.getEntry('DisputeManager')?.address ?? null) : null + const matches = expected ? dm.toLowerCase() === expected.toLowerCase() : null + checks.push({ + ok: dm !== ZERO_ADDRESS ? matches : false, + label: `disputeManager: ${dm}${matches === false && expected ? ` (expected ${expected})` : ''}`, + }) + } + + // GraphTallyCollector reference + const gtc = await ssRead('getGraphTallyCollector') + if (gtc !== null) { + const expected = horizonBook.entryExists('GraphTallyCollector') + ? (horizonBook.getEntry('GraphTallyCollector')?.address ?? null) + : null + const matches = expected ? gtc.toLowerCase() === expected.toLowerCase() : null + checks.push({ + ok: gtc !== ZERO_ADDRESS ? matches : false, + label: `graphTallyCollector: ${gtc}${matches === false && expected ? ` (expected ${expected})` : ''}`, + }) + } + + // Curation reference + const curation = await ssRead('getCuration') + if (curation !== null) { + const expected = horizonBook.entryExists('L2Curation') + ? (horizonBook.getEntry('L2Curation')?.address ?? null) + : null + const matches = expected ? curation.toLowerCase() === expected.toLowerCase() : null + checks.push({ + ok: curation !== ZERO_ADDRESS ? matches : false, + label: `curation: ${curation}${matches === false && expected ? ` (expected ${expected})` : ''}`, + }) + } + + // Provision tokens range + const provisionRange = await ssRead('getProvisionTokensRange') + if (provisionRange !== null) { + checks.push({ + ok: null, + label: `provisionTokensRange: [${formatGRT(provisionRange[0])}, ${formatGRT(provisionRange[1])}]`, + }) + } + + // Delegation ratio + const delegationRatio = await ssRead('getDelegationRatio') + if (delegationRatio !== null) { + checks.push({ ok: null, label: `delegationRatio: ${delegationRatio}` }) + } + + // Stake to fees ratio + const stakeToFees = await ssRead('stakeToFeesRatio') + if (stakeToFees !== null) { + checks.push({ ok: null, label: `stakeToFeesRatio: ${stakeToFees}` }) + } + + // Curation fees cut (PPM) + const curationCut = await ssRead('curationFeesCut') + if (curationCut !== null) { + checks.push({ + ok: null, + label: `curationFeesCut: ${curationCut} (${((Number(curationCut) / PPM) * 100).toFixed(2)}%)`, + }) + } + + return checks +} + +// ============================================================================ +// High-Level Status Display +// ============================================================================ + +/** + * Show detailed status for a single component from the registry. + * + * Displays: status line + proxy admin detail + contract-specific integration checks. + * This is the detail view shown when running `--tags IssuanceAllocator`. + */ +export async function showDetailedComponentStatus( + env: Environment, + contract: RegistryEntry, + options?: { showHints?: boolean }, +): Promise { + const chainId = await getTargetChainIdFromEnv(env) + const client = graph.getPublicClient(env) as PublicClient + + // Resolve address books + const horizonBook = graph.getHorizonAddressBook(chainId) + const addressBook = + contract.addressBook === 'horizon' + ? horizonBook + : contract.addressBook === 'subgraph-service' + ? graph.getSubgraphServiceAddressBook(chainId) + : graph.getIssuanceAddressBook(chainId) + + // Resolve ownership context + const ownershipCtx = await resolveOwnershipContext(client, env, chainId) + + // Get status line with detail + const result = await getContractStatusLine( + client, + contract.addressBook, + addressBook, + contract.name, + undefined, + ownershipCtx, + ) + env.showMessage(` ${result.line}`) + for (const line of formatWarnings(result.warnings)) { + env.showMessage(line) + } + // Show ProxyAdmin detail for OZ v5 transparent proxies (not old Graph proxies, + // which are controller-governed and don't expose owner()) + if (contract.proxyType !== 'graph') { + for (const line of formatProxyAdminDetail(result)) { + env.showMessage(line) + } + } + + // Verification status from address book + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (result.exists && (addressBook as any).entryExists(contract.name)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const entry = (addressBook as any).getEntry(contract.name) + if (entry.proxy) { + const proxyVerified = entry.proxyDeployment?.verified + const implVerified = entry.implementationDeployment?.verified + env.showMessage(` ${proxyVerified ? '✓' : '✗'} proxy verified${proxyVerified ? `: ${proxyVerified}` : ''}`) + env.showMessage(` ${implVerified ? '✓' : '✗'} impl verified${implVerified ? `: ${implVerified}` : ''}`) + } else { + const verified = entry.deployment?.verified + env.showMessage(` ${verified ? '✓' : '✗'} verified${verified ? `: ${verified}` : ''}`) + } + } + + const showHints = options?.showHints !== false + + // Contract-specific integration checks + if (!result.exists) { + if (showHints && contract.componentTag && contract.deployable) { + showLifecycleHints(env, contract, result) + } + return result + } + + const issuanceBook = contract.addressBook === 'issuance' ? addressBook : graph.getIssuanceAddressBook(chainId) + + let checks: IntegrationCheck[] = [] + if (contract.name === 'RewardsManager') { + checks = await getRewardsManagerChecks( + client, + horizonBook, + issuanceBook, + graph.getSubgraphServiceAddressBook(chainId), + ) + } else if (contract.name === 'IssuanceAllocator') { + checks = await getIssuanceAllocatorChecks(client, horizonBook, issuanceBook) + } else if ( + contract.name === 'RewardsEligibilityOracleA' || + contract.name === 'RewardsEligibilityOracleB' || + contract.name === 'RewardsEligibilityOracleMock' + ) { + checks = await getRewardsEligibilityOracleChecks(client, horizonBook, issuanceBook, contract.name) + } else if (contract.name === 'RecurringAgreementManager') { + checks = await getRecurringAgreementManagerChecks( + client, + horizonBook, + issuanceBook, + graph.getSubgraphServiceAddressBook(chainId), + ) + } else if (contract.name === 'ReclaimedRewards') { + checks = await getReclaimAddressChecks(client, horizonBook, issuanceBook) + } else if (contract.name === 'RecurringCollector') { + const addr = horizonBook.entryExists('RecurringCollector') + ? horizonBook.getEntry('RecurringCollector')?.address + : null + if (addr) checks = await getRecurringCollectorChecks(client, addr, horizonBook) + } else if (contract.name === 'DisputeManager') { + const ssBook = graph.getSubgraphServiceAddressBook(chainId) + const addr = ssBook.entryExists('DisputeManager') ? ssBook.getEntry('DisputeManager')?.address : null + if (addr) checks = await getDisputeManagerChecks(client, addr, horizonBook, ssBook) + } else if (contract.name === 'SubgraphService') { + const ssBook = graph.getSubgraphServiceAddressBook(chainId) + const addr = ssBook.entryExists('SubgraphService') ? ssBook.getEntry('SubgraphService')?.address : null + if (addr) checks = await getSubgraphServiceChecks(client, addr, horizonBook, ssBook) + } + + for (const check of checks) { + env.showMessage(formatCheck(check)) + } + + // Lifecycle action hints + if (showHints && contract.componentTag && contract.deployable) { + showLifecycleHints(env, contract, result) + } + + return result +} + +/** + * Show available lifecycle actions and state-based hint for a component. + */ +function showLifecycleHints(env: Environment, contract: RegistryEntry, result: ContractStatusResult): void { + const tag = contract.componentTag! + + // State-based hint + if (!result.exists) { + env.showMessage(`\n → Not deployed. Run with: --tags ${tag},deploy`) + } else if (result.codeChanged && !result.hasPendingImplementation) { + env.showMessage(`\n → Code changed. Run with: --tags ${tag},deploy`) + } else if (result.hasPendingImplementation) { + env.showMessage(`\n → Pending implementation. Run with: --tags ${tag},upgrade`) + } else { + env.showMessage(`\n → Up to date`) + } + + // Available actions — use explicit list if provided, otherwise derive from metadata + let actions: readonly string[] + if (contract.lifecycleActions) { + actions = contract.lifecycleActions + } else { + const derived: string[] = ['deploy'] + if (contract.proxyType) derived.push('upgrade') + actions = derived + } + env.showMessage(` Actions: --tags ${tag},<${[...actions, 'all'].join('|')}>`) +} + +/** + * Show pending governance TX count with execute command if any exist. + * Call once at the end of a status display, not per-component. + */ +export function showPendingGovernanceTxs(env: Environment): void { + const count = countPendingGovernanceTxs(env.name) + if (count > 0) { + env.showMessage(`\n ⚠ ${count} pending governance TX(s)`) + env.showMessage(` Run: npx hardhat deploy:execute-governance --network ${env.name}`) + } +} diff --git a/packages/deployment/lib/sync-utils.ts b/packages/deployment/lib/sync-utils.ts index 4680158e4..a67574bad 100644 --- a/packages/deployment/lib/sync-utils.ts +++ b/packages/deployment/lib/sync-utils.ts @@ -1,8 +1,21 @@ +import { existsSync } from 'node:fs' + import type { Artifact, Environment } from '@rocketh/core/types' import type { DeploymentMetadata } from '@graphprotocol/toolshed/deployments' import { + autoDetectForkNetwork, + getForkNetwork, + getForkStateDir, + getForkTargetChainId, + getIssuanceAddressBookPath, + getTargetChainIdFromEnv, + isForkMode, +} from './address-book-utils.js' +import { + getLibraryResolver, loadContractsArtifact, + loadHorizonBuildArtifact, loadIssuanceArtifact, loadOpenZeppelinArtifact, loadSubgraphServiceArtifact, @@ -12,9 +25,12 @@ import { type AddressBookType, type ArtifactSource, type ContractMetadata, + type RegistryEntry, getAddressBookEntryName, getContractMetadata, + getContractsByAddressBook, } from './contract-registry.js' +import { SpecialTags } from './deployment-tags.js' import { getOnChainImplementation } from './deploy-implementation.js' import { graph } from '../rocketh/deploy.js' import type { AnyAddressBookOps } from './address-book-ops.js' @@ -22,11 +38,11 @@ import type { AnyAddressBookOps } from './address-book-ops.js' /** * Format an address based on SHOW_ADDRESSES environment variable * - 0: return empty string (no addresses shown) - * - 1: return truncated address (0x1234567890...) + * - 1: return truncated address (0x1234...5678) * - 2 (default): return full address */ function formatAddress(address: string): string { - const showAddresses = process.env.SHOW_ADDRESSES ?? '1' + const showAddresses = process.env.SHOW_ADDRESSES ?? '2' if (showAddresses === '0') { return '' @@ -46,6 +62,8 @@ function loadArtifactFromSource(source: ArtifactSource): Artifact | undefined { switch (source.type) { case 'contracts': return loadContractsArtifact(source.path, source.name) + case 'horizon': + return loadHorizonBuildArtifact(source.path) case 'subgraph-service': return loadSubgraphServiceArtifact(source.name) case 'issuance': @@ -111,7 +129,12 @@ export function checkShouldSync( if (metadata?.bytecodeHash && artifact) { const loadedArtifact = loadArtifactFromSource(artifact) if (loadedArtifact?.deployedBytecode) { - const localHash = computeBytecodeHash(loadedArtifact.deployedBytecode) + const libResolver = getLibraryResolver(artifact.type) + const localHash = computeBytecodeHash( + loadedArtifact.deployedBytecode, + loadedArtifact.deployedLinkReferences, + libResolver, + ) if (metadata.bytecodeHash !== localHash) { return { shouldSync: false, @@ -170,7 +193,12 @@ export function reconstructDeploymentRecord( } if (deploymentMetadata.bytecodeHash && loadedArtifact.deployedBytecode) { - const localHash = computeBytecodeHash(loadedArtifact.deployedBytecode) + const libResolver = getLibraryResolver(artifact.type) + const localHash = computeBytecodeHash( + loadedArtifact.deployedBytecode, + loadedArtifact.deployedLinkReferences, + libResolver, + ) if (deploymentMetadata.bytecodeHash !== localHash) { // Bytecode has changed - cannot reconstruct reliably return undefined @@ -215,6 +243,45 @@ export function createDeploymentMetadata( } } +/** + * Check if local artifact bytecode differs from what was last deployed. + * + * Compares the local artifact's bytecodeHash against the stored hash in the + * address book. The stored hash is recorded from the local artifact at deploy + * time, so this is a local-to-local comparison (no on-chain bytecode fetch). + * + * @returns codeChanged flag and the computed localHash (needed for hashMatches checks) + */ +function checkCodeChanged( + artifactSource: ArtifactSource | undefined, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + addressBook: any, + contractName: string, +): { codeChanged: boolean; localHash?: string } { + if (!artifactSource) return { codeChanged: false } + + const localArtifact = loadArtifactFromSource(artifactSource) + const resolver = getLibraryResolver(artifactSource.type) + const localHash = localArtifact?.deployedBytecode + ? computeBytecodeHash(localArtifact.deployedBytecode, localArtifact.deployedLinkReferences, resolver) + : undefined + + const deploymentMetadata = addressBook.getDeploymentMetadata(contractName) + if (deploymentMetadata?.bytecodeHash && localHash) { + return { codeChanged: localHash !== deploymentMetadata.bytecodeHash, localHash } + } + if (localArtifact?.deployedBytecode) { + // No stored bytecodeHash but artifact exists - untracked/legacy state + return { codeChanged: true, localHash } + } + return { codeChanged: false, localHash } +} + +/** + * Proxy admin ownership state + */ +export type ProxyAdminOwner = 'governor' | 'deployer' | 'other' | 'unknown' + /** * Input for proxy status line generation */ @@ -233,6 +300,8 @@ interface ProxyStatusInput { syncNotes?: string[] /** Whether local bytecode differs from deployed (shows △ icon) */ codeChanged?: boolean + /** ProxyAdmin ownership state — 'deployer' shows 🔑 warning icon */ + proxyAdminOwner?: ProxyAdminOwner } /** @@ -270,9 +339,13 @@ function formatProxyStatusLine(input: ProxyStatusInput): ProxyStatusResult { notes.push('code changed') } + // ProxyAdmin ownership warning: 🔑 when known to be non-governor (deployer or other) + const adminIcon = + input.proxyAdminOwner && input.proxyAdminOwner !== 'governor' && input.proxyAdminOwner !== 'unknown' ? ' 🔑' : '' + // Format the line const suffix = notes.length > 0 ? ` (${notes.join(', ')})` : '' - const line = `${codeIcon} ${statusIcon} ${input.name} @ ${formatAddress(input.proxyAddress)} → ${formatAddress(input.implAddress)}${suffix}` + const line = `${codeIcon} ${statusIcon} ${input.name} @ ${formatAddress(input.proxyAddress)} → ${formatAddress(input.implAddress)}${suffix}${adminIcon}` return { line } } @@ -293,6 +366,9 @@ export interface ContractSpec { artifact?: ArtifactSource /** If true, address-only placeholder (code not required) */ addressOnly?: boolean + /** ABI-encoded constructor args from address book deployment metadata. + * Used to seed rocketh records with real argsData instead of '0x'. */ + deploymentArgsData?: string /** Proxy sync fields (if present, will sync implementation with on-chain) */ proxy?: { proxyAdminAddress: string @@ -342,6 +418,17 @@ export function buildContractSpec( throw new Error(`${addressBookEntryName} not found in address book for chainId ${targetChainId}`) } + // Get deployment argsData from address book for accurate rocketh record seeding + let deploymentArgsData: string | undefined + if (entry) { + const deploymentMeta = entry.proxy + ? entry.implementationDeployment + : entry.deployment + if (deploymentMeta?.argsData && deploymentMeta.argsData !== '0x') { + deploymentArgsData = deploymentMeta.argsData + } + } + const spec: ContractSpec = { name: contractName, addressBookType, @@ -349,6 +436,7 @@ export function buildContractSpec( prerequisite: metadata.prerequisite ?? false, artifact: metadata.artifact, addressOnly: metadata.addressOnly, + deploymentArgsData, } // Add proxy configuration if this is a proxied contract @@ -395,7 +483,7 @@ export interface SyncResult { /** * Sync a single contract - returns status and whether it succeeded */ -async function syncContract( +export async function syncContract( env: Environment, // eslint-disable-next-line @typescript-eslint/no-explicit-any client: any, @@ -463,20 +551,13 @@ async function syncContract( // Get updated entry for formatProxyStatusLine const updatedEntry = spec.proxy.addressBook.getEntry(spec.name) - // Check if local bytecode differs from deployed (via bytecodeHash) - // If artifact exists but no bytecodeHash stored, assume code changed (untracked state) - let codeChanged = false - if (spec.proxy.artifact) { - const deploymentMetadata = spec.proxy.addressBook.getDeploymentMetadata(spec.name) - const localArtifact = loadArtifactFromSource(spec.proxy.artifact) - if (deploymentMetadata?.bytecodeHash && localArtifact?.deployedBytecode) { - const localHash = computeBytecodeHash(localArtifact.deployedBytecode) - codeChanged = localHash !== deploymentMetadata.bytecodeHash - } else if (localArtifact?.deployedBytecode) { - // No stored bytecodeHash but artifact exists - untracked/legacy state - codeChanged = true - } - } + const pendingImpl = updatedEntry.pendingImplementation + const implAddress = pendingImpl?.address ?? updatedEntry.implementation + const implDeployment = pendingImpl + ? pendingImpl.deployment + : spec.proxy.addressBook.getDeploymentMetadata(spec.name) + + const { codeChanged, localHash } = checkCodeChanged(spec.proxy.artifact, spec.proxy.addressBook, spec.name) const result = formatProxyStatusLine({ name: spec.name, @@ -507,32 +588,25 @@ async function syncContract( if (!existing) { // No existing record - create from artifact + // IMPORTANT: For proxy contracts, we only load the ABI, not bytecode + // The artifact is for the implementation, not the proxy itself let abi: readonly unknown[] = [] - let bytecode: `0x${string}` = '0x' - let deployedBytecode: `0x${string}` | undefined if (spec.artifact) { const artifact = loadArtifactFromSource(spec.artifact) if (artifact?.abi) { abi = artifact.abi } - if (artifact?.bytecode) { - bytecode = artifact.bytecode as `0x${string}` - } - if (artifact?.deployedBytecode) { - deployedBytecode = artifact.deployedBytecode as `0x${string}` - } } await env.save(spec.name, { address: spec.address as `0x${string}`, abi: abi as typeof abi & readonly unknown[], - bytecode, - deployedBytecode, + bytecode: '0x' as `0x${string}`, // Don't store impl bytecode for proxy record + deployedBytecode: undefined, argsData: '0x' as `0x${string}`, metadata: '', } as unknown as Parameters[1]) } else if (addressChanged) { - // Address changed - update address but preserve existing bytecode - // This handles the case where address book points to new address + // Address changed - update address and clear bytecode (proxy address changed) let abi: readonly unknown[] = existing.abi as readonly unknown[] // Update ABI from artifact if available (ABI doesn't affect change detection) if (spec.artifact) { @@ -544,10 +618,10 @@ async function syncContract( await env.save(spec.name, { address: spec.address as `0x${string}`, abi: abi as typeof abi & readonly unknown[], - bytecode: existing.bytecode as `0x${string}`, - deployedBytecode: existing.deployedBytecode as `0x${string}`, - argsData: existing.argsData as `0x${string}`, - metadata: existing.metadata ?? '', + bytecode: '0x' as `0x${string}`, // Clear bytecode - proxy changed + deployedBytecode: undefined, + argsData: '0x' as `0x${string}`, + metadata: '', } as unknown as Parameters[1]) } // else: existing record with same address - do nothing, preserve rocketh's state @@ -625,42 +699,52 @@ async function syncContract( } as unknown as Parameters[1]) } - // Save implementation deployment record - // Pick pending or current - both have same structure (address + deployment metadata) - const pendingImpl = updatedEntry.pendingImplementation - const implAddress = pendingImpl?.address ?? updatedEntry.implementation - const implDeployment = pendingImpl - ? pendingImpl.deployment - : spec.proxy.addressBook.getDeploymentMetadata(spec.name) - + // Save implementation deployment record (if local hash matches stored) if (implAddress) { const storedHash = implDeployment?.bytecodeHash - - // Only sync if stored hash matches local artifact let hashMatches = false - if (storedHash && spec.proxy.artifact) { - const localArtifact = loadArtifactFromSource(spec.proxy.artifact) - if (localArtifact?.deployedBytecode) { - const localHash = computeBytecodeHash(localArtifact.deployedBytecode) - if (storedHash === localHash) { - hashMatches = true - } else { - syncNotes.push('impl outdated') - } - } + + if (storedHash && localHash) { + hashMatches = storedHash === localHash } + // When hash doesn't match, leave the existing rocketh record untouched. + // The old record (with real bytecode from the previous deploy) lets rocketh + // correctly detect the bytecode change and trigger a fresh deployment. + // NOTE: Do NOT clear the record to bytecode '0x' — rocketh's CBOR-stripping + // comparison treats '0x' as NaN length, causing slice(0, NaN) → '' for both + // old and new bytecodes, making them falsely compare as equal. + if (hashMatches) { const implResult = await syncContract(env, client, { name: `${spec.name}_Implementation`, addressBookType: spec.addressBookType, address: implAddress, prerequisite: true, + artifact: spec.proxy.artifact, }) if (!implResult.success) { return implResult } + // Patch implementation record with deployment metadata for accurate + // rocketh comparison. syncContract creates bare records without argsData, + // but rocketh's deploy() compares argsData to decide if redeployment is + // needed. Without the real argsData, rocketh falsely detects a change + // and redeploys implementations that haven't changed. + const implRecordName = `${spec.name}_Implementation` + const implRecord = env.getOrNull(implRecordName) + if (implRecord && implDeployment?.argsData && (!implRecord.argsData || implRecord.argsData === '0x')) { + await env.save(implRecordName, { + address: implRecord.address as `0x${string}`, + abi: implRecord.abi as typeof implRecord.abi & readonly unknown[], + bytecode: (implRecord.bytecode ?? '0x') as `0x${string}`, + deployedBytecode: implRecord.deployedBytecode as `0x${string}` | undefined, + argsData: implDeployment.argsData as `0x${string}`, + metadata: (implRecord as Record).metadata ?? '', + } as unknown as Parameters[1]) + } + // Backfill address book metadata from rocketh if rocketh is newer const rockethImpl = env.getOrNull(`${spec.name}_Implementation`) if (rockethImpl?.argsData && rockethImpl.argsData !== '0x') { @@ -764,7 +848,7 @@ async function syncContract( abi: abi as typeof abi & readonly unknown[], bytecode, deployedBytecode, - argsData: '0x' as `0x${string}`, + argsData: (spec.deploymentArgsData ?? '0x') as `0x${string}`, metadata: '', } as unknown as Parameters[1]) } else if (addressChanged) { @@ -787,11 +871,99 @@ async function syncContract( } // else: existing record with same address - do nothing, preserve rocketh's state + // Backfill deployment metadata from rocketh → address book (mirrors proxy backfill) + // Only for real registry entries — skip synthetic names (e.g. HorizonStaking_Implementation) + // created by proxy sync as rocketh-only records + const registryMetadata = getContractMetadata(spec.addressBookType, spec.name) + const rockethRecord = env.getOrNull(spec.name) + if (registryMetadata && rockethRecord?.argsData && rockethRecord.argsData !== '0x') { + const chainId = await getTargetChainIdFromEnv(env) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const addressBook: any = getAddressBookForType(spec.addressBookType, chainId) + const entry = addressBook.getEntry(spec.name) + const rockethBlockNumber = rockethRecord.receipt?.blockNumber + ? parseInt(rockethRecord.receipt.blockNumber as string) + : undefined + const addressBookBlockNumber = entry.deployment?.blockNumber + + const rockethIsNewer = + !entry.deployment?.argsData || + (rockethBlockNumber !== undefined && addressBookBlockNumber === undefined) || + (rockethBlockNumber !== undefined && + addressBookBlockNumber !== undefined && + rockethBlockNumber > addressBookBlockNumber) + + if (rockethIsNewer) { + const deploymentMetadata: DeploymentMetadata = { + txHash: rockethRecord.transaction?.hash ?? '', + argsData: rockethRecord.argsData, + bytecodeHash: rockethRecord.deployedBytecode ? computeBytecodeHash(rockethRecord.deployedBytecode) : '', + ...(rockethBlockNumber !== undefined && { blockNumber: rockethBlockNumber }), + } + addressBook.setDeploymentMetadata(spec.name, deploymentMetadata) + statusNotes.push('backfilled metadata') + } + } + // Format status line for non-proxy contracts (two-column format with blank status icon position) const statusSuffix = statusNotes.length > 0 ? ` (${statusNotes.join(', ')})` : '' return { success: true, status: `✓ ${nonProxySyncIcon} ${spec.name} @ ${formatAddress(spec.address)}${statusSuffix}` } } +/** + * Options for sync display filtering + */ +export interface SyncOptions { + /** + * Tags requested in the deploy command (e.g., ['IssuanceAllocator:deploy', 'sync']). + * When set, only contracts matching these tags or with detected changes are displayed. + * Sync still runs for all contracts regardless of filter. + */ + tagFilter?: string[] +} + +/** + * Extract component names from deployment tags. + * + * Strips action suffixes (e.g., 'IssuanceAllocator:deploy' → 'IssuanceAllocator') + * and filters out the special 'sync' tag. + */ +function extractComponentNames(tags: string[]): Set { + const components = new Set() + for (const tag of tags) { + if (tag === SpecialTags.SYNC) continue + components.add(tag.split(':')[0]) + } + return components +} + +/** + * Check whether a sync status line indicates changes were detected. + * + * Icons: ↑ upgraded, ↻ synced/re-imported, ◷ pending, △ code changed + * Parenthetical notes also indicate notable state (but not "(not deployed)"). + */ +function statusHasChanges(status: string): boolean { + if (/[↑↻◷△]/.test(status)) return true + if (status.includes('(') && !status.includes('(not deployed)')) return true + return false +} + +/** + * Determine whether a contract's sync result should be displayed. + */ +function shouldDisplay( + spec: ContractSpec, + result: { success: boolean; status: string }, + filterComponents: Set | null, +): boolean { + if (!filterComponents) return true + if (!result.success) return true + if (statusHasChanges(result.status)) return true + const metadata = getContractMetadata(spec.addressBookType, spec.name) + return !!metadata?.componentTag && filterComponents.has(metadata.componentTag) +} + /** * Sync contract groups with on-chain state * @@ -800,34 +972,248 @@ async function syncContract( * - Import contract addresses into rocketh deployment records * - Validate prerequisites exist on-chain * - Show code changed indicator (△) when local bytecode differs from deployed + * + * When options.tagFilter is set, only contracts matching the requested tags + * or with detected changes are displayed. Sync still runs for all contracts. */ -export async function syncContractGroups(env: Environment, groups: AddressBookGroup[]): Promise { +export async function syncContractGroups( + env: Environment, + groups: AddressBookGroup[], + options?: SyncOptions, +): Promise { const client = graph.getPublicClient(env) const failures: string[] = [] let totalSynced = 0 + // Build component filter from tags (null = no filtering) + const filterComponents = + options?.tagFilter && options.tagFilter.length > 0 ? extractComponentNames(options.tagFilter) : null + const isFiltering = filterComponents !== null && filterComponents.size > 0 + let totalSuppressed = 0 + for (const group of groups) { - env.showMessage(`\n📦 ${group.label}`) + // Buffer results so we can filter display without affecting sync + const results: Array<{ spec: ContractSpec; result: { success: boolean; status: string } }> = [] for (const spec of group.contracts) { const result = await syncContract(env, client, spec) + results.push({ spec, result }) - env.showMessage(` ${result.status}`) if (!result.success) { failures.push(spec.name) } else { totalSynced++ - // For proxies, syncContract also syncs the implementation internally if (spec.proxy) { - totalSynced++ // Count the implementation sync + totalSynced++ } } } + + // Filter which results to display + const visible = isFiltering + ? results.filter(({ spec, result }) => shouldDisplay(spec, result, filterComponents)) + : results + const suppressed = results.length - visible.length + totalSuppressed += suppressed + + if (visible.length > 0) { + env.showMessage(`\n📦 ${group.label}`) + for (const { result } of visible) { + env.showMessage(` ${result.status}`) + } + if (suppressed > 0) { + env.showMessage(` ... ${suppressed} unchanged`) + } + } + } + + if (isFiltering && totalSuppressed > 0) { + env.showMessage(`\n ... ${totalSuppressed} unchanged contracts hidden (--tags sync for full output)`) } return { success: failures.length === 0, totalSynced, failures } } +/** + * Resolve address book instance for a given address book type and chain ID + */ +function getAddressBookForType(addressBookType: AddressBookType, chainId: number) { + switch (addressBookType) { + case 'horizon': + return graph.getHorizonAddressBook(chainId) + case 'subgraph-service': + return graph.getSubgraphServiceAddressBook(chainId) + case 'issuance': + return graph.getIssuanceAddressBook(chainId) + } +} + +/** + * Sync a single component from the contract registry with on-chain state. + * + * Resolves the address book, builds a ContractSpec, and runs the same sync + * logic as the full sync script — reading on-chain state to confirm and + * propagate reality into address books and rocketh records. + * + * Components call this immediately before and after mutating actions so the + * action operates on a confirmed-fresh view, without requiring a separate + * global sync to have run first. + */ +export async function syncComponentFromRegistry(env: Environment, contract: RegistryEntry): Promise { + const chainId = await getTargetChainIdFromEnv(env) + const addressBook = getAddressBookForType(contract.addressBook, chainId) + const metadata = getContractMetadata(contract.addressBook, contract.name) + if (!metadata) { + throw new Error(`Contract '${contract.name}' not found in ${contract.addressBook} registry`) + } + + const spec = buildContractSpec(contract.addressBook, contract.name, metadata, addressBook, chainId) + const client = graph.getPublicClient(env) + const result = await syncContract(env, client, spec) + + env.showMessage(` ${result.status}`) + if (!result.success) { + throw new Error(`Sync failed for ${contract.name}: ${result.status}`) + } +} + +/** + * Sync multiple components from the contract registry with on-chain state. + * + * Convenience wrapper around `syncComponentFromRegistry` for scripts that need + * a small set of contracts in sync before they read them — typically the + * contract being acted on plus its direct on-chain prerequisites (Controller, + * shared implementations, etc.). + */ +export async function syncComponentsFromRegistry(env: Environment, contracts: RegistryEntry[]): Promise { + for (const contract of contracts) { + await syncComponentFromRegistry(env, contract) + } +} + +/** + * Run the full address book sync across every deployable contract in every + * address book (Horizon, SubgraphService, Issuance). + * + * This is the implementation behind both the `00_sync.ts` deploy script (run + * via `--tags sync`) and the `deploy:sync` Hardhat task. Orchestration scripts + * that need many contracts in sync before they run (e.g. the GIP-0088 upgrade + * batch builder) call this directly instead of relying on a tag dependency. + * + * On failure, exits the process with code 1 after printing remediation hints. + */ +export async function runFullSync(env: Environment): Promise { + // Get chainId from provider (will be 31337 in fork mode) + const chainIdHex = await env.network.provider.request({ method: 'eth_chainId' }) + const providerChainId = Number(chainIdHex) + + // Auto-detect fork network from anvil if not explicitly set + if (providerChainId === 31337 && !getForkNetwork(env.name)) { + const detected = await autoDetectForkNetwork() + if (detected) { + env.showMessage(`\n🔍 Auto-detected fork network: ${detected}`) + } + } + + // Determine target chain ID for address book lookups + const forkNetwork = getForkNetwork(env.name) + const isForking = isForkMode(env.name) + const forkChainId = getForkTargetChainId(env.name) + const targetChainId = forkChainId ?? providerChainId + + // Check for common misconfiguration: localhost without FORK_NETWORK and not a detectable fork + if (providerChainId === 31337 && !forkNetwork) { + throw new Error( + `Running on localhost (chainId 31337) without FORK_NETWORK set.\n\n` + + `If you're testing against a forked network, set the environment variable:\n` + + ` export FORK_NETWORK=arbitrumSepolia\n` + + ` npx hardhat deploy:sync --network localhost\n\n` + + `Or use ephemeral fork mode:\n` + + ` HARDHAT_FORK=arbitrumSepolia npx hardhat deploy:sync`, + ) + } + + if (forkNetwork) { + const forkStateDir = getForkStateDir(env.name, forkNetwork) + env.showMessage(`\n🔄 Sync: ${forkNetwork} fork (chainId: ${targetChainId})`) + env.showMessage(` Using fork-local address books (${forkStateDir}/)`) + } else { + env.showMessage(`\n🔄 Sync: ${env.name} (chainId: ${providerChainId})`) + } + + // Get address books (automatically uses fork-local copies in fork mode) + const horizonAddressBook = graph.getHorizonAddressBook(targetChainId) + const ssAddressBook = graph.getSubgraphServiceAddressBook(targetChainId) + + const groups: AddressBookGroup[] = [] + + // --- Horizon contracts --- + const horizonContracts: ContractSpec[] = getDeployableContracts('horizon').map((name) => { + const metadata = getContractMetadata('horizon', name) + if (!metadata) throw new Error(`Contract ${name} not found in horizon registry`) + return buildContractSpec('horizon', name, metadata, horizonAddressBook, targetChainId) + }) + groups.push({ label: 'Horizon', contracts: horizonContracts, addressBook: horizonAddressBook }) + + // --- SubgraphService contracts --- + const ssContracts: ContractSpec[] = getDeployableContracts('subgraph-service').map((name) => { + const metadata = getContractMetadata('subgraph-service', name) + if (!metadata) throw new Error(`Contract ${name} not found in subgraph-service registry`) + return buildContractSpec('subgraph-service', name, metadata, ssAddressBook, targetChainId) + }) + groups.push({ label: 'SubgraphService', contracts: ssContracts, addressBook: ssAddressBook }) + + // --- Issuance contracts --- + const issuanceBookPath = getIssuanceAddressBookPath() + const issuanceAddressBook = existsSync(issuanceBookPath) ? graph.getIssuanceAddressBook(targetChainId) : null + + if (issuanceAddressBook) { + const issuanceContracts: ContractSpec[] = getDeployableContracts('issuance').map((name) => { + const metadata = getContractMetadata('issuance', name) + if (!metadata) throw new Error(`Contract ${name} not found in issuance registry`) + return buildContractSpec('issuance', name, metadata, issuanceAddressBook, targetChainId) + }) + if (issuanceContracts.length > 0) { + groups.push({ label: 'Issuance', contracts: issuanceContracts, addressBook: issuanceAddressBook }) + } + } + + // Parse --tags from process.argv to filter sync display when invoked via + // `hardhat deploy --tags ...` (does nothing for the standalone deploy:sync task) + const tagsIndex = process.argv.indexOf('--tags') + const requestedTags = + tagsIndex !== -1 && tagsIndex < process.argv.length - 1 ? process.argv[tagsIndex + 1].split(',') : [] + + const syncOptions: SyncOptions = requestedTags.length > 0 ? { tagFilter: requestedTags } : {} + + const result = await syncContractGroups(env, groups, syncOptions) + + if (!result.success) { + env.showMessage(`\n❌ Sync failed: address book does not match chain state.\n`) + env.showMessage(`The following contracts are in address book but have no code on-chain:`) + env.showMessage(` ${result.failures.join(', ')}\n`) + if (isForking) { + env.showMessage(`This is likely because the fork was restarted.\n`) + env.showMessage(`To fix, reset fork state and re-run:`) + env.showMessage(` npx hardhat deploy:reset-fork --network localhost`) + } else { + env.showMessage(`Possible causes:`) + env.showMessage(` 1. Address book has incorrect addresses for this network`) + env.showMessage(` 2. Running against wrong network`) + } + process.exit(1) + } + + env.showMessage(`\n✅ Sync complete: ${result.totalSynced} contracts synced\n`) +} + +/** Filter deployable contracts from a registry namespace. */ +function getDeployableContracts(addressBook: AddressBookType): string[] { + return getContractsByAddressBook(addressBook) + .filter(([_, metadata]) => metadata.deployable !== false) + .map(([name]) => name) +} + /** * Contract status result (read-only, no sync operations) */ @@ -838,6 +1224,64 @@ export interface ContractStatusResult { exists: boolean /** Optional warnings (e.g., address book stale) */ warnings?: string[] + /** Proxy admin ownership state (only for proxied contracts) */ + proxyAdminOwner?: ProxyAdminOwner + /** Proxy admin address (only for proxied contracts) */ + proxyAdminAddress?: string + /** Proxy admin owner address (only for proxied contracts with on-chain query) */ + proxyAdminOwnerAddress?: string + /** Whether local compiled bytecode differs from deployed bytecode */ + codeChanged?: boolean + /** Whether a pending implementation upgrade exists */ + hasPendingImplementation?: boolean +} + +/** + * Options for querying proxy admin ownership during status checks + */ +export interface ProxyAdminOwnershipContext { + /** Governor address (from Controller) — required */ + governor: string + /** Deployer address (from named accounts) — optional, used for labelling */ + deployer?: string +} + +/** + * Query ProxyAdmin ownership and classify as governor/deployer/unknown + * + * The 🔑 warning icon is shown for anything NOT governor-owned. + * Deployer detection is best-effort (only when deployer address is known). + */ +async function queryProxyAdminOwnership( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + client: any, + proxyAdminAddress: string, + ctx: ProxyAdminOwnershipContext, +): Promise<{ owner: ProxyAdminOwner; ownerAddress: string }> { + try { + const ownerAddress = (await client.readContract({ + address: proxyAdminAddress as `0x${string}`, + abi: [ + { + inputs: [], + name: 'owner', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'owner', + })) as string + + if (ownerAddress.toLowerCase() === ctx.governor.toLowerCase()) { + return { owner: 'governor', ownerAddress } + } else if (ctx.deployer && ownerAddress.toLowerCase() === ctx.deployer.toLowerCase()) { + return { owner: 'deployer', ownerAddress } + } + return { owner: 'other', ownerAddress } + } catch { + return { owner: 'unknown', ownerAddress: '' } + } } /** @@ -845,12 +1289,14 @@ export interface ContractStatusResult { * * Returns a formatted status line similar to sync output: * - ✓ = ok, △ = code changed, ◷ = pending upgrade, ○ = not deployed, ❌ = error + * - 🔑 = ProxyAdmin still owned by deployer (not yet transferred to governor) * * @param client - Viem public client * @param addressBookType - Which address book this contract belongs to * @param addressBook - Address book instance * @param contractName - Name of the contract in the registry * @param metadata - Contract metadata from registry (optional, will look up if not provided) + * @param ownershipCtx - Governor/deployer context for proxy admin ownership checks */ export async function getContractStatusLine( // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -860,6 +1306,7 @@ export async function getContractStatusLine( addressBook: any, contractName: string, metadata?: ContractMetadata, + ownershipCtx?: ProxyAdminOwnershipContext, ): Promise { const meta = metadata ?? getContractMetadata(addressBookType, contractName) const entryName = getAddressBookEntryName(addressBookType, contractName) @@ -875,6 +1322,17 @@ export async function getContractStatusLine( return { line: `✓ ${contractName} @ ${formatAddress(entry.address)}`, exists: true } } + // If no client available, show address book status without on-chain verification + if (!client) { + if (meta?.proxyType && entry.implementation) { + return { + line: `? ${contractName} @ ${formatAddress(entry.address)} → ${formatAddress(entry.implementation)} (no on-chain check)`, + exists: true, + } + } + return { line: `? ${contractName} @ ${formatAddress(entry.address)} (no on-chain check)`, exists: true } + } + // Check if code exists on-chain const code = await client.getCode({ address: entry.address as `0x${string}` }) if (!code || code === '0x') { @@ -904,27 +1362,33 @@ export async function getContractStatusLine( } if (actualImpl) { - // Check if local bytecode differs from deployed (via bytecodeHash) - // If artifact exists but no bytecodeHash stored, assume code changed (untracked state) - let codeChanged = false - if (meta.artifact) { - const deploymentMetadata = addressBook.getDeploymentMetadata(contractName) - const localArtifact = loadArtifactFromSource(meta.artifact) - if (deploymentMetadata?.bytecodeHash && localArtifact?.deployedBytecode) { - const localHash = computeBytecodeHash(localArtifact.deployedBytecode) - codeChanged = localHash !== deploymentMetadata.bytecodeHash - } else if (localArtifact?.deployedBytecode) { - // No stored bytecodeHash but artifact exists - untracked/legacy state - codeChanged = true + // Check code changes: own artifact first, then shared implementation's artifact + let { codeChanged } = checkCodeChanged(meta.artifact, addressBook, entryName) + if (!codeChanged && meta.sharedImplementation) { + const sharedMeta = getContractMetadata(addressBookType, meta.sharedImplementation) + if (sharedMeta?.artifact) { + const sharedCheck = checkCodeChanged(sharedMeta.artifact, addressBook, meta.sharedImplementation) + codeChanged = sharedCheck.codeChanged } } + // Query proxy admin ownership for OZ v5 transparent proxies only + // (old Graph proxies are controller-governed, owner() doesn't exist) + let proxyAdminOwner: ProxyAdminOwner | undefined + let proxyAdminOwnerAddress: string | undefined + if (ownershipCtx && proxyAdminAddress && meta.proxyType !== 'graph') { + const ownership = await queryProxyAdminOwnership(client, proxyAdminAddress, ownershipCtx) + proxyAdminOwner = ownership.owner + proxyAdminOwnerAddress = ownership.ownerAddress + } + const result = formatProxyStatusLine({ name: contractName, proxyAddress: entry.address, implAddress: actualImpl, pendingAddress: entry.pendingImplementation?.address, codeChanged, + proxyAdminOwner, }) // Check if address book is stale (on-chain impl differs from recorded impl) @@ -934,13 +1398,65 @@ export async function getContractStatusLine( warnings.push(`address book stale: recorded impl ${formatAddress(bookImpl)}`) } - return { line: result.line, exists: true, warnings: warnings.length > 0 ? warnings : undefined } + return { + line: result.line, + exists: true, + warnings: warnings.length > 0 ? warnings : undefined, + proxyAdminOwner, + proxyAdminAddress, + proxyAdminOwnerAddress, + codeChanged, + hasPendingImplementation: !!entry.pendingImplementation?.address, + } } } - // Non-proxy contract - use two-column format with blank status icon - return { line: `✓ ${contractName} @ ${formatAddress(entry.address)}`, exists: true } - } catch { - return { line: `⚠ ${contractName}: error reading`, exists: false } + // Non-proxy contract — check for code changes against stored bytecodeHash + const { codeChanged } = meta?.artifact ? checkCodeChanged(meta.artifact, addressBook, entryName) : { codeChanged: false } + const icon = codeChanged ? '△' : '✓' + return { line: `${icon} ${contractName} @ ${formatAddress(entry.address)}`, exists: true, codeChanged } + } catch (e) { + const errMsg = e instanceof Error ? e.message.split('\n')[0].slice(0, 120) : String(e).slice(0, 120) + return { line: `⚠ ${contractName}: error reading (${errMsg})`, exists: false } } } + +/** + * Check if any deployable proxy across all address books has a pending + * implementation or local code that differs from the deployed version. + * + * Used by status scripts for next-step guidance without duplicating + * address book scanning logic. + */ +export function checkAllProxyStates(targetChainId: number): { anyCodeChanged: boolean; anyPending: boolean } { + const addressBookTypes: AddressBookType[] = ['horizon', 'subgraph-service', 'issuance'] + let anyCodeChanged = false + let anyPending = false + + for (const abType of addressBookTypes) { + const ab: AnyAddressBookOps = getAddressBookForType(abType, targetChainId) + + for (const [name, meta] of getContractsByAddressBook(abType)) { + if (!meta.deployable || !meta.proxyType) continue + if (!ab.entryExists(name)) continue + const entry = ab.getEntry(name) + if (!entry?.address) continue + + if (entry.pendingImplementation?.address) anyPending = true + if (meta.artifact) { + const { codeChanged } = checkCodeChanged(meta.artifact, ab, name) + if (codeChanged) anyCodeChanged = true + } else if (meta.sharedImplementation) { + const sharedMeta = getContractMetadata(abType, meta.sharedImplementation) + if (sharedMeta?.artifact) { + const { codeChanged } = checkCodeChanged(sharedMeta.artifact, ab, meta.sharedImplementation) + if (codeChanged) anyCodeChanged = true + } + } + + if (anyCodeChanged && anyPending) return { anyCodeChanged, anyPending } + } + } + + return { anyCodeChanged, anyPending } +} diff --git a/packages/deployment/lib/task-utils.ts b/packages/deployment/lib/task-utils.ts new file mode 100644 index 000000000..72473073e --- /dev/null +++ b/packages/deployment/lib/task-utils.ts @@ -0,0 +1,139 @@ +/** + * Shared Task Utilities + * + * Common functions used across Hardhat tasks. Consolidates helpers that were + * previously duplicated across grant-role, revoke-role, reo-tasks, eth-tasks, + * grt-tasks, and check-deployer. + */ + +import { configVariable } from 'hardhat/config' + +import { type AddressBookType, CONTRACT_REGISTRY } from './contract-registry.js' +import { graph } from '../rocketh/deploy.js' + +/** + * Convert network name to env var prefix: arbitrumSepolia → ARBITRUM_SEPOLIA + */ +export function networkToEnvPrefix(networkName: string): string { + return networkName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() +} + +/** + * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) + * + * Tries the Hardhat keystore plugin first, then falls back to environment variables. + * Returns undefined if the variable is not found in either location. + * + * @param hre - Hardhat Runtime Environment + * @param name - Configuration variable name (e.g., 'ARBITRUM_SEPOLIA_DEPLOYER_KEY') + * @returns The resolved value or undefined if not set + */ +export async function resolveConfigVar(hre: unknown, name: string): Promise { + try { + const variable = configVariable(name) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hooks = (hre as any).hooks + + const value = await hooks.runHandlerChain( + 'configurationVariables', + 'fetchValue', + [variable], + async (_context: unknown, v: { name: string }) => { + const envValue = process.env[v.name] + if (typeof envValue !== 'string') { + throw new Error(`Variable ${v.name} not found`) + } + return envValue + }, + ) + return value + } catch { + return undefined + } +} + +/** + * Get the deployer key name for a network, handling fork mode. + * + * In fork mode (network name is 'fork'), uses the HARDHAT_FORK env var to + * determine the source network. Falls back to 'arbitrumSepolia'. + * + * @param networkName - Network name (e.g., 'fork', 'arbitrumSepolia') + * @returns Key name (e.g., 'ARBITRUM_SEPOLIA_DEPLOYER_KEY') + */ +export function getDeployerKeyName(networkName: string): string { + const effectiveNetwork = networkName === 'fork' ? (process.env.HARDHAT_FORK ?? 'arbitrumSepolia') : networkName + return `${networkToEnvPrefix(effectiveNetwork)}_DEPLOYER_KEY` +} + +/** + * Resolve contract from registry by name + * + * Searches across all address books for a matching contract with roles defined. + * Returns the address book type and role list if found. + */ +export function resolveContractFromRegistry( + contractName: string, +): { addressBook: AddressBookType; roles: readonly string[] } | null { + for (const [book, contracts] of Object.entries(CONTRACT_REGISTRY)) { + const contract = contracts[contractName as keyof typeof contracts] as { roles?: readonly string[] } | undefined + if (contract?.roles) { + return { addressBook: book as AddressBookType, roles: contract.roles } + } + } + return null +} + +/** + * Get contract address from address book + */ +export function getContractAddress(addressBook: AddressBookType, contractName: string, chainId: number): string | null { + const book = + addressBook === 'issuance' + ? graph.getIssuanceAddressBook(chainId) + : addressBook === 'horizon' + ? graph.getHorizonAddressBook(chainId) + : graph.getSubgraphServiceAddressBook(chainId) + + // Address book type is a union — cast to access entryExists/getEntry with a runtime name + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const anyBook = book as any + if (!anyBook.entryExists(contractName)) { + return null + } + + return anyBook.getEntry(contractName)?.address ?? null +} + +/** + * Format duration in seconds to human-readable string (e.g., "2d 3h 15m") + */ +export function formatDuration(seconds: bigint): string { + const days = seconds / 86400n + const hours = (seconds % 86400n) / 3600n + const mins = (seconds % 3600n) / 60n + + if (days > 0n) { + return `${days}d ${hours}h ${mins}m` + } else if (hours > 0n) { + return `${hours}h ${mins}m` + } else { + return `${mins}m` + } +} + +/** + * Format timestamp to human-readable string (ISO format without milliseconds) + */ +export function formatTimestamp(timestamp: bigint): string { + if (timestamp === 0n) { + return 'never' + } + + const date = new Date(Number(timestamp) * 1000) + return date + .toISOString() + .replace(/\.000Z$/, '') + .replace(/Z$/, '') + .replace('T', ' ') +} diff --git a/packages/deployment/lib/upgrade-implementation.ts b/packages/deployment/lib/upgrade-implementation.ts index 866cfd047..3b35d482d 100644 --- a/packages/deployment/lib/upgrade-implementation.ts +++ b/packages/deployment/lib/upgrade-implementation.ts @@ -5,9 +5,10 @@ import { getTargetChainIdFromEnv } from './address-book-utils.js' import type { AnyAddressBookOps } from './address-book-ops.js' import { GRAPH_PROXY_ADMIN_ABI, OZ_PROXY_ADMIN_ABI } from './abis.js' import { type AddressBookType, type ProxyType, type RegistryEntry } from './contract-registry.js' -import { createGovernanceTxBuilder } from './execute-governance.js' +import { getOnChainImplementation } from './deploy-implementation.js' +import { createGovernanceTxBuilder, saveGovernanceTx } from './execute-governance.js' import { graph } from '../rocketh/deploy.js' -import type { TxMetadata } from './tx-builder.js' +import type { TxBuilder, TxMetadata } from './tx-builder.js' /** * Configuration for upgrading an implementation (manual override mode) @@ -19,10 +20,11 @@ export interface ImplementationUpgradeConfig { /** * Name of the proxy admin entry in address book. - * Examples: 'GraphProxyAdmin', 'GraphIssuanceProxyAdmin' + * Example: 'GraphProxyAdmin' for legacy GraphProxy contracts. * - * Optional for subgraph-service contracts - the proxy admin address - * is read from the contract entry's proxyAdmin field. + * Optional for OZ v5 TransparentUpgradeableProxy contracts (subgraph-service + * and issuance) — the per-proxy admin address is read from the contract + * entry's proxyAdmin field. */ proxyAdminName?: string @@ -30,8 +32,8 @@ export interface ImplementationUpgradeConfig { * Implementation contract name if different from contractName. * Used when a proxy is upgraded to a different contract type. * - * Example: PilotAllocation proxy upgraded to DirectAllocation implementation - * contractName: 'PilotAllocation' + * Example: ReclaimedRewards proxy upgraded to DirectAllocation implementation + * contractName: 'ReclaimedRewards' * implementationName: 'DirectAllocation' * * Default: same as contractName @@ -62,7 +64,7 @@ export interface ImplementationUpgradeOverrides { * Implementation contract name if different from contractName. * Used when a proxy is upgraded to a different contract type. * - * Example: PilotAllocation proxy upgraded to DirectAllocation implementation + * Example: ReclaimedRewards proxy upgraded to DirectAllocation implementation */ implementationName?: string @@ -110,7 +112,7 @@ function createUpgradeConfigFromRegistry( * import { Contracts } from '../../lib/contract-registry.js' * await upgradeImplementation(env, Contracts.horizon.RewardsManager) * await upgradeImplementation(env, Contracts["subgraph-service"].SubgraphService) - * await upgradeImplementation(env, Contracts.issuance.PilotAllocation, { + * await upgradeImplementation(env, Contracts.issuance.ReclaimedRewards, { * implementationName: 'DirectAllocation', // Upgrade to different implementation * }) * ``` @@ -124,17 +126,27 @@ function createUpgradeConfigFromRegistry( * }) * ``` */ -export async function upgradeImplementation( +/** + * Build upgrade TXs for a contract and add them to an existing builder. + * + * Checks the address book for a pendingImplementation. If found, encodes upgrade + * TX(s) and adds them to the provided builder. Returns without exiting. + * + * Use this when building a batch of upgrades (e.g., GIP-level stage scripts). + * For single-contract upgrades that save and exit, use `upgradeImplementation`. + * + * @returns Whether an upgrade was needed (pendingImplementation existed) + */ +export async function buildUpgradeTxs( env: Environment, entryOrConfig: RegistryEntry | ImplementationUpgradeConfig, + builder: TxBuilder, overrides?: ImplementationUpgradeOverrides, -): Promise { - // Handle overloads - convert registry entry to config +): Promise<{ upgraded: boolean }> { const config: ImplementationUpgradeConfig = 'name' in entryOrConfig ? createUpgradeConfigFromRegistry(entryOrConfig, overrides) : entryOrConfig const { contractName, proxyAdminName, proxyType = 'graph', addressBook = 'horizon' } = config - // Use fork-local address book in fork mode, canonical address book otherwise const targetChainId = await getTargetChainIdFromEnv(env) const addressBookInstance: AnyAddressBookOps = addressBook === 'subgraph-service' @@ -146,19 +158,49 @@ export async function upgradeImplementation( // Check for pending implementation const contractEntry = addressBookInstance.getEntry(contractName) if (!contractEntry?.pendingImplementation?.address) { - env.showMessage(`\n✓ No pending ${contractName} implementation to upgrade`) - return { upgraded: false, executed: false } + // No pending implementation stored — check if a shared implementation has changed on-chain + const implName = config.implementationName + if (implName && contractEntry?.address) { + const implDepName = `${implName}_Implementation` + const implDep = env.getOrNull(implDepName) + if (implDep) { + const client = graph.getPublicClient(env) + const onChainImpl = await getOnChainImplementation(client, contractEntry.address, proxyType) + if (onChainImpl.toLowerCase() !== implDep.address.toLowerCase()) { + // Shared implementation changed — auto-set pendingImplementation + const implMetadata = addressBookInstance.getDeploymentMetadata(implDepName) + addressBookInstance.setPendingImplementationWithMetadata( + contractName, + implDep.address, + implMetadata ?? { txHash: '', bytecodeHash: '' }, + ) + env.showMessage(` ⚠️ ${contractName}: shared implementation changed, setting pending upgrade`) + // Fall through to process the upgrade + } else { + env.showMessage(` ✓ ${contractName}: no pending implementation`) + return { upgraded: false } + } + } else { + env.showMessage(` ✓ ${contractName}: no pending implementation`) + return { upgraded: false } + } + } else { + env.showMessage(` ✓ ${contractName}: no pending implementation`) + return { upgraded: false } + } + } + + // Re-read entry after potential auto-set + const updatedEntry = addressBookInstance.getEntry(contractName) + if (!updatedEntry?.pendingImplementation?.address) { + return { upgraded: false } } // Get proxy admin address - // Priority: 1) Per-proxy ProxyAdmin in entry (OZ v5 / subgraph-service) - // 2) Shared ProxyAdmin by name (legacy horizon pattern) let proxyAdminAddress: string | undefined - if (contractEntry.proxyAdmin) { - // Per-proxy ProxyAdmin stored inline (OZ v5 issuance, subgraph-service) - proxyAdminAddress = contractEntry.proxyAdmin + if (updatedEntry.proxyAdmin) { + proxyAdminAddress = updatedEntry.proxyAdmin } else if (proxyAdminName) { - // Shared ProxyAdmin by name (horizon legacy pattern) proxyAdminAddress = addressBookInstance.getEntry(proxyAdminName)?.address } @@ -169,28 +211,13 @@ export async function upgradeImplementation( ) } - const proxyAddress = contractEntry.address - const pendingImpl = contractEntry.pendingImplementation.address - - env.showMessage(`\n🔧 Upgrading ${contractName}...`) - env.showMessage(` Proxy: ${proxyAddress}`) - env.showMessage(` ProxyAdmin: ${proxyAdminAddress}`) - env.showMessage(` New implementation: ${pendingImpl}`) - - // Generate governance TX with deterministic name (overwrites if exists) - const builder = await createGovernanceTxBuilder(env, `upgrade-${contractName}`, { - name: `${contractName} Upgrade`, - description: `Upgrade ${contractName} proxy to new implementation`, - }) + const proxyAddress = updatedEntry.address + const pendingImpl = updatedEntry.pendingImplementation!.address + const currentImpl = updatedEntry.implementation ?? 'unknown' - // Get current implementation for state change tracking - const currentImpl = contractEntry.implementation ?? 'unknown' + env.showMessage(` + ${contractName}: ${pendingImpl.slice(0, 10)}... (${proxyType} proxy)`) - // Build TX based on proxy type if (proxyType === 'transparent') { - // OpenZeppelin v5 ProxyAdmin uses upgradeAndCall() with empty calldata - // Note: we use empty bytes (0x) because not all contracts implement ERC165, - // so supportsInterface cannot be used as a universal no-op const upgradeData = encodeFunctionData({ abi: OZ_PROXY_ADMIN_ABI, functionName: 'upgradeAndCall', @@ -202,25 +229,15 @@ export async function upgradeImplementation( contractName, decoded: { function: 'upgradeAndCall(address,address,bytes)', - args: { - proxy: proxyAddress, - implementation: pendingImpl, - data: '0x [empty]', - }, + args: { proxy: proxyAddress, implementation: pendingImpl, data: '0x [empty]' }, }, stateChanges: { - [`${contractName} implementation`]: { - current: currentImpl, - new: pendingImpl, - }, + [`${contractName} implementation`]: { current: currentImpl, new: pendingImpl }, }, notes: 'OZ TransparentUpgradeableProxy upgrade via per-proxy ProxyAdmin', } builder.addTx({ to: proxyAdminAddress, value: '0', data: upgradeData }, metadata) } else { - // Graph legacy: upgrade() + acceptProxy(implementation, proxy) - // Note: GraphProxyAdmin.sol requires both implementation and proxy parameters, - // despite IGraphProxyAdmin interface only showing proxy parameter (interface is outdated) const upgradeData = encodeFunctionData({ abi: GRAPH_PROXY_ADMIN_ABI, functionName: 'upgrade', @@ -232,45 +249,75 @@ export async function upgradeImplementation( args: [pendingImpl as `0x${string}`, proxyAddress as `0x${string}`], }) - const upgradeMetadata: TxMetadata = { - toLabel: 'GraphProxyAdmin', - contractName, - decoded: { - function: 'upgrade(address,address)', - args: { - proxy: proxyAddress, - implementation: pendingImpl, + builder.addTx( + { to: proxyAdminAddress, value: '0', data: upgradeData }, + { + toLabel: 'GraphProxyAdmin', + contractName, + decoded: { + function: 'upgrade(address,address)', + args: { proxy: proxyAddress, implementation: pendingImpl }, }, + notes: 'Graph legacy proxy upgrade (step 1/2: set pending implementation)', }, - notes: 'Graph legacy proxy upgrade (step 1/2: set pending implementation)', - } - builder.addTx({ to: proxyAdminAddress, value: '0', data: upgradeData }, upgradeMetadata) - - const acceptMetadata: TxMetadata = { - toLabel: 'GraphProxyAdmin', - contractName, - decoded: { - function: 'acceptProxy(address,address)', - args: { - implementation: pendingImpl, - proxy: proxyAddress, + ) + builder.addTx( + { to: proxyAdminAddress, value: '0', data: acceptData }, + { + toLabel: 'GraphProxyAdmin', + contractName, + decoded: { + function: 'acceptProxy(address,address)', + args: { implementation: pendingImpl, proxy: proxyAddress }, }, - }, - stateChanges: { - [`${contractName} implementation`]: { - current: currentImpl, - new: pendingImpl, + stateChanges: { + [`${contractName} implementation`]: { current: currentImpl, new: pendingImpl }, }, + notes: 'Graph legacy proxy upgrade (step 2/2: accept and activate)', }, - notes: 'Graph legacy proxy upgrade (step 2/2: accept and activate)', - } - builder.addTx({ to: proxyAdminAddress, value: '0', data: acceptData }, acceptMetadata) + ) } - const txFile = builder.saveToFile() - env.showMessage(` ✓ Governance TX saved: ${txFile}`) - env.showMessage(` Run: npx hardhat deploy:execute-governance --network ${env.name}`) + return { upgraded: true } +} + +/** + * Upgrade an implementation via governance TX (registry-driven) + * + * Generates a governance TX batch file for a single contract upgrade, then exits. + * For batch upgrades (multiple contracts in one TX batch), use `buildUpgradeTxs` instead. + * + * @example Registry-driven with Contracts object (recommended): + * ```typescript + * import { Contracts } from '../../lib/contract-registry.js' + * await upgradeImplementation(env, Contracts.horizon.RewardsManager) + * await upgradeImplementation(env, Contracts["subgraph-service"].SubgraphService) + * await upgradeImplementation(env, Contracts.issuance.ReclaimedRewards, { + * implementationName: 'DirectAllocation', // Upgrade to different implementation + * }) + * ``` + */ +export async function upgradeImplementation( + env: Environment, + entryOrConfig: RegistryEntry | ImplementationUpgradeConfig, + overrides?: ImplementationUpgradeOverrides, +): Promise { + const config: ImplementationUpgradeConfig = + 'name' in entryOrConfig ? createUpgradeConfigFromRegistry(entryOrConfig, overrides) : entryOrConfig + + const builder = await createGovernanceTxBuilder(env, `upgrade-${config.contractName}`, { + name: `${config.contractName} Upgrade`, + description: `Upgrade ${config.contractName} proxy to new implementation`, + }) + + env.showMessage(`\n🔧 Upgrading ${config.contractName}...`) + const { upgraded } = await buildUpgradeTxs(env, entryOrConfig, builder, overrides) + + if (!upgraded) { + env.showMessage(`\n✓ No pending ${config.contractName} implementation to upgrade`) + return { upgraded: false, executed: false } + } - // Exit to prevent subsequent deployment steps until governance TX is executed - process.exit(1) + saveGovernanceTx(env, builder, `${config.contractName} upgrade`) + return { upgraded: true, executed: false } } diff --git a/packages/deployment/package.json b/packages/deployment/package.json index fc4a55ad2..a1feebbef 100644 --- a/packages/deployment/package.json +++ b/packages/deployment/package.json @@ -4,9 +4,11 @@ "description": "Unified deployment for Graph Protocol contracts", "private": true, "scripts": { - "build": "pnpm build:deps", + "build": "pnpm build:deps && pnpm build:self", + "build:self": "pnpm generate:abis", "build:deps": "pnpm --filter @graphprotocol/deployment^... build", "build:clean": "pnpm --filter @graphprotocol/contracts clean && pnpm build:deps", + "generate:abis": "tsx scripts/generate-abis.ts", "deploy": "pnpm build:clean && hardhat deploy", "deploy:sync": "hardhat deploy --tags sync", "deploy:status": "hardhat deploy:deployment-status", @@ -21,6 +23,7 @@ "dependencies": { "@graphprotocol/contracts": "workspace:*", "@graphprotocol/horizon": "workspace:*", + "@graphprotocol/interfaces": "workspace:*", "@graphprotocol/issuance": "workspace:*", "@graphprotocol/subgraph-service": "workspace:*", "@graphprotocol/toolshed": "workspace:*", diff --git a/packages/deployment/rocketh/config.ts b/packages/deployment/rocketh/config.ts index 44bcb4fd6..c9cfffdc5 100644 --- a/packages/deployment/rocketh/config.ts +++ b/packages/deployment/rocketh/config.ts @@ -33,6 +33,14 @@ const hardhatLocalChain: ChainInfo = { testnet: true, } +const graphLocalNetworkChain: ChainInfo = { + id: 1337, + name: 'Graph Local Network', + nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { default: { http: ['http://chain:8545'] } }, + testnet: true, +} + const arbitrumSepoliaChain: ChainInfo = { id: 421614, name: 'Arbitrum Sepolia', @@ -58,6 +66,7 @@ export const config: UserConfig = { deployments: 'deployments', scripts: ['deploy'], chains: { + 1337: { info: graphLocalNetworkChain }, 31337: { info: hardhatLocalChain }, 421614: { info: arbitrumSepoliaChain }, 42161: { info: arbitrumOneChain }, @@ -68,6 +77,7 @@ export const config: UserConfig = { hardhat: { chain: 31337 }, localhost: { chain: 31337 }, fork: { chain: 31337 }, + localNetwork: { chain: 1337 }, arbitrumSepolia: { chain: 421614 }, arbitrumOne: { chain: 42161 }, }, diff --git a/packages/deployment/rocketh/deploy.ts b/packages/deployment/rocketh/deploy.ts index c3c86f230..384150c88 100644 --- a/packages/deployment/rocketh/deploy.ts +++ b/packages/deployment/rocketh/deploy.ts @@ -6,6 +6,7 @@ import { execute, read, tx } from '@rocketh/read-execute' import { createPublicClient, custom } from 'viem' import { + autoDetectForkNetwork, getForkTargetChainId, getHorizonAddressBook, getIssuanceAddressBook, @@ -16,9 +17,9 @@ import { import { accounts, data } from './config.js' /** - * Options for updating issuance address book after deployment + * Options for updating an address book after deployment */ -export interface IssuanceDeploymentUpdate { +export interface DeploymentUpdate { /** Contract name in the address book */ name: string /** Deployed address (proxy address if proxied) */ @@ -29,10 +30,15 @@ export interface IssuanceDeploymentUpdate { implementation?: string /** Proxy type if this is a proxied contract */ proxy?: 'transparent' | 'graph' - /** Implementation deployment metadata (for verification) */ + /** Implementation deployment metadata (for verification of proxied contracts) */ implementationDeployment?: DeploymentMetadata + /** Deployment metadata (for verification of non-proxied contracts) */ + deployment?: DeploymentMetadata } +/** @deprecated Use DeploymentUpdate */ +export type IssuanceDeploymentUpdate = DeploymentUpdate + /** * Graph Protocol deployment helpers * @@ -56,6 +62,13 @@ export interface IssuanceDeploymentUpdate { * ``` */ export const graph = { + /** + * Auto-detect fork network by querying anvil. + * Call at the top of any task that needs fork awareness. + * No-op if FORK_NETWORK is already set or node isn't an anvil fork. + */ + autoDetect: () => autoDetectForkNetwork(), + /** * Get a viem public client for on-chain queries */ @@ -90,6 +103,42 @@ export const graph = { */ getIssuanceAddressBook: (chainId?: number) => getIssuanceAddressBook(chainId), + /** + * Update horizon address book after deploying a contract. + * Supports both standalone and proxied contracts. + * + * @param env - Rocketh environment (used to get chain ID from provider) + * @param update - Deployment update details + */ + updateHorizonAddressBook: async (env: Environment, update: DeploymentUpdate) => { + const chainId = await getTargetChainIdFromEnv(env) + const addressBook = getHorizonAddressBook(chainId) + + if (update.proxy) { + addressBook.setProxy( + update.name as Parameters[0], + update.address, + update.implementation!, + update.proxyAdmin!, + update.proxy, + ) + if (update.implementationDeployment) { + addressBook.setImplementationDeploymentMetadata( + update.name as Parameters[0], + update.implementationDeployment, + ) + } + } else { + addressBook.setContract(update.name as Parameters[0], update.address) + if (update.deployment) { + addressBook.setDeploymentMetadata( + update.name as Parameters[0], + update.deployment, + ) + } + } + }, + /** * Update issuance address book after deploying a contract. * Call this after rocketh's deployViaProxy or deploy to sync the address book. @@ -118,6 +167,12 @@ export const graph = { } } else { addressBook.setContract(update.name as Parameters[0], update.address) + if (update.deployment) { + addressBook.setDeploymentMetadata( + update.name as Parameters[0], + update.deployment, + ) + } } }, } diff --git a/packages/deployment/scripts/check-bytecode.ts b/packages/deployment/scripts/check-bytecode.ts new file mode 100644 index 000000000..9d9178b2a --- /dev/null +++ b/packages/deployment/scripts/check-bytecode.ts @@ -0,0 +1,54 @@ +import { createPublicClient, http } from 'viem' + +import { loadSubgraphServiceArtifact } from '../lib/artifact-loaders.js' +import { computeBytecodeHash } from '../lib/bytecode-utils.js' +import { graph } from '../rocketh/deploy.js' + +async function main() { + const chainId = 421614 // arbitrumSepolia + + // Get address book + const addressBook = graph.getSubgraphServiceAddressBook(chainId) + const entry = addressBook.getEntry('SubgraphService') + const deploymentMetadata = addressBook.getDeploymentMetadata('SubgraphService') + + console.log('\n📋 SubgraphService Bytecode Analysis\n') + console.log('Proxy address:', entry.address) + console.log('Current implementation:', entry.implementation) + console.log('Pending implementation:', entry.pendingImplementation?.address ?? 'none') + + // Get local artifact + const artifact = loadSubgraphServiceArtifact('SubgraphService') + const localHash = computeBytecodeHash(artifact.deployedBytecode ?? '0x') + console.log('\nLocal artifact bytecode hash:', localHash) + + // Get address book stored hash + console.log('Address book stored hash:', deploymentMetadata?.bytecodeHash ?? '(none)') + + // Get on-chain bytecode + const client = createPublicClient({ + transport: http('https://sepolia-rollup.arbitrum.io/rpc'), + }) + + const onChainBytecode = await client.getCode({ + address: entry.implementation as `0x${string}`, + }) + + if (onChainBytecode && onChainBytecode !== '0x') { + const onChainHash = computeBytecodeHash(onChainBytecode) + console.log('On-chain implementation hash:', onChainHash) + + console.log('\n🔍 Comparison:') + console.log( + 'Local vs Address Book:', + localHash === (deploymentMetadata?.bytecodeHash ?? '') ? '✓ MATCH' : '✗ DIFFERENT', + ) + console.log('Local vs On-chain:', localHash === onChainHash ? '✓ MATCH' : '✗ DIFFERENT') + console.log( + 'Address Book vs On-chain:', + (deploymentMetadata?.bytecodeHash ?? '') === onChainHash ? '✓ MATCH' : '✗ DIFFERENT (or missing)', + ) + } +} + +main().catch(console.error) diff --git a/packages/deployment/scripts/check-rocketh-bytecode.ts b/packages/deployment/scripts/check-rocketh-bytecode.ts new file mode 100644 index 000000000..aff8f394a --- /dev/null +++ b/packages/deployment/scripts/check-rocketh-bytecode.ts @@ -0,0 +1,34 @@ +import { readFileSync } from 'fs' + +import { loadSubgraphServiceArtifact } from '../lib/artifact-loaders.js' +import { computeBytecodeHash } from '../lib/bytecode-utils.js' + +async function main() { + console.log('\n📋 Rocketh vs Local Artifact Comparison\n') + + // Get local artifact + const artifact = loadSubgraphServiceArtifact('SubgraphService') + const localHash = computeBytecodeHash(artifact.deployedBytecode ?? '0x') + console.log('Local artifact hash:', localHash) + + // Check rocketh stored bytecode + try { + const rockethPath = '.rocketh/deployments/arbitrumSepolia/SubgraphService_Implementation.json' + const rockethData = JSON.parse(readFileSync(rockethPath, 'utf-8')) + + if (rockethData.deployedBytecode) { + const rockethHash = computeBytecodeHash(rockethData.deployedBytecode) + console.log('Rocketh stored hash:', rockethHash) + console.log( + '\nComparison:', + localHash === rockethHash ? '✓ MATCH (deploy will skip)' : '✗ DIFFERENT (deploy will redeploy)', + ) + } else { + console.log('Rocketh stored hash: (no deployedBytecode)') + } + } catch { + console.log('Rocketh record:', 'not found') + } +} + +main().catch(console.error) diff --git a/packages/deployment/scripts/debug-deploy-state.ts b/packages/deployment/scripts/debug-deploy-state.ts new file mode 100644 index 000000000..6267734f2 --- /dev/null +++ b/packages/deployment/scripts/debug-deploy-state.ts @@ -0,0 +1,27 @@ +import { loadSubgraphServiceArtifact } from '../lib/artifact-loaders.js' +import { computeBytecodeHash } from '../lib/bytecode-utils.js' + +async function main() { + console.log('\n📋 Investigating Deploy "Unchanged" Message\n') + + // The deploy script checks env.getOrNull('SubgraphService_Implementation') + // But rocketh state is in-memory during deploy runs + // We can't easily check that without running deploy + + // What we CAN check is: + // 1. If sync step would have synced the implementation + // 2. The actual bytecode hashes + + const artifact = loadSubgraphServiceArtifact('SubgraphService') + const localHash = computeBytecodeHash(artifact.deployedBytecode ?? '0x') + + console.log('Local artifact bytecode hash:', localHash) + console.log('\n⚠️ The issue:') + console.log('1. Sync shows "code changed" because address book has different/missing hash') + console.log('2. Deploy says "unchanged" - this suggests rocketh has the implementation') + console.log('3. But local bytecode IS different from on-chain') + console.log('\nThis means deploy will NOT deploy the new implementation!') + console.log('The local changes will be ignored.\n') +} + +main().catch(console.error) diff --git a/packages/deployment/scripts/generate-abis.ts b/packages/deployment/scripts/generate-abis.ts new file mode 100644 index 000000000..f4ac49a14 --- /dev/null +++ b/packages/deployment/scripts/generate-abis.ts @@ -0,0 +1,264 @@ +/** + * ABI Codegen Script + * + * Generates typed `as const` ABI exports from the contract registry. + * Reads interface declarations and artifact sources from the registry, + * resolves them to JSON artifacts, and writes a generated TypeScript file. + * + * Usage: tsx scripts/generate-abis.ts + */ + +import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs' +import { createRequire } from 'node:module' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +import { toFunctionSelector } from 'viem' + +import { CONTRACT_REGISTRY, type ContractMetadata, type InterfaceAbiConfig } from '../lib/contract-registry.js' + +const require = createRequire(import.meta.url) +const __dirname = dirname(fileURLToPath(import.meta.url)) +const OUTPUT_DIR = join(__dirname, '..', 'lib', 'generated') +const OUTPUT_FILE = join(OUTPUT_DIR, 'abis.ts') + +// --------------------------------------------------------------------------- +// Utility ABIs — not tied to any registry entry +// --------------------------------------------------------------------------- + +const UTILITY_ABIS: Array<{ name: string; artifactPath: string }> = [ + { + name: 'IERC165_ABI', + artifactPath: '@graphprotocol/interfaces/artifacts/@openzeppelin/contracts/introspection/IERC165.sol/IERC165.json', + }, + { + name: 'ISSUANCE_TARGET_ABI', + artifactPath: + '@graphprotocol/interfaces/artifacts/contracts/issuance/allocate/IIssuanceTarget.sol/IIssuanceTarget.json', + }, + { + name: 'OZ_PROXY_ADMIN_ABI', + artifactPath: + '@graphprotocol/horizon/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json', + }, +] + +// Alias re-exports (source export name → alias export name) +const ABI_ALIASES: Array<{ source: string; alias: string }> = [ + { source: 'ISSUANCE_ALLOCATOR_ABI', alias: 'SET_TARGET_ALLOCATION_ABI' }, + { source: 'DIRECT_ALLOCATION_ABI', alias: 'INITIALIZE_GOVERNOR_ABI' }, +] + +// Interface IDs to extract (export name → interface name used in ABI_SOURCES or registry) +// Derived from registry interfaces + utility ABIs +const INTERFACE_IDS: Array<{ name: string; abiExportName: string }> = [ + { name: 'IERC165_INTERFACE_ID', abiExportName: 'IERC165_ABI' }, + { name: 'IISSUANCE_TARGET_INTERFACE_ID', abiExportName: 'ISSUANCE_TARGET_ABI' }, + { name: 'IREWARDS_MANAGER_INTERFACE_ID', abiExportName: 'REWARDS_MANAGER_ABI' }, +] + +// --------------------------------------------------------------------------- +// Interface artifact discovery +// --------------------------------------------------------------------------- + +/** + * Build an index of interface name → artifact path by scanning the + * @graphprotocol/interfaces artifacts directory. + */ +function buildInterfaceIndex(): Map { + const index = new Map() + + // Resolve the interfaces package artifacts root + // Use a known artifact to locate the package, then walk up + const knownArtifact = + require.resolve('@graphprotocol/interfaces/artifacts/contracts/contracts/rewards/IRewardsManager.sol/IRewardsManager.json') + // Walk up to find the 'artifacts' directory + let artifactsRoot = dirname(knownArtifact) + while (!artifactsRoot.endsWith('/artifacts') && artifactsRoot !== '/') { + artifactsRoot = dirname(artifactsRoot) + } + + // Recursively scan for JSON files + function scan(dir: string): void { + for (const entry of readdirSync(dir)) { + const full = join(dir, entry) + if (entry === 'build-info') continue + if (statSync(full).isDirectory()) { + scan(full) + } else if (entry.endsWith('.json') && !entry.endsWith('.dbg.json')) { + // Extract interface name from filename (e.g. IRewardsManager.json → IRewardsManager) + const name = entry.replace('.json', '') + // Store as package-relative path for require.resolve + const relativePath = full.slice(full.indexOf('/artifacts/') + 1) + index.set(name, `@graphprotocol/interfaces/${relativePath}`) + } + } + } + + scan(artifactsRoot) + return index +} + +// --------------------------------------------------------------------------- +// Artifact loading +// --------------------------------------------------------------------------- + +type AbiEntry = Record + +function loadAbiFromArtifact(artifactPath: string): AbiEntry[] { + const resolved = require.resolve(artifactPath) + const artifact = JSON.parse(readFileSync(resolved, 'utf-8')) + return artifact.abi +} + +/** + * Resolve artifact path for a generateAbi entry based on its ArtifactSource. + */ +function resolveContractArtifactPath(artifact: { type: string; path?: string; name?: string }): string { + switch (artifact.type) { + case 'contracts': + return `@graphprotocol/contracts/artifacts/contracts/${artifact.path}/${artifact.name}.sol/${artifact.name}.json` + case 'subgraph-service': { + const baseName = (artifact.name ?? '').includes('/') ? (artifact.name ?? '').split('/').pop()! : artifact.name + return `@graphprotocol/subgraph-service/artifacts/contracts/${artifact.name}.sol/${baseName}.json` + } + case 'horizon': + return `@graphprotocol/horizon/artifacts/${artifact.path}.json` + case 'issuance': + return `@graphprotocol/issuance/artifacts/${artifact.path}.json` + case 'openzeppelin': + return `@openzeppelin/contracts/build/contracts/${artifact.name}.json` + default: + throw new Error(`Unknown artifact type: ${artifact.type}`) + } +} + +// --------------------------------------------------------------------------- +// Interface ID calculation +// --------------------------------------------------------------------------- + +/** + * Calculate ERC-165 interface ID from an ABI. + * The interface ID is XOR of all function selectors. + */ +function calculateInterfaceId(abi: AbiEntry[]): string { + const functions = abi.filter((entry) => entry.type === 'function') + if (functions.length === 0) return '0x00000000' + + let id = BigInt(0) + for (const fn of functions) { + const inputs = (fn.inputs as Array<{ type: string }>) ?? [] + const sig = `${fn.name}(${inputs.map((i) => i.type).join(',')})` + const selector = toFunctionSelector(sig) + id ^= BigInt(selector) + } + + return '0x' + id.toString(16).padStart(8, '0') +} + +// --------------------------------------------------------------------------- +// Code generation +// --------------------------------------------------------------------------- + +function formatAbiEntry(entry: AbiEntry, indent: string): string { + return `${indent}${JSON.stringify(entry)}` +} + +function generateAbiExport(name: string, abi: AbiEntry[]): string { + const entries = abi.map((entry) => formatAbiEntry(entry, ' ')).join(',\n') + return `export const ${name} = [\n${entries},\n] as const\n` +} + +function main(): void { + const verbose = process.argv.includes('--verbose') + + const interfaceIndex = buildInterfaceIndex() + const abiMap = new Map() + const lines: string[] = [ + '/**', + ' * Auto-generated typed ABI exports', + ' *', + ' * DO NOT EDIT — regenerate with: pnpm generate:abis', + ' */', + '', + ] + + // 1. Walk registry for interface ABIs + for (const [bookName, book] of Object.entries(CONTRACT_REGISTRY)) { + for (const [contractName, rawMeta] of Object.entries(book)) { + const meta = rawMeta as ContractMetadata + // Interface ABIs + if (meta.interfaces) { + for (const iface of meta.interfaces as readonly InterfaceAbiConfig[]) { + const artifactPath = interfaceIndex.get(iface.interface) + if (!artifactPath) { + throw new Error( + `Interface "${iface.interface}" not found in @graphprotocol/interfaces artifacts ` + + `(referenced by ${bookName}.${contractName})`, + ) + } + const abi = loadAbiFromArtifact(artifactPath) + abiMap.set(iface.name, abi) + if (verbose) console.log(` ${iface.name} ← ${iface.interface} (${abi.length} entries)`) + } + } + + // Full contract ABI + if (meta.generateAbi && meta.artifact) { + const exportName = meta.generateAbi as string + const artifactPath = resolveContractArtifactPath( + meta.artifact as { type: string; path?: string; name?: string }, + ) + const abi = loadAbiFromArtifact(artifactPath) + abiMap.set(exportName, abi) + if (verbose) console.log(` ${exportName} ← ${contractName} (${abi.length} entries)`) + } + } + } + + // 2. Utility ABIs + for (const util of UTILITY_ABIS) { + const abi = loadAbiFromArtifact(util.artifactPath) + abiMap.set(util.name, abi) + if (verbose) console.log(` ${util.name} ← utility (${abi.length} entries)`) + } + + // 3. Generate ABI exports + for (const [name, abi] of abiMap) { + lines.push(generateAbiExport(name, abi)) + } + + // 4. Alias re-exports + for (const { source, alias } of ABI_ALIASES) { + if (!abiMap.has(source)) { + throw new Error(`Alias source "${source}" not found in generated ABIs`) + } + lines.push(`export { ${source} as ${alias} }\n`) + if (verbose) console.log(` ${alias} → ${source}`) + } + + // 5. Interface IDs + lines.push('// Interface IDs (computed from ABI function selectors)') + for (const { name, abiExportName } of INTERFACE_IDS) { + const abi = abiMap.get(abiExportName) + if (!abi) { + throw new Error(`ABI "${abiExportName}" not found for interface ID "${name}"`) + } + const id = calculateInterfaceId(abi) + lines.push(`export const ${name} = '${id}' as const`) + if (verbose) console.log(` ${name} = ${id}`) + } + lines.push('') + + // Write output + if (!existsSync(OUTPUT_DIR)) { + mkdirSync(OUTPUT_DIR, { recursive: true }) + } + writeFileSync(OUTPUT_FILE, lines.join('\n')) + + console.log( + `Generated ${abiMap.size} ABIs, ${ABI_ALIASES.length} aliases, ${INTERFACE_IDS.length} interface IDs → lib/generated/abis.ts`, + ) +} + +main() diff --git a/packages/deployment/scripts/tag-deployment.sh b/packages/deployment/scripts/tag-deployment.sh new file mode 100755 index 000000000..3ec32053d --- /dev/null +++ b/packages/deployment/scripts/tag-deployment.sh @@ -0,0 +1,287 @@ +#!/usr/bin/env bash +# +# tag-deployment.sh - Create annotated git tag for a contract deployment +# +# Usage: +# ./scripts/tag-deployment.sh --deployer --network --name [options] +# +# Options: +# --deployer What performed the deployment (free-form, e.g., "packages/deployment --tags RewardsManager") +# --network Network: arbitrumOne or arbitrumSepolia +# --name Upgrade short name for the tag (e.g., "reward-manager-and-subgraph-service") +# --base Git ref to diff against (default: HEAD~1) +# --dry-run Preview tag without creating it +# --sign Force-sign the tag with -s +# --help Show this help +# +set -euo pipefail + +# --- Dependencies --- +for cmd in git jq; do + if ! command -v "$cmd" >/dev/null 2>&1; then + echo "Error: $cmd is required but not found" + exit 1 + fi +done + +REPO_ROOT="$(git rev-parse --show-toplevel)" + +# --- Defaults --- +DEPLOYER="" +NETWORK="" +UPGRADE_NAME="" +BASE_REF="HEAD~1" +DRY_RUN=false +SIGN_FLAG="-a" + +# --- Address books managed by packages/deployment --- +ADDRESS_BOOKS=( + "packages/horizon/addresses.json:horizon" + "packages/subgraph-service/addresses.json:subgraph-service" + "packages/issuance/addresses.json:issuance" +) + +# --- Network to chain ID / label mapping --- +network_to_chain_id() { + case "$1" in + arbitrumOne) echo "42161" ;; + arbitrumSepolia) echo "421614" ;; + *) echo "unknown" ;; + esac +} + +network_to_label() { + case "$1" in + arbitrumOne) echo "mainnet" ;; + arbitrumSepolia) echo "testnet" ;; + *) echo "unknown" ;; + esac +} + +network_to_display() { + case "$1" in + arbitrumOne) echo "arbitrum-one" ;; + arbitrumSepolia) echo "arbitrum-sepolia" ;; + *) echo "$1" ;; + esac +} + +# --- Parse arguments --- +usage() { + sed -n '3,14p' "$0" | sed 's/^# \?//' + exit "${1:-0}" +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --deployer) DEPLOYER="$2"; shift 2 ;; + --network) NETWORK="$2"; shift 2 ;; + --name) UPGRADE_NAME="$2"; shift 2 ;; + --base) BASE_REF="$2"; shift 2 ;; + --dry-run) DRY_RUN=true; shift ;; + --sign) SIGN_FLAG="-s"; shift ;; + --help) usage 0 ;; + *) echo "Unknown option: $1"; usage 1 ;; + esac +done + +if [[ -z "$DEPLOYER" ]]; then + echo "Error: --deployer is required" + usage 1 +fi + +if [[ -z "$NETWORK" ]]; then + echo "Error: --network is required" + usage 1 +fi + +if [[ -z "$UPGRADE_NAME" ]]; then + echo "Error: --name is required" + usage 1 +fi + +# Validate upgrade name: lowercase, digits, hyphens only +if [[ ! "$UPGRADE_NAME" =~ ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$ ]]; then + echo "Error: --name must be lowercase alphanumeric with hyphens (e.g., 'reward-manager-and-subgraph-service')" + exit 1 +fi + +CHAIN_ID="$(network_to_chain_id "$NETWORK")" +LABEL="$(network_to_label "$NETWORK")" +DISPLAY="$(network_to_display "$NETWORK")" + +if [[ "$CHAIN_ID" == "unknown" ]]; then + echo "Error: unknown network '$NETWORK' (expected arbitrumOne or arbitrumSepolia)" + exit 1 +fi + +# --- Preconditions --- +if [[ -n "$(git status --porcelain)" ]]; then + echo "Error: working tree is not clean. Commit or stash changes first." + echo " (Tag must point to a finalized commit)" + exit 1 +fi + +COMMIT_SHA="$(git rev-parse HEAD)" +COMMIT_SHORT="$(git rev-parse --short HEAD)" + +# Check if commit is signed (informational) +if ! git log -1 --format='%G?' HEAD | grep -q '[GU]'; then + echo "Warning: HEAD commit ($COMMIT_SHORT) is not signed" +fi + +# Verify base ref exists +if ! git rev-parse --verify "$BASE_REF" >/dev/null 2>&1; then + echo "Error: base ref '$BASE_REF' does not exist" + exit 1 +fi + +# --- Detect changed contracts per address book --- +collect_changes() { + local book_path="$1" + local chain_id="$2" + local base_ref="$3" + # Get the file at base ref and at HEAD (both via git, not filesystem) + local base_json head_json + base_json="$(git show "$base_ref:$book_path" 2>/dev/null || echo '{}')" + head_json="$(git show "HEAD:$book_path" 2>/dev/null || echo '{}')" + + if [[ "$head_json" == '{}' ]]; then + return + fi + + # Extract contract names for this chain at base and head + local base_contracts head_contracts + base_contracts="$(echo "$base_json" | jq -r --arg cid "$chain_id" '.[$cid] // {} | keys[]' 2>/dev/null || true)" + head_contracts="$(echo "$head_json" | jq -r --arg cid "$chain_id" '.[$cid] // {} | keys[]' 2>/dev/null || true)" + + # Find contracts that are new or changed + local all_contracts + all_contracts="$(echo -e "${base_contracts}\n${head_contracts}" | sort -u | grep -v '^$' || true)" + + for contract in $all_contracts; do + local base_entry head_entry + base_entry="$(echo "$base_json" | jq -c --arg cid "$chain_id" --arg c "$contract" '.[$cid][$c] // empty' 2>/dev/null || true)" + head_entry="$(echo "$head_json" | jq -c --arg cid "$chain_id" --arg c "$contract" '.[$cid][$c] // empty' 2>/dev/null || true)" + + if [[ "$base_entry" != "$head_entry" ]]; then + # Contract changed - extract key details + local impl addr change_type + addr="$(echo "$head_json" | jq -r --arg cid "$chain_id" --arg c "$contract" '.[$cid][$c].address // empty' 2>/dev/null || true)" + impl="$(echo "$head_json" | jq -r --arg cid "$chain_id" --arg c "$contract" '.[$cid][$c].implementation // empty' 2>/dev/null || true)" + + if [[ -z "$base_entry" ]]; then + change_type="new" + elif [[ -z "$head_entry" ]]; then + change_type="removed" + else + change_type="updated" + fi + + local detail="" + if [[ -n "$impl" ]]; then + detail="implementation: ${impl}" + elif [[ -n "$addr" ]]; then + detail="address: ${addr}" + fi + + echo "${change_type}|${contract}|${detail}" + fi + done +} + +# Collect all changes grouped by address book +declare -A BOOK_CHANGES +has_changes=false + +for entry in "${ADDRESS_BOOKS[@]}"; do + book_path="${entry%%:*}" + book_name="${entry##*:}" + + changes="$(collect_changes "$book_path" "$CHAIN_ID" "$BASE_REF")" + if [[ -n "$changes" ]]; then + BOOK_CHANGES["$book_name"]="$changes" + has_changes=true + fi +done + +if [[ "$has_changes" == false ]]; then + echo "No address book changes detected for chain $CHAIN_ID between $BASE_REF and HEAD" + echo " Checked:" + for entry in "${ADDRESS_BOOKS[@]}"; do + echo " ${entry%%:*}" + done + exit 1 +fi + +# --- Generate tag name --- +TAG_DATE="$(date +%Y-%m-%d)" +TAG_BASE="deploy/${LABEL}/${TAG_DATE}/${UPGRADE_NAME}" +TAG_NAME="$TAG_BASE" + +# Handle suffix for multiple deploys with the same name on the same day +if git tag -l "$TAG_NAME" | grep -q .; then + for suffix in b c d e f; do + candidate="${TAG_BASE}-${suffix}" + if ! git tag -l "$candidate" | grep -q .; then + TAG_NAME="$candidate" + break + fi + done + if [[ "$TAG_NAME" == "$TAG_BASE" ]]; then + echo "Error: too many deployment tags for ${TAG_DATE}/${UPGRADE_NAME}" + exit 1 + fi +fi + +# --- Build annotation --- +ANNOTATION="upgrade: ${UPGRADE_NAME} +network: ${DISPLAY} (${CHAIN_ID}) +deployed-by: ${DEPLOYER} +commit: ${COMMIT_SHA}" + +for book_name in $(echo "${!BOOK_CHANGES[@]}" | tr ' ' '\n' | sort); do + changes="${BOOK_CHANGES[$book_name]}" + ANNOTATION="${ANNOTATION} + +contracts (${book_name}):" + + while IFS='|' read -r change_type contract detail; do + local_line=" - ${contract}" + if [[ -n "$detail" ]]; then + local_line="${local_line} (${detail})" + fi + if [[ "$change_type" == "new" ]]; then + local_line="${local_line} [new]" + elif [[ "$change_type" == "removed" ]]; then + local_line="${local_line} [removed]" + fi + ANNOTATION="${ANNOTATION} +${local_line}" + done <<< "$changes" +done + +# --- Create or preview tag --- +echo "" +echo "--- Deployment Tag ---" +echo "Tag: ${TAG_NAME}" +echo "Commit: ${COMMIT_SHORT} ($(git log -1 --format='%s' HEAD))" +echo "" +echo "$ANNOTATION" +echo "----------------------" +echo "" + +if [[ "$DRY_RUN" == true ]]; then + echo "[dry-run] Tag not created" + exit 0 +fi + +MSG_FILE="$(mktemp)" +trap 'rm -f "$MSG_FILE"' EXIT +printf '%s\n' "$ANNOTATION" > "$MSG_FILE" +git tag "$SIGN_FLAG" "$TAG_NAME" -F "$MSG_FILE" + +echo "Tag created: ${TAG_NAME}" +echo "" +echo "To push: git push origin ${TAG_NAME}" +echo "To view: git show ${TAG_NAME}" diff --git a/packages/deployment/tasks/check-deployer.ts b/packages/deployment/tasks/check-deployer.ts index d28eba36c..275568ad0 100644 --- a/packages/deployment/tasks/check-deployer.ts +++ b/packages/deployment/tasks/check-deployer.ts @@ -1,47 +1,15 @@ -import { configVariable, task } from 'hardhat/config' +import { task } from 'hardhat/config' import type { NewTaskActionFunction } from 'hardhat/types/tasks' import { createPublicClient, custom, formatEther } from 'viem' import { privateKeyToAccount } from 'viem/accounts' +import { networkToEnvPrefix, resolveConfigVar } from '../lib/task-utils.js' + const BLOCK_EXPLORERS: Record = { 42161: 'https://arbiscan.io/address/', 421614: 'https://sepolia.arbiscan.io/address/', } -/** - * Convert network name to env var prefix: arbitrumSepolia → ARBITRUM_SEPOLIA - */ -function networkToEnvPrefix(networkName: string): string { - return networkName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() -} - -/** - * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) - */ -async function resolveConfigVar(hre: unknown, name: string): Promise { - try { - const variable = configVariable(name) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hooks = (hre as any).hooks - - const value = await hooks.runHandlerChain( - 'configurationVariables', - 'fetchValue', - [variable], - async (_context: unknown, v: { name: string }) => { - const envValue = process.env[v.name] - if (typeof envValue !== 'string') { - throw new Error(`Variable ${v.name} not found`) - } - return envValue - }, - ) - return value - } catch { - return undefined - } -} - interface TaskArgs { // No arguments for this task } diff --git a/packages/deployment/tasks/deployment-status.ts b/packages/deployment/tasks/deployment-status.ts index 8b5994f0d..fc612c154 100644 --- a/packages/deployment/tasks/deployment-status.ts +++ b/packages/deployment/tasks/deployment-status.ts @@ -1,27 +1,20 @@ import { task } from 'hardhat/config' import { ArgumentType } from 'hardhat/types/arguments' import type { NewTaskActionFunction } from 'hardhat/types/tasks' -import { createPublicClient, custom, type PublicClient } from 'viem' +import { createPublicClient, custom, http, type PublicClient } from 'viem' -import { - IISSUANCE_TARGET_INTERFACE_ID, - IREWARDS_MANAGER_INTERFACE_ID, - ISSUANCE_ALLOCATOR_ABI, - REWARDS_ELIGIBILITY_ORACLE_ABI, - REWARDS_MANAGER_ABI, -} from '../lib/abis.js' -import type { AddressBookOps } from '../lib/address-book-ops.js' -import { - checkIssuanceAllocatorActivation, - checkOperatorRole, - getReclaimAddress, - RECLAIM_CONTRACT_NAMES, - RECLAIM_REASONS, - type ReclaimReasonKey, - supportsInterface, -} from '../lib/contract-checks.js' +import { CONTROLLER_ABI } from '../lib/abis.js' +import { autoDetectForkNetwork } from '../lib/address-book-utils.js' +import { formatAddress } from '../lib/contract-checks.js' import { type AddressBookType, getContractsByAddressBook } from '../lib/contract-registry.js' -import { getContractStatusLine } from '../lib/sync-utils.js' +import { + getIssuanceAllocatorChecks, + getReclaimAddressChecks, + getRewardsEligibilityOracleChecks, + getRewardsManagerChecks, + type IntegrationCheck, +} from '../lib/status-detail.js' +import { getContractStatusLine, type ProxyAdminOwnershipContext } from '../lib/sync-utils.js' import { graph } from '../rocketh/deploy.js' /** Get deployable contract names for an address book (requires explicit deployable: true) */ @@ -31,14 +24,97 @@ function getDeployableContracts(addressBook: AddressBookType): string[] { .map(([name]) => name) } -/** Integration check result */ -interface IntegrationCheck { - ok: boolean | null // null = not applicable / not deployed - label: string +/** + * Get non-deployable contract names for an address book. + * + * Includes prerequisites (`prerequisite: true`), address-only entries + * (`addressOnly: true`) and pure registry placeholders (`{}`). The status task + * surfaces these as context — they're contracts the deployment depends on but + * doesn't manage. Entries not present in the on-chain address book are filtered + * out at print time so the listing only shows what actually exists for the + * network. + */ +function getPrerequisiteContracts(addressBook: AddressBookType): string[] { + return getContractsByAddressBook(addressBook) + .filter(([_, meta]) => meta.deployable !== true) + .map(([name]) => name) +} + +function printCheck(check: IntegrationCheck): void { + const icon = check.ok === null ? '○' : check.ok ? '✓' : '✗' + console.log(` ${icon} ${check.label}`) +} + +function printWarnings(warnings: string[] | undefined): void { + if (!warnings) return + for (const warning of warnings) { + console.log(` ⚠ ${warning}`) + } +} + +/** Print proxy admin detail in verbose/component mode */ +function printProxyAdminDetail(result: { + proxyAdminOwner?: string + proxyAdminAddress?: string + proxyAdminOwnerAddress?: string +}): void { + if (!result.proxyAdminAddress) return + const ownerLabel = + result.proxyAdminOwner === 'governor' + ? 'governor ✓' + : result.proxyAdminOwner === 'deployer' + ? 'deployer ⚠' + : 'not governor ⚠' + const ownerAddr = result.proxyAdminOwnerAddress ? ` ${result.proxyAdminOwnerAddress}` : '' + console.log(` ProxyAdmin: ${result.proxyAdminAddress}`) + console.log(` ProxyAdmin owner:${ownerAddr} (${ownerLabel})`) +} + +/** + * Print prerequisite contracts (non-deployable registry entries) in a dim format. + * + * Shown after the deployable contracts in each address book section. Skips + * entries that aren't present in the address book — placeholders that are in + * the registry for type completeness but aren't configured for the network are + * silent rather than printed as `(not deployed)`. + * + * In default mode each entry is one line: `· Name @ 0x1234...5678`. In + * verbose mode the full `getContractStatusLine` output is shown so users can + * drill into proxy detail for prerequisites that have it. + */ +async function printPrerequisites( + client: PublicClient | undefined, + addressBookType: AddressBookType, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + addressBook: any, + matchesComponent: (name: string) => boolean, + verbose: boolean, + ownershipCtx: ProxyAdminOwnershipContext | undefined, +): Promise { + const names = getPrerequisiteContracts(addressBookType).filter(matchesComponent) + // Filter to entries actually present in the address book — placeholders that + // aren't configured for this network shouldn't add noise. + const present = names.filter((name) => addressBook.entryExists(name)) + if (present.length === 0) return + + for (const name of present) { + if (verbose) { + const result = await getContractStatusLine(client, addressBookType, addressBook, name, undefined, ownershipCtx) + console.log(` · ${result.line}`) + printWarnings(result.warnings) + printProxyAdminDetail(result) + } else { + const entry = addressBook.getEntry(name) + const addr = entry?.address ? formatAddress(entry.address) : '(no address)' + console.log(` · ${name} @ ${addr}`) + } + } } interface TaskArgs { package: string + verbose: boolean + component: string } const action: NewTaskActionFunction = async (taskArgs, hre) => { @@ -47,25 +123,82 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { const conn = await (hre as any).network.connect() const networkName = conn.networkName const packageFilter = taskArgs.package.toLowerCase() + const verbose = taskArgs.verbose + const componentFilter = taskArgs.component?.toLowerCase() || '' + const showDetail = verbose || !!componentFilter + + // Get configured chain ID from network config (always available) + const configuredChainId = conn.networkConfig?.chainId as number | undefined + + // Default RPC URLs for read-only access (no accounts needed) + const DEFAULT_RPC_URLS: Record = { + arbitrumOne: 'https://arb1.arbitrum.io/rpc', + arbitrumSepolia: 'https://sepolia-rollup.arbitrum.io/rpc', + } + + // Get RPC URL: prefer env var, then default + const envRpcUrl = + networkName === 'arbitrumSepolia' + ? process.env.ARBITRUM_SEPOLIA_RPC + : networkName === 'arbitrumOne' + ? process.env.ARBITRUM_ONE_RPC + : undefined + const rpcUrl = envRpcUrl || DEFAULT_RPC_URLS[networkName] // Get viem public client for on-chain checks + // Use direct HTTP transport to RPC URL (bypasses Hardhat's account resolution) let client: PublicClient | undefined let actualChainId: number | undefined - try { - if (conn.provider) { + let providerError: string | undefined + + if (rpcUrl) { + // Create read-only client directly to RPC (no accounts needed) + try { client = createPublicClient({ - transport: custom(conn.provider), + transport: http(rpcUrl), }) as PublicClient actualChainId = await client.getChainId() + } catch (e) { + client = undefined + const errMsg = e instanceof Error ? e.message : String(e) + providerError = errMsg.split('\n')[0] + } + } else { + // No RPC URL available - try Hardhat's provider (may fail if accounts not configured) + try { + if (conn.provider) { + client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + actualChainId = await client.getChainId() + } + } catch (e) { + // Provider failed - disable on-chain checks + client = undefined + + // Extract error message (may be nested in viem error or cause chain) + let errMsg = e instanceof Error ? e.message : String(e) + const cause = e instanceof Error ? (e as Error & { cause?: Error }).cause : undefined + if (cause?.message) { + errMsg = cause.message + } + + providerError = errMsg.split('\n')[0] + } + } + + // Auto-detect fork network from anvil if on localhost without FORK_NETWORK + if (configuredChainId === 31337 && !process.env.FORK_NETWORK && !process.env.HARDHAT_FORK) { + const detected = await autoDetectForkNetwork() + if (detected) { + console.log(`🔍 Auto-detected fork network: ${detected}`) } - } catch { - // Provider not available } - // Determine target chain ID: use actual chain ID when not in fork mode + // Determine target chain ID: use fork target, then configured, then actual, then fallback const forkChainId = graph.getForkTargetChainId() const isForkMode = forkChainId !== null - const targetChainId = forkChainId ?? actualChainId ?? 31337 + const targetChainId = forkChainId ?? configuredChainId ?? actualChainId ?? 31337 // Show status header with chain info if (isForkMode) { @@ -75,7 +208,13 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { console.log(`⚠️ Warning: Connected chain (${actualChainId}) differs from target (${targetChainId})`) console.log(` Address book lookups use chainId ${targetChainId}\n`) } else { - console.log(`\n🔍 Status: ${networkName} (chainId: ${actualChainId ?? targetChainId})\n`) + console.log(`\n🔍 Status: ${networkName} (chainId: ${targetChainId})\n`) + } + + // Show provider warning if we couldn't connect (but continue with address book lookups) + if (providerError) { + console.log(`⚠️ Provider unavailable: ${providerError}`) + console.log(` On-chain checks disabled. Set the missing variable or use --network hardhat for local testing.\n`) } // Get address books @@ -83,324 +222,180 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { const subgraphServiceAddressBook = graph.getSubgraphServiceAddressBook(targetChainId) const issuanceAddressBook = graph.getIssuanceAddressBook(targetChainId) - // Horizon contracts (deploy targets only) - if (packageFilter === 'all' || packageFilter === 'horizon') { - console.log('📦 Horizon') - for (const name of getDeployableContracts('horizon')) { - const result = await getContractStatusLine(client, 'horizon', horizonAddressBook, name) - console.log(` ${result.line}`) - printWarnings(result.warnings) - - // Integration checks for RewardsManager (only if deployed) - if (name === 'RewardsManager' && client && result.exists) { - const checks = await getRewardsManagerChecks(client, horizonAddressBook) - for (const check of checks) { - printCheck(check) + // Resolve governor/deployer for proxy admin ownership checks + let ownershipCtx: ProxyAdminOwnershipContext | undefined + if (client) { + try { + const controllerAddress = horizonAddressBook.entryExists('Controller') + ? horizonAddressBook.getEntry('Controller')?.address + : null + if (controllerAddress) { + const governor = (await client.readContract({ + address: controllerAddress as `0x${string}`, + abi: CONTROLLER_ABI, + functionName: 'getGovernor', + })) as string + + if (governor) { + // Deployer is best-effort: available when provider has accounts (fork/local) + let deployer: string | undefined + try { + const accounts = (await conn.provider?.request({ method: 'eth_accounts' })) as string[] | undefined + if (accounts && accounts.length > 0) { + deployer = accounts[0] + } + } catch { + // No accounts available (read-only provider) — that's fine + } + ownershipCtx = { governor, deployer } } } + } catch { + // Controller not available — skip ownership checks } } - // SubgraphService contracts - if (packageFilter === 'all' || packageFilter === 'subgraph-service') { - console.log('\n📦 SubgraphService') - for (const name of getDeployableContracts('subgraph-service')) { - const result = await getContractStatusLine(client, 'subgraph-service', subgraphServiceAddressBook, name) - console.log(` ${result.line}`) - printWarnings(result.warnings) + // Helper to check if a contract name matches the component filter + const matchesComponent = (name: string) => !componentFilter || name.toLowerCase().includes(componentFilter) + + // Show ownership context in verbose mode + if (verbose && ownershipCtx) { + console.log(` Governor: ${ownershipCtx.governor}`) + if (ownershipCtx.deployer) { + console.log(` Deployer: ${ownershipCtx.deployer}`) } + console.log() } - // Issuance contracts - if (packageFilter === 'all' || packageFilter === 'issuance') { - console.log('\n📦 Issuance') - for (const name of getDeployableContracts('issuance')) { - const result = await getContractStatusLine(client, 'issuance', issuanceAddressBook, name) - console.log(` ${result.line}`) - printWarnings(result.warnings) - - // Integration checks for IssuanceAllocator (only if deployed) - if (name === 'IssuanceAllocator' && client && result.exists) { - const checks = await getIssuanceAllocatorChecks(client, horizonAddressBook, issuanceAddressBook) - for (const check of checks) { - printCheck(check) - } - } - - // Integration checks for RewardsEligibilityOracle (only if deployed) - if (name === 'RewardsEligibilityOracle' && client && result.exists) { - const checks = await getRewardsEligibilityOracleChecks(client, horizonAddressBook, issuanceAddressBook) - for (const check of checks) { - printCheck(check) + // Horizon contracts (deploy targets + prerequisites) + if (packageFilter === 'all' || packageFilter === 'horizon') { + const contracts = getDeployableContracts('horizon').filter(matchesComponent) + if (contracts.length > 0 || showDetail) { + console.log('📦 Horizon') + for (const name of contracts) { + const result = await getContractStatusLine(client, 'horizon', horizonAddressBook, name, undefined, ownershipCtx) + console.log(` ${result.line}`) + printWarnings(result.warnings) + + if (showDetail) { + printProxyAdminDetail(result) + + // Integration checks for RewardsManager (only if deployed) + if (name === 'RewardsManager' && client && result.exists) { + const checks = await getRewardsManagerChecks(client, horizonAddressBook) + for (const check of checks) { + printCheck(check) + } + } } } - - // Integration checks for reclaim addresses (only if deployed) - if (name.startsWith('ReclaimedRewardsFor') && client && result.exists) { - const checks = await getReclaimAddressChecks(client, horizonAddressBook, issuanceAddressBook, name) - for (const check of checks) { - printCheck(check) - } + if (showDetail) { + await printPrerequisites(client, 'horizon', horizonAddressBook, matchesComponent, verbose, ownershipCtx) } } } - console.log() -} - -function printCheck(check: IntegrationCheck): void { - const icon = check.ok === null ? '○' : check.ok ? '✓' : '✗' - console.log(` ${icon} ${check.label}`) -} - -function printWarnings(warnings: string[] | undefined): void { - if (!warnings) return - for (const warning of warnings) { - console.log(` ⚠ ${warning}`) - } -} - -async function getRewardsManagerChecks(client: PublicClient, horizonBook: AddressBookOps): Promise { - const checks: IntegrationCheck[] = [] - const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null - - if (!rmAddress) return checks - - // Check IRewardsManager support (latest interface version) - const supportsRewardsManager = await supportsInterface(client, rmAddress, IREWARDS_MANAGER_INTERFACE_ID) - checks.push({ ok: supportsRewardsManager, label: `implements IRewardsManager (${IREWARDS_MANAGER_INTERFACE_ID})` }) - - // Check IIssuanceTarget support (required for issuance integration) - const supportsIssuanceTarget = await supportsInterface(client, rmAddress, IISSUANCE_TARGET_INTERFACE_ID) - checks.push({ ok: supportsIssuanceTarget, label: `implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})` }) - - return checks -} - -async function getIssuanceAllocatorChecks( - client: PublicClient, - horizonBook: AddressBookOps, - issuanceBook: AddressBookOps, -): Promise { - const checks: IntegrationCheck[] = [] - - const iaAddress = issuanceBook.entryExists('IssuanceAllocator') - ? issuanceBook.getEntry('IssuanceAllocator')?.address - : null - const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null - const gtAddress = horizonBook.entryExists('L2GraphToken') ? horizonBook.getEntry('L2GraphToken')?.address : null - - if (!iaAddress || !rmAddress || !gtAddress) return checks - - // RM must implement IIssuanceTarget for IA integration - const rmSupportsTarget = await supportsInterface(client, rmAddress, IISSUANCE_TARGET_INTERFACE_ID) - checks.push({ ok: rmSupportsTarget, label: `RM implements IIssuanceTarget (${IISSUANCE_TARGET_INTERFACE_ID})` }) - - // Only check activation if RM supports IIssuanceTarget (has been upgraded) - if (rmSupportsTarget) { - const activation = await checkIssuanceAllocatorActivation(client, iaAddress, rmAddress, gtAddress) - checks.push({ ok: activation.iaIntegrated, label: 'RM.issuanceAllocator == this' }) - checks.push({ ok: activation.iaMinter, label: 'GraphToken.MINTER_ROLE granted' }) - } else { - // RM not upgraded yet - can't check activation - checks.push({ ok: null, label: 'RM.issuanceAllocator == this (RM not upgraded)' }) - checks.push({ ok: null, label: 'GraphToken.MINTER_ROLE granted (RM not upgraded)' }) - } - - // Check default target configured - try { - const defaultTarget = (await client.readContract({ - address: iaAddress as `0x${string}`, - abi: ISSUANCE_ALLOCATOR_ABI, - functionName: 'getDefaultTarget', - })) as string - const hasDefaultTarget = defaultTarget !== '0x0000000000000000000000000000000000000000' - checks.push({ ok: hasDefaultTarget, label: 'defaultTarget configured' }) - } catch { - // Function not available - } - - return checks -} - -async function getRewardsEligibilityOracleChecks( - client: PublicClient, - horizonBook: AddressBookOps, - issuanceBook: AddressBookOps, -): Promise { - const checks: IntegrationCheck[] = [] - - const reoAddress = issuanceBook.entryExists('RewardsEligibilityOracle') - ? issuanceBook.getEntry('RewardsEligibilityOracle')?.address - : null - const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null - const controllerAddress = horizonBook.entryExists('Controller') ? horizonBook.getEntry('Controller')?.address : null - - if (!reoAddress || !rmAddress) return checks - - // Get governor and pause guardian from Controller for role checks - let governor: string | null = null - let pauseGuardian: string | null = null - if (controllerAddress) { - try { - governor = (await client.readContract({ - address: controllerAddress as `0x${string}`, - abi: [ - { - inputs: [], - name: 'getGovernor', - outputs: [{ type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - ], - functionName: 'getGovernor', - })) as string - } catch { - // Controller doesn't have getGovernor - } - try { - pauseGuardian = (await client.readContract({ - address: controllerAddress as `0x${string}`, - abi: [ - { - inputs: [], - name: 'pauseGuardian', - outputs: [{ type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - ], - functionName: 'pauseGuardian', - })) as string - } catch { - // Controller doesn't have pauseGuardian - } - } - - // Check access control roles - try { - const governorRole = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'GOVERNOR_ROLE', - })) as `0x${string}` - - if (governor) { - const governorHasRole = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'hasRole', - args: [governorRole, governor as `0x${string}`], - })) as boolean - checks.push({ ok: governorHasRole, label: 'governor has GOVERNOR_ROLE' }) + // SubgraphService contracts + if (packageFilter === 'all' || packageFilter === 'subgraph-service') { + const contracts = getDeployableContracts('subgraph-service').filter(matchesComponent) + if (contracts.length > 0 || showDetail) { + console.log('\n📦 SubgraphService') + for (const name of contracts) { + const result = await getContractStatusLine( + client, + 'subgraph-service', + subgraphServiceAddressBook, + name, + undefined, + ownershipCtx, + ) + console.log(` ${result.line}`) + printWarnings(result.warnings) + if (showDetail) { + printProxyAdminDetail(result) + } + } + if (showDetail) { + await printPrerequisites( + client, + 'subgraph-service', + subgraphServiceAddressBook, + matchesComponent, + verbose, + ownershipCtx, + ) + } } - } catch { - // Role check not available } - // Check PAUSE_ROLE - try { - const pauseRole = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'PAUSE_ROLE', - })) as `0x${string}` - - if (pauseGuardian) { - const pauseGuardianHasRole = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'hasRole', - args: [pauseRole, pauseGuardian as `0x${string}`], - })) as boolean - checks.push({ ok: pauseGuardianHasRole, label: 'pause guardian has PAUSE_ROLE' }) + // Issuance contracts + if (packageFilter === 'all' || packageFilter === 'issuance') { + const contracts = getDeployableContracts('issuance').filter(matchesComponent) + if (contracts.length > 0 || showDetail) { + console.log('\n📦 Issuance') + for (const name of contracts) { + const result = await getContractStatusLine( + client, + 'issuance', + issuanceAddressBook, + name, + undefined, + ownershipCtx, + ) + console.log(` ${result.line}`) + printWarnings(result.warnings) + + if (showDetail) { + printProxyAdminDetail(result) + + // Integration checks for IssuanceAllocator (only if deployed) + if (name === 'IssuanceAllocator' && client && result.exists) { + const checks = await getIssuanceAllocatorChecks(client, horizonAddressBook, issuanceAddressBook) + for (const check of checks) { + printCheck(check) + } + } + + // Integration checks for REO instances (only if deployed) + if ( + (name === 'RewardsEligibilityOracleA' || name === 'RewardsEligibilityOracleB') && + client && + result.exists + ) { + const checks = await getRewardsEligibilityOracleChecks( + client, + horizonAddressBook, + issuanceAddressBook, + name, + ) + for (const check of checks) { + printCheck(check) + } + } + + // Integration checks for reclaim address (only if deployed) + if (name === 'ReclaimedRewards' && client && result.exists) { + const checks = await getReclaimAddressChecks(client, horizonAddressBook, issuanceAddressBook) + for (const check of checks) { + printCheck(check) + } + } + } + } + if (showDetail) { + await printPrerequisites(client, 'issuance', issuanceAddressBook, matchesComponent, verbose, ownershipCtx) + } } - } catch { - // Role check not available - } - - // Check OPERATOR_ROLE using shared function (single source of truth) - const networkOperator = issuanceBook.entryExists('NetworkOperator') - ? (issuanceBook.getEntry('NetworkOperator')?.address ?? null) - : null - - try { - const operatorCheck = await checkOperatorRole(client, reoAddress, networkOperator) - // For status check: NetworkOperator not configured is always a configuration failure - // (even if role assignment is technically correct with 0 holders) - const statusOk = networkOperator === null ? false : operatorCheck.ok - checks.push({ ok: statusOk, label: operatorCheck.message }) - } catch { - checks.push({ ok: null, label: 'OPERATOR_ROLE (check failed)' }) - } - - // Check if configured in RM - try { - const currentREO = (await client.readContract({ - address: rmAddress as `0x${string}`, - abi: REWARDS_MANAGER_ABI, - functionName: 'getProviderEligibilityOracle', - })) as string - const configured = currentREO.toLowerCase() === reoAddress.toLowerCase() - checks.push({ ok: configured, label: 'RM.providerEligibilityOracle == this' }) - } catch { - // Function not available on old RM } - // Check if validation is enabled - try { - const enabled = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'getEligibilityValidation', - })) as boolean - checks.push({ ok: enabled, label: 'eligibility validation enabled' }) - } catch { - // Function not available + // Legend for icons (shown when proxy admin warnings are present or in verbose mode) + if (verbose) { + console.log( + '\n Legend: ✓ ok △ code changed ◷ pending upgrade ↑ upgraded ↻ synced 🔑 ProxyAdmin not on governor', + ) } - // Check last oracle update time (indicates if active) - try { - const lastUpdate = (await client.readContract({ - address: reoAddress as `0x${string}`, - abi: REWARDS_ELIGIBILITY_ORACLE_ABI, - functionName: 'getLastOracleUpdateTime', - })) as bigint - const hasUpdates = lastUpdate > 0n - checks.push({ ok: hasUpdates, label: 'oracle has processed updates' }) - } catch { - // Function not available - } - - return checks -} - -async function getReclaimAddressChecks( - client: PublicClient, - horizonBook: AddressBookOps, - issuanceBook: AddressBookOps, - contractName: string, -): Promise { - const checks: IntegrationCheck[] = [] - - const rmAddress = horizonBook.entryExists('RewardsManager') ? horizonBook.getEntry('RewardsManager')?.address : null - const contractAddress = issuanceBook.entryExists(contractName) ? issuanceBook.getEntry(contractName)?.address : null - - if (!rmAddress || !contractAddress) return checks - - // Find the reclaim reason for this contract - const reclaimKey = Object.entries(RECLAIM_CONTRACT_NAMES).find(([_, name]) => name === contractName)?.[0] as - | ReclaimReasonKey - | undefined - if (!reclaimKey) return checks - - const reason = RECLAIM_REASONS[reclaimKey] - const actualAddress = await getReclaimAddress(client, rmAddress, reason) - const configured = actualAddress?.toLowerCase() === contractAddress.toLowerCase() - checks.push({ ok: configured, label: 'configured in RM.reclaimAddresses' }) - - return checks + console.log() } const deployStatusTask = task('deploy:status', 'Show deployment and integration status') @@ -410,6 +405,18 @@ const deployStatusTask = task('deploy:status', 'Show deployment and integration type: ArgumentType.STRING, defaultValue: 'all', }) + .addOption({ + name: 'verbose', + description: 'Show full detail including proxy admin ownership, addresses, and legend', + type: ArgumentType.FLAG, + defaultValue: false, + }) + .addOption({ + name: 'component', + description: 'Filter to contracts matching this name (case-insensitive substring match)', + type: ArgumentType.STRING, + defaultValue: '', + }) .setAction(async () => ({ default: action })) .build() diff --git a/packages/deployment/tasks/eth-tasks.ts b/packages/deployment/tasks/eth-tasks.ts new file mode 100644 index 000000000..7033fe8c4 --- /dev/null +++ b/packages/deployment/tasks/eth-tasks.ts @@ -0,0 +1,208 @@ +import { task } from 'hardhat/config' +import { ArgumentType } from 'hardhat/types/arguments' +import type { NewTaskActionFunction } from 'hardhat/types/tasks' +import { createPublicClient, createWalletClient, custom, formatEther, parseEther, type PublicClient } from 'viem' +import { privateKeyToAccount } from 'viem/accounts' + +import { getDeployerKeyName, resolveConfigVar } from '../lib/task-utils.js' + +// -- Task Types -- + +interface CheckKeyArgs { + key: string +} + +interface FundArgs { + to: string + amount: string +} + +interface BalanceArgs { + account: string +} + +// -- Task Actions -- + +/** + * Verify a keystore variable holds the private key for an expected address + */ +const checkKeyAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.key) { + console.error('\nError: --key is required') + console.error('Usage: npx hardhat eth:check-key --key ARBITRUM_ONE_ORACLE_KEY') + return + } + + const keyValue = await resolveConfigVar(hre, taskArgs.key) + + if (!keyValue) { + console.error(`\nError: Key "${taskArgs.key}" not found in keystore or environment.`) + console.error(`Set via keystore: npx hardhat keystore set ${taskArgs.key}`) + console.error(`Or environment: export ${taskArgs.key}=0x...`) + return + } + + const account = privateKeyToAccount(keyValue as `0x${string}`) + + console.log(`\nKey Check`) + console.log(` Variable: ${taskArgs.key}`) + console.log(` Address: ${account.address}`) + console.log() +} + +/** + * Query ETH balance for an address + */ +const balanceAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.account) { + console.error('\nError: --account is required') + console.error('Usage: npx hardhat eth:balance --account 0x... --network arbitrumOne') + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const chainId = await client.getChainId() + const account = taskArgs.account as `0x${string}` + const balance = await client.getBalance({ address: account }) + + console.log(`\nETH Balance`) + console.log(` Account: ${account}`) + console.log(` Network: ${networkName} (chainId: ${chainId})`) + console.log(` Balance: ${formatEther(balance)} ETH`) + console.log() +} + +/** + * Send ETH from deployer to an address + */ +const fundAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.to || !taskArgs.amount) { + console.error('\nError: --to and --amount are required') + console.error('Usage: npx hardhat eth:fund --to 0x... --amount 0.01 --network arbitrumOne') + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const chainId = await client.getChainId() + + // Get deployer key + const keyName = getDeployerKeyName(networkName) + const deployerKey = await resolveConfigVar(hre, keyName) + + if (!deployerKey) { + console.error('\nError: No deployer key configured.') + console.error(`Set via keystore: npx hardhat keystore set ${keyName}`) + console.error(`Or environment: export ${keyName}=0x...`) + return + } + + const account = privateKeyToAccount(deployerKey as `0x${string}`) + const to = taskArgs.to as `0x${string}` + const value = parseEther(taskArgs.amount) + + // Check deployer balance + const balance = await client.getBalance({ address: account.address }) + + if (balance < value) { + console.error(`\nError: Insufficient balance`) + console.error(` Deployer balance: ${formatEther(balance)} ETH`) + console.error(` Requested: ${taskArgs.amount} ETH`) + return + } + + console.log(`\nSending ETH`) + console.log(` From: ${account.address}`) + console.log(` To: ${to}`) + console.log(` Amount: ${taskArgs.amount} ETH`) + console.log(` Network: ${networkName} (chainId: ${chainId})`) + + const walletClient = createWalletClient({ + account, + transport: custom(conn.provider), + }) + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).sendTransaction({ to, value }) + console.log(` TX: ${hash}`) + + const receipt = await client.waitForTransactionReceipt({ hash }) + if (receipt.status === 'success') { + const newBalance = await client.getBalance({ address: to }) + console.log(`\n Sent successfully!`) + console.log(` Recipient balance: ${formatEther(newBalance)} ETH\n`) + } else { + console.error(`\n Transaction failed\n`) + } +} + +// -- Task Definitions -- + +/** + * Verify a keystore/env variable holds the key for an expected address + * + * Examples: + * npx hardhat eth:check-key --key ARBITRUM_ONE_ORACLE_KEY + */ +export const ethCheckKeyTask = task('eth:check-key', 'Derive and display address from a keystore variable') + .addOption({ + name: 'key', + description: 'Keystore variable name (e.g. ARBITRUM_ONE_ORACLE_KEY)', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: checkKeyAction })) + .build() + +/** + * Query ETH balance for an address + * + * Examples: + * npx hardhat eth:balance --account 0x1234... --network arbitrumOne + */ +export const ethBalanceTask = task('eth:balance', 'Query ETH balance for an address') + .addOption({ + name: 'account', + description: 'Address to query balance for', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: balanceAction })) + .build() + +/** + * Send ETH from deployer to an address + * + * Uses the deployer key from the Hardhat keystore or environment. + * + * Examples: + * npx hardhat eth:fund --to 0x1234... --amount 0.01 --network arbitrumOne + */ +export const ethFundTask = task('eth:fund', 'Send ETH from deployer to an address') + .addOption({ + name: 'to', + description: 'Recipient address', + type: ArgumentType.STRING, + defaultValue: '', + }) + .addOption({ + name: 'amount', + description: 'Amount of ETH to send (e.g. 0.01)', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: fundAction })) + .build() + +export default [ethCheckKeyTask, ethBalanceTask, ethFundTask] diff --git a/packages/deployment/tasks/execute-governance.ts b/packages/deployment/tasks/execute-governance.ts index ea405265d..2fb205a74 100644 --- a/packages/deployment/tasks/execute-governance.ts +++ b/packages/deployment/tasks/execute-governance.ts @@ -1,50 +1,11 @@ import fs from 'fs' -import { configVariable, task } from 'hardhat/config' +import { task } from 'hardhat/config' import type { NewTaskActionFunction } from 'hardhat/types/tasks' import path from 'path' +import { autoDetectForkNetwork } from '../lib/address-book-utils.js' import { executeGovernanceTxs } from '../lib/execute-governance.js' - -/** - * Convert network name to env var prefix: arbitrumSepolia → ARBITRUM_SEPOLIA - */ -function networkToEnvPrefix(networkName: string): string { - return networkName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() -} - -/** - * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) - * - * Uses hre.hooks.runHandlerChain to go through the configurationVariables fetchValue - * hook chain, which includes the keystore plugin. - */ -async function resolveConfigVar(hre: unknown, name: string): Promise { - try { - const variable = configVariable(name) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hooks = (hre as any).hooks - - // Call the configurationVariables fetchValue hook chain - // Falls back to env var if not in keystore - const value = await hooks.runHandlerChain( - 'configurationVariables', - 'fetchValue', - [variable], - // Default handler: read from environment variable - async (_context: unknown, v: { name: string }) => { - const envValue = process.env[v.name] - if (typeof envValue !== 'string') { - throw new Error(`Environment variable ${v.name} not found`) - } - return envValue - }, - ) - return value - } catch { - // Key not configured in keystore or env - return undefined - } -} +import { networkToEnvPrefix, resolveConfigVar } from '../lib/task-utils.js' /** * Resolve governor key for a network. @@ -79,17 +40,17 @@ interface TaskArgs { * npx hardhat keystore set ARBITRUM_SEPOLIA_GOVERNOR_KEY * npx hardhat deploy:execute-governance --network arbitrumSepolia * - * For fork testing: - * FORK_NETWORK=arbitrumSepolia npx hardhat deploy:execute-governance --network fork + * For fork testing (auto-detects fork network from anvil): + * npx hardhat deploy:execute-governance --network fork */ const action: NewTaskActionFunction = async (_taskArgs, hre) => { + // Auto-detect fork network from anvil before checking + await autoDetectForkNetwork() + // HH v3: Connect to network to get network connection // eslint-disable-next-line @typescript-eslint/no-explicit-any const conn = await (hre as any).network.connect() - // Get governor key: try network-specific first, fall back to generic - const governorPrivateKey = await resolveGovernorKey(hre, conn.networkName) - // Create minimal Environment-like object for executeGovernanceTxs const env = { name: conn.networkName, @@ -112,8 +73,11 @@ const action: NewTaskActionFunction = async (_taskArgs, hre) => { }, } + // Lazy resolver for governor key - only called when actually needed (non-fork EOA mode) + const resolveKey = () => resolveGovernorKey(hre, conn.networkName) + // eslint-disable-next-line @typescript-eslint/no-explicit-any - await executeGovernanceTxs(env as any, { governorPrivateKey }) + await executeGovernanceTxs(env as any, { resolveGovernorKey: resolveKey }) } const executeGovernanceTask = task( diff --git a/packages/deployment/tasks/grant-role.ts b/packages/deployment/tasks/grant-role.ts index daea22f3a..df28572e7 100644 --- a/packages/deployment/tasks/grant-role.ts +++ b/packages/deployment/tasks/grant-role.ts @@ -1,4 +1,4 @@ -import { configVariable, task } from 'hardhat/config' +import { task } from 'hardhat/config' import { ArgumentType } from 'hardhat/types/arguments' import type { NewTaskActionFunction } from 'hardhat/types/tasks' import { @@ -19,8 +19,13 @@ import { getRoleHash, hasAdminRole, } from '../lib/contract-checks.js' -import { type AddressBookType, CONTRACT_REGISTRY } from '../lib/contract-registry.js' import { createGovernanceTxBuilder } from '../lib/execute-governance.js' +import { + getContractAddress, + getDeployerKeyName, + resolveConfigVar, + resolveContractFromRegistry, +} from '../lib/task-utils.js' import { graph } from '../rocketh/deploy.js' interface TaskArgs { @@ -30,73 +35,6 @@ interface TaskArgs { account: string } -/** - * Convert network name to env var prefix: arbitrumSepolia → ARBITRUM_SEPOLIA - */ -function networkToEnvPrefix(networkName: string): string { - return networkName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() -} - -/** - * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) - */ -async function resolveConfigVar(hre: unknown, name: string): Promise { - try { - const variable = configVariable(name) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hooks = (hre as any).hooks - - const value = await hooks.runHandlerChain( - 'configurationVariables', - 'fetchValue', - [variable], - async (_context: unknown, v: { name: string }) => { - const envValue = process.env[v.name] - if (typeof envValue !== 'string') { - throw new Error(`Variable ${v.name} not found`) - } - return envValue - }, - ) - return value - } catch { - return undefined - } -} - -/** - * Resolve contract from registry by name - */ -function resolveContractFromRegistry( - contractName: string, -): { addressBook: AddressBookType; roles: readonly string[] } | null { - for (const [book, contracts] of Object.entries(CONTRACT_REGISTRY)) { - const contract = contracts[contractName as keyof typeof contracts] as { roles?: readonly string[] } | undefined - if (contract?.roles) { - return { addressBook: book as AddressBookType, roles: contract.roles } - } - } - return null -} - -/** - * Get contract address from address book - */ -function getContractAddress(addressBook: AddressBookType, contractName: string, chainId: number): string | null { - const book = - addressBook === 'issuance' - ? graph.getIssuanceAddressBook(chainId) - : addressBook === 'horizon' - ? graph.getHorizonAddressBook(chainId) - : graph.getSubgraphServiceAddressBook(chainId) - - if (!book.entryExists(contractName)) { - return null - } - - return book.getEntry(contractName)?.address ?? null -} - const action: NewTaskActionFunction = async (taskArgs, hre) => { const contractName = taskArgs.contract || undefined const addressArg = taskArgs.address || undefined @@ -128,6 +66,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { }) as PublicClient const actualChainId = await client.getChainId() + await graph.autoDetect() const forkChainId = graph.getForkTargetChainId() const targetChainId = forkChainId ?? actualChainId @@ -184,7 +123,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { console.log(` Admin holders: ${adminInfo.adminMembers.length > 0 ? adminInfo.adminMembers.join(', ') : '(none)'}`) // Get deployer account (from keystore or env var) - const keyName = `${networkToEnvPrefix(networkName === 'fork' ? (process.env.HARDHAT_FORK ?? 'arbitrumSepolia') : networkName)}_DEPLOYER_KEY` + const keyName = getDeployerKeyName(networkName) const deployerKey = await resolveConfigVar(hre, keyName) let deployer: string | undefined @@ -206,7 +145,8 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { console.log(`\n Deployer has ${adminInfo.adminRoleName ?? 'admin role'}, executing directly...`) // Execute directly - const hash = await walletClient.writeContract({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).writeContract({ address: contractAddress as `0x${string}`, abi: ACCESS_CONTROL_ENUMERABLE_ABI, functionName: 'grantRole', @@ -266,12 +206,12 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { * Grant a role to an account on a BaseUpgradeable contract * * Examples: - * npx hardhat roles:grant --contract RewardsEligibilityOracle --role ORACLE_ROLE --account 0x... --network arbitrumSepolia + * npx hardhat roles:grant --contract RewardsEligibilityOracleA --role ORACLE_ROLE --account 0x... --network arbitrumSepolia */ const grantRoleTask = task('roles:grant', 'Grant a role to an account') .addOption({ name: 'contract', - description: 'Contract name from registry (e.g., RewardsEligibilityOracle)', + description: 'Contract name from registry (e.g., RewardsEligibilityOracleA)', type: ArgumentType.STRING, defaultValue: '', }) diff --git a/packages/deployment/tasks/grt-tasks.ts b/packages/deployment/tasks/grt-tasks.ts new file mode 100644 index 000000000..1a8ffa099 --- /dev/null +++ b/packages/deployment/tasks/grt-tasks.ts @@ -0,0 +1,449 @@ +import { task } from 'hardhat/config' +import { ArgumentType } from 'hardhat/types/arguments' +import type { NewTaskActionFunction } from 'hardhat/types/tasks' +import { createPublicClient, createWalletClient, custom, formatEther, parseEther, type PublicClient } from 'viem' +import { privateKeyToAccount } from 'viem/accounts' + +import { GRAPH_TOKEN_ABI } from '../lib/abis.js' +import { getDeployerKeyName, resolveConfigVar } from '../lib/task-utils.js' +import { graph } from '../rocketh/deploy.js' + +// governor() is on the Governed base contract, not in IGraphToken +const GOVERNED_ABI = [ + { + inputs: [], + name: 'governor', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, +] as const + +/** + * Get L2GraphToken address from horizon address book + */ +function getGraphTokenAddress(chainId: number): string | null { + const book = graph.getHorizonAddressBook(chainId) + if (!book.entryExists('L2GraphToken')) { + return null + } + return book.getEntry('L2GraphToken')?.address ?? null +} + +// -- Task Types -- + +interface EmptyArgs { + // No arguments +} + +interface BalanceArgs { + account: string +} + +interface TransferArgs { + to: string + amount: string +} + +interface MintArgs { + to: string + amount: string +} + +// -- Task Actions -- + +/** + * Query GRT balance for an address + */ +const balanceAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.account) { + console.error('\nError: --account is required') + console.error('Usage: npx hardhat grt:balance --account 0x... --network arbitrumSepolia') + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + const tokenAddress = getGraphTokenAddress(targetChainId) + if (!tokenAddress) { + console.error(`\nError: L2GraphToken not found in address book for chain ${targetChainId}`) + return + } + + const account = taskArgs.account as `0x${string}` + + const balance = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'balanceOf', + args: [account], + })) as bigint + + console.log(`\nGRT Balance`) + console.log(` Account: ${account}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Token: ${tokenAddress}`) + console.log(` Balance: ${formatEther(balance)} GRT`) + console.log() +} + +/** + * Transfer GRT from deployer to an address + */ +const transferAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.to || !taskArgs.amount) { + console.error('\nError: --to and --amount are required') + console.error('Usage: npx hardhat grt:transfer --to 0x... --amount 10000 --network arbitrumSepolia') + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + const tokenAddress = getGraphTokenAddress(targetChainId) + if (!tokenAddress) { + console.error(`\nError: L2GraphToken not found in address book for chain ${targetChainId}`) + return + } + + // Get deployer key + const keyName = getDeployerKeyName(networkName) + const deployerKey = await resolveConfigVar(hre, keyName) + + if (!deployerKey) { + console.error('\nError: No deployer key configured.') + console.error(`Set via keystore: npx hardhat keystore set ${keyName}`) + console.error(`Or environment: export ${keyName}=0x...`) + return + } + + const account = privateKeyToAccount(deployerKey as `0x${string}`) + const to = taskArgs.to as `0x${string}` + const amount = parseEther(taskArgs.amount) + + // Check deployer balance + const balance = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'balanceOf', + args: [account.address], + })) as bigint + + if (balance < amount) { + console.error(`\nError: Insufficient balance`) + console.error(` Deployer balance: ${formatEther(balance)} GRT`) + console.error(` Requested: ${taskArgs.amount} GRT`) + return + } + + console.log(`\nTransferring GRT`) + console.log(` From: ${account.address}`) + console.log(` To: ${to}`) + console.log(` Amount: ${taskArgs.amount} GRT`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Token: ${tokenAddress}`) + + const walletClient = createWalletClient({ + account, + transport: custom(conn.provider), + }) + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).writeContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'transfer', + args: [to, amount], + }) + + console.log(` TX: ${hash}`) + + const receipt = await client.waitForTransactionReceipt({ hash }) + if (receipt.status === 'success') { + const newBalance = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'balanceOf', + args: [to], + })) as bigint + + console.log(`\n Transferred successfully!`) + console.log(` Recipient balance: ${formatEther(newBalance)} GRT\n`) + } else { + console.error(`\n Transaction failed\n`) + } +} + +/** + * Mint GRT to an address (requires deployer to be a minter) + */ +const mintAction: NewTaskActionFunction = async (taskArgs, hre) => { + if (!taskArgs.to || !taskArgs.amount) { + console.error('\nError: --to and --amount are required') + console.error('Usage: npx hardhat grt:mint --to 0x... --amount 10000 --network arbitrumSepolia') + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + const tokenAddress = getGraphTokenAddress(targetChainId) + if (!tokenAddress) { + console.error(`\nError: L2GraphToken not found in address book for chain ${targetChainId}`) + return + } + + // Get deployer key + const keyName = getDeployerKeyName(networkName) + const deployerKey = await resolveConfigVar(hre, keyName) + + if (!deployerKey) { + console.error('\nError: No deployer key configured.') + console.error(`Set via keystore: npx hardhat keystore set ${keyName}`) + console.error(`Or environment: export ${keyName}=0x...`) + return + } + + const account = privateKeyToAccount(deployerKey as `0x${string}`) + const to = taskArgs.to as `0x${string}` + const amount = parseEther(taskArgs.amount) + + // Check deployer is a minter + const isMinter = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'isMinter', + args: [account.address], + })) as boolean + + if (!isMinter) { + console.error(`\nError: Deployer ${account.address} is not a minter on GraphToken`) + console.error('The deployer must be added as a minter by the governor first.') + return + } + + console.log(`\nMinting GRT`) + console.log(` To: ${to}`) + console.log(` Amount: ${taskArgs.amount} GRT`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Token: ${tokenAddress}`) + console.log(` Minter: ${account.address}`) + + const walletClient = createWalletClient({ + account, + transport: custom(conn.provider), + }) + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).writeContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'mint', + args: [to, amount], + }) + + console.log(` TX: ${hash}`) + + const receipt = await client.waitForTransactionReceipt({ hash }) + if (receipt.status === 'success') { + // Read new balance + const newBalance = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'balanceOf', + args: [to], + })) as bigint + + console.log(`\n Minted successfully!`) + console.log(` New balance: ${formatEther(newBalance)} GRT\n`) + } else { + console.error(`\n Transaction failed\n`) + } +} + +/** + * Show GRT token status: governor, deployer minter check, total supply + */ +const statusAction: NewTaskActionFunction = async (_taskArgs, hre) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + const tokenAddress = getGraphTokenAddress(targetChainId) + if (!tokenAddress) { + console.error(`\nError: L2GraphToken not found in address book for chain ${targetChainId}`) + return + } + + // Read token info in parallel + const [governor, totalSupply] = await Promise.all([ + client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GOVERNED_ABI, + functionName: 'governor', + }) as Promise, + client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'totalSupply', + }) as Promise, + ]) + + console.log(`\nGRT Token Status`) + console.log(` Token: ${tokenAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Total supply: ${formatEther(totalSupply)} GRT`) + console.log(` Governor: ${governor}`) + + // Check if governor is a minter + const governorIsMinter = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'isMinter', + args: [governor as `0x${string}`], + })) as boolean + console.log(` Governor is minter: ${governorIsMinter ? 'yes' : 'no'}`) + + // Check deployer if key is available + const keyName = getDeployerKeyName(networkName) + const deployerKey = await resolveConfigVar(hre, keyName) + + if (deployerKey) { + const deployer = privateKeyToAccount(deployerKey as `0x${string}`) + const deployerIsMinter = (await client.readContract({ + address: tokenAddress as `0x${string}`, + abi: GRAPH_TOKEN_ABI, + functionName: 'isMinter', + args: [deployer.address], + })) as boolean + + console.log(`\n Deployer: ${deployer.address}`) + console.log(` Deployer is minter: ${deployerIsMinter ? 'yes' : 'no'}`) + console.log(` Deployer is governor: ${deployer.address.toLowerCase() === governor.toLowerCase() ? 'yes' : 'no'}`) + + if (!deployerIsMinter) { + console.log(`\n To add deployer as minter, the governor must call:`) + console.log(` addMinter(${deployer.address})`) + } + } else { + console.log(`\n Deployer key not configured (${keyName})`) + } + + console.log() +} + +// -- Task Definitions -- + +/** + * Show GRT token status: governor, deployer minter status, total supply + * + * Examples: + * npx hardhat grt:status --network arbitrumSepolia + */ +export const grtStatusTask = task('grt:status', 'Show GRT token status (governor, minter, supply)') + .setAction(async () => ({ default: statusAction })) + .build() + +/** + * Query GRT balance for an address + * + * Examples: + * npx hardhat grt:balance --account 0x1234... --network arbitrumSepolia + */ +export const grtBalanceTask = task('grt:balance', 'Query GRT balance for an address') + .addOption({ + name: 'account', + description: 'Address to query balance for', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: balanceAction })) + .build() + +/** + * Transfer testnet GRT from deployer to an address + * + * Uses the deployer's existing balance. No minter role needed. + * + * Examples: + * npx hardhat grt:transfer --to 0x1234... --amount 10000 --network arbitrumSepolia + */ +export const grtTransferTask = task('grt:transfer', 'Transfer GRT from deployer to an address') + .addOption({ + name: 'to', + description: 'Recipient address', + type: ArgumentType.STRING, + defaultValue: '', + }) + .addOption({ + name: 'amount', + description: 'Amount of GRT to transfer (in whole tokens, e.g. 10000)', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: transferAction })) + .build() + +/** + * Mint testnet GRT to an address + * + * Requires deployer to be a minter on the GraphToken contract. + * The deployer/governor is a minter by default after deployment. + * + * Examples: + * npx hardhat grt:mint --to 0x1234... --amount 10000 --network arbitrumSepolia + */ +export const grtMintTask = task('grt:mint', 'Mint testnet GRT to an address') + .addOption({ + name: 'to', + description: 'Recipient address', + type: ArgumentType.STRING, + defaultValue: '', + }) + .addOption({ + name: 'amount', + description: 'Amount of GRT to mint (in whole tokens, e.g. 10000)', + type: ArgumentType.STRING, + defaultValue: '', + }) + .setAction(async () => ({ default: mintAction })) + .build() + +export default [grtStatusTask, grtBalanceTask, grtTransferTask, grtMintTask] diff --git a/packages/deployment/tasks/list-pending-implementations.ts b/packages/deployment/tasks/list-pending-implementations.ts index 3d85f50a4..76b0d4553 100644 --- a/packages/deployment/tasks/list-pending-implementations.ts +++ b/packages/deployment/tasks/list-pending-implementations.ts @@ -5,6 +5,7 @@ import type { NewTaskActionFunction } from 'hardhat/types/tasks' import type { AddressBookEntry, AddressBookOps } from '../lib/address-book-ops.js' import { + autoDetectForkNetwork, getForkTargetChainId, getHorizonAddressBook, getIssuanceAddressBook, @@ -33,6 +34,9 @@ const action: NewTaskActionFunction = async (_taskArgs, hre) => { const conn = await (hre as any).network.connect() const networkName = conn.networkName + // Auto-detect fork network from anvil before checking + await autoDetectForkNetwork() + // Get target chain ID (fork mode or provider) const forkChainId = getForkTargetChainId() let targetChainId: number diff --git a/packages/deployment/tasks/list-roles.ts b/packages/deployment/tasks/list-roles.ts index 1f0a8a4ac..46af75366 100644 --- a/packages/deployment/tasks/list-roles.ts +++ b/packages/deployment/tasks/list-roles.ts @@ -4,12 +4,8 @@ import type { NewTaskActionFunction } from 'hardhat/types/tasks' import { createPublicClient, custom, type PublicClient } from 'viem' import { enumerateContractRoles, type RoleInfo } from '../lib/contract-checks.js' -import { - type AddressBookType, - CONTRACT_REGISTRY, - Contracts, - type IssuanceContractName, -} from '../lib/contract-registry.js' +import { Contracts, type IssuanceContractName } from '../lib/contract-registry.js' +import { getContractAddress, resolveContractFromRegistry } from '../lib/task-utils.js' import { graph } from '../rocketh/deploy.js' interface TaskArgs { @@ -52,43 +48,6 @@ function printRoleInfo(role: RoleInfo, knownRoles: RoleInfo[]): void { } } -/** - * Resolve contract from registry by name - * - * Searches across all address books for a matching contract name. - * Returns the contract metadata and address book type if found. - */ -function resolveContractFromRegistry( - contractName: string, -): { addressBook: AddressBookType; roles: readonly string[] } | null { - // Search issuance first (most likely for this use case) - for (const [book, contracts] of Object.entries(CONTRACT_REGISTRY)) { - const contract = contracts[contractName as keyof typeof contracts] as { roles?: readonly string[] } | undefined - if (contract?.roles) { - return { addressBook: book as AddressBookType, roles: contract.roles } - } - } - return null -} - -/** - * Get contract address from address book - */ -function getContractAddress(addressBook: AddressBookType, contractName: string, chainId: number): string | null { - const book = - addressBook === 'issuance' - ? graph.getIssuanceAddressBook(chainId) - : addressBook === 'horizon' - ? graph.getHorizonAddressBook(chainId) - : graph.getSubgraphServiceAddressBook(chainId) - - if (!book.entryExists(contractName)) { - return null - } - - return book.getEntry(contractName)?.address ?? null -} - const action: NewTaskActionFunction = async (taskArgs, hre) => { // Empty strings treated as not provided const contractName = taskArgs.contract || undefined @@ -97,7 +56,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { // Validate: must provide either --contract or --address if (!contractName && !address) { console.error('\nError: Must provide either --contract or --address') - console.error(' --contract Contract name from registry (e.g., RewardsEligibilityOracle)') + console.error(' --contract Contract name from registry (e.g., RewardsEligibilityOracleA)') console.error(' --address Contract address (requires known role list)\n') return } @@ -115,6 +74,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { const actualChainId = await client.getChainId() // Determine target chain ID (handle fork mode) + await graph.autoDetect() const forkChainId = graph.getForkTargetChainId() const targetChainId = forkChainId ?? actualChainId @@ -189,13 +149,13 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { * List all role holders for a BaseUpgradeable contract * * Examples: - * npx hardhat roles:list --contract RewardsEligibilityOracle --network arbitrumSepolia + * npx hardhat roles:list --contract RewardsEligibilityOracleA --network arbitrumSepolia * npx hardhat roles:list --address 0x62c2... --network arbitrumSepolia */ const listRolesTask = task('roles:list', 'List all role holders for a contract') .addOption({ name: 'contract', - description: 'Contract name from registry (e.g., RewardsEligibilityOracle)', + description: 'Contract name from registry (e.g., RewardsEligibilityOracleA)', type: ArgumentType.STRING, defaultValue: '', }) diff --git a/packages/deployment/tasks/reo-tasks.ts b/packages/deployment/tasks/reo-tasks.ts new file mode 100644 index 000000000..4489ee3ce --- /dev/null +++ b/packages/deployment/tasks/reo-tasks.ts @@ -0,0 +1,597 @@ +import { task } from 'hardhat/config' +import type { NewTaskActionFunction } from 'hardhat/types/tasks' +import { + createPublicClient, + createWalletClient, + custom, + encodeFunctionData, + type PublicClient, + type WalletClient, +} from 'viem' +import { privateKeyToAccount } from 'viem/accounts' + +import { PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, REWARDS_ELIGIBILITY_ORACLE_ABI } from '../lib/abis.js' +import { accountHasRole, enumerateContractRoles, getRoleHash } from '../lib/contract-checks.js' +import { createGovernanceTxBuilder } from '../lib/execute-governance.js' +import { formatDuration, formatTimestamp, getDeployerKeyName, resolveConfigVar } from '../lib/task-utils.js' +import { graph } from '../rocketh/deploy.js' + +// -- Types -- + +type REOInstance = 'A' | 'B' | 'Mock' + +const VALID_INSTANCES: REOInstance[] = ['A', 'B', 'Mock'] + +interface TaskArgs { + instance: string +} + +/** + * Get address book entry name for an REO instance + */ +function reoEntryName(instance: REOInstance): string { + return `RewardsEligibilityOracle${instance}` +} + +/** + * Get REO address from issuance address book for a specific instance + */ +function getREOAddress(chainId: number, instance: REOInstance): string | null { + const book = graph.getIssuanceAddressBook(chainId) + const name = reoEntryName(instance) as Parameters[0] + if (!book.entryExists(name)) { + return null + } + return book.getEntry(name)?.address ?? null +} + +/** + * Parse and validate --instance flag. Returns null if invalid. + * Accepts case-insensitive input: "a", "A", "b", "B", "mock", "Mock" + */ +function parseInstance(raw: string): REOInstance | null { + const lower = raw.toLowerCase() + const mapping: Record = { a: 'A', b: 'B', mock: 'Mock' } + return mapping[lower] ?? null +} + +// -- Enable/Disable Shared Logic -- + +interface SetValidationArgs { + enabled: boolean + instance: REOInstance + hre: unknown +} + +async function setEligibilityValidation({ enabled, instance, hre }: SetValidationArgs): Promise { + const action = enabled ? 'Enable' : 'Disable' + const actionLower = enabled ? 'enable' : 'disable' + + // Connect to network + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + // Create viem client + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + // Get REO address + const reoAddress = getREOAddress(targetChainId, instance) + if (!reoAddress) { + console.error(`\nError: ${reoEntryName(instance)} not found in address book for chain ${targetChainId}`) + return + } + + // Check current state + const currentState = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityValidation', + })) as boolean + + if (currentState === enabled) { + console.log(`\n✓ [${instance}] Eligibility validation already ${actionLower}d`) + console.log(' No action needed.\n') + return + } + + // Get OPERATOR_ROLE hash + const operatorRoleHash = await getRoleHash(client, reoAddress, 'OPERATOR_ROLE') + if (!operatorRoleHash) { + console.error('\nError: Could not read OPERATOR_ROLE from contract') + return + } + + console.log(`\n🔧 ${action} Eligibility Validation [Instance ${instance}]`) + console.log(` Contract: ${reoAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Current: ${currentState ? 'enabled' : 'disabled'}`) + console.log(` Target: ${enabled ? 'enabled' : 'disabled'}`) + + // Get deployer account (from keystore or env var) + const keyName = getDeployerKeyName(networkName) + const deployerKey = await resolveConfigVar(hre, keyName) + + let deployer: string | undefined + let walletClient: WalletClient | undefined + + if (deployerKey) { + const account = privateKeyToAccount(deployerKey as `0x${string}`) + deployer = account.address + walletClient = createWalletClient({ + account, + transport: custom(conn.provider), + }) + } + + // Check if deployer has OPERATOR_ROLE + const canExecuteDirectly = deployer ? await accountHasRole(client, reoAddress, operatorRoleHash, deployer) : false + + if (canExecuteDirectly && walletClient && deployer) { + console.log(`\n Deployer has OPERATOR_ROLE, executing directly...`) + + // Execute directly + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).writeContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'setEligibilityValidation', + args: [enabled], + }) + + console.log(` TX: ${hash}`) + + // Wait for confirmation + const receipt = await client.waitForTransactionReceipt({ hash }) + if (receipt.status === 'success') { + console.log(`\n✓ [${instance}] Eligibility validation ${actionLower}d successfully\n`) + } else { + console.error(`\n✗ Transaction failed\n`) + } + } else { + // Generate governance TX + console.log(`\n Requires OPERATOR_ROLE to ${actionLower}`) + console.log(' Generating governance TX...') + + // Create a minimal environment for the TxBuilder + const env = { + name: networkName, + network: { provider: conn.provider }, + showMessage: console.log, + } + + const txName = `reo-${instance.toLowerCase()}-${actionLower}-validation` + const builder = await createGovernanceTxBuilder(env as Parameters[0], txName, { + name: `${action} REO ${instance} Validation`, + description: `${action} eligibility validation on ${reoEntryName(instance)}`, + }) + + // Encode the setEligibilityValidation call + const data = encodeFunctionData({ + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'setEligibilityValidation', + args: [enabled], + }) + + builder.addTx({ + to: reoAddress, + data, + value: '0', + }) + + const txFile = builder.saveToFile() + console.log(`\n✓ Governance TX saved: ${txFile}`) + console.log('\nNext steps:') + console.log(' • Fork testing: npx hardhat deploy:execute-governance --network fork') + console.log(' • Safe multisig: Upload JSON to Transaction Builder') + console.log('') + } +} + +// -- Status for a single instance -- + +async function showInstanceStatus( + client: PublicClient, + reoAddress: string, + instance: REOInstance, + networkName: string, + targetChainId: number, +): Promise { + // Mock has a simplified status (no roles, no validation toggle, no oracle) + if (instance === 'Mock') { + console.log(`\n📊 RewardsEligibilityOracle Mock Status`) + console.log(` Address: ${reoAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + console.log(` Type: MockRewardsEligibilityOracle (testnet, indexers self-manage eligibility)`) + console.log() + return + } + + console.log(`\n📊 RewardsEligibilityOracle ${instance} Status`) + console.log(` Address: ${reoAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + + // Read all status values + const [validationEnabled, eligibilityPeriod, oracleUpdateTimeout, lastOracleUpdateTime] = await Promise.all([ + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityValidation', + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityPeriod', + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getOracleUpdateTimeout', + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getLastOracleUpdateTime', + }) as Promise, + ]) + + // Calculate derived states + const now = BigInt(Math.floor(Date.now() / 1000)) + const timeSinceLastUpdate = lastOracleUpdateTime > 0n ? now - lastOracleUpdateTime : null + const timeoutExceeded = timeSinceLastUpdate !== null && timeSinceLastUpdate > oracleUpdateTimeout + const effectivelyDisabled = !validationEnabled || timeoutExceeded + + // Configuration section + console.log(`\n🔧 Configuration`) + console.log(` Validation enabled: ${validationEnabled ? '✓ yes' : '✗ no'}`) + console.log(` Eligibility period: ${formatDuration(eligibilityPeriod)} (${eligibilityPeriod} seconds)`) + console.log(` Oracle timeout: ${formatDuration(oracleUpdateTimeout)} (${oracleUpdateTimeout} seconds)`) + + // Oracle activity section + console.log(`\n📡 Oracle Activity`) + console.log(` Last update: ${formatTimestamp(lastOracleUpdateTime)}`) + if (timeSinceLastUpdate === null) { + console.log(` ⚠️ No oracle updates yet`) + } else if (timeoutExceeded) { + console.log(` ⚠️ Timeout exceeded! All indexers treated as eligible (fail-safe active)`) + } + + // Effective state section + console.log(`\n🎯 Effective State`) + if (effectivelyDisabled) { + console.log(` Status: ✗ DISABLED (all indexers eligible)`) + if (!validationEnabled) { + console.log(` Reason: Validation toggle is off`) + } else if (timeoutExceeded) { + console.log(` Reason: Oracle timeout exceeded (fail-safe)`) + } + } else { + console.log(` Status: ✓ ACTIVE (enforcing eligibility)`) + } + + // Check if RewardsManager is configured to use this REO instance + const horizonBook = graph.getHorizonAddressBook(targetChainId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const rmAddress = (horizonBook as any).entryExists('RewardsManager') + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + (horizonBook as any).getEntry('RewardsManager')?.address + : null + + if (rmAddress) { + try { + const configuredOracle = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, + functionName: 'getProviderEligibilityOracle', + })) as string + + const isConfigured = configuredOracle.toLowerCase() === reoAddress.toLowerCase() + if (isConfigured) { + console.log(` RewardsManager: ✓ using this instance`) + } else if (configuredOracle === '0x0000000000000000000000000000000000000000') { + console.log(` RewardsManager: ✗ no oracle configured`) + } else { + console.log(` RewardsManager: ✗ using different oracle (${configuredOracle})`) + } + } catch { + console.log(` RewardsManager: ? not upgraded yet (getProviderEligibilityOracle not available)`) + } + } + + // Role holders section + console.log(`\n🔐 Role Holders`) + const knownRoles = ['GOVERNOR_ROLE', 'PAUSE_ROLE', 'OPERATOR_ROLE', 'ORACLE_ROLE'] + const result = await enumerateContractRoles(client, reoAddress, knownRoles) + + for (const role of result.roles) { + const memberList = role.members.length > 0 ? role.members.join(', ') : '(none)' + console.log(` ${role.name} (${role.memberCount}): ${memberList}`) + } + + if (result.failedRoles.length > 0) { + console.log(` ⚠️ Failed to read: ${result.failedRoles.join(', ')}`) + } + + console.log() +} + +// -- Indexer listing for a single instance -- + +async function showInstanceIndexers( + client: PublicClient, + reoAddress: string, + instance: REOInstance, + networkName: string, + targetChainId: number, +): Promise { + console.log(`\n📋 RewardsEligibilityOracle ${instance} — Tracked Indexers`) + console.log(` Address: ${reoAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + + // Get indexer count and eligibility period in parallel + const [indexerCount, eligibilityPeriod, validationEnabled] = await Promise.all([ + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getIndexerCount', + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityPeriod', + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityValidation', + }) as Promise, + ]) + + console.log(` Validation: ${validationEnabled ? 'enabled' : 'disabled'}`) + console.log(` Eligibility period: ${formatDuration(eligibilityPeriod)}`) + console.log(` Tracked indexers: ${indexerCount}`) + + if (indexerCount === 0n) { + console.log('\n No indexers tracked.\n') + return + } + + // Fetch all indexer addresses + const indexers = (await client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getIndexers', + })) as `0x${string}`[] + + // Batch-read eligibility and renewal time for each indexer + const details = await Promise.all( + indexers.map(async (indexer) => { + const [eligible, renewalTime] = await Promise.all([ + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'isEligible', + args: [indexer], + }) as Promise, + client.readContract({ + address: reoAddress as `0x${string}`, + abi: REWARDS_ELIGIBILITY_ORACLE_ABI, + functionName: 'getEligibilityRenewalTime', + args: [indexer], + }) as Promise, + ]) + return { indexer, eligible, renewalTime } + }), + ) + + // Sort by renewal time (most recent first), then by address within each group + details.sort((a, b) => { + if (a.renewalTime !== b.renewalTime) { + return a.renewalTime < b.renewalTime ? 1 : -1 + } + return a.indexer.toLowerCase() < b.indexer.toLowerCase() ? -1 : 1 + }) + + // Display results grouped by renewal time with blank lines between groups + let lastRenewalTime: bigint | null = null + for (const { indexer, eligible, renewalTime } of details) { + if (lastRenewalTime !== null && renewalTime !== lastRenewalTime) { + console.log('') + } + lastRenewalTime = renewalTime + const status = eligible ? '✓' : '✗' + console.log(` ${status} ${indexer} renewed ${formatTimestamp(renewalTime)}`) + } + + // Summary + const eligibleCount = details.filter((d) => d.eligible).length + console.log(`\n Summary: ${eligibleCount}/${details.length} eligible\n`) +} + +// -- Task Actions -- + +const enableAction: NewTaskActionFunction = async (taskArgs, hre) => { + const instance = parseInstance(taskArgs.instance) + if (!instance) { + console.error(`\nError: --instance is required (a, b, or mock)`) + return + } + if (instance === 'Mock') { + console.error(`\nError: Mock REO has no validation toggle — it's always active`) + return + } + await setEligibilityValidation({ enabled: true, instance, hre }) +} + +const disableAction: NewTaskActionFunction = async (taskArgs, hre) => { + const instance = parseInstance(taskArgs.instance) + if (!instance) { + console.error(`\nError: --instance is required (a, b, or mock)`) + return + } + if (instance === 'Mock') { + console.error(`\nError: Mock REO has no validation toggle — it's always active`) + return + } + await setEligibilityValidation({ enabled: false, instance, hre }) +} + +const indexersAction: NewTaskActionFunction = async (taskArgs, hre) => { + // Connect to network + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + // Create viem client + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + // Determine which instances to show + const requestedInstance = taskArgs.instance ? parseInstance(taskArgs.instance) : null + const instancesToShow: REOInstance[] = requestedInstance ? [requestedInstance] : VALID_INSTANCES + + let found = false + for (const instance of instancesToShow) { + const reoAddress = getREOAddress(targetChainId, instance) + if (reoAddress) { + found = true + await showInstanceIndexers(client, reoAddress, instance, networkName, targetChainId) + } else if (requestedInstance) { + console.error(`\nError: ${reoEntryName(instance)} not found in address book for chain ${targetChainId}`) + } + } + + if (!found) { + console.error(`\nError: No REO instances found in address book for chain ${targetChainId}`) + } +} + +const statusAction: NewTaskActionFunction = async (taskArgs, hre) => { + // Connect to network + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + // Create viem client + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + // Determine which instances to show + const requestedInstance = taskArgs.instance ? parseInstance(taskArgs.instance) : null + const instancesToShow: REOInstance[] = requestedInstance ? [requestedInstance] : VALID_INSTANCES + + let found = false + for (const instance of instancesToShow) { + const reoAddress = getREOAddress(targetChainId, instance) + if (reoAddress) { + found = true + await showInstanceStatus(client, reoAddress, instance, networkName, targetChainId) + } else if (requestedInstance) { + // Only error if a specific instance was requested and not found + console.error(`\nError: ${reoEntryName(instance)} not found in address book for chain ${targetChainId}`) + } + } + + if (!found) { + console.error(`\nError: No REO instances found in address book for chain ${targetChainId}`) + } +} + +// -- Task Definitions -- + +/** + * Enable eligibility validation on a REO instance + * + * Requires OPERATOR_ROLE. If deployer has the role, executes directly. + * Otherwise generates a governance TX for multisig execution. + * + * Examples: + * npx hardhat reo:enable --instance a --network arbitrumSepolia + */ +export const reoEnableTask = task('reo:enable', 'Enable eligibility validation on a REO instance') + .addOption({ + name: 'instance', + description: 'REO instance (a, b, or mock)', + defaultValue: '', + }) + .setAction(async () => ({ default: enableAction })) + .build() + +/** + * Disable eligibility validation on a REO instance + * + * Requires OPERATOR_ROLE. If deployer has the role, executes directly. + * Otherwise generates a governance TX for multisig execution. + * + * WARNING: When validation is disabled, ALL indexers are treated as eligible. + * + * Examples: + * npx hardhat reo:disable --instance b --network arbitrumSepolia + */ +export const reoDisableTask = task('reo:disable', 'Disable eligibility validation on a REO instance') + .addOption({ + name: 'instance', + description: 'REO instance (a, b, or mock)', + defaultValue: '', + }) + .setAction(async () => ({ default: disableAction })) + .build() + +/** + * Show detailed status of REO instance(s) + * + * Displays configuration, oracle activity, effective state, and role holders. + * If --instance is omitted, shows status for all deployed instances. + * + * Examples: + * npx hardhat reo:status --network arbitrumSepolia # show all + * npx hardhat reo:status --instance a --network arbitrumSepolia # show A only + */ +export const reoStatusTask = task('reo:status', 'Show detailed REO status') + .addOption({ + name: 'instance', + description: 'REO instance (a, b, or mock; omit for all)', + defaultValue: '', + }) + .setAction(async () => ({ default: statusAction })) + .build() + +/** + * List tracked indexers with eligibility info + * + * Shows each indexer's eligibility status, renewal time, and expiry. + * If --instance is omitted, shows indexers for all deployed instances. + * + * Examples: + * npx hardhat reo:indexers --network arbitrumSepolia # show all + * npx hardhat reo:indexers --instance a --network arbitrumSepolia # show A only + */ +export const reoIndexersTask = task('reo:indexers', 'List tracked indexers with eligibility info') + .addOption({ + name: 'instance', + description: 'REO instance (a, b, or mock; omit for all)', + defaultValue: '', + }) + .setAction(async () => ({ default: indexersAction })) + .build() + +export default [reoEnableTask, reoDisableTask, reoStatusTask, reoIndexersTask] diff --git a/packages/deployment/tasks/reset-fork.ts b/packages/deployment/tasks/reset-fork.ts index f64335c3d..ff683423d 100644 --- a/packages/deployment/tasks/reset-fork.ts +++ b/packages/deployment/tasks/reset-fork.ts @@ -4,7 +4,7 @@ import path from 'node:path' import { task } from 'hardhat/config' import type { NewTaskActionFunction } from 'hardhat/types/tasks' -import { getForkNetwork, getForkStateDir } from '../lib/address-book-utils.js' +import { autoDetectForkNetwork, getForkNetwork, getForkStateDir } from '../lib/address-book-utils.js' interface TaskArgs { // No arguments for this task @@ -27,6 +27,8 @@ const action: NewTaskActionFunction = async (_taskArgs, hre) => { const conn = await (hre as any).network.connect() const networkName = conn.networkName + // Auto-detect fork network from anvil before checking + await autoDetectForkNetwork() const forkNetwork = getForkNetwork() if (!forkNetwork) { diff --git a/packages/deployment/tasks/revoke-role.ts b/packages/deployment/tasks/revoke-role.ts index 029d23336..10f239508 100644 --- a/packages/deployment/tasks/revoke-role.ts +++ b/packages/deployment/tasks/revoke-role.ts @@ -1,4 +1,4 @@ -import { configVariable, task } from 'hardhat/config' +import { task } from 'hardhat/config' import { ArgumentType } from 'hardhat/types/arguments' import type { NewTaskActionFunction } from 'hardhat/types/tasks' import { @@ -19,8 +19,13 @@ import { getRoleHash, hasAdminRole, } from '../lib/contract-checks.js' -import { type AddressBookType, CONTRACT_REGISTRY } from '../lib/contract-registry.js' import { createGovernanceTxBuilder } from '../lib/execute-governance.js' +import { + getContractAddress, + getDeployerKeyName, + resolveConfigVar, + resolveContractFromRegistry, +} from '../lib/task-utils.js' import { graph } from '../rocketh/deploy.js' interface TaskArgs { @@ -30,73 +35,6 @@ interface TaskArgs { account: string } -/** - * Convert network name to env var prefix: arbitrumSepolia → ARBITRUM_SEPOLIA - */ -function networkToEnvPrefix(networkName: string): string { - return networkName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() -} - -/** - * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) - */ -async function resolveConfigVar(hre: unknown, name: string): Promise { - try { - const variable = configVariable(name) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hooks = (hre as any).hooks - - const value = await hooks.runHandlerChain( - 'configurationVariables', - 'fetchValue', - [variable], - async (_context: unknown, v: { name: string }) => { - const envValue = process.env[v.name] - if (typeof envValue !== 'string') { - throw new Error(`Variable ${v.name} not found`) - } - return envValue - }, - ) - return value - } catch { - return undefined - } -} - -/** - * Resolve contract from registry by name - */ -function resolveContractFromRegistry( - contractName: string, -): { addressBook: AddressBookType; roles: readonly string[] } | null { - for (const [book, contracts] of Object.entries(CONTRACT_REGISTRY)) { - const contract = contracts[contractName as keyof typeof contracts] as { roles?: readonly string[] } | undefined - if (contract?.roles) { - return { addressBook: book as AddressBookType, roles: contract.roles } - } - } - return null -} - -/** - * Get contract address from address book - */ -function getContractAddress(addressBook: AddressBookType, contractName: string, chainId: number): string | null { - const book = - addressBook === 'issuance' - ? graph.getIssuanceAddressBook(chainId) - : addressBook === 'horizon' - ? graph.getHorizonAddressBook(chainId) - : graph.getSubgraphServiceAddressBook(chainId) - - if (!book.entryExists(contractName)) { - return null - } - - return book.getEntry(contractName)?.address ?? null -} - const action: NewTaskActionFunction = async (taskArgs, hre) => { const contractName = taskArgs.contract || undefined const addressArg = taskArgs.address || undefined @@ -128,6 +66,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { }) as PublicClient const actualChainId = await client.getChainId() + await graph.autoDetect() const forkChainId = graph.getForkTargetChainId() const targetChainId = forkChainId ?? actualChainId @@ -184,7 +123,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { console.log(` Admin holders: ${adminInfo.adminMembers.length > 0 ? adminInfo.adminMembers.join(', ') : '(none)'}`) // Get deployer account - const keyName = `${networkToEnvPrefix(networkName === 'fork' ? (process.env.HARDHAT_FORK ?? 'arbitrumSepolia') : networkName)}_DEPLOYER_KEY` + const keyName = getDeployerKeyName(networkName) const deployerKey = await resolveConfigVar(hre, keyName) let deployer: string | undefined @@ -206,7 +145,8 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { console.log(`\n Deployer has ${adminInfo.adminRoleName ?? 'admin role'}, executing directly...`) // Execute directly - const hash = await walletClient.writeContract({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hash = await (walletClient as any).writeContract({ address: contractAddress as `0x${string}`, abi: ACCESS_CONTROL_ENUMERABLE_ABI, functionName: 'revokeRole', @@ -266,12 +206,12 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { * Revoke a role from an account on a BaseUpgradeable contract * * Examples: - * npx hardhat roles:revoke --contract RewardsEligibilityOracle --role ORACLE_ROLE --account 0x... --network arbitrumSepolia + * npx hardhat roles:revoke --contract RewardsEligibilityOracleA --role ORACLE_ROLE --account 0x... --network arbitrumSepolia */ const revokeRoleTask = task('roles:revoke', 'Revoke a role from an account') .addOption({ name: 'contract', - description: 'Contract name from registry (e.g., RewardsEligibilityOracle)', + description: 'Contract name from registry (e.g., RewardsEligibilityOracleA)', type: ArgumentType.STRING, defaultValue: '', }) diff --git a/packages/deployment/tasks/ss-tasks.ts b/packages/deployment/tasks/ss-tasks.ts new file mode 100644 index 000000000..6479fa681 --- /dev/null +++ b/packages/deployment/tasks/ss-tasks.ts @@ -0,0 +1,306 @@ +import { task } from 'hardhat/config' +import type { NewTaskActionFunction } from 'hardhat/types/tasks' +import { createPublicClient, custom, type PublicClient } from 'viem' + +// Minimal ABI for RewardsManager public storage variable (not in the IRewardsManager interface) +const REWARDS_MANAGER_SIGNAL_ABI = [ + { + inputs: [], + name: 'minimumSubgraphSignal', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, +] as const +import { formatGRT } from '../lib/format.js' +import { formatDuration } from '../lib/task-utils.js' +import { graph } from '../rocketh/deploy.js' + +// -- ABIs -- + +// Minimal ABI for SubgraphService view functions +const SUBGRAPH_SERVICE_ABI = [ + { + inputs: [], + name: 'getProvisionTokensRange', + outputs: [{ type: 'uint256' }, { type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getDelegationRatio', + outputs: [{ type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'stakeToFeesRatio', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'curationFeesCut', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'maxPOIStaleness', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getThawingPeriodRange', + outputs: [{ type: 'uint64' }, { type: 'uint64' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getVerifierCutRange', + outputs: [{ type: 'uint32' }, { type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getDisputeManager', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getGraphTallyCollector', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getCuration', + outputs: [{ type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getBlockClosingAllocationWithActiveAgreement', + outputs: [{ type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, +] as const + +// -- Helpers -- + +const PPM = 1_000_000 + +function formatPPM(value: bigint | number): string { + const pct = (Number(value) / PPM) * 100 + return `${pct}% (${value} PPM)` +} + +// -- Task Action -- + +const statusAction: NewTaskActionFunction = async (_taskArgs, hre) => { + // Connect to network + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const conn = await (hre as any).network.connect() + const networkName = conn.networkName + + const client = createPublicClient({ + transport: custom(conn.provider), + }) as PublicClient + + const actualChainId = await client.getChainId() + await graph.autoDetect() + const forkChainId = graph.getForkTargetChainId() + const targetChainId = forkChainId ?? actualChainId + + // Get SubgraphService address + const ssBook = graph.getSubgraphServiceAddressBook(targetChainId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const ssAddress = (ssBook as any).entryExists('SubgraphService') + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + (ssBook as any).getEntry('SubgraphService')?.address + : null + + if (!ssAddress) { + console.error(`\nError: SubgraphService not found in address book for chain ${targetChainId}`) + return + } + + // Get RewardsManager address + const horizonBook = graph.getHorizonAddressBook(targetChainId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const rmAddress = (horizonBook as any).entryExists('RewardsManager') + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + (horizonBook as any).getEntry('RewardsManager')?.address + : null + + console.log(`\n📊 SubgraphService Status`) + console.log(` Address: ${ssAddress}`) + console.log(` Network: ${networkName} (chainId: ${targetChainId})`) + + // Batch-read all SubgraphService parameters + const [ + provisionRange, + delegationRatio, + stakeToFees, + curationCut, + poiStaleness, + thawingRange, + verifierCutRange, + disputeManager, + tallyCollector, + curation, + ] = await Promise.all([ + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getProvisionTokensRange', + }) as Promise<[bigint, bigint]>, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getDelegationRatio', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'stakeToFeesRatio', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'curationFeesCut', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'maxPOIStaleness', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getThawingPeriodRange', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getVerifierCutRange', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getDisputeManager', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getGraphTallyCollector', + }) as Promise, + client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getCuration', + }) as Promise, + ]) + + // Try newer functions that may not be on current deployment + let blockClosingWithAgreement: boolean | null = null + try { + blockClosingWithAgreement = (await client.readContract({ + address: ssAddress as `0x${string}`, + abi: SUBGRAPH_SERVICE_ABI, + functionName: 'getBlockClosingAllocationWithActiveAgreement', + })) as boolean + } catch { + // Not available on current implementation + } + + // Display SubgraphService parameters + console.log(`\n🔧 Provision Parameters`) + console.log(` Min provision tokens: ${formatGRT(provisionRange[0])}`) + if (provisionRange[1] < 2n ** 256n - 1n) { + console.log(` Max provision tokens: ${formatGRT(provisionRange[1])}`) + } else { + console.log(` Max provision tokens: unlimited`) + } + console.log(` Delegation ratio: ${delegationRatio}x`) + + console.log(`\n📐 Thawing & Verifier Ranges`) + if (thawingRange[0] === thawingRange[1]) { + console.log(` Thawing period: ${formatDuration(thawingRange[0])} (fixed)`) + } else { + console.log(` Thawing period: ${formatDuration(thawingRange[0])} – ${formatDuration(thawingRange[1])}`) + } + console.log(` Verifier cut: ${formatPPM(verifierCutRange[0])} – ${formatPPM(verifierCutRange[1])}`) + + console.log(`\n💰 Fee Parameters`) + console.log(` Stake to fees ratio: ${stakeToFees}`) + console.log(` Curation fees cut: ${formatPPM(curationCut)}`) + + console.log(`\n⏱️ Staleness`) + console.log(` Max POI staleness: ${formatDuration(poiStaleness)} (${poiStaleness} seconds)`) + + if (blockClosingWithAgreement !== null) { + console.log(`\n🔒 Agreement Guards`) + console.log(` Block closing allocation with active agreement: ${blockClosingWithAgreement ? 'yes' : 'no'}`) + } + + console.log(`\n🔗 Linked Contracts`) + console.log(` DisputeManager: ${disputeManager}`) + console.log(` GraphTallyCollector: ${tallyCollector}`) + console.log(` Curation: ${curation}`) + + // RewardsManager parameters + if (rmAddress) { + console.log(`\n📊 RewardsManager`) + console.log(` Address: ${rmAddress}`) + + try { + const minimumSignal = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_SIGNAL_ABI, + functionName: 'minimumSubgraphSignal', + })) as bigint + + if (minimumSignal === 0n) { + console.log(` Minimum subgraph signal: 0 (disabled)`) + } else { + console.log(` Minimum subgraph signal: ${formatGRT(minimumSignal)}`) + } + } catch { + console.log(` Minimum subgraph signal: ? (not readable)`) + } + } + + console.log() +} + +// -- Task Definition -- + +/** + * Show SubgraphService configuration parameters + * + * Displays provision requirements, fee parameters, staleness thresholds, + * and linked contract addresses. + * + * Examples: + * npx hardhat ss:status --network arbitrumOne + * npx hardhat ss:status --network arbitrumSepolia + */ +export const ssStatusTask = task('ss:status', 'Show SubgraphService configuration parameters') + .setAction(async () => ({ default: statusAction })) + .build() + +export default [ssStatusTask] diff --git a/packages/deployment/tasks/sync.ts b/packages/deployment/tasks/sync.ts new file mode 100644 index 000000000..563cad8ad --- /dev/null +++ b/packages/deployment/tasks/sync.ts @@ -0,0 +1,37 @@ +import { task } from 'hardhat/config' +import type { NewTaskActionFunction } from 'hardhat/types/tasks' + +interface TaskArgs { + // No arguments for this task +} + +/** + * Explicit global address book sync. + * + * Runs the full sync (00_sync.ts) over every contract in every address book, + * reconciling on-chain implementation state with the recorded address books and + * rocketh deployment records. Use this when: + * + * - You want a full overview of address book state + * - Governance executed a TX batch out-of-band and address books need to catch up + * - A fork was reset and rocketh records need to be rebuilt + * + * Per-component actions sync the contracts they touch immediately before and + * after their work, so this task is no longer required as a prerequisite for + * normal `--tags Component,verb` invocations. + * + * Usage: + * npx hardhat deploy:sync --network arbitrumOne + * npx hardhat deploy:sync --network localhost (auto-detects fork network) + */ +const action: NewTaskActionFunction = async (_taskArgs, hre) => { + // Sync is read-only, so suppress the gas-price confirmation prompt that the + // rocketh deploy task shows by default. + await hre.tasks.getTask('deploy').run({ tags: 'sync', skipPrompts: true }) +} + +const syncTask = task('deploy:sync', 'Sync address books and deployment records with on-chain state') + .setAction(async () => ({ default: action })) + .build() + +export default syncTask diff --git a/packages/deployment/tasks/verify-contract.ts b/packages/deployment/tasks/verify-contract.ts index 793f921f3..921465dae 100644 --- a/packages/deployment/tasks/verify-contract.ts +++ b/packages/deployment/tasks/verify-contract.ts @@ -1,6 +1,6 @@ import { spawn } from 'child_process' import fs from 'fs' -import { configVariable, task } from 'hardhat/config' +import { task } from 'hardhat/config' import { ArgumentType } from 'hardhat/types/arguments' import type { NewTaskActionFunction } from 'hardhat/types/tasks' import os from 'os' @@ -8,6 +8,7 @@ import path from 'path' import { decodeAbiParameters } from 'viem' import type { AnyAddressBookOps } from '../lib/address-book-ops.js' +import { getLibraryResolver } from '../lib/artifact-loaders.js' import { computeBytecodeHash } from '../lib/bytecode-utils.js' import { type AddressBookType, @@ -17,7 +18,8 @@ import { getContractsByAddressBook, } from '../lib/contract-registry.js' import { loadArtifactFromSource } from '../lib/deploy-implementation.js' -import { verifyOZProxy } from '../lib/oz-proxy-verify.js' +import { checkEtherscanVerified, verifyOZProxy } from '../lib/oz-proxy-verify.js' +import { resolveConfigVar } from '../lib/task-utils.js' import { graph } from '../rocketh/deploy.js' const ADDRESS_BOOK_TYPES: AddressBookType[] = ['horizon', 'subgraph-service', 'issuance'] @@ -31,6 +33,8 @@ function getPackageDir(artifactSource: ArtifactSource): string { return 'packages/contracts' case 'subgraph-service': return 'packages/subgraph-service' + case 'horizon': + return 'packages/horizon' case 'issuance': return 'packages/issuance' case 'openzeppelin': @@ -50,6 +54,14 @@ function getFullyQualifiedContractName(artifactSource: ArtifactSource): string { case 'subgraph-service': // e.g., contracts/SubgraphService.sol:SubgraphService return `contracts/${artifactSource.name}.sol:${artifactSource.name}` + case 'horizon': { + // path is like 'contracts/staking/HorizonStaking.sol/HorizonStaking' + // Need to convert to 'contracts/staking/HorizonStaking.sol:HorizonStaking' + const parts = artifactSource.path.split('/') + const contractName = parts.pop()! + const solPath = parts.join('/') + return `${solPath}:${contractName}` + } case 'issuance': { // path is like 'contracts/allocate/IssuanceAllocator.sol/IssuanceAllocator' // Need to convert to 'contracts/allocate/IssuanceAllocator.sol:IssuanceAllocator' @@ -74,8 +86,8 @@ function findContractAddressBook( for (const addressBook of ADDRESS_BOOK_TYPES) { const metadata = getContractMetadata(addressBook, contractName) - // Only consider entries that are deployable and have an artifact source - if (metadata?.deployable && metadata.artifact) { + // Consider entries that are deployable with an artifact, or proxy-only contracts (shared impl) + if (metadata?.deployable && (metadata.artifact || metadata.proxyType)) { matches.push({ addressBook, metadata }) } } @@ -107,7 +119,7 @@ function getAllDeployableContracts(): Array<{ for (const addressBook of ADDRESS_BOOK_TYPES) { for (const [name, metadata] of getContractsByAddressBook(addressBook)) { - if (metadata.deployable && metadata.artifact) { + if (metadata.deployable && (metadata.artifact || metadata.proxyType)) { contracts.push({ name, addressBook, metadata }) } } @@ -116,32 +128,7 @@ function getAllDeployableContracts(): Array<{ return contracts } -/** - * Resolve a configuration variable using Hardhat's hook chain (keystore + env fallback) - */ -async function resolveConfigVar(hre: unknown, name: string): Promise { - try { - const variable = configVariable(name) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const hooks = (hre as any).hooks - - const value = await hooks.runHandlerChain( - 'configurationVariables', - 'fetchValue', - [variable], - async (_context: unknown, v: { name: string }) => { - const envValue = process.env[v.name] - if (typeof envValue !== 'string') { - throw new Error(`Environment variable ${v.name} not found`) - } - return envValue - }, - ) - return value - } catch { - return undefined - } -} +// resolveConfigVar imported from shared task-utils /** * Check if a package uses Hardhat v3 (which has different verify CLI options) @@ -348,7 +335,9 @@ function checkBytecodeMatch( } // Compare local artifact bytecodeHash with stored hash - const localBytecodeHash = computeBytecodeHash(artifact.deployedBytecode) + // Must pass linkReferences and resolver to match how hash was computed at deployment + const resolver = getLibraryResolver(metadata.artifact!.type) + const localBytecodeHash = computeBytecodeHash(artifact.deployedBytecode, artifact.deployedLinkReferences, resolver) if (localBytecodeHash !== deploymentMetadata.bytecodeHash) { return { matches: false, @@ -393,24 +382,23 @@ async function verifySingleContract( const isProxied = Boolean(metadata.proxyType) const implAddress = isProxied ? entry.implementation : entry.address + // Proxy-only contracts (shared implementation, no artifact) — only verify the proxy + // Implementation verification is handled by the shared _Implementation entry + const hasArtifact = Boolean(metadata.artifact) + // Check bytecode matches for implementation (using stored bytecodeHash) - if (implAddress) { + // This is a warning, not a blocker — Etherscan is the ultimate arbiter + let bytecodeMatches = true + if (hasArtifact && implAddress) { const bytecodeCheck = checkBytecodeMatch(contractName, metadata, addressBook) if (!bytecodeCheck.matches) { - return { - contract: contractName, - addressBook: addressBookType, - status: 'skipped', - reason: bytecodeCheck.reason, - } + bytecodeMatches = false + console.log(` ⚠️ ${bytecodeCheck.reason}`) } } - const packageDir = getPackageDir(metadata.artifact!) - const isHHv3 = isHardhatV3Package(metadata.artifact!) - const artifact = loadArtifactFromSource(metadata.artifact!) - const fullyQualifiedName = getFullyQualifiedContractName(metadata.artifact!) let implResult: { success: boolean; url?: string } = { success: true } + let verificationFailed = false // Get constructor args from deployment metadata const deploymentMetadata = addressBook.getDeploymentMetadata?.(contractName) @@ -423,75 +411,106 @@ async function verifySingleContract( if (entry.proxyDeployment?.verified) { console.log(` ✓ Proxy already verified: ${entry.proxyDeployment.verified}`) } else { - // Get proxy constructor args from address book (stored separately from implementation args) - const proxyArgsData = entry.proxyDeployment?.argsData - if (!proxyArgsData) { - console.log(` ⏭️ Proxy verification skipped (no constructor args in address book)`) + // Check Etherscan before submitting — avoids redundant submissions + const existingUrl = await checkEtherscanVerified(entry.address, apiKey, chainId) + if (existingUrl) { + console.log(` ✓ Proxy already verified: ${existingUrl}`) + addressBook.setVerified(contractName, existingUrl) } else { - console.log(` 📋 Verifying OZ TransparentUpgradeableProxy at: ${entry.address}`) - console.log(` 📦 Source: @openzeppelin/contracts v5.4.0 (from node_modules)`) + // Get proxy constructor args from address book (stored separately from implementation args) + const proxyArgsData = entry.proxyDeployment?.argsData + if (!proxyArgsData) { + console.log(` ⏭️ Proxy verification skipped (no constructor args in address book)`) + } else { + console.log(` 📋 Verifying OZ TransparentUpgradeableProxy at: ${entry.address}`) + console.log(` 📦 Source: @openzeppelin/contracts v5.4.0 (from node_modules)`) - const proxyResult = await verifyOZProxy(entry.address, proxyArgsData, apiKey, chainId) + const proxyResult = await verifyOZProxy(entry.address, proxyArgsData, apiKey, chainId) - if (proxyResult.success && proxyResult.url) { - console.log(` ✅ Proxy verification complete`) - // Record verification URL in address book (setVerified sets proxyDeployment.verified for proxied contracts) - addressBook.setVerified(contractName, proxyResult.url) - } else if (proxyResult.success) { - console.log(` ✅ Proxy verification complete (${proxyResult.message || 'no URL returned'})`) - } else { - console.log(` ⚠️ Proxy verification failed: ${proxyResult.message || 'unknown error'}`) + if (proxyResult.success && proxyResult.url) { + console.log(` ✅ Proxy verification complete`) + addressBook.setVerified(contractName, proxyResult.url) + } else if (proxyResult.success) { + console.log(` ✅ Proxy verification complete (${proxyResult.message || 'no URL returned'})`) + } else { + console.log(` ⚠️ Proxy verification failed: ${proxyResult.message || 'unknown error'}`) + verificationFailed = true + } } } } } // Verify implementation (if proxied and not proxy-only, or if not proxied) - if ((isProxied && !proxyOnly) || !isProxied) { + // Skip for proxy-only contracts with no artifact (shared implementation verified separately) + if (!hasArtifact) { + if (!proxyOnly) { + console.log(` ⏭️ Implementation verification skipped (shared implementation)`) + } + } else if ((isProxied && !proxyOnly) || !isProxied) { + const packageDir = getPackageDir(metadata.artifact!) + const isHHv3 = isHardhatV3Package(metadata.artifact!) + const artifact = loadArtifactFromSource(metadata.artifact!) + const fullyQualifiedName = getFullyQualifiedContractName(metadata.artifact!) + if (!implAddress) { console.log(' ⚠️ No implementation address found, skipping') } else { - // Skip if already verified + // Skip if already verified (local record) const implVerified = isProxied ? entry.implementationDeployment?.verified : entry.deployment?.verified if (implVerified) { const label = isProxied ? 'Implementation' : 'Contract' console.log(` ✓ ${label} already verified: ${implVerified}`) } else { - const label = isProxied ? 'implementation' : 'contract' - console.log(` 📋 Verifying ${label} at: ${implAddress}`) - // Pass constructor args for implementation contracts - // Use fullyQualifiedName to ensure hardhat uses current build artifacts - implResult = await runVerify( - packageDir, - networkName, - implAddress, - apiKey, - constructorArgsData, - artifact, - isHHv3, - fullyQualifiedName, - ) - if (implResult.success && implResult.url) { - console.log(` ✅ ${label.charAt(0).toUpperCase() + label.slice(1)} verification complete`) - // Record verification URL in address book + // Check Etherscan before attempting local verify — catches contracts + // verified out-of-band or where previous attempts failed locally + const existingImplUrl = await checkEtherscanVerified(implAddress, apiKey, chainId) + if (existingImplUrl) { + const label = isProxied ? 'Implementation' : 'Contract' + console.log(` ✓ ${label} already verified: ${existingImplUrl}`) if (isProxied) { - addressBook.setImplementationVerified(contractName, implResult.url) + addressBook.setImplementationVerified(contractName, existingImplUrl) } else { - addressBook.setVerified(contractName, implResult.url) + addressBook.setVerified(contractName, existingImplUrl) } - } else if (implResult.success) { - console.log(` ✅ ${label.charAt(0).toUpperCase() + label.slice(1)} verification complete`) + } else if (!bytecodeMatches) { + // Bytecode mismatch and not verified on Etherscan — skip + const label = isProxied ? 'Implementation' : 'Contract' + console.log(` ⏭️ ${label} verification skipped (bytecode mismatch)`) } else { - console.log( - ` ⚠️ ${label.charAt(0).toUpperCase() + label.slice(1)} verification failed (may already be verified)`, + const label = isProxied ? 'implementation' : 'contract' + console.log(` 📋 Verifying ${label} at: ${implAddress}`) + implResult = await runVerify( + packageDir, + networkName, + implAddress, + apiKey, + constructorArgsData, + artifact, + isHHv3, + fullyQualifiedName, ) + if (implResult.success && implResult.url) { + console.log(` ✅ ${label.charAt(0).toUpperCase() + label.slice(1)} verification complete`) + if (isProxied) { + addressBook.setImplementationVerified(contractName, implResult.url) + } else { + addressBook.setVerified(contractName, implResult.url) + } + } else if (implResult.success) { + console.log(` ✅ ${label.charAt(0).toUpperCase() + label.slice(1)} verification complete`) + } else { + console.log( + ` ⚠️ ${label.charAt(0).toUpperCase() + label.slice(1)} verification failed (may already be verified)`, + ) + verificationFailed = true + } } } } } - // Both failing or already verified is still "success" for the workflow - return { contract: contractName, addressBook: addressBookType, status: 'verified' } + return { contract: contractName, addressBook: addressBookType, status: verificationFailed ? 'failed' : 'verified' } } interface TaskArgs { @@ -534,7 +553,11 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { // Get API key from keystore const apiKey = await resolveConfigVar(hre, 'ARBISCAN_API_KEY') if (!apiKey) { - throw new Error('ARBISCAN_API_KEY not found. Set it in keystore:\n npx hardhat keystore set ARBISCAN_API_KEY') + throw new Error( + 'No Arbiscan API key configured.\n' + + 'Set via keystore: npx hardhat keystore set ARBISCAN_API_KEY\n' + + 'Or environment: export ARBISCAN_API_KEY=...', + ) } // Determine contracts to verify @@ -548,7 +571,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { if (explicitAddressBook) { addressBookType = explicitAddressBook as AddressBookType const foundMetadata = getContractMetadata(addressBookType, contract) - if (!foundMetadata?.deployable || !foundMetadata.artifact) { + if (!foundMetadata?.deployable || (!foundMetadata.artifact && !foundMetadata.proxyType)) { throw new Error(`Contract ${contract} not found as deployable in ${addressBookType} registry`) } metadata = foundMetadata diff --git a/packages/deployment/test/bytecode-comparison.test.ts b/packages/deployment/test/bytecode-comparison.test.ts index 394cf57e4..8e0ebef27 100644 --- a/packages/deployment/test/bytecode-comparison.test.ts +++ b/packages/deployment/test/bytecode-comparison.test.ts @@ -1,6 +1,11 @@ import { expect } from 'chai' -import { computeBytecodeHash, stripMetadata } from '../lib/bytecode-utils.js' +import { + computeBytecodeHash, + type LibraryArtifactResolver, + type LinkReferences, + stripMetadata, +} from '../lib/bytecode-utils.js' import { loadContractsArtifact } from '../lib/deploy-implementation.js' /** @@ -102,6 +107,55 @@ describe('Bytecode Utilities', function () { expect(hash).to.be.a('string') expect(hash).to.match(/^0x[a-f0-9]{64}$/) }) + + it('should handle bytecode with unlinked library placeholders', function () { + // Library placeholders are deterministic (keccak256 of "path:name")) and + // included as-is in the hash — they're part of the artifact identity + const placeholder = '__$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$__' + const code = '0x' + BASE_CODE + '73' + placeholder + METADATA_A + const hash = computeBytecodeHash(code) + expect(hash).to.be.a('string') + expect(hash).to.match(/^0x[a-f0-9]{64}$/) + }) + + it('should detect code changes around library placeholders', function () { + const placeholder = '__$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$__' + const codeA = '0x' + BASE_CODE + '73' + placeholder + METADATA_A + const codeB = '0x' + BASE_CODE + '6001' + '73' + placeholder + METADATA_A + expect(computeBytecodeHash(codeA)).to.not.equal(computeBytecodeHash(codeB)) + }) + + it('should resolve library placeholders with resolver', async function () { + const { keccak256: k, toUtf8Bytes: u } = await import('ethers') + const libPath = 'contracts/libs/MyLib.sol' + const libName = 'MyLib' + const placeholderHash = k(u(`${libPath}:${libName}`)).slice(2, 36) + const placeholder = `__$${placeholderHash}$__` + // Use placeholder in middle with enough valid hex around it, plus metadata suffix + const code = '0x' + BASE_CODE + '73' + placeholder + BASE_CODE + METADATA_A + + const linkRefs: LinkReferences = { + [libPath]: { [libName]: [{ length: 20, start: 0 }] }, + } + const libBytecodeA = '0x6001600201' + const libBytecodeB = '0x6001600301' // different library code + + const resolver: LibraryArtifactResolver = () => ({ + deployedBytecode: libBytecodeA, + }) + const resolverB: LibraryArtifactResolver = () => ({ + deployedBytecode: libBytecodeB, + }) + + const hashA = computeBytecodeHash(code, linkRefs, resolver) + const hashB = computeBytecodeHash(code, linkRefs, resolverB) + const hashNoResolver = computeBytecodeHash(code) + + // Different library code should produce different hashes + expect(hashA).to.not.equal(hashB) + // With resolver should differ from without (zero-filled) + expect(hashA).to.not.equal(hashNoResolver) + }) }) }) diff --git a/packages/deployment/test/chain-id-resolution.test.ts b/packages/deployment/test/chain-id-resolution.test.ts index 356f653d8..3e5948580 100644 --- a/packages/deployment/test/chain-id-resolution.test.ts +++ b/packages/deployment/test/chain-id-resolution.test.ts @@ -1,16 +1,18 @@ import type { Environment } from '@rocketh/core/types' import { expect } from 'chai' -import { getForkTargetChainId, getTargetChainIdFromEnv } from '../lib/address-book-utils.js' +import { getForkNetwork, getForkTargetChainId, getTargetChainIdFromEnv, isForkMode } from '../lib/address-book-utils.js' describe('Chain ID Resolution', function () { // Store original env vars to restore after tests let originalHardhatFork: string | undefined let originalForkNetwork: string | undefined + let originalHardhatNetwork: string | undefined beforeEach(function () { originalHardhatFork = process.env.HARDHAT_FORK originalForkNetwork = process.env.FORK_NETWORK + originalHardhatNetwork = process.env.HARDHAT_NETWORK }) afterEach(function () { @@ -25,6 +27,11 @@ describe('Chain ID Resolution', function () { } else { process.env.FORK_NETWORK = originalForkNetwork } + if (originalHardhatNetwork === undefined) { + delete process.env.HARDHAT_NETWORK + } else { + process.env.HARDHAT_NETWORK = originalHardhatNetwork + } }) describe('getForkTargetChainId', function () { @@ -81,6 +88,116 @@ describe('Chain ID Resolution', function () { expect(() => getForkTargetChainId()).to.throw('Unknown fork network: unknownNetwork') }) + + it('should return null when FORK_NETWORK is set but network is a real network', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumSepolia' + + const result = getForkTargetChainId() + expect(result).to.be.null + }) + + it('should return chain ID when FORK_NETWORK is set and network is localhost', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'localhost' + + const result = getForkTargetChainId() + expect(result).to.equal(421614) + }) + + it('should return chain ID when explicit networkName is localhost', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumSepolia' // would normally prevent fork mode + + // Explicit networkName overrides HARDHAT_NETWORK + const result = getForkTargetChainId('localhost') + expect(result).to.equal(421614) + }) + + it('should return null when explicit networkName is a real network', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + delete process.env.HARDHAT_NETWORK + + const result = getForkTargetChainId('arbitrumSepolia') + expect(result).to.be.null + }) + }) + + describe('isForkMode (network-aware)', function () { + it('should return false when no fork env vars are set', function () { + delete process.env.HARDHAT_FORK + delete process.env.FORK_NETWORK + + expect(isForkMode()).to.be.false + }) + + it('should return true when FORK_NETWORK is set and HARDHAT_NETWORK is localhost', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'localhost' + + expect(isForkMode()).to.be.true + }) + + it('should return true when FORK_NETWORK is set and HARDHAT_NETWORK is fork', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'fork' + + expect(isForkMode()).to.be.true + }) + + it('should return false when FORK_NETWORK is set but HARDHAT_NETWORK is a real network', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumSepolia' + + expect(isForkMode()).to.be.false + }) + + it('should return false when FORK_NETWORK is set but HARDHAT_NETWORK is arbitrumOne', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumOne' + + expect(isForkMode()).to.be.false + }) + + it('should use explicit networkName over HARDHAT_NETWORK', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumSepolia' // real network + + // Explicit networkName says localhost - should be fork mode + expect(isForkMode('localhost')).to.be.true + }) + + it('should return false with explicit real networkName even if HARDHAT_NETWORK is local', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'localhost' + + // Explicit networkName says real network - should not be fork mode + expect(isForkMode('arbitrumSepolia')).to.be.false + }) + + it('should return true when FORK_NETWORK is set and no network context available', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + delete process.env.HARDHAT_NETWORK + + // No context - preserves existing behavior (trusts env var) + expect(isForkMode()).to.be.true + }) + }) + + describe('getForkNetwork (network-aware)', function () { + it('should return null on real networks even if FORK_NETWORK is set', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'arbitrumSepolia' + + expect(getForkNetwork()).to.be.null + }) + + it('should return fork network name on localhost', function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + process.env.HARDHAT_NETWORK = 'localhost' + + expect(getForkNetwork()).to.equal('arbitrumSepolia') + }) }) describe('getTargetChainIdFromEnv', function () { @@ -89,6 +206,7 @@ describe('Chain ID Resolution', function () { // Mock environment - provider won't be called in fork mode const mockEnv = { + name: 'localhost', network: { provider: { request: () => { @@ -108,6 +226,7 @@ describe('Chain ID Resolution', function () { // Mock environment with provider returning 421614 const mockEnv = { + name: 'arbitrumSepolia', network: { provider: { request: async ({ method }: { method: string }) => { @@ -130,6 +249,7 @@ describe('Chain ID Resolution', function () { // Test Arbitrum One (42161 = 0xA4B1) const mockEnvArb = { + name: 'arbitrumOne', network: { provider: { request: async () => '0xa4b1', // 42161 in hex @@ -140,17 +260,18 @@ describe('Chain ID Resolution', function () { const resultArb = await getTargetChainIdFromEnv(mockEnvArb) expect(resultArb).to.equal(42161) - // Test localhost (31337 = 0x7A69) - const mockEnvLocal = { + // Test Ethereum mainnet (1 = 0x1) + const mockEnvMainnet = { + name: 'mainnet', network: { provider: { - request: async () => '0x7a69', // 31337 in hex + request: async () => '0x1', // 1 in hex }, }, } as unknown as Environment - const resultLocal = await getTargetChainIdFromEnv(mockEnvLocal) - expect(resultLocal).to.equal(31337) + const resultMainnet = await getTargetChainIdFromEnv(mockEnvMainnet) + expect(resultMainnet).to.equal(1) }) it('should prefer fork chain ID over provider chain ID when forking', async function () { @@ -158,6 +279,7 @@ describe('Chain ID Resolution', function () { // Mock provider returning 31337 (local hardhat node) const mockEnv = { + name: 'localhost', network: { provider: { request: async () => '0x7a69', // 31337 in hex @@ -169,6 +291,24 @@ describe('Chain ID Resolution', function () { // Should return fork target (42161), not provider chain ID (31337) expect(result).to.equal(42161) }) + + it('should return provider chain ID on real network even if FORK_NETWORK is set', async function () { + process.env.FORK_NETWORK = 'arbitrumSepolia' + + // Running on arbitrumOne - FORK_NETWORK should be ignored + const mockEnv = { + name: 'arbitrumOne', + network: { + provider: { + request: async () => '0xa4b1', // 42161 in hex + }, + }, + } as unknown as Environment + + const result = await getTargetChainIdFromEnv(mockEnv) + // Should return provider chain ID (42161), not fork target (421614) + expect(result).to.equal(42161) + }) }) describe('Integration: Fork mode detection', function () { @@ -178,6 +318,7 @@ describe('Chain ID Resolution', function () { delete process.env.FORK_NETWORK const mockEnvNonFork = { + name: 'arbitrumSepolia', network: { provider: { request: async () => '0x66eee', // 421614 @@ -186,7 +327,7 @@ describe('Chain ID Resolution', function () { } as unknown as Environment const nonForkChainId = await getTargetChainIdFromEnv(mockEnvNonFork) - const forkChainId1 = getForkTargetChainId() + const forkChainId1 = getForkTargetChainId('arbitrumSepolia') expect(forkChainId1).to.be.null expect(nonForkChainId).to.equal(421614) @@ -195,6 +336,7 @@ describe('Chain ID Resolution', function () { process.env.FORK_NETWORK = 'arbitrumSepolia' const mockEnvFork = { + name: 'localhost', network: { provider: { request: async () => '0x7a69', // 31337 (local node) @@ -203,7 +345,7 @@ describe('Chain ID Resolution', function () { } as unknown as Environment const forkModeChainId = await getTargetChainIdFromEnv(mockEnvFork) - const forkChainId2 = getForkTargetChainId() + const forkChainId2 = getForkTargetChainId('localhost') expect(forkChainId2).to.equal(421614) expect(forkModeChainId).to.equal(421614) // Fork target, not 31337 diff --git a/packages/deployment/tsconfig.json b/packages/deployment/tsconfig.json index 75fbe69b6..b97d405ac 100644 --- a/packages/deployment/tsconfig.json +++ b/packages/deployment/tsconfig.json @@ -5,6 +5,6 @@ "rootDir": ".", "composite": true }, - "include": ["lib/**/*", "tasks/**/*", "governance/**/*", "deploy/**/*", "rocketh/**/*", "hardhat.config.ts"], + "include": ["lib/**/*", "tasks/**/*", "deploy/**/*", "rocketh/**/*", "types/**/*", "hardhat.config.ts"], "exclude": ["node_modules", "dist", "artifacts", "cache", "test"] } diff --git a/packages/deployment/types/rocketh.d.ts b/packages/deployment/types/rocketh.d.ts new file mode 100644 index 000000000..af44ad34a --- /dev/null +++ b/packages/deployment/types/rocketh.d.ts @@ -0,0 +1,24 @@ +// Type augmentation: rocketh's skip() support is enabled via pnpm patch (patches/rocketh@0.17.13.patch). +// Deploy scripts also have early-return guards as a safety net. +import type { + UnknownDeployments, + UnresolvedNetworkSpecificData, + UnresolvedUnknownNamedAccounts, +} from '@rocketh/core/types' + +declare module '@rocketh/core/types' { + interface DeployScriptModule< + // eslint-disable-next-line @typescript-eslint/no-unused-vars + NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + ArgumentsTypes = undefined, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Deployments extends UnknownDeployments = UnknownDeployments, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Extra extends Record = Record, + > { + skip?: () => Promise + } +} diff --git a/packages/toolshed/src/deployments/address-book.ts b/packages/toolshed/src/deployments/address-book.ts index 63bbc26f6..147bc61c5 100644 --- a/packages/toolshed/src/deployments/address-book.ts +++ b/packages/toolshed/src/deployments/address-book.ts @@ -17,8 +17,8 @@ export type AddressBookJson=8.0.0' + specifier: 'catalog:' version: 10.9.2(@types/node@20.19.14)(typescript@5.9.3) typechain: - specifier: ^8.3.0 + specifier: 'catalog:' version: 8.3.2(patch_hash=b34ed6afcf99760666fdc85ecb2094fdd20ce509f947eb09cef21665a2a6a1d6)(typescript@5.9.3) typescript: specifier: 'catalog:' @@ -753,6 +737,9 @@ importers: '@graphprotocol/horizon': specifier: workspace:* version: link:../horizon + '@graphprotocol/interfaces': + specifier: workspace:* + version: link:../interfaces '@graphprotocol/issuance': specifier: workspace:* version: link:../issuance @@ -798,13 +785,13 @@ importers: version: 0.17.11(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@rocketh/doc': specifier: ^0.17.16 - version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@rocketh/export': specifier: ^0.17.16 - version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@rocketh/node': specifier: ^0.17.16 - version: 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + version: 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@rocketh/proxy': specifier: ^0.17.12 version: 0.17.12(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) @@ -813,7 +800,7 @@ importers: version: 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@rocketh/verifier': specifier: ^0.17.16 - version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + version: 0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/chai': specifier: ^4.3.0 version: 4.3.20 @@ -831,7 +818,7 @@ importers: version: 9.39.2(jiti@2.5.1) hardhat-deploy: specifier: 2.0.0-next.61 - version: 2.0.0-next.61(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(hardhat@3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + version: 2.0.0-next.61(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(hardhat@3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10)) lint-staged: specifier: 'catalog:' version: 16.2.7 @@ -840,7 +827,7 @@ importers: version: 10.8.2 rocketh: specifier: ^0.17.13 - version: 0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + version: 0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) ts-node: specifier: ^10.9.0 version: 10.9.2(@types/node@20.19.14)(typescript@5.9.3) @@ -861,7 +848,7 @@ importers: version: 3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) debug: specifier: ^4.3.7 - version: 4.4.3(supports-color@9.4.0) + version: 4.4.3(supports-color@8.1.1) json5: specifier: ^2.2.3 version: 2.2.3 @@ -1371,7 +1358,7 @@ importers: version: 3.1.8(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@nomiclabs/hardhat-waffle': specifier: ^2.0.6 - version: 2.0.6(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@types/sinon-chai@3.2.12)(ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) + version: 2.0.6(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@types/sinon-chai@3.2.12)(ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@openzeppelin/contracts': specifier: 3.4.2 version: 3.4.2 @@ -1494,7 +1481,7 @@ importers: version: 3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) debug: specifier: ^4.4.0 - version: 4.4.3(supports-color@9.4.0) + version: 4.4.3(supports-color@8.1.1) ethers: specifier: 'catalog:' version: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) @@ -2563,20 +2550,12 @@ packages: resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@ethereum-waffle/chai@3.4.4': - resolution: {integrity: sha512-/K8czydBtXXkcM9X6q29EqEkc5dN3oYenyH2a9hF7rGAApAJUpH8QBtojxOY/xQ2up5W332jqgxwp0yPiYug1g==} - engines: {node: '>=10.0'} - '@ethereum-waffle/chai@4.0.10': resolution: {integrity: sha512-X5RepE7Dn8KQLFO7HHAAe+KeGaX/by14hn90wePGBhzL54tq4Y8JscZFu+/LCwCl6TnkAAy5ebiMoqJ37sFtWw==} engines: {node: '>=10.0'} peerDependencies: ethers: '*' - '@ethereum-waffle/compiler@3.4.4': - resolution: {integrity: sha512-RUK3axJ8IkD5xpWjWoJgyHclOeEzDLQFga6gKpeGxiS/zBu+HB0W2FvsrrLalTFIaPw/CGYACRBSIxqiCqwqTQ==} - engines: {node: '>=10.0'} - '@ethereum-waffle/compiler@4.0.3': resolution: {integrity: sha512-5x5U52tSvEVJS6dpCeXXKvRKyf8GICDwiTwUvGD3/WD+DpvgvaoHOL82XqpTSUHgV3bBq6ma5/8gKUJUIAnJCw==} engines: {node: '>=10.0'} @@ -2585,10 +2564,6 @@ packages: solc: '*' typechain: ^8.0.0 - '@ethereum-waffle/ens@3.4.4': - resolution: {integrity: sha512-0m4NdwWxliy3heBYva1Wr4WbJKLnwXizmy5FfSSr5PMbjI7SIGCdCB59U7/ZzY773/hY3bLnzLwvG5mggVjJWg==} - engines: {node: '>=10.0'} - '@ethereum-waffle/ens@4.0.3': resolution: {integrity: sha512-PVLcdnTbaTfCrfSOrvtlA9Fih73EeDvFS28JQnT5M5P4JMplqmchhcZB1yg/fCtx4cvgHlZXa0+rOCAk2Jk0Jw==} engines: {node: '>=10.0'} @@ -2597,20 +2572,12 @@ packages: '@ensdomains/resolver': ^0.2.4 ethers: '*' - '@ethereum-waffle/mock-contract@3.4.4': - resolution: {integrity: sha512-Mp0iB2YNWYGUV+VMl5tjPsaXKbKo8MDH9wSJ702l9EBjdxFf/vBvnMBAC1Fub1lLtmD0JHtp1pq+mWzg/xlLnA==} - engines: {node: '>=10.0'} - '@ethereum-waffle/mock-contract@4.0.4': resolution: {integrity: sha512-LwEj5SIuEe9/gnrXgtqIkWbk2g15imM/qcJcxpLyAkOj981tQxXmtV4XmQMZsdedEsZ/D/rbUAOtZbgwqgUwQA==} engines: {node: '>=10.0'} peerDependencies: ethers: '*' - '@ethereum-waffle/provider@3.4.4': - resolution: {integrity: sha512-GK8oKJAM8+PKy2nK08yDgl4A80mFuI8zBkE0C9GqTRYQqvuxIyXoLmJ5NZU9lIwyWVv5/KsoA11BgAv2jXE82g==} - engines: {node: '>=10.0'} - '@ethereum-waffle/provider@4.0.5': resolution: {integrity: sha512-40uzfyzcrPh+Gbdzv89JJTMBlZwzya1YLDyim8mVbEqYLP5VRYWoGp0JMyaizgV3hMoUFRqJKVmIUw4v7r3hYw==} engines: {node: '>=10.0'} @@ -2659,9 +2626,6 @@ packages: '@ethereumjs/vm@5.6.0': resolution: {integrity: sha512-J2m/OgjjiGdWF2P9bj/4LnZQ1zRoZhY8mRNVw/N3tXliGI8ai1sI1mlDPkLpeUUM4vq54gH6n0ZlSpz8U/qlYQ==} - '@ethersproject/abi@5.0.0-beta.153': - resolution: {integrity: sha512-aXweZ1Z7vMNzJdLpR1CZUAIgnwjrZeUSvN9syCwlBaEBUFJmFY+HHnfuTI5vIhVs/mRkfJVrbEyl51JZQqyjAg==} - '@ethersproject/abi@5.6.0': resolution: {integrity: sha512-AhVByTwdXCc2YQ20v300w6KVHle9g2OFc28ZAFCPnJyEpkv1xKXjZcSTgWOlv1i+0dqlgF8RCF2Rn2KC1t+1Vg==} @@ -3535,14 +3499,6 @@ packages: '@ledgerhq/logs@5.50.0': resolution: {integrity: sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==} - '@ljharb/resumer@0.0.1': - resolution: {integrity: sha512-skQiAOrCfO7vRTq53cxznMpks7wS1va95UCidALlOVWqvBAzwPVErwizDwoMqNVMEn1mDq0utxZd02eIrvF1lw==} - engines: {node: '>= 0.4'} - - '@ljharb/through@2.3.14': - resolution: {integrity: sha512-ajBvlKpWucBB17FuQYUShqpqy8GRgYEpJW0vWJbUu1CV9lWyrDCapy0lScU8T8Z6qn49sSwJB3+M+evYIdGg+A==} - engines: {node: '>= 0.4'} - '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -3888,9 +3844,6 @@ packages: '@openzeppelin/contracts@3.4.2': resolution: {integrity: sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA==} - '@openzeppelin/contracts@4.9.6': - resolution: {integrity: sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==} - '@openzeppelin/contracts@5.4.0': resolution: {integrity: sha512-eCYgWnLg6WO+X52I16TZt8uEjbtdkgLC0SUX/xnAksjjrQI4Xfn4iBRoI5j55dmlOhDv1Y7BoR3cU7e3WWhC6A==} @@ -4023,27 +3976,15 @@ packages: '@repeaterjs/repeater@3.0.6': resolution: {integrity: sha512-Javneu5lsuhwNCryN+pXH93VPQ8g0dBX7wItHFgYiwQmzE1sVdg5tWHiOgHywzL2W21XQopa7IwIEnNbmeUJYA==} - '@resolver-engine/core@0.2.1': - resolution: {integrity: sha512-nsLQHmPJ77QuifqsIvqjaF5B9aHnDzJjp73Q1z6apY3e9nqYrx4Dtowhpsf7Jwftg/XzVDEMQC+OzUBNTS+S1A==} - '@resolver-engine/core@0.3.3': resolution: {integrity: sha512-eB8nEbKDJJBi5p5SrvrvILn4a0h42bKtbCTri3ZxCGt6UvoQyp7HnGOfki944bUjBSHKK3RvgfViHn+kqdXtnQ==} - '@resolver-engine/fs@0.2.1': - resolution: {integrity: sha512-7kJInM1Qo2LJcKyDhuYzh9ZWd+mal/fynfL9BNjWOiTcOpX+jNfqb/UmGUqros5pceBITlWGqS4lU709yHFUbg==} - '@resolver-engine/fs@0.3.3': resolution: {integrity: sha512-wQ9RhPUcny02Wm0IuJwYMyAG8fXVeKdmhm8xizNByD4ryZlx6PP6kRen+t/haF43cMfmaV7T3Cx6ChOdHEhFUQ==} - '@resolver-engine/imports-fs@0.2.2': - resolution: {integrity: sha512-gFCgMvCwyppjwq0UzIjde/WI+yDs3oatJhozG9xdjJdewwtd7LiF0T5i9lrHAUtqrQbqoFE4E+ZMRVHWpWHpKQ==} - '@resolver-engine/imports-fs@0.3.3': resolution: {integrity: sha512-7Pjg/ZAZtxpeyCFlZR5zqYkz+Wdo84ugB5LApwriT8XFeQoLwGUj4tZFFvvCuxaNCcqZzCYbonJgmGObYBzyCA==} - '@resolver-engine/imports@0.2.2': - resolution: {integrity: sha512-u5/HUkvo8q34AA+hnxxqqXGfby5swnH0Myw91o3Sm2TETJlNKXibFGSKBavAH+wvWdBi4Z5gS2Odu0PowgVOUg==} - '@resolver-engine/imports@0.3.3': resolution: {integrity: sha512-anHpS4wN4sRMwsAbMXhMfOD/y4a4Oo0Cw/5+rue7hSwGWsDOQaAU1ClK1OxjUC35/peazxEl8JaSRRS+Xb8t3Q==} @@ -4149,14 +4090,6 @@ packages: '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} - '@sindresorhus/is@0.14.0': - resolution: {integrity: sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==} - engines: {node: '>=6'} - - '@sindresorhus/is@4.6.0': - resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} - engines: {node: '>=10'} - '@sindresorhus/is@5.6.0': resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==} engines: {node: '>=14.16'} @@ -4371,14 +4304,6 @@ packages: '@streamparser/json@0.0.22': resolution: {integrity: sha512-b6gTSBjJ8G8SuO3Gbbj+zXbVx8NSs1EbpbMKpzGLWMdkR+98McH9bEjSz3+0mPJf68c5nxa3CrJHp5EQNXM6zQ==} - '@szmarczak/http-timer@1.1.2': - resolution: {integrity: sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==} - engines: {node: '>=6'} - - '@szmarczak/http-timer@4.0.6': - resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==} - engines: {node: '>=10'} - '@szmarczak/http-timer@5.0.1': resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==} engines: {node: '>=14.16'} @@ -4427,12 +4352,6 @@ packages: typechain: ^8.1.1 typescript: '>=4.3.0' - '@typechain/ethers-v5@2.0.0': - resolution: {integrity: sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw==} - peerDependencies: - ethers: ^5.0.0 - typechain: ^3.0.0 - '@typechain/ethers-v6@0.5.1': resolution: {integrity: sha512-F+GklO8jBWlsaVV+9oHaPh5NJdd6rAKN4tklGfInX1Q7h0xPgVLP39Jl3eCulPB5qexI71ZFHwbljx4ZXNfouA==} peerDependencies: @@ -4479,9 +4398,6 @@ packages: '@types/bn.js@5.2.0': resolution: {integrity: sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q==} - '@types/cacheable-request@6.0.3': - resolution: {integrity: sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==} - '@types/chai-as-promised@7.1.8': resolution: {integrity: sha512-ThlRVIJhr69FLlh6IctTXFkmhtP3NpMZ2QGq69StYLyKZFp/HOp1VdKZj7RvfNWYYcJ1xlbLGLLWj1UvP5u/Gw==} @@ -4546,9 +4462,6 @@ packages: '@types/katex@0.16.7': resolution: {integrity: sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==} - '@types/keyv@3.1.4': - resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} - '@types/level-errors@3.0.2': resolution: {integrity: sha512-gyZHbcQ2X5hNXf/9KS2qGEmgDe9EN2WDM3rJ5Ele467C0nA1sLhtmv1bZiPMDYfAYCfPWft0uQIaTvXbASSTRA==} @@ -4592,12 +4505,6 @@ packages: '@types/qs@6.14.0': resolution: {integrity: sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==} - '@types/resolve@0.0.8': - resolution: {integrity: sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==} - - '@types/responselike@1.0.3': - resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} - '@types/secp256k1@4.0.6': resolution: {integrity: sha512-hHxJU6PAEUn0TP4S/ZOzuTUvJWuZ6eIKeNKb5RBpODvSl6hp1Wrw4s7ATY50rklRCScUDpHzVA/DQdSjJ3UoYQ==} @@ -4764,9 +4671,6 @@ packages: '@whatwg-node/server@0.7.7': resolution: {integrity: sha512-aHURgNDFm/48WVV3vhTMfnEKCYwYgdaRdRhZsQZx4UVFjGGkGay7Ys0+AYu9QT/jpoImv2oONkstoTMUprDofg==} - '@yarnpkg/lockfile@1.1.0': - resolution: {integrity: sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==} - JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -4800,24 +4704,6 @@ packages: resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} engines: {node: '>=6.5'} - abstract-leveldown@2.6.3: - resolution: {integrity: sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA==} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - - abstract-leveldown@2.7.2: - resolution: {integrity: sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w==} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - - abstract-leveldown@3.0.0: - resolution: {integrity: sha512-KUWx9UWGQD12zsmLNj64/pndaz4iJh/Pj7nopgkfDG6RlCcbMZvT6+9l7dchK4idog2Is8VdC/PvNbFuFmalIQ==} - engines: {node: '>=4'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - - abstract-leveldown@5.0.0: - resolution: {integrity: sha512-5mU5P1gXtsMIXg65/rsYGsi93+MlogXZ9FA8JnwKurHQg64bfXwGYVdVdijNTVNOlAsuIiOwHdvFFD5JqCJQ7A==} - engines: {node: '>=6'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - abstract-leveldown@6.2.3: resolution: {integrity: sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==} engines: {node: '>=6'} @@ -4853,9 +4739,6 @@ packages: aes-js@3.0.0: resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} - aes-js@3.1.2: - resolution: {integrity: sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==} - aes-js@4.0.0-beta.5: resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} @@ -4884,9 +4767,6 @@ packages: ajv: optional: true - ajv@5.5.2: - resolution: {integrity: sha512-Ajr4IcMXq/2QmMkEmSvxqfLN5zGmJ92gHXAeOXq1OekoH2rfDNsgdDoL2f7QaRCy7G/E6TpxBVdRuNraMztGHw==} - ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} @@ -4938,10 +4818,6 @@ packages: resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} engines: {node: '>=12'} - ansi-styles@2.2.1: - resolution: {integrity: sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==} - engines: {node: '>=0.10.0'} - ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -4961,9 +4837,6 @@ packages: antlr4ts@0.5.0-alpha.4: resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} - anymatch@1.3.2: - resolution: {integrity: sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==} - anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -4988,30 +4861,6 @@ packages: argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - arr-diff@2.0.0: - resolution: {integrity: sha512-dtXTVMkh6VkEEA7OhXnN1Ecb8aAGFdZ1LFxtOCoqj4qkyOJMt7+qs6Ahdy6p/NQCPYsRSXXivhSB/J5E9jmYKA==} - engines: {node: '>=0.10.0'} - - arr-diff@4.0.0: - resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} - engines: {node: '>=0.10.0'} - - arr-flatten@1.1.0: - resolution: {integrity: sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==} - engines: {node: '>=0.10.0'} - - arr-union@3.1.0: - resolution: {integrity: sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==} - engines: {node: '>=0.10.0'} - - array-back@1.0.4: - resolution: {integrity: sha512-1WxbZvrmyhkNoeYcizokbmh5oiOCIfyvGtcqbK3Ls1v1fKcquzxnQSceOx6tzq7jmai2kFLWIpGND2cLhH6TPw==} - engines: {node: '>=0.12.0'} - - array-back@2.0.0: - resolution: {integrity: sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==} - engines: {node: '>=4'} - array-back@3.1.0: resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} engines: {node: '>=6'} @@ -5042,14 +4891,6 @@ packages: resolution: {integrity: sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==} engines: {node: '>=0.10.0'} - array-unique@0.2.1: - resolution: {integrity: sha512-G2n5bG5fSUCpnsXz4+8FUkYsGPkNfLn9YvS66U5qbTIXI2Ynnlo4Bi42bWv+omKUCqz+ejzfClwne0alJWJPhg==} - engines: {node: '>=0.10.0'} - - array-unique@0.3.2: - resolution: {integrity: sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==} - engines: {node: '>=0.10.0'} - array.prototype.findlastindex@1.2.6: resolution: {integrity: sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==} engines: {node: '>= 0.4'} @@ -5062,10 +4903,6 @@ packages: resolution: {integrity: sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg==} engines: {node: '>= 0.4'} - array.prototype.reduce@1.0.8: - resolution: {integrity: sha512-DwuEqgXFBwbmZSRqt3BpQigWNUoqw9Ml2dTWdF3B2zQlQX4OeUE0zyuzX0fX0IbTvjdkZbcBTU3idgpO78qkTw==} - engines: {node: '>= 0.4'} - arraybuffer.prototype.slice@1.0.4: resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} engines: {node: '>= 0.4'} @@ -5073,9 +4910,6 @@ packages: asap@2.0.6: resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==} - asn1.js@4.10.1: - resolution: {integrity: sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==} - asn1@0.2.6: resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} @@ -5094,10 +4928,6 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} - assign-symbols@1.0.0: - resolution: {integrity: sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==} - engines: {node: '>=0.10.0'} - ast-parents@0.0.1: resolution: {integrity: sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA==} @@ -5105,9 +4935,6 @@ packages: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} - async-each@1.0.6: - resolution: {integrity: sha512-c646jH1avxr+aVpndVMeAfYw7wAa6idufrlN3LPA4PmKS0QEGp6PIC9nwz0WQkkvBGAMEki3pFdtxaF39J9vvg==} - async-eventemitter@0.2.4: resolution: {integrity: sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==} @@ -5127,9 +4954,6 @@ packages: async@1.5.2: resolution: {integrity: sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==} - async@2.6.2: - resolution: {integrity: sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==} - async@2.6.4: resolution: {integrity: sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==} @@ -5143,11 +4967,6 @@ packages: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} engines: {node: '>= 4.0.0'} - atob@2.1.2: - resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==} - engines: {node: '>= 4.5.0'} - hasBin: true - atomic-sleep@1.0.0: resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} engines: {node: '>=8.0.0'} @@ -5175,63 +4994,12 @@ packages: axios@1.12.2: resolution: {integrity: sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==} - babel-code-frame@6.26.0: - resolution: {integrity: sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==} - - babel-core@6.26.3: - resolution: {integrity: sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==} - - babel-generator@6.26.1: - resolution: {integrity: sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==} - - babel-helper-builder-binary-assignment-operator-visitor@6.24.1: - resolution: {integrity: sha512-gCtfYORSG1fUMX4kKraymq607FWgMWg+j42IFPc18kFQEsmtaibP4UrqsXt8FlEJle25HUd4tsoDR7H2wDhe9Q==} - - babel-helper-call-delegate@6.24.1: - resolution: {integrity: sha512-RL8n2NiEj+kKztlrVJM9JT1cXzzAdvWFh76xh/H1I4nKwunzE4INBXn8ieCZ+wh4zWszZk7NBS1s/8HR5jDkzQ==} - - babel-helper-define-map@6.26.0: - resolution: {integrity: sha512-bHkmjcC9lM1kmZcVpA5t2om2nzT/xiZpo6TJq7UlZ3wqKfzia4veeXbIhKvJXAMzhhEBd3cR1IElL5AenWEUpA==} - - babel-helper-explode-assignable-expression@6.24.1: - resolution: {integrity: sha512-qe5csbhbvq6ccry9G7tkXbzNtcDiH4r51rrPUbwwoTzZ18AqxWYRZT6AOmxrpxKnQBW0pYlBI/8vh73Z//78nQ==} - - babel-helper-function-name@6.24.1: - resolution: {integrity: sha512-Oo6+e2iX+o9eVvJ9Y5eKL5iryeRdsIkwRYheCuhYdVHsdEQysbc2z2QkqCLIYnNxkT5Ss3ggrHdXiDI7Dhrn4Q==} - - babel-helper-get-function-arity@6.24.1: - resolution: {integrity: sha512-WfgKFX6swFB1jS2vo+DwivRN4NB8XUdM3ij0Y1gnC21y1tdBoe6xjVnd7NSI6alv+gZXCtJqvrTeMW3fR/c0ng==} - - babel-helper-hoist-variables@6.24.1: - resolution: {integrity: sha512-zAYl3tqerLItvG5cKYw7f1SpvIxS9zi7ohyGHaI9cgDUjAT6YcY9jIEH5CstetP5wHIVSceXwNS7Z5BpJg+rOw==} - - babel-helper-optimise-call-expression@6.24.1: - resolution: {integrity: sha512-Op9IhEaxhbRT8MDXx2iNuMgciu2V8lDvYCNQbDGjdBNCjaMvyLf4wl4A3b8IgndCyQF8TwfgsQ8T3VD8aX1/pA==} - - babel-helper-regex@6.26.0: - resolution: {integrity: sha512-VlPiWmqmGJp0x0oK27Out1D+71nVVCTSdlbhIVoaBAj2lUgrNjBCRR9+llO4lTSb2O4r7PJg+RobRkhBrf6ofg==} - - babel-helper-remap-async-to-generator@6.24.1: - resolution: {integrity: sha512-RYqaPD0mQyQIFRu7Ho5wE2yvA/5jxqCIj/Lv4BXNq23mHYu/vxikOy2JueLiBxQknwapwrJeNCesvY0ZcfnlHg==} - - babel-helper-replace-supers@6.24.1: - resolution: {integrity: sha512-sLI+u7sXJh6+ToqDr57Bv973kCepItDhMou0xCP2YPVmR1jkHSCY+p1no8xErbV1Siz5QE8qKT1WIwybSWlqjw==} - - babel-helpers@6.24.1: - resolution: {integrity: sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==} - babel-jest@29.7.0: resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: '@babel/core': ^7.8.0 - babel-messages@6.23.0: - resolution: {integrity: sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==} - - babel-plugin-check-es2015-constants@6.22.0: - resolution: {integrity: sha512-B1M5KBP29248dViEo1owyY32lk1ZSH2DaNNrXLGt8lyjjHm7pBqAdQ7VKUPR6EEDO323+OvT3MQXbCin8ooWdA==} - babel-plugin-istanbul@6.1.1: resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} engines: {node: '>=8'} @@ -5240,107 +5008,17 @@ packages: resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - babel-plugin-syntax-async-functions@6.13.0: - resolution: {integrity: sha512-4Zp4unmHgw30A1eWI5EpACji2qMocisdXhAftfhXoSV9j0Tvj6nRFE3tOmRY912E0FMRm/L5xWE7MGVT2FoLnw==} - - babel-plugin-syntax-exponentiation-operator@6.13.0: - resolution: {integrity: sha512-Z/flU+T9ta0aIEKl1tGEmN/pZiI1uXmCiGFRegKacQfEJzp7iNsKloZmyJlQr+75FCJtiFfGIK03SiCvCt9cPQ==} - babel-plugin-syntax-hermes-parser@0.29.1: resolution: {integrity: sha512-2WFYnoWGdmih1I1J5eIqxATOeycOqRwYxAQBu3cUu/rhwInwHUg7k60AFNbuGjSDL8tje5GDrAnxzRLcu2pYcA==} - babel-plugin-syntax-trailing-function-commas@6.22.0: - resolution: {integrity: sha512-Gx9CH3Q/3GKbhs07Bszw5fPTlU+ygrOGfAhEt7W2JICwufpC4SuO0mG0+4NykPBSYPMJhqvVlDBU17qB1D+hMQ==} - babel-plugin-syntax-trailing-function-commas@7.0.0-beta.0: resolution: {integrity: sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==} - babel-plugin-transform-async-to-generator@6.24.1: - resolution: {integrity: sha512-7BgYJujNCg0Ti3x0c/DL3tStvnKS6ktIYOmo9wginv/dfZOrbSZ+qG4IRRHMBOzZ5Awb1skTiAsQXg/+IWkZYw==} - - babel-plugin-transform-es2015-arrow-functions@6.22.0: - resolution: {integrity: sha512-PCqwwzODXW7JMrzu+yZIaYbPQSKjDTAsNNlK2l5Gg9g4rz2VzLnZsStvp/3c46GfXpwkyufb3NCyG9+50FF1Vg==} - - babel-plugin-transform-es2015-block-scoped-functions@6.22.0: - resolution: {integrity: sha512-2+ujAT2UMBzYFm7tidUsYh+ZoIutxJ3pN9IYrF1/H6dCKtECfhmB8UkHVpyxDwkj0CYbQG35ykoz925TUnBc3A==} - - babel-plugin-transform-es2015-block-scoping@6.26.0: - resolution: {integrity: sha512-YiN6sFAQ5lML8JjCmr7uerS5Yc/EMbgg9G8ZNmk2E3nYX4ckHR01wrkeeMijEf5WHNK5TW0Sl0Uu3pv3EdOJWw==} - - babel-plugin-transform-es2015-classes@6.24.1: - resolution: {integrity: sha512-5Dy7ZbRinGrNtmWpquZKZ3EGY8sDgIVB4CU8Om8q8tnMLrD/m94cKglVcHps0BCTdZ0TJeeAWOq2TK9MIY6cag==} - - babel-plugin-transform-es2015-computed-properties@6.24.1: - resolution: {integrity: sha512-C/uAv4ktFP/Hmh01gMTvYvICrKze0XVX9f2PdIXuriCSvUmV9j+u+BB9f5fJK3+878yMK6dkdcq+Ymr9mrcLzw==} - - babel-plugin-transform-es2015-destructuring@6.23.0: - resolution: {integrity: sha512-aNv/GDAW0j/f4Uy1OEPZn1mqD+Nfy9viFGBfQ5bZyT35YqOiqx7/tXdyfZkJ1sC21NyEsBdfDY6PYmLHF4r5iA==} - - babel-plugin-transform-es2015-duplicate-keys@6.24.1: - resolution: {integrity: sha512-ossocTuPOssfxO2h+Z3/Ea1Vo1wWx31Uqy9vIiJusOP4TbF7tPs9U0sJ9pX9OJPf4lXRGj5+6Gkl/HHKiAP5ug==} - - babel-plugin-transform-es2015-for-of@6.23.0: - resolution: {integrity: sha512-DLuRwoygCoXx+YfxHLkVx5/NpeSbVwfoTeBykpJK7JhYWlL/O8hgAK/reforUnZDlxasOrVPPJVI/guE3dCwkw==} - - babel-plugin-transform-es2015-function-name@6.24.1: - resolution: {integrity: sha512-iFp5KIcorf11iBqu/y/a7DK3MN5di3pNCzto61FqCNnUX4qeBwcV1SLqe10oXNnCaxBUImX3SckX2/o1nsrTcg==} - - babel-plugin-transform-es2015-literals@6.22.0: - resolution: {integrity: sha512-tjFl0cwMPpDYyoqYA9li1/7mGFit39XiNX5DKC/uCNjBctMxyL1/PT/l4rSlbvBG1pOKI88STRdUsWXB3/Q9hQ==} - - babel-plugin-transform-es2015-modules-amd@6.24.1: - resolution: {integrity: sha512-LnIIdGWIKdw7zwckqx+eGjcS8/cl8D74A3BpJbGjKTFFNJSMrjN4bIh22HY1AlkUbeLG6X6OZj56BDvWD+OeFA==} - - babel-plugin-transform-es2015-modules-commonjs@6.26.2: - resolution: {integrity: sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==} - - babel-plugin-transform-es2015-modules-systemjs@6.24.1: - resolution: {integrity: sha512-ONFIPsq8y4bls5PPsAWYXH/21Hqv64TBxdje0FvU3MhIV6QM2j5YS7KvAzg/nTIVLot2D2fmFQrFWCbgHlFEjg==} - - babel-plugin-transform-es2015-modules-umd@6.24.1: - resolution: {integrity: sha512-LpVbiT9CLsuAIp3IG0tfbVo81QIhn6pE8xBJ7XSeCtFlMltuar5VuBV6y6Q45tpui9QWcy5i0vLQfCfrnF7Kiw==} - - babel-plugin-transform-es2015-object-super@6.24.1: - resolution: {integrity: sha512-8G5hpZMecb53vpD3mjs64NhI1au24TAmokQ4B+TBFBjN9cVoGoOvotdrMMRmHvVZUEvqGUPWL514woru1ChZMA==} - - babel-plugin-transform-es2015-parameters@6.24.1: - resolution: {integrity: sha512-8HxlW+BB5HqniD+nLkQ4xSAVq3bR/pcYW9IigY+2y0dI+Y7INFeTbfAQr+63T3E4UDsZGjyb+l9txUnABWxlOQ==} - - babel-plugin-transform-es2015-shorthand-properties@6.24.1: - resolution: {integrity: sha512-mDdocSfUVm1/7Jw/FIRNw9vPrBQNePy6wZJlR8HAUBLybNp1w/6lr6zZ2pjMShee65t/ybR5pT8ulkLzD1xwiw==} - - babel-plugin-transform-es2015-spread@6.22.0: - resolution: {integrity: sha512-3Ghhi26r4l3d0Js933E5+IhHwk0A1yiutj9gwvzmFbVV0sPMYk2lekhOufHBswX7NCoSeF4Xrl3sCIuSIa+zOg==} - - babel-plugin-transform-es2015-sticky-regex@6.24.1: - resolution: {integrity: sha512-CYP359ADryTo3pCsH0oxRo/0yn6UsEZLqYohHmvLQdfS9xkf+MbCzE3/Kolw9OYIY4ZMilH25z/5CbQbwDD+lQ==} - - babel-plugin-transform-es2015-template-literals@6.22.0: - resolution: {integrity: sha512-x8b9W0ngnKzDMHimVtTfn5ryimars1ByTqsfBDwAqLibmuuQY6pgBQi5z1ErIsUOWBdw1bW9FSz5RZUojM4apg==} - - babel-plugin-transform-es2015-typeof-symbol@6.23.0: - resolution: {integrity: sha512-fz6J2Sf4gYN6gWgRZaoFXmq93X+Li/8vf+fb0sGDVtdeWvxC9y5/bTD7bvfWMEq6zetGEHpWjtzRGSugt5kNqw==} - - babel-plugin-transform-es2015-unicode-regex@6.24.1: - resolution: {integrity: sha512-v61Dbbihf5XxnYjtBN04B/JBvsScY37R1cZT5r9permN1cp+b70DY3Ib3fIkgn1DI9U3tGgBJZVD8p/mE/4JbQ==} - - babel-plugin-transform-exponentiation-operator@6.24.1: - resolution: {integrity: sha512-LzXDmbMkklvNhprr20//RStKVcT8Cu+SQtX18eMHLhjHf2yFzwtQ0S2f0jQ+89rokoNdmwoSqYzAhq86FxlLSQ==} - - babel-plugin-transform-regenerator@6.26.0: - resolution: {integrity: sha512-LS+dBkUGlNR15/5WHKe/8Neawx663qttS6AGqoOUhICc9d1KciBvtrQSuc0PI+CxQ2Q/S1aKuJ+u64GtLdcEZg==} - - babel-plugin-transform-strict-mode@6.24.1: - resolution: {integrity: sha512-j3KtSpjyLSJxNoCDrhwiJad8kw0gJ9REGj8/CqL0HeRyLnvUNYV9zcqluL6QJSXh3nfsLEmSLvwRfGzrgR96Pw==} - babel-preset-current-node-syntax@1.2.0: resolution: {integrity: sha512-E/VlAEzRrsLEb2+dv8yp3bo4scof3l9nR4lrld+Iy5NyVqgVYUJnDAmunkhPMisRI32Qc4iRiz425d8vM++2fg==} peerDependencies: '@babel/core': ^7.0.0 || ^8.0.0-0 - babel-preset-env@1.7.0: - resolution: {integrity: sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==} - babel-preset-fbjs@3.4.0: resolution: {integrity: sha512-9ywCsCvo1ojrw0b+XYk7aFvTH6D9064t0RIL1rtMf3nsa02Xw41MS7sZw216Im35xj/UY0PDBQsa1brUDDF1Ow==} peerDependencies: @@ -5352,32 +5030,6 @@ packages: peerDependencies: '@babel/core': ^7.0.0 - babel-register@6.26.0: - resolution: {integrity: sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==} - - babel-runtime@6.26.0: - resolution: {integrity: sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==} - - babel-template@6.26.0: - resolution: {integrity: sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==} - - babel-traverse@6.26.0: - resolution: {integrity: sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==} - - babel-types@6.26.0: - resolution: {integrity: sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==} - - babelify@7.3.0: - resolution: {integrity: sha512-vID8Fz6pPN5pJMdlUnNFSfrlcx5MUule4k9aKs/zbZPyXxMTcRrB0M4Tarw22L8afr8eYSWxDPYCob3TdrqtlA==} - - babylon@6.18.0: - resolution: {integrity: sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==} - hasBin: true - - backoff@2.5.0: - resolution: {integrity: sha512-wC5ihrnUXmR2douXmXLCe5O3zg3GKIyvRi/hi58a/XyRxVI+3/yM0PYueQOZXPXQ9pxBislYkw+sF9b7C/RuMA==} - engines: {node: '>= 0.6'} - balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -5393,10 +5045,6 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - base@0.11.2: - resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==} - engines: {node: '>=0.10.0'} - baseline-browser-mapping@2.8.4: resolution: {integrity: sha512-L+YvJwGAgwJBV1p6ffpSTa2KRc69EeeYGYjRVWKs0GKrK+LON0GC0gV+rKSNtALEDvMDqkvCFq9r1r94/Gjwxw==} hasBin: true @@ -5424,10 +5072,6 @@ packages: bignumber.js@9.3.1: resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} - binary-extensions@1.13.1: - resolution: {integrity: sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==} - engines: {node: '>=0.10.0'} - binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -5438,9 +5082,6 @@ packages: bintrees@1.0.2: resolution: {integrity: sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==} - bip39@2.5.0: - resolution: {integrity: sha512-xwIx/8JKoT2+IPJpFEfXoWdYwP7UVAoUxxLNfGCfVowaJE7yg1Y5B1BVPqlUNsBq5/nGwmFkwRJ8xDW4sX8OdA==} - bip39@3.0.4: resolution: {integrity: sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==} @@ -5478,10 +5119,6 @@ packages: resolution: {integrity: sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - body-parser@1.20.3: - resolution: {integrity: sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==} - engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - bowser@2.12.1: resolution: {integrity: sha512-z4rE2Gxh7tvshQ4hluIT7XcFrgLIQaw9X3A+kTTRdovCz5PMukm/0QC/BKSYPj3omF5Qfypn9O/c5kgpmvYUCw==} @@ -5495,14 +5132,6 @@ packages: brace-expansion@2.0.2: resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==} - braces@1.8.5: - resolution: {integrity: sha512-xU7bpz2ytJl1bH9cgIurjpg/n8Gohy9GTw81heDYLJQ4RU60dlyJsa+atVF2pI0yMMvKxI9HkKwjePCj5XI1hw==} - engines: {node: '>=0.10.0'} - - braces@2.3.2: - resolution: {integrity: sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==} - engines: {node: '>=0.10.0'} - braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} @@ -5510,33 +5139,12 @@ packages: brorand@1.1.0: resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - browser-stdout@1.3.0: - resolution: {integrity: sha512-7Rfk377tpSM9TWBEeHs0FlDZGoAIei2V/4MdZJoFMBFAK6BqLpxAIUepGRHGdPFgGsLb02PXovC4qddyHvQqTg==} - browser-stdout@1.3.1: resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==} browserify-aes@1.2.0: resolution: {integrity: sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==} - browserify-cipher@1.0.1: - resolution: {integrity: sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==} - - browserify-des@1.0.2: - resolution: {integrity: sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==} - - browserify-rsa@4.1.1: - resolution: {integrity: sha512-YBjSAiTqM04ZVei6sXighu679a3SqWORA3qZTEqZImnlkDIFtKc6pNutpjyZ8RJTjQtuYfeetkxM11GwoYXMIQ==} - engines: {node: '>= 0.10'} - - browserify-sign@4.2.3: - resolution: {integrity: sha512-JWCZW6SKhfhjJxO8Tyiiy+XYB7cqd2S5/+WeYHsKdNKFlCBhKbblba1A/HN/90YwtxKc8tCErjffZl++UNmGiw==} - engines: {node: '>= 0.12'} - - browserslist@3.2.8: - resolution: {integrity: sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==} - hasBin: true - browserslist@4.26.0: resolution: {integrity: sha512-P9go2WrP9FiPwLv3zqRD/Uoxo0RSHjzFCiQz7d4vbmwNqQFo9T9WCeP/Qn5EbcKQY6DBbkxEXNcpJOmncNrb7A==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -5557,9 +5165,6 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - buffer-to-arraybuffer@0.0.5: - resolution: {integrity: sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ==} - buffer-writer@2.0.0: resolution: {integrity: sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==} engines: {node: '>=4'} @@ -5602,12 +5207,6 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - bytewise-core@1.2.3: - resolution: {integrity: sha512-nZD//kc78OOxeYtRlVk8/zXqTB4gf/nlguL1ggWA8FuchMyOxcyHR4QPQZMUmA7czC+YnaBrPUCubqAWe50DaA==} - - bytewise@1.1.0: - resolution: {integrity: sha512-rHuuseJ9iQ0na6UDhnrRVDh8YnWVlU6xM3VH6q/+yHDeUH2zIhUzP+2/h3LIrhLDBtTqzWpE3p3tP/boefskKQ==} - cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -5616,14 +5215,6 @@ packages: resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} engines: {node: ^16.14.0 || >=18.0.0} - cache-base@1.0.1: - resolution: {integrity: sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==} - engines: {node: '>=0.10.0'} - - cacheable-lookup@5.0.4: - resolution: {integrity: sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==} - engines: {node: '>=10.6.0'} - cacheable-lookup@7.0.0: resolution: {integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==} engines: {node: '>=14.16'} @@ -5632,17 +5223,6 @@ packages: resolution: {integrity: sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ==} engines: {node: '>=14.16'} - cacheable-request@6.1.0: - resolution: {integrity: sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==} - engines: {node: '>=8'} - - cacheable-request@7.0.4: - resolution: {integrity: sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==} - engines: {node: '>=8'} - - cachedown@1.0.0: - resolution: {integrity: sha512-t+yVk82vQWCJF3PsWHMld+jhhjkkWjcAzz8NbFx1iULOXWl8Tm/FdM4smZNVw3MRr0X+lVTx9PKzvEn4Ng19RQ==} - call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -5678,10 +5258,6 @@ packages: resolution: {integrity: sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==} engines: {node: '>=0.10.0'} - camelcase@4.1.0: - resolution: {integrity: sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw==} - engines: {node: '>=4'} - camelcase@5.3.1: resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} engines: {node: '>=6'} @@ -5733,10 +5309,6 @@ packages: resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} engines: {node: '>=18'} - chalk@1.1.3: - resolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==} - engines: {node: '>=0.10.0'} - chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -5786,12 +5358,6 @@ packages: resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==} engines: {node: '>= 16'} - checkpoint-store@1.1.0: - resolution: {integrity: sha512-J/NdY2WvIx654cc6LWSq/IYFFCUf75fFTgwzFnmbqyORH4MwgiQCgswLLKBGzmsyTI5V7i5bp/So6sMbDWhedg==} - - chokidar@1.7.0: - resolution: {integrity: sha512-mk8fAWcRUOxY7btlLtitj3A45jOwSAxH4tOFOoEGbVsl6cL6pPMWUy7dwZ/canfj3QEdP6FHSnf/l1c6/WkzVg==} - chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -5826,22 +5392,10 @@ packages: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} - cids@0.7.5: - resolution: {integrity: sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA==} - engines: {node: '>=4.0.0', npm: '>=3.0.0'} - deprecated: This module has been superseded by the multiformats module - cipher-base@1.0.6: resolution: {integrity: sha512-3Ek9H3X6pj5TgenXYtNWdaBon1tgYCaebd+XPg0keyjEbEfkD4KkmAxkQ/i1vYvxdcT5nscLBfq9VJRmCBcFSw==} engines: {node: '>= 0.10'} - class-is@1.1.0: - resolution: {integrity: sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==} - - class-utils@0.3.6: - resolution: {integrity: sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==} - engines: {node: '>=0.10.0'} - clean-stack@2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} @@ -5866,14 +5420,6 @@ packages: resolution: {integrity: sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==} engines: {node: 10.* || >= 12.*} - cli-truncate@2.1.0: - resolution: {integrity: sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==} - engines: {node: '>=8'} - - cli-truncate@3.1.0: - resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - cli-truncate@5.0.0: resolution: {integrity: sha512-ds7u02fPOOBpcUl2VSjLF3lfnAik9u7Zt0BTaaAQlT5RtABALl4cvpJHthXx+rM50J4gSfXKPH5Tix/tfdefUQ==} engines: {node: '>=20'} @@ -5885,9 +5431,6 @@ packages: cliui@3.2.0: resolution: {integrity: sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==} - cliui@4.1.0: - resolution: {integrity: sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==} - cliui@6.0.0: resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==} @@ -5898,17 +5441,6 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} - clone-response@1.0.3: - resolution: {integrity: sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==} - - clone@2.1.2: - resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==} - engines: {node: '>=0.8'} - - co@4.6.0: - resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} - engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - code-point-at@1.1.0: resolution: {integrity: sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==} engines: {node: '>=0.10.0'} @@ -5916,10 +5448,6 @@ packages: coingecko-api@1.0.10: resolution: {integrity: sha512-7YLLC85+daxAw5QlBWoHVBVpJRwoPr4HtwanCr8V/WRjoyHTa1Lb9DQAvv4MDJZHiz4no6HGnDQnddtjV35oRA==} - collection-visit@1.0.0: - resolution: {integrity: sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==} - engines: {node: '>=0.10.0'} - color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -5956,10 +5484,6 @@ packages: command-exists@1.2.9: resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==} - command-line-args@4.0.7: - resolution: {integrity: sha512-aUdPvQRAyBvQd2n7jXcsMDz68ckBJELXNzBybCHOibUWEg0mWTnaYCSRU8h9R+aNRSvDihJtssSRCiDRpLaezA==} - hasBin: true - command-line-args@5.2.1: resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} engines: {node: '>=4.0.0'} @@ -5984,15 +5508,9 @@ packages: resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} engines: {node: '>=20'} - commander@2.11.0: - resolution: {integrity: sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==} - commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - commander@3.0.2: - resolution: {integrity: sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==} - commander@8.3.0: resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} engines: {node: '>= 12'} @@ -6011,9 +5529,6 @@ packages: compare-versions@6.1.1: resolution: {integrity: sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==} - component-emitter@1.3.1: - resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} - concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -6044,9 +5559,6 @@ packages: resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==} engines: {node: '>= 0.6'} - content-hash@2.5.2: - resolution: {integrity: sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw==} - content-type@1.0.5: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} @@ -6064,9 +5576,6 @@ packages: engines: {node: '>=16'} hasBin: true - convert-source-map@1.9.0: - resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} - convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -6081,24 +5590,9 @@ packages: resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} engines: {node: '>= 0.6'} - cookie@0.7.1: - resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} - engines: {node: '>= 0.6'} - - cookiejar@2.1.4: - resolution: {integrity: sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==} - - copy-descriptor@0.1.1: - resolution: {integrity: sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==} - engines: {node: '>=0.10.0'} - core-js-pure@3.45.1: resolution: {integrity: sha512-OHnWFKgTUshEU8MK+lOs1H8kC8GkTi9Z1tvNkxrCcw9wl3MJIO7q2ld77wjWn4/xuGrVu2X+nME1iIIPBSdyEQ==} - core-js@2.6.12: - resolution: {integrity: sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==} - deprecated: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. - core-util-is@1.0.2: resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==} @@ -6144,9 +5638,6 @@ packages: engines: {node: '>=0.8'} hasBin: true - create-ecdh@4.0.4: - resolution: {integrity: sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==} - create-hash@1.1.3: resolution: {integrity: sha512-snRpch/kwQhcdlnZKYanNF1m0RDlrCdSKQaH87w1FCFPVPNCQ/Il9QJKAX2jVBZddRdaHBMC+zXa9Gw9tmkNUA==} @@ -6159,9 +5650,6 @@ packages: create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - cross-fetch@2.2.6: - resolution: {integrity: sha512-9JZz+vXCmfKUZ68zAptS7k4Nu8e2qcibe7WVZYps7sAgk5R8GYTc+T1WR0v1rlP9HxgARmOX1UTIJZFytajpNA==} - cross-fetch@3.1.5: resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==} @@ -6175,13 +5663,6 @@ packages: resolution: {integrity: sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A==} engines: {node: '>=16.0.0'} - cross-spawn@5.1.0: - resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} - - cross-spawn@6.0.6: - resolution: {integrity: sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==} - engines: {node: '>=4.8'} - cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -6189,13 +5670,6 @@ packages: crypt@0.0.2: resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==} - crypto-browserify@3.12.0: - resolution: {integrity: sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==} - - d@1.0.2: - resolution: {integrity: sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==} - engines: {node: '>=0.12'} - dargs@8.1.0: resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} engines: {node: '>=12'} @@ -6236,23 +5710,6 @@ packages: supports-color: optional: true - debug@3.1.0: - resolution: {integrity: sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - - debug@3.2.6: - resolution: {integrity: sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==} - deprecated: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -6281,14 +5738,6 @@ packages: decode-named-character-reference@1.2.0: resolution: {integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==} - decode-uri-component@0.2.2: - resolution: {integrity: sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==} - engines: {node: '>=0.10'} - - decompress-response@3.3.0: - resolution: {integrity: sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA==} - engines: {node: '>=4'} - decompress-response@4.2.1: resolution: {integrity: sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==} engines: {node: '>=8'} @@ -6308,10 +5757,6 @@ packages: resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} engines: {node: '>=6'} - deep-equal@1.1.2: - resolution: {integrity: sha512-5tdhKF6DbU7iIzrIOa1AOUt39ZRm13cmL1cGEh//aqR8x9+tNfbywRf0n5FD/18OKMdo7DNEtrX2t22ZAkI+eg==} - engines: {node: '>= 0.4'} - deep-extend@0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} @@ -6319,22 +5764,10 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - defer-to-connect@1.1.3: - resolution: {integrity: sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==} - defer-to-connect@2.0.1: resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} engines: {node: '>=10'} - deferred-leveldown@1.2.2: - resolution: {integrity: sha512-uukrWD2bguRtXilKt6cAWKyoXrTSMo5m7crUdLfWQmu8kIm88w3QZoUL+6nhpfKVmhHANER6Re3sKoNoZ3IKMA==} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - - deferred-leveldown@4.0.2: - resolution: {integrity: sha512-5fMC8ek8alH16QiV0lTCis610D1Zt1+LA4MS4d63JgS32lrCjTFDUFz2ao09/j2I4Bqb5jL4FZYwu7Jz0XO1ww==} - engines: {node: '>=6'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - deferred-leveldown@5.3.0: resolution: {integrity: sha512-a59VOT+oDy7vtAbLRCZwWgxu2BaCfd5Hk7wxJd48ei7I+nsg8Orlb9CLG0PMZienk9BSUKgeAqkO2+Lw+1+Ukw==} engines: {node: '>=6'} @@ -6352,21 +5785,6 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} - define-property@0.2.5: - resolution: {integrity: sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==} - engines: {node: '>=0.10.0'} - - define-property@1.0.0: - resolution: {integrity: sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==} - engines: {node: '>=0.10.0'} - - define-property@2.0.2: - resolution: {integrity: sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==} - engines: {node: '>=0.10.0'} - - defined@1.0.1: - resolution: {integrity: sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==} - delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} @@ -6395,9 +5813,6 @@ packages: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} - des.js@1.1.0: - resolution: {integrity: sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==} - destroy@1.0.4: resolution: {integrity: sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==} @@ -6405,10 +5820,6 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - detect-indent@4.0.0: - resolution: {integrity: sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==} - engines: {node: '>=0.10.0'} - detect-indent@6.1.0: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} @@ -6421,14 +5832,6 @@ packages: devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} - diff@3.3.1: - resolution: {integrity: sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==} - engines: {node: '>=0.3.1'} - - diff@3.5.0: - resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==} - engines: {node: '>=0.3.1'} - diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -6437,9 +5840,6 @@ packages: resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==} engines: {node: '>=0.3.1'} - diffie-hellman@5.0.3: - resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==} - difflib@0.2.4: resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} @@ -6454,9 +5854,6 @@ packages: resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} engines: {node: '>=0.10.0'} - dom-walk@0.1.2: - resolution: {integrity: sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==} - dot-case@3.0.4: resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} @@ -6472,10 +5869,6 @@ packages: resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==} engines: {node: '>=12'} - dotignore@0.1.2: - resolution: {integrity: sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw==} - hasBin: true - dottie@2.0.6: resolution: {integrity: sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA==} @@ -6487,9 +5880,6 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} - duplexer3@0.1.5: - resolution: {integrity: sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==} - duplexify@4.1.3: resolution: {integrity: sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==} @@ -6544,11 +5934,6 @@ packages: resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} engines: {node: '>= 0.8'} - encoding-down@5.0.4: - resolution: {integrity: sha512-8CIZLDcSKxgzT+zX8ZVfgNbu8Md2wq/iqa1Y7zyVR18QBEAc0Nmzuvj/N5ykSKpfGzjM8qxbaFntLPwnVoUhZw==} - engines: {node: '>=6'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - encoding-down@6.3.0: resolution: {integrity: sha512-QKrV0iKR6MZVJV08QY0wp1e7vF6QbhnbQhb07bwpEyuz4uZiZgPlEGdkCROuFkUwdxlFaiPIhjyarH1ee/3vhw==} engines: {node: '>=6'} @@ -6576,9 +5961,6 @@ packages: resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==} engines: {node: '>=18'} - eol@0.9.1: - resolution: {integrity: sha512-Ds/TEoZjwggRoz/Q2O7SE3i4Jm66mqTDfmdHdq/7DKVk3bro9Q8h6WdXKdPqFLMoqxrDK5SVRzHVPOS6uuGtrg==} - err-code@2.0.3: resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==} @@ -6596,9 +5978,6 @@ packages: resolution: {integrity: sha512-WSzPgsdLtTcQwm4CROfS5ju2Wa1QQcVeT37jFjYzdFz1r9ahadC8B8/a4qxJxM+09F18iumCdRmlr96ZYkQvEg==} engines: {node: '>= 0.4'} - es-array-method-boxes-properly@1.0.0: - resolution: {integrity: sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==} - es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -6623,17 +6002,6 @@ packages: resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==} engines: {node: '>= 0.4'} - es5-ext@0.10.64: - resolution: {integrity: sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==} - engines: {node: '>=0.10'} - - es6-iterator@2.0.3: - resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==} - - es6-symbol@3.1.4: - resolution: {integrity: sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==} - engines: {node: '>=0.12'} - esbuild@0.25.9: resolution: {integrity: sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==} engines: {node: '>=18'} @@ -6748,10 +6116,6 @@ packages: jiti: optional: true - esniff@2.0.1: - resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==} - engines: {node: '>=0.10'} - espree@10.4.0: resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -6790,9 +6154,6 @@ packages: resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} engines: {node: '>= 0.6'} - eth-block-tracker@3.0.1: - resolution: {integrity: sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug==} - eth-ens-namehash@2.0.8: resolution: {integrity: sha512-VWEI1+KJfz4Km//dadyvBBoBeSQ0MHTXPvr8UIXiLW6IanxvAV+DmlZAijZwAyggqGUfwQBeHf7tc9wzc1piSw==} @@ -6804,46 +6165,9 @@ packages: '@codechecks/client': optional: true - eth-json-rpc-infura@3.2.1: - resolution: {integrity: sha512-W7zR4DZvyTn23Bxc0EWsq4XGDdD63+XPUCEhV2zQvQGavDVC4ZpFDK4k99qN7bd7/fjj37+rxmuBOBeIqCA5Mw==} - deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. - - eth-json-rpc-middleware@1.6.0: - resolution: {integrity: sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==} - - eth-lib@0.1.29: - resolution: {integrity: sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ==} - - eth-lib@0.2.8: - resolution: {integrity: sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==} - - eth-query@2.1.2: - resolution: {integrity: sha512-srES0ZcvwkR/wd5OQBRA1bIJMww1skfGS0s8wlwK3/oNP4+wnds60krvu5R1QbpRQjMmpG5OMIWro5s7gvDPsA==} - - eth-sig-util@1.4.2: - resolution: {integrity: sha512-iNZ576iTOGcfllftB73cPB5AN+XUQAT/T8xzsILsghXC1o8gJUqe3RHlcDqagu+biFpYQ61KQrZZJza8eRSYqw==} - deprecated: Deprecated in favor of '@metamask/eth-sig-util' - - eth-sig-util@3.0.0: - resolution: {integrity: sha512-4eFkMOhpGbTxBQ3AMzVf0haUX2uTur7DpWiHzWyTURa28BVJJtOkcb9Ok5TV0YvEPG61DODPW7ZUATbJTslioQ==} - deprecated: Deprecated in favor of '@metamask/eth-sig-util' - - eth-tx-summary@3.2.4: - resolution: {integrity: sha512-NtlDnaVZah146Rm8HMRUNMgIwG/ED4jiqk0TME9zFheMl1jOp6jL1m0NKGjJwehXQ6ZKCPr16MTr+qspKpEXNg==} - - ethashjs@0.0.8: - resolution: {integrity: sha512-/MSbf/r2/Ld8o0l15AymjOTlPqpN8Cr4ByUEA9GtR4x0yAh3TdtDzEg29zMjXCNPI7u6E5fOQdj/Cf9Tc7oVNw==} - deprecated: 'New package name format for new versions: @ethereumjs/ethash. Please update.' - ethereum-bloom-filters@1.2.0: resolution: {integrity: sha512-28hyiE7HVsWubqhpVLVmZXFd4ITeHi+BUu05o9isf0GUpMtzBUi+8/gFrGaGYzvGAJQmJ3JKj77Mk9G98T84rA==} - ethereum-common@0.0.18: - resolution: {integrity: sha512-EoltVQTRNg2Uy4o84qpa2aXymXDJhxm7eos/ACOg0DG4baAbMjhbdAEsx9GeE8sC3XCxnYvrrzZDH8D8MtA2iQ==} - - ethereum-common@0.2.0: - resolution: {integrity: sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA==} - ethereum-cryptography@0.1.3: resolution: {integrity: sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==} @@ -6853,11 +6177,6 @@ packages: ethereum-cryptography@2.2.1: resolution: {integrity: sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==} - ethereum-waffle@3.4.4: - resolution: {integrity: sha512-PA9+jCjw4WC3Oc5ocSMBj5sXvueWQeAbvCA+hUlb6oFgwwKyq5ka3bWQ7QZcjzIX+TdFkxP4IbFmoY2D8Dkj9Q==} - engines: {node: '>=10.0'} - hasBin: true - ethereum-waffle@4.0.10: resolution: {integrity: sha512-iw9z1otq7qNkGDNcMoeNeLIATF9yKl1M8AIeu42ElfNBplq0e+5PeasQmm8ybY/elkZ1XyRO0JBQxQdVRb8bqQ==} engines: {node: '>=10.0'} @@ -6865,55 +6184,10 @@ packages: peerDependencies: ethers: '*' - ethereumjs-abi@0.6.5: - resolution: {integrity: sha512-rCjJZ/AE96c/AAZc6O3kaog4FhOsAViaysBxqJNy2+LHP0ttH0zkZ7nXdVHOAyt6lFwLO0nlCwWszysG/ao1+g==} - deprecated: This library has been deprecated and usage is discouraged. - ethereumjs-abi@0.6.8: resolution: {integrity: sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==} deprecated: This library has been deprecated and usage is discouraged. - ethereumjs-abi@https://codeload.github.com/ethereumjs/ethereumjs-abi/tar.gz/ee3994657fa7a427238e6ba92a84d0b529bbcde0: - resolution: {tarball: https://codeload.github.com/ethereumjs/ethereumjs-abi/tar.gz/ee3994657fa7a427238e6ba92a84d0b529bbcde0} - version: 0.6.8 - - ethereumjs-account@2.0.5: - resolution: {integrity: sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA==} - - ethereumjs-account@3.0.0: - resolution: {integrity: sha512-WP6BdscjiiPkQfF9PVfMcwx/rDvfZTjFKY0Uwc09zSQr9JfIVH87dYIJu0gNhBhpmovV4yq295fdllS925fnBA==} - deprecated: Please use Util.Account class found on package ethereumjs-util@^7.0.6 https://github.com/ethereumjs/ethereumjs-util/releases/tag/v7.0.6 - - ethereumjs-block@1.7.1: - resolution: {integrity: sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg==} - deprecated: 'New package name format for new versions: @ethereumjs/block. Please update.' - - ethereumjs-block@2.2.2: - resolution: {integrity: sha512-2p49ifhek3h2zeg/+da6XpdFR3GlqY3BIEiqxGF8j9aSRIgkb7M1Ky+yULBKJOu8PAZxfhsYA+HxUk2aCQp3vg==} - deprecated: 'New package name format for new versions: @ethereumjs/block. Please update.' - - ethereumjs-blockchain@4.0.4: - resolution: {integrity: sha512-zCxaRMUOzzjvX78DTGiKjA+4h2/sF0OYL1QuPux0DHpyq8XiNoF5GYHtb++GUxVlMsMfZV7AVyzbtgcRdIcEPQ==} - deprecated: 'New package name format for new versions: @ethereumjs/blockchain. Please update.' - - ethereumjs-common@1.5.0: - resolution: {integrity: sha512-SZOjgK1356hIY7MRj3/ma5qtfr/4B5BL+G4rP/XSMYr2z1H5el4RX5GReYCKmQmYI/nSBmRnwrZ17IfHuG0viQ==} - deprecated: 'New package name format for new versions: @ethereumjs/common. Please update.' - - ethereumjs-tx@1.3.7: - resolution: {integrity: sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA==} - deprecated: 'New package name format for new versions: @ethereumjs/tx. Please update.' - - ethereumjs-tx@2.1.2: - resolution: {integrity: sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw==} - deprecated: 'New package name format for new versions: @ethereumjs/tx. Please update.' - - ethereumjs-util@4.5.1: - resolution: {integrity: sha512-WrckOZ7uBnei4+AKimpuF1B3Fv25OmoRgmYCpGsP7u8PFxXAmAgiJSYT2kRWnt6fVIlKaQlZvuwXp7PIrmn3/w==} - - ethereumjs-util@5.2.1: - resolution: {integrity: sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ==} - ethereumjs-util@6.2.1: resolution: {integrity: sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==} @@ -6925,18 +6199,6 @@ packages: resolution: {integrity: sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==} engines: {node: '>=10.0.0'} - ethereumjs-vm@2.6.0: - resolution: {integrity: sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw==} - deprecated: 'New package name format for new versions: @ethereumjs/vm. Please update.' - - ethereumjs-vm@4.2.0: - resolution: {integrity: sha512-X6qqZbsY33p5FTuZqCnQ4+lo957iUJMM6Mpa6bL4UW0dxM6WmDSHuI4j/zOp1E2TDKImBGCJA9QPfc08PaNubA==} - deprecated: 'New package name format for new versions: @ethereumjs/vm. Please update.' - - ethereumjs-wallet@0.6.5: - resolution: {integrity: sha512-MDwjwB9VQVnpp/Dc1XzA6J1a3wgHQ4hSvA1uWNatdpOrtCbPVuQSKSyRnjLvS0a+KKMw2pvQ9Ybqpb3+eW8oNA==} - deprecated: 'New package name format for new versions: @ethereumjs/wallet. Please update.' - ethers@5.6.2: resolution: {integrity: sha512-EzGCbns24/Yluu7+ToWnMca3SXJ1Jk1BvWB7CCmVNxyOeM4LLvw2OLuIHhlkhQk1dtOcj9UMsdkxUh8RiG1dxQ==} @@ -6965,20 +6227,10 @@ packages: resolution: {integrity: sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==} engines: {node: '>=6.5.0', npm: '>=3'} - ethlint@1.2.5: - resolution: {integrity: sha512-x2nKK98zmd72SFWL3Ul1S6scWYf5QqG221N6/mFNMO661g7ASvTRINGIWVvHzsvflW6y4tvgMSjnTN5RCTuZug==} - hasBin: true - - event-emitter@0.3.5: - resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} - event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} - eventemitter3@4.0.4: - resolution: {integrity: sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ==} - eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} @@ -6992,26 +6244,6 @@ packages: evp_bytestokey@1.0.3: resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==} - execa@0.7.0: - resolution: {integrity: sha512-RztN09XglpYI7aBBrJCPW95jEH7YF1UEPOoX9yDhUTPdp7mK+CQvnLTuD10BNXZ3byLTu2uehZ8EcKT/4CGiFw==} - engines: {node: '>=4'} - - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - - expand-brackets@0.1.5: - resolution: {integrity: sha512-hxx03P2dJxss6ceIeri9cmYOT4SRs3Zk3afZwWpOsRqLqprhTR8u++SlC+sFGsQr7WGFPdMF7Gjc1njDLDK6UA==} - engines: {node: '>=0.10.0'} - - expand-brackets@2.1.4: - resolution: {integrity: sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==} - engines: {node: '>=0.10.0'} - - expand-range@1.8.2: - resolution: {integrity: sha512-AFASGfIlnIbkKPQwX1yHaDjFvh/1gyKJODme52V6IORh69uEYgZp0o9C+qsIGNVEiuuhQU0CSSl++Rlegg1qvA==} - engines: {node: '>=0.10.0'} - expand-template@2.0.3: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} @@ -7027,21 +6259,6 @@ packages: resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==} engines: {node: '>= 0.10.0'} - express@4.21.2: - resolution: {integrity: sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==} - engines: {node: '>= 0.10.0'} - - ext@1.7.0: - resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==} - - extend-shallow@2.0.1: - resolution: {integrity: sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==} - engines: {node: '>=0.10.0'} - - extend-shallow@3.0.2: - resolution: {integrity: sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==} - engines: {node: '>=0.10.0'} - extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -7052,14 +6269,6 @@ packages: resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} engines: {node: '>=4'} - extglob@0.3.2: - resolution: {integrity: sha512-1FOj1LOwn42TMrruOHGt18HemVnbwAmAak7krWk+wa93KXxGbK+2jpezm+ytJYDaBX0/SPLZFHKM7m+tKobWGg==} - engines: {node: '>=0.10.0'} - - extglob@2.0.4: - resolution: {integrity: sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==} - engines: {node: '>=0.10.0'} - extract-files@11.0.0: resolution: {integrity: sha512-FuoE1qtbJ4bBVvv94CC7s0oTnKUGvQs+Rjf1L2SJFfS+HTVVjhPFtehPdQ0JiGPqVNfSSZvL5yzHHQq2Z4WNhQ==} engines: {node: ^12.20 || >= 14.13} @@ -7068,18 +6277,12 @@ packages: resolution: {integrity: sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==} engines: {'0': node >=0.6.0} - fake-merkle-patricia-tree@1.0.1: - resolution: {integrity: sha512-Tgq37lkc9pUIgIKw5uitNUKcgcYL3R6JvXtKQbOf/ZSavXbidsksgp/pAY6p//uhw0I4yoMsvTSovvVIsk/qxA==} - fast-base64-decode@1.0.0: resolution: {integrity: sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q==} fast-decode-uri-component@1.0.1: resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} - fast-deep-equal@1.1.0: - resolution: {integrity: sha512-fueX787WZKCV0Is4/T2cyAdM4+x1S3MXXOAhavE1ys/W42SHAPacLTQhucja22QBYrfGw50M2sRiXPtTGv9Ymw==} - fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -7145,9 +6348,6 @@ packages: fecha@4.2.3: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} - fetch-ponyfill@4.1.0: - resolution: {integrity: sha512-knK9sGskIg2T7OnYLdZ2hZXn0CtDrAIBxYQLpmEf0BqfdWnwmM1weccUl5+4EdA44tzNSFAuxITPbXtPehUB3g==} - fets@0.1.5: resolution: {integrity: sha512-mL/ya591WOgCP1yBBPbp8E37nynj8QQF6iQCUVl0aHDL80BZ9SOL4BcKBy0dnKdC+clnnAkMm05KB9hsj4m4jQ==} @@ -7162,18 +6362,6 @@ packages: file-uri-to-path@1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} - filename-regex@2.0.1: - resolution: {integrity: sha512-BTCqyBaWBTsauvnHiE8i562+EdJj+oUpkqWp2R1iCoR8f6oo8STRu3of7WJJ0TqWtxN50a5YFpzYK4Jj9esYfQ==} - engines: {node: '>=0.10.0'} - - fill-range@2.2.4: - resolution: {integrity: sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==} - engines: {node: '>=0.10.0'} - - fill-range@4.0.0: - resolution: {integrity: sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==} - engines: {node: '>=0.10.0'} - fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -7186,14 +6374,6 @@ packages: resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==} engines: {node: '>= 0.8'} - finalhandler@1.3.1: - resolution: {integrity: sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==} - engines: {node: '>= 0.8'} - - find-replace@1.0.3: - resolution: {integrity: sha512-KrUnjzDCD9426YnCP56zGYy/eieTnhtK6Vn++j+JJzmlsWWwEkDnsyVF575spT6HJ6Ow9tlbT3TQTDsa+O4UWA==} - engines: {node: '>=4.0.0'} - find-replace@3.0.0: resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} engines: {node: '>=4.0.0'} @@ -7202,10 +6382,6 @@ packages: resolution: {integrity: sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==} engines: {node: '>=0.10.0'} - find-up@2.1.0: - resolution: {integrity: sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==} - engines: {node: '>=4'} - find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -7218,12 +6394,6 @@ packages: resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} engines: {node: '>=18'} - find-yarn-workspace-root@1.2.1: - resolution: {integrity: sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q==} - - find-yarn-workspace-root@2.0.0: - resolution: {integrity: sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==} - flat-cache@4.0.1: resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} engines: {node: '>=16'} @@ -7238,9 +6408,6 @@ packages: flow-enums-runtime@0.0.6: resolution: {integrity: sha512-3PYnM29RFXwvAN6Pc/scUfkI7RwhQ/xqyLUyPNlXUp9S40zI8nup9tUSrTLSVnWGBN38FNiGWbwZOB6uR4OGdw==} - flow-stoplight@1.0.0: - resolution: {integrity: sha512-rDjbZUKpN8OYhB0IE/vY/I8UWO/602IIJEU/76Tv4LvYnwHCk0BCsvz4eRr9n+FQcri7L5cyaXOo0+/Kh4HisA==} - fmix@0.1.0: resolution: {integrity: sha512-Y6hyofImk9JdzU8k5INtTXX1cu8LDlePWDFU5sftm9H+zKCr5SGrVjdhkvsim646cw5zD0nADj8oHyXMZmCZ9w==} @@ -7260,14 +6427,6 @@ packages: resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} engines: {node: '>= 0.4'} - for-in@1.0.2: - resolution: {integrity: sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==} - engines: {node: '>=0.10.0'} - - for-own@0.1.5: - resolution: {integrity: sha512-SKmowqGTJoPzLO1T0BBJpkfp3EMacCMOuH40hOUbrbzElVktk4DioXVM99QkLCyKoiuOmyjgcWMpVz2xjE7LZw==} - engines: {node: '>=0.10.0'} - foreach@2.0.6: resolution: {integrity: sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==} @@ -7309,10 +6468,6 @@ packages: fp-ts@1.19.3: resolution: {integrity: sha512-H5KQDspykdHuztLTg+ajGN0Z2qUjcEf3Ybxc6hLt0k7/zPkn29XnKnxlBPyW2XIddWrGaJBzBl4VLYOtk39yZg==} - fragment-cache@0.2.1: - resolution: {integrity: sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==} - engines: {node: '>=0.10.0'} - fresh@0.5.2: resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} engines: {node: '>= 0.6'} @@ -7331,9 +6486,6 @@ packages: resolution: {integrity: sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==} engines: {node: '>=14.14'} - fs-extra@4.0.3: - resolution: {integrity: sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==} - fs-extra@7.0.1: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} @@ -7346,9 +6498,6 @@ packages: resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} engines: {node: '>=10'} - fs-minipass@1.2.7: - resolution: {integrity: sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==} - fs-minipass@2.1.0: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} @@ -7363,12 +6512,6 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - fsevents@1.2.13: - resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} - engines: {node: '>= 4.0'} - os: [darwin] - deprecated: Upgrade to fsevents v2 to mitigate potential security issues - fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -7387,13 +6530,6 @@ packages: functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - ganache-core@2.13.2: - resolution: {integrity: sha512-tIF5cR+ANQz0+3pHWxHjIwHqFXcVo0Mb+kcsNhglNFALcYo49aQpnS9dqHartqPfMFjiHh/qFoD3mYK0d/qGgw==} - engines: {node: '>=8.9.0'} - deprecated: ganache-core is now ganache; visit https://trfl.io/g7 for details - bundledDependencies: - - keccak - ganache@7.4.3: resolution: {integrity: sha512-RpEDUiCkqbouyE7+NMXG26ynZ+7sGiODU84Kz+FVoXUnQ4qQM4M8wif3Y4qUCt+D/eM1RVeGq0my62FPD6Y1KA==} hasBin: true @@ -7445,18 +6581,6 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} - get-stream@3.0.0: - resolution: {integrity: sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==} - engines: {node: '>=4'} - - get-stream@4.1.0: - resolution: {integrity: sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==} - engines: {node: '>=6'} - - get-stream@5.2.0: - resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} - engines: {node: '>=8'} - get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -7468,10 +6592,6 @@ packages: get-tsconfig@4.13.0: resolution: {integrity: sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==} - get-value@2.0.6: - resolution: {integrity: sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==} - engines: {node: '>=0.10.0'} - getpass@0.1.7: resolution: {integrity: sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==} @@ -7487,13 +6607,6 @@ packages: github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} - glob-base@0.3.0: - resolution: {integrity: sha512-ab1S1g1EbO7YzauaJLkgLp7DZVAqj9M/dvKlTt8DkXA2tiOIcSMrlVI2J1RZyB5iJVccEscjGn+kpOG9788MHA==} - engines: {node: '>=0.10.0'} - - glob-parent@2.0.0: - resolution: {integrity: sha512-JDYOvfxio/t42HKdxkAYaCiBN7oYiuxykOxKxdaUW5Qn0zaYN3gRQWolrwdnf0shM9/EP0ebuuTmyoXNr1cC5w==} - glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -7515,10 +6628,6 @@ packages: resolution: {integrity: sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==} deprecated: Glob versions prior to v9 are no longer supported - glob@7.1.2: - resolution: {integrity: sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==} - deprecated: Glob versions prior to v9 are no longer supported - glob@7.1.7: resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} deprecated: Glob versions prior to v9 are no longer supported @@ -7544,9 +6653,6 @@ packages: resolution: {integrity: sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==} engines: {node: '>=6'} - global@4.4.0: - resolution: {integrity: sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==} - globals@14.0.0: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} @@ -7555,10 +6661,6 @@ packages: resolution: {integrity: sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==} engines: {node: '>=18'} - globals@9.18.0: - resolution: {integrity: sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==} - engines: {node: '>=0.10.0'} - globalthis@1.0.4: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} @@ -7575,18 +6677,10 @@ packages: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} - got@11.8.6: - resolution: {integrity: sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==} - engines: {node: '>=10.19.0'} - got@12.6.1: resolution: {integrity: sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==} engines: {node: '>=14.16'} - got@9.6.0: - resolution: {integrity: sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==} - engines: {node: '>=8.6'} - graceful-fs@4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} @@ -7639,10 +6733,6 @@ packages: resolution: {integrity: sha512-0oKGaR+y3qcS5mCu1vb7KG+a89vjn06C7Ihq/dDl3jA+A8B3TKomvi3CiEcVLJQGalbu8F52LxkOym7U5sSfbg==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} - growl@1.10.3: - resolution: {integrity: sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==} - engines: {node: '>=4.x'} - handlebars@4.7.8: resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} engines: {node: '>=0.4.7'} @@ -7726,10 +6816,6 @@ packages: resolution: {integrity: sha512-0Z0KI/m6wJYCMZgDK3QuVqR59lSa3aMu6QHKqnbIYXKu/phQ+YFKJZAY4zkUKX21ZjcrrRg25qLUzZw1bO6g/A==} hasBin: true - has-ansi@2.0.0: - resolution: {integrity: sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==} - engines: {node: '>=0.10.0'} - has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} engines: {node: '>= 0.4'} @@ -7738,10 +6824,6 @@ packages: resolution: {integrity: sha512-DyYHfIYwAJmjAjSSPKANxI8bFY9YtFrgkAfinBojQ8YJTOuOuav64tMUJv584SES4xl74PmuaevIyaLESHdTAA==} engines: {node: '>=0.10.0'} - has-flag@2.0.0: - resolution: {integrity: sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==} - engines: {node: '>=0.10.0'} - has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} @@ -7768,33 +6850,9 @@ packages: has-unicode@2.0.1: resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==} - has-value@0.3.1: - resolution: {integrity: sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==} - engines: {node: '>=0.10.0'} - - has-value@1.0.0: - resolution: {integrity: sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==} - engines: {node: '>=0.10.0'} - - has-values@0.1.4: - resolution: {integrity: sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==} - engines: {node: '>=0.10.0'} - - has-values@1.0.0: - resolution: {integrity: sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==} - engines: {node: '>=0.10.0'} - - has@1.0.4: - resolution: {integrity: sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==} - engines: {node: '>= 0.4.0'} - hash-base@2.0.2: resolution: {integrity: sha512-0TROgQ1/SxE6KmxWSvXHvRj90/Xo1JvZShofnYF+f6ZsGtR4eES7WfrQzPalmyagfKZCXpVnitiRebZulWsbiw==} - hash-base@3.0.5: - resolution: {integrity: sha512-vXm0l45VbcHEVlTCzs8M+s0VeYsB2lnlAaThoLKGXr3bE/VWDOelNUnycUPEhKEaXARL2TEFjBOyUiM6+55KBg==} - engines: {node: '>= 0.10'} - hash-base@3.1.0: resolution: {integrity: sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==} engines: {node: '>=4'} @@ -7809,10 +6867,6 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} - he@1.1.1: - resolution: {integrity: sha512-z/GDPjlRMNOa2XJiB4em8wJpuuBfrFOlYKTZxtpkdr1uPdibHI8rYA3MY0KDObpVyaes0e/aunid/t88ZI2EKA==} - hasBin: true - he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true @@ -7820,9 +6874,6 @@ packages: header-case@2.0.4: resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==} - heap@0.2.6: - resolution: {integrity: sha512-MzzWcnfB1e4EG2vHi3dXHoBupmuXNZzx6pY6HldVS55JKKBoq3xOyzfSaZRkJp37HIhEYC78knabHff3zc4dQQ==} - heap@0.2.7: resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} @@ -7843,10 +6894,6 @@ packages: hmac-drbg@1.0.1: resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} - home-or-tmp@2.0.0: - resolution: {integrity: sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==} - engines: {node: '>=0.10.0'} - hosted-git-info@2.8.9: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} @@ -7872,9 +6919,6 @@ packages: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} engines: {node: '>= 0.8'} - http-https@1.0.0: - resolution: {integrity: sha512-o0PWwVCSp3O0wS6FvNr6xfBCHgt0m1tvPLFOCc2iFDKTRAXhB7m8klDf7ErowFH8POa6dVdGatKU5I1YYwzUyg==} - http-proxy-agent@7.0.2: resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} engines: {node: '>= 14'} @@ -7886,10 +6930,6 @@ packages: resolution: {integrity: sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==} engines: {node: '>=0.8', npm: '>=1.3.7'} - http2-wrapper@1.0.3: - resolution: {integrity: sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==} - engines: {node: '>=10.19.0'} - http2-wrapper@2.2.1: resolution: {integrity: sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==} engines: {node: '>=10.19.0'} @@ -7906,15 +6946,6 @@ packages: resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==} hasBin: true - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - - husky@7.0.4: - resolution: {integrity: sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==} - engines: {node: '>=12'} - hasBin: true - husky@9.1.7: resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} engines: {node: '>=18'} @@ -8058,20 +7089,12 @@ packages: resolution: {integrity: sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==} engines: {node: '>=0.10.0'} - is-accessor-descriptor@1.0.1: - resolution: {integrity: sha512-YBUanLI8Yoihw923YeFUS5fs0fF2f5TSFTNiYAAzhhDscDa3lEqYuz1pDOEP5KvX94I9ey3vsqjJcLVFVU+3QA==} - engines: {node: '>= 0.10'} - is-alphabetical@2.0.1: resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==} is-alphanumerical@2.0.1: resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==} - is-arguments@1.2.0: - resolution: {integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==} - engines: {node: '>= 0.4'} - is-array-buffer@3.0.5: resolution: {integrity: sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==} engines: {node: '>= 0.4'} @@ -8090,10 +7113,6 @@ packages: resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} engines: {node: '>= 0.4'} - is-binary-path@1.0.1: - resolution: {integrity: sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==} - engines: {node: '>=0.10.0'} - is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -8102,25 +7121,14 @@ packages: resolution: {integrity: sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==} engines: {node: '>= 0.4'} - is-buffer@1.1.6: - resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} - is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} - is-ci@2.0.0: - resolution: {integrity: sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==} - hasBin: true - is-core-module@2.16.1: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} - is-data-descriptor@1.0.1: - resolution: {integrity: sha512-bc4NlCDiCr28U4aEsQ3Qs2491gVq4V8G7MQyws968ImqjKuYtTJXrl7Vq7jsN7Ly/C3xj5KWFrY7sHNeDkAzXw==} - engines: {node: '>= 0.4'} - is-data-view@1.0.2: resolution: {integrity: sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==} engines: {node: '>= 0.4'} @@ -8132,14 +7140,6 @@ packages: is-decimal@2.0.1: resolution: {integrity: sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==} - is-descriptor@0.1.7: - resolution: {integrity: sha512-C3grZTvObeN1xud4cRWl366OMXZTj0+HGyk4hvfpx4ZHt1Pb60ANSXqCK7pdOTeUQpRzECBSTphqvD7U+l22Eg==} - engines: {node: '>= 0.4'} - - is-descriptor@1.0.3: - resolution: {integrity: sha512-JCNNGbwWZEVaSPtS45mdtrneRWJFp07LLmykxeFV5F6oBvNF8vHSfJuJgoT472pSfk+Mf8VnlrspaFBHWM8JAw==} - engines: {node: '>= 0.4'} - is-directory@0.3.1: resolution: {integrity: sha512-yVChGzahRFvbkscn2MlwGismPO12i9+znNruC5gVEntG3qu0xQMzsGg/JFbrsqDOHtHFPci+V5aP5T9I+yeKqw==} engines: {node: '>=0.10.0'} @@ -8149,26 +7149,6 @@ packages: engines: {node: '>=8'} hasBin: true - is-dotfile@1.0.3: - resolution: {integrity: sha512-9YclgOGtN/f8zx0Pr4FQYMdibBiTaH3sn52vjYip4ZSf6C4/6RfTEZ+MR4GvKhCxdPh21Bg42/WL55f6KSnKpg==} - engines: {node: '>=0.10.0'} - - is-equal-shallow@0.1.3: - resolution: {integrity: sha512-0EygVC5qPvIyb+gSz7zdD5/AAoS6Qrx1e//6N4yv4oNm30kqvdmG66oZFWVlQHUWe5OjP08FuTw2IdT0EOTcYA==} - engines: {node: '>=0.10.0'} - - is-extendable@0.1.1: - resolution: {integrity: sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==} - engines: {node: '>=0.10.0'} - - is-extendable@1.0.1: - resolution: {integrity: sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==} - engines: {node: '>=0.10.0'} - - is-extglob@1.0.0: - resolution: {integrity: sha512-7Q+VbVafe6x2T+Tu6NcOf6sRklazEPmBoB3IWk3WdGZM2iGUwU/Oe3Wtq5lSEkDTTlpp8yx+5t4pzO/i9Ty1ww==} - engines: {node: '>=0.10.0'} - is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -8177,14 +7157,6 @@ packages: resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} engines: {node: '>= 0.4'} - is-finite@1.1.0: - resolution: {integrity: sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==} - engines: {node: '>=0.10.0'} - - is-fn@1.0.0: - resolution: {integrity: sha512-XoFPJQmsAShb3jEQRfzf2rqXavq7fIqF/jOekp308JlThqrODnMpweVSGilKTCXELfLhltGP2AGgbQGVP8F1dg==} - engines: {node: '>=0.10.0'} - is-fullwidth-code-point@1.0.0: resolution: {integrity: sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==} engines: {node: '>=0.10.0'} @@ -8197,25 +7169,14 @@ packages: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} - is-fullwidth-code-point@4.0.0: - resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} - engines: {node: '>=12'} - is-fullwidth-code-point@5.1.0: resolution: {integrity: sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ==} engines: {node: '>=18'} - is-function@1.0.2: - resolution: {integrity: sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==} - is-generator-function@1.1.0: resolution: {integrity: sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==} engines: {node: '>= 0.4'} - is-glob@2.0.1: - resolution: {integrity: sha512-a1dBeB19NXsf/E0+FHqkagizel/LQw2DjSQpvQrj3zT+jYPpaUCryPnrQajXKFLCMuf4I6FhRpaGtw4lPrG6Eg==} - engines: {node: '>=0.10.0'} - is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -8245,18 +7206,6 @@ packages: resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} engines: {node: '>= 0.4'} - is-number@2.1.0: - resolution: {integrity: sha512-QUzH43Gfb9+5yckcrSA0VBDwEtDUchrk4F6tfJZQuNzDJbEDB9cZNzSfXGQ1jqmdDY/kl41lUOWM9syA8z8jlg==} - engines: {node: '>=0.10.0'} - - is-number@3.0.0: - resolution: {integrity: sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==} - engines: {node: '>=0.10.0'} - - is-number@4.0.0: - resolution: {integrity: sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==} - engines: {node: '>=0.10.0'} - is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -8269,22 +7218,6 @@ packages: resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} engines: {node: '>=8'} - is-plain-object@2.0.4: - resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} - engines: {node: '>=0.10.0'} - - is-posix-bracket@0.1.1: - resolution: {integrity: sha512-Yu68oeXJ7LeWNmZ3Zov/xg/oDBnBK2RNxwYY1ilNJX+tKKZqgPK+qOn/Gs9jEu66KDY9Netf5XLKNGzas/vPfQ==} - engines: {node: '>=0.10.0'} - - is-primitive@2.0.0: - resolution: {integrity: sha512-N3w1tFaRfk3UrPfqeRyD+GYDASU3W5VinKhlORy8EWVf/sIdDL9GAcew85XmktCfH+ngG7SRXEVDoO18WMdB/Q==} - engines: {node: '>=0.10.0'} - - is-regex@1.1.4: - resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} - engines: {node: '>= 0.4'} - is-regex@1.2.1: resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} engines: {node: '>= 0.4'} @@ -8301,10 +7234,6 @@ packages: resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} engines: {node: '>= 0.4'} - is-stream@1.1.0: - resolution: {integrity: sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==} - engines: {node: '>=0.10.0'} - is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -8369,9 +7298,6 @@ packages: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} - isarray@0.0.1: - resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} - isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -8381,14 +7307,6 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - isobject@2.1.0: - resolution: {integrity: sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==} - engines: {node: '>=0.10.0'} - - isobject@3.0.1: - resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} - engines: {node: '>=0.10.0'} - isomorphic-unfetch@3.1.0: resolution: {integrity: sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==} @@ -8469,13 +7387,6 @@ packages: js-sha3@0.8.0: resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} - js-string-escape@1.0.1: - resolution: {integrity: sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==} - engines: {node: '>= 0.8'} - - js-tokens@3.0.2: - resolution: {integrity: sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -8497,14 +7408,6 @@ packages: jsc-safe-url@0.2.4: resolution: {integrity: sha512-0wM3YBWtYePOjfyXQH5MWQ8H7sdk5EXSwZvmSLKk2RboVQ2Bu239jycHDz5J/8Blf3K0Qnoy2b6xD+z10MFB+Q==} - jsesc@0.5.0: - resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==} - hasBin: true - - jsesc@1.3.0: - resolution: {integrity: sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==} - hasBin: true - jsesc@3.1.0: resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} engines: {node: '>=6'} @@ -8516,9 +7419,6 @@ packages: json-bigint@1.0.0: resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==} - json-buffer@3.0.0: - resolution: {integrity: sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==} - json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} @@ -8531,22 +7431,10 @@ packages: json-pointer@0.6.2: resolution: {integrity: sha512-vLWcKbOaXlO+jvRy4qNd+TI1QUPZzfJj1tpJ3vAXDych5XJf93ftpUKe5pKCrzyIIwgBJcOcCVRUfqQP25afBw==} - json-rpc-engine@3.8.0: - resolution: {integrity: sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA==} - - json-rpc-error@2.0.0: - resolution: {integrity: sha512-EwUeWP+KgAZ/xqFpaP6YDAXMtCJi+o/QQpCQFIYyxr01AdADi2y413eM8hSqJcoQym9WMePAJWoaODEJufC4Ug==} - - json-rpc-random-id@1.0.1: - resolution: {integrity: sha512-RJ9YYNCkhVDBuP4zN5BBtYAzEl03yq/jIIsyif0JY9qyJuQQZNeDK7anAPKKlyEtLSj2s8h6hNh2F8zO5q7ScA==} - json-schema-to-ts@2.12.0: resolution: {integrity: sha512-uTde38yBm5lzJSRPWRaasxZo72pb+JGE4iUksNdNfAkFaLhV4N9akeBxPPUpZy5onINt9Zo0oTLrAoEXyZESiQ==} engines: {node: '>=16'} - json-schema-traverse@0.3.1: - resolution: {integrity: sha512-4JD/Ivzg7PoW8NzdrBSr3UFwC9mHgvI7Z6z3QGBsSHgKaRTUDmyZAAKJo2UbG1kUVfS9WS8bi36N49U1xw43DA==} - json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -8559,10 +7447,6 @@ packages: json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} - json-stable-stringify@1.3.0: - resolution: {integrity: sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==} - engines: {node: '>= 0.4'} - json-stream-stringify@3.1.6: resolution: {integrity: sha512-x7fpwxOkbhFCaJDJ8vb1fBY3DdSa4AlITaz+HHILQJzdPMnHEFjxPwVUi1ALIbcIxDE0PNe/0i7frnY8QnBQog==} engines: {node: '>=7.10.1'} @@ -8570,10 +7454,6 @@ packages: json-stringify-safe@5.0.1: resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} - json5@0.5.1: - resolution: {integrity: sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==} - hasBin: true - json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} hasBin: true @@ -8595,9 +7475,6 @@ packages: jsonfile@6.2.0: resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==} - jsonify@0.0.1: - resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==} - jsonparse@1.3.1: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} @@ -8625,27 +7502,13 @@ packages: resolution: {integrity: sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q==} engines: {node: '>=10.0.0'} - keyv@3.1.0: - resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==} - keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} - kind-of@3.2.2: - resolution: {integrity: sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==} - engines: {node: '>=0.10.0'} - - kind-of@4.0.0: - resolution: {integrity: sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==} - engines: {node: '>=0.10.0'} - kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} - klaw-sync@6.0.0: - resolution: {integrity: sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==} - klaw@1.3.1: resolution: {integrity: sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==} @@ -8668,10 +7531,6 @@ packages: resolution: {integrity: sha512-ShaNPPzgUi+iGj9bsQ0TPRm6MuOcPpc1NklL0/IzJsvB0OdHwWoPhmeTVR5z0oC3zzLebrojozo/nt8d2XTZbQ==} hasBin: true - level-codec@7.0.1: - resolution: {integrity: sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==} - deprecated: Superseded by level-transcoder (https://github.com/Level/community#faq) - level-codec@9.0.2: resolution: {integrity: sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ==} engines: {node: '>=6'} @@ -8682,80 +7541,33 @@ packages: engines: {node: '>=6'} deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - level-errors@1.0.5: - resolution: {integrity: sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - level-errors@2.0.1: resolution: {integrity: sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw==} engines: {node: '>=6'} deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - level-iterator-stream@1.3.1: - resolution: {integrity: sha512-1qua0RHNtr4nrZBgYlpV0qHHeHpcRRWTxEZJ8xsemoHAXNL5tbooh4tPEEqIqsbWCAJBmUmkwYK/sW5OrFjWWw==} - - level-iterator-stream@2.0.3: - resolution: {integrity: sha512-I6Heg70nfF+e5Y3/qfthJFexhRw/Gi3bIymCoXAlijZdAcLaPuWSJs3KXyTYf23ID6g0o2QF62Yh+grOXY3Rig==} - engines: {node: '>=4'} - - level-iterator-stream@3.0.1: - resolution: {integrity: sha512-nEIQvxEED9yRThxvOrq8Aqziy4EGzrxSZK+QzEFAVuJvQ8glfyZ96GB6BoI4sBbLfjMXm2w4vu3Tkcm9obcY0g==} - engines: {node: '>=6'} - level-iterator-stream@4.0.2: resolution: {integrity: sha512-ZSthfEqzGSOMWoUGhTXdX9jv26d32XJuHz/5YnuHZzH6wldfWMOVwI9TBtKcya4BKTyTt3XVA0A3cF3q5CY30Q==} engines: {node: '>=6'} - level-mem@3.0.1: - resolution: {integrity: sha512-LbtfK9+3Ug1UmvvhR2DqLqXiPW1OJ5jEh0a3m9ZgAipiwpSxGj/qaVVy54RG5vAQN1nCuXqjvprCuKSCxcJHBg==} - engines: {node: '>=6'} - deprecated: Superseded by memory-level (https://github.com/Level/community#faq) - level-mem@5.0.1: resolution: {integrity: sha512-qd+qUJHXsGSFoHTziptAKXoLX87QjR7v2KMbqncDXPxQuCdsQlzmyX+gwrEHhlzn08vkf8TyipYyMmiC6Gobzg==} engines: {node: '>=6'} deprecated: Superseded by memory-level (https://github.com/Level/community#faq) - level-packager@4.0.1: - resolution: {integrity: sha512-svCRKfYLn9/4CoFfi+d8krOtrp6RoX8+xm0Na5cgXMqSyRru0AnDYdLl+YI8u1FyS6gGZ94ILLZDE5dh2but3Q==} - engines: {node: '>=6'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - level-packager@5.1.1: resolution: {integrity: sha512-HMwMaQPlTC1IlcwT3+swhqf/NUO+ZhXVz6TY1zZIIZlIR0YSn8GtAAWmIvKjNY16ZkEg/JcpAuQskxsXqC0yOQ==} engines: {node: '>=6'} deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - level-post@1.0.7: - resolution: {integrity: sha512-PWYqG4Q00asOrLhX7BejSajByB4EmG2GaKHfj3h5UmmZ2duciXLPGYWIjBzLECFWUGOZWlm5B20h/n3Gs3HKew==} - - level-sublevel@6.6.4: - resolution: {integrity: sha512-pcCrTUOiO48+Kp6F1+UAzF/OtWqLcQVTVF39HLdZ3RO8XBoXt+XVPKZO1vVr1aUoxHZA9OtD2e1v7G+3S5KFDA==} - level-supports@1.0.1: resolution: {integrity: sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==} engines: {node: '>=6'} - level-ws@0.0.0: - resolution: {integrity: sha512-XUTaO/+Db51Uiyp/t7fCMGVFOTdtLS/NIACxE/GHsij15mKzxksZifKVjlXDF41JMUP/oM1Oc4YNGdKnc3dVLw==} - - level-ws@1.0.0: - resolution: {integrity: sha512-RXEfCmkd6WWFlArh3X8ONvQPm8jNpfA0s/36M4QzLqrLEIt1iJE9WBHLZ5vZJK6haMjJPJGJCQWfjMNnRcq/9Q==} - engines: {node: '>=6'} - level-ws@2.0.0: resolution: {integrity: sha512-1iv7VXx0G9ec1isqQZ7y5LmoZo/ewAsyDHNA8EFDW5hqH2Kqovm33nSFkSdnLLAK+I5FlT+lo5Cw9itGe+CpQA==} engines: {node: '>=6'} - levelup@1.3.9: - resolution: {integrity: sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - - levelup@3.1.1: - resolution: {integrity: sha512-9N10xRkUU4dShSRRFTBdNaBxofz+PGaIZO962ckboJZiNmLuhVT6FZ6ZKAsICKfUBO76ySaYU6fJWX/jnj3Lcg==} - engines: {node: '>=6'} - deprecated: Superseded by abstract-level (https://github.com/Level/community#faq) - levelup@4.4.0: resolution: {integrity: sha512-94++VFO3qN95cM/d6eBXvd894oJE0w3cInq9USsyQzzoJxmiYzPAocNcuGCPGGjoXqDVJcr3C1jzt1TSjyaiLQ==} engines: {node: '>=6'} @@ -8779,35 +7591,17 @@ packages: lighthouse-logger@1.4.2: resolution: {integrity: sha512-gPWxznF6TKmUHrOQjlVo2UbaL2EJ71mb2CCeRs/2qBpi4L/g4LUVc9+3lKQ6DTUZwJswfM7ainGrLO1+fOqa2g==} - lilconfig@2.0.5: - resolution: {integrity: sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==} - engines: {node: '>=10'} - lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} linkify-it@5.0.0: resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} - lint-staged@12.5.0: - resolution: {integrity: sha512-BKLUjWDsKquV/JuIcoQW4MSAI3ggwEImF1+sB4zaKvyVx1wBk3FsG7UK9bpnmBTN1pm7EH2BBcMwINJzCRv12g==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - hasBin: true - lint-staged@16.2.7: resolution: {integrity: sha512-lDIj4RnYmK7/kXMya+qJsmkRFkGolciXjrsZ6PC25GdTfWOAWetR0ZbsNXRAj1EHHImRSalc+whZFg56F5DVow==} engines: {node: '>=20.17'} hasBin: true - listr2@4.0.5: - resolution: {integrity: sha512-juGHV1doQdpNT3GSTs9IUN43QJb7KHdF9uqg7Vufs/tG9VTzpFphqF4pm/ICdAABGQxsyNn9CiYA3StkI6jpwA==} - engines: {node: '>=12'} - peerDependencies: - enquirer: '>= 2.3.0 < 3' - peerDependenciesMeta: - enquirer: - optional: true - listr2@9.0.5: resolution: {integrity: sha512-ME4Fb83LgEgwNw96RKNvKV4VTLuXfoKudAmm2lP8Kk87KaMK0/Xrx/aAkMWmT8mDb+3MlFDspfbCs7adjRxA2g==} engines: {node: '>=20.0.0'} @@ -8823,10 +7617,6 @@ packages: localforage@1.10.0: resolution: {integrity: sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==} - locate-path@2.0.0: - resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==} - engines: {node: '>=4'} - locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -8896,9 +7686,6 @@ packages: lodash.upperfirst@4.3.1: resolution: {integrity: sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==} - lodash@4.17.20: - resolution: {integrity: sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==} - lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -8906,10 +7693,6 @@ packages: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} engines: {node: '>=10'} - log-update@4.0.0: - resolution: {integrity: sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==} - engines: {node: '>=10'} - log-update@6.1.0: resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==} engines: {node: '>=18'} @@ -8918,12 +7701,6 @@ packages: resolution: {integrity: sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==} engines: {node: '>= 12.0.0'} - looper@2.0.0: - resolution: {integrity: sha512-6DzMHJcjbQX/UPHc1rRCBfKlLwDkvuGZ715cIR36wSdYqWXFT35uLXq5P/2orl3tz+t+VOVPxw4yPinQlUDGDQ==} - - looper@3.0.0: - resolution: {integrity: sha512-LJ9wplN/uSn72oJRsXTx+snxPet5c8XiZmOKCm906NVYu+ag6SB6vUcnJcWxgnl2NfbIyeobAn7Bwv6xRj2XJg==} - loose-envify@1.4.0: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true @@ -8940,14 +7717,6 @@ packages: lower-case@2.0.2: resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} - lowercase-keys@1.0.1: - resolution: {integrity: sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==} - engines: {node: '>=0.10.0'} - - lowercase-keys@2.0.0: - resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==} - engines: {node: '>=8'} - lowercase-keys@3.0.0: resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -8959,12 +7728,6 @@ packages: resolution: {integrity: sha512-r8LA6i4LP4EeWOhqBaZZjDWwehd1xUJPCJd9Sv300H0ZmcUER4+JPh7bqqZeqs1o5pgtgvXm+d9UGrB5zZGDiQ==} engines: {node: 20 || >=22} - lru-cache@3.2.0: - resolution: {integrity: sha512-91gyOKTc2k66UG6kHiH4h3S2eltcPwE1STVfMYC/NG+nZwf8IIuiamfmpGZjpbbxzSyEJaLC0tNSmhjlQUTJow==} - - lru-cache@4.1.5: - resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} - lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -8979,9 +7742,6 @@ packages: lru_map@0.3.3: resolution: {integrity: sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==} - ltgt@2.1.3: - resolution: {integrity: sha512-5VjHC5GsENtIi5rbJd+feEpDKhfr7j0odoUR2Uh978g+2p93nd5o34cTjQWohXsPsCZeqoDnIqEf88mPCe0Pfw==} - ltgt@2.2.1: resolution: {integrity: sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA==} @@ -8999,10 +7759,6 @@ packages: resolution: {integrity: sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==} engines: {node: '>=0.10.0'} - map-visit@1.0.0: - resolution: {integrity: sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==} - engines: {node: '>=0.10.0'} - markdown-it@14.1.0: resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==} hasBin: true @@ -9038,9 +7794,6 @@ packages: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} - math-random@1.0.4: - resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==} - mcl-wasm@0.7.9: resolution: {integrity: sha512-iJIUcQWA88IJB/5L15GnJVnSQJmf/YaxxV6zRavv83HILHaJQb6y0iFyDMdDO0gN8X37tdxmAOrH/P8B6RB8sQ==} engines: {node: '>=8.9.0'} @@ -9055,19 +7808,6 @@ packages: resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} engines: {node: '>= 0.6'} - mem@1.1.0: - resolution: {integrity: sha512-nOBDrc/wgpkd3X/JOhMqYR+/eLqlfLP4oQfoBA6QExIxEl+GU01oyEkwWyueyO8110pUKijtiHGhEmYoOn88oQ==} - engines: {node: '>=4'} - - memdown@1.4.1: - resolution: {integrity: sha512-iVrGHZB8i4OQfM155xx8akvG9FIj+ht14DX5CQkCTG4EHzZ3d3sgckIf/Lm9ivZalEsFuEVnWv2B2WZvbrro2w==} - deprecated: Superseded by memory-level (https://github.com/Level/community#faq) - - memdown@3.0.0: - resolution: {integrity: sha512-tbV02LfZMWLcHcq4tw++NuqMO+FZX8tNJEiD2aNRm48ZZusVg5N8NART+dmBkepJVye986oixErf7jfXboMGMA==} - engines: {node: '>=6'} - deprecated: Superseded by memory-level (https://github.com/Level/community#faq) - memdown@5.1.0: resolution: {integrity: sha512-B3J+UizMRAlEArDjWHTMmadet+UKwHd3UjMgGBkZcKAxAYVPS9o0Yeiha4qvz7iGiL2Sb3igUft6p7nbFWctpw==} engines: {node: '>=6'} @@ -9087,9 +7827,6 @@ packages: merge-descriptors@1.0.1: resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==} - merge-descriptors@1.0.3: - resolution: {integrity: sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==} - merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -9097,12 +7834,6 @@ packages: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} - merkle-patricia-tree@2.3.2: - resolution: {integrity: sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==} - - merkle-patricia-tree@3.0.0: - resolution: {integrity: sha512-soRaMuNf/ILmw3KWbybaCjhx86EYeBbD8ph0edQCTed0JN/rxDt1EBN52Ajre3VyGo+91f8+/rfPIRQnnGMqmQ==} - merkle-patricia-tree@4.2.4: resolution: {integrity: sha512-eHbf/BG6eGNsqqfbLED9rIqbsF4+sykEaBn6OLNs71tjclbMcMOk1tEPmJKcNcNCLkvbpY/lwyOlizWsqPNo8w==} @@ -9261,14 +7992,6 @@ packages: micromark@4.0.2: resolution: {integrity: sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==} - micromatch@2.3.11: - resolution: {integrity: sha512-LnU2XFEk9xxSJ6rfgAry/ty5qwUTyHYOBU0g4R6tIw5ljwgGIBmiKhRWLw5NpMOnrgUNcDJ4WMp8rl3sYVHLNA==} - engines: {node: '>=0.10.0'} - - micromatch@3.1.10: - resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==} - engines: {node: '>=0.10.0'} - micromatch@4.0.8: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} @@ -9290,10 +8013,6 @@ packages: engines: {node: '>=4'} hasBin: true - mimic-fn@1.2.0: - resolution: {integrity: sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==} - engines: {node: '>=4'} - mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -9302,10 +8021,6 @@ packages: resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} engines: {node: '>=18'} - mimic-response@1.0.1: - resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==} - engines: {node: '>=4'} - mimic-response@2.1.0: resolution: {integrity: sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==} engines: {node: '>=8'} @@ -9318,9 +8033,6 @@ packages: resolution: {integrity: sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - min-document@2.19.0: - resolution: {integrity: sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==} - minimalistic-assert@1.0.1: resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} @@ -9346,9 +8058,6 @@ packages: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} - minimist@0.0.8: - resolution: {integrity: sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q==} - minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} @@ -9372,9 +8081,6 @@ packages: resolution: {integrity: sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==} engines: {node: '>=8'} - minipass@2.9.0: - resolution: {integrity: sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==} - minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -9387,30 +8093,13 @@ packages: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} - minizlib@1.3.3: - resolution: {integrity: sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==} - minizlib@2.1.2: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} engines: {node: '>= 8'} - mixin-deep@1.3.2: - resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} - engines: {node: '>=0.10.0'} - mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} - mkdirp-promise@5.0.1: - resolution: {integrity: sha512-Hepn5kb1lJPtVW84RFT40YG1OddBNTOVUZR2bzQUHc+Z03en8/3uX0+060JDhcEzyO08HmipsN9DcnFMxhIL9w==} - engines: {node: '>=4'} - deprecated: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that. - - mkdirp@0.5.1: - resolution: {integrity: sha512-SknJC52obPfGQPnjIkXbmA6+5H15E+fR+E4iR2oQ3zzCLbd7/ONua69R/Gw7AgkTLsRG+r5fzksYwWe1AgTyWA==} - deprecated: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) - hasBin: true - mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -9433,18 +8122,6 @@ packages: engines: {node: '>= 14.0.0'} hasBin: true - mocha@4.1.0: - resolution: {integrity: sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==} - engines: {node: '>= 4.0.0'} - hasBin: true - - mock-fs@4.14.0: - resolution: {integrity: sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw==} - - mock-property@1.0.3: - resolution: {integrity: sha512-2emPTb1reeLLYwHxyVx993iYyCHEiRRO+y8NFXFPL5kl5q14sgTK76cXyEKkeKCHeRw35SfdkUJ10Q1KfHuiIQ==} - engines: {node: '>= 0.4'} - moment-timezone@0.5.48: resolution: {integrity: sha512-f22b8LV1gbTO2ms2j2z13MuPogNoh5UzxL3nzNAYKGraILnbGc9NEE6dyiiiLv46DGRb8A4kg8UKWLjPthxBHw==} @@ -9465,25 +8142,6 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - multibase@0.6.1: - resolution: {integrity: sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw==} - deprecated: This module has been superseded by the multiformats module - - multibase@0.7.0: - resolution: {integrity: sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg==} - deprecated: This module has been superseded by the multiformats module - - multicodec@0.5.7: - resolution: {integrity: sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA==} - deprecated: This module has been superseded by the multiformats module - - multicodec@1.0.4: - resolution: {integrity: sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg==} - deprecated: This module has been superseded by the multiformats module - - multihashes@0.4.21: - resolution: {integrity: sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw==} - murmur-128@0.2.1: resolution: {integrity: sha512-WseEgiRkI6aMFBbj8Cg9yBj/y+OdipwVC7zUo3W2W1JAJITwouUOtpqsmGSg67EQmwwSyod7hsVsWY5LsrfQVg==} @@ -9502,17 +8160,10 @@ packages: nan@2.23.0: resolution: {integrity: sha512-1UxuyYGdoQHcGg87Lkqm3FzefucTa0NAiOcuRsDmysep3c1LVCRK2krrUDafMWtjSG04htvAmvg96+SDknOmgQ==} - nano-json-stream-parser@0.1.2: - resolution: {integrity: sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew==} - nano-spawn@2.0.0: resolution: {integrity: sha512-tacvGzUY5o2D8CBh2rrwxyNojUsZNU2zjNTzKQrkgGJQTbGAfArVWXSKMBokBeeg6C7OLRGUEyoFlYbfeWQIqw==} engines: {node: '>=20.17'} - nanomatch@1.2.13: - resolution: {integrity: sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==} - engines: {node: '>=0.10.0'} - nanospinner@1.2.2: resolution: {integrity: sha512-Zt/AmG6qRU3e+WnzGGLuMCEAO/dAu45stNbHY223tUxldaDAeE+FxSPsd9Q+j+paejmm0ZbrNVs5Sraqy3dRxA==} @@ -9545,16 +8196,10 @@ packages: neoqs@6.13.0: resolution: {integrity: sha512-IysBpjrEG9qiUb/IT6XrXSz2ASzBxLebp4s8/GBm7STYC315vMNqH0aWdRR+f7KvXK4aRlLcf5r2Z6dOTxQSrQ==} - next-tick@1.1.0: - resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} - ngeohash@0.6.3: resolution: {integrity: sha512-kltF0cOxgx1AbmVzKxYZaoB0aj7mOxZeHaerEtQV0YaqnkXNq26WWqMmJ6lTqShYxVRWZ/mwvvTrNeOwdslWiw==} engines: {node: '>=v0.2.0'} - nice-try@1.0.5: - resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - no-case@3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} @@ -9576,9 +8221,6 @@ packages: node-emoji@1.11.0: resolution: {integrity: sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==} - node-fetch@1.7.3: - resolution: {integrity: sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==} - node-fetch@2.6.7: resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} engines: {node: 4.x || >=6.0.0} @@ -9647,14 +8289,6 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - normalize-url@4.5.1: - resolution: {integrity: sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==} - engines: {node: '>=8'} - - normalize-url@6.1.0: - resolution: {integrity: sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==} - engines: {node: '>=10'} - normalize-url@8.1.0: resolution: {integrity: sha512-X06Mfd/5aKsRHc0O0J5CUedwnPmnDtLF2+nq+KN9KSDlJHkPuh0JUviWjEWMe0SW/9TDdSLVPuk7L5gGTIA1/w==} engines: {node: '>=14.16'} @@ -9667,14 +8301,6 @@ packages: resolution: {integrity: sha512-5+bKQRH0J1xG1uZ1zMNvxW0VEyoNWgJpY9UDuluPFLKDfJ9u2JmmjmTJV1srBGQOROfdBMiVvnH2Zvpbm+xkVA==} engines: {node: ^16.14.0 || >=18.0.0} - npm-run-path@2.0.2: - resolution: {integrity: sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==} - engines: {node: '>=4'} - - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} deprecated: This package is no longer supported. @@ -9701,35 +8327,17 @@ packages: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} - object-copy@0.1.0: - resolution: {integrity: sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==} - engines: {node: '>=0.10.0'} - object-inspect@1.10.3: resolution: {integrity: sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==} - object-inspect@1.12.3: - resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} - object-inspect@1.13.4: resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} engines: {node: '>= 0.4'} - object-is@1.1.6: - resolution: {integrity: sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==} - engines: {node: '>= 0.4'} - - object-keys@0.4.0: - resolution: {integrity: sha512-ncrLw+X55z7bkl5PnUvHwFK9FcGuFYo9gtjws2XtSzL+aZ8tm830P60WJ0dSmFVaSalWieW5MD7kEdnXda9yJw==} - object-keys@1.1.1: resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} engines: {node: '>= 0.4'} - object-visit@1.0.1: - resolution: {integrity: sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==} - engines: {node: '>=0.10.0'} - object.assign@4.1.7: resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} engines: {node: '>= 0.4'} @@ -9738,22 +8346,10 @@ packages: resolution: {integrity: sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==} engines: {node: '>= 0.4'} - object.getownpropertydescriptors@2.1.8: - resolution: {integrity: sha512-qkHIGe4q0lSYMv0XI4SsBTJz3WaURhLvd0lKSgtVuOsJ2krg4SgMw3PIRQFMp07yi++UR3se2mkcLqsBNpBb/A==} - engines: {node: '>= 0.8'} - object.groupby@1.0.3: resolution: {integrity: sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==} engines: {node: '>= 0.4'} - object.omit@2.0.1: - resolution: {integrity: sha512-UiAM5mhmIuKLsOvrL+B0U2d1hXHF3bFYWIuH1LMpuV2EJEHG1Ntz06PgLEHjm6VFd87NpH8rastvPoyv6UW2fA==} - engines: {node: '>=0.10.0'} - - object.pick@1.3.0: - resolution: {integrity: sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==} - engines: {node: '>=0.10.0'} - object.values@1.2.1: resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==} engines: {node: '>= 0.4'} @@ -9761,9 +8357,6 @@ packages: obliterator@2.0.5: resolution: {integrity: sha512-42CPE9AhahZRsMNslczq0ctAEtqk8Eka26QofnqC346BZdHDySk3LWka23LI7ULIw11NmltpiLagIq8gBozxTw==} - oboe@2.1.4: - resolution: {integrity: sha512-ymBJ4xSC6GBXLT9Y7lirj+xbqBLa+jADGJldGEYG7u8sZbS9GyG+u1Xk9c5cbriKwSpCg41qUhPjvU5xOpvIyQ==} - on-exit-leak-free@0.2.0: resolution: {integrity: sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==} @@ -9815,18 +8408,10 @@ packages: ordinal@1.0.3: resolution: {integrity: sha512-cMddMgb2QElm8G7vdaa02jhUNbTSrhsgAGUz1OokD83uJTwSUn+nKoNoKVVaRa08yF6sgfO7Maou1+bgLd9rdQ==} - os-homedir@1.0.2: - resolution: {integrity: sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==} - engines: {node: '>=0.10.0'} - os-locale@1.4.0: resolution: {integrity: sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==} engines: {node: '>=0.10.0'} - os-locale@2.1.0: - resolution: {integrity: sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==} - engines: {node: '>=4'} - os-tmpdir@1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -9854,14 +8439,6 @@ packages: typescript: optional: true - p-cancelable@1.1.0: - resolution: {integrity: sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==} - engines: {node: '>=6'} - - p-cancelable@2.1.1: - resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==} - engines: {node: '>=8'} - p-cancelable@3.0.0: resolution: {integrity: sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==} engines: {node: '>=12.20'} @@ -9874,10 +8451,6 @@ packages: resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==} engines: {node: '>=4'} - p-limit@1.3.0: - resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==} - engines: {node: '>=4'} - p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -9890,10 +8463,6 @@ packages: resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - p-locate@2.0.0: - resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==} - engines: {node: '>=4'} - p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -9926,10 +8495,6 @@ packages: resolution: {integrity: sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==} engines: {node: '>=8'} - p-try@1.0.0: - resolution: {integrity: sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==} - engines: {node: '>=4'} - p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -9954,10 +8519,6 @@ packages: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} - parse-asn1@5.1.7: - resolution: {integrity: sha512-CTM5kuWR3sx9IFamcl5ErfPl6ea/N8IYwiJ+vpeB2g+1iknv7zBl5uPwbMbRVznRVbrNY6lGuDoE5b30grmbqg==} - engines: {node: '>= 0.10'} - parse-cache-control@1.0.1: resolution: {integrity: sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==} @@ -9968,13 +8529,6 @@ packages: resolution: {integrity: sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==} engines: {node: '>=0.8'} - parse-glob@3.0.4: - resolution: {integrity: sha512-FC5TeK0AwXzq3tUBFtH74naWkPQCEWs4K+xMxWZBlKDWu0bVHXGZa+KKqxKidd7xwhdZ19ZNuF2uO1M/r196HA==} - engines: {node: '>=0.10.0'} - - parse-headers@2.0.6: - resolution: {integrity: sha512-Tz11t3uKztEW5FEVZnj1ox8GKblWn+PvHY9TmJV5Mll2uHEwRdR/5Li1OlXoECjLYkApdhWy44ocONwXLiKO5A==} - parse-json@2.2.0: resolution: {integrity: sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==} engines: {node: '>=0.10.0'} @@ -9994,20 +8548,6 @@ packages: pascal-case@3.1.2: resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} - pascalcase@0.1.1: - resolution: {integrity: sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==} - engines: {node: '>=0.10.0'} - - patch-package@6.2.2: - resolution: {integrity: sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg==} - engines: {npm: '>5'} - hasBin: true - - patch-package@6.5.1: - resolution: {integrity: sha512-I/4Zsalfhc6bphmJTlrLoOcAF87jcxko4q0qsv4bGcurbr8IskEOtdnt9iCmsQVGL1B+iUhSQqweyTLJfCF9rA==} - engines: {node: '>=10', npm: '>5'} - hasBin: true - path-browserify@1.0.1: resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} @@ -10018,10 +8558,6 @@ packages: resolution: {integrity: sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==} engines: {node: '>=0.10.0'} - path-exists@3.0.0: - resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} - engines: {node: '>=4'} - path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -10034,10 +8570,6 @@ packages: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} - path-key@2.0.1: - resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} - engines: {node: '>=4'} - path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -10065,9 +8597,6 @@ packages: resolution: {integrity: sha512-wZ3AeiRBRlNwkdUxvBANh0+esnt38DLffHDujZyRHkqkaKHTglnY2EP5UX3b8rdeiSutgO4y9NEJwXezNP5vHg==} engines: {node: '>=8'} - path-to-regexp@0.1.12: - resolution: {integrity: sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==} - path-to-regexp@0.1.7: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} @@ -10093,11 +8622,6 @@ packages: resolution: {integrity: sha512-wfRLBZ0feWRhCIkoMB6ete7czJcnNnqRpcoWQBLqatqXXmelSRqfdDK4F3u9T2s2cXas/hQJcryI/4lAL+XTlA==} engines: {node: '>=0.12'} - pegjs@0.10.0: - resolution: {integrity: sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==} - engines: {node: '>=0.10'} - hasBin: true - performance-now@2.1.0: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} @@ -10163,11 +8687,6 @@ packages: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} - pidtree@0.5.0: - resolution: {integrity: sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA==} - engines: {node: '>=0.10'} - hasBin: true - pidtree@0.6.0: resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} engines: {node: '>=0.10'} @@ -10211,10 +8730,6 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - posix-character-classes@0.1.1: - resolution: {integrity: sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==} - engines: {node: '>=0.10.0'} - possible-typed-array-names@1.1.0: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} @@ -10235,9 +8750,6 @@ packages: resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} engines: {node: '>=0.10.0'} - postinstall-postinstall@2.1.0: - resolution: {integrity: sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==} - prebuild-install@5.3.6: resolution: {integrity: sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==} engines: {node: '>=6'} @@ -10248,10 +8760,6 @@ packages: engines: {node: '>=6'} hasBin: true - precond@0.2.3: - resolution: {integrity: sha512-QCYG84SgGyGzqJ/vlMsxeXd/pgL/I94ixdNFyh1PusWmTCyVfPJjZ1K1jvHtsbfnXQs2TSkEP2fR7QiMZAnKFQ==} - engines: {node: '>= 0.6'} - prelude-ls@1.1.2: resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} engines: {node: '>= 0.8.0'} @@ -10260,14 +8768,6 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - prepend-http@2.0.0: - resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} - engines: {node: '>=4'} - - preserve@0.2.0: - resolution: {integrity: sha512-s/46sYeylUfHNjI+sA/78FAHlmIuKqI9wNnzEOGehAlUUYeObv5C2mOinXBjyUyWmJ2SfcS2/ydApH4hTF4WXQ==} - engines: {node: '>=0.10.0'} - prettier-plugin-solidity@2.1.0: resolution: {integrity: sha512-O5HX4/PCE5aqiaEiNGbSRLbSBZQ6kLswAav5LBSewwzhT+sZlN6iAaLZlZcJzPEnIAxwLEHP03xKEg92fflT9Q==} engines: {node: '>=20'} @@ -10288,10 +8788,6 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - private@0.1.8: - resolution: {integrity: sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==} - engines: {node: '>= 0.6'} - proc-log@4.2.0: resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -10299,10 +8795,6 @@ packages: process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - process@0.11.10: - resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} - engines: {node: '>= 0.6.0'} - prom-client@14.0.1: resolution: {integrity: sha512-HxTArb6fkOntQHoRGvv4qd/BkorjliiuO2uSWC2KC17MUTKYttWdDoXX/vxOhQdkoECEM9BBH0pj2l8G8kev6w==} engines: {node: '>=10'} @@ -10318,10 +8810,6 @@ packages: promise-throttle@1.1.2: resolution: {integrity: sha512-dij7vjyXNewuuN/gyr+TX2KRjw48mbV5FEtgyXaIoJjGYAKT0au23/voNvy9eS4UNJjx2KUdEcO5Yyfc1h7vWQ==} - promise-to-callback@1.0.0: - resolution: {integrity: sha512-uhMIZmKM5ZteDMfLgJnoSq9GCwsNKrYau73Awf1jIy6/eUcuuZ3P+CD9zUv0kJsIUbU+x6uLNIhXhLHDs1pNPA==} - engines: {node: '>=0.10.0'} - promise@7.3.1: resolution: {integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==} @@ -10351,36 +8839,9 @@ packages: prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} - pseudomap@1.0.2: - resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} - psl@1.15.0: resolution: {integrity: sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==} - public-encrypt@4.0.3: - resolution: {integrity: sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==} - - pull-cat@1.1.11: - resolution: {integrity: sha512-i3w+xZ3DCtTVz8S62hBOuNLRHqVDsHMNZmgrZsjPnsxXUgbWtXEee84lo1XswE7W2a3WHyqsNuDJTjVLAQR8xg==} - - pull-defer@0.2.3: - resolution: {integrity: sha512-/An3KE7mVjZCqNhZsr22k1Tx8MACnUnHZZNPSJ0S62td8JtYr/AiRG42Vz7Syu31SoTLUzVIe61jtT/pNdjVYA==} - - pull-level@2.0.4: - resolution: {integrity: sha512-fW6pljDeUThpq5KXwKbRG3X7Ogk3vc75d5OQU/TvXXui65ykm+Bn+fiktg+MOx2jJ85cd+sheufPL+rw9QSVZg==} - - pull-live@1.0.1: - resolution: {integrity: sha512-tkNz1QT5gId8aPhV5+dmwoIiA1nmfDOzJDlOOUpU5DNusj6neNd3EePybJ5+sITr2FwyCs/FVpx74YMCfc8YeA==} - - pull-pushable@2.2.0: - resolution: {integrity: sha512-M7dp95enQ2kaHvfCt2+DJfyzgCSpWVR2h2kWYnVsW6ZpxQBx5wOu0QWOvQPVoPnBLUZYitYP2y7HyHkLQNeGXg==} - - pull-stream@3.7.0: - resolution: {integrity: sha512-Eco+/R004UaCK2qEDE8vGklcTG2OeZSVm1kTUQNrykEjDwcFXDZhygFDsW49DbXyJMEhHeRL3z5cRVqPAhXlIw==} - - pull-window@2.1.4: - resolution: {integrity: sha512-cbDzN76BMlcGG46OImrgpkMf/VkCnupj8JhsrpBw3aWBM9ye345aYnqitmZCgauBkc0HbbRRn9hCnsa3k2FNUg==} - pump@3.0.3: resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==} @@ -10413,10 +8874,6 @@ packages: resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==} engines: {node: '>=0.6'} - qs@6.13.0: - resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==} - engines: {node: '>=0.6'} - qs@6.14.0: resolution: {integrity: sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==} engines: {node: '>=0.6'} @@ -10436,10 +8893,6 @@ packages: quansync@0.2.11: resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==} - query-string@5.1.1: - resolution: {integrity: sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==} - engines: {node: '>=0.10.0'} - queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -10453,16 +8906,9 @@ packages: resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==} engines: {node: '>=10'} - randomatic@3.1.1: - resolution: {integrity: sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==} - engines: {node: '>= 0.10.0'} - randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} - randomfill@1.0.4: - resolution: {integrity: sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==} - range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} engines: {node: '>= 0.6'} @@ -10536,12 +8982,6 @@ packages: resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} engines: {node: '>=6'} - readable-stream@1.0.34: - resolution: {integrity: sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==} - - readable-stream@1.1.14: - resolution: {integrity: sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==} - readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} @@ -10549,10 +8989,6 @@ packages: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} - readdirp@2.2.1: - resolution: {integrity: sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==} - engines: {node: '>=0.10'} - readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -10581,33 +9017,13 @@ packages: resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==} engines: {node: '>= 0.4'} - regenerate@1.4.2: - resolution: {integrity: sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==} - - regenerator-runtime@0.11.1: - resolution: {integrity: sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==} - regenerator-runtime@0.13.11: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} - regenerator-transform@0.10.1: - resolution: {integrity: sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==} - - regex-cache@0.4.4: - resolution: {integrity: sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==} - engines: {node: '>=0.10.0'} - - regex-not@1.0.2: - resolution: {integrity: sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==} - engines: {node: '>=0.10.0'} - regexp.prototype.flags@1.5.4: resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} engines: {node: '>= 0.4'} - regexpu-core@2.0.0: - resolution: {integrity: sha512-tJ9+S4oKjxY8IZ9jmjnp/mtytu1u3iyIQAfmI51IKWH6bFf7XR1ybtaO6j7INhZKXOTYADk7V5qxaqLkmNxiZQ==} - registry-auth-token@5.1.0: resolution: {integrity: sha512-GdekYuwLXLxMuFTwAPg5UKGLW/UXzQrZvH/Zj791BQif5T05T0RsaLfHc9q3ZOKi7n+BoprPD9mJ0O0k4xzUlw==} engines: {node: '>=14'} @@ -10616,31 +9032,12 @@ packages: resolution: {integrity: sha512-+crtS5QjFRqFCoQmvGduwYWEBng99ZvmFvF+cUJkGYF1L1BfU8C6Zp9T7f5vPAwyLkUExpvK+ANVZmGU49qi4Q==} engines: {node: '>=12'} - regjsgen@0.2.0: - resolution: {integrity: sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g==} - - regjsparser@0.1.5: - resolution: {integrity: sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw==} - hasBin: true - relay-runtime@12.0.0: resolution: {integrity: sha512-QU6JKr1tMsry22DXNy9Whsq5rmvwr3LSZiiWV/9+DFpuTWvp+WFhobWMc8TC4OjKFfNhEZy7mOiqUAn5atQtug==} remove-trailing-separator@1.1.0: resolution: {integrity: sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==} - repeat-element@1.1.4: - resolution: {integrity: sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==} - engines: {node: '>=0.10.0'} - - repeat-string@1.6.1: - resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==} - engines: {node: '>=0.10'} - - repeating@2.0.1: - resolution: {integrity: sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==} - engines: {node: '>=0.10.0'} - req-cwd@2.0.0: resolution: {integrity: sha512-ueoIoLo1OfB6b05COxAA9UpeoscNpYyM+BqYlA7H6LVF4hKGPXQQSSaD2YmvDVJMkk4UDpAHIeU1zG53IqjvlQ==} engines: {node: '>=4'} @@ -10690,10 +9087,6 @@ packages: resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - resolve-url@0.2.1: - resolution: {integrity: sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==} - deprecated: https://github.com/lydell/resolve-url#deprecated - resolve.exports@2.0.3: resolution: {integrity: sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==} engines: {node: '>=10'} @@ -10709,12 +9102,6 @@ packages: engines: {node: '>= 0.4'} hasBin: true - responselike@1.0.2: - resolution: {integrity: sha512-/Fpe5guzJk1gPqdJLJR5u7eG/gNY4nImjbRDaVWVMRhne55TCmj2i9Q+54PBRfatRC8v/rIiv9BN0pMd9OV5EQ==} - - responselike@2.0.1: - resolution: {integrity: sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==} - responselike@3.0.0: resolution: {integrity: sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg==} engines: {node: '>=14.16'} @@ -10727,10 +9114,6 @@ packages: resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==} engines: {node: '>=18'} - ret@0.1.15: - resolution: {integrity: sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==} - engines: {node: '>=0.12'} - retry-as-promised@5.0.0: resolution: {integrity: sha512-6S+5LvtTl2ggBumk04hBo/4Uf6fRJUwIgunGZ7CYEBCeufGFW1Pu6ucUf/UskHeWOIsUcLOGLFXPig5tR5V1nA==} @@ -10814,10 +9197,6 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - safe-event-emitter@1.0.1: - resolution: {integrity: sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg==} - deprecated: Renamed to @metamask/safe-event-emitter - safe-push-apply@1.0.0: resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==} engines: {node: '>= 0.4'} @@ -10826,9 +9205,6 @@ packages: resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} engines: {node: '>= 0.4'} - safe-regex@1.1.0: - resolution: {integrity: sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==} - safe-stable-stringify@2.5.0: resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} engines: {node: '>=10'} @@ -10846,9 +9222,6 @@ packages: scrypt-js@3.0.1: resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==} - scryptsy@1.2.1: - resolution: {integrity: sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw==} - secp256k1@4.0.4: resolution: {integrity: sha512-6JfvwvjUOn8F/jUoBY2Q1v5WY5XS+rj8qSe0v8Y4ezH4InLgTEeOOPQsRll9OV429Pvo6BCHGavIyJfr3TAhsw==} engines: {node: '>=18.0.0'} @@ -10856,9 +9229,6 @@ packages: secure-keys@1.0.0: resolution: {integrity: sha512-nZi59hW3Sl5P3+wOO89eHBAAGwmCPd2aE1+dLZV5MO+ItQctIvAqihzaAXIQhvtH4KJPxM080HsnqltR2y8cWg==} - seedrandom@3.0.1: - resolution: {integrity: sha512-1/02Y/rUeU1CJBAGLebiC5Lbo5FnB22gQbIFFYTLkwvp1xdABZJH1sn4ZT1MzXmPpzv+Rf/Lu2NcsLJiK4rcDg==} - seedrandom@3.0.5: resolution: {integrity: sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==} @@ -10866,14 +9236,6 @@ packages: resolution: {integrity: sha512-b/ptP11hETwYWpeilHXXQiV5UJNJl7ZWWooKRE5eBIYWoom6dZ0SluCIdCtKycsMtZgKWE01/qAw6jblw1YVhg==} engines: {node: '>=4.1'} - semaphore@1.1.0: - resolution: {integrity: sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA==} - engines: {node: '>=0.8.0'} - - semver@5.4.1: - resolution: {integrity: sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==} - hasBin: true - semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -10993,10 +9355,6 @@ packages: resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==} engines: {node: '>= 0.8.0'} - servify@0.1.12: - resolution: {integrity: sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw==} - engines: {node: '>=6'} - set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} @@ -11008,18 +9366,10 @@ packages: resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} engines: {node: '>= 0.4'} - set-immediate-shim@1.0.1: - resolution: {integrity: sha512-Li5AOqrZWCVA2n5kryzEmqai6bKSIvpz5oUJHPVj6+dsbD3X1ixtsY5tEnsaNpH3pFAHmG8eIHUrtEtohrg+UQ==} - engines: {node: '>=0.10.0'} - set-proto@1.0.0: resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} engines: {node: '>= 0.4'} - set-value@2.0.1: - resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==} - engines: {node: '>=0.10.0'} - setimmediate@1.0.5: resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} @@ -11037,18 +9387,10 @@ packages: shallowequal@1.1.0: resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==} - shebang-command@1.2.0: - resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} - engines: {node: '>=0.10.0'} - shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} - shebang-regex@1.0.0: - resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} - engines: {node: '>=0.10.0'} - shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} @@ -11091,9 +9433,6 @@ packages: simple-concat@1.0.1: resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} - simple-get@2.8.2: - resolution: {integrity: sha512-Ijd/rV5o+mSBBs4F/x9oDPtTx9Zb6X9brmnXvMW4J7IR15ngi9q5xxqWBKU744jTZiaXtxaPL7uHG6vtN8kUkw==} - simple-get@3.1.1: resolution: {integrity: sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==} @@ -11106,14 +9445,6 @@ packages: sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - slash@1.0.0: - resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==} - engines: {node: '>=0.10.0'} - - slash@2.0.0: - resolution: {integrity: sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==} - engines: {node: '>=6'} - slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -11122,18 +9453,10 @@ packages: resolution: {integrity: sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==} engines: {node: '>=14.16'} - slice-ansi@3.0.0: - resolution: {integrity: sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==} - engines: {node: '>=8'} - slice-ansi@4.0.0: resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} engines: {node: '>=10'} - slice-ansi@5.0.0: - resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} - engines: {node: '>=12'} - slice-ansi@7.1.2: resolution: {integrity: sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w==} engines: {node: '>=18'} @@ -11153,18 +9476,6 @@ packages: snake-case@3.0.4: resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==} - snapdragon-node@2.1.1: - resolution: {integrity: sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==} - engines: {node: '>=0.10.0'} - - snapdragon-util@3.0.1: - resolution: {integrity: sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==} - engines: {node: '>=0.10.0'} - - snapdragon@0.8.2: - resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==} - engines: {node: '>=0.10.0'} - socks-proxy-agent@8.0.5: resolution: {integrity: sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==} engines: {node: '>= 14'} @@ -11173,21 +9484,10 @@ packages: resolution: {integrity: sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==} engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} - sol-digger@0.0.2: - resolution: {integrity: sha512-oqrw1E/X2WWYUYCzKDM5INDDH2nWOWos4p2Cw2OF52qoZcTDzlKMJQ5pJFXKOCADCg6KggBO5WYE/vNb+kJ0Hg==} - - sol-explore@1.6.1: - resolution: {integrity: sha512-cmwg7l+QLj2LE3Qvwrdo4aPYcNYY425+bN5VPkgCjkO0CiSz33G5vM5BmMZNrfd/6yNGwcm0KtwDJmh5lUElEQ==} - solc@0.4.26: resolution: {integrity: sha512-o+c6FpkiHd+HPjmjEVpQgH7fqZ14tJpXhho+/bQXlXbliLIS/xjXb42Vxh+qQY1WCSTMQ0+a5vR9vi0MfhU6mA==} hasBin: true - solc@0.6.12: - resolution: {integrity: sha512-Lm0Ql2G9Qc7yPP2Ba+WNmzw2jwsrd3u4PobHYlSOxaut3TtUbj9+5ZrT6f4DUpNPEoBaFUOEg9Op9C0mk7ge9g==} - engines: {node: '>=8.0.0'} - hasBin: true - solc@0.8.15: resolution: {integrity: sha512-Riv0GNHNk/SddN/JyEuFKwbcWcEeho15iyupTSHw5Np6WuXA5D8kEHbyzDHi6sqmvLzu2l+8b1YmL8Ytple+8w==} engines: {node: '>=10.0.0'} @@ -11286,39 +9586,12 @@ packages: peerDependencies: hardhat: ^2.8.0 - solium-plugin-security@0.1.1: - resolution: {integrity: sha512-kpLirBwIq4mhxk0Y/nn5cQ6qdJTI+U1LO3gpoNIcqNaW+sI058moXBe2UiHs+9wvF9IzYD49jcKhFTxcR9u9SQ==} - peerDependencies: - solium: ^1.0.0 - - solium@1.2.5: - resolution: {integrity: sha512-NuNrm7fp8JcDN/P+SAdM5TVa4wYDtwVtLY/rG4eBOZrC5qItsUhmQKR/YhjszaEW4c8tNUYhkhQcwOsS25znpw==} - hasBin: true - - solparse@2.2.8: - resolution: {integrity: sha512-Tm6hdfG72DOxD40SD+T5ddbekWglNWjzDRSNq7ZDIOHVsyaJSeeunUuWNj4DE7uDrJK3tGQuX0ZTDZWNYsGPMA==} - hasBin: true - sonic-boom@2.8.0: resolution: {integrity: sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==} - source-map-resolve@0.5.3: - resolution: {integrity: sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==} - deprecated: See https://github.com/lydell/source-map-resolve#deprecated - - source-map-support@0.4.18: - resolution: {integrity: sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==} - - source-map-support@0.5.12: - resolution: {integrity: sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==} - source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - source-map-url@0.4.1: - resolution: {integrity: sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==} - deprecated: See https://github.com/lydell/source-map-url#deprecated - source-map@0.2.0: resolution: {integrity: sha512-CBdZ2oa/BHhS4xj5DlhjWNHcan57/5YuvfdLf17iVmIpd9KRm+DFLmC6nBNj+6Ua7Kt3TmOjDpQT1aTYOQtoUA==} engines: {node: '>=0.8.0'} @@ -11346,10 +9619,6 @@ packages: spdx-license-ids@3.0.22: resolution: {integrity: sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==} - split-string@3.1.0: - resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} - engines: {node: '>=0.10.0'} - split2@3.2.2: resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==} @@ -11386,10 +9655,6 @@ packages: resolution: {integrity: sha512-WjlahMgHmCJpqzU8bIBy4qtsZdU9lRlcZE3Lvyej6t4tuOuv1vk57OW3MBrj6hXBFx/nNoC9MPMTcr5YA7NQbg==} engines: {node: '>=6'} - static-extend@0.1.2: - resolution: {integrity: sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==} - engines: {node: '>=0.10.0'} - statuses@1.5.0: resolution: {integrity: sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==} engines: {node: '>= 0.6'} @@ -11405,17 +9670,10 @@ packages: stream-shift@1.0.3: resolution: {integrity: sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==} - stream-to-pull-stream@1.7.3: - resolution: {integrity: sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==} - streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} - strict-uri-encode@1.1.0: - resolution: {integrity: sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==} - engines: {node: '>=0.10.0'} - string-argv@0.3.2: resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} engines: {node: '>=0.6.19'} @@ -11459,9 +9717,6 @@ packages: resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} engines: {node: '>= 0.4'} - string_decoder@0.10.31: - resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==} - string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} @@ -11496,14 +9751,6 @@ packages: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} - strip-eof@1.0.0: - resolution: {integrity: sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==} - engines: {node: '>=0.10.0'} - - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - strip-hex-prefix@1.0.0: resolution: {integrity: sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==} engines: {node: '>=6.5.0', npm: '>=3'} @@ -11519,18 +9766,10 @@ packages: strnum@2.1.1: resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==} - supports-color@2.0.0: - resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} - engines: {node: '>=0.8.0'} - supports-color@3.2.3: resolution: {integrity: sha512-Jds2VIYDrlp5ui7t8abHN2bjAu4LV/q4N2KivFPpGH0lrka0BMq/33AmECUXlKPcHigkNaqfXRENFju+rlcy+A==} engines: {node: '>=0.8.0'} - supports-color@4.4.0: - resolution: {integrity: sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==} - engines: {node: '>=4'} - supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} @@ -11543,10 +9782,6 @@ packages: resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} engines: {node: '>=10'} - supports-color@9.4.0: - resolution: {integrity: sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==} - engines: {node: '>=12'} - supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} @@ -11554,9 +9789,6 @@ packages: swap-case@2.0.2: resolution: {integrity: sha512-kc6S2YS/2yXbtkSMunBtKdah4VFETZ8Oh6ONSmSd9bRxhqTrtARUCBUiWXH3xVPpvR7tz2CSnkuXVE42EcGnMw==} - swarm-js@0.1.42: - resolution: {integrity: sha512-BV7c/dVlA3R6ya1lMlSSNPLYrntt0LUq4YMgy3iwpCIc6rZnS5W2wUoctarZ5pXlpKtxDDf9hNziEkcfrxdhqQ==} - sync-request@6.1.0: resolution: {integrity: sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==} engines: {node: '>=8.0.0'} @@ -11572,10 +9804,6 @@ packages: resolution: {integrity: sha512-9kY+CygyYM6j02t5YFHbNz2FN5QmYGv9zAjVp4lCDjlCw7amdckXlEt/bjMhUIfj4ThGRE4gCUH5+yGnNuPo5A==} engines: {node: '>=10.0.0'} - tape@4.17.0: - resolution: {integrity: sha512-KCuXjYxCZ3ru40dmND+oCLsXyuA8hoseu2SS404Px5ouyS0A99v8X/mdiLqsR5MTAyamMBN7PRwt2Dv3+xGIxw==} - hasBin: true - tar-fs@2.1.3: resolution: {integrity: sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==} @@ -11583,11 +9811,6 @@ packages: resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} engines: {node: '>=6'} - tar@4.4.19: - resolution: {integrity: sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==} - engines: {node: '>=4.5'} - deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me - tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} @@ -11609,10 +9832,6 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} - test-value@2.1.0: - resolution: {integrity: sha512-+1epbAxtKeXttkGFMTX9H42oqzOTufR1ceCF+GYA5aOmvaPq9wd4PUS8329fn2RRLGNeUkgRLnVpycjx8DsO2w==} - engines: {node: '>=0.10.0'} - testrpc@0.0.1: resolution: {integrity: sha512-afH1hO+SQ/VPlmaLUFj2636QMeDvPCeQMc/9RBMW0IfjNe9gFD9Ra3ShqYkB7py0do1ZcCna/9acHyzTJ+GcNA==} deprecated: testrpc has been renamed to ganache-cli, please use this package from now on. @@ -11637,9 +9856,6 @@ packages: throat@5.0.0: resolution: {integrity: sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==} - through2@2.0.5: - resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} - through2@3.0.2: resolution: {integrity: sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==} @@ -11649,10 +9865,6 @@ packages: through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - timed-out@4.0.1: - resolution: {integrity: sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==} - engines: {node: '>=0.10.0'} - tiny-lru@8.0.2: resolution: {integrity: sha512-ApGvZ6vVvTNdsmt676grvCkUCGwzG9IqXma5Z07xJgiC5L7akUMof5U8G2JTI9Rz/ovtVhJBlY6mNhEvtjzOIg==} engines: {node: '>=6'} @@ -11671,10 +9883,6 @@ packages: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} engines: {node: '>=0.6.0'} - tmp@0.1.0: - resolution: {integrity: sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==} - engines: {node: '>=6'} - tmpl@1.0.5: resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} @@ -11682,30 +9890,10 @@ packages: resolution: {integrity: sha512-tB82LpAIWjhLYbqjx3X4zEeHN6M8CiuOEy2JY8SEQVdYRe3CCHOFaqrBW1doLDrfpWhplcW7BL+bO3/6S3pcDQ==} engines: {node: '>= 0.4'} - to-fast-properties@1.0.3: - resolution: {integrity: sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==} - engines: {node: '>=0.10.0'} - - to-object-path@0.3.0: - resolution: {integrity: sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==} - engines: {node: '>=0.10.0'} - - to-readable-stream@1.0.0: - resolution: {integrity: sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==} - engines: {node: '>=6'} - - to-regex-range@2.1.1: - resolution: {integrity: sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==} - engines: {node: '>=0.10.0'} - to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} - to-regex@3.0.2: - resolution: {integrity: sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==} - engines: {node: '>=0.10.0'} - toidentifier@1.0.1: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} @@ -11720,18 +9908,10 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - trim-right@1.0.1: - resolution: {integrity: sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==} - engines: {node: '>=0.10.0'} - triple-beam@1.4.1: resolution: {integrity: sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==} engines: {node: '>= 14.0.0'} - truffle-flattener@1.6.0: - resolution: {integrity: sha512-scS5Bsi4CZyvlrmD4iQcLHTiG2RQFUXVheTgWeH6PuafmI+Lk5U87Es98loM3w3ImqC9/fPHq+3QIXbcPuoJ1Q==} - hasBin: true - ts-algebra@1.2.2: resolution: {integrity: sha512-kloPhf1hq3JbCPOTYoOWDKxebWjNb2o/LKnNfkWhxVVisFFmMJPPdJeGoGmM+iRLyoXAR61e08Pb+vUXINg8aA==} @@ -11745,23 +9925,11 @@ packages: resolution: {integrity: sha512-H69ZwTw3rFHb5WYpQya40YAX2/w7Ut75uUECbgBIsLmM+BNuYnxsltfyyLMxy6sEeKxgijLTnQtLd0nKd6+IYw==} hasBin: true - ts-essentials@1.0.4: - resolution: {integrity: sha512-q3N1xS4vZpRouhYHDPwO0bDW3EZ6SK9CrrDHxi/D6BPReSjpVgWIOpLS2o0gSBZm+7q/wyKp6RVM1AeeW7uyfQ==} - - ts-essentials@6.0.7: - resolution: {integrity: sha512-2E4HIIj4tQJlIHuATRHayv0EfMGK3ris/GRk1E3CFnsZzeNV+hUmelbaTZHLtXaZppM5oLhHRtO04gINC4Jusw==} - peerDependencies: - typescript: '>=3.7.0' - ts-essentials@7.0.3: resolution: {integrity: sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==} peerDependencies: typescript: '>=3.7.0' - ts-generator@0.1.1: - resolution: {integrity: sha512-N+ahhZxTLYu1HNTQetwWcx3so8hcYbkKBHTr4b4/YgObFTIKkOSSsaa+nal12w8mfrJAyzJfETXawbNjSfP2gQ==} - hasBin: true - ts-node@10.9.2: resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true @@ -11820,15 +9988,9 @@ packages: tunnel-agent@0.6.0: resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} - tweetnacl-util@0.15.1: - resolution: {integrity: sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==} - tweetnacl@0.14.5: resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} - tweetnacl@1.0.3: - resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} - type-check@0.3.2: resolution: {integrity: sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==} engines: {node: '>= 0.8.0'} @@ -11861,13 +10023,6 @@ packages: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} - type@2.7.3: - resolution: {integrity: sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==} - - typechain@3.0.0: - resolution: {integrity: sha512-ft4KVmiN3zH4JUFu2WJBrwfHeDf772Tt2d8bssDTo/YcckKW2D+OwFrHXRC6hJvO3mHjFQTihoMV6fJOi0Hngg==} - hasBin: true - typechain@8.3.2: resolution: {integrity: sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==} hasBin: true @@ -11890,9 +10045,6 @@ packages: resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} engines: {node: '>= 0.4'} - typedarray-to-buffer@3.1.5: - resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} - typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} @@ -11908,18 +10060,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - typewise-core@1.2.0: - resolution: {integrity: sha512-2SCC/WLzj2SbUwzFOzqMCkz5amXLlxtJqDKTICqg30x+2DZxcfZN2MvQZmGfXWKNWaKK9pBPsvkcwv8bF/gxKg==} - - typewise@1.0.3: - resolution: {integrity: sha512-aXofE06xGhaQSPzt8hlTY+/YWQhm9P0jYUp1f2XtmW/3Bk0qzXcyFWAtPoo2uTGQj1ZwbDuSyuxicq+aDo8lCQ==} - - typewiselite@1.0.0: - resolution: {integrity: sha512-J9alhjVHupW3Wfz6qFRGgQw0N3gr8hOkw6zm7FZ6UR1Cse/oD9/JVok7DNE9TT9IbciDHX2Ex9+ksE6cRmtymw==} - - typical@2.6.1: - resolution: {integrity: sha512-ofhi8kjIje6npGozTip9Fr8iecmYfEbS06i0JnIg+rh51KakryWF4+jX8lLKZVhy6N+ID45WYSFCxPOdTWCzNg==} - typical@4.0.0: resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} engines: {node: '>=8'} @@ -11943,9 +10083,6 @@ packages: engines: {node: '>=0.8.0'} hasBin: true - ultron@1.1.1: - resolution: {integrity: sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==} - unbox-primitive@1.1.0: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} @@ -11957,9 +10094,6 @@ packages: underscore@1.13.7: resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==} - underscore@1.9.1: - resolution: {integrity: sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==} - undici-types@6.21.0: resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} @@ -11978,10 +10112,6 @@ packages: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} - union-value@1.0.1: - resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} - engines: {node: '>=0.10.0'} - unique-filename@3.0.0: resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -12002,18 +10132,10 @@ packages: resolution: {integrity: sha512-6bc58dPYhCMHHuwxldQxO3RRNZ4eCogZ/st++0+fcC1nr0jiGUtAdBJ2qzmLQWSxbtz42pWt4QQMiZ9HvZf5cg==} engines: {node: '>=0.10.0'} - unorm@1.6.0: - resolution: {integrity: sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==} - engines: {node: '>= 0.4.0'} - unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - unset-value@1.0.0: - resolution: {integrity: sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==} - engines: {node: '>=0.10.0'} - update-browserslist-db@1.1.3: resolution: {integrity: sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==} hasBin: true @@ -12029,17 +10151,6 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - urix@0.1.0: - resolution: {integrity: sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==} - deprecated: Please see https://github.com/lydell/urix#deprecated - - url-parse-lax@3.0.0: - resolution: {integrity: sha512-NjFKA0DidqPa5ciFcSrXnAltTtzz84ogy+NebPvfEgAck0+TNg4UJ4IN+fB7zRZfbgUf0syOo9MDxFkDSMuFaQ==} - engines: {node: '>=4'} - - url-set-query@1.0.0: - resolution: {integrity: sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==} - url@0.11.4: resolution: {integrity: sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg==} engines: {node: '>= 0.4'} @@ -12054,10 +10165,6 @@ packages: resolution: {integrity: sha512-dryNz030LWBPAf6gj8vyq0Iev3vPbCLHCT8dBw3gQRXRzVNsIdeuU+VjPp3ksmSPkeMAl1k+kQ14Ij0QHyeiAg==} engines: {node: '>=10.16.0'} - use@3.1.1: - resolution: {integrity: sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==} - engines: {node: '>=0.10.0'} - utf-8-validate@5.0.10: resolution: {integrity: sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==} engines: {node: '>=6.14.2'} @@ -12072,19 +10179,10 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - util.promisify@1.1.3: - resolution: {integrity: sha512-GIEaZ6o86fj09Wtf0VfZ5XP7tmd4t3jM5aZCgmBi231D0DB1AEBa3Aa6MP48DMsAIi96WkpWLimIWVwOjbDMOw==} - engines: {node: '>= 0.8'} - utils-merge@1.0.1: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} - uuid@3.3.2: - resolution: {integrity: sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==} - deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. - hasBin: true - uuid@3.4.0: resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. @@ -12116,9 +10214,6 @@ packages: resolution: {integrity: sha512-Z6Uz+TYwEqE7ZN50gwn+1LCVo9ZVrpxRPOhOLnncYkY1ZzOYtrX8Fwf/rFktZ8R5mJms6EZf5TqNOMeZmnPq9Q==} engines: {node: '>=12'} - varint@5.0.2: - resolution: {integrity: sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==} - vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -12153,111 +10248,16 @@ packages: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} - web3-bzz@1.2.11: - resolution: {integrity: sha512-XGpWUEElGypBjeFyUhTkiPXFbDVD6Nr/S5jznE3t8cWUA0FxRf1n3n/NuIZeb0H9RkN2Ctd/jNma/k8XGa3YKg==} - engines: {node: '>=8.0.0'} - - web3-core-helpers@1.2.11: - resolution: {integrity: sha512-PEPoAoZd5ME7UfbnCZBdzIerpe74GEvlwT4AjOmHeCVZoIFk7EqvOZDejJHt+feJA6kMVTdd0xzRNN295UhC1A==} - engines: {node: '>=8.0.0'} - - web3-core-method@1.2.11: - resolution: {integrity: sha512-ff0q76Cde94HAxLDZ6DbdmKniYCQVtvuaYh+rtOUMB6kssa5FX0q3vPmixi7NPooFnbKmmZCM6NvXg4IreTPIw==} - engines: {node: '>=8.0.0'} - - web3-core-promievent@1.2.11: - resolution: {integrity: sha512-il4McoDa/Ox9Agh4kyfQ8Ak/9ABYpnF8poBLL33R/EnxLsJOGQG2nZhkJa3I067hocrPSjEdlPt/0bHXsln4qA==} - engines: {node: '>=8.0.0'} - - web3-core-requestmanager@1.2.11: - resolution: {integrity: sha512-oFhBtLfOiIbmfl6T6gYjjj9igOvtyxJ+fjS+byRxiwFJyJ5BQOz4/9/17gWR1Cq74paTlI7vDGxYfuvfE/mKvA==} - engines: {node: '>=8.0.0'} - - web3-core-subscriptions@1.2.11: - resolution: {integrity: sha512-qEF/OVqkCvQ7MPs1JylIZCZkin0aKK9lDxpAtQ1F8niEDGFqn7DT8E/vzbIa0GsOjL2fZjDhWJsaW+BSoAW1gg==} - engines: {node: '>=8.0.0'} - - web3-core@1.2.11: - resolution: {integrity: sha512-CN7MEYOY5ryo5iVleIWRE3a3cZqVaLlIbIzDPsvQRUfzYnvzZQRZBm9Mq+ttDi2STOOzc1MKylspz/o3yq/LjQ==} - engines: {node: '>=8.0.0'} - - web3-eth-abi@1.2.11: - resolution: {integrity: sha512-PkRYc0+MjuLSgg03QVWqWlQivJqRwKItKtEpRUaxUAeLE7i/uU39gmzm2keHGcQXo3POXAbOnMqkDvOep89Crg==} - engines: {node: '>=8.0.0'} - - web3-eth-accounts@1.2.11: - resolution: {integrity: sha512-6FwPqEpCfKIh3nSSGeo3uBm2iFSnFJDfwL3oS9pyegRBXNsGRVpgiW63yhNzL0796StsvjHWwQnQHsZNxWAkGw==} - engines: {node: '>=8.0.0'} - - web3-eth-contract@1.2.11: - resolution: {integrity: sha512-MzYuI/Rq2o6gn7vCGcnQgco63isPNK5lMAan2E51AJLknjSLnOxwNY3gM8BcKoy4Z+v5Dv00a03Xuk78JowFow==} - engines: {node: '>=8.0.0'} - - web3-eth-ens@1.2.11: - resolution: {integrity: sha512-dbW7dXP6HqT1EAPvnniZVnmw6TmQEKF6/1KgAxbo8iBBYrVTMDGFQUUnZ+C4VETGrwwaqtX4L9d/FrQhZ6SUiA==} - engines: {node: '>=8.0.0'} - - web3-eth-iban@1.2.11: - resolution: {integrity: sha512-ozuVlZ5jwFC2hJY4+fH9pIcuH1xP0HEFhtWsR69u9uDIANHLPQQtWYmdj7xQ3p2YT4bQLq/axKhZi7EZVetmxQ==} - engines: {node: '>=8.0.0'} - - web3-eth-personal@1.2.11: - resolution: {integrity: sha512-42IzUtKq9iHZ8K9VN0vAI50iSU9tOA1V7XU2BhF/tb7We2iKBVdkley2fg26TxlOcKNEHm7o6HRtiiFsVK4Ifw==} - engines: {node: '>=8.0.0'} - - web3-eth@1.2.11: - resolution: {integrity: sha512-REvxW1wJ58AgHPcXPJOL49d1K/dPmuw4LjPLBPStOVkQjzDTVmJEIsiLwn2YeuNDd4pfakBwT8L3bz1G1/wVsQ==} - engines: {node: '>=8.0.0'} - - web3-net@1.2.11: - resolution: {integrity: sha512-sjrSDj0pTfZouR5BSTItCuZ5K/oZPVdVciPQ6981PPPIwJJkCMeVjD7I4zO3qDPCnBjBSbWvVnLdwqUBPtHxyg==} - engines: {node: '>=8.0.0'} - - web3-provider-engine@14.2.1: - resolution: {integrity: sha512-iSv31h2qXkr9vrL6UZDm4leZMc32SjWJFGOp/D92JXfcEboCqraZyuExDkpxKw8ziTufXieNM7LSXNHzszYdJw==} - deprecated: 'This package has been deprecated, see the README for details: https://github.com/MetaMask/web3-provider-engine' - - web3-providers-http@1.2.11: - resolution: {integrity: sha512-psh4hYGb1+ijWywfwpB2cvvOIMISlR44F/rJtYkRmQ5jMvG4FOCPlQJPiHQZo+2cc3HbktvvSJzIhkWQJdmvrA==} - engines: {node: '>=8.0.0'} - - web3-providers-ipc@1.2.11: - resolution: {integrity: sha512-yhc7Y/k8hBV/KlELxynWjJDzmgDEDjIjBzXK+e0rHBsYEhdCNdIH5Psa456c+l0qTEU2YzycF8VAjYpWfPnBpQ==} - engines: {node: '>=8.0.0'} - - web3-providers-ws@1.2.11: - resolution: {integrity: sha512-ZxnjIY1Er8Ty+cE4migzr43zA/+72AF1myzsLaU5eVgdsfV7Jqx7Dix1hbevNZDKFlSoEyq/3j/jYalh3So1Zg==} - engines: {node: '>=8.0.0'} - - web3-shh@1.2.11: - resolution: {integrity: sha512-B3OrO3oG1L+bv3E1sTwCx66injW1A8hhwpknDUbV+sw3fehFazA06z9SGXUefuFI1kVs4q2vRi0n4oCcI4dZDg==} - engines: {node: '>=8.0.0'} - web3-utils@1.10.4: resolution: {integrity: sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==} engines: {node: '>=8.0.0'} - web3-utils@1.2.11: - resolution: {integrity: sha512-3Tq09izhD+ThqHEaWYX4VOT7dNPdZiO+c/1QMA0s5X2lDFKK/xHJb7cyTRRVzN2LvlHbR7baS1tmQhSua51TcQ==} - engines: {node: '>=8.0.0'} - - web3@1.2.11: - resolution: {integrity: sha512-mjQ8HeU41G6hgOYm1pmeH0mRAeNKJGnJEUzDMoerkpw7QUQT4exVREgF1MYPvL/z6vAshOXei25LE/t/Bxl8yQ==} - engines: {node: '>=8.0.0'} - webcrypto-core@1.8.1: resolution: {integrity: sha512-P+x1MvlNCXlKbLSOY4cYrdreqPG5hbzkmawbcXLKN/mf6DZW0SdNNkZ+sjwsqVkI4A4Ko2sPZmkZtCKY58w83A==} webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - websocket@1.0.32: - resolution: {integrity: sha512-i4yhcllSP4wrpoPMU2N0TQ/q0O94LRG/eUQjEAamRltjQ1oT1PFFKOG4i877OlJgCG8rw6LrrowJp+TYCEWF7Q==} - engines: {node: '>=4.0.0'} - - whatwg-fetch@2.0.4: - resolution: {integrity: sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==} - whatwg-fetch@3.6.20: resolution: {integrity: sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==} @@ -12369,28 +10369,6 @@ packages: resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} - ws@3.3.3: - resolution: {integrity: sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - - ws@5.2.4: - resolution: {integrity: sha512-fFCejsuC8f9kOSu9FYaOw8CdO68O3h5v0lg4p74o8JqWpwTf9tniOD+nOB78aWoVSS6WptVUmDrp/KPsMVBWFQ==} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - ws@6.2.3: resolution: {integrity: sha512-jmTjYU0j60B+vHey6TfR3Z7RD61z/hmxBS3VMSGIrroOWXQEneK1zNuotOUrGyBHQj0yrpsLHPWtigEFd13ndA==} peerDependencies: @@ -12474,22 +10452,6 @@ packages: utf-8-validate: optional: true - xhr-request-promise@0.1.3: - resolution: {integrity: sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg==} - - xhr-request@1.1.0: - resolution: {integrity: sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA==} - - xhr2-cookies@1.1.0: - resolution: {integrity: sha512-hjXUA6q+jl/bd8ADHcVfFsSPIf+tyLIjuO9TwJC9WI6JP2zKcS7C+p56I9kCLLsaCiNT035iYvEUUzdEFj/8+g==} - - xhr@2.6.0: - resolution: {integrity: sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA==} - - xtend@2.1.2: - resolution: {integrity: sha512-vMNKzr2rHP9Dp/e1NQFnLQlwlhp9L/LfvnsVdHxN1f+uggyVI3i08uD14GPvCToPkdsRfyPqIyYGmIk58V98ZQ==} - engines: {node: '>=0.4'} - xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -12504,14 +10466,6 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} - yaeti@0.0.6: - resolution: {integrity: sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==} - engines: {node: '>=0.10.32'} - deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. - - yallist@2.1.2: - resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} - yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -12546,16 +10500,10 @@ packages: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} - yargs-parser@8.1.0: - resolution: {integrity: sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==} - yargs-unparser@2.0.0: resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} engines: {node: '>=10'} - yargs@10.1.2: - resolution: {integrity: sha512-ivSoxqBGYOqQVruxD35+EyCFDYNEFL/Uo6FcOnz+9xZdZzK0Zzw4r4KhbrME1Oo2gOggwJod2MnsdamSG7H9ig==} - yargs@15.4.1: resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==} engines: {node: '>=8'} @@ -13054,7 +11002,7 @@ snapshots: '@babel/types': 7.28.4 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -13413,7 +11361,7 @@ snapshots: '@babel/parser': 7.28.4 '@babel/template': 7.27.2 '@babel/types': 7.28.4 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -13936,7 +11884,7 @@ snapshots: '@eslint/config-array@0.21.1': dependencies: '@eslint/object-schema': 2.1.7 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -13952,7 +11900,7 @@ snapshots: '@eslint/eslintrc@3.3.1': dependencies: ajv: 6.12.6 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) espree: 10.4.0 globals: 14.0.0 ignore: 5.3.2 @@ -13972,20 +11920,10 @@ snapshots: '@eslint/core': 0.17.0 levn: 0.4.1 - '@ethereum-waffle/chai@3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10)': - dependencies: - '@ethereum-waffle/provider': 3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - utf-8-validate - '@ethereum-waffle/chai@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': dependencies: '@ethereum-waffle/provider': 4.0.5(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) json-bigint: 1.0.0 transitivePeerDependencies: @@ -13993,26 +11931,6 @@ snapshots: - '@ensdomains/resolver' - supports-color - '@ethereum-waffle/compiler@3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(typescript@5.9.3)(utf-8-validate@5.0.10)': - dependencies: - '@resolver-engine/imports': 0.3.3 - '@resolver-engine/imports-fs': 0.3.3 - '@typechain/ethers-v5': 2.0.0(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typechain@3.0.0(typescript@5.9.3)) - '@types/mkdirp': 0.5.2 - '@types/node-fetch': 2.6.13 - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - mkdirp: 0.5.6 - node-fetch: 2.7.0(encoding@0.1.13) - solc: 0.6.12 - ts-generator: 0.1.1 - typechain: 3.0.0(typescript@5.9.3) - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - typescript - - utf-8-validate - '@ethereum-waffle/compiler@4.0.3(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(solc@0.8.15)(typechain@8.3.2(patch_hash=b34ed6afcf99760666fdc85ecb2094fdd20ce509f947eb09cef21665a2a6a1d6)(typescript@5.9.3))(typescript@5.9.3)': dependencies: '@resolver-engine/imports': 0.3.3 @@ -14032,51 +11950,21 @@ snapshots: - supports-color - typescript - '@ethereum-waffle/ens@3.4.4(bufferutil@4.0.9)(utf-8-validate@5.0.10)': - dependencies: - '@ensdomains/ens': 0.4.5 - '@ensdomains/resolver': 0.2.4 - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - utf-8-validate - '@ethereum-waffle/ens@4.0.3(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': dependencies: '@ensdomains/ens': 0.4.5 '@ensdomains/resolver': 0.2.4 ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@ethereum-waffle/mock-contract@3.4.4(bufferutil@4.0.9)(utf-8-validate@5.0.10)': - dependencies: - '@ethersproject/abi': 5.8.0 - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - utf-8-validate - '@ethereum-waffle/mock-contract@4.0.4(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': dependencies: ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@ethereum-waffle/provider@3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10)': - dependencies: - '@ethereum-waffle/ens': 3.4.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - ganache-core: 2.13.2(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) - patch-package: 6.5.1 - postinstall-postinstall: 2.1.0 - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - utf-8-validate - '@ethereum-waffle/provider@4.0.5(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': dependencies: '@ethereum-waffle/ens': 4.0.3(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) '@ganache/ethereum-options': 0.1.4 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) ganache: 7.4.3 transitivePeerDependencies: @@ -14096,7 +11984,7 @@ snapshots: '@ethereumjs/block': 3.6.3 '@ethereumjs/common': 2.6.5 '@ethereumjs/ethash': 1.1.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethereumjs-util: 7.1.5 level-mem: 5.0.1 lru-cache: 5.1.1 @@ -14128,7 +12016,7 @@ snapshots: '@ethereumjs/tx@3.4.0': dependencies: - '@ethereumjs/common': 2.6.0 + '@ethereumjs/common': 2.6.5 ethereumjs-util: 7.1.5 '@ethereumjs/tx@3.5.2': @@ -14151,8 +12039,8 @@ snapshots: dependencies: '@ethereumjs/block': 3.6.3 '@ethereumjs/blockchain': 5.5.3 - '@ethereumjs/common': 2.6.0 - '@ethereumjs/tx': 3.4.0 + '@ethereumjs/common': 2.6.5 + '@ethereumjs/tx': 3.5.2 async-eventemitter: 0.2.4 core-js-pure: 3.45.1 debug: 2.6.9 @@ -14164,19 +12052,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@ethersproject/abi@5.0.0-beta.153': - dependencies: - '@ethersproject/address': 5.8.0 - '@ethersproject/bignumber': 5.8.0 - '@ethersproject/bytes': 5.8.0 - '@ethersproject/constants': 5.8.0 - '@ethersproject/hash': 5.8.0 - '@ethersproject/keccak256': 5.8.0 - '@ethersproject/logger': 5.8.0 - '@ethersproject/properties': 5.8.0 - '@ethersproject/strings': 5.8.0 - optional: true - '@ethersproject/abi@5.6.0': dependencies: '@ethersproject/address': 5.8.0 @@ -15249,7 +13124,7 @@ snapshots: '@graphprotocol/contracts': 7.2.1 '@nomicfoundation/hardhat-network-helpers': 1.1.0(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) hardhat-secure-accounts: 0.0.6(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) @@ -16180,14 +14055,6 @@ snapshots: '@ledgerhq/logs@5.50.0': {} - '@ljharb/resumer@0.0.1': - dependencies: - '@ljharb/through': 2.3.14 - - '@ljharb/through@2.3.14': - dependencies: - call-bind: 1.0.8 - '@manypkg/find-root@1.1.0': dependencies: '@babel/runtime': 7.28.4 @@ -16349,7 +14216,7 @@ snapshots: '@nomicfoundation/hardhat-ethers@3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': dependencies: - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) lodash.isequal: 4.5.0 @@ -16358,7 +14225,7 @@ snapshots: '@nomicfoundation/hardhat-ethers@3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': dependencies: - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) lodash.isequal: 4.5.0 @@ -16369,7 +14236,7 @@ snapshots: dependencies: '@nomicfoundation/hardhat-errors': 3.0.6 '@nomicfoundation/hardhat-utils': 3.0.6 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethereum-cryptography: 2.2.1 ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10) @@ -16397,7 +14264,7 @@ snapshots: '@nomicfoundation/ignition-core': 0.15.13(bufferutil@4.0.9)(utf-8-validate@5.0.10) '@nomicfoundation/ignition-ui': 0.15.12 chalk: 4.1.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) fs-extra: 10.1.0 hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) json5: 2.2.3 @@ -16415,7 +14282,7 @@ snapshots: '@nomicfoundation/hardhat-utils': 3.0.6 '@nomicfoundation/hardhat-zod-utils': 3.0.1(zod@3.25.76) chalk: 5.6.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) hardhat: 3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10) zod: 3.25.76 transitivePeerDependencies: @@ -16498,7 +14365,7 @@ snapshots: '@nomicfoundation/hardhat-utils@3.0.6': dependencies: '@streamparser/json-node': 0.0.22 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) env-paths: 2.2.1 ethereum-cryptography: 2.2.1 fast-equals: 5.4.0 @@ -16515,7 +14382,7 @@ snapshots: '@ethersproject/abi': 5.8.0 '@ethersproject/address': 5.8.0 cbor: 8.1.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) lodash.clonedeep: 4.5.0 picocolors: 1.1.1 @@ -16530,7 +14397,7 @@ snapshots: '@ethersproject/abi': 5.8.0 '@ethersproject/address': 5.8.0 cbor: 8.1.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) lodash.clonedeep: 4.5.0 picocolors: 1.1.1 @@ -16548,7 +14415,7 @@ snapshots: '@nomicfoundation/hardhat-zod-utils': 3.0.1(zod@3.25.76) cbor2: 1.12.0 chalk: 5.6.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) hardhat: 3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10) semver: 7.7.2 zod: 3.25.76 @@ -16568,7 +14435,7 @@ snapshots: '@ethersproject/address': 5.6.1 '@nomicfoundation/solidity-analyzer': 0.1.2 cbor: 9.0.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) fs-extra: 10.1.0 immer: 10.0.2 @@ -16625,13 +14492,18 @@ snapshots: ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) + '@nomiclabs/hardhat-ethers@2.2.3(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': + dependencies: + ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) + '@nomiclabs/hardhat-etherscan@3.1.8(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': dependencies: '@ethersproject/abi': 5.8.0 '@ethersproject/address': 5.8.0 cbor: 8.1.0 chalk: 2.4.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) fs-extra: 7.0.1 hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) lodash: 4.17.21 @@ -16641,21 +14513,19 @@ snapshots: transitivePeerDependencies: - supports-color - '@nomiclabs/hardhat-waffle@2.0.6(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@types/sinon-chai@3.2.12)(ethereum-waffle@3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(typescript@5.9.3)(utf-8-validate@5.0.10))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': - dependencies: - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) - '@types/sinon-chai': 3.2.12 - ethereum-waffle: 3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(typescript@5.9.3)(utf-8-validate@5.0.10) - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) - - '@nomiclabs/hardhat-waffle@2.0.6(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@types/sinon-chai@3.2.12)(ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': + '@nomiclabs/hardhat-waffle@2.0.6(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@types/sinon-chai@3.2.12)(ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))': dependencies: + '@ethereum-waffle/chai': 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + '@ethereum-waffle/provider': 4.0.5(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@types/sinon-chai': 3.2.12 ethereum-waffle: 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3) ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - '@ensdomains/ens' + - '@ensdomains/resolver' + - supports-color '@npmcli/agent@2.2.2': dependencies: @@ -16681,8 +14551,6 @@ snapshots: '@openzeppelin/contracts@3.4.2': {} - '@openzeppelin/contracts@4.9.6': {} - '@openzeppelin/contracts@5.4.0': {} '@openzeppelin/defender-base-client@1.54.6(debug@4.4.3)(encoding@0.1.13)': @@ -16750,7 +14618,7 @@ snapshots: '@openzeppelin/platform-deploy-client': 0.8.0(debug@4.4.3)(encoding@0.1.13) '@openzeppelin/upgrades-core': 1.44.1 chalk: 4.1.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) proper-lockfile: 4.1.2 @@ -16776,7 +14644,7 @@ snapshots: cbor: 10.0.11 chalk: 4.1.2 compare-versions: 6.1.1 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) ethereumjs-util: 7.1.5 minimatch: 9.0.5 minimist: 1.2.8 @@ -16833,7 +14701,7 @@ snapshots: '@react-native/community-cli-plugin@0.81.4(bufferutil@4.0.9)(utf-8-validate@5.0.10)': dependencies: '@react-native/dev-middleware': 0.81.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) invariant: 2.2.4 metro: 0.83.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) metro-config: 0.83.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) @@ -16853,7 +14721,7 @@ snapshots: chrome-launcher: 0.15.2 chromium-edge-launcher: 0.2.0 connect: 3.7.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) invariant: 2.2.4 nullthrows: 1.1.1 open: 7.4.2 @@ -16881,13 +14749,6 @@ snapshots: '@repeaterjs/repeater@3.0.6': {} - '@resolver-engine/core@0.2.1': - dependencies: - debug: 3.2.7 - request: 2.88.2 - transitivePeerDependencies: - - supports-color - '@resolver-engine/core@0.3.3': dependencies: debug: 3.2.7 @@ -16896,13 +14757,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@resolver-engine/fs@0.2.1': - dependencies: - '@resolver-engine/core': 0.2.1 - debug: 3.2.7 - transitivePeerDependencies: - - supports-color - '@resolver-engine/fs@0.3.3': dependencies: '@resolver-engine/core': 0.3.3 @@ -16910,14 +14764,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@resolver-engine/imports-fs@0.2.2': - dependencies: - '@resolver-engine/fs': 0.2.1 - '@resolver-engine/imports': 0.2.2 - debug: 3.2.7 - transitivePeerDependencies: - - supports-color - '@resolver-engine/imports-fs@0.3.3': dependencies: '@resolver-engine/fs': 0.3.3 @@ -16926,14 +14772,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@resolver-engine/imports@0.2.2': - dependencies: - '@resolver-engine/core': 0.2.1 - debug: 3.2.7 - hosted-git-info: 2.8.9 - transitivePeerDependencies: - - supports-color - '@resolver-engine/imports@0.3.3': dependencies: '@resolver-engine/core': 0.3.3 @@ -16984,10 +14822,10 @@ snapshots: - utf-8-validate - zod - '@rocketh/doc@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': + '@rocketh/doc@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': dependencies: '@rocketh/core': 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) - '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/fs-extra': 11.0.4 abitype: 1.2.3(typescript@5.9.3)(zod@3.25.76) commander: 14.0.2 @@ -17000,24 +14838,24 @@ snapshots: - utf-8-validate - zod - '@rocketh/export@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': + '@rocketh/export@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': dependencies: '@rocketh/core': 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) - '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/fs-extra': 11.0.4 abitype: 1.2.3(typescript@5.9.3)(zod@3.25.76) chalk: 5.6.2 commander: 14.0.2 eip-1193: 0.6.5 fs-extra: 11.3.3 - rocketh: 0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + rocketh: 0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) transitivePeerDependencies: - bufferutil - typescript - utf-8-validate - zod - '@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': + '@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': dependencies: '@rocketh/core': 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/prompts': 2.4.9 @@ -17028,7 +14866,7 @@ snapshots: named-logs: 0.4.1 named-logs-console: 0.5.1 prompts: 2.4.2 - rocketh: 0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + rocketh: 0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) tsx: 4.21.0 viem: 2.44.4(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) transitivePeerDependencies: @@ -17065,10 +14903,10 @@ snapshots: - utf-8-validate - zod - '@rocketh/verifier@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': + '@rocketh/verifier@0.17.16(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76)': dependencies: '@rocketh/core': 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) - '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/fs-extra': 11.0.4 '@types/qs': 6.14.0 chalk: 5.6.2 @@ -17174,12 +15012,6 @@ snapshots: '@sinclair/typebox@0.27.8': {} - '@sindresorhus/is@0.14.0': - optional: true - - '@sindresorhus/is@4.6.0': - optional: true - '@sindresorhus/is@5.6.0': {} '@sinonjs/commons@3.0.1': @@ -17510,16 +15342,6 @@ snapshots: '@streamparser/json@0.0.22': {} - '@szmarczak/http-timer@1.1.2': - dependencies: - defer-to-connect: 1.1.3 - optional: true - - '@szmarczak/http-timer@4.0.6': - dependencies: - defer-to-connect: 2.0.1 - optional: true - '@szmarczak/http-timer@5.0.1': dependencies: defer-to-connect: 2.0.1 @@ -17565,7 +15387,7 @@ snapshots: '@tenderly/hardhat-tenderly@1.11.0(@types/node@20.19.14)(bufferutil@4.0.9)(encoding@0.1.13)(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10))(utf-8-validate@5.0.10)': dependencies: '@ethersproject/bignumber': 5.8.0 - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) + '@nomiclabs/hardhat-ethers': 2.2.3(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@nomiclabs/hardhat-etherscan': 3.1.8(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@openzeppelin/hardhat-upgrades': 1.28.0(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(@nomiclabs/hardhat-etherscan@3.1.8(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) '@openzeppelin/upgrades-core': 1.44.1 @@ -17617,11 +15439,6 @@ snapshots: typechain: 8.3.2(patch_hash=b34ed6afcf99760666fdc85ecb2094fdd20ce509f947eb09cef21665a2a6a1d6)(typescript@5.9.3) typescript: 5.9.3 - '@typechain/ethers-v5@2.0.0(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typechain@3.0.0(typescript@5.9.3))': - dependencies: - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - typechain: 3.0.0(typescript@5.9.3) - '@typechain/ethers-v6@0.5.1(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typechain@8.3.2(patch_hash=b34ed6afcf99760666fdc85ecb2094fdd20ce509f947eb09cef21665a2a6a1d6)(typescript@5.9.3))(typescript@5.9.3)': dependencies: ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) @@ -17679,14 +15496,6 @@ snapshots: dependencies: '@types/node': 20.19.14 - '@types/cacheable-request@6.0.3': - dependencies: - '@types/http-cache-semantics': 4.0.4 - '@types/keyv': 3.1.4 - '@types/node': 20.19.14 - '@types/responselike': 1.0.3 - optional: true - '@types/chai-as-promised@7.1.8': dependencies: '@types/chai': 4.3.20 @@ -17760,11 +15569,6 @@ snapshots: '@types/katex@0.16.7': {} - '@types/keyv@3.1.4': - dependencies: - '@types/node': 20.19.14 - optional: true - '@types/level-errors@3.0.2': {} '@types/levelup@4.3.3': @@ -17811,15 +15615,6 @@ snapshots: '@types/qs@6.14.0': {} - '@types/resolve@0.0.8': - dependencies: - '@types/node': 20.19.14 - - '@types/responselike@1.0.3': - dependencies: - '@types/node': 20.19.14 - optional: true - '@types/secp256k1@4.0.6': dependencies: '@types/node': 20.19.14 @@ -17877,7 +15672,7 @@ snapshots: '@typescript-eslint/types': 8.53.1 '@typescript-eslint/typescript-estree': 8.53.1(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.53.1 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) eslint: 9.39.2(jiti@2.5.1) typescript: 5.9.3 transitivePeerDependencies: @@ -17887,7 +15682,7 @@ snapshots: dependencies: '@typescript-eslint/tsconfig-utils': 8.53.1(typescript@5.9.3) '@typescript-eslint/types': 8.53.1 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -17906,7 +15701,7 @@ snapshots: '@typescript-eslint/types': 8.53.1 '@typescript-eslint/typescript-estree': 8.53.1(typescript@5.9.3) '@typescript-eslint/utils': 8.53.1(eslint@9.39.2(jiti@2.5.1))(typescript@5.9.3) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) eslint: 9.39.2(jiti@2.5.1) ts-api-utils: 2.4.0(typescript@5.9.3) typescript: 5.9.3 @@ -17921,7 +15716,7 @@ snapshots: '@typescript-eslint/tsconfig-utils': 8.53.1(typescript@5.9.3) '@typescript-eslint/types': 8.53.1 '@typescript-eslint/visitor-keys': 8.53.1 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) minimatch: 9.0.5 semver: 7.7.3 tinyglobby: 0.2.15 @@ -18058,8 +15853,6 @@ snapshots: '@whatwg-node/fetch': 0.8.8 tslib: 2.8.1 - '@yarnpkg/lockfile@1.1.0': {} - JSONStream@1.3.5: dependencies: jsonparse: 1.3.1 @@ -18081,26 +15874,10 @@ snapshots: dependencies: event-target-shim: 5.0.1 - abstract-leveldown@2.6.3: - dependencies: - xtend: 4.0.2 - - abstract-leveldown@2.7.2: - dependencies: - xtend: 4.0.2 - - abstract-leveldown@3.0.0: - dependencies: - xtend: 4.0.2 - - abstract-leveldown@5.0.0: - dependencies: - xtend: 4.0.2 - abstract-leveldown@6.2.3: dependencies: buffer: 5.7.1 - immediate: 3.2.3 + immediate: 3.3.0 level-concat-iterator: 2.0.1 level-supports: 1.0.1 xtend: 4.0.2 @@ -18132,14 +15909,11 @@ snapshots: aes-js@3.0.0: {} - aes-js@3.1.2: - optional: true - aes-js@4.0.0-beta.5: {} agent-base@6.0.2: dependencies: - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -18158,13 +15932,6 @@ snapshots: optionalDependencies: ajv: 8.17.1 - ajv@5.5.2: - dependencies: - co: 4.6.0 - fast-deep-equal: 1.1.0 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.3.1 - ajv@6.12.6: dependencies: fast-deep-equal: 3.1.3 @@ -18218,8 +15985,6 @@ snapshots: ansi-regex@6.2.2: {} - ansi-styles@2.2.1: {} - ansi-styles@3.2.1: dependencies: color-convert: 1.9.3 @@ -18234,11 +15999,6 @@ snapshots: antlr4ts@0.5.0-alpha.4: {} - anymatch@1.3.2: - dependencies: - micromatch: 2.3.11 - normalize-path: 2.1.1 - anymatch@3.1.3: dependencies: normalize-path: 3.0.0 @@ -18271,24 +16031,6 @@ snapshots: argparse@2.0.1: {} - arr-diff@2.0.0: - dependencies: - arr-flatten: 1.1.0 - - arr-diff@4.0.0: {} - - arr-flatten@1.1.0: {} - - arr-union@3.1.0: {} - - array-back@1.0.4: - dependencies: - typical: 2.6.1 - - array-back@2.0.0: - dependencies: - typical: 2.6.1 - array-back@3.1.0: {} array-back@4.0.2: {} @@ -18317,10 +16059,6 @@ snapshots: array-uniq@1.0.3: {} - array-unique@0.2.1: {} - - array-unique@0.3.2: {} - array.prototype.findlastindex@1.2.6: dependencies: call-bind: 1.0.8 @@ -18345,17 +16083,6 @@ snapshots: es-abstract: 1.24.0 es-shim-unscopables: 1.1.0 - array.prototype.reduce@1.0.8: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.4 - define-properties: 1.2.1 - es-abstract: 1.24.0 - es-array-method-boxes-properly: 1.0.0 - es-errors: 1.3.0 - es-object-atoms: 1.1.1 - is-string: 1.1.1 - arraybuffer.prototype.slice@1.0.4: dependencies: array-buffer-byte-length: 1.0.2 @@ -18368,13 +16095,6 @@ snapshots: asap@2.0.6: {} - asn1.js@4.10.1: - dependencies: - bn.js: 4.12.2 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - optional: true - asn1@0.2.6: dependencies: safer-buffer: 2.1.2 @@ -18391,14 +16111,10 @@ snapshots: assertion-error@2.0.1: {} - assign-symbols@1.0.0: {} - ast-parents@0.0.1: {} astral-regex@2.0.0: {} - async-each@1.0.6: {} - async-eventemitter@0.2.4: dependencies: async: 2.6.4 @@ -18417,10 +16133,6 @@ snapshots: async@1.5.2: {} - async@2.6.2: - dependencies: - lodash: 4.17.21 - async@2.6.4: dependencies: lodash: 4.17.21 @@ -18431,8 +16143,6 @@ snapshots: at-least-node@1.0.0: {} - atob@2.1.2: {} - atomic-sleep@1.0.0: {} auto-bind@4.0.0: {} @@ -18466,140 +16176,6 @@ snapshots: transitivePeerDependencies: - debug - babel-code-frame@6.26.0: - dependencies: - chalk: 1.1.3 - esutils: 2.0.3 - js-tokens: 3.0.2 - - babel-core@6.26.3: - dependencies: - babel-code-frame: 6.26.0 - babel-generator: 6.26.1 - babel-helpers: 6.24.1 - babel-messages: 6.23.0 - babel-register: 6.26.0 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - babylon: 6.18.0 - convert-source-map: 1.9.0 - debug: 2.6.9 - json5: 0.5.1 - lodash: 4.17.21 - minimatch: 3.1.2 - path-is-absolute: 1.0.1 - private: 0.1.8 - slash: 1.0.0 - source-map: 0.5.7 - transitivePeerDependencies: - - supports-color - - babel-generator@6.26.1: - dependencies: - babel-messages: 6.23.0 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - detect-indent: 4.0.0 - jsesc: 1.3.0 - lodash: 4.17.21 - source-map: 0.5.7 - trim-right: 1.0.1 - - babel-helper-builder-binary-assignment-operator-visitor@6.24.1: - dependencies: - babel-helper-explode-assignable-expression: 6.24.1 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helper-call-delegate@6.24.1: - dependencies: - babel-helper-hoist-variables: 6.24.1 - babel-runtime: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helper-define-map@6.26.0: - dependencies: - babel-helper-function-name: 6.24.1 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - lodash: 4.17.21 - transitivePeerDependencies: - - supports-color - - babel-helper-explode-assignable-expression@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helper-function-name@6.24.1: - dependencies: - babel-helper-get-function-arity: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helper-get-function-arity@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-helper-hoist-variables@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-helper-optimise-call-expression@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-helper-regex@6.26.0: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - lodash: 4.17.21 - - babel-helper-remap-async-to-generator@6.24.1: - dependencies: - babel-helper-function-name: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helper-replace-supers@6.24.1: - dependencies: - babel-helper-optimise-call-expression: 6.24.1 - babel-messages: 6.23.0 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-helpers@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-template: 6.26.0 - transitivePeerDependencies: - - supports-color - babel-jest@29.7.0(@babel/core@7.28.4): dependencies: '@babel/core': 7.28.4 @@ -18613,14 +16189,6 @@ snapshots: transitivePeerDependencies: - supports-color - babel-messages@6.23.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-check-es2015-constants@6.22.0: - dependencies: - babel-runtime: 6.26.0 - babel-plugin-istanbul@6.1.1: dependencies: '@babel/helper-plugin-utils': 7.27.1 @@ -18638,242 +16206,32 @@ snapshots: '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.28.0 - babel-plugin-syntax-async-functions@6.13.0: {} - - babel-plugin-syntax-exponentiation-operator@6.13.0: {} - babel-plugin-syntax-hermes-parser@0.29.1: dependencies: hermes-parser: 0.29.1 - babel-plugin-syntax-trailing-function-commas@6.22.0: {} - babel-plugin-syntax-trailing-function-commas@7.0.0-beta.0: {} - babel-plugin-transform-async-to-generator@6.24.1: - dependencies: - babel-helper-remap-async-to-generator: 6.24.1 - babel-plugin-syntax-async-functions: 6.13.0 - babel-runtime: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-arrow-functions@6.22.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-block-scoped-functions@6.22.0: + babel-preset-current-node-syntax@1.2.0(@babel/core@7.28.4): dependencies: - babel-runtime: 6.26.0 + '@babel/core': 7.28.4 + '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.28.4) + '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.28.4) + '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.28.4) + '@babel/plugin-syntax-import-attributes': 7.27.1(@babel/core@7.28.4) + '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.28.4) + '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.28.4) + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.28.4) + '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.28.4) + '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.28.4) + '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.28.4) - babel-plugin-transform-es2015-block-scoping@6.26.0: - dependencies: - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - lodash: 4.17.21 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-classes@6.24.1: - dependencies: - babel-helper-define-map: 6.26.0 - babel-helper-function-name: 6.24.1 - babel-helper-optimise-call-expression: 6.24.1 - babel-helper-replace-supers: 6.24.1 - babel-messages: 6.23.0 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-computed-properties@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-template: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-destructuring@6.23.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-duplicate-keys@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-plugin-transform-es2015-for-of@6.23.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-function-name@6.24.1: - dependencies: - babel-helper-function-name: 6.24.1 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-literals@6.22.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-modules-amd@6.24.1: - dependencies: - babel-plugin-transform-es2015-modules-commonjs: 6.26.2 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-modules-commonjs@6.26.2: - dependencies: - babel-plugin-transform-strict-mode: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-modules-systemjs@6.24.1: - dependencies: - babel-helper-hoist-variables: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-modules-umd@6.24.1: - dependencies: - babel-plugin-transform-es2015-modules-amd: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-object-super@6.24.1: - dependencies: - babel-helper-replace-supers: 6.24.1 - babel-runtime: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-parameters@6.24.1: - dependencies: - babel-helper-call-delegate: 6.24.1 - babel-helper-get-function-arity: 6.24.1 - babel-runtime: 6.26.0 - babel-template: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-es2015-shorthand-properties@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-plugin-transform-es2015-spread@6.22.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-sticky-regex@6.24.1: - dependencies: - babel-helper-regex: 6.26.0 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-plugin-transform-es2015-template-literals@6.22.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-typeof-symbol@6.23.0: - dependencies: - babel-runtime: 6.26.0 - - babel-plugin-transform-es2015-unicode-regex@6.24.1: - dependencies: - babel-helper-regex: 6.26.0 - babel-runtime: 6.26.0 - regexpu-core: 2.0.0 - - babel-plugin-transform-exponentiation-operator@6.24.1: - dependencies: - babel-helper-builder-binary-assignment-operator-visitor: 6.24.1 - babel-plugin-syntax-exponentiation-operator: 6.13.0 - babel-runtime: 6.26.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-transform-regenerator@6.26.0: - dependencies: - regenerator-transform: 0.10.1 - - babel-plugin-transform-strict-mode@6.24.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - - babel-preset-current-node-syntax@1.2.0(@babel/core@7.28.4): - dependencies: - '@babel/core': 7.28.4 - '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.28.4) - '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.28.4) - '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.28.4) - '@babel/plugin-syntax-import-attributes': 7.27.1(@babel/core@7.28.4) - '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.28.4) - '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.28.4) - '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.28.4) - '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.28.4) - '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.28.4) - '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.28.4) - - babel-preset-env@1.7.0: - dependencies: - babel-plugin-check-es2015-constants: 6.22.0 - babel-plugin-syntax-trailing-function-commas: 6.22.0 - babel-plugin-transform-async-to-generator: 6.24.1 - babel-plugin-transform-es2015-arrow-functions: 6.22.0 - babel-plugin-transform-es2015-block-scoped-functions: 6.22.0 - babel-plugin-transform-es2015-block-scoping: 6.26.0 - babel-plugin-transform-es2015-classes: 6.24.1 - babel-plugin-transform-es2015-computed-properties: 6.24.1 - babel-plugin-transform-es2015-destructuring: 6.23.0 - babel-plugin-transform-es2015-duplicate-keys: 6.24.1 - babel-plugin-transform-es2015-for-of: 6.23.0 - babel-plugin-transform-es2015-function-name: 6.24.1 - babel-plugin-transform-es2015-literals: 6.22.0 - babel-plugin-transform-es2015-modules-amd: 6.24.1 - babel-plugin-transform-es2015-modules-commonjs: 6.26.2 - babel-plugin-transform-es2015-modules-systemjs: 6.24.1 - babel-plugin-transform-es2015-modules-umd: 6.24.1 - babel-plugin-transform-es2015-object-super: 6.24.1 - babel-plugin-transform-es2015-parameters: 6.24.1 - babel-plugin-transform-es2015-shorthand-properties: 6.24.1 - babel-plugin-transform-es2015-spread: 6.22.0 - babel-plugin-transform-es2015-sticky-regex: 6.24.1 - babel-plugin-transform-es2015-template-literals: 6.22.0 - babel-plugin-transform-es2015-typeof-symbol: 6.23.0 - babel-plugin-transform-es2015-unicode-regex: 6.24.1 - babel-plugin-transform-exponentiation-operator: 6.24.1 - babel-plugin-transform-regenerator: 6.26.0 - browserslist: 3.2.8 - invariant: 2.2.4 - semver: 5.7.2 - transitivePeerDependencies: - - supports-color - - babel-preset-fbjs@3.4.0(@babel/core@7.28.4): + babel-preset-fbjs@3.4.0(@babel/core@7.28.4): dependencies: '@babel/core': 7.28.4 '@babel/plugin-proposal-class-properties': 7.18.6(@babel/core@7.28.4) @@ -18912,67 +16270,6 @@ snapshots: babel-plugin-jest-hoist: 29.6.3 babel-preset-current-node-syntax: 1.2.0(@babel/core@7.28.4) - babel-register@6.26.0: - dependencies: - babel-core: 6.26.3 - babel-runtime: 6.26.0 - core-js: 2.6.12 - home-or-tmp: 2.0.0 - lodash: 4.17.21 - mkdirp: 0.5.6 - source-map-support: 0.4.18 - transitivePeerDependencies: - - supports-color - - babel-runtime@6.26.0: - dependencies: - core-js: 2.6.12 - regenerator-runtime: 0.11.1 - - babel-template@6.26.0: - dependencies: - babel-runtime: 6.26.0 - babel-traverse: 6.26.0 - babel-types: 6.26.0 - babylon: 6.18.0 - lodash: 4.17.21 - transitivePeerDependencies: - - supports-color - - babel-traverse@6.26.0: - dependencies: - babel-code-frame: 6.26.0 - babel-messages: 6.23.0 - babel-runtime: 6.26.0 - babel-types: 6.26.0 - babylon: 6.18.0 - debug: 2.6.9 - globals: 9.18.0 - invariant: 2.2.4 - lodash: 4.17.21 - transitivePeerDependencies: - - supports-color - - babel-types@6.26.0: - dependencies: - babel-runtime: 6.26.0 - esutils: 2.0.3 - lodash: 4.17.21 - to-fast-properties: 1.0.3 - - babelify@7.3.0: - dependencies: - babel-core: 6.26.3 - object-assign: 4.1.1 - transitivePeerDependencies: - - supports-color - - babylon@6.18.0: {} - - backoff@2.5.0: - dependencies: - precond: 0.2.3 - balanced-match@1.0.2: {} base-64@0.1.0: {} @@ -18985,16 +16282,6 @@ snapshots: base64-js@1.5.1: {} - base@0.11.2: - dependencies: - cache-base: 1.0.1 - class-utils: 0.3.6 - component-emitter: 1.3.1 - define-property: 1.0.0 - isobject: 3.0.1 - mixin-deep: 1.3.2 - pascalcase: 0.1.1 - baseline-browser-mapping@2.8.4: {} basic-auth@2.0.1: @@ -19022,8 +16309,6 @@ snapshots: bignumber.js@9.3.1: {} - binary-extensions@1.13.1: {} - binary-extensions@2.3.0: {} bindings@1.5.0: @@ -19033,14 +16318,6 @@ snapshots: bintrees@1.0.2: {} - bip39@2.5.0: - dependencies: - create-hash: 1.2.0 - pbkdf2: 3.1.3 - randombytes: 2.1.0 - safe-buffer: 5.2.1 - unorm: 1.6.0 - bip39@3.0.4: dependencies: '@types/node': 20.19.14 @@ -19129,24 +16406,6 @@ snapshots: transitivePeerDependencies: - supports-color - body-parser@1.20.3: - dependencies: - bytes: 3.1.2 - content-type: 1.0.5 - debug: 2.6.9 - depd: 2.0.0 - destroy: 1.2.0 - http-errors: 2.0.0 - iconv-lite: 0.4.24 - on-finished: 2.4.1 - qs: 6.13.0 - raw-body: 2.5.2 - type-is: 1.6.18 - unpipe: 1.0.0 - transitivePeerDependencies: - - supports-color - optional: true - bowser@2.12.1: {} boxen@5.1.2: @@ -19169,35 +16428,12 @@ snapshots: dependencies: balanced-match: 1.0.2 - braces@1.8.5: - dependencies: - expand-range: 1.8.2 - preserve: 0.2.0 - repeat-element: 1.1.4 - - braces@2.3.2: - dependencies: - arr-flatten: 1.1.0 - array-unique: 0.3.2 - extend-shallow: 2.0.1 - fill-range: 4.0.0 - isobject: 3.0.1 - repeat-element: 1.1.4 - snapdragon: 0.8.2 - snapdragon-node: 2.1.1 - split-string: 3.1.0 - to-regex: 3.0.2 - transitivePeerDependencies: - - supports-color - braces@3.0.3: dependencies: fill-range: 7.1.1 brorand@1.1.0: {} - browser-stdout@1.3.0: {} - browser-stdout@1.3.1: {} browserify-aes@1.2.0: @@ -19209,47 +16445,6 @@ snapshots: inherits: 2.0.4 safe-buffer: 5.2.1 - browserify-cipher@1.0.1: - dependencies: - browserify-aes: 1.2.0 - browserify-des: 1.0.2 - evp_bytestokey: 1.0.3 - optional: true - - browserify-des@1.0.2: - dependencies: - cipher-base: 1.0.6 - des.js: 1.1.0 - inherits: 2.0.4 - safe-buffer: 5.2.1 - optional: true - - browserify-rsa@4.1.1: - dependencies: - bn.js: 5.2.2 - randombytes: 2.1.0 - safe-buffer: 5.2.1 - optional: true - - browserify-sign@4.2.3: - dependencies: - bn.js: 5.2.2 - browserify-rsa: 4.1.1 - create-hash: 1.2.0 - create-hmac: 1.1.7 - elliptic: 6.6.1 - hash-base: 3.0.5 - inherits: 2.0.4 - parse-asn1: 5.1.7 - readable-stream: 2.3.8 - safe-buffer: 5.2.1 - optional: true - - browserslist@3.2.8: - dependencies: - caniuse-lite: 1.0.30001741 - electron-to-chromium: 1.5.218 - browserslist@4.26.0: dependencies: baseline-browser-mapping: 2.8.4 @@ -19278,9 +16473,6 @@ snapshots: buffer-from@1.1.2: {} - buffer-to-arraybuffer@0.0.5: - optional: true - buffer-writer@2.0.0: {} buffer-xor@1.0.3: {} @@ -19308,6 +16500,7 @@ snapshots: bufferutil@4.0.9: dependencies: node-gyp-build: 4.8.4 + optional: true bundle-require@5.1.0(esbuild@0.25.9): dependencies: @@ -19322,15 +16515,6 @@ snapshots: bytes@3.1.2: {} - bytewise-core@1.2.3: - dependencies: - typewise-core: 1.2.0 - - bytewise@1.1.0: - dependencies: - bytewise-core: 1.2.3 - typewise: 1.0.3 - cac@6.7.14: {} cacache@18.0.4: @@ -19348,21 +16532,6 @@ snapshots: tar: 6.2.1 unique-filename: 3.0.0 - cache-base@1.0.1: - dependencies: - collection-visit: 1.0.0 - component-emitter: 1.3.1 - get-value: 2.0.6 - has-value: 1.0.0 - isobject: 3.0.1 - set-value: 2.0.1 - to-object-path: 0.3.0 - union-value: 1.0.1 - unset-value: 1.0.0 - - cacheable-lookup@5.0.4: - optional: true - cacheable-lookup@7.0.0: {} cacheable-request@10.2.14: @@ -19375,33 +16544,6 @@ snapshots: normalize-url: 8.1.0 responselike: 3.0.0 - cacheable-request@6.1.0: - dependencies: - clone-response: 1.0.3 - get-stream: 5.2.0 - http-cache-semantics: 4.2.0 - keyv: 3.1.0 - lowercase-keys: 2.0.0 - normalize-url: 4.5.1 - responselike: 1.0.2 - optional: true - - cacheable-request@7.0.4: - dependencies: - clone-response: 1.0.3 - get-stream: 5.2.0 - http-cache-semantics: 4.2.0 - keyv: 4.5.4 - lowercase-keys: 2.0.0 - normalize-url: 6.1.0 - responselike: 2.0.1 - optional: true - - cachedown@1.0.0: - dependencies: - abstract-leveldown: 2.7.2 - lru-cache: 3.2.0 - call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -19438,8 +16580,6 @@ snapshots: camelcase@3.0.0: {} - camelcase@4.1.0: {} - camelcase@5.3.1: {} camelcase@6.3.0: {} @@ -19501,14 +16641,6 @@ snapshots: loupe: 3.2.1 pathval: 2.0.1 - chalk@1.1.3: - dependencies: - ansi-styles: 2.2.1 - escape-string-regexp: 1.0.5 - has-ansi: 2.0.0 - strip-ansi: 3.0.1 - supports-color: 2.0.0 - chalk@2.4.2: dependencies: ansi-styles: 3.2.1 @@ -19583,25 +16715,6 @@ snapshots: check-error@2.1.3: {} - checkpoint-store@1.1.0: - dependencies: - functional-red-black-tree: 1.0.1 - - chokidar@1.7.0: - dependencies: - anymatch: 1.3.2 - async-each: 1.0.6 - glob-parent: 2.0.0 - inherits: 2.0.4 - is-binary-path: 1.0.1 - is-glob: 2.0.1 - path-is-absolute: 1.0.1 - readdirp: 2.2.1 - optionalDependencies: - fsevents: 1.2.13 - transitivePeerDependencies: - - supports-color - chokidar@3.6.0: dependencies: anymatch: 3.1.3 @@ -19651,30 +16764,11 @@ snapshots: ci-info@3.9.0: {} - cids@0.7.5: - dependencies: - buffer: 5.7.1 - class-is: 1.1.0 - multibase: 0.6.1 - multicodec: 1.0.4 - multihashes: 0.4.21 - optional: true - cipher-base@1.0.6: dependencies: inherits: 2.0.4 safe-buffer: 5.2.1 - class-is@1.1.0: - optional: true - - class-utils@0.3.6: - dependencies: - arr-union: 3.1.0 - define-property: 0.2.5 - isobject: 3.0.1 - static-extend: 0.1.2 - clean-stack@2.2.0: {} cli-boxes@2.2.1: {} @@ -19700,16 +16794,6 @@ snapshots: optionalDependencies: '@colors/colors': 1.5.0 - cli-truncate@2.1.0: - dependencies: - slice-ansi: 3.0.0 - string-width: 4.2.3 - - cli-truncate@3.1.0: - dependencies: - slice-ansi: 5.0.0 - string-width: 5.1.2 - cli-truncate@5.0.0: dependencies: slice-ansi: 7.1.2 @@ -19723,12 +16807,6 @@ snapshots: strip-ansi: 3.0.1 wrap-ansi: 2.1.0 - cliui@4.1.0: - dependencies: - string-width: 2.1.1 - strip-ansi: 4.0.0 - wrap-ansi: 2.1.0 - cliui@6.0.0: dependencies: string-width: 4.2.3 @@ -19747,24 +16825,10 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 - clone-response@1.0.3: - dependencies: - mimic-response: 1.0.1 - optional: true - - clone@2.1.2: {} - - co@4.6.0: {} - code-point-at@1.1.0: {} coingecko-api@1.0.10: {} - collection-visit@1.0.0: - dependencies: - map-visit: 1.0.0 - object-visit: 1.0.1 - color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -19802,12 +16866,6 @@ snapshots: command-exists@1.2.9: {} - command-line-args@4.0.7: - dependencies: - array-back: 2.0.0 - find-replace: 1.0.3 - typical: 2.6.1 - command-line-args@5.2.1: dependencies: array-back: 3.1.0 @@ -19830,12 +16888,8 @@ snapshots: commander@14.0.2: {} - commander@2.11.0: {} - commander@2.20.3: {} - commander@3.0.2: {} - commander@8.3.0: {} commander@9.5.0: {} @@ -19849,8 +16903,6 @@ snapshots: compare-versions@6.1.1: {} - component-emitter@1.3.1: {} - concat-map@0.0.1: {} concat-stream@1.6.2: @@ -19893,13 +16945,6 @@ snapshots: dependencies: safe-buffer: 5.2.1 - content-hash@2.5.2: - dependencies: - cids: 0.7.5 - multicodec: 0.5.7 - multihashes: 0.4.21 - optional: true - content-type@1.0.5: {} conventional-changelog-angular@7.0.0: @@ -19917,8 +16962,6 @@ snapshots: meow: 12.1.1 split2: 4.2.0 - convert-source-map@1.9.0: {} - convert-source-map@2.0.0: {} cookie-signature@1.0.6: {} @@ -19927,18 +16970,8 @@ snapshots: cookie@0.5.0: {} - cookie@0.7.1: - optional: true - - cookiejar@2.1.4: - optional: true - - copy-descriptor@0.1.1: {} - core-js-pure@3.45.1: {} - core-js@2.6.12: {} - core-util-is@1.0.2: {} core-util-is@1.0.3: {} @@ -19982,12 +17015,6 @@ snapshots: crc-32@1.2.2: {} - create-ecdh@4.0.4: - dependencies: - bn.js: 4.12.2 - elliptic: 6.6.1 - optional: true - create-hash@1.1.3: dependencies: cipher-base: 1.0.6 @@ -20014,13 +17041,6 @@ snapshots: create-require@1.1.1: {} - cross-fetch@2.2.6(encoding@0.1.13): - dependencies: - node-fetch: 2.7.0(encoding@0.1.13) - whatwg-fetch: 2.0.4 - transitivePeerDependencies: - - encoding - cross-fetch@3.1.5(encoding@0.1.13): dependencies: node-fetch: 2.6.7(encoding@0.1.13) @@ -20043,20 +17063,6 @@ snapshots: dependencies: tslib: 2.8.1 - cross-spawn@5.1.0: - dependencies: - lru-cache: 4.1.5 - shebang-command: 1.2.0 - which: 1.3.1 - - cross-spawn@6.0.6: - dependencies: - nice-try: 1.0.5 - path-key: 2.0.1 - semver: 5.7.2 - shebang-command: 1.2.0 - which: 1.3.1 - cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -20065,26 +17071,6 @@ snapshots: crypt@0.0.2: {} - crypto-browserify@3.12.0: - dependencies: - browserify-cipher: 1.0.1 - browserify-sign: 4.2.3 - create-ecdh: 4.0.4 - create-hash: 1.2.0 - create-hmac: 1.1.7 - diffie-hellman: 5.0.3 - inherits: 2.0.4 - pbkdf2: 3.1.3 - public-encrypt: 4.0.3 - randombytes: 2.1.0 - randomfill: 1.0.4 - optional: true - - d@1.0.2: - dependencies: - es5-ext: 0.10.64 - type: 2.7.3 - dargs@8.1.0: {} dashdash@1.14.1: @@ -20121,16 +17107,6 @@ snapshots: dependencies: ms: 2.0.0 - debug@3.1.0(supports-color@4.4.0): - dependencies: - ms: 2.0.0 - optionalDependencies: - supports-color: 4.4.0 - - debug@3.2.6: - dependencies: - ms: 2.1.3 - debug@3.2.7: dependencies: ms: 2.1.3 @@ -20141,12 +17117,6 @@ snapshots: optionalDependencies: supports-color: 8.1.1 - debug@4.4.3(supports-color@9.4.0): - dependencies: - ms: 2.1.3 - optionalDependencies: - supports-color: 9.4.0 - decamelize@1.2.0: {} decamelize@4.0.0: {} @@ -20155,13 +17125,6 @@ snapshots: dependencies: character-entities: 2.0.2 - decode-uri-component@0.2.2: {} - - decompress-response@3.3.0: - dependencies: - mimic-response: 1.0.1 - optional: true - decompress-response@4.2.1: dependencies: mimic-response: 2.1.0 @@ -20179,33 +17142,12 @@ snapshots: deep-eql@5.0.2: {} - deep-equal@1.1.2: - dependencies: - is-arguments: 1.2.0 - is-date-object: 1.1.0 - is-regex: 1.2.1 - object-is: 1.1.6 - object-keys: 1.1.1 - regexp.prototype.flags: 1.5.4 - deep-extend@0.6.0: {} deep-is@0.1.4: {} - defer-to-connect@1.1.3: - optional: true - defer-to-connect@2.0.1: {} - deferred-leveldown@1.2.2: - dependencies: - abstract-leveldown: 2.6.3 - - deferred-leveldown@4.0.2: - dependencies: - abstract-leveldown: 5.0.0 - inherits: 2.0.4 - deferred-leveldown@5.3.0: dependencies: abstract-leveldown: 6.2.3 @@ -20225,21 +17167,6 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 - define-property@0.2.5: - dependencies: - is-descriptor: 0.1.7 - - define-property@1.0.0: - dependencies: - is-descriptor: 1.0.3 - - define-property@2.0.2: - dependencies: - is-descriptor: 1.0.3 - isobject: 3.0.1 - - defined@1.0.1: {} - delayed-stream@1.0.0: {} delegates@1.0.0: @@ -20260,20 +17187,10 @@ snapshots: dequal@2.0.3: {} - des.js@1.1.0: - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - optional: true - destroy@1.0.4: {} destroy@1.2.0: {} - detect-indent@4.0.0: - dependencies: - repeating: 2.0.1 - detect-indent@6.1.0: {} detect-libc@1.0.3: @@ -20283,21 +17200,10 @@ snapshots: dependencies: dequal: 2.0.3 - diff@3.3.1: {} - - diff@3.5.0: {} - diff@4.0.2: {} diff@5.2.0: {} - diffie-hellman@5.0.3: - dependencies: - bn.js: 4.12.2 - miller-rabin: 4.0.1 - randombytes: 2.1.0 - optional: true - difflib@0.2.4: dependencies: heap: 0.2.7 @@ -20315,8 +17221,6 @@ snapshots: dependencies: esutils: 2.0.3 - dom-walk@0.1.2: {} - dot-case@3.0.4: dependencies: no-case: 3.0.4 @@ -20330,10 +17234,6 @@ snapshots: dotenv@16.6.1: {} - dotignore@0.1.2: - dependencies: - minimatch: 3.1.2 - dottie@2.0.6: {} dset@3.1.4: {} @@ -20344,9 +17244,6 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - duplexer3@0.1.5: - optional: true - duplexify@4.1.3: dependencies: end-of-stream: 1.4.5 @@ -20408,14 +17305,6 @@ snapshots: encodeurl@2.0.0: {} - encoding-down@5.0.4: - dependencies: - abstract-leveldown: 5.0.0 - inherits: 2.0.4 - level-codec: 9.0.2 - level-errors: 2.0.1 - xtend: 4.0.2 - encoding-down@6.3.0: dependencies: abstract-leveldown: 6.3.0 @@ -20426,6 +17315,7 @@ snapshots: encoding@0.1.13: dependencies: iconv-lite: 0.6.3 + optional: true end-of-stream@1.4.5: dependencies: @@ -20442,8 +17332,6 @@ snapshots: environment@1.1.0: {} - eol@0.9.1: {} - err-code@2.0.3: {} errno@0.1.8: @@ -20515,8 +17403,6 @@ snapshots: unbox-primitive: 1.1.0 which-typed-array: 1.1.19 - es-array-method-boxes-properly@1.0.0: {} - es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -20542,24 +17428,6 @@ snapshots: is-date-object: 1.1.0 is-symbol: 1.1.1 - es5-ext@0.10.64: - dependencies: - es6-iterator: 2.0.3 - es6-symbol: 3.1.4 - esniff: 2.0.1 - next-tick: 1.1.0 - - es6-iterator@2.0.3: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-symbol: 3.1.4 - - es6-symbol@3.1.4: - dependencies: - d: 1.0.2 - ext: 1.7.0 - esbuild@0.25.9: optionalDependencies: '@esbuild/aix-ppc64': 0.25.9 @@ -20726,7 +17594,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1 @@ -20750,13 +17618,6 @@ snapshots: transitivePeerDependencies: - supports-color - esniff@2.0.1: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - event-emitter: 0.3.5 - type: 2.7.3 - espree@10.4.0: dependencies: acorn: 8.15.0 @@ -20783,18 +17644,6 @@ snapshots: etag@1.8.1: {} - eth-block-tracker@3.0.1: - dependencies: - eth-query: 2.1.2 - ethereumjs-tx: 1.3.7 - ethereumjs-util: 5.2.1 - ethjs-util: 0.1.6 - json-rpc-engine: 3.8.0 - pify: 2.3.0 - tape: 4.17.0 - transitivePeerDependencies: - - supports-color - eth-ens-namehash@2.0.8: dependencies: idna-uts46-hx: 2.3.1 @@ -20820,102 +17669,10 @@ snapshots: - debug - utf-8-validate - eth-json-rpc-infura@3.2.1(encoding@0.1.13): - dependencies: - cross-fetch: 2.2.6(encoding@0.1.13) - eth-json-rpc-middleware: 1.6.0 - json-rpc-engine: 3.8.0 - json-rpc-error: 2.0.0 - transitivePeerDependencies: - - encoding - - supports-color - - eth-json-rpc-middleware@1.6.0: - dependencies: - async: 2.6.4 - eth-query: 2.1.2 - eth-tx-summary: 3.2.4 - ethereumjs-block: 1.7.1 - ethereumjs-tx: 1.3.7 - ethereumjs-util: 5.2.1 - ethereumjs-vm: 2.6.0 - fetch-ponyfill: 4.1.0 - json-rpc-engine: 3.8.0 - json-rpc-error: 2.0.0 - json-stable-stringify: 1.3.0 - promise-to-callback: 1.0.0 - tape: 4.17.0 - transitivePeerDependencies: - - supports-color - - eth-lib@0.1.29(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - bn.js: 4.12.2 - elliptic: 6.6.1 - nano-json-stream-parser: 0.1.2 - servify: 0.1.12 - ws: 3.3.3(bufferutil@4.0.9)(utf-8-validate@5.0.10) - xhr-request-promise: 0.1.3 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - optional: true - - eth-lib@0.2.8: - dependencies: - bn.js: 4.12.2 - elliptic: 6.6.1 - xhr-request-promise: 0.1.3 - optional: true - - eth-query@2.1.2: - dependencies: - json-rpc-random-id: 1.0.1 - xtend: 4.0.2 - - eth-sig-util@1.4.2: - dependencies: - ethereumjs-abi: https://codeload.github.com/ethereumjs/ethereumjs-abi/tar.gz/ee3994657fa7a427238e6ba92a84d0b529bbcde0 - ethereumjs-util: 5.2.1 - - eth-sig-util@3.0.0: - dependencies: - buffer: 5.7.1 - elliptic: 6.6.1 - ethereumjs-abi: 0.6.5 - ethereumjs-util: 5.2.1 - tweetnacl: 1.0.3 - tweetnacl-util: 0.15.1 - - eth-tx-summary@3.2.4: - dependencies: - async: 2.6.4 - clone: 2.1.2 - concat-stream: 1.6.2 - end-of-stream: 1.4.5 - eth-query: 2.1.2 - ethereumjs-block: 1.7.1 - ethereumjs-tx: 1.3.7 - ethereumjs-util: 5.2.1 - ethereumjs-vm: 2.6.0 - through2: 2.0.5 - - ethashjs@0.0.8: - dependencies: - async: 2.6.4 - buffer-xor: 2.0.2 - ethereumjs-util: 7.1.5 - miller-rabin: 4.0.1 - ethereum-bloom-filters@1.2.0: dependencies: '@noble/hashes': 1.8.0 - ethereum-common@0.0.18: {} - - ethereum-common@0.2.0: {} - ethereum-cryptography@0.1.3: dependencies: '@types/pbkdf2': 3.1.2 @@ -20948,20 +17705,6 @@ snapshots: '@scure/bip32': 1.4.0 '@scure/bip39': 1.3.0 - ethereum-waffle@3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(typescript@5.9.3)(utf-8-validate@5.0.10): - dependencies: - '@ethereum-waffle/chai': 3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) - '@ethereum-waffle/compiler': 3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(typescript@5.9.3)(utf-8-validate@5.0.10) - '@ethereum-waffle/mock-contract': 3.4.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@ethereum-waffle/provider': 3.4.4(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) - ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - typescript - - utf-8-validate - ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.8.0)(@ethersproject/providers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(encoding@0.1.13)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.9.3): dependencies: '@ethereum-waffle/chai': 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) @@ -20981,92 +17724,11 @@ snapshots: - supports-color - typescript - ethereumjs-abi@0.6.5: - dependencies: - bn.js: 4.12.2 - ethereumjs-util: 4.5.1 - ethereumjs-abi@0.6.8: dependencies: bn.js: 4.12.2 ethereumjs-util: 6.2.1 - ethereumjs-abi@https://codeload.github.com/ethereumjs/ethereumjs-abi/tar.gz/ee3994657fa7a427238e6ba92a84d0b529bbcde0: - dependencies: - bn.js: 4.12.2 - ethereumjs-util: 6.2.1 - - ethereumjs-account@2.0.5: - dependencies: - ethereumjs-util: 5.2.1 - rlp: 2.2.7 - safe-buffer: 5.2.1 - - ethereumjs-account@3.0.0: - dependencies: - ethereumjs-util: 6.2.1 - rlp: 2.2.7 - safe-buffer: 5.2.1 - - ethereumjs-block@1.7.1: - dependencies: - async: 2.6.4 - ethereum-common: 0.2.0 - ethereumjs-tx: 1.3.7 - ethereumjs-util: 5.2.1 - merkle-patricia-tree: 2.3.2 - - ethereumjs-block@2.2.2: - dependencies: - async: 2.6.4 - ethereumjs-common: 1.5.0 - ethereumjs-tx: 2.1.2 - ethereumjs-util: 5.2.1 - merkle-patricia-tree: 2.3.2 - - ethereumjs-blockchain@4.0.4: - dependencies: - async: 2.6.4 - ethashjs: 0.0.8 - ethereumjs-block: 2.2.2 - ethereumjs-common: 1.5.0 - ethereumjs-util: 6.2.1 - flow-stoplight: 1.0.0 - level-mem: 3.0.1 - lru-cache: 5.1.1 - rlp: 2.2.7 - semaphore: 1.1.0 - - ethereumjs-common@1.5.0: {} - - ethereumjs-tx@1.3.7: - dependencies: - ethereum-common: 0.0.18 - ethereumjs-util: 5.2.1 - - ethereumjs-tx@2.1.2: - dependencies: - ethereumjs-common: 1.5.0 - ethereumjs-util: 6.2.1 - - ethereumjs-util@4.5.1: - dependencies: - bn.js: 4.12.2 - create-hash: 1.2.0 - elliptic: 6.6.1 - ethereum-cryptography: 0.1.3 - rlp: 2.2.7 - - ethereumjs-util@5.2.1: - dependencies: - bn.js: 4.12.2 - create-hash: 1.2.0 - elliptic: 6.6.1 - ethereum-cryptography: 0.1.3 - ethjs-util: 0.1.6 - rlp: 2.2.7 - safe-buffer: 5.2.1 - ethereumjs-util@6.2.1: dependencies: '@types/bn.js': 4.11.6 @@ -21093,51 +17755,6 @@ snapshots: ethereum-cryptography: 0.1.3 rlp: 2.2.7 - ethereumjs-vm@2.6.0: - dependencies: - async: 2.6.4 - async-eventemitter: 0.2.4 - ethereumjs-account: 2.0.5 - ethereumjs-block: 2.2.2 - ethereumjs-common: 1.5.0 - ethereumjs-util: 6.2.1 - fake-merkle-patricia-tree: 1.0.1 - functional-red-black-tree: 1.0.1 - merkle-patricia-tree: 2.3.2 - rustbn.js: 0.2.0 - safe-buffer: 5.2.1 - - ethereumjs-vm@4.2.0: - dependencies: - async: 2.6.4 - async-eventemitter: 0.2.4 - core-js-pure: 3.45.1 - ethereumjs-account: 3.0.0 - ethereumjs-block: 2.2.2 - ethereumjs-blockchain: 4.0.4 - ethereumjs-common: 1.5.0 - ethereumjs-tx: 2.1.2 - ethereumjs-util: 6.2.1 - fake-merkle-patricia-tree: 1.0.1 - functional-red-black-tree: 1.0.1 - merkle-patricia-tree: 2.3.2 - rustbn.js: 0.2.0 - safe-buffer: 5.2.1 - util.promisify: 1.1.3 - - ethereumjs-wallet@0.6.5: - dependencies: - aes-js: 3.1.2 - bs58check: 2.1.2 - ethereum-cryptography: 0.1.3 - ethereumjs-util: 6.2.1 - randombytes: 2.1.0 - safe-buffer: 5.2.1 - scryptsy: 1.2.1 - utf8: 3.0.0 - uuid: 3.4.0 - optional: true - ethers@5.6.2(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: '@ethersproject/abi': 5.6.0 @@ -21318,35 +17935,8 @@ snapshots: is-hex-prefixed: 1.0.0 strip-hex-prefix: 1.0.0 - ethlint@1.2.5(solium@1.2.5): - dependencies: - ajv: 5.5.2 - chokidar: 1.7.0 - colors: 1.4.0 - commander: 2.20.3 - diff: 3.5.0 - eol: 0.9.1 - js-string-escape: 1.0.1 - lodash: 4.17.21 - sol-digger: 0.0.2 - sol-explore: 1.6.1 - solium-plugin-security: 0.1.1(solium@1.2.5) - solparse: 2.2.8 - text-table: 0.2.0 - transitivePeerDependencies: - - solium - - supports-color - - event-emitter@0.3.5: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - event-target-shim@5.0.1: {} - eventemitter3@4.0.4: - optional: true - eventemitter3@4.0.7: {} eventemitter3@5.0.1: {} @@ -21358,48 +17948,6 @@ snapshots: md5.js: 1.3.5 safe-buffer: 5.2.1 - execa@0.7.0: - dependencies: - cross-spawn: 5.1.0 - get-stream: 3.0.0 - is-stream: 1.1.0 - npm-run-path: 2.0.2 - p-finally: 1.0.0 - signal-exit: 3.0.7 - strip-eof: 1.0.0 - - execa@5.1.1: - dependencies: - cross-spawn: 7.0.6 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - - expand-brackets@0.1.5: - dependencies: - is-posix-bracket: 0.1.1 - - expand-brackets@2.1.4: - dependencies: - debug: 2.6.9 - define-property: 0.2.5 - extend-shallow: 2.0.1 - posix-character-classes: 0.1.1 - regex-not: 1.0.2 - snapdragon: 0.8.2 - to-regex: 3.0.2 - transitivePeerDependencies: - - supports-color - - expand-range@1.8.2: - dependencies: - fill-range: 2.2.4 - expand-template@2.0.3: optional: true @@ -21476,56 +18024,6 @@ snapshots: transitivePeerDependencies: - supports-color - express@4.21.2: - dependencies: - accepts: 1.3.8 - array-flatten: 1.1.1 - body-parser: 1.20.3 - content-disposition: 0.5.4 - content-type: 1.0.5 - cookie: 0.7.1 - cookie-signature: 1.0.6 - debug: 2.6.9 - depd: 2.0.0 - encodeurl: 2.0.0 - escape-html: 1.0.3 - etag: 1.8.1 - finalhandler: 1.3.1 - fresh: 0.5.2 - http-errors: 2.0.0 - merge-descriptors: 1.0.3 - methods: 1.1.2 - on-finished: 2.4.1 - parseurl: 1.3.3 - path-to-regexp: 0.1.12 - proxy-addr: 2.0.7 - qs: 6.13.0 - range-parser: 1.2.1 - safe-buffer: 5.2.1 - send: 0.19.0 - serve-static: 1.16.2 - setprototypeof: 1.2.0 - statuses: 2.0.1 - type-is: 1.6.18 - utils-merge: 1.0.1 - vary: 1.1.2 - transitivePeerDependencies: - - supports-color - optional: true - - ext@1.7.0: - dependencies: - type: 2.7.3 - - extend-shallow@2.0.1: - dependencies: - is-extendable: 0.1.1 - - extend-shallow@3.0.2: - dependencies: - assign-symbols: 1.0.0 - is-extendable: 1.0.1 - extend@3.0.2: {} extendable-error@0.1.7: {} @@ -21536,37 +18034,14 @@ snapshots: iconv-lite: 0.4.24 tmp: 0.0.33 - extglob@0.3.2: - dependencies: - is-extglob: 1.0.0 - - extglob@2.0.4: - dependencies: - array-unique: 0.3.2 - define-property: 1.0.0 - expand-brackets: 2.1.4 - extend-shallow: 2.0.1 - fragment-cache: 0.2.1 - regex-not: 1.0.2 - snapdragon: 0.8.2 - to-regex: 3.0.2 - transitivePeerDependencies: - - supports-color - extract-files@11.0.0: {} extsprintf@1.3.0: {} - fake-merkle-patricia-tree@1.0.1: - dependencies: - checkpoint-store: 1.1.0 - fast-base64-decode@1.0.0: {} fast-decode-uri-component@1.0.1: {} - fast-deep-equal@1.1.0: {} - fast-deep-equal@3.1.3: {} fast-diff@1.3.0: {} @@ -21635,10 +18110,6 @@ snapshots: fecha@4.2.3: {} - fetch-ponyfill@4.1.0: - dependencies: - node-fetch: 1.7.3 - fets@0.1.5: dependencies: '@ardatan/fast-json-stringify': 0.0.6(ajv-formats@2.1.1(ajv@8.17.1))(ajv@8.17.1) @@ -21665,23 +18136,6 @@ snapshots: file-uri-to-path@1.0.0: optional: true - filename-regex@2.0.1: {} - - fill-range@2.2.4: - dependencies: - is-number: 2.1.0 - isobject: 2.1.0 - randomatic: 3.1.1 - repeat-element: 1.1.4 - repeat-string: 1.6.1 - - fill-range@4.0.0: - dependencies: - extend-shallow: 2.0.1 - is-number: 3.0.0 - repeat-string: 1.6.1 - to-regex-range: 2.1.1 - fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -21710,24 +18164,6 @@ snapshots: transitivePeerDependencies: - supports-color - finalhandler@1.3.1: - dependencies: - debug: 2.6.9 - encodeurl: 2.0.0 - escape-html: 1.0.3 - on-finished: 2.4.1 - parseurl: 1.3.3 - statuses: 2.0.1 - unpipe: 1.0.0 - transitivePeerDependencies: - - supports-color - optional: true - - find-replace@1.0.3: - dependencies: - array-back: 1.0.4 - test-value: 2.1.0 - find-replace@3.0.0: dependencies: array-back: 3.1.0 @@ -21737,10 +18173,6 @@ snapshots: path-exists: 2.1.0 pinkie-promise: 2.0.1 - find-up@2.1.0: - dependencies: - locate-path: 2.0.0 - find-up@4.1.0: dependencies: locate-path: 5.0.0 @@ -21757,17 +18189,6 @@ snapshots: path-exists: 5.0.0 unicorn-magic: 0.1.0 - find-yarn-workspace-root@1.2.1: - dependencies: - fs-extra: 4.0.3 - micromatch: 3.1.10 - transitivePeerDependencies: - - supports-color - - find-yarn-workspace-root@2.0.0: - dependencies: - micromatch: 4.0.8 - flat-cache@4.0.1: dependencies: flatted: 3.3.3 @@ -21779,8 +18200,6 @@ snapshots: flow-enums-runtime@0.0.6: {} - flow-stoplight@1.0.0: {} - fmix@0.1.0: dependencies: imul: 1.0.1 @@ -21789,18 +18208,12 @@ snapshots: follow-redirects@1.15.11(debug@4.4.3): optionalDependencies: - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) for-each@0.3.5: dependencies: is-callable: 1.2.7 - for-in@1.0.2: {} - - for-own@0.1.5: - dependencies: - for-in: 1.0.2 - foreach@2.0.6: {} foreground-child@3.3.1: @@ -21849,10 +18262,6 @@ snapshots: fp-ts@1.19.3: {} - fragment-cache@0.2.1: - dependencies: - map-cache: 0.2.2 - fresh@0.5.2: {} fs-constants@1.0.0: @@ -21878,12 +18287,6 @@ snapshots: jsonfile: 6.2.0 universalify: 2.0.1 - fs-extra@4.0.3: - dependencies: - graceful-fs: 4.2.11 - jsonfile: 4.0.0 - universalify: 0.1.2 - fs-extra@7.0.1: dependencies: graceful-fs: 4.2.11 @@ -21903,11 +18306,6 @@ snapshots: jsonfile: 6.2.0 universalify: 2.0.1 - fs-minipass@1.2.7: - dependencies: - minipass: 2.9.0 - optional: true - fs-minipass@2.1.0: dependencies: minipass: 3.3.6 @@ -21920,12 +18318,6 @@ snapshots: fs.realpath@1.0.0: {} - fsevents@1.2.13: - dependencies: - bindings: 1.5.0 - nan: 2.23.0 - optional: true - fsevents@2.3.3: optional: true @@ -21944,44 +18336,6 @@ snapshots: functions-have-names@1.2.3: {} - ganache-core@2.13.2(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10): - dependencies: - abstract-leveldown: 3.0.0 - async: 2.6.2 - bip39: 2.5.0 - cachedown: 1.0.0 - clone: 2.1.2 - debug: 3.2.6 - encoding-down: 5.0.4 - eth-sig-util: 3.0.0 - ethereumjs-abi: 0.6.8 - ethereumjs-account: 3.0.0 - ethereumjs-block: 2.2.2 - ethereumjs-common: 1.5.0 - ethereumjs-tx: 2.1.2 - ethereumjs-util: 6.2.1 - ethereumjs-vm: 4.2.0 - heap: 0.2.6 - level-sublevel: 6.6.4 - levelup: 3.1.1 - lodash: 4.17.20 - lru-cache: 5.1.1 - merkle-patricia-tree: 3.0.0 - patch-package: 6.2.2 - seedrandom: 3.0.1 - source-map-support: 0.5.12 - tmp: 0.1.0 - web3-provider-engine: 14.2.1(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) - websocket: 1.0.32 - optionalDependencies: - ethereumjs-wallet: 0.6.5 - web3: 1.2.11(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - utf-8-validate - ganache@7.4.3: optionalDependencies: bufferutil: 4.0.5 @@ -22031,18 +18385,6 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 - get-stream@3.0.0: {} - - get-stream@4.1.0: - dependencies: - pump: 3.0.3 - optional: true - - get-stream@5.2.0: - dependencies: - pump: 3.0.3 - optional: true - get-stream@6.0.1: {} get-symbol-description@1.1.0: @@ -22055,8 +18397,6 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - get-value@2.0.6: {} - getpass@0.1.7: dependencies: assert-plus: 1.0.0 @@ -22075,15 +18415,6 @@ snapshots: github-from-package@0.0.0: optional: true - glob-base@0.3.0: - dependencies: - glob-parent: 2.0.0 - is-glob: 2.0.1 - - glob-parent@2.0.0: - dependencies: - is-glob: 2.0.1 - glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -22118,15 +18449,6 @@ snapshots: once: 1.4.0 path-is-absolute: 1.0.1 - glob@7.1.2: - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - glob@7.1.7: dependencies: fs.realpath: 1.0.0 @@ -22167,17 +18489,10 @@ snapshots: kind-of: 6.0.3 which: 1.3.1 - global@4.4.0: - dependencies: - min-document: 2.19.0 - process: 0.11.10 - globals@14.0.0: {} globals@16.4.0: {} - globals@9.18.0: {} - globalthis@1.0.4: dependencies: define-properties: 1.2.1 @@ -22205,21 +18520,6 @@ snapshots: gopd@1.2.0: {} - got@11.8.6: - dependencies: - '@sindresorhus/is': 4.6.0 - '@szmarczak/http-timer': 4.0.6 - '@types/cacheable-request': 6.0.3 - '@types/responselike': 1.0.3 - cacheable-lookup: 5.0.4 - cacheable-request: 7.0.4 - decompress-response: 6.0.0 - http2-wrapper: 1.0.3 - lowercase-keys: 2.0.0 - p-cancelable: 2.1.1 - responselike: 2.0.1 - optional: true - got@12.6.1: dependencies: '@sindresorhus/is': 5.6.0 @@ -22234,23 +18534,6 @@ snapshots: p-cancelable: 3.0.0 responselike: 3.0.0 - got@9.6.0: - dependencies: - '@sindresorhus/is': 0.14.0 - '@szmarczak/http-timer': 1.1.2 - '@types/keyv': 3.1.4 - '@types/responselike': 1.0.3 - cacheable-request: 6.1.0 - decompress-response: 3.3.0 - duplexer3: 0.1.5 - get-stream: 4.1.0 - lowercase-keys: 1.0.1 - mimic-response: 1.0.1 - p-cancelable: 1.1.0 - to-readable-stream: 1.0.0 - url-parse-lax: 3.0.0 - optional: true - graceful-fs@4.2.10: {} graceful-fs@4.2.11: {} @@ -22321,8 +18604,6 @@ snapshots: graphql@16.8.0: {} - growl@1.10.3: {} - handlebars@4.7.8: dependencies: minimist: 1.2.8 @@ -22369,7 +18650,7 @@ snapshots: axios: 0.21.4(debug@4.4.3) chalk: 4.1.2 chokidar: 3.6.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) form-data: 4.0.4 @@ -22400,7 +18681,7 @@ snapshots: axios: 0.21.4(debug@4.4.3) chalk: 4.1.2 chokidar: 3.6.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) form-data: 3.0.4 fs-extra: 9.1.0 hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) @@ -22412,12 +18693,12 @@ snapshots: - supports-color - utf-8-validate - hardhat-deploy@2.0.0-next.61(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(hardhat@3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10)): + hardhat-deploy@2.0.0-next.61(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(hardhat@3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10)): dependencies: '@nomicfoundation/hardhat-zod-utils': 3.0.1(zod@3.25.76) - '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) + '@rocketh/node': 0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@types/debug': 4.1.12 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) hardhat: 3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10) named-logs-console: 0.5.1 slash: 5.1.0 @@ -22446,7 +18727,7 @@ snapshots: hardhat-secure-accounts@0.0.6(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)): dependencies: '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 ethers: 5.8.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) @@ -22458,7 +18739,7 @@ snapshots: hardhat-secure-accounts@1.0.5(@nomicfoundation/hardhat-ethers@3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)): dependencies: '@nomicfoundation/hardhat-ethers': 3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) @@ -22470,7 +18751,7 @@ snapshots: hardhat-secure-accounts@1.0.5(@nomicfoundation/hardhat-ethers@3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)))(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)): dependencies: '@nomicfoundation/hardhat-ethers': 3.1.0(ethers@6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(hardhat@2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10)) - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 ethers: 6.16.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@8.10.2(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) @@ -22497,7 +18778,7 @@ snapshots: boxen: 5.1.2 chokidar: 4.0.3 ci-info: 2.0.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 env-paths: 2.2.1 ethereum-cryptography: 1.2.0 @@ -22546,7 +18827,7 @@ snapshots: boxen: 5.1.2 chokidar: 4.0.3 ci-info: 2.0.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 env-paths: 2.2.1 ethereum-cryptography: 1.2.0 @@ -22594,7 +18875,7 @@ snapshots: adm-zip: 0.4.16 chalk: 5.6.2 chokidar: 4.0.3 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) enquirer: 2.4.1 ethereum-cryptography: 2.2.1 micro-eth-signer: 0.14.0 @@ -22609,16 +18890,10 @@ snapshots: - supports-color - utf-8-validate - has-ansi@2.0.0: - dependencies: - ansi-regex: 2.1.1 - has-bigints@1.1.0: {} has-flag@1.0.0: {} - has-flag@2.0.0: {} - has-flag@3.0.0: {} has-flag@4.0.0: {} @@ -22640,37 +18915,10 @@ snapshots: has-unicode@2.0.1: optional: true - has-value@0.3.1: - dependencies: - get-value: 2.0.6 - has-values: 0.1.4 - isobject: 2.1.0 - - has-value@1.0.0: - dependencies: - get-value: 2.0.6 - has-values: 1.0.0 - isobject: 3.0.1 - - has-values@0.1.4: {} - - has-values@1.0.0: - dependencies: - is-number: 3.0.0 - kind-of: 4.0.0 - - has@1.0.4: {} - hash-base@2.0.2: dependencies: inherits: 2.0.4 - hash-base@3.0.5: - dependencies: - inherits: 2.0.4 - safe-buffer: 5.2.1 - optional: true - hash-base@3.1.0: dependencies: inherits: 2.0.4 @@ -22688,8 +18936,6 @@ snapshots: dependencies: function-bind: 1.1.2 - he@1.1.1: {} - he@1.2.0: {} header-case@2.0.4: @@ -22697,8 +18943,6 @@ snapshots: capital-case: 1.0.4 tslib: 2.8.1 - heap@0.2.6: {} - heap@0.2.7: {} helmet@5.0.2: {} @@ -22717,11 +18961,6 @@ snapshots: minimalistic-assert: 1.0.1 minimalistic-crypto-utils: 1.0.1 - home-or-tmp@2.0.0: - dependencies: - os-homedir: 1.0.2 - os-tmpdir: 1.0.2 - hosted-git-info@2.8.9: {} hosted-git-info@7.0.2: @@ -22755,13 +18994,10 @@ snapshots: statuses: 2.0.1 toidentifier: 1.0.1 - http-https@1.0.0: - optional: true - http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.4 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -22775,12 +19011,6 @@ snapshots: jsprim: 1.4.2 sshpk: 1.18.0 - http2-wrapper@1.0.3: - dependencies: - quick-lru: 5.1.1 - resolve-alpn: 1.2.1 - optional: true - http2-wrapper@2.2.1: dependencies: quick-lru: 5.1.1 @@ -22789,23 +19019,19 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color https-proxy-agent@7.0.6: dependencies: agent-base: 7.1.4 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color human-id@4.1.1: {} - human-signals@2.1.0: {} - - husky@7.0.4: {} - husky@9.1.7: {} iconv-lite@0.4.24: @@ -22815,6 +19041,7 @@ snapshots: iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2 + optional: true iconv-lite@0.7.0: dependencies: @@ -22926,10 +19153,6 @@ snapshots: is-relative: 1.0.0 is-windows: 1.0.2 - is-accessor-descriptor@1.0.1: - dependencies: - hasown: 2.0.2 - is-alphabetical@2.0.1: {} is-alphanumerical@2.0.1: @@ -22937,11 +19160,6 @@ snapshots: is-alphabetical: 2.0.1 is-decimal: 2.0.1 - is-arguments@1.2.0: - dependencies: - call-bound: 1.0.4 - has-tostringtag: 1.0.2 - is-array-buffer@3.0.5: dependencies: call-bind: 1.0.8 @@ -22964,10 +19182,6 @@ snapshots: dependencies: has-bigints: 1.1.0 - is-binary-path@1.0.1: - dependencies: - binary-extensions: 1.13.1 - is-binary-path@2.1.0: dependencies: binary-extensions: 2.3.0 @@ -22977,22 +19191,12 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 - is-buffer@1.1.6: {} - is-callable@1.2.7: {} - is-ci@2.0.0: - dependencies: - ci-info: 2.0.0 - is-core-module@2.16.1: dependencies: hasown: 2.0.2 - is-data-descriptor@1.0.1: - dependencies: - hasown: 2.0.2 - is-data-view@1.0.2: dependencies: call-bound: 1.0.4 @@ -23006,44 +19210,16 @@ snapshots: is-decimal@2.0.1: {} - is-descriptor@0.1.7: - dependencies: - is-accessor-descriptor: 1.0.1 - is-data-descriptor: 1.0.1 - - is-descriptor@1.0.3: - dependencies: - is-accessor-descriptor: 1.0.1 - is-data-descriptor: 1.0.1 - is-directory@0.3.1: {} is-docker@2.2.1: {} - is-dotfile@1.0.3: {} - - is-equal-shallow@0.1.3: - dependencies: - is-primitive: 2.0.0 - - is-extendable@0.1.1: {} - - is-extendable@1.0.1: - dependencies: - is-plain-object: 2.0.4 - - is-extglob@1.0.0: {} - is-extglob@2.1.1: {} is-finalizationregistry@1.1.1: dependencies: call-bound: 1.0.4 - is-finite@1.1.0: {} - - is-fn@1.0.0: {} - is-fullwidth-code-point@1.0.0: dependencies: number-is-nan: 1.0.1 @@ -23052,14 +19228,10 @@ snapshots: is-fullwidth-code-point@3.0.0: {} - is-fullwidth-code-point@4.0.0: {} - is-fullwidth-code-point@5.1.0: dependencies: get-east-asian-width: 1.4.0 - is-function@1.0.2: {} - is-generator-function@1.1.0: dependencies: call-bound: 1.0.4 @@ -23067,10 +19239,6 @@ snapshots: has-tostringtag: 1.0.2 safe-regex-test: 1.1.0 - is-glob@2.0.1: - dependencies: - is-extglob: 1.0.0 - is-glob@4.0.3: dependencies: is-extglob: 2.1.1 @@ -23094,35 +19262,12 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 - is-number@2.1.0: - dependencies: - kind-of: 3.2.2 - - is-number@3.0.0: - dependencies: - kind-of: 3.2.2 - - is-number@4.0.0: {} - is-number@7.0.0: {} is-obj@2.0.0: {} is-plain-obj@2.1.0: {} - is-plain-object@2.0.4: - dependencies: - isobject: 3.0.1 - - is-posix-bracket@0.1.1: {} - - is-primitive@2.0.0: {} - - is-regex@1.1.4: - dependencies: - call-bind: 1.0.8 - has-tostringtag: 1.0.2 - is-regex@1.2.1: dependencies: call-bound: 1.0.4 @@ -23140,8 +19285,6 @@ snapshots: dependencies: call-bound: 1.0.4 - is-stream@1.1.0: {} - is-stream@2.0.1: {} is-string@1.1.1: @@ -23200,20 +19343,12 @@ snapshots: dependencies: is-docker: 2.2.1 - isarray@0.0.1: {} - isarray@1.0.0: {} isarray@2.0.5: {} isexe@2.0.0: {} - isobject@2.1.0: - dependencies: - isarray: 1.0.0 - - isobject@3.0.1: {} - isomorphic-unfetch@3.1.0(encoding@0.1.13): dependencies: node-fetch: 2.7.0(encoding@0.1.13) @@ -23337,10 +19472,6 @@ snapshots: js-sha3@0.8.0: {} - js-string-escape@1.0.1: {} - - js-tokens@3.0.2: {} - js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -23360,10 +19491,6 @@ snapshots: jsc-safe-url@0.2.4: {} - jsesc@0.5.0: {} - - jsesc@1.3.0: {} - jsesc@3.1.0: {} json-bigint-patch@0.0.8: {} @@ -23372,9 +19499,6 @@ snapshots: dependencies: bignumber.js: 9.3.1 - json-buffer@3.0.0: - optional: true - json-buffer@3.0.1: {} json-parse-better-errors@1.0.2: {} @@ -23385,31 +19509,12 @@ snapshots: dependencies: foreach: 2.0.6 - json-rpc-engine@3.8.0: - dependencies: - async: 2.6.4 - babel-preset-env: 1.7.0 - babelify: 7.3.0 - json-rpc-error: 2.0.0 - promise-to-callback: 1.0.0 - safe-event-emitter: 1.0.1 - transitivePeerDependencies: - - supports-color - - json-rpc-error@2.0.0: - dependencies: - inherits: 2.0.4 - - json-rpc-random-id@1.0.1: {} - json-schema-to-ts@2.12.0: dependencies: '@babel/runtime': 7.28.4 '@types/json-schema': 7.0.15 ts-algebra: 1.2.2 - json-schema-traverse@0.3.1: {} - json-schema-traverse@0.4.1: {} json-schema-traverse@1.0.0: {} @@ -23418,20 +19523,10 @@ snapshots: json-stable-stringify-without-jsonify@1.0.1: {} - json-stable-stringify@1.3.0: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.4 - isarray: 2.0.5 - jsonify: 0.0.1 - object-keys: 1.1.1 - json-stream-stringify@3.1.6: {} json-stringify-safe@5.0.1: {} - json5@0.5.1: {} - json5@1.0.2: dependencies: minimist: 1.2.8 @@ -23454,8 +19549,6 @@ snapshots: optionalDependencies: graceful-fs: 4.2.11 - jsonify@0.0.1: {} - jsonparse@1.3.1: {} jsonpointer@5.0.1: {} @@ -23484,29 +19577,12 @@ snapshots: node-gyp-build: 4.8.4 readable-stream: 3.6.2 - keyv@3.1.0: - dependencies: - json-buffer: 3.0.0 - optional: true - keyv@4.5.4: dependencies: json-buffer: 3.0.1 - kind-of@3.2.2: - dependencies: - is-buffer: 1.1.6 - - kind-of@4.0.0: - dependencies: - is-buffer: 1.1.6 - kind-of@6.0.3: {} - klaw-sync@6.0.0: - dependencies: - graceful-fs: 4.2.11 - klaw@1.3.1: optionalDependencies: graceful-fs: 4.2.11 @@ -23528,122 +19604,42 @@ snapshots: dotenv: 16.6.1 dotenv-expand: 10.0.0 - level-codec@7.0.1: {} - level-codec@9.0.2: dependencies: buffer: 5.7.1 level-concat-iterator@2.0.1: {} - level-errors@1.0.5: - dependencies: - errno: 0.1.8 - level-errors@2.0.1: dependencies: errno: 0.1.8 - level-iterator-stream@1.3.1: - dependencies: - inherits: 2.0.4 - level-errors: 1.0.5 - readable-stream: 1.1.14 - xtend: 4.0.2 - - level-iterator-stream@2.0.3: - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.8 - xtend: 4.0.2 - - level-iterator-stream@3.0.1: - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.8 - xtend: 4.0.2 - level-iterator-stream@4.0.2: dependencies: inherits: 2.0.4 readable-stream: 3.6.2 xtend: 4.0.2 - level-mem@3.0.1: - dependencies: - level-packager: 4.0.1 - memdown: 3.0.0 - level-mem@5.0.1: dependencies: level-packager: 5.1.1 memdown: 5.1.0 - level-packager@4.0.1: - dependencies: - encoding-down: 5.0.4 - levelup: 3.1.1 - level-packager@5.1.1: dependencies: encoding-down: 6.3.0 levelup: 4.4.0 - level-post@1.0.7: - dependencies: - ltgt: 2.1.3 - - level-sublevel@6.6.4: - dependencies: - bytewise: 1.1.0 - level-codec: 9.0.2 - level-errors: 2.0.1 - level-iterator-stream: 2.0.3 - ltgt: 2.1.3 - pull-defer: 0.2.3 - pull-level: 2.0.4 - pull-stream: 3.7.0 - typewiselite: 1.0.0 - xtend: 4.0.2 - level-supports@1.0.1: dependencies: xtend: 4.0.2 - level-ws@0.0.0: - dependencies: - readable-stream: 1.0.34 - xtend: 2.1.2 - - level-ws@1.0.0: - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.8 - xtend: 4.0.2 - level-ws@2.0.0: dependencies: inherits: 2.0.4 readable-stream: 3.6.2 xtend: 4.0.2 - levelup@1.3.9: - dependencies: - deferred-leveldown: 1.2.2 - level-codec: 7.0.1 - level-errors: 1.0.5 - level-iterator-stream: 1.3.1 - prr: 1.0.1 - semver: 5.4.1 - xtend: 4.0.2 - - levelup@3.1.1: - dependencies: - deferred-leveldown: 4.0.2 - level-errors: 2.0.1 - level-iterator-stream: 3.0.1 - xtend: 4.0.2 - levelup@4.4.0: dependencies: deferred-leveldown: 5.3.0 @@ -23675,33 +19671,12 @@ snapshots: transitivePeerDependencies: - supports-color - lilconfig@2.0.5: {} - lines-and-columns@1.2.4: {} linkify-it@5.0.0: dependencies: uc.micro: 2.1.0 - lint-staged@12.5.0(enquirer@2.4.1): - dependencies: - cli-truncate: 3.1.0 - colorette: 2.0.20 - commander: 9.5.0 - debug: 4.4.3(supports-color@9.4.0) - execa: 5.1.1 - lilconfig: 2.0.5 - listr2: 4.0.5(enquirer@2.4.1) - micromatch: 4.0.8 - normalize-path: 3.0.0 - object-inspect: 1.13.4 - pidtree: 0.5.0 - string-argv: 0.3.2 - supports-color: 9.4.0 - yaml: 1.10.2 - transitivePeerDependencies: - - enquirer - lint-staged@16.2.7: dependencies: commander: 14.0.2 @@ -23712,19 +19687,6 @@ snapshots: string-argv: 0.3.2 yaml: 2.8.1 - listr2@4.0.5(enquirer@2.4.1): - dependencies: - cli-truncate: 2.1.0 - colorette: 2.0.20 - log-update: 4.0.0 - p-map: 4.0.0 - rfdc: 1.4.1 - rxjs: 7.8.2 - through: 2.3.8 - wrap-ansi: 7.0.0 - optionalDependencies: - enquirer: 2.4.1 - listr2@9.0.5: dependencies: cli-truncate: 5.0.0 @@ -23748,11 +19710,6 @@ snapshots: dependencies: lie: 3.1.1 - locate-path@2.0.0: - dependencies: - p-locate: 2.0.0 - path-exists: 3.0.0 - locate-path@5.0.0: dependencies: p-locate: 4.1.0 @@ -23801,8 +19758,6 @@ snapshots: lodash.upperfirst@4.3.1: {} - lodash@4.17.20: {} - lodash@4.17.21: {} log-symbols@4.1.0: @@ -23810,13 +19765,6 @@ snapshots: chalk: 4.1.2 is-unicode-supported: 0.1.0 - log-update@4.0.0: - dependencies: - ansi-escapes: 4.3.2 - cli-cursor: 3.1.0 - slice-ansi: 4.0.0 - wrap-ansi: 6.2.0 - log-update@6.1.0: dependencies: ansi-escapes: 7.1.0 @@ -23834,10 +19782,6 @@ snapshots: safe-stable-stringify: 2.5.0 triple-beam: 1.4.1 - looper@2.0.0: {} - - looper@3.0.0: {} - loose-envify@1.4.0: dependencies: js-tokens: 4.0.0 @@ -23856,27 +19800,12 @@ snapshots: dependencies: tslib: 2.8.1 - lowercase-keys@1.0.1: - optional: true - - lowercase-keys@2.0.0: - optional: true - lowercase-keys@3.0.0: {} lru-cache@10.4.3: {} lru-cache@11.2.1: {} - lru-cache@3.2.0: - dependencies: - pseudomap: 1.0.2 - - lru-cache@4.1.5: - dependencies: - pseudomap: 1.0.2 - yallist: 2.1.2 - lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -23889,8 +19818,6 @@ snapshots: lru_map@0.3.3: {} - ltgt@2.1.3: {} - ltgt@2.2.1: {} make-error@1.3.6: {} @@ -23918,10 +19845,6 @@ snapshots: map-cache@0.2.2: {} - map-visit@1.0.0: - dependencies: - object-visit: 1.0.1 - markdown-it@14.1.0: dependencies: argparse: 2.0.1 @@ -23999,8 +19922,6 @@ snapshots: math-intrinsics@1.1.0: {} - math-random@1.0.4: {} - mcl-wasm@0.7.9: {} md5.js@1.3.5: @@ -24013,28 +19934,6 @@ snapshots: media-typer@0.3.0: {} - mem@1.1.0: - dependencies: - mimic-fn: 1.2.0 - - memdown@1.4.1: - dependencies: - abstract-leveldown: 2.7.2 - functional-red-black-tree: 1.0.1 - immediate: 3.3.0 - inherits: 2.0.4 - ltgt: 2.2.1 - safe-buffer: 5.1.2 - - memdown@3.0.0: - dependencies: - abstract-leveldown: 5.0.0 - functional-red-black-tree: 1.0.1 - immediate: 3.2.3 - inherits: 2.0.4 - ltgt: 2.2.1 - safe-buffer: 5.1.2 - memdown@5.1.0: dependencies: abstract-leveldown: 6.2.3 @@ -24052,34 +19951,10 @@ snapshots: merge-descriptors@1.0.1: {} - merge-descriptors@1.0.3: - optional: true - merge-stream@2.0.0: {} merge2@1.4.1: {} - merkle-patricia-tree@2.3.2: - dependencies: - async: 1.5.2 - ethereumjs-util: 5.2.1 - level-ws: 0.0.0 - levelup: 1.3.9 - memdown: 1.4.1 - readable-stream: 2.3.8 - rlp: 2.2.7 - semaphore: 1.1.0 - - merkle-patricia-tree@3.0.0: - dependencies: - async: 2.6.4 - ethereumjs-util: 5.2.1 - level-mem: 3.0.1 - level-ws: 1.0.0 - readable-stream: 3.6.2 - rlp: 2.2.7 - semaphore: 1.1.0 - merkle-patricia-tree@4.2.4: dependencies: '@types/levelup': 4.3.3 @@ -24140,7 +20015,7 @@ snapshots: metro-file-map@0.83.1: dependencies: - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) fb-watchman: 2.0.2 flow-enums-runtime: 0.0.6 graceful-fs: 4.2.11 @@ -24236,7 +20111,7 @@ snapshots: chalk: 4.1.2 ci-info: 2.0.0 connect: 3.7.0 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) error-stack-parser: 2.1.4 flow-enums-runtime: 0.0.6 graceful-fs: 4.2.11 @@ -24435,7 +20310,7 @@ snapshots: micromark@4.0.2: dependencies: '@types/debug': 4.1.12 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) decode-named-character-reference: 1.2.0 devlop: 1.1.0 micromark-core-commonmark: 2.0.3 @@ -24454,40 +20329,6 @@ snapshots: transitivePeerDependencies: - supports-color - micromatch@2.3.11: - dependencies: - arr-diff: 2.0.0 - array-unique: 0.2.1 - braces: 1.8.5 - expand-brackets: 0.1.5 - extglob: 0.3.2 - filename-regex: 2.0.1 - is-extglob: 1.0.0 - is-glob: 2.0.1 - kind-of: 3.2.2 - normalize-path: 2.1.1 - object.omit: 2.0.1 - parse-glob: 3.0.4 - regex-cache: 0.4.4 - - micromatch@3.1.10: - dependencies: - arr-diff: 4.0.0 - array-unique: 0.3.2 - braces: 2.3.2 - define-property: 2.0.2 - extend-shallow: 3.0.2 - extglob: 2.0.4 - fragment-cache: 0.2.1 - kind-of: 6.0.3 - nanomatch: 1.2.13 - object.pick: 1.3.0 - regex-not: 1.0.2 - snapdragon: 0.8.2 - to-regex: 3.0.2 - transitivePeerDependencies: - - supports-color - micromatch@4.0.8: dependencies: braces: 3.0.3 @@ -24506,15 +20347,10 @@ snapshots: mime@1.6.0: {} - mimic-fn@1.2.0: {} - mimic-fn@2.1.0: {} mimic-function@5.0.1: {} - mimic-response@1.0.1: - optional: true - mimic-response@2.1.0: optional: true @@ -24522,10 +20358,6 @@ snapshots: mimic-response@4.0.0: {} - min-document@2.19.0: - dependencies: - dom-walk: 0.1.2 - minimalistic-assert@1.0.1: {} minimalistic-crypto-utils@1.0.1: {} @@ -24550,8 +20382,6 @@ snapshots: dependencies: brace-expansion: 2.0.2 - minimist@0.0.8: {} - minimist@1.2.8: {} minipass-collect@2.0.1: @@ -24578,12 +20408,6 @@ snapshots: dependencies: minipass: 3.3.6 - minipass@2.9.0: - dependencies: - safe-buffer: 5.2.1 - yallist: 3.1.1 - optional: true - minipass@3.3.6: dependencies: yallist: 4.0.0 @@ -24592,33 +20416,14 @@ snapshots: minipass@7.1.2: {} - minizlib@1.3.3: - dependencies: - minipass: 2.9.0 - optional: true - minizlib@2.1.2: dependencies: minipass: 3.3.6 yallist: 4.0.0 - mixin-deep@1.3.2: - dependencies: - for-in: 1.0.2 - is-extendable: 1.0.1 - mkdirp-classic@0.5.3: optional: true - mkdirp-promise@5.0.1: - dependencies: - mkdirp: 3.0.1 - optional: true - - mkdirp@0.5.1: - dependencies: - minimist: 0.0.8 - mkdirp@0.5.6: dependencies: minimist: 1.2.8 @@ -24654,31 +20459,6 @@ snapshots: yargs-parser: 20.2.9 yargs-unparser: 2.0.0 - mocha@4.1.0: - dependencies: - browser-stdout: 1.3.0 - commander: 2.11.0 - debug: 3.1.0(supports-color@4.4.0) - diff: 3.3.1 - escape-string-regexp: 1.0.5 - glob: 7.1.2 - growl: 1.10.3 - he: 1.1.1 - mkdirp: 0.5.1 - supports-color: 4.4.0 - - mock-fs@4.14.0: - optional: true - - mock-property@1.0.3: - dependencies: - define-data-property: 1.1.4 - functions-have-names: 1.2.3 - gopd: 1.2.0 - has-property-descriptors: 1.0.2 - hasown: 2.0.2 - isarray: 2.0.5 - moment-timezone@0.5.48: dependencies: moment: 2.30.1 @@ -24701,36 +20481,6 @@ snapshots: ms@2.1.3: {} - multibase@0.6.1: - dependencies: - base-x: 3.0.11 - buffer: 5.7.1 - optional: true - - multibase@0.7.0: - dependencies: - base-x: 3.0.11 - buffer: 5.7.1 - optional: true - - multicodec@0.5.7: - dependencies: - varint: 5.0.2 - optional: true - - multicodec@1.0.4: - dependencies: - buffer: 5.7.1 - varint: 5.0.2 - optional: true - - multihashes@0.4.21: - dependencies: - buffer: 5.7.1 - multibase: 0.7.0 - varint: 5.0.2 - optional: true - murmur-128@0.2.1: dependencies: encode-utf8: 1.0.3 @@ -24750,27 +20500,8 @@ snapshots: nan@2.23.0: optional: true - nano-json-stream-parser@0.1.2: - optional: true - nano-spawn@2.0.0: {} - nanomatch@1.2.13: - dependencies: - arr-diff: 4.0.0 - array-unique: 0.3.2 - define-property: 2.0.2 - extend-shallow: 3.0.2 - fragment-cache: 0.2.1 - is-windows: 1.0.2 - kind-of: 6.0.3 - object.pick: 1.3.0 - regex-not: 1.0.2 - snapdragon: 0.8.2 - to-regex: 3.0.2 - transitivePeerDependencies: - - supports-color - nanospinner@1.2.2: dependencies: picocolors: 1.1.1 @@ -24803,12 +20534,8 @@ snapshots: neoqs@6.13.0: {} - next-tick@1.1.0: {} - ngeohash@0.6.3: {} - nice-try@1.0.5: {} - no-case@3.0.4: dependencies: lower-case: 2.0.2 @@ -24833,11 +20560,6 @@ snapshots: dependencies: lodash: 4.17.21 - node-fetch@1.7.3: - dependencies: - encoding: 0.1.13 - is-stream: 1.1.0 - node-fetch@2.6.7(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 @@ -24900,12 +20622,6 @@ snapshots: normalize-path@3.0.0: {} - normalize-url@4.5.1: - optional: true - - normalize-url@6.1.0: - optional: true - normalize-url@8.1.0: {} npm-package-arg@11.0.3: @@ -24928,14 +20644,6 @@ snapshots: transitivePeerDependencies: - supports-color - npm-run-path@2.0.2: - dependencies: - path-key: 2.0.1 - - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - npmlog@4.1.2: dependencies: are-we-there-yet: 1.1.7 @@ -24961,31 +20669,12 @@ snapshots: object-assign@4.1.1: {} - object-copy@0.1.0: - dependencies: - copy-descriptor: 0.1.1 - define-property: 0.2.5 - kind-of: 3.2.2 - object-inspect@1.10.3: {} - object-inspect@1.12.3: {} - object-inspect@1.13.4: {} - object-is@1.1.6: - dependencies: - call-bind: 1.0.8 - define-properties: 1.2.1 - - object-keys@0.4.0: {} - object-keys@1.1.1: {} - object-visit@1.0.1: - dependencies: - isobject: 3.0.1 - object.assign@4.1.7: dependencies: call-bind: 1.0.8 @@ -25002,45 +20691,21 @@ snapshots: es-abstract: 1.24.0 es-object-atoms: 1.1.1 - object.getownpropertydescriptors@2.1.8: + object.groupby@1.0.3: dependencies: - array.prototype.reduce: 1.0.8 call-bind: 1.0.8 define-properties: 1.2.1 es-abstract: 1.24.0 - es-object-atoms: 1.1.1 - gopd: 1.2.0 - safe-array-concat: 1.1.3 - object.groupby@1.0.3: + object.values@1.2.1: dependencies: call-bind: 1.0.8 + call-bound: 1.0.4 define-properties: 1.2.1 - es-abstract: 1.24.0 - - object.omit@2.0.1: - dependencies: - for-own: 0.1.5 - is-extendable: 0.1.1 - - object.pick@1.3.0: - dependencies: - isobject: 3.0.1 - - object.values@1.2.1: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.4 - define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.1 obliterator@2.0.5: {} - oboe@2.1.4: - dependencies: - http-https: 1.0.0 - optional: true - on-exit-leak-free@0.2.0: {} on-finished@2.3.0: @@ -25102,18 +20767,10 @@ snapshots: ordinal@1.0.3: {} - os-homedir@1.0.2: {} - os-locale@1.4.0: dependencies: lcid: 1.0.0 - os-locale@2.1.0: - dependencies: - execa: 0.7.0 - lcid: 1.0.0 - mem: 1.1.0 - os-tmpdir@1.0.2: {} outdent@0.5.0: {} @@ -25154,12 +20811,6 @@ snapshots: transitivePeerDependencies: - zod - p-cancelable@1.1.0: - optional: true - - p-cancelable@2.1.1: - optional: true - p-cancelable@3.0.0: {} p-filter@2.1.0: @@ -25168,10 +20819,6 @@ snapshots: p-finally@1.0.0: {} - p-limit@1.3.0: - dependencies: - p-try: 1.0.0 - p-limit@2.3.0: dependencies: p-try: 2.2.0 @@ -25184,10 +20831,6 @@ snapshots: dependencies: yocto-queue: 1.2.1 - p-locate@2.0.0: - dependencies: - p-limit: 1.3.0 - p-locate@4.1.0: dependencies: p-limit: 2.3.0 @@ -25217,8 +20860,6 @@ snapshots: dependencies: p-finally: 1.0.0 - p-try@1.0.0: {} - p-try@2.2.0: {} package-json-from-dist@1.0.1: {} @@ -25245,16 +20886,6 @@ snapshots: dependencies: callsites: 3.1.0 - parse-asn1@5.1.7: - dependencies: - asn1.js: 4.10.1 - browserify-aes: 1.2.0 - evp_bytestokey: 1.0.3 - hash-base: 3.0.5 - pbkdf2: 3.1.3 - safe-buffer: 5.2.1 - optional: true - parse-cache-control@1.0.1: {} parse-entities@4.0.2: @@ -25273,15 +20904,6 @@ snapshots: map-cache: 0.2.2 path-root: 0.1.1 - parse-glob@3.0.4: - dependencies: - glob-base: 0.3.0 - is-dotfile: 1.0.3 - is-extglob: 1.0.0 - is-glob: 2.0.1 - - parse-headers@2.0.6: {} - parse-json@2.2.0: dependencies: error-ex: 1.3.4 @@ -25305,42 +20927,6 @@ snapshots: no-case: 3.0.4 tslib: 2.8.1 - pascalcase@0.1.1: {} - - patch-package@6.2.2: - dependencies: - '@yarnpkg/lockfile': 1.1.0 - chalk: 2.4.2 - cross-spawn: 6.0.6 - find-yarn-workspace-root: 1.2.1 - fs-extra: 7.0.1 - is-ci: 2.0.0 - klaw-sync: 6.0.0 - minimist: 1.2.8 - rimraf: 2.7.1 - semver: 5.7.2 - slash: 2.0.0 - tmp: 0.0.33 - transitivePeerDependencies: - - supports-color - - patch-package@6.5.1: - dependencies: - '@yarnpkg/lockfile': 1.1.0 - chalk: 4.1.2 - cross-spawn: 6.0.6 - find-yarn-workspace-root: 2.0.0 - fs-extra: 9.1.0 - is-ci: 2.0.0 - klaw-sync: 6.0.0 - minimist: 1.2.8 - open: 7.4.2 - rimraf: 2.7.1 - semver: 5.7.2 - slash: 2.0.0 - tmp: 0.0.33 - yaml: 1.10.2 - path-browserify@1.0.1: {} path-case@3.0.4: @@ -25352,16 +20938,12 @@ snapshots: dependencies: pinkie-promise: 2.0.1 - path-exists@3.0.0: {} - path-exists@4.0.0: {} path-exists@5.0.0: {} path-is-absolute@1.0.1: {} - path-key@2.0.1: {} - path-key@3.1.1: {} path-parse@1.0.7: {} @@ -25384,9 +20966,6 @@ snapshots: path-starts-with@2.0.1: {} - path-to-regexp@0.1.12: - optional: true - path-to-regexp@0.1.7: {} path-type@1.1.0: @@ -25412,8 +20991,6 @@ snapshots: sha.js: 2.4.12 to-buffer: 1.2.1 - pegjs@0.10.0: {} - performance-now@2.1.0: {} pg-cloudflare@1.2.7: @@ -25479,8 +21056,6 @@ snapshots: picomatch@4.0.3: {} - pidtree@0.5.0: {} - pidtree@0.6.0: {} pify@2.3.0: {} @@ -25521,8 +21096,6 @@ snapshots: pluralize@8.0.0: {} - posix-character-classes@0.1.1: {} - possible-typed-array-names@1.1.0: {} postgres-array@2.0.0: {} @@ -25535,8 +21108,6 @@ snapshots: dependencies: xtend: 4.0.2 - postinstall-postinstall@2.1.0: {} - prebuild-install@5.3.6: dependencies: detect-libc: 1.0.3 @@ -25573,17 +21144,10 @@ snapshots: tunnel-agent: 0.6.0 optional: true - precond@0.2.3: {} - prelude-ls@1.1.2: {} prelude-ls@1.2.1: {} - prepend-http@2.0.0: - optional: true - - preserve@0.2.0: {} - prettier-plugin-solidity@2.1.0(prettier@3.8.1): dependencies: '@nomicfoundation/slang': 1.2.0 @@ -25601,14 +21165,10 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.3.1 - private@0.1.8: {} - proc-log@4.2.0: {} process-nextick-args@2.0.1: {} - process@0.11.10: {} - prom-client@14.0.1: dependencies: tdigest: 0.1.2 @@ -25624,11 +21184,6 @@ snapshots: promise-throttle@1.1.2: {} - promise-to-callback@1.0.0: - dependencies: - is-fn: 1.0.0 - set-immediate-shim: 1.0.1 - promise@7.3.1: dependencies: asap: 2.0.6 @@ -25663,49 +21218,10 @@ snapshots: prr@1.0.1: {} - pseudomap@1.0.2: {} - psl@1.15.0: dependencies: punycode: 2.3.1 - public-encrypt@4.0.3: - dependencies: - bn.js: 4.12.2 - browserify-rsa: 4.1.1 - create-hash: 1.2.0 - parse-asn1: 5.1.7 - randombytes: 2.1.0 - safe-buffer: 5.2.1 - optional: true - - pull-cat@1.1.11: {} - - pull-defer@0.2.3: {} - - pull-level@2.0.4: - dependencies: - level-post: 1.0.7 - pull-cat: 1.1.11 - pull-live: 1.0.1 - pull-pushable: 2.2.0 - pull-stream: 3.7.0 - pull-window: 2.1.4 - stream-to-pull-stream: 1.7.3 - - pull-live@1.0.1: - dependencies: - pull-cat: 1.1.11 - pull-stream: 3.7.0 - - pull-pushable@2.2.0: {} - - pull-stream@3.7.0: {} - - pull-window@2.1.4: - dependencies: - looper: 2.0.0 - pump@3.0.3: dependencies: end-of-stream: 1.4.5 @@ -25735,11 +21251,6 @@ snapshots: dependencies: side-channel: 1.1.0 - qs@6.13.0: - dependencies: - side-channel: 1.1.0 - optional: true - qs@6.14.0: dependencies: side-channel: 1.1.0 @@ -25752,13 +21263,6 @@ snapshots: quansync@0.2.11: {} - query-string@5.1.1: - dependencies: - decode-uri-component: 0.2.2 - object-assign: 4.1.1 - strict-uri-encode: 1.1.0 - optional: true - queue-microtask@1.2.3: {} queue@6.0.2: @@ -25769,22 +21273,10 @@ snapshots: quick-lru@5.1.1: {} - randomatic@3.1.1: - dependencies: - is-number: 4.0.0 - kind-of: 6.0.3 - math-random: 1.0.4 - randombytes@2.1.0: dependencies: safe-buffer: 5.2.1 - randomfill@1.0.4: - dependencies: - randombytes: 2.1.0 - safe-buffer: 5.2.1 - optional: true - range-parser@1.2.1: {} raw-body@2.4.2: @@ -25907,20 +21399,6 @@ snapshots: pify: 4.0.1 strip-bom: 3.0.0 - readable-stream@1.0.34: - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 0.0.1 - string_decoder: 0.10.31 - - readable-stream@1.1.14: - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 0.0.1 - string_decoder: 0.10.31 - readable-stream@2.3.8: dependencies: core-util-is: 1.0.3 @@ -25937,14 +21415,6 @@ snapshots: string_decoder: 1.3.0 util-deprecate: 1.0.2 - readdirp@2.2.1: - dependencies: - graceful-fs: 4.2.11 - micromatch: 3.1.10 - readable-stream: 2.3.8 - transitivePeerDependencies: - - supports-color - readdirp@3.6.0: dependencies: picomatch: 2.3.1 @@ -25974,27 +21444,8 @@ snapshots: get-proto: 1.0.1 which-builtin-type: 1.2.1 - regenerate@1.4.2: {} - - regenerator-runtime@0.11.1: {} - regenerator-runtime@0.13.11: {} - regenerator-transform@0.10.1: - dependencies: - babel-runtime: 6.26.0 - babel-types: 6.26.0 - private: 0.1.8 - - regex-cache@0.4.4: - dependencies: - is-equal-shallow: 0.1.3 - - regex-not@1.0.2: - dependencies: - extend-shallow: 3.0.2 - safe-regex: 1.1.0 - regexp.prototype.flags@1.5.4: dependencies: call-bind: 1.0.8 @@ -26004,12 +21455,6 @@ snapshots: gopd: 1.2.0 set-function-name: 2.0.2 - regexpu-core@2.0.0: - dependencies: - regenerate: 1.4.2 - regjsgen: 0.2.0 - regjsparser: 0.1.5 - registry-auth-token@5.1.0: dependencies: '@pnpm/npm-conf': 2.3.1 @@ -26018,12 +21463,6 @@ snapshots: dependencies: rc: 1.2.8 - regjsgen@0.2.0: {} - - regjsparser@0.1.5: - dependencies: - jsesc: 0.5.0 - relay-runtime@12.0.0(encoding@0.1.13): dependencies: '@babel/runtime': 7.28.4 @@ -26034,14 +21473,6 @@ snapshots: remove-trailing-separator@1.1.0: {} - repeat-element@1.1.4: {} - - repeat-string@1.6.1: {} - - repeating@2.0.1: - dependencies: - is-finite: 1.1.0 - req-cwd@2.0.0: dependencies: req-from: 2.0.0 @@ -26093,8 +21524,6 @@ snapshots: resolve-pkg-maps@1.0.0: {} - resolve-url@0.2.1: {} - resolve.exports@2.0.3: {} resolve@1.1.7: {} @@ -26109,16 +21538,6 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - responselike@1.0.2: - dependencies: - lowercase-keys: 1.0.1 - optional: true - - responselike@2.0.1: - dependencies: - lowercase-keys: 2.0.0 - optional: true - responselike@3.0.0: dependencies: lowercase-keys: 3.0.0 @@ -26133,8 +21552,6 @@ snapshots: onetime: 7.0.0 signal-exit: 4.1.0 - ret@0.1.15: {} - retry-as-promised@5.0.0: {} retry-as-promised@7.1.1: {} @@ -26177,7 +21594,7 @@ snapshots: dependencies: bn.js: 5.2.2 - rocketh@0.17.13(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76): + rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76): dependencies: '@rocketh/core': 0.17.8(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) abitype: 1.2.3(typescript@5.9.3)(zod@3.25.76) @@ -26228,10 +21645,6 @@ snapshots: safe-buffer@5.2.1: {} - safe-event-emitter@1.0.1: - dependencies: - events: 3.3.0 - safe-push-apply@1.0.0: dependencies: es-errors: 1.3.0 @@ -26243,10 +21656,6 @@ snapshots: es-errors: 1.3.0 is-regex: 1.2.1 - safe-regex@1.1.0: - dependencies: - ret: 0.1.15 - safe-stable-stringify@2.5.0: {} safer-buffer@2.1.2: {} @@ -26272,11 +21681,6 @@ snapshots: scrypt-js@3.0.1: {} - scryptsy@1.2.1: - dependencies: - pbkdf2: 3.1.3 - optional: true - secp256k1@4.0.4: dependencies: elliptic: 6.6.1 @@ -26285,16 +21689,10 @@ snapshots: secure-keys@1.0.0: {} - seedrandom@3.0.1: {} - seedrandom@3.0.5: {} semaphore-async-await@1.5.1: {} - semaphore@1.1.0: {} - - semver@5.4.1: {} - semver@5.7.2: {} semver@6.3.1: {} @@ -26369,7 +21767,7 @@ snapshots: dependencies: '@types/debug': 4.1.12 '@types/validator': 13.15.3 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) dottie: 2.0.6 inflection: 1.13.4 lodash: 4.17.21 @@ -26393,7 +21791,7 @@ snapshots: dependencies: '@types/debug': 4.1.12 '@types/validator': 13.15.3 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) dottie: 2.0.6 inflection: 1.13.4 lodash: 4.17.21 @@ -26446,17 +21844,6 @@ snapshots: transitivePeerDependencies: - supports-color - servify@0.1.12: - dependencies: - body-parser: 1.20.3 - cors: 2.8.5 - express: 4.21.2 - request: 2.88.2 - xhr: 2.6.0 - transitivePeerDependencies: - - supports-color - optional: true - set-blocking@2.0.0: {} set-function-length@1.2.2: @@ -26475,21 +21862,12 @@ snapshots: functions-have-names: 1.2.3 has-property-descriptors: 1.0.2 - set-immediate-shim@1.0.1: {} - set-proto@1.0.0: dependencies: dunder-proto: 1.0.1 es-errors: 1.3.0 es-object-atoms: 1.1.1 - set-value@2.0.1: - dependencies: - extend-shallow: 2.0.1 - is-extendable: 0.1.1 - is-plain-object: 2.0.4 - split-string: 3.1.0 - setimmediate@1.0.5: {} setprototypeof@1.2.0: {} @@ -26507,16 +21885,10 @@ snapshots: shallowequal@1.1.0: {} - shebang-command@1.2.0: - dependencies: - shebang-regex: 1.0.0 - shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 - shebang-regex@1.0.0: {} - shebang-regex@3.0.0: {} shell-quote@1.8.3: {} @@ -26564,13 +21936,6 @@ snapshots: simple-concat@1.0.1: optional: true - simple-get@2.8.2: - dependencies: - decompress-response: 3.3.0 - once: 1.4.0 - simple-concat: 1.0.1 - optional: true - simple-get@3.1.1: dependencies: decompress-response: 4.2.1 @@ -26586,31 +21951,16 @@ snapshots: sisteransi@1.0.5: {} - slash@1.0.0: {} - - slash@2.0.0: {} - slash@3.0.0: {} slash@5.1.0: {} - slice-ansi@3.0.0: - dependencies: - ansi-styles: 4.3.0 - astral-regex: 2.0.0 - is-fullwidth-code-point: 3.0.0 - slice-ansi@4.0.0: dependencies: ansi-styles: 4.3.0 astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 - slice-ansi@5.0.0: - dependencies: - ansi-styles: 6.2.3 - is-fullwidth-code-point: 4.0.0 - slice-ansi@7.1.2: dependencies: ansi-styles: 6.2.3 @@ -26627,33 +21977,10 @@ snapshots: dot-case: 3.0.4 tslib: 2.8.1 - snapdragon-node@2.1.1: - dependencies: - define-property: 1.0.0 - isobject: 3.0.1 - snapdragon-util: 3.0.1 - - snapdragon-util@3.0.1: - dependencies: - kind-of: 3.2.2 - - snapdragon@0.8.2: - dependencies: - base: 0.11.2 - debug: 2.6.9 - define-property: 0.2.5 - extend-shallow: 2.0.1 - map-cache: 0.2.2 - source-map: 0.5.7 - source-map-resolve: 0.5.3 - use: 3.1.1 - transitivePeerDependencies: - - supports-color - socks-proxy-agent@8.0.5: dependencies: agent-base: 7.1.4 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) socks: 2.8.7 transitivePeerDependencies: - supports-color @@ -26663,10 +21990,6 @@ snapshots: ip-address: 10.0.1 smart-buffer: 4.2.0 - sol-digger@0.0.2: {} - - sol-explore@1.6.1: {} - solc@0.4.26: dependencies: fs-extra: 0.30.0 @@ -26675,17 +21998,6 @@ snapshots: semver: 5.7.2 yargs: 4.8.1 - solc@0.6.12: - dependencies: - command-exists: 1.2.9 - commander: 3.0.2 - fs-extra: 0.30.0 - js-sha3: 0.8.0 - memorystream: 0.3.1 - require-from-string: 2.0.2 - semver: 5.7.2 - tmp: 0.0.33 - solc@0.8.15: dependencies: command-exists: 1.2.9 @@ -26832,62 +22144,15 @@ snapshots: hardhat: 2.26.3(bufferutil@4.0.9)(ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3))(typescript@5.9.3)(utf-8-validate@5.0.10) solidity-ast: 0.4.61 - solium-plugin-security@0.1.1(solium@1.2.5): - dependencies: - solium: 1.2.5 - - solium@1.2.5: - dependencies: - ajv: 5.5.2 - chokidar: 1.7.0 - colors: 1.4.0 - commander: 2.20.3 - diff: 3.5.0 - eol: 0.9.1 - js-string-escape: 1.0.1 - lodash: 4.17.21 - sol-digger: 0.0.2 - sol-explore: 1.6.1 - solium-plugin-security: 0.1.1(solium@1.2.5) - solparse: 2.2.8 - text-table: 0.2.0 - transitivePeerDependencies: - - supports-color - - solparse@2.2.8: - dependencies: - mocha: 4.1.0 - pegjs: 0.10.0 - yargs: 10.1.2 - sonic-boom@2.8.0: dependencies: atomic-sleep: 1.0.0 - source-map-resolve@0.5.3: - dependencies: - atob: 2.1.2 - decode-uri-component: 0.2.2 - resolve-url: 0.2.1 - source-map-url: 0.4.1 - urix: 0.1.0 - - source-map-support@0.4.18: - dependencies: - source-map: 0.5.7 - - source-map-support@0.5.12: - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 - source-map-url@0.4.1: {} - source-map@0.2.0: dependencies: amdefine: 1.0.1 @@ -26916,10 +22181,6 @@ snapshots: spdx-license-ids@3.0.22: {} - split-string@3.1.0: - dependencies: - extend-shallow: 3.0.2 - split2@3.2.2: dependencies: readable-stream: 3.6.2 @@ -26960,11 +22221,6 @@ snapshots: dependencies: type-fest: 0.7.1 - static-extend@0.1.2: - dependencies: - define-property: 0.2.5 - object-copy: 0.1.0 - statuses@1.5.0: {} statuses@2.0.1: {} @@ -26976,16 +22232,8 @@ snapshots: stream-shift@1.0.3: {} - stream-to-pull-stream@1.7.3: - dependencies: - looper: 3.0.0 - pull-stream: 3.7.0 - streamsearch@1.1.0: {} - strict-uri-encode@1.1.0: - optional: true - string-argv@0.3.2: {} string-format@2.0.0: {} @@ -27047,8 +22295,6 @@ snapshots: define-properties: 1.2.1 es-object-atoms: 1.1.1 - string_decoder@0.10.31: {} - string_decoder@1.1.1: dependencies: safe-buffer: 5.1.2 @@ -27083,10 +22329,6 @@ snapshots: strip-bom@3.0.0: {} - strip-eof@1.0.0: {} - - strip-final-newline@2.0.0: {} - strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed: 1.0.0 @@ -27097,16 +22339,10 @@ snapshots: strnum@2.1.1: {} - supports-color@2.0.0: {} - supports-color@3.2.3: dependencies: has-flag: 1.0.0 - supports-color@4.4.0: - dependencies: - has-flag: 2.0.0 - supports-color@5.5.0: dependencies: has-flag: 3.0.0 @@ -27119,34 +22355,13 @@ snapshots: dependencies: has-flag: 4.0.0 - supports-color@9.4.0: {} - supports-preserve-symlinks-flag@1.0.0: {} swap-case@2.0.2: dependencies: tslib: 2.8.1 - swarm-js@0.1.42(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - bluebird: 3.7.2 - buffer: 5.7.1 - eth-lib: 0.1.29(bufferutil@4.0.9)(utf-8-validate@5.0.10) - fs-extra: 4.0.3 - got: 11.8.6 - mime-types: 2.1.35 - mkdirp-promise: 5.0.1 - mock-fs: 4.14.0 - setimmediate: 1.0.5 - tar: 4.4.19 - xhr-request: 1.1.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - optional: true - - sync-request@6.1.0: + sync-request@6.1.0: dependencies: http-response-object: 3.0.2 sync-rpc: 1.3.6 @@ -27171,25 +22386,6 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - tape@4.17.0: - dependencies: - '@ljharb/resumer': 0.0.1 - '@ljharb/through': 2.3.14 - call-bind: 1.0.8 - deep-equal: 1.1.2 - defined: 1.0.1 - dotignore: 0.1.2 - for-each: 0.3.5 - glob: 7.2.3 - has: 1.0.4 - inherits: 2.0.4 - is-regex: 1.1.4 - minimist: 1.2.8 - mock-property: 1.0.3 - object-inspect: 1.12.3 - resolve: 1.22.10 - string.prototype.trim: 1.2.10 - tar-fs@2.1.3: dependencies: chownr: 1.1.4 @@ -27207,17 +22403,6 @@ snapshots: readable-stream: 3.6.2 optional: true - tar@4.4.19: - dependencies: - chownr: 1.1.4 - fs-minipass: 1.2.7 - minipass: 2.9.0 - minizlib: 1.3.3 - mkdirp: 0.5.6 - safe-buffer: 5.2.1 - yallist: 3.1.1 - optional: true - tar@6.2.1: dependencies: chownr: 2.0.0 @@ -27246,11 +22431,6 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 - test-value@2.1.0: - dependencies: - array-back: 1.0.4 - typical: 2.6.1 - testrpc@0.0.1: {} text-extensions@2.4.0: {} @@ -27279,11 +22459,6 @@ snapshots: throat@5.0.0: {} - through2@2.0.5: - dependencies: - readable-stream: 2.3.8 - xtend: 4.0.2 - through2@3.0.2: dependencies: inherits: 2.0.4 @@ -27295,9 +22470,6 @@ snapshots: through@2.3.8: {} - timed-out@4.0.1: - optional: true - tiny-lru@8.0.2: {} tinyexec@1.0.1: {} @@ -27315,10 +22487,6 @@ snapshots: dependencies: os-tmpdir: 1.0.2 - tmp@0.1.0: - dependencies: - rimraf: 2.7.1 - tmpl@1.0.5: {} to-buffer@1.2.1: @@ -27327,31 +22495,10 @@ snapshots: safe-buffer: 5.2.1 typed-array-buffer: 1.0.3 - to-fast-properties@1.0.3: {} - - to-object-path@0.3.0: - dependencies: - kind-of: 3.2.2 - - to-readable-stream@1.0.0: - optional: true - - to-regex-range@2.1.1: - dependencies: - is-number: 3.0.0 - repeat-string: 1.6.1 - to-regex-range@5.0.1: dependencies: is-number: 7.0.0 - to-regex@3.0.2: - dependencies: - define-property: 2.0.2 - extend-shallow: 3.0.2 - regex-not: 1.0.2 - safe-regex: 1.1.0 - toidentifier@1.0.1: {} toposort-class@1.0.1: {} @@ -27363,20 +22510,8 @@ snapshots: tr46@0.0.3: {} - trim-right@1.0.1: {} - triple-beam@1.4.1: {} - truffle-flattener@1.6.0: - dependencies: - '@resolver-engine/imports-fs': 0.2.2 - '@solidity-parser/parser': 0.14.5 - find-up: 2.1.0 - mkdirp: 1.0.4 - tsort: 0.0.1 - transitivePeerDependencies: - - supports-color - ts-algebra@1.2.2: {} ts-api-utils@2.4.0(typescript@5.9.3): @@ -27390,28 +22525,10 @@ snapshots: command-line-usage: 6.1.3 string-format: 2.0.0 - ts-essentials@1.0.4: {} - - ts-essentials@6.0.7(typescript@5.9.3): - dependencies: - typescript: 5.9.3 - ts-essentials@7.0.3(typescript@5.9.3): dependencies: typescript: 5.9.3 - ts-generator@0.1.1: - dependencies: - '@types/mkdirp': 0.5.2 - '@types/prettier': 2.7.3 - '@types/resolve': 0.0.8 - chalk: 2.4.2 - glob: 7.2.3 - mkdirp: 0.5.6 - prettier: 2.8.8 - resolve: 1.22.10 - ts-essentials: 1.0.4 - ts-node@10.9.2(@types/node@20.19.14)(typescript@5.9.3): dependencies: '@cspotcode/source-map-support': 0.8.1 @@ -27477,12 +22594,8 @@ snapshots: dependencies: safe-buffer: 5.2.1 - tweetnacl-util@0.15.1: {} - tweetnacl@0.14.5: {} - tweetnacl@1.0.3: {} - type-check@0.3.2: dependencies: prelude-ls: 1.1.2 @@ -27506,25 +22619,10 @@ snapshots: media-typer: 0.3.0 mime-types: 2.1.35 - type@2.7.3: {} - - typechain@3.0.0(typescript@5.9.3): - dependencies: - command-line-args: 4.0.7 - debug: 4.4.3(supports-color@9.4.0) - fs-extra: 7.0.1 - js-sha3: 0.8.0 - lodash: 4.17.21 - ts-essentials: 6.0.7(typescript@5.9.3) - ts-generator: 0.1.1 - transitivePeerDependencies: - - supports-color - - typescript - typechain@8.3.2(patch_hash=b34ed6afcf99760666fdc85ecb2094fdd20ce509f947eb09cef21665a2a6a1d6)(typescript@5.9.3): dependencies: '@types/prettier': 2.7.3 - debug: 4.4.3(supports-color@9.4.0) + debug: 4.4.3(supports-color@8.1.1) fs-extra: 7.0.1 glob: 7.1.7 js-sha3: 0.8.0 @@ -27570,10 +22668,6 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typedarray-to-buffer@3.1.5: - dependencies: - is-typedarray: 1.0.0 - typedarray@0.0.6: {} typescript-eslint@8.53.1(eslint@9.39.2(jiti@2.5.1))(typescript@5.9.3): @@ -27589,16 +22683,6 @@ snapshots: typescript@5.9.3: {} - typewise-core@1.2.0: {} - - typewise@1.0.3: - dependencies: - typewise-core: 1.2.0 - - typewiselite@1.0.0: {} - - typical@2.6.1: {} - typical@4.0.0: {} typical@5.2.0: {} @@ -27612,9 +22696,6 @@ snapshots: uglify-js@3.19.3: optional: true - ultron@1.1.1: - optional: true - unbox-primitive@1.1.0: dependencies: call-bound: 1.0.4 @@ -27626,9 +22707,6 @@ snapshots: underscore@1.13.7: {} - underscore@1.9.1: - optional: true - undici-types@6.21.0: {} undici@5.29.0: @@ -27641,13 +22719,6 @@ snapshots: unicorn-magic@0.1.0: {} - union-value@1.0.1: - dependencies: - arr-union: 3.1.0 - get-value: 2.0.6 - is-extendable: 0.1.1 - set-value: 2.0.1 - unique-filename@3.0.0: dependencies: unique-slug: 4.0.0 @@ -27664,15 +22735,8 @@ snapshots: dependencies: normalize-path: 2.1.1 - unorm@1.6.0: {} - unpipe@1.0.0: {} - unset-value@1.0.0: - dependencies: - has-value: 0.3.1 - isobject: 3.0.1 - update-browserslist-db@1.1.3(browserslist@4.26.0): dependencies: browserslist: 4.26.0 @@ -27691,16 +22755,6 @@ snapshots: dependencies: punycode: 2.3.1 - urix@0.1.0: {} - - url-parse-lax@3.0.0: - dependencies: - prepend-http: 2.0.0 - optional: true - - url-set-query@1.0.0: - optional: true - url@0.11.4: dependencies: punycode: 1.4.1 @@ -27716,11 +22770,10 @@ snapshots: node-gyp-build: 4.8.4 optional: true - use@3.1.1: {} - utf-8-validate@5.0.10: dependencies: node-gyp-build: 4.8.4 + optional: true utf-8-validate@5.0.7: dependencies: @@ -27731,26 +22784,8 @@ snapshots: util-deprecate@1.0.2: {} - util.promisify@1.1.3: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.4 - define-data-property: 1.1.4 - define-properties: 1.2.1 - es-errors: 1.3.0 - es-object-atoms: 1.1.1 - for-each: 0.3.5 - get-intrinsic: 1.3.0 - has-proto: 1.2.0 - has-symbols: 1.1.0 - object.getownpropertydescriptors: 2.1.8 - safe-array-concat: 1.1.3 - utils-merge@1.0.1: {} - uuid@3.3.2: - optional: true - uuid@3.4.0: {} uuid@8.3.2: {} @@ -27770,9 +22805,6 @@ snapshots: value-or-promise@1.0.12: {} - varint@5.0.2: - optional: true - vary@1.1.2: {} verror@1.10.0: @@ -27823,232 +22855,6 @@ snapshots: web-streams-polyfill@3.3.3: {} - web3-bzz@1.2.11(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - '@types/node': 20.19.14 - got: 9.6.0 - swarm-js: 0.1.42(bufferutil@4.0.9)(utf-8-validate@5.0.10) - underscore: 1.9.1 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - optional: true - - web3-core-helpers@1.2.11: - dependencies: - underscore: 1.9.1 - web3-eth-iban: 1.2.11 - web3-utils: 1.2.11 - optional: true - - web3-core-method@1.2.11: - dependencies: - '@ethersproject/transactions': 5.8.0 - underscore: 1.9.1 - web3-core-helpers: 1.2.11 - web3-core-promievent: 1.2.11 - web3-core-subscriptions: 1.2.11 - web3-utils: 1.2.11 - optional: true - - web3-core-promievent@1.2.11: - dependencies: - eventemitter3: 4.0.4 - optional: true - - web3-core-requestmanager@1.2.11: - dependencies: - underscore: 1.9.1 - web3-core-helpers: 1.2.11 - web3-providers-http: 1.2.11 - web3-providers-ipc: 1.2.11 - web3-providers-ws: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-core-subscriptions@1.2.11: - dependencies: - eventemitter3: 4.0.4 - underscore: 1.9.1 - web3-core-helpers: 1.2.11 - optional: true - - web3-core@1.2.11: - dependencies: - '@types/bn.js': 4.11.6 - '@types/node': 20.19.14 - bignumber.js: 9.3.1 - web3-core-helpers: 1.2.11 - web3-core-method: 1.2.11 - web3-core-requestmanager: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-eth-abi@1.2.11: - dependencies: - '@ethersproject/abi': 5.0.0-beta.153 - underscore: 1.9.1 - web3-utils: 1.2.11 - optional: true - - web3-eth-accounts@1.2.11: - dependencies: - crypto-browserify: 3.12.0 - eth-lib: 0.2.8 - ethereumjs-common: 1.5.0 - ethereumjs-tx: 2.1.2 - scrypt-js: 3.0.1 - underscore: 1.9.1 - uuid: 3.3.2 - web3-core: 1.2.11 - web3-core-helpers: 1.2.11 - web3-core-method: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-eth-contract@1.2.11: - dependencies: - '@types/bn.js': 4.11.6 - underscore: 1.9.1 - web3-core: 1.2.11 - web3-core-helpers: 1.2.11 - web3-core-method: 1.2.11 - web3-core-promievent: 1.2.11 - web3-core-subscriptions: 1.2.11 - web3-eth-abi: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-eth-ens@1.2.11: - dependencies: - content-hash: 2.5.2 - eth-ens-namehash: 2.0.8 - underscore: 1.9.1 - web3-core: 1.2.11 - web3-core-helpers: 1.2.11 - web3-core-promievent: 1.2.11 - web3-eth-abi: 1.2.11 - web3-eth-contract: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-eth-iban@1.2.11: - dependencies: - bn.js: 4.12.2 - web3-utils: 1.2.11 - optional: true - - web3-eth-personal@1.2.11: - dependencies: - '@types/node': 20.19.14 - web3-core: 1.2.11 - web3-core-helpers: 1.2.11 - web3-core-method: 1.2.11 - web3-net: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-eth@1.2.11: - dependencies: - underscore: 1.9.1 - web3-core: 1.2.11 - web3-core-helpers: 1.2.11 - web3-core-method: 1.2.11 - web3-core-subscriptions: 1.2.11 - web3-eth-abi: 1.2.11 - web3-eth-accounts: 1.2.11 - web3-eth-contract: 1.2.11 - web3-eth-ens: 1.2.11 - web3-eth-iban: 1.2.11 - web3-eth-personal: 1.2.11 - web3-net: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-net@1.2.11: - dependencies: - web3-core: 1.2.11 - web3-core-method: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - - web3-provider-engine@14.2.1(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10): - dependencies: - async: 2.6.4 - backoff: 2.5.0 - clone: 2.1.2 - cross-fetch: 2.2.6(encoding@0.1.13) - eth-block-tracker: 3.0.1 - eth-json-rpc-infura: 3.2.1(encoding@0.1.13) - eth-sig-util: 1.4.2 - ethereumjs-block: 1.7.1 - ethereumjs-tx: 1.3.7 - ethereumjs-util: 5.2.1 - ethereumjs-vm: 2.6.0 - json-rpc-error: 2.0.0 - json-stable-stringify: 1.3.0 - promise-to-callback: 1.0.0 - readable-stream: 2.3.8 - request: 2.88.2 - semaphore: 1.1.0 - ws: 5.2.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) - xhr: 2.6.0 - xtend: 4.0.2 - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - utf-8-validate - - web3-providers-http@1.2.11: - dependencies: - web3-core-helpers: 1.2.11 - xhr2-cookies: 1.1.0 - optional: true - - web3-providers-ipc@1.2.11: - dependencies: - oboe: 2.1.4 - underscore: 1.9.1 - web3-core-helpers: 1.2.11 - optional: true - - web3-providers-ws@1.2.11: - dependencies: - eventemitter3: 4.0.4 - underscore: 1.9.1 - web3-core-helpers: 1.2.11 - websocket: 1.0.32 - transitivePeerDependencies: - - supports-color - optional: true - - web3-shh@1.2.11: - dependencies: - web3-core: 1.2.11 - web3-core-method: 1.2.11 - web3-core-subscriptions: 1.2.11 - web3-net: 1.2.11 - transitivePeerDependencies: - - supports-color - optional: true - web3-utils@1.10.4: dependencies: '@ethereumjs/util': 8.1.0 @@ -28060,33 +22866,6 @@ snapshots: randombytes: 2.1.0 utf8: 3.0.0 - web3-utils@1.2.11: - dependencies: - bn.js: 4.12.2 - eth-lib: 0.2.8 - ethereum-bloom-filters: 1.2.0 - ethjs-unit: 0.1.6 - number-to-bn: 1.7.0 - randombytes: 2.1.0 - underscore: 1.9.1 - utf8: 3.0.0 - optional: true - - web3@1.2.11(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - web3-bzz: 1.2.11(bufferutil@4.0.9)(utf-8-validate@5.0.10) - web3-core: 1.2.11 - web3-eth: 1.2.11 - web3-eth-personal: 1.2.11 - web3-net: 1.2.11 - web3-shh: 1.2.11 - web3-utils: 1.2.11 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - optional: true - webcrypto-core@1.8.1: dependencies: '@peculiar/asn1-schema': 2.5.0 @@ -28097,19 +22876,6 @@ snapshots: webidl-conversions@3.0.1: {} - websocket@1.0.32: - dependencies: - bufferutil: 4.0.9 - debug: 2.6.9 - es5-ext: 0.10.64 - typedarray-to-buffer: 3.1.5 - utf-8-validate: 5.0.10 - yaeti: 0.0.6 - transitivePeerDependencies: - - supports-color - - whatwg-fetch@2.0.4: {} - whatwg-fetch@3.6.20: {} whatwg-url@5.0.0: @@ -28259,23 +23025,6 @@ snapshots: imurmurhash: 0.1.4 signal-exit: 3.0.7 - ws@3.3.3(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - async-limiter: 1.0.1 - safe-buffer: 5.1.2 - ultron: 1.1.1 - optionalDependencies: - bufferutil: 4.0.9 - utf-8-validate: 5.0.10 - optional: true - - ws@5.2.4(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - async-limiter: 1.0.1 - optionalDependencies: - bufferutil: 4.0.9 - utf-8-validate: 5.0.10 - ws@6.2.3(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: async-limiter: 1.0.1 @@ -28313,38 +23062,6 @@ snapshots: bufferutil: 4.0.9 utf-8-validate: 5.0.10 - xhr-request-promise@0.1.3: - dependencies: - xhr-request: 1.1.0 - optional: true - - xhr-request@1.1.0: - dependencies: - buffer-to-arraybuffer: 0.0.5 - object-assign: 4.1.1 - query-string: 5.1.1 - simple-get: 2.8.2 - timed-out: 4.0.1 - url-set-query: 1.0.0 - xhr: 2.6.0 - optional: true - - xhr2-cookies@1.1.0: - dependencies: - cookiejar: 2.1.4 - optional: true - - xhr@2.6.0: - dependencies: - global: 4.4.0 - is-function: 1.0.2 - parse-headers: 2.0.6 - xtend: 4.0.2 - - xtend@2.1.2: - dependencies: - object-keys: 0.4.0 - xtend@4.0.2: {} y18n@3.2.2: {} @@ -28353,10 +23070,6 @@ snapshots: y18n@5.0.8: {} - yaeti@0.0.6: {} - - yallist@2.1.2: {} - yallist@3.1.1: {} yallist@4.0.0: {} @@ -28386,10 +23099,6 @@ snapshots: yargs-parser@21.1.1: {} - yargs-parser@8.1.0: - dependencies: - camelcase: 4.1.0 - yargs-unparser@2.0.0: dependencies: camelcase: 6.3.0 @@ -28397,21 +23106,6 @@ snapshots: flat: 5.0.2 is-plain-obj: 2.1.0 - yargs@10.1.2: - dependencies: - cliui: 4.1.0 - decamelize: 1.2.0 - find-up: 2.1.0 - get-caller-file: 1.0.3 - os-locale: 2.1.0 - require-directory: 2.1.1 - require-main-filename: 1.0.1 - set-blocking: 2.0.0 - string-width: 2.1.1 - which-module: 2.0.1 - y18n: 3.2.2 - yargs-parser: 8.1.0 - yargs@15.4.1: dependencies: cliui: 6.0.0 From df9a8464e5c11d769d99d0f6305193eccb8d9c7d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 17 Apr 2026 07:52:46 +0000 Subject: [PATCH 082/157] docs: update audit extracts for PR1301 v02 report Update existing findings with status, team responses, and mitigation reviews from the v02 audit report. Add 17 new findings (M-4, M-5, L-6 through L-11, R-5 through R-13) and the v02 PDF. --- .../audits/PR1301/Graph_PR1301_v02.pdf | Bin 0 -> 589789 bytes packages/issuance/audits/PR1301/README.md | 62 +++++++++++------- packages/issuance/audits/PR1301/TRST-H-1.md | 8 ++- packages/issuance/audits/PR1301/TRST-H-2.md | 8 ++- packages/issuance/audits/PR1301/TRST-H-3.md | 8 ++- packages/issuance/audits/PR1301/TRST-H-4.md | 8 ++- packages/issuance/audits/PR1301/TRST-L-1.md | 8 ++- packages/issuance/audits/PR1301/TRST-L-10.md | 22 +++++++ packages/issuance/audits/PR1301/TRST-L-11.md | 26 ++++++++ packages/issuance/audits/PR1301/TRST-L-2.md | 8 ++- packages/issuance/audits/PR1301/TRST-L-3.md | 8 ++- packages/issuance/audits/PR1301/TRST-L-4.md | 4 +- packages/issuance/audits/PR1301/TRST-L-5.md | 8 ++- packages/issuance/audits/PR1301/TRST-L-6.md | 24 +++++++ packages/issuance/audits/PR1301/TRST-L-7.md | 22 +++++++ packages/issuance/audits/PR1301/TRST-L-8.md | 22 +++++++ packages/issuance/audits/PR1301/TRST-L-9.md | 22 +++++++ packages/issuance/audits/PR1301/TRST-M-1.md | 6 +- packages/issuance/audits/PR1301/TRST-M-2.md | 8 ++- packages/issuance/audits/PR1301/TRST-M-3.md | 4 +- packages/issuance/audits/PR1301/TRST-M-4.md | 24 +++++++ packages/issuance/audits/PR1301/TRST-M-5.md | 24 +++++++ packages/issuance/audits/PR1301/TRST-R-10.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-11.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-12.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-13.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-5.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-6.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-7.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-8.md | 7 ++ packages/issuance/audits/PR1301/TRST-R-9.md | 7 ++ .../indexing-agreement/cancel.t.sol | 4 +- 32 files changed, 353 insertions(+), 48 deletions(-) create mode 100644 packages/issuance/audits/PR1301/Graph_PR1301_v02.pdf create mode 100644 packages/issuance/audits/PR1301/TRST-L-10.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-11.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-6.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-7.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-8.md create mode 100644 packages/issuance/audits/PR1301/TRST-L-9.md create mode 100644 packages/issuance/audits/PR1301/TRST-M-4.md create mode 100644 packages/issuance/audits/PR1301/TRST-M-5.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-10.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-11.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-12.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-13.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-5.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-6.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-7.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-8.md create mode 100644 packages/issuance/audits/PR1301/TRST-R-9.md diff --git a/packages/issuance/audits/PR1301/Graph_PR1301_v02.pdf b/packages/issuance/audits/PR1301/Graph_PR1301_v02.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e9512ec7ee7fb2da516b299461a93a06fed9299d GIT binary patch literal 589789 zcmeFa1z45cwl+*CC=JrN1nKUQZjkO~(cRJ|-5}j9-5?;Pba!`3hjin=fcHJecb~oY zIs5wd_g~k!K9>uhXZD!)j4>Ja97-%BC`?UH!wL^WoLSW|1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fgvU}&gcLCeR;gCU?5%cdDzC_#+G9)e4N2eU2}@XQNh z$?YH|=d0)rZXz#4YPpaS7m|bQ7>+H&Txjt^c)W+qE0=R$1nvkZGc= zB=cH%J*M1@3oXMbsT!-PMNh_Q|7!lwucU-q~q)ml)r9ILu4H1IvT$$?2IP zC1s*UGRMqH?j_K9o@M;cC884}mt)MnNJ*ie!N|xA47Uu;-Algs1YoXRasR}-0HvI9 z{La-ti?hIXiLrD?7ac6(NTlZ-5u#X@JyeR)vS3hQIjG0>M7$4;%@q7-GqD}r zg~Q;0m4Gjo$1L ziEOqMM5g}6u;TcSU`7GgIh=3*bWC*krh6 zEf)%hFw{8rgB*XRBS$ceQOWzN|@ICHk8JCVP&@@UWC+)Kc~| zIUCLtz+n)ez1TpwdtVinIv-m?kl{#Trh&)J6HNIkuf8>7v+i;(WWZj=g#@Bmwh&rgKBjO>g@A

From 60498e9713a0cf642764286cdb53f673ac5fa8ff Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 24 Apr 2026 10:18:59 +0000 Subject: [PATCH 087/157] chore(tag-deployment): drop commit sha from tag annotation The tag itself carries the commit reference (annotated tags point at a commit); duplicating the sha in the annotation body is redundant. --- packages/deployment/scripts/tag-deployment.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/deployment/scripts/tag-deployment.sh b/packages/deployment/scripts/tag-deployment.sh index a6c5f8838..3e05e28a9 100755 --- a/packages/deployment/scripts/tag-deployment.sh +++ b/packages/deployment/scripts/tag-deployment.sh @@ -271,8 +271,7 @@ fi # --- Build annotation --- ANNOTATION="network: ${DISPLAY} (${CHAIN_ID}) -deployed-by: ${DEPLOYER} -commit: ${COMMIT_SHA}" +deployed-by: ${DEPLOYER}" if [[ -n "$UPGRADE_NAME" ]]; then ANNOTATION="upgrade: ${UPGRADE_NAME} ${ANNOTATION}" From cb6c45c1a843f601d34081020b6428e15f886d67 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 17 Apr 2026 09:15:16 +0000 Subject: [PATCH 088/157] fix(collector): add gas overhead buffer to callback prechecks (TRST-L-9) The gasleft() prechecks only accounted for EIP-150's 63/64 rule but not the gas consumed between the check and the CALL opcode. Add a CALLBACK_GAS_OVERHEAD constant (3,000 gas) to all three prechecks so at least MAX_PAYER_CALLBACK_GAS is forwarded to the callee. --- .../collectors/RecurringCollector.sol | 15 +- .../recurring-collector/afterCollection.t.sol | 64 +++++- .../recurring-collector/coverageGaps.t.sol | 191 ++++++++++++++++++ packages/issuance/audits/PR1301/TRST-L-9.md | 11 + 4 files changed, 277 insertions(+), 4 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 171e6e8f0..c51d79d44 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -58,6 +58,12 @@ contract RecurringCollector is /// that could starve the core collect() call of gas. uint256 private constant MAX_PAYER_CALLBACK_GAS = 1_500_000; + /// @notice Gas overhead between the gasleft() precheck and the actual CALL/STATICCALL opcode. + /// Covers ABI encoding, stack/memory setup, and the CALL base cost so that at least + /// MAX_PAYER_CALLBACK_GAS is forwarded to the callee. Sized to cover the cold-account + /// EIP-2929 access cost (2_600) plus Solidity framing. + uint256 private constant CALLBACK_GAS_OVERHEAD = 3_000; + /* solhint-disable gas-small-strings */ /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct bytes32 public constant EIP712_RCA_TYPEHASH = @@ -730,7 +736,8 @@ contract RecurringCollector is if ((agreement.conditions & CONDITION_ELIGIBILITY_CHECK) != 0) { // 64/63 accounts for EIP-150 63/64 gas forwarding rule. - if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) + revert RecurringCollectorInsufficientCallbackGas(); // Eligibility gate (opt-in via conditions bitmask): low-level staticcall avoids // caller-side ABI decode reverts. Only an explicit return of 0 blocks collection; @@ -747,7 +754,8 @@ contract RecurringCollector is } if (payer.code.length != 0 && payer != msg.sender) { - if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) + revert RecurringCollectorInsufficientCallbackGas(); // solhint-disable-next-line avoid-low-level-calls (bool beforeOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( @@ -768,7 +776,8 @@ contract RecurringCollector is // Notify contract payers so they can reconcile escrow in the same transaction. if (payer != msg.sender && payer.code.length != 0) { // 64/63 accounts for EIP-150 63/64 gas forwarding rule. - if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert RecurringCollectorInsufficientCallbackGas(); + if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) + revert RecurringCollectorInsufficientCallbackGas(); // solhint-disable-next-line avoid-low-level-calls (bool afterOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( abi.encodeCall(IAgreementOwner.afterCollection, (agreementId, tokensToCollect)) diff --git a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol index 3e7396178..90ae638e7 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol @@ -143,7 +143,7 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { ); // Binary-search for a gas limit that passes core collect logic but trips the - // callback gas guard (gasleft < MAX_PAYER_CALLBACK_GAS * 64/63 ≈ 1_523_810). + // callback gas guard (gasleft < MAX_PAYER_CALLBACK_GAS * 64/63 + CALLBACK_GAS_OVERHEAD ≈ 1_526_810). // Core logic + escrow call + beforeCollection + events uses ~200k gas. bool triggered; for (uint256 gasLimit = 1_700_000; gasLimit > 1_500_000; gasLimit -= 10_000) { @@ -166,6 +166,68 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { assertTrue(triggered, "Should have triggered InsufficientCallbackGas at some gas limit"); } + /// @notice TRST-L-9: the CALLBACK_GAS_OVERHEAD precheck also guards the eligibility staticcall + /// (first of three callback prechecks). Binary-search for a gas limit that reaches the + /// eligibility precheck and trips it, confirming the buffer logic applies there too. + function test_Collect_Revert_WhenInsufficientCallbackGas_EligibilityPrecheck() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + rca.conditions = 1; // CONDITION_ELIGIBILITY_CHECK — activates the eligibility precheck first + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + bytes memory callData = abi.encodeCall( + _recurringCollector.collect, + (IGraphPayments.PaymentTypes.IndexingFee, data) + ); + + // With eligibility enabled, three sequential callbacks each need the buffer. The test + // confirms at least one (the first, eligibility) trips InsufficientCallbackGas. + bool triggered; + for (uint256 gasLimit = 1_700_000; gasLimit > 1_500_000; gasLimit -= 10_000) { + uint256 snap = vm.snapshot(); + vm.prank(rca.dataService); + (bool success, bytes memory returnData) = address(_recurringCollector).call{ gas: gasLimit }(callData); + if (!success && returnData.length >= 4) { + bytes4 selector; + // solhint-disable-next-line no-inline-assembly + assembly { + selector := mload(add(returnData, 32)) + } + if (selector == IRecurringCollector.RecurringCollectorInsufficientCallbackGas.selector) { + triggered = true; + assertTrue(vm.revertTo(snap)); + break; + } + } + assertTrue(vm.revertTo(snap)); + } + assertTrue(triggered, "eligibility precheck must trip InsufficientCallbackGas under tight gas"); + } + function test_AfterCollection_NotCalledForEOAPayer(FuzzyTestCollect calldata fuzzy) public { // Use standard ECDSA-signed path (EOA payer, no contract) (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, , , ) = _sensibleAuthorizeAndAccept( diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index 696f97584..f81187662 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -995,6 +995,197 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { assertEq(dataServiceMock.canceledAgreementId(), agreementId, "Agreement ID should match"); } + // ══════════════════════════════════════════════════════════════════════ + // Gap 20 — _offerNew deadline guard (L481): offer with deadline already past + // ══════════════════════════════════════════════════════════════════════ + + /// @notice Offering an RCA whose deadline is already past must revert. The deadline guard + /// at the entry of {_offerNew} is independent from the collection-window check in + /// {_requireValidTerms}; this exercises the deadline-elapsed branch directly. + function test_OfferNew_Revert_WhenDeadlineAlreadyPast() public { + MockAgreementOwner approver = new MockAgreementOwner(); + uint64 deadline = uint64(block.timestamp + 100); + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: deadline, + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + // Warp past the deadline before the offer call so the entry-time guard fires. + skip(101); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, + block.timestamp, + deadline + ) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 21 — _requirePayerToSupportEligibilityCheck (L788): contract payer + // sets CONDITION_ELIGIBILITY_CHECK but does not implement IProviderEligibility + // ══════════════════════════════════════════════════════════════════════ + + /// @notice When an RCA enables CONDITION_ELIGIBILITY_CHECK, the payer must support + /// IProviderEligibility via ERC-165. BareAgreementOwner implements IAgreementOwner but + /// not IERC165, so ERC165Checker.supportsInterface returns false and the require fires + /// at offer time. + function test_OfferNew_Revert_WhenEligibilityConditionAndPayerLacksInterface() public { + BareAgreementOwner bare = new BareAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(bare), + dataService: makeAddr("ds-elig-bare"), + serviceProvider: makeAddr("sp-elig-bare"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 1, // CONDITION_ELIGIBILITY_CHECK + nonce: 1, + metadata: "" + }); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorPayerDoesNotSupportEligibilityInterface.selector, + address(bare) + ) + ); + vm.prank(address(bare)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + } + + // ══════════════════════════════════════════════════════════════════════ + // Gap 22 / 23 — Callback-gas prechecks (deterministic single-call) + // + // afterCollection.t.sol uses vm.revertTo in a binary-search loop, which + // discards forge coverage traces. Direct calls track them. + // ══════════════════════════════════════════════════════════════════════ + + /// @notice Eligibility-precheck gas guard reverts under tight gas. Direct call + /// so coverage tracks the revert. + function test_Collect_Revert_LowGas_EligibilityPrecheck_Direct() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds-elig-low-gas"), + serviceProvider: makeAddr("sp-elig-low-gas"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + rca.conditions = 1; // CONDITION_ELIGIBILITY_CHECK + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData( + _generateCollectParams(rca, agreementId, bytes32("col-elig-low"), 1 ether, 0) + ); + bytes memory callData = abi.encodeCall( + _recurringCollector.collect, + (IGraphPayments.PaymentTypes.IndexingFee, data) + ); + + // Outer gas just below the 64/63 + overhead threshold (~1.527M) — gasleft() at the + // first precheck must fall under threshold and trigger the revert. + vm.prank(rca.dataService); + (bool ok, bytes memory ret) = address(_recurringCollector).call{ gas: 1_500_000 }(callData); + assertFalse(ok, "expected revert"); + assertTrue(ret.length >= 4, "expected revert reason"); + bytes4 selector; + // solhint-disable-next-line no-inline-assembly + assembly { + selector := mload(add(ret, 32)) + } + assertEq( + selector, + IRecurringCollector.RecurringCollectorInsufficientCallbackGas.selector, + "expected InsufficientCallbackGas at eligibility precheck" + ); + } + + /// @notice beforeCollection-precheck gas guard reverts under tight gas. With no + /// eligibility flag the first precheck is skipped, so this hits the second guard. + function test_Collect_Revert_LowGas_BeforeCollection_Direct() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds-before-low-gas"), + serviceProvider: makeAddr("sp-before-low-gas"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, // no eligibility — skip first precheck + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + bytes memory data = _generateCollectData( + _generateCollectParams(rca, agreementId, bytes32("col-before-low"), 1 ether, 0) + ); + bytes memory callData = abi.encodeCall( + _recurringCollector.collect, + (IGraphPayments.PaymentTypes.IndexingFee, data) + ); + + vm.prank(rca.dataService); + (bool ok, bytes memory ret) = address(_recurringCollector).call{ gas: 1_500_000 }(callData); + assertFalse(ok, "expected revert"); + assertTrue(ret.length >= 4, "expected revert reason"); + bytes4 selector; + // solhint-disable-next-line no-inline-assembly + assembly { + selector := mload(add(ret, 32)) + } + assertEq( + selector, + IRecurringCollector.RecurringCollectorInsufficientCallbackGas.selector, + "expected InsufficientCallbackGas at beforeCollection precheck" + ); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/issuance/audits/PR1301/TRST-L-9.md b/packages/issuance/audits/PR1301/TRST-L-9.md index d53f195b7..e98f66046 100644 --- a/packages/issuance/audits/PR1301/TRST-L-9.md +++ b/packages/issuance/audits/PR1301/TRST-L-9.md @@ -20,3 +20,14 @@ Add explicit buffer constants to the precheck so that the comparison accounts fo TBD --- + +Added `CALLBACK_GAS_OVERHEAD = 3_000` constant. All three prechecks now use: + +```solidity +if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) + revert RecurringCollectorInsufficientCallbackGas(); +``` + +Sized to cover the worst-case pre-opcode cost. The eligibility STATICCALL is the first access to the payer account on the collect path, so the EIP-2929 cold-account access cost (2_600) dominates; the remaining headroom covers `abi.encodeCall` and stack/memory setup. Subsequent `beforeCollection` / `afterCollection` calls hit the payer warm (100 gas access), so the buffer is generous there. + +Follows the Optimism buffer-constant pattern as suggested. From 3ce58131594a74cb2f681e7a2a3a4246bd9315a4 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 17 Apr 2026 09:34:45 +0000 Subject: [PATCH 089/157] fix(collector): cap returndata copy in payer callbacks (TRST-M-4) Replace Solidity low-level calls with inline assembly to bound returndata copy: eligibility staticcall copies at most 32 bytes, beforeCollection/afterCollection copy zero bytes. Prevents a malicious payer from forcing ~4.5M gas overhead via returndata bombing. --- .../collectors/RecurringCollector.sol | 54 +++++---- .../recurring-collector/returndataBomb.t.sol | 108 ++++++++++++++++++ packages/issuance/audits/PR1301/TRST-M-4.md | 9 ++ 3 files changed, 149 insertions(+), 22 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/returndataBomb.t.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index c51d79d44..2cfb38767 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -731,36 +731,40 @@ contract RecurringCollector is ) private { address payer = agreement.payer; address provider = agreement.serviceProvider; - // Payer callbacks use gas-capped low-level calls to prevent gas siphoning and - // caller-side ABI decode reverts. Failures emit events but do not block collection. + // Eligibility gate (opt-in via conditions bitmask). Assembly staticcall caps returndata + // copy to 32 bytes, preventing returndata bombing. Only an explicit return of 0 blocks + // collection; reverts, short returndata, and malformed responses are treated as "no + // opinion" (collection proceeds). if ((agreement.conditions & CONDITION_ELIGIBILITY_CHECK) != 0) { - // 64/63 accounts for EIP-150 63/64 gas forwarding rule. if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); - - // Eligibility gate (opt-in via conditions bitmask): low-level staticcall avoids - // caller-side ABI decode reverts. Only an explicit return of 0 blocks collection; - // reverts, short returndata, and malformed responses are treated as "no opinion" - // (collection proceeds). - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory result) = payer.staticcall{ gas: MAX_PAYER_CALLBACK_GAS }( - abi.encodeCall(IProviderEligibility.isEligible, (provider)) - ); - if (success && !(result.length < 32) && abi.decode(result, (uint256)) == 0) + bytes memory cd = abi.encodeCall(IProviderEligibility.isEligible, (provider)); + bool success; + uint256 returnLen; + uint256 result; + // solhint-disable-next-line no-inline-assembly + assembly { + success := staticcall(MAX_PAYER_CALLBACK_GAS, payer, add(cd, 0x20), mload(cd), 0x00, 0x20) + returnLen := returndatasize() + result := mload(0x00) + } + if (success && !(returnLen < 32) && result == 0) revert RecurringCollectorCollectionNotEligible(agreementId, provider); - if (!success || result.length < 32) + if (!success || returnLen < 32) emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.EligibilityCheck); } + // Assembly call copies 0 bytes of returndata, preventing returndata bombing. if (payer.code.length != 0 && payer != msg.sender) { if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); - - // solhint-disable-next-line avoid-low-level-calls - (bool beforeOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( - abi.encodeCall(IAgreementOwner.beforeCollection, (agreementId, tokensToCollect)) - ); + bytes memory cd = abi.encodeCall(IAgreementOwner.beforeCollection, (agreementId, tokensToCollect)); + bool beforeOk; + // solhint-disable-next-line no-inline-assembly + assembly { + beforeOk := call(MAX_PAYER_CALLBACK_GAS, payer, 0, add(cd, 0x20), mload(cd), 0, 0) + } if (!beforeOk) emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.BeforeCollection); } } @@ -778,10 +782,16 @@ contract RecurringCollector is // 64/63 accounts for EIP-150 63/64 gas forwarding rule. if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); - // solhint-disable-next-line avoid-low-level-calls - (bool afterOk, ) = payer.call{ gas: MAX_PAYER_CALLBACK_GAS }( - abi.encodeCall(IAgreementOwner.afterCollection, (agreementId, tokensToCollect)) + // Assembly call copies 0 bytes of returndata, preventing returndata bombing. + bytes memory afterCallData = abi.encodeCall( + IAgreementOwner.afterCollection, + (agreementId, tokensToCollect) ); + bool afterOk; + // solhint-disable-next-line no-inline-assembly + assembly { + afterOk := call(MAX_PAYER_CALLBACK_GAS, payer, 0, add(afterCallData, 0x20), mload(afterCallData), 0, 0) + } if (!afterOk) emit PayerCallbackFailed(agreementId, payer, PayerCallbackStage.AfterCollection); } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/returndataBomb.t.sol b/packages/horizon/test/unit/payments/recurring-collector/returndataBomb.t.sol new file mode 100644 index 000000000..3ef69f430 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/returndataBomb.t.sol @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; +import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; +import { IProviderEligibility } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibility.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +/// @notice Payer that returns a configurable-size buffer from every callback. +/// Used to verify the collector caps returndata copy into its outer frame. +contract HugeReturnPayer is IAgreementOwner, IERC165 { + uint256 public returnBytes = 500_000; + + function setReturnBytes(uint256 size) external { + returnBytes = size; + } + + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return interfaceId == type(IERC165).interfaceId || interfaceId == type(IProviderEligibility).interfaceId; + } + + function beforeCollection(bytes16, uint256) external { + uint256 size = returnBytes; + // solhint-disable-next-line no-inline-assembly + assembly { + return(0, size) + } + } + + function afterCollection(bytes16, uint256) external { + uint256 size = returnBytes; + // solhint-disable-next-line no-inline-assembly + assembly { + return(0, size) + } + } + + /// @notice isEligible — first 32 bytes = 1 (eligible), remainder is memory-expansion padding. + fallback() external { + uint256 size = returnBytes; + // solhint-disable-next-line no-inline-assembly + assembly { + mstore(0, 1) + return(0, size) + } + } +} + +contract RecurringCollectorReturndataBombTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + /// @notice All three payer callbacks return 500KB. With bounded retSize at each call site + /// the outer frame does not copy the returndata, so gas usage stays proportional to the + /// callbacks' own internal work. Without the bound, the outer frame incurs memory expansion + /// + RETURNDATACOPY for each 500KB payload, roughly doubling gas consumption. + function test_Collect_BoundsReturndataCopy_WhenPayerReturnsHuge() public { + HugeReturnPayer attacker = new HugeReturnPayer(); + attacker.setReturnBytes(500_000); + + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(attacker), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + rca.conditions = 1; // CONDITION_ELIGIBILITY_CHECK — exercise the eligibility staticcall path + + vm.prank(address(attacker)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + uint256 gasBefore = gasleft(); + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + uint256 gasUsed = gasBefore - gasleft(); + + assertEq(collected, tokens, "collect should succeed despite huge returndata"); + + // Bounded frame: base collect (~200k) plus three callbacks' internal 500KB expansion + // (~520k each) totals roughly 1.8M. Without the bound each callback additionally causes + // ~520k of outer-frame memory expansion plus the RETURNDATACOPY itself, pushing the + // total above 3.3M. A 2.5M ceiling cleanly separates the two cases. + assertLt(gasUsed, 2_500_000, "outer frame consumed unbounded payer returndata"); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/issuance/audits/PR1301/TRST-M-4.md b/packages/issuance/audits/PR1301/TRST-M-4.md index 4da7a926a..ad06eac0e 100644 --- a/packages/issuance/audits/PR1301/TRST-M-4.md +++ b/packages/issuance/audits/PR1301/TRST-M-4.md @@ -22,3 +22,12 @@ Replace the affected high-level call sites with inline assembly that performs th TBD --- + +## Fix + +Replaced all three call sites with inline assembly that bounds returndata copy: + +- **Eligibility staticcall**: copies at most 32 bytes into scratch space (0x00), reads the `uint256` result from there. +- **beforeCollection / afterCollection**: copy 0 bytes (`retSize=0`), only the `bool success` from the CALL opcode is used. + +This prevents a malicious payer from forcing RETURNDATACOPY of ~850 KB per callback. From 8e50abda2dbd3e189aed2c5fa71565776aaf12f4 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 17 Apr 2026 09:50:52 +0000 Subject: [PATCH 090/157] docs: add response to TRST-L-10 EIP-7702 callback dispatch (won't fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CONDITION_ELIGIBILITY_CHECK is an agreement term, not a proxy for payer type — contract payers can legitimately offer agreements without it, and gating callback dispatch on the flag would deny beforeCollection / afterCollection to those payers. With the M-4 returndata-bombing fix in place, the gas impact of an EIP-7702 EOA acquiring callbacks is bounded and predictable, and the callbacks themselves are non-reverting and non-blocking. --- packages/issuance/audits/PR1301/TRST-L-10.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-L-10.md b/packages/issuance/audits/PR1301/TRST-L-10.md index 385b4ee0c..919cda91d 100644 --- a/packages/issuance/audits/PR1301/TRST-L-10.md +++ b/packages/issuance/audits/PR1301/TRST-L-10.md @@ -20,3 +20,7 @@ Use the introduced `CONDITION_ELIGIBILITY_CHECK` flag in place of the live `code TBD --- + +Using `CONDITION_ELIGIBILITY_CHECK` for callback dispatch does not seem appropriate. The eligibility check is an agreement term, not a proxy for payer type and contract payers can legitimately offer agreements without this condition. The provider agreeing to the check requires greater trust in the payer. Gating callbacks on this flag would deny `beforeCollection`/`afterCollection` to contract payers for agreements without eligibility gating. + +With the returndata bombing fix (TRST-M-4), the gas impact of an EIP-7702 EOA gaining callbacks is bounded and predictable. We do not believe this as a significant attack vector. The `beforeCollection`/`afterCollection` callbacks are non-reverting and non-blocking. A payer adding code via EIP-7702 to better handle escrow reconciliation could be a valid use case and in the best interests of all parties. From 6a0ac799db1fd81ae0f08a9ba4270b59332708a5 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 17 Apr 2026 12:13:24 +0000 Subject: [PATCH 091/157] feat(RAM): drop pair tracking below residual escrow threshold (TRST-M-1, TRST-M-5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add minResidualEscrowFactor (uint8, default 50 → threshold 2^50 wei ≈ 0.001 GRT) to RecurringAgreementManager. When a (collector, provider) pair has no remaining agreements and the escrow balance is below the threshold, tracking is dropped — the residual is not worth the gas cost of further thaw/withdraw cycles. For untracked pairs, reconcileProvider performs a blind drain (withdraw matured thaw, thaw remainder) without re-creating tracking state. New agreements for the same pair re-add tracking naturally via _offerAgreement. --- .../payments/recurring-collector/cancel.t.sol | 2 + .../agreement/IRecurringAgreements.sol | 7 + .../agreement/IRecurringEscrowManagement.sol | 23 ++ packages/issuance/audits/PR1301/TRST-M-1.md | 4 +- packages/issuance/audits/PR1301/TRST-M-5.md | 4 + .../agreement/RecurringAgreementManager.sol | 84 +++++- .../agreement-manager/cascadeCleanup.t.sol | 11 + .../escrowSnapStaleness.t.sol | 6 +- .../agreement-manager/residualEscrow.t.sol | 280 ++++++++++++++++++ 9 files changed, 408 insertions(+), 13 deletions(-) create mode 100644 packages/issuance/test/unit/agreement-manager/residualEscrow.t.sol diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol index cf1da6743..1b19a2fc8 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/cancel.t.sol @@ -27,6 +27,8 @@ contract RecurringCollectorCancelTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreement memory fuzzyRCA, uint8 unboundedCanceler ) public { + vm.assume(fuzzyRCA.dataService != _proxyAdmin); + // Generate deterministic agreement ID bytes16 agreementId = _recurringCollector.generateAgreementId( fuzzyRCA.payer, diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol index debbff6c0..4c01aba27 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol @@ -68,6 +68,13 @@ interface IRecurringAgreements { */ function getMinThawFraction() external view returns (uint8 fraction); + /** + * @notice Minimum residual escrow factor for cleanup. + * @dev Pairs with no agreements and escrow below 2^value are dropped from tracking. + * @return value The exponent (threshold = 2^value) + */ + function getMinResidualEscrowFactor() external view returns (uint8 value); + /** * @notice Get the sum of maxNextClaim across all (collector, provider) pairs * @dev Populated lazily through normal operations. diff --git a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol index f19bc108b..76bca5f62 100644 --- a/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol +++ b/packages/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol @@ -76,6 +76,13 @@ interface IRecurringEscrowManagement { */ event MinThawFractionSet(uint8 oldFraction, uint8 newFraction); + /** + * @notice Emitted when the minimum residual escrow is changed + * @param oldValue The previous value + * @param newValue The new value + */ + event MinResidualEscrowFactorSet(uint8 oldValue, uint8 newValue); + // solhint-enable gas-indexed-events // -- Functions -- @@ -124,4 +131,20 @@ interface IRecurringEscrowManagement { * @param fraction The numerator over 256 for the dust threshold */ function setMinThawFraction(uint8 fraction) external; + + /** + * @notice Set the minimum residual escrow factor for pair tracking cleanup. + * @dev Requires OPERATOR_ROLE. When a (collector, provider) pair has no remaining agreements + * and the escrow balance is below 2^value, tracking is dropped because the residual is not worth + * the gas cost of further thaw/withdraw cycles. Funds remain in PaymentsEscrow but are no + * longer actively managed by RAM. Higher values drop tracking more aggressively. + * + * - 0: 2^0 = 1 wei (drop only at zero balance — effectively never drop) + * - 50: 2^50 ≈ 10^15 (0.001 GRT, default) + * - 60: 2^60 ≈ 10^18 (1 GRT) + * - 255: 2^255 (always drop when no agreements remain — effectively disables residual tracking) + * + * @param value The exponent (threshold = 2^value) + */ + function setMinResidualEscrowFactor(uint8 value) external; } diff --git a/packages/issuance/audits/PR1301/TRST-M-1.md b/packages/issuance/audits/PR1301/TRST-M-1.md index 6b10edb96..72927231d 100644 --- a/packages/issuance/audits/PR1301/TRST-M-1.md +++ b/packages/issuance/audits/PR1301/TRST-M-1.md @@ -31,4 +31,6 @@ The griefing path remains reachable. Before any agreement is offered, a 1 wei do --- -Added configurable `minThawFraction` (uint8, proportion of 256, default 16 = 6.25%) that skips thaws when the excess above max is below `sumMaxNextClaim * fraction / 256` for the (collector, provider) pair. An attacker must now donate a meaningful fraction per griefing round, making such an attack both economically unattractive and less effective. +Added configurable `minThawFraction` (uint8, default 16 = 6.25% of `sumMaxNextClaim`) that skips thaws below threshold. + +The zero-threshold path when `sumMaxNextClaim = 0` is acknowledged. Timer resets do not occur (`evenIfTimerReset=false` rejects increases), so the vector is limited to postponing pair tracking cleanup via repeated dust deposits. Added `minResidualEscrowFactor` (uint8, default 50, threshold = 2^value ≈ 0.001 GRT for default): pairs with no agreements and escrow below threshold are dropped from tracking. Untracked pairs can still have escrow drained via blind thaw/withdraw on `reconcileProvider`. diff --git a/packages/issuance/audits/PR1301/TRST-M-5.md b/packages/issuance/audits/PR1301/TRST-M-5.md index 34890fba2..155efa2be 100644 --- a/packages/issuance/audits/PR1301/TRST-M-5.md +++ b/packages/issuance/audits/PR1301/TRST-M-5.md @@ -22,3 +22,7 @@ Gate the check on the incremental amount being added to `thawingTarget` in the c TBD --- + +RAM always calls `adjustThaw(..., evenIfTimerReset=false)`. When a thaw is already active, any increase to `thawingTarget` that would change `thawEndTimestamp` is silently rejected by PaymentsEscrow so the timer is never reset. The "bootstrap + repeated 1 wei" attack does not work as described? + +The actual vector is narrower: indefinite postponement of pair tracking cleanup when `sumMaxNextClaim = 0`. Addressed by `minResidualEscrowFactor` in the fix for TRST-M-1. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 881208eed..6edf82117 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -143,7 +143,11 @@ contract RecurringAgreementManager is /** * @notice Per-(collector, provider) pair tracking data * @param sumMaxNextClaim Sum of maxNextClaim for all agreements in this pair - * @param escrowSnap Last known escrow balance (for snapshot diff) + * @param escrowSnap Snapshot of escrow balance at the last _setEscrowSnap call. + * Input to totalEscrowDeficit accounting, not a guarantee of the live balance — it can + * drift between reconciliations (e.g. after beforeCollection's JIT deposit) until the + * next _reconcileProviderEscrow resyncs it. Read the live balance via _fetchEscrowAccount + * when actual solvency matters. * @param agreements Set of agreement IDs for this pair (stored as bytes32 for EnumerableSet) */ struct CollectorProviderData { @@ -176,8 +180,9 @@ contract RecurringAgreementManager is /// @notice Total unfunded escrow: sum of max(0, sumMaxNextClaim[c][p] - escrowSnap[c][p]) uint256 totalEscrowDeficit; /// @notice The issuance allocator that mints GRT to this contract (20 bytes) - /// @dev Packed slot (28/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (4) + - /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1) + minThawFraction (1). + /// @dev Packed slot (29/32 bytes): issuanceAllocator (20) + ensuredIncomingDistributedToBlock (4) + + /// escrowBasis (1) + minOnDemandBasisThreshold (1) + minFullBasisMargin (1) + minThawFraction (1) + + /// minResidualEscrowFactor (1). /// All read together in _reconcileProviderEscrow / beforeCollection. IIssuanceAllocationDistribution issuanceAllocator; /// @notice Block number when _ensureIncomingDistributionToCurrentBlock last ran @@ -194,6 +199,13 @@ contract RecurringAgreementManager is /// per (collector, provider) pair is skipped as operationally insignificant. /// Governance-configured. uint8 minThawFraction; + /// @notice Minimum residual escrow factor: when a (collector, provider) pair has no agreements + /// and the escrow balance is below 2^value, tracking is dropped; the residual is not worth + /// the gas cost of further thaw/withdraw cycles. Funds remain in PaymentsEscrow but are no + /// longer actively managed by RAM. Higher values drop more aggressively: + /// 0 = drop only at zero balance (effectively never drop); 255 = always drop when no + /// agreements remain. Governance-configured. Default 50 ≈ 0.001 GRT. + uint8 minResidualEscrowFactor; /// @notice Optional oracle for checking payment eligibility of service providers (20/32 bytes in slot) IProviderEligibility providerEligibilityOracle; } @@ -231,6 +243,7 @@ contract RecurringAgreementManager is $.minOnDemandBasisThreshold = 128; $.minFullBasisMargin = 16; $.minThawFraction = 16; + $.minResidualEscrowFactor = 50; // 2^50 ≈ 10^15 ≈ 0.001 GRT } // -- ERC165 -- @@ -435,6 +448,16 @@ contract RecurringAgreementManager is emit MinThawFractionSet(oldFraction, fraction); } + /// @inheritdoc IRecurringEscrowManagement + function setMinResidualEscrowFactor(uint8 value) external onlyRole(OPERATOR_ROLE) { + RecurringAgreementManagerStorage storage $ = _getStorage(); + if ($.minResidualEscrowFactor == value) return; + + uint8 oldValue = $.minResidualEscrowFactor; + $.minResidualEscrowFactor = value; + emit MinResidualEscrowFactorSet(oldValue, value); + } + // -- IProviderEligibilityManagement -- /// @inheritdoc IProviderEligibilityManagement @@ -542,6 +565,11 @@ contract RecurringAgreementManager is return _getStorage().minThawFraction; } + /// @inheritdoc IRecurringAgreements + function getMinResidualEscrowFactor() external view returns (uint8) { + return _getStorage().minResidualEscrowFactor; + } + /// @inheritdoc IRecurringAgreements function getCollectorCount() external view returns (uint256) { return _getStorage().collectorSet.length(); @@ -683,9 +711,17 @@ contract RecurringAgreementManager is } /** - * @notice Reconcile escrow then remove (collector, provider) tracking if fully drained. - * @dev Calls {_reconcileProviderEscrow} to withdraw completed thaws, then removes the pair from - * tracking only when both agreement count and escrowSnap are zero. + * @notice Reconcile escrow then remove (collector, provider) tracking if below residual threshold. + * @dev For tracked pairs (in providerSet): runs {_reconcileProviderEscrow}, then drops tracking + * when no agreements remain and escrow balance is strictly below the residual threshold. + * For untracked pairs: performs a blind drain (withdraw matured thaw, thaw remainder) without + * re-creating tracking state. + * + * The residual threshold = 2^minResidualEscrowFactor. Below this, the residual is not worth + * the gas cost of further thaw/withdraw cycles, so tracking is dropped. Funds remain in + * PaymentsEscrow, just no longer actively managed by RAM. A subsequent {_offerAgreement} + * for the same pair will re-add tracking naturally. + * * Cascades to remove the collector when it has no remaining providers. * @param $ The storage reference * @param collector The collector contract address @@ -698,11 +734,22 @@ contract RecurringAgreementManager is address collector, address provider ) private returns (bool tracked) { + if (!$.collectors[collector].providerSet.contains(provider)) { + // Not tracked — blind drain without re-creating tracking state. + _drainUntracked(collector, provider); + return false; + } + _reconcileProviderEscrow($, collector, provider); CollectorProviderData storage cpd = $.collectors[collector].providers[provider]; - if (cpd.agreements.length() != 0 || cpd.escrowSnap != 0) tracked = true; - else if ($.collectors[collector].providerSet.remove(provider)) { + // Drop tracking when no agreements and escrow is below residual threshold. + // Funds remain in PaymentsEscrow; deficit contribution is already 0 (sumMaxNextClaim == 0). + // Read real balance (escrowSnap is already cleared when sumMaxNextClaim == 0). + tracked = + cpd.agreements.length() != 0 || + ((uint256(1) << $.minResidualEscrowFactor) <= _fetchEscrowAccount(collector, provider).balance); + if (!tracked && $.collectors[collector].providerSet.remove(provider)) { emit ProviderRemoved(collector, provider); if ($.collectors[collector].providerSet.length() == 0) { // Provider agreement count will already be zero at this point. @@ -712,6 +759,24 @@ contract RecurringAgreementManager is } } + /** + * @notice Blind drain for an untracked (collector, provider) escrow pair. + * @dev Withdraws matured thaw if any, then starts a new thaw for remaining balance. + * Does not read or write any RAM tracking state. Only acts when no thaw is active + * (after withdraw or if none was started), so thaw() is safe — no timer to reset. + * @param collector The collector contract address + * @param provider Service provider address + */ + function _drainUntracked(address collector, address provider) private { + IPaymentsEscrow.EscrowAccount memory account = _fetchEscrowAccount(collector, provider); + if (0 < account.tokensThawing && account.thawEndTimestamp < block.timestamp) { + PAYMENTS_ESCROW.withdraw(collector, provider); + account = _fetchEscrowAccount(collector, provider); + } + if (account.tokensThawing == 0 && 0 < account.balance) + PAYMENTS_ESCROW.thaw(collector, provider, account.balance); + } + /** * @notice The sole mutation point for agreement.maxNextClaim and all derived totals. * @dev ALL writes to agreement.maxNextClaim, sumMaxNextClaim, sumMaxNextClaimAll, and @@ -928,7 +993,8 @@ contract RecurringAgreementManager is address provider ) private { uint256 oldEscrow = cpd.escrowSnap; - uint256 newEscrow = _fetchEscrowAccount(collector, provider).balance; + // No need to track escrow when no claims remain (deficit is 0 regardless). + uint256 newEscrow = cpd.sumMaxNextClaim != 0 ? _fetchEscrowAccount(collector, provider).balance : 0; if (oldEscrow == newEscrow) return; uint256 oldDeficit = _providerEscrowDeficit(cpd); diff --git a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol index eeffa61e1..b9d058c6c 100644 --- a/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol +++ b/packages/issuance/test/unit/agreement-manager/cascadeCleanup.t.sol @@ -193,6 +193,12 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage assertEq(agreementManager.getCollectorCount(), 0); assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); + // Storage fully released: escrowSnap cleared when sumMaxNextClaim reached 0 + assertEq( + agreementManager.getEscrowSnap(IAgreementCollector(address(recurringCollector)), indexer), + 0, + "escrowSnap should be cleared after pair drop" + ); } function test_Cascade_ReconcileLastProvider_CollectorCleanedUp_OtherCollectorRemains() public { @@ -271,6 +277,11 @@ contract RecurringAgreementManagerCascadeCleanupTest is RecurringAgreementManage vm.warp(block.timestamp + paymentsEscrow.THAWING_PERIOD() + 1); agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); assertEq(agreementManager.getCollectorCount(), 0); + assertEq( + agreementManager.getEscrowSnap(IAgreementCollector(address(recurringCollector)), indexer), + 0, + "escrowSnap clean before re-add" + ); // Re-add — sets repopulate (IRecurringCollector.RecurringCollectionAgreement memory rca2, ) = _makeRCAForCollector(recurringCollector, 2); diff --git a/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol b/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol index 65cc44245..8bf7c5844 100644 --- a/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol +++ b/packages/issuance/test/unit/agreement-manager/escrowSnapStaleness.t.sol @@ -9,9 +9,9 @@ import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/ import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; /// @notice Tests for escrow snapshot staleness correction and threshold boundary behavior. -/// Covers gaps: -/// - Stale escrow snap self-correction via _setEscrowSnap (TRST-H-3) -/// - Threshold-based basis degradation boundary conditions (TRST-M-2, M-3) +/// Covers: +/// - Stale escrow snap self-correction via _setEscrowSnap +/// - Threshold-based basis degradation boundary conditions /// - Deficit tracking accuracy after external escrow mutations contract RecurringAgreementManagerEscrowSnapStalenessTest is RecurringAgreementManagerSharedTest { /* solhint-disable graph/func-name-mixedcase */ diff --git a/packages/issuance/test/unit/agreement-manager/residualEscrow.t.sol b/packages/issuance/test/unit/agreement-manager/residualEscrow.t.sol new file mode 100644 index 000000000..c96003e67 --- /dev/null +++ b/packages/issuance/test/unit/agreement-manager/residualEscrow.t.sol @@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { IPaymentsEscrow } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsEscrow.sol"; +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringEscrowManagement.sol"; + +import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; + +/// @notice Tests for minResidualEscrowFactor — residual escrow threshold for pair cleanup. +contract RecurringAgreementManagerResidualEscrowTest is RecurringAgreementManagerSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + // -- Helpers -- + + /// @notice Create an agreement, cancel it, and advance past the thaw period so escrow is withdrawable. + function _createAndCancelAgreement() + private + returns (bytes16 agreementId, IRecurringCollector.RecurringCollectionAgreement memory rca) + { + (rca, ) = _makeRCAWithId(100 ether, 1 ether, 3600, uint64(block.timestamp + 365 days)); + agreementId = _offerAgreement(rca); + + _setAgreementCanceledBySP(agreementId, rca); + agreementManager.reconcileAgreement(IAgreementCollector(address(recurringCollector)), agreementId); + } + + /// @notice Inject dust directly into escrow (simulates external depositTo by attacker). + function _injectDust(uint256 amount) private { + (uint256 bal, uint256 thawing, uint256 thawEnd) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + // Mint backing tokens to the escrow so withdraw can transfer them + token.mint(address(paymentsEscrow), amount); + paymentsEscrow.setAccount( + address(agreementManager), + address(recurringCollector), + indexer, + bal + amount, + thawing, + thawEnd + ); + } + + // -- Tests: residual threshold drops tracking -- + + function test_ResidualEscrow_DropsTrackingBelowThreshold() public { + // Default factor = 50, threshold = 2^50 ≈ 1.1e15 + _createAndCancelAgreement(); + + // Advance past thaw period so escrow can be withdrawn + vm.warp(block.timestamp + 1 days + 1); + + // reconcileProvider: withdraws full balance, dust is zero, pair is dropped + bool tracked = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(tracked, "pair should be dropped when escrow is zero"); + assertEq( + agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), + 0, + "provider should be removed from set" + ); + assertEq(agreementManager.getCollectorCount(), 0, "collector should be removed from set"); + } + + function test_ResidualEscrow_KeepsTrackingAboveThreshold() public { + _createAndCancelAgreement(); + + // Inject balance well above threshold (2^50 ≈ 1.1e15) + vm.warp(block.timestamp + 1 days + 1); + _injectDust(1 ether); + + bool tracked = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertTrue(tracked, "pair should remain tracked when escrow exceeds threshold"); + } + + function test_ResidualEscrow_DustGriefingDropsTracking() public { + _createAndCancelAgreement(); + + // Advance past thaw, then inject 1 wei (simulates attacker depositTo) + vm.warp(block.timestamp + 1 days + 1); + _injectDust(1); + + // reconcileProvider: withdraws matured thaw, 1 wei remains, + // 1 wei < 2^50 threshold → pair is dropped + bool tracked = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(tracked, "dust should not prevent cleanup"); + } + + // -- Tests: blind drain for untracked pairs -- + + function test_ResidualEscrow_BlindDrainUntrackedPair() public { + _createAndCancelAgreement(); + + // Drop tracking first + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertEq(agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), 0); + + // Inject dust into the now-untracked escrow + _injectDust(100); + + // reconcileProvider on untracked pair: blind drain starts thaw + bool tracked = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertFalse(tracked, "untracked pair should stay untracked"); + + // Escrow should now be thawing + (uint256 bal, uint256 thawing, ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + assertEq(thawing, bal, "full balance should be thawing"); + } + + function test_ResidualEscrow_BlindDrainWithdrawsMaturedThaw() public { + _createAndCancelAgreement(); + + // Drop tracking + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Inject dust, start thaw via blind drain + _injectDust(100); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Read the thaw end timestamp and advance past it + (, , uint256 thawEnd) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + vm.warp(thawEnd + 1); + + uint256 balBefore = token.balanceOf(address(agreementManager)); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + uint256 balAfter = token.balanceOf(address(agreementManager)); + + assertEq(balAfter - balBefore, 100, "dust should be withdrawn to agreement manager"); + } + + function test_ResidualEscrow_BlindDrainNoopMidThaw() public { + _createAndCancelAgreement(); + + // Drop tracking + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Inject dust, start thaw + _injectDust(100); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Inject more dust mid-thaw — blind drain should NOT reset the timer + _injectDust(50); + + (, , uint256 thawEndBefore) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + (, uint256 thawingAfter, uint256 thawEndAfter) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + + // Timer should not have reset (evenIfTimerReset=false) + assertEq(thawEndAfter, thawEndBefore, "thaw timer should not reset on blind drain mid-thaw"); + // Only the original 100 should be thawing, not 150 + assertEq(thawingAfter, 100, "thaw amount should not increase mid-thaw"); + } + + // -- Tests: re-entry after drop restores tracking -- + + function test_ResidualEscrow_ReentryRestoresTracking() public { + _createAndCancelAgreement(); + + // Drop tracking + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertEq(agreementManager.getCollectorCount(), 0, "collector should be removed"); + + // New agreement for the same (collector, provider) pair + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 50 ether, + 0.5 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + _offerAgreement(rca2); + + // Tracking should be restored + assertEq( + agreementManager.getProviderCount(IAgreementCollector(address(recurringCollector))), + 1, + "provider should be re-tracked" + ); + assertEq(agreementManager.getCollectorCount(), 1, "collector should be re-tracked"); + } + + function test_ResidualEscrow_ReentryWithStaleSnapCorrects() public { + _createAndCancelAgreement(); + + // Inject extra balance, then drop tracking — snap records the inflated balance + _injectDust(500); + vm.warp(block.timestamp + 1 days + 1); + agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + + // Escrow still has some balance (the dust that was below threshold or leftover) + // Now create new agreement — snap should be corrected from real balance + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _makeRCA( + 50 ether, + 0.5 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + rca2.nonce = 2; + _offerAgreement(rca2); + + // The system should work normally — no stale snap causing issues + // Verify escrow is funded correctly for the new agreement + (uint256 bal, , ) = paymentsEscrow.escrowAccounts( + address(agreementManager), + address(recurringCollector), + indexer + ); + uint256 expectedMaxClaim = 0.5 ether * 3600 + 50 ether; + assertEq(bal, expectedMaxClaim, "escrow should be funded for new agreement (snap corrected)"); + } + + // -- Tests: setter -- + + function test_ResidualEscrow_SetFactor() public { + assertEq(agreementManager.getMinResidualEscrowFactor(), 50, "default should be 50"); + + vm.prank(operator); + agreementManager.setMinResidualEscrowFactor(60); + assertEq(agreementManager.getMinResidualEscrowFactor(), 60); + } + + function test_ResidualEscrow_SetFactor_SameValueNoop() public { + vm.prank(operator); + // Should not emit event + vm.recordLogs(); + agreementManager.setMinResidualEscrowFactor(50); + assertEq(vm.getRecordedLogs().length, 0, "no event on same value"); + } + + function test_ResidualEscrow_SetFactor_EmitsEvent() public { + vm.expectEmit(address(agreementManager)); + emit IRecurringEscrowManagement.MinResidualEscrowFactorSet(50, 100); + + vm.prank(operator); + agreementManager.setMinResidualEscrowFactor(100); + } + + function test_ResidualEscrow_SetFactor_ZeroDisables() public { + _createAndCancelAgreement(); + + vm.prank(operator); + agreementManager.setMinResidualEscrowFactor(0); + + // With factor=0, threshold = 2^0 = 1, only drops at zero balance + // Inject 1 wei — should keep tracking + vm.warp(block.timestamp + 1 days + 1); + _injectDust(1); + + bool tracked = agreementManager.reconcileProvider(IAgreementCollector(address(recurringCollector)), indexer); + assertTrue(tracked, "factor=0 means threshold=1, 1 wei should keep tracking"); + } +} From f96a7316c360a8f0b6b72ae56b71d9c8f35df298 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:03:14 +0000 Subject: [PATCH 092/157] docs: add responses to TRST-L-6, TRST-R-7 (both won't fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TRST-L-6: planted-offer-matching-active-terms cleanup bypass — rejected because cross-type EIP-712 collisions are computationally infeasible and same-type 'collisions' require the payer to reproduce their own terms, which is not an attack. TRST-R-7: eagerly delete consumed offers — rejected because offer data (metadata, nonce, deadline) is intentionally kept accessible via getAgreementOfferAt() until obsolete. --- packages/issuance/audits/PR1301/TRST-L-6.md | 4 ++++ packages/issuance/audits/PR1301/TRST-R-7.md | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-L-6.md b/packages/issuance/audits/PR1301/TRST-L-6.md index c0792c908..50b3bf72f 100644 --- a/packages/issuance/audits/PR1301/TRST-L-6.md +++ b/packages/issuance/audits/PR1301/TRST-L-6.md @@ -22,3 +22,7 @@ Delete both `rcaOffers[agreementId]` and `rcauOffers[agreementId]` unconditional TBD --- + +The described attack requires planting an RCA offer whose EIP-712 hash collides with the active `activeTermsHash`. Because `_hashRCA` and `_hashRCAU` use distinct type hashes (`EIP712_RCA_TYPEHASH` vs `EIP712_RCAU_TYPEHASH`), cross-type collisions require a keccak256 preimage collision? Same-type collisions require the payer to reproduce the exact RCA terms, which is not an attack (the payer authored those terms). + +(Cleanup handling will be improved in combination with the response to TRST-L-11.) diff --git a/packages/issuance/audits/PR1301/TRST-R-7.md b/packages/issuance/audits/PR1301/TRST-R-7.md index 903eaaea7..65f7ae98c 100644 --- a/packages/issuance/audits/PR1301/TRST-R-7.md +++ b/packages/issuance/audits/PR1301/TRST-R-7.md @@ -5,3 +5,9 @@ ## Description After `accept()` or `update()` consumes a stored offer, the corresponding entry in `rcaOffers` or `rcauOffers` becomes stale. Currently only `_validateAndStoreUpdate()` cleans up the previously active offer by looking up the old `activeTermsHash`; the offer whose terms were just accepted is not deleted. This is a storage hygiene concern: stale offer entries remain in storage indefinitely until explicitly replaced or matched by a future update. Consider deleting the consumed offer entry inside `accept()` and `update()` after it has been applied. + +--- + +Keeping consumed offers in storage is by design — offer data (including metadata, nonce, deadline) remains accessible on-chain via `getAgreementOfferAt()` until the terms are obsolete. Stale entries are cleaned up by `_validateAndStoreUpdate()` on the next update, overwritten by a new `offer()`, or removed by `cancel()`. Eagerly deleting on consumption would lose data that callers may still want to inspect. + +(Cleanup handling will be improved in combination with the response to TRST-L-11.) From 35447e70395b3f4efea0656549df6a31b5940674 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:21:01 +0000 Subject: [PATCH 093/157] docs(audit): acknowledge TRST-R-3 cancelAgreement defensive check The RAM's cancelAgreement is now a pass-through to collector.cancel(), which requires agreement.state == AgreementState.Accepted. The defensive guard the recommendation asks for already lives in the single authoritative location for agreement state; no further change required. --- packages/issuance/audits/PR1301/TRST-R-3.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-R-3.md b/packages/issuance/audits/PR1301/TRST-R-3.md index d3fa90130..0e012a072 100644 --- a/packages/issuance/audits/PR1301/TRST-R-3.md +++ b/packages/issuance/audits/PR1301/TRST-R-3.md @@ -5,3 +5,7 @@ ## Description In the RAM's `cancelAgreement()` function, the agreement state is required to not be not accepted. However, the logic could be more specific and require the agreement to be Accepted - rejecting previously cancelled agreements. There is no impact because corresponding checks in the RecurringCollector would deny such cancels, but it remains as a best practice. + +--- + +Fixed. The RAM's `cancelAgreement()` was refactored into a pass-through to `collector.cancel()`, which requires `agreement.state == AgreementState.Accepted` before proceeding. The defensive guard now lives in the single authoritative location for agreement state. From 2dd23720fb6ef3a132ce2c567e1aa05aee1cb87d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:21:01 +0000 Subject: [PATCH 094/157] fix(collector): remove dead oldHash guard (TRST-R-6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _validateAndStoreUpdate's `if (oldHash != bytes32(0))` branch was unreachable — every Accepted agreement has a non-zero activeTermsHash written during accept() or a prior update(). Dropped the guard; the offer cleanup is now unconditional with an inline comment noting the invariant. --- .../contracts/payments/collectors/RecurringCollector.sol | 9 ++++----- packages/issuance/audits/PR1301/TRST-R-6.md | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 2cfb38767..fa404a14a 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -1040,11 +1040,10 @@ contract RecurringCollector is // Reverts on overflow — rejecting excessive terms that could prevent collection _rcau.maxOngoingTokensPerSecond * _rcau.maxSecondsPerCollection * 1024; - // Clean up stored replaced offer - bytes32 oldHash = _agreement.activeTermsHash; - if (oldHash != bytes32(0)) - if ($.rcaOffers[_rcau.agreementId].offerHash == oldHash) delete $.rcaOffers[_rcau.agreementId]; - else if ($.rcauOffers[_rcau.agreementId].offerHash == oldHash) delete $.rcauOffers[_rcau.agreementId]; + // Clean up stored replaced offer. oldHash is always non-zero for accepted agreements + // and can only ever survive in rcaOffers. + if ($.rcaOffers[_rcau.agreementId].offerHash == _agreement.activeTermsHash) + delete $.rcaOffers[_rcau.agreementId]; // update the agreement _agreement.endsAt = _rcau.endsAt; diff --git a/packages/issuance/audits/PR1301/TRST-R-6.md b/packages/issuance/audits/PR1301/TRST-R-6.md index 9fa653c5f..46215cc6b 100644 --- a/packages/issuance/audits/PR1301/TRST-R-6.md +++ b/packages/issuance/audits/PR1301/TRST-R-6.md @@ -5,3 +5,7 @@ ## Description In `_validateAndStoreUpdate()` (line 855), the guard `if (oldHash != bytes32(0))` is unreachable as a false branch. Only agreements in the Accepted state may be updated, and every accepted agreement has a non-zero `activeTermsHash` written during `accept()` or a prior `update()`. The guard can be removed or converted into an invariant comment documenting this assumption. + +--- + +Fixed. Removed the dead `if (oldHash != bytes32(0))` guard. Also dropped the unreachable `else if` for `rcauOffers` cleanup — `oldHash` can only survive in `rcaOffers` (from `accept()`), since `update()` always overwrites `rcauOffers` with the new RCAU hash before this point. From c1ef1cb685314c69eb753470af685f2d380f2c2d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 16:07:23 +0000 Subject: [PATCH 095/157] fix(collector): non-zero offer types, reserve OFFER_TYPE_NONE=0 sentinel (TRST-R-5) getAgreementOfferAt callers could not distinguish a stored OFFER_TYPE_NEW (value 0) from the zero default returned when no offer exists. Make the offer type flags non-zero (NEW=1, UPDATE=2), reserve 0 as the named OFFER_TYPE_NONE sentinel, and use it at the no-offer return site. --- .../offerStorageLifecycle.t.sol | 355 ++++++++++++++++++ .../contracts/horizon/IAgreementCollector.sol | 11 +- packages/issuance/audits/PR1301/TRST-R-5.md | 4 + 3 files changed, 366 insertions(+), 4 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol diff --git a/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol new file mode 100644 index 000000000..0aece90ae --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol @@ -0,0 +1,355 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { Vm } from "forge-std/Vm.sol"; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NONE, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + SCOPE_PENDING, + VERSION_CURRENT, + VERSION_NEXT +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice Targeted coverage for the hash-keyed offer storage refactor. +contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function _makeRca(address payer) internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + } + + function _makeRcau( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint32 nonce + ) internal view returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt + 30 days, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond * 2, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: nonce, + metadata: "" + }); + } + + // ────────────────────────────────────────────────────────────────────── + // Hash-keyed offer storage lifecycle + // ────────────────────────────────────────────────────────────────────── + + /// @notice offer(RCA) creates a storage entry at the EIP-712 hash and emits OfferStored. + function test_OfferNew_StoresEntryAtHash_EmitsEvent() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, rcaHash); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(offerType, OFFER_TYPE_NEW, "stored entry at rcaHash"); + assertTrue(offerData.length > 0, "stored data non-empty"); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcaHash, "agreement.activeTermsHash points at offer hash"); + assertEq(agreement.pendingTermsHash, bytes32(0), "no pending before update"); + } + + /// @notice Re-offering the identical RCA is idempotent — no second OfferStored event, storage unchanged. + function test_OfferNew_Idempotent_WhenResubmittedSameHash() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + // Second call with the same RCA must not emit OfferStored again + vm.recordLogs(); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + Vm.Log[] memory logs = vm.getRecordedLogs(); + bytes32 offerStoredSig = keccak256("OfferStored(bytes16,address,uint8,bytes32)"); + for (uint256 i = 0; i < logs.length; i++) { + if (logs[i].topics.length > 0) { + assertFalse(logs[i].topics[0] == offerStoredSig, "no duplicate OfferStored on re-offer"); + } + } + } + + /// @notice Accepting a stored offer preserves the offer entry — getAgreementOfferAt still returns it. + function test_OfferNew_EntryPersistsAcrossAccept() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(offerType, OFFER_TYPE_NEW, "accept does not delete the RCA offer entry"); + assertTrue(offerData.length > 0, "accept preserves stored data"); + } + + /// @notice A successful update deletes the prior active offer from storage; the new RCAU terms + /// become VERSION_CURRENT (OFFER_TYPE_UPDATE) and the pending slot clears. + function test_Update_DeletesPriorActiveOffer_PromotesRcauToCurrent() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + // Prior active (RCA) offer deleted from storage — since activeTermsHash now points at rcauHash, + // a fresh agreementId derived with mismatched hash should return empty at the rcaHash slot. + // We assert via getAgreementDetails: rcaHash is no longer a current version. + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash = rcauHash after update"); + assertEq(agreement.pendingTermsHash, bytes32(0), "pendingTermsHash cleared after update"); + + (uint8 currentType, ) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_CURRENT); + assertEq(currentType, OFFER_TYPE_UPDATE, "current offer type now OFFER_TYPE_UPDATE"); + + (uint8 nextType, bytes memory nextData) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); + assertEq(nextType, OFFER_TYPE_NONE, "no pending offer after update"); + assertEq(nextData.length, 0, "pending data empty after update"); + + // Old RCA hash is no longer referenced; since getAgreementOfferAt only resolves via version + // indices, confirm indirectly that no version maps to rcaHash. + bytes32 currentHash = _recurringCollector.getAgreementDetails(agreementId, VERSION_CURRENT).versionHash; + assertTrue(currentHash != rcaHash, "no version maps to old rcaHash"); + } + + /// @notice Offering a different pending update replaces the prior pending RCAU — the replaced + /// entry is deleted from storage. + function test_OfferUpdate_ReplacesPriorPending_DeletesReplaced() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcauA = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcauA), 0); + bytes32 rcauAHash = _recurringCollector.hashRCAU(rcauA); + + // Second update with different terms (different maxInitialTokens) replaces the pending RCAU + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcauB = rcauA; + rcauB.maxInitialTokens = rcauA.maxInitialTokens + 1; + bytes32 rcauBHash = _recurringCollector.hashRCAU(rcauB); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcauB), 0); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.pendingTermsHash, rcauBHash, "pending now points to rcauB"); + + // Replaced rcauA entry no longer referenced by any version — VERSION_NEXT is now rcauB. + bytes32 pendingHash = _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash; + assertEq(pendingHash, rcauBHash, "VERSION_NEXT resolves to rcauB"); + assertTrue(pendingHash != rcauAHash, "old rcauA no longer reachable via version index"); + } + + // ────────────────────────────────────────────────────────────────────── + // Pre-acceptance cancel cascades deletion of any pending RCAU + // ────────────────────────────────────────────────────────────────────── + + /// @notice Pre-acceptance cancel of the RCA under SCOPE_PENDING deletes BOTH the RCA offer + /// and any pending RCAU offer. After cascade, both slots are empty. + function test_CancelPreAcceptanceRca_CascadesDeleteRcau() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory rcaDetails = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = rcaDetails.agreementId; + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Sanity: both slots populated before the cancel + (uint8 preCurrentType, ) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_CURRENT); + (uint8 preNextType, ) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); + assertEq(preCurrentType, OFFER_TYPE_NEW, "RCA stored before cancel"); + assertEq(preNextType, OFFER_TYPE_UPDATE, "RCAU stored before cancel"); + + // Cancel the pre-acceptance RCA — one OfferCancelled event, both slots cleared + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcaHash); + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, bytes32(0), "activeTermsHash cleared"); + assertEq(agreement.pendingTermsHash, bytes32(0), "pendingTermsHash cascade-cleared"); + + (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(currentType, OFFER_TYPE_NONE, "RCA offer deleted"); + assertEq(currentData.length, 0, "RCA data empty"); + + (uint8 nextType, bytes memory nextData) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); + assertEq(nextType, OFFER_TYPE_NONE, "RCAU offer cascade-deleted"); + assertEq(nextData.length, 0, "RCAU data empty"); + + // The original rcauHash stored-offer entry is no longer referenced. No version hash + // resolves to it — confirmed above — so the cleanup is complete for view purposes. + rcauHash; // silence unused warning; kept for clarity in the narrative + } + + /// @notice After a pre-acceptance cascade delete, a follow-up cancel targeting the orphan RCAU + /// hash must NOT revert: _requirePayerIfExists short-circuits because agreement.payer was + /// zeroed when activeTermsHash was cleared — but the agreement struct still exists. The cancel + /// is therefore a no-op targeting already-empty state. + function test_CancelPreAcceptanceRca_SubsequentRcauCancel_DoesNotRevert() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory rcaDetails = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = rcaDetails.agreementId; + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel the RCA — cascades the RCAU + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); + + // The approver can still cancel(rcauHash) without reverting — the payer slot on the + // agreement is still set (clearing is by *termsHash*, not payer field), so the call + // enters the pending-hash branch, observes pendingTermsHash == 0, and exits silently. + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + } + + /// @notice Pre-acceptance cancel with no pending RCAU still deletes the RCA offer and + /// emits a single OfferCancelled. + function test_CancelPreAcceptanceRca_NoPending_OnlyDeletesRca() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = details.agreementId; + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcaHash); + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); + + (uint8 currentType, ) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_CURRENT); + assertEq(currentType, OFFER_TYPE_NONE, "RCA offer deleted"); + assertEq(_recurringCollector.getAgreement(agreementId).activeTermsHash, bytes32(0), "activeTermsHash cleared"); + } + + // ────────────────────────────────────────────────────────────────────── + // OFFER_TYPE_NONE sentinel + // ────────────────────────────────────────────────────────────────────── + + /// @notice The offer-type sentinel values: OFFER_TYPE_NONE must be 0 so callers can distinguish + /// "no offer stored" (default mapping value) from OFFER_TYPE_NEW / OFFER_TYPE_UPDATE. + function test_OfferTypeConstants_NoneIsZero_OthersNonZero() public pure { + assertEq(OFFER_TYPE_NONE, uint8(0), "OFFER_TYPE_NONE must be 0"); + assertTrue(OFFER_TYPE_NEW != OFFER_TYPE_NONE, "OFFER_TYPE_NEW distinct from NONE"); + assertTrue(OFFER_TYPE_UPDATE != OFFER_TYPE_NONE, "OFFER_TYPE_UPDATE distinct from NONE"); + assertTrue(OFFER_TYPE_NEW != OFFER_TYPE_UPDATE, "NEW and UPDATE distinct"); + } + + /// @notice offer() rejects OFFER_TYPE_NONE as an offer type — the sentinel cannot be used to + /// create a stored offer, so getAgreementOfferAt's OFFER_TYPE_NONE return unambiguously means + /// "no offer stored". + function test_Offer_Revert_WhenOfferTypeIsNone() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes memory data = abi.encode(rca); + + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidCollectData.selector, data) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NONE, data, 0); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/interfaces/contracts/horizon/IAgreementCollector.sol b/packages/interfaces/contracts/horizon/IAgreementCollector.sol index ee8bad086..ee3a5bd80 100644 --- a/packages/interfaces/contracts/horizon/IAgreementCollector.sol +++ b/packages/interfaces/contracts/horizon/IAgreementCollector.sol @@ -44,10 +44,13 @@ uint16 constant AUTO_UPDATED = 512; // -- Offer type constants -- +/// @dev No stored offer — sentinel returned by {IAgreementCollector.getAgreementOfferAt} +/// when the requested version has no offer data. +uint8 constant OFFER_TYPE_NONE = 0; /// @dev Create a new agreement -uint8 constant OFFER_TYPE_NEW = 0; +uint8 constant OFFER_TYPE_NEW = 1; /// @dev Update an existing agreement -uint8 constant OFFER_TYPE_UPDATE = 1; +uint8 constant OFFER_TYPE_UPDATE = 2; // -- Cancel scope constants -- @@ -154,8 +157,8 @@ interface IAgreementCollector is IPaymentsCollector { * original struct. Callers can decode and hash to verify the stored version hash. * @param agreementId The ID of the agreement * @param index The zero-based version index - * @return offerType OFFER_TYPE_NEW (0) or OFFER_TYPE_UPDATE (1) - * @return offerData ABI-encoded original offer struct + * @return offerType OFFER_TYPE_NEW, OFFER_TYPE_UPDATE, or OFFER_TYPE_NONE when no offer is stored + * @return offerData ABI-encoded original offer struct, or empty when offerType is OFFER_TYPE_NONE */ function getAgreementOfferAt( bytes16 agreementId, diff --git a/packages/issuance/audits/PR1301/TRST-R-5.md b/packages/issuance/audits/PR1301/TRST-R-5.md index f3d5ac72e..0db3ff607 100644 --- a/packages/issuance/audits/PR1301/TRST-R-5.md +++ b/packages/issuance/audits/PR1301/TRST-R-5.md @@ -5,3 +5,7 @@ ## Description `getAgreementOfferAt()` returns `(uint8 offerType, bytes memory offerData)`. The offer type constant `OFFER_TYPE_NEW` is defined as 0, which is also the default Solidity return value when no stored offer exists for the given `agreementId` and index. A caller receiving `offerType == 0` cannot distinguish between a stored new-type offer existing and no offer existing. Consider redefining offer type constants with 1-indexed values, or adding an explicit `bool found` return parameter. + +--- + +Using non-zero offer type constants as suggested: `OFFER_TYPE_NEW = 1`, `OFFER_TYPE_UPDATE = 2`. The zero value is declared explicitly as `OFFER_TYPE_NONE` so the "no stored offer" sentinel is part of the interface rather than a NatSpec-only convention. From 36217930d2a79e3e0df68e992ffaad83fe4d26c0 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 18:46:34 +0000 Subject: [PATCH 096/157] refactor(interfaces): drop unused state and offer-option flags, tighten flag NatSpec (TRST-R-11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove AUTO_UPDATE, AUTO_UPDATED, and BY_DATA_SERVICE from IAgreementCollector: none had an implementation path or in-tree consumer (RecurringCollector's cancel vocabulary is Payer / ServiceProvider only; there is no auto-update feature). Remaining flags' NatSpec tightened to describe the semantics they now carry after R-12. Also drop WITH_NOTICE and IF_NOT_ACCEPTED: declared on the unsigned offer path but never referenced — offer() ignores its options parameter. Parameter NatSpec now describes the bitmask as reserved for implementation-specific use. --- .../contracts/horizon/IAgreementCollector.sol | 36 +++++-------------- packages/issuance/audits/PR1301/TRST-R-11.md | 6 ++++ 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/interfaces/contracts/horizon/IAgreementCollector.sol b/packages/interfaces/contracts/horizon/IAgreementCollector.sol index ee3a5bd80..0d83cf904 100644 --- a/packages/interfaces/contracts/horizon/IAgreementCollector.sol +++ b/packages/interfaces/contracts/horizon/IAgreementCollector.sol @@ -4,26 +4,24 @@ pragma solidity ^0.8.22; import { IPaymentsCollector } from "./IPaymentsCollector.sol"; // -- Agreement state flags -- -// REGISTERED, ACCEPTED are monotonic (once set, never cleared). -// All other flags are clearable — cleared when pending terms are accepted. /// @dev Offer exists in storage uint16 constant REGISTERED = 1; /// @dev Provider accepted terms uint16 constant ACCEPTED = 2; -/// @dev collectableUntil has been reduced, collection capped (clearable) +/// @dev The agreement's collection window has been truncated (e.g. by cancellation). +/// Paired with a BY_* flag identifying the origin. uint16 constant NOTICE_GIVEN = 4; -/// @dev Nothing to collect in current state (clearable — cleared on new terms promotion) +/// @dev Nothing to collect under this version's terms (per-version: scoped to active claim +/// for VERSION_CURRENT, pending claim for VERSION_NEXT). uint16 constant SETTLED = 8; -// -- Who-initiated flags (clearable, meaningful when NOTICE_GIVEN is set) -- +// -- Who-initiated flags (meaningful when NOTICE_GIVEN is set) -- -/// @dev Notice given by payer +/// @dev NOTICE_GIVEN originated from the payer. uint16 constant BY_PAYER = 16; -/// @dev Notice given by provider (forfeit — immediate SETTLED) +/// @dev NOTICE_GIVEN originated from the service provider. uint16 constant BY_PROVIDER = 32; -/// @dev Notice given by data service -uint16 constant BY_DATA_SERVICE = 64; // -- Update-origin flag -- @@ -32,16 +30,6 @@ uint16 constant BY_DATA_SERVICE = 64; /// ORed into returned state by getAgreementDetails for pending versions (index 1). uint16 constant UPDATE = 128; -// -- Togglable option flags (set via accept options parameter) -- - -/// @dev Provider opts in to automatic update on final collect -uint16 constant AUTO_UPDATE = 256; - -// -- Lifecycle flags (set by the collector during auto-update, clearable) -- - -/// @dev Active terms were promoted via auto-update (not explicit provider accept) -uint16 constant AUTO_UPDATED = 512; - // -- Offer type constants -- /// @dev No stored offer — sentinel returned by {IAgreementCollector.getAgreementOfferAt} @@ -59,13 +47,6 @@ uint8 constant SCOPE_ACTIVE = 1; /// @dev Cancel targets pending offers uint8 constant SCOPE_PENDING = 2; -// -- Offer option constants (for unsigned offer path) -- - -/// @dev Reduce collectableUntil and set NOTICE_GIVEN | BY_PAYER on the agreement -uint16 constant WITH_NOTICE = 1; -/// @dev Revert if the targeted version has already been accepted -uint16 constant IF_NOT_ACCEPTED = 2; - /** * @title Base interface for agreement-based payment collectors * @notice Base interface for agreement-based payment collectors. @@ -115,7 +96,8 @@ interface IAgreementCollector is IPaymentsCollector { * @notice Offer a new agreement or update an existing one. * @param offerType The type of offer (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) * @param data ABI-encoded offer data - * @param options Bitmask of offer options + * @param options Bitmask reserved for implementation-specific options; pass 0 when none apply. + * No flags are defined at the interface level. * @return Agreement details including participants and version hash */ function offer(uint8 offerType, bytes calldata data, uint16 options) external returns (AgreementDetails memory); diff --git a/packages/issuance/audits/PR1301/TRST-R-11.md b/packages/issuance/audits/PR1301/TRST-R-11.md index 014f20625..0bc206182 100644 --- a/packages/issuance/audits/PR1301/TRST-R-11.md +++ b/packages/issuance/audits/PR1301/TRST-R-11.md @@ -5,3 +5,9 @@ ## Description `IAgreementCollector` defines state flag constants that are not currently used in the RecurringCollector implementation, including `NOTICE_GIVEN`, `SETTLED`, `BY_PAYER`, `BY_PROVIDER`, `BY_DATA_SERVICE`, `AUTO_UPDATE`, and `AUTO_UPDATED`. Unused public interface constants are a source of confusion for integrators, who may code against documented semantics that the implementation does not honor. Either remove the unused flags from the interface, or implement the behaviors they describe in the collector. + +--- + +Removed unused flags: `AUTO_UPDATE`, `AUTO_UPDATED`, `BY_DATA_SERVICE`, `WITH_NOTICE` and `IF_NOT_ACCEPTED` are dropped from the interface. + +NatSpec updated for remaining flags with new semantics. From f32e55024279ea2350b19c9fa21e6926721fddc9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:26:20 +0000 Subject: [PATCH 097/157] docs(audit): acknowledge trust-boundary correction in TRST-H-4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v02 mitigation review corrected the security-boundary framing in our fix comment: an EIP-7702 EOA can toggle code on and off across calls, so "an EOA cannot pass the interface check" is not a durable guarantee. The correct boundary is that a provider opting into CONDITION_ELIGIBILITY_CHECK is trusting the payer contract. Recorded the acknowledgement in the team response — no code change required, since the gate already depends on the provider's opt-in. --- packages/issuance/audits/PR1301/TRST-H-4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/issuance/audits/PR1301/TRST-H-4.md b/packages/issuance/audits/PR1301/TRST-H-4.md index dda0b4f17..d9fa550bc 100644 --- a/packages/issuance/audits/PR1301/TRST-H-4.md +++ b/packages/issuance/audits/PR1301/TRST-H-4.md @@ -29,4 +29,4 @@ Fixed under the assumption that a provider setting `CONDITION_ELIGIBILITY_CHECK` --- -Eligibility checks are now opt-in via the `CONDITION_ELIGIBILITY_CHECK` flag, set explicitly in the agreement terms. Providers agree to eligibility gating by accepting an agreement that includes this condition. When the flag is set, the payer must pass an ERC-165 `supportsInterface` check for `IProviderEligibility` at offer time. An EOA cannot pass this check, so an EOA cannot create an agreement with eligibility gating enabled. +Agreed; the security boundary is that a provider opts into `CONDITION_ELIGIBILITY_CHECK` to trust the payer contract. From d2fd36444840d25f48021fa119893d7ffa7f689d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:51:35 +0000 Subject: [PATCH 098/157] docs(audit): acknowledge reclaim-reason change in TRST-R-13 STALE_POI is the correct reason for the resize-based stale-allocation path (allocation stays open as stakeless, not closed). The previous CLOSE_ALLOCATION behavior never shipped to production, so there is no operator configuration to migrate. --- packages/issuance/audits/PR1301/TRST-R-13.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-R-13.md b/packages/issuance/audits/PR1301/TRST-R-13.md index 6b9b090c0..cefb73ec0 100644 --- a/packages/issuance/audits/PR1301/TRST-R-13.md +++ b/packages/issuance/audits/PR1301/TRST-R-13.md @@ -5,3 +5,7 @@ ## Description Before the PR's refactor, `forceCloseStaleAllocation()` closed the allocation via `_closeAllocation()` and caused a reclaim with reason `CLOSE_ALLOCATION`. Post refactor, the force close path goes through `_resizeAllocation(allocationId, 0, ...)`, which triggers a reclaim with reason `STALE_POI` instead. The reclaim still occurs, but the reason code exposed to reclaim address configuration changes. Document this change so that operators are able to prepare accordingly and have funding paths line up with intention. + +--- + +Noted. The previous `CLOSE_ALLOCATION` reclaim behavior for this path has not shipped to production, so there is no live operator configuration to migrate. `STALE_POI` is the correct reason for the post-refactor semantics (the allocation is stale; it stays open as stakeless rather than closing). From b61d4415f92d5557883aa2d3fd4e1c0f2187f6de Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:55:40 +0000 Subject: [PATCH 099/157] docs(ram): document collector replay-protection assumption (TRST-R-4) RAM trusts collectors to enforce agreement uniqueness and state transitions. Future collectors must implement their own replay protection on acceptance. --- packages/issuance/audits/PR1301/TRST-R-4.md | 4 ++++ .../contracts/agreement/RecurringAgreementManager.sol | 3 +++ 2 files changed, 7 insertions(+) diff --git a/packages/issuance/audits/PR1301/TRST-R-4.md b/packages/issuance/audits/PR1301/TRST-R-4.md index 6e40e6682..7947adbdc 100644 --- a/packages/issuance/audits/PR1301/TRST-R-4.md +++ b/packages/issuance/audits/PR1301/TRST-R-4.md @@ -5,3 +5,7 @@ ## Description The `approveAgreement()` view checks if the agreement hash is valid, however it offers no replay protection for repeated agreement approvals. This attack vector is only stopped at the RecurringCollector as it checks the agreement does not exist and maintains unidirectional transitions from the agreement Accepted state. For future collectors this may not be the case, necessitating clear documentation of the assumption. + +--- + +Documented in the `RecurringAgreementManager` contract header (collector-trust section): collectors own agreement uniqueness, replay protection, and state transitions; RAM does not re-check them. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 6edf82117..141d58dcb 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -57,6 +57,9 @@ import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/Reentran * {forceRemoveAgreement} as an operator escape hatch. Once tracked, reconciliation proceeds * even if COLLECTOR_ROLE is later revoked, ensuring orderly settlement. * + * Collectors own agreement uniqueness, replay protection, and state transitions; this + * contract does not re-check them. + * * {offerAgreement} and {cancelAgreement} forward to the collector then reconcile locally. * The collector does not callback to `msg.sender`, so these methods own the full call * sequence and hold the reentrancy lock for the entire operation. From 02710154df5d7221e7dd2c51bb1ebaa858c7faf2 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:55:59 +0000 Subject: [PATCH 100/157] docs(ram): document non-retroactive role-change semantics (TRST-R-10) Revoking COLLECTOR_ROLE or DATA_SERVICE_ROLE does not invalidate tracked agreements; reconciliation proceeds to orderly settlement. Role checks gate only new offerAgreement calls and discovery inside _reconcileAgreement. --- packages/issuance/audits/PR1301/TRST-R-10.md | 4 ++++ .../contracts/agreement/RecurringAgreementManager.sol | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/issuance/audits/PR1301/TRST-R-10.md b/packages/issuance/audits/PR1301/TRST-R-10.md index 219698e5f..e1d200ba7 100644 --- a/packages/issuance/audits/PR1301/TRST-R-10.md +++ b/packages/issuance/audits/PR1301/TRST-R-10.md @@ -5,3 +5,7 @@ ## Description Changes to `DATA_SERVICE_ROLE` and `COLLECTOR_ROLE` on the RecurringAgreementManager do not affect agreements that have already been offered or accepted through the previously authorized addresses. This is by design (revoking a role should not invalidate settled obligations), but the behavior is not documented. Record this invariant in the RAM documentation so that operators and integrators understand the effect of role changes. + +--- + +Documented in the `RecurringAgreementManager` contract header: role changes are not retroactive — revoking `COLLECTOR_ROLE` or `DATA_SERVICE_ROLE` does not invalidate tracked agreements, which continue to reconcile to orderly settlement. Role checks gate only new `offerAgreement` calls and discovery inside `_reconcileAgreement`. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index 141d58dcb..ab0dbd8f0 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -54,12 +54,16 @@ import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/Reentran * and {cancelAgreement} call collectors directly. Discovery calls `getAgreementDetails`; * reconciliation calls `getMaxNextClaim` — these return values drive escrow accounting. * A broken or malicious collector can cause reconciliation to revert; use - * {forceRemoveAgreement} as an operator escape hatch. Once tracked, reconciliation proceeds - * even if COLLECTOR_ROLE is later revoked, ensuring orderly settlement. + * {forceRemoveAgreement} as an operator escape hatch. * * Collectors own agreement uniqueness, replay protection, and state transitions; this * contract does not re-check them. * + * Role changes are not retroactive. Revoking COLLECTOR_ROLE or DATA_SERVICE_ROLE does not + * invalidate agreements that were offered or accepted while the roles were held. Once + * tracked, reconciliation proceeds to orderly settlement. Role changes only gate *new* + * {offerAgreement} calls and discovery inside {_reconcileAgreement}. + * * {offerAgreement} and {cancelAgreement} forward to the collector then reconcile locally. * The collector does not callback to `msg.sender`, so these methods own the full call * sequence and hold the reentrancy lock for the entire operation. From 1ee49f232f7120c6788c0067488dc65ffadc7570 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:56:16 +0000 Subject: [PATCH 101/157] docs(ram): align pause-escalation prose with whenNotPaused scope (TRST-R-8) Escalation ladder item 3 now refers to the existing cross-contract note so the prose matches the whenNotPaused scope on beforeCollection and afterCollection. --- packages/issuance/audits/PR1301/TRST-R-8.md | 4 ++++ .../contracts/agreement/RecurringAgreementManager.sol | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/issuance/audits/PR1301/TRST-R-8.md b/packages/issuance/audits/PR1301/TRST-R-8.md index dd2ea9619..821e84823 100644 --- a/packages/issuance/audits/PR1301/TRST-R-8.md +++ b/packages/issuance/audits/PR1301/TRST-R-8.md @@ -5,3 +5,7 @@ ## Description The RecurringAgreementManager documentation header states that pausing the contract "stops all permissionless escrow management". In practice, the `whenNotPaused` modifier also applies to `beforeCollection()` and `afterCollection()`, so pause also halts the callback path used during `collect()`. Update the documentation to reflect that callbacks are affected, or narrow the modifier application so that behavior matches the prose. + +--- + +Updated in the `RecurringAgreementManager` contract header: pause is described as blocking permissionless state changes "including collection callbacks and reconciliation", with a cross-reference to the existing cross-contract note describing the resulting escrow-accounting drift. diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index ab0dbd8f0..a5f3c40b0 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -84,7 +84,8 @@ import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/Reentran * Escalation ladder (targeted → full stop): * 1. {emergencyRevokeRole} — disable a specific actor (operator, collector, guardian) * 2. {emergencyClearEligibilityOracle} — fail-open if oracle blocks collections - * 3. Pause this contract — stops all permissionless escrow management + * 3. Pause this contract — blocks permissionless state changes, including collection + * callbacks and reconciliation (see cross-contract note above) * 4. Pause RecurringCollector — stops all collections and state changes * 5. Pause both — full halt * From 9396dbd12250ea31b5644e41c2dae7d3570fb3fe Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:56:22 +0000 Subject: [PATCH 102/157] docs(collector): note self-authorization auth-check obligation (TRST-R-9) RC overrides _isAuthorized to return true when signer == address(this), so RC itself must perform the appropriate authorization check before any external call it initiates. --- .../contracts/payments/collectors/RecurringCollector.sol | 5 +++++ packages/horizon/test/unit/utilities/Authorizable.t.sol | 6 +++++- packages/issuance/audits/PR1301/TRST-R-9.md | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index fa404a14a..52ea3aaa9 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -34,6 +34,11 @@ import { PPMMath } from "../../libraries/PPMMath.sol"; * @author Edge & Node * @dev Implements the {IRecurringCollector} interface. * @notice A payments collector contract that can be used to collect payments using a RCA (Recurring Collection Agreement). + * + * @custom:security Self-authorization: RC overrides {_isAuthorized} to return true whenever + * `signer == address(this)`, so RC itself must perform the appropriate authorization check + * before any external call. + * * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ diff --git a/packages/horizon/test/unit/utilities/Authorizable.t.sol b/packages/horizon/test/unit/utilities/Authorizable.t.sol index 18ed8df54..c9f47fcba 100644 --- a/packages/horizon/test/unit/utilities/Authorizable.t.sol +++ b/packages/horizon/test/unit/utilities/Authorizable.t.sol @@ -326,7 +326,11 @@ contract AuthorizableTest is Test, Bounder { authorizable.revokeAuthorizedSigner(signer); } - function test_IsAuthorized_Revert_WhenZero(address signer) public view { + function test_IsAuthorized_Revert_WhenZero(address signer) public { + // Subclasses (e.g. RecurringCollector) may treat specific addresses — notably + // the contract itself — as authorized regardless of the authorizer, so rely on + // assumeValidFuzzAddress to exclude those. + assumeValidFuzzAddress(signer); authHelper.assertNotAuthorized(address(0), signer); } } diff --git a/packages/issuance/audits/PR1301/TRST-R-9.md b/packages/issuance/audits/PR1301/TRST-R-9.md index b78e271fe..efa601a43 100644 --- a/packages/issuance/audits/PR1301/TRST-R-9.md +++ b/packages/issuance/audits/PR1301/TRST-R-9.md @@ -5,3 +5,7 @@ ## Description The `_isAuthorized(address authorizer, address signer)` override in RecurringCollector returns true whenever `signer == address(this)`, regardless of `authorizer`. This enables RecurringCollector to call `dataService.cancelIndexingAgreementByPayer()` on the payer's behalf. The semantics are safe in the current integration with SubgraphService, but they widen the trust surface: any future consumer that relies on `RecurringCollector.isAuthorized()` for access control will grant access when the signer is the collector itself. Consider tightening the override to scope trust to specific callers, or explicitly document the integration contract so it is not misapplied by future consumers. + +--- + +Added a `@custom:security` note at the `RecurringCollector` contract header: self-authorization requires the collector itself to perform the appropriate authorization check before any external call. From 1e5a6b33a1ca84c3c1c9784afb454efb301e5ad7 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:09:24 +0000 Subject: [PATCH 103/157] fix(subgraph-service): validate update terms against RCAU rate, not stale agreement rate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IndexingAgreement.update() validated new indexing terms against wrapper.collectorAgreement.maxOngoingTokensPerSecond (the current agreement's rate) instead of rcau.maxOngoingTokensPerSecond (the update's rate). If the RCAU decreased the rate, indexing terms exceeding the new cap would be accepted. accept() already validates against rca.maxOngoingTokensPerSecond — this makes update() consistent. --- .../contracts/libraries/IndexingAgreement.sol | 2 +- .../subgraphService/indexing-agreement/shared.t.sol | 10 +++------- .../subgraphService/indexing-agreement/update.t.sol | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 1aa2b9677..347eed37e 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -396,7 +396,7 @@ library IndexingAgreement { metadata.version == IIndexingAgreement.IndexingAgreementVersion.V1, IndexingAgreementInvalidVersion(metadata.version) ); - _setTermsV1(self, rcau.agreementId, metadata.terms, wrapper.collectorAgreement.maxOngoingTokensPerSecond); + _setTermsV1(self, rcau.agreementId, metadata.terms, rcau.maxOngoingTokensPerSecond); emit IndexingAgreementUpdated({ indexer: wrapper.collectorAgreement.serviceProvider, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol index cd35f4aa0..c4d84d705 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol @@ -294,13 +294,14 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun _rca.deadline, _rca.nonce ); + rcau = _recurringCollectorHelper.sensibleRCAU(rcau); rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( _newUpdateIndexingAgreementMetadataV1( - bound(_ctx.ctxInternal.seed.termsV1.tokensPerSecond, 0, _rca.maxOngoingTokensPerSecond), + bound(_ctx.ctxInternal.seed.termsV1.tokensPerSecond, 0, rcau.maxOngoingTokensPerSecond), _ctx.ctxInternal.seed.termsV1.tokensPerEntityPerSecond ) ); - return _recurringCollectorHelper.sensibleRCAU(rcau); + return rcau; } function _requireIndexer(Context storage _ctx, address _indexer) internal view returns (IndexerState memory) { @@ -448,10 +449,5 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun assertEq(_expected.dataService, _actual.collectorAgreement.dataService); assertEq(_expected.payer, _actual.collectorAgreement.payer); assertEq(_expected.serviceProvider, _actual.collectorAgreement.serviceProvider); - assertEq(_expected.endsAt, _actual.collectorAgreement.endsAt); - assertEq(_expected.maxInitialTokens, _actual.collectorAgreement.maxInitialTokens); - assertEq(_expected.maxOngoingTokensPerSecond, _actual.collectorAgreement.maxOngoingTokensPerSecond); - assertEq(_expected.minSecondsPerCollection, _actual.collectorAgreement.minSecondsPerCollection); - assertEq(_expected.maxSecondsPerCollection, _actual.collectorAgreement.maxSecondsPerCollection); } } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index 321c26df0..9f1abc180 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -166,10 +166,10 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA indexerState ); - // Create update with tokensPerSecond exceeding the RCA's maxOngoingTokensPerSecond - uint256 excessiveTokensPerSecond = acceptedRca.maxOngoingTokensPerSecond + 1; + // Create update with tokensPerSecond exceeding the RCAU's maxOngoingTokensPerSecond IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _generateAcceptableRecurringCollectionAgreementUpdate(ctx, acceptedRca); + uint256 excessiveTokensPerSecond = rcau.maxOngoingTokensPerSecond + 1; rcau.metadata = _encodeUpdateIndexingAgreementMetadataV1( IndexingAgreement.UpdateIndexingAgreementMetadata({ version: IIndexingAgreement.IndexingAgreementVersion.V1, @@ -190,7 +190,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA bytes memory expectedErr = abi.encodeWithSelector( IndexingAgreement.IndexingAgreementInvalidTerms.selector, excessiveTokensPerSecond, - acceptedRca.maxOngoingTokensPerSecond + rcau.maxOngoingTokensPerSecond ); vm.expectRevert(expectedErr); resetPrank(indexerState.addr); From 8be1aa0c8cbc02b7785d35c7f69bb5b8021fc01d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 22 Apr 2026 08:03:24 +0000 Subject: [PATCH 104/157] refactor(collector): preparatory helpers, signatures, and version constants Assorted small refactors and interface tweaks that prepare for follow-on changes without changing behavior: - extract _rcaIdAndHash helper (agreement ID + RCA hash used together) - default _getMaxNextClaimScoped scope to both (active | pending) on 0 - drop redundant isSigned param from _requireAuthorization - drop redundant timestamp from agreement lifecycle events - single-line AgreementCanceled emit - add VERSION_CURRENT/VERSION_NEXT constants and clarify state flag NatSpec in IAgreementCollector --- .../collectors/RecurringCollector.sol | 98 +++++++++---------- .../recurring-collector/acceptUnsigned.t.sol | 1 - .../recurring-collector/mixedPath.t.sol | 2 - .../payments/recurring-collector/shared.t.sol | 2 - .../payments/recurring-collector/update.t.sol | 1 - .../recurring-collector/updateUnsigned.t.sol | 1 - .../contracts/horizon/IAgreementCollector.sol | 66 ++++++++++--- .../contracts/horizon/IRecurringCollector.sol | 6 -- .../indexing-agreement/integration.t.sol | 1 - 9 files changed, 95 insertions(+), 83 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 52ea3aaa9..6360fc7d7 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -210,7 +210,7 @@ contract RecurringCollector is function accept( RecurringCollectionAgreement calldata rca, bytes calldata signature - ) external whenNotPaused returns (bytes16) { + ) external whenNotPaused returns (bytes16 agreementId) { /* solhint-disable gas-strict-inequalities */ require( rca.deadline >= block.timestamp, @@ -218,17 +218,10 @@ contract RecurringCollector is ); /* solhint-enable gas-strict-inequalities */ - bool isSigned = 0 < signature.length; - bytes32 rcaHash = _hashRCA(rca); - bytes16 agreementId = _generateAgreementId( - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.deadline, - rca.nonce - ); + bytes32 rcaHash; + (agreementId, rcaHash) = _rcaIdAndHash(rca); - _requireAuthorization(rca.payer, rcaHash, signature, isSigned, agreementId, OFFER_TYPE_NEW); + _requireAuthorization(rca.payer, rcaHash, signature, agreementId, OFFER_TYPE_NEW); return _validateAndStoreAgreement(rca, agreementId, rcaHash); } @@ -285,7 +278,6 @@ contract RecurringCollector is agreement.payer, agreement.serviceProvider, agreementId, - agreement.acceptedAt, agreement.endsAt, agreement.maxInitialTokens, agreement.maxOngoingTokensPerSecond, @@ -320,14 +312,7 @@ contract RecurringCollector is agreement.state = AgreementState.CanceledByServiceProvider; } - emit AgreementCanceled( - agreement.dataService, - agreement.payer, - agreement.serviceProvider, - agreementId, - agreement.canceledAt, - by - ); + emit AgreementCanceled(agreement.dataService, agreement.payer, agreement.serviceProvider, agreementId, by); } /** @@ -347,10 +332,9 @@ contract RecurringCollector is ); /* solhint-enable gas-strict-inequalities */ - bool isSigned = 0 < signature.length; bytes32 rcauHash = _hashRCAU(rcau); - _requireAuthorization(agreement.payer, rcauHash, signature, isSigned, rcau.agreementId, OFFER_TYPE_UPDATE); + _requireAuthorization(agreement.payer, rcauHash, signature, rcau.agreementId, OFFER_TYPE_UPDATE); _validateAndStoreUpdate(agreement, rcau, rcauHash); } @@ -395,7 +379,7 @@ contract RecurringCollector is /// @inheritdoc IAgreementCollector function getMaxNextClaim(bytes16 agreementId) external view returns (uint256) { - return _getMaxNextClaimScoped(agreementId, SCOPE_ACTIVE | SCOPE_PENDING); + return _getMaxNextClaimScoped(agreementId, 0); } /// @inheritdoc IRecurringCollector @@ -430,28 +414,22 @@ contract RecurringCollector is function _offerNew(bytes calldata _data) private returns (AgreementDetails memory details) { RecurringCollectorStorage storage $ = _getStorage(); RecurringCollectionAgreement memory rca = abi.decode(_data, (RecurringCollectionAgreement)); + + (bytes16 agreementId, bytes32 rcaHash) = _rcaIdAndHash(rca); + require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); - bytes16 agreementId = _generateAgreementId( - rca.payer, - rca.dataService, - rca.serviceProvider, - rca.deadline, - rca.nonce - ); - bytes32 offerHash = _hashRCA(rca); - - $.rcaOffers[agreementId] = StoredOffer({ offerHash: offerHash, data: _data }); + $.rcaOffers[agreementId] = StoredOffer({ offerHash: rcaHash, data: _data }); details.agreementId = agreementId; details.payer = rca.payer; details.dataService = rca.dataService; details.serviceProvider = rca.serviceProvider; - details.versionHash = offerHash; + details.versionHash = rcaHash; details.state = REGISTERED; - emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, offerHash); + emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, rcaHash); } /** @@ -974,8 +952,7 @@ contract RecurringCollector is * @notice Verifies authorization for an EIP712 hash using the given basis. * @param _payer The payer address (signer owner for ECDSA, contract for approval) * @param _hash The EIP712 typed data hash - * @param _signature The ECDSA signature (only used when basis is Signature) - * @param _isSigned True if ECDSA-signed, false if pre-approved via stored offer + * @param _signature The ECDSA signature bytes, zero length for no signature (pre-approved via stored offer) * @param _agreementId The agreement ID (used to look up stored offer when not signed) * @param _offerType OFFER_TYPE_NEW or OFFER_TYPE_UPDATE (selects which stored offer to check) */ @@ -983,13 +960,12 @@ contract RecurringCollector is address _payer, bytes32 _hash, bytes memory _signature, - bool _isSigned, bytes16 _agreementId, uint8 _offerType ) private view { RecurringCollectorStorage storage $ = _getStorage(); - if (_isSigned) + if (0 < _signature.length) require(_isAuthorized(_payer, ECDSA.recover(_hash, _signature)), RecurringCollectorInvalidSigner()); else // Check stored offer hash instead of callback @@ -1065,7 +1041,6 @@ contract RecurringCollector is _agreement.payer, _agreement.serviceProvider, _rcau.agreementId, - uint64(block.timestamp), _agreement.endsAt, _agreement.maxInitialTokens, _agreement.maxOngoingTokensPerSecond, @@ -1161,8 +1136,7 @@ contract RecurringCollector is // Only Accepted and CanceledByPayer are collectable if (_a.state != AgreementState.Accepted && _a.state != AgreementState.CanceledByPayer) return 0; - // Collection starts from last collection (or acceptance if never collected) - uint256 collectionStart = 0 < _a.lastCollectionAt ? _a.lastCollectionAt : _a.acceptedAt; + uint256 collectionStart = _agreementCollectionStartAt(_a); // Determine the latest possible collection end uint256 collectionEnd; @@ -1194,12 +1168,11 @@ contract RecurringCollector is * @return maxClaim The maximum tokens claimable under the requested scope */ function _getMaxNextClaimScoped(bytes16 agreementId, uint8 agreementScope) private view returns (uint256 maxClaim) { + if (agreementScope == 0) agreementScope = SCOPE_ACTIVE | SCOPE_PENDING; + RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage _a = $.agreements[agreementId]; - uint256 maxActiveClaim = 0; - uint256 maxPendingClaim = 0; - if (agreementScope & SCOPE_ACTIVE != 0) { if (_a.state == AgreementState.NotAccepted) { // Not yet accepted — check stored RCA offer @@ -1207,19 +1180,16 @@ contract RecurringCollector is if (rcaOffer.offerHash != bytes32(0)) { RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); // Use block.timestamp as proxy for acceptedAt, deadline as expiry - if (block.timestamp < rca.deadline) { - maxActiveClaim = _maxClaim( + if (block.timestamp < rca.deadline) + maxClaim = _maxClaim( block.timestamp, rca.endsAt, rca.maxSecondsPerCollection, rca.maxOngoingTokensPerSecond, rca.maxInitialTokens ); - } } - } else { - maxActiveClaim = _getMaxNextClaim(_a); - } + } else maxClaim = _getMaxNextClaim(_a); } if (agreementScope & SCOPE_PENDING != 0) { @@ -1230,17 +1200,17 @@ contract RecurringCollector is (RecurringCollectionAgreementUpdate) ); // Ongoing claim: time-capped from now to rcau.endsAt - maxPendingClaim = _maxClaim( + uint256 maxPendingClaim = _maxClaim( block.timestamp, rcau.endsAt, rcau.maxSecondsPerCollection, rcau.maxOngoingTokensPerSecond, _a.lastCollectionAt == 0 ? rcau.maxInitialTokens : 0 ); + + if (maxClaim < maxPendingClaim) maxClaim = maxPendingClaim; } } - - maxClaim = maxActiveClaim < maxPendingClaim ? maxPendingClaim : maxActiveClaim; } /** @@ -1300,4 +1270,24 @@ contract RecurringCollector is ) private pure returns (bytes16) { return bytes16(keccak256(abi.encode(payer, dataService, serviceProvider, deadline, nonce))); } + + /** + * @notice Compute the agreement ID and EIP-712 hash for an RCA. + * @dev These are always used together when accepting or offering an RCA. + * @param _rca The Recurring Collection Agreement + * @return agreementId The deterministic agreement ID + * @return rcaHash The EIP-712 hash of the RCA + */ + function _rcaIdAndHash( + RecurringCollectionAgreement memory _rca + ) private view returns (bytes16 agreementId, bytes32 rcaHash) { + agreementId = _generateAgreementId( + _rca.payer, + _rca.dataService, + _rca.serviceProvider, + _rca.deadline, + _rca.nonce + ); + rcaHash = _hashRCA(_rca); + } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol index 7feca10c9..fb26e3d99 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol @@ -60,7 +60,6 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { rca.payer, rca.serviceProvider, expectedId, - uint64(block.timestamp), rca.endsAt, rca.maxInitialTokens, rca.maxOngoingTokensPerSecond, diff --git a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol index f81aa0f04..120214815 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol @@ -64,7 +64,6 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { address(approver), rca.serviceProvider, agreementId, - uint64(block.timestamp), rcau.endsAt, rcau.maxInitialTokens, rcau.maxOngoingTokensPerSecond, @@ -185,7 +184,6 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { payer, rca.serviceProvider, agreementId, - uint64(block.timestamp), rcau.endsAt, rcau.maxInitialTokens, rcau.maxOngoingTokensPerSecond, diff --git a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol index 3e88525e9..2d90e7142 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/shared.t.sol @@ -120,7 +120,6 @@ contract RecurringCollectorSharedTest is Test, Bounder { _rca.payer, _rca.serviceProvider, expectedAgreementId, - uint64(block.timestamp), _rca.endsAt, _rca.maxInitialTokens, _rca.maxOngoingTokensPerSecond, @@ -165,7 +164,6 @@ contract RecurringCollectorSharedTest is Test, Bounder { _rca.payer, _rca.serviceProvider, _agreementId, - uint64(block.timestamp), _by ); vm.prank(_rca.dataService); diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index be84dde2f..57e8f0ad3 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -143,7 +143,6 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { acceptedRca.payer, acceptedRca.serviceProvider, rcau.agreementId, - uint64(block.timestamp), rcau.endsAt, rcau.maxInitialTokens, rcau.maxOngoingTokensPerSecond, diff --git a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol index 45d05c55b..84eab9b75 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol @@ -87,7 +87,6 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { rca.payer, rca.serviceProvider, agreementId, - uint64(block.timestamp), rcau.endsAt, rcau.maxInitialTokens, rcau.maxOngoingTokensPerSecond, diff --git a/packages/interfaces/contracts/horizon/IAgreementCollector.sol b/packages/interfaces/contracts/horizon/IAgreementCollector.sol index 0d83cf904..3e2d694fc 100644 --- a/packages/interfaces/contracts/horizon/IAgreementCollector.sol +++ b/packages/interfaces/contracts/horizon/IAgreementCollector.sol @@ -3,11 +3,13 @@ pragma solidity ^0.8.22; import { IPaymentsCollector } from "./IPaymentsCollector.sol"; -// -- Agreement state flags -- +// -- State flags for AgreementDetails -- +// Describe the queried version in context of its agreement; returned by both +// offer() and getAgreementDetails(). See AgreementDetails.state NatSpec. -/// @dev Offer exists in storage +/// @dev Offer exists in storage. Implied by ACCEPTED. uint16 constant REGISTERED = 1; -/// @dev Provider accepted terms +/// @dev Provider accepted terms. Always returned with REGISTERED set (accepted terms were stored). uint16 constant ACCEPTED = 2; /// @dev The agreement's collection window has been truncated (e.g. by cancellation). /// Paired with a BY_* flag identifying the origin. @@ -25,9 +27,8 @@ uint16 constant BY_PROVIDER = 32; // -- Update-origin flag -- -/// @dev Terms originated from an RCAU (update), not the initial RCA. -/// Set on agreement state when active terms come from an accepted or pre-acceptance update. -/// ORed into returned state by getAgreementDetails for pending versions (index 1). +/// @dev This version's terms originated from an update, not the initial agreement offer. +/// Describes the version's provenance; set wherever the update-derived version is returned. uint16 constant UPDATE = 128; // -- Offer type constants -- @@ -47,6 +48,19 @@ uint8 constant SCOPE_ACTIVE = 1; /// @dev Cancel targets pending offers uint8 constant SCOPE_PENDING = 2; +// -- Version indices (shared by getAgreementDetails and getAgreementOfferAt) -- +// +// Versions are enumerated starting at 0. Implementations may expose any number of versions; +// callers iterate until an empty result signals no further versions. These named aliases +// cover the two versions every collector is expected to expose. + +/// @dev The currently-active version: the accepted terms if the agreement is accepted, +/// otherwise the pre-acceptance offer (if any). Empty when no agreement or offer exists. +uint256 constant VERSION_CURRENT = 0; +/// @dev The next queued version: a pending update offer waiting to be accepted. +/// Empty when no queued update exists. +uint256 constant VERSION_NEXT = 1; + /** * @title Base interface for agreement-based payment collectors * @notice Base interface for agreement-based payment collectors. @@ -64,12 +78,21 @@ interface IAgreementCollector is IPaymentsCollector { /** * @notice Agreement details: participants, version hash, and state flags. * Returned by {offer} and {getAgreementDetails}. + * + * The `state` field describes the version identified by `versionHash` in the + * context of its agreement. Version-specific flags (REGISTERED, ACCEPTED, + * UPDATE, SETTLED) are set only when they apply to that specific version; + * agreement-wide flags (NOTICE_GIVEN, BY_PAYER, BY_PROVIDER) reflect the + * current agreement state. Identical semantics whether returned by {offer} + * or {getAgreementDetails} — the returned flags always describe the queried + * version. + * * @param agreementId The agreement ID * @param payer The address of the payer * @param dataService The address of the data service * @param serviceProvider The address of the service provider * @param versionHash The EIP-712 hash of the terms at the requested version - * @param state Agreement state flags, with UPDATE set when applicable + * @param state State flags describing the queried version in context of its agreement */ // solhint-disable-next-line gas-struct-packing struct AgreementDetails { @@ -94,6 +117,11 @@ interface IAgreementCollector is IPaymentsCollector { /** * @notice Offer a new agreement or update an existing one. + * @dev Returns {AgreementDetails} for the just-stored offer. The `state` field + * describes that version in context of its agreement (see {AgreementDetails}): + * version-specific flags (REGISTERED, ACCEPTED, UPDATE, SETTLED) are set when + * they apply to the offered version; agreement-wide flags (NOTICE_GIVEN, BY_*) + * reflect current agreement state. * @param offerType The type of offer (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) * @param data ABI-encoded offer data * @param options Bitmask reserved for implementation-specific options; pass 0 when none apply. @@ -103,17 +131,23 @@ interface IAgreementCollector is IPaymentsCollector { function offer(uint8 offerType, bytes calldata data, uint16 options) external returns (AgreementDetails memory); /** - * @notice Cancel an agreement or revoke a pending update, determined by termsHash. + * @notice Cancel an agreement or revoke a pending offer. + * @dev Scopes can be combined. SCOPE_PENDING and SCOPE_ACTIVE require payer authorization + * and no-op if nothing exists on-chain. * @param agreementId The agreement's ID. - * @param termsHash EIP-712 hash identifying which terms to cancel (active or pending). - * @param options Bitmask — SCOPE_ACTIVE (1) targets active terms, SCOPE_PENDING (2) targets pending offers. + * @param termsHash EIP-712 hash identifying which terms to cancel. + * @param options Bitmask — SCOPE_ACTIVE (1) active terms, SCOPE_PENDING (2) pending offers. */ function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external; /** * @notice Get agreement details at a given version index. + * @dev Versions are enumerated from 0. VERSION_CURRENT is the active version (or + * pre-acceptance offer); VERSION_NEXT is the queued pending update, if any. Empty + * details are returned when no version exists at the requested index — callers can + * iterate versions until reaching an empty result. * @param agreementId The ID of the agreement - * @param index The zero-based version index + * @param index Version index (VERSION_CURRENT, VERSION_NEXT, or higher if the implementation supports more) * @return Agreement details including participants, version hash, and state flags */ function getAgreementDetails(bytes16 agreementId, uint256 index) external view returns (AgreementDetails memory); @@ -134,11 +168,13 @@ interface IAgreementCollector is IPaymentsCollector { function getMaxNextClaim(bytes16 agreementId) external view returns (uint256); /** - * @notice Original offer for a given version, enabling independent access and hash verification. - * @dev Returns the offer type (OFFER_TYPE_NEW or OFFER_TYPE_UPDATE) and the ABI-encoded - * original struct. Callers can decode and hash to verify the stored version hash. + * @notice Original offer data for a given version index, enabling independent access and hash verification. + * @dev Returns the offer type and the ABI-encoded original struct so callers can decode + * and rehash to verify the version hash returned by getAgreementDetails. Version semantics + * mirror getAgreementDetails, but empty data is returned when the version's offer was not + * stored (e.g. signed acceptance without a prior offer(), or overwritten by a later update). * @param agreementId The ID of the agreement - * @param index The zero-based version index + * @param index Version index (VERSION_CURRENT, VERSION_NEXT, or higher if supported) * @return offerType OFFER_TYPE_NEW, OFFER_TYPE_UPDATE, or OFFER_TYPE_NONE when no offer is stored * @return offerData ABI-encoded original offer struct, or empty when offerType is OFFER_TYPE_NONE */ diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 33501f940..6315033e2 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -164,7 +164,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { * @param payer The address of the payer * @param serviceProvider The address of the service provider * @param agreementId The agreement ID - * @param acceptedAt The timestamp when the agreement was accepted * @param endsAt The timestamp when the agreement ends * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second @@ -176,7 +175,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { address indexed payer, address indexed serviceProvider, bytes16 agreementId, - uint64 acceptedAt, uint64 endsAt, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, @@ -190,7 +188,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { * @param payer The address of the payer * @param serviceProvider The address of the service provider * @param agreementId The agreement ID - * @param canceledAt The timestamp when the agreement was canceled * @param canceledBy The party that canceled the agreement */ event AgreementCanceled( @@ -198,7 +195,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { address indexed payer, address indexed serviceProvider, bytes16 agreementId, - uint64 canceledAt, CancelAgreementBy canceledBy ); @@ -208,7 +204,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { * @param payer The address of the payer * @param serviceProvider The address of the service provider * @param agreementId The agreement ID - * @param updatedAt The timestamp when the agreement was updated * @param endsAt The timestamp when the agreement ends * @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection * @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second @@ -220,7 +215,6 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { address indexed payer, address indexed serviceProvider, bytes16 agreementId, - uint64 updatedAt, uint64 endsAt, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol index 609a91b46..45f31e527 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol @@ -139,7 +139,6 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex acceptedRca.payer, acceptedRca.serviceProvider, agreementId, - uint64(block.timestamp), IRecurringCollector.CancelAgreementBy.Payer ); From cfaf39b210637de8dbc30c15294bcd61a6323876 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:18:30 +0000 Subject: [PATCH 105/157] refactor(collector): drop unreachable agreementId-zero check --- .../horizon/contracts/payments/collectors/RecurringCollector.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 6360fc7d7..24c33c550 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -237,7 +237,6 @@ contract RecurringCollector is bytes16 agreementId, bytes32 _rcaHash ) private returns (bytes16) { - require(agreementId != bytes16(0), RecurringCollectorAgreementIdZero()); require(msg.sender == _rca.dataService, RecurringCollectorUnauthorizedCaller(msg.sender, _rca.dataService)); require( From 35748ff47830c428ed67c9a12b12c44f3215869e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:29:24 +0000 Subject: [PATCH 106/157] refactor(collector): extract _requireValidTerms from duplicated validation The (window params + eligibility + overflow) triple was duplicated in _validateAndStoreAgreement and _validateAndStoreUpdate. Extract into _requireValidTerms. No behaviour change. --- .../collectors/RecurringCollector.sol | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 24c33c550..64d72f2f9 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -244,9 +244,6 @@ contract RecurringCollector is RecurringCollectorAgreementAddressNotSet() ); - _requireValidCollectionWindowParams(_rca.endsAt, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection); - _requirePayerToSupportEligibilityCheck(_rca.payer, _rca.conditions); - AgreementData storage agreement = _getAgreementStorage(agreementId); // check that the agreement is not already accepted require( @@ -254,8 +251,10 @@ contract RecurringCollector is RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) ); - // Reverts on overflow — rejecting excessive terms that could prevent collection - _rca.maxOngoingTokensPerSecond * _rca.maxSecondsPerCollection * 1024; + _requireValidTerms( + _rca.endsAt, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection, + _rca.payer, _rca.conditions, _rca.maxOngoingTokensPerSecond + ); // accept the agreement agreement.acceptedAt = uint64(block.timestamp); @@ -816,6 +815,30 @@ contract RecurringCollector is ); } + /** + * @notice Validates offer terms: collection window, eligibility support, and overflow. + * @dev Called by _validateAndStoreAgreement and _validateAndStoreUpdate. + * @param _endsAt The end time of the agreement + * @param _minSecondsPerCollection The minimum seconds per collection + * @param _maxSecondsPerCollection The maximum seconds per collection + * @param _payer The payer address (for eligibility validation) + * @param _conditions The conditions bitmask + * @param _maxOngoingTokensPerSecond The maximum ongoing tokens per second + */ + function _requireValidTerms( + uint64 _endsAt, + uint32 _minSecondsPerCollection, + uint32 _maxSecondsPerCollection, + address _payer, + uint16 _conditions, + uint256 _maxOngoingTokensPerSecond + ) private view { + _requireValidCollectionWindowParams(_endsAt, _minSecondsPerCollection, _maxSecondsPerCollection); + _requirePayerToSupportEligibilityCheck(_payer, _conditions); + // Reverts on overflow — rejecting excessive terms that could prevent collection + _maxOngoingTokensPerSecond * _maxSecondsPerCollection * 1024; + } + /** * @notice Validates temporal constraints and caps the requested token amount. * @dev Enforces `minSecondsPerCollection` (unless canceled/elapsed) and returns the lesser of @@ -1014,11 +1037,10 @@ contract RecurringCollector is RecurringCollectorInvalidUpdateNonce(_rcau.agreementId, expectedNonce, _rcau.nonce) ); - _requireValidCollectionWindowParams(_rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection); - _requirePayerToSupportEligibilityCheck(_agreement.payer, _rcau.conditions); - - // Reverts on overflow — rejecting excessive terms that could prevent collection - _rcau.maxOngoingTokensPerSecond * _rcau.maxSecondsPerCollection * 1024; + _requireValidTerms( + _rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection, + _agreement.payer, _rcau.conditions, _rcau.maxOngoingTokensPerSecond + ); // Clean up stored replaced offer. oldHash is always non-zero for accepted agreements // and can only ever survive in rcaOffers. From 0ad0be4fd68546fd5f874b038194156fdd2bc9fc Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:42:54 +0000 Subject: [PATCH 107/157] refactor(collector): split accept logic out of _validateAndStoreAgreement Move the state flip (acceptedAt, state=Accepted) and AgreementAccepted event from _validateAndStoreAgreement into accept() inline. Use rca.* for the event instead of re-reading from storage. The function now only validates and registers (identity + terms). --- .../collectors/RecurringCollector.sol | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 64d72f2f9..d2e0ceab0 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -223,20 +223,41 @@ contract RecurringCollector is _requireAuthorization(rca.payer, rcaHash, signature, agreementId, OFFER_TYPE_NEW); - return _validateAndStoreAgreement(rca, agreementId, rcaHash); + _validateAndStoreAgreement(rca, agreementId, rcaHash); + + AgreementData storage agreement = _getStorage().agreements[agreementId]; + require( + agreement.state == AgreementState.NotAccepted, + RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) + ); + agreement.acceptedAt = uint64(block.timestamp); + agreement.state = AgreementState.Accepted; + + emit AgreementAccepted( + rca.dataService, + rca.payer, + rca.serviceProvider, + agreementId, + rca.endsAt, + rca.maxInitialTokens, + rca.maxOngoingTokensPerSecond, + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection + ); } /** - * @notice Validates RCA fields and stores the agreement. + * @notice Validates RCA fields and registers the agreement (identity + terms). + * Does not flip state to Accepted — caller handles the accept step. * @param _rca The Recurring Collection Agreement to validate and store - * @return agreementId The deterministically generated agreement ID + * @param agreementId The deterministic agreement ID + * @param _rcaHash The EIP-712 hash of the RCA */ - /* solhint-disable function-max-lines */ function _validateAndStoreAgreement( RecurringCollectionAgreement memory _rca, bytes16 agreementId, bytes32 _rcaHash - ) private returns (bytes16) { + ) private { require(msg.sender == _rca.dataService, RecurringCollectorUnauthorizedCaller(msg.sender, _rca.dataService)); require( @@ -245,7 +266,6 @@ contract RecurringCollector is ); AgreementData storage agreement = _getAgreementStorage(agreementId); - // check that the agreement is not already accepted require( agreement.state == AgreementState.NotAccepted, RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) @@ -256,9 +276,6 @@ contract RecurringCollector is _rca.payer, _rca.conditions, _rca.maxOngoingTokensPerSecond ); - // accept the agreement - agreement.acceptedAt = uint64(block.timestamp); - agreement.state = AgreementState.Accepted; agreement.dataService = _rca.dataService; agreement.payer = _rca.payer; agreement.serviceProvider = _rca.serviceProvider; @@ -270,22 +287,7 @@ contract RecurringCollector is agreement.conditions = _rca.conditions; agreement.activeTermsHash = _rcaHash; agreement.updateNonce = 0; - - emit AgreementAccepted( - agreement.dataService, - agreement.payer, - agreement.serviceProvider, - agreementId, - agreement.endsAt, - agreement.maxInitialTokens, - agreement.maxOngoingTokensPerSecond, - agreement.minSecondsPerCollection, - agreement.maxSecondsPerCollection - ); - - return agreementId; } - /* solhint-enable function-max-lines */ /** * @inheritdoc IRecurringCollector From bfe77547df11d8c1b86a86181f96086fc908c819 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:44:13 +0000 Subject: [PATCH 108/157] refactor(collector): split update apply out of _validateAndStoreUpdate Move nonce check, nonce write, and AgreementUpdated event from _validateAndStoreUpdate into update() inline. Use rcau.* for event fields. The function now only validates terms and writes them to storage; update() handles lifecycle (nonce, event). --- .../collectors/RecurringCollector.sol | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index d2e0ceab0..526d1abd6 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -336,7 +336,26 @@ contract RecurringCollector is _requireAuthorization(agreement.payer, rcauHash, signature, rcau.agreementId, OFFER_TYPE_UPDATE); + uint32 expectedNonce = agreement.updateNonce + 1; + require( + rcau.nonce == expectedNonce, + RecurringCollectorInvalidUpdateNonce(rcau.agreementId, expectedNonce, rcau.nonce) + ); + _validateAndStoreUpdate(agreement, rcau, rcauHash); + agreement.updateNonce = rcau.nonce; + + emit AgreementUpdated( + agreement.dataService, + agreement.payer, + agreement.serviceProvider, + rcau.agreementId, + rcau.endsAt, + rcau.maxInitialTokens, + rcau.maxOngoingTokensPerSecond, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection + ); } /// @inheritdoc IRecurringCollector @@ -1032,13 +1051,6 @@ contract RecurringCollector is ) private { RecurringCollectorStorage storage $ = _getStorage(); - // validate nonce to prevent replay attacks - uint32 expectedNonce = _agreement.updateNonce + 1; - require( - _rcau.nonce == expectedNonce, - RecurringCollectorInvalidUpdateNonce(_rcau.agreementId, expectedNonce, _rcau.nonce) - ); - _requireValidTerms( _rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection, _agreement.payer, _rcau.conditions, _rcau.maxOngoingTokensPerSecond @@ -1049,7 +1061,7 @@ contract RecurringCollector is if ($.rcaOffers[_rcau.agreementId].offerHash == _agreement.activeTermsHash) delete $.rcaOffers[_rcau.agreementId]; - // update the agreement + // update the agreement terms _agreement.endsAt = _rcau.endsAt; _agreement.maxInitialTokens = _rcau.maxInitialTokens; _agreement.maxOngoingTokensPerSecond = _rcau.maxOngoingTokensPerSecond; @@ -1057,19 +1069,6 @@ contract RecurringCollector is _agreement.maxSecondsPerCollection = _rcau.maxSecondsPerCollection; _agreement.conditions = _rcau.conditions; _agreement.activeTermsHash = _rcauHash; - _agreement.updateNonce = _rcau.nonce; - - emit AgreementUpdated( - _agreement.dataService, - _agreement.payer, - _agreement.serviceProvider, - _rcau.agreementId, - _agreement.endsAt, - _agreement.maxInitialTokens, - _agreement.maxOngoingTokensPerSecond, - _agreement.minSecondsPerCollection, - _agreement.maxSecondsPerCollection - ); } /** From 594d19b074a057822cf625e7c137448f382d6f33 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:44:04 +0000 Subject: [PATCH 109/157] feat(subgraph-service): idempotent accept/update with allocation rebinding Defer state authority to the collector and align SS-side semantics for duplicate calls and re-acceptance with a different allocation: - update(): _isValid replaces _isActive; an activeTermsHash match short-circuits the SS-side event and terms re-write. - accept(): same-allocation re-accept is an idempotent no-op at the SS layer; different-allocation re-accept rebinds the agreement by clearing the old allocationToActiveAgreementId link and establishing the new one. Enables moving an active agreement to a new allocation when the original is closed. --- .../contracts/libraries/IndexingAgreement.sol | 90 ++++++++------- .../indexing-agreement/accept.t.sol | 105 ++++++++++++++++-- .../indexing-agreement/update.t.sol | 24 ++++ 3 files changed, 169 insertions(+), 50 deletions(-) diff --git a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol index 347eed37e..8516334f4 100644 --- a/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol +++ b/packages/subgraph-service/contracts/libraries/IndexingAgreement.sol @@ -218,12 +218,6 @@ library IndexingAgreement { bytes32 allocationDeploymentId ); - /** - * @notice Thrown when the agreement is already accepted - * @param agreementId The agreement ID - */ - error IndexingAgreementAlreadyAccepted(bytes16 agreementId); - /** * @notice Thrown when an allocation already has an active agreement * @param allocationId The allocation ID @@ -310,42 +304,48 @@ library IndexingAgreement { IIndexingAgreement.State storage agreement = self.agreements[agreementId]; - require(agreement.allocationId == address(0), IndexingAgreementAlreadyAccepted(agreementId)); - - require( - allocation.subgraphDeploymentId == metadata.subgraphDeploymentId, - IndexingAgreementDeploymentIdMismatch( - metadata.subgraphDeploymentId, + // Accept is idempotent for the same allocation, and supports moving + // the agreement to a different allocation. The collector's accept handles state + // validity (reverts if the agreement is cancelled, no-ops if already accepted). + if (agreement.allocationId != allocationId) { + require( + allocation.subgraphDeploymentId == metadata.subgraphDeploymentId, + IndexingAgreementDeploymentIdMismatch( + metadata.subgraphDeploymentId, + allocationId, + allocation.subgraphDeploymentId + ) + ); + + // Ensure that an allocation can only have one active indexing agreement + require( + self.allocationToActiveAgreementId[allocationId] == bytes16(0), + AllocationAlreadyHasIndexingAgreement(allocationId) + ); + + if (agreement.allocationId != address(0)) delete self.allocationToActiveAgreementId[agreement.allocationId]; + agreement.allocationId = allocationId; + + self.allocationToActiveAgreementId[allocationId] = agreementId; + + agreement.version = metadata.version; + + require( + metadata.version == IIndexingAgreement.IndexingAgreementVersion.V1, + IndexingAgreementInvalidVersion(metadata.version) + ); + _setTermsV1(self, agreementId, metadata.terms, rca.maxOngoingTokensPerSecond); + + emit IndexingAgreementAccepted( + rca.serviceProvider, + rca.payer, + agreementId, allocationId, - allocation.subgraphDeploymentId - ) - ); - - // Ensure that an allocation can only have one active indexing agreement - require( - self.allocationToActiveAgreementId[allocationId] == bytes16(0), - AllocationAlreadyHasIndexingAgreement(allocationId) - ); - self.allocationToActiveAgreementId[allocationId] = agreementId; - - agreement.version = metadata.version; - agreement.allocationId = allocationId; - - require( - metadata.version == IIndexingAgreement.IndexingAgreementVersion.V1, - IndexingAgreementInvalidVersion(metadata.version) - ); - _setTermsV1(self, agreementId, metadata.terms, rca.maxOngoingTokensPerSecond); - - emit IndexingAgreementAccepted( - rca.serviceProvider, - rca.payer, - agreementId, - allocationId, - metadata.subgraphDeploymentId, - metadata.version, - metadata.terms - ); + metadata.subgraphDeploymentId, + metadata.version, + metadata.terms + ); + } require( _directory().recurringCollector().accept(rca, authData) == agreementId, @@ -380,12 +380,18 @@ library IndexingAgreement { bytes calldata authData ) external { IIndexingAgreement.AgreementWrapper memory wrapper = _get(self, rcau.agreementId); - require(_isActive(wrapper), IndexingAgreementNotActive(rcau.agreementId)); + // SS gate: only checks that this is an SS-managed, tracked agreement. Collector is the + // state authority — it reverts if the agreement cannot actually accept an update. + require(_isValid(wrapper), IndexingAgreementNotActive(rcau.agreementId)); require( wrapper.collectorAgreement.serviceProvider == indexer, IndexingAgreementNotAuthorized(rcau.agreementId, indexer) ); + // Idempotent: this RCAU is already the active version — both SS terms and collector state + // are in sync because both are written together on the original update. + if (wrapper.collectorAgreement.activeTermsHash == _directory().recurringCollector().hashRCAU(rcau)) return; + UpdateIndexingAgreementMetadata memory metadata = IndexingAgreementDecoder.decodeRCAUMetadata(rcau.metadata); require( diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index 1d2e2b9fb..b2853949d 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -5,6 +5,7 @@ import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/P import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol"; +import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol"; import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol"; @@ -231,7 +232,9 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg subgraphService.acceptIndexingAgreement(indexerState.allocationId, unacceptableRca, signature); } - function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAccepted(Seed memory seed) public { + function test_SubgraphService_AcceptIndexingAgreement_Idempotent_WhenAlreadyAcceptedSameAllocation( + Seed memory seed + ) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); ( @@ -239,19 +242,20 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg bytes16 agreementId ) = _withAcceptedIndexingAgreement(ctx, indexerState); - // Re-sign for the re-accept attempt (the original signature was consumed) + // Re-sign for the re-accept (the original signature was consumed) (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA( acceptedRca, ctx.payer.signerPrivateKey ); - bytes memory expectedErr = abi.encodeWithSelector( - IndexingAgreement.IndexingAgreementAlreadyAccepted.selector, - agreementId - ); - vm.expectRevert(expectedErr); + // Re-accepting the same RCA on the same allocation is a no-op. resetPrank(ctx.indexers[0].addr); - subgraphService.acceptIndexingAgreement(ctx.indexers[0].allocationId, acceptedRca, signature); + bytes16 returnedId = subgraphService.acceptIndexingAgreement( + ctx.indexers[0].allocationId, + acceptedRca, + signature + ); + assertEq(returnedId, agreementId); } function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated( @@ -384,5 +388,90 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg resetPrank(indexerState.addr); subgraphService.acceptIndexingAgreement(indexerState.allocationId, acceptableRca, signature); } + + function test_SubgraphService_AcceptIndexingAgreement_Rebinds_WhenDifferentAllocation( + Seed memory seed, + uint256 secondAllocationKey + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Agreement is now bound to the first allocation. + IIndexingAgreement.AgreementWrapper memory before = subgraphService.getIndexingAgreement(agreementId); + assertEq(before.agreement.allocationId, indexerState.allocationId, "starts bound to first allocation"); + + // Derive a second allocation for the same indexer + same subgraph deployment. The first + // allocation already consumed the indexer's provision, so top up first. + uint256 extraTokens = 10_000_000 ether; + deal({ token: address(token), to: indexerState.addr, give: extraTokens }); + resetPrank(indexerState.addr); + _addToProvision(indexerState.addr, extraTokens); + + secondAllocationKey = boundKey(secondAllocationKey); + address secondAllocationId = vm.addr(secondAllocationKey); + vm.assume(secondAllocationId != indexerState.allocationId); + vm.assume(ctx.allocations[secondAllocationId] == address(0)); + ctx.allocations[secondAllocationId] = indexerState.addr; + + bytes memory allocData = _createSubgraphAllocationData( + indexerState.addr, + indexerState.subgraphDeploymentId, + secondAllocationKey, + extraTokens + ); + _startService(indexerState.addr, allocData); + + // Re-sign the same RCA (original signature was consumed on first accept). + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA( + acceptedRca, + ctx.payer.signerPrivateKey + ); + + // Re-accepting the same agreement on the new allocation rebinds it: + // event is re-emitted, agreement.allocationId updates, old allocation's active-agreement + // mapping is cleared. Collector's accept() is a no-op (already Accepted). + IndexingAgreement.AcceptIndexingAgreementMetadata memory metadata = abi.decode( + acceptedRca.metadata, + (IndexingAgreement.AcceptIndexingAgreementMetadata) + ); + vm.expectEmit(address(subgraphService)); + emit IndexingAgreement.IndexingAgreementAccepted( + acceptedRca.serviceProvider, + acceptedRca.payer, + agreementId, + secondAllocationId, + metadata.subgraphDeploymentId, + metadata.version, + metadata.terms + ); + resetPrank(indexerState.addr); + bytes16 returnedId = subgraphService.acceptIndexingAgreement(secondAllocationId, acceptedRca, signature); + assertEq(returnedId, agreementId, "rebind returns same agreementId"); + + IIndexingAgreement.AgreementWrapper memory rebound = subgraphService.getIndexingAgreement(agreementId); + assertEq(rebound.agreement.allocationId, secondAllocationId, "rebound to second allocation"); + assertEq( + uint8(rebound.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "collector state still Accepted after rebind" + ); + + // Closing the OLD allocation must not cancel the agreement — the agreement no longer + // points to it. onCloseAllocation's allocationToActiveAgreementId lookup should return 0. + resetPrank(indexerState.addr); + subgraphService.stopService(indexerState.addr, abi.encode(indexerState.allocationId)); + + IIndexingAgreement.AgreementWrapper memory afterOldClose = subgraphService.getIndexingAgreement(agreementId); + assertEq( + uint8(afterOldClose.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "closing old allocation leaves agreement intact" + ); + assertEq(afterOldClose.agreement.allocationId, secondAllocationId, "still bound to second allocation"); + } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol index 9f1abc180..dcd6bf32f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol @@ -227,5 +227,29 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA resetPrank(indexerState.addr); subgraphService.updateIndexingAgreement(indexerState.addr, acceptableRcau, authData); } + + function test_SubgraphService_UpdateIndexingAgreement_Idempotent_WhenAlreadyAtActiveHash(Seed memory seed) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + (IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, ) = _withAcceptedIndexingAgreement( + ctx, + indexerState + ); + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory acceptableRcau, + bytes memory authData + ) = _generateAcceptableSignedRCAU(ctx, acceptedRca); + + // First update sets activeTermsHash = hash(rcau) on the collector and applies SS terms. + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableRcau, authData); + + // Re-submitting the same RCAU is a no-op at the SS layer: + // the hash match short-circuits before re-emitting or re-writing terms. + vm.recordLogs(); + resetPrank(indexerState.addr); + subgraphService.updateIndexingAgreement(indexerState.addr, acceptableRcau, authData); + assertEq(vm.getRecordedLogs().length, 0, "no event emitted on idempotent re-update"); + } /* solhint-enable graph/func-name-mixedcase */ } From 885555e91defed01af61cb5a663e9ee7dbfed645 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:56:31 +0000 Subject: [PATCH 110/157] refactor(collector): hoist solhint-disable, idiomatic deadline comparisons Preparatory cleanup: - Hoist `solhint-disable gas-strict-inequalities` to file level; drop per-block/per-line fences and flip `deadline >= block.timestamp` callsites to the idiomatic `block.timestamp <= deadline`. --- .../payments/collectors/RecurringCollector.sol | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 526d1abd6..81fbe4fa0 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.27; +// solhint-disable gas-strict-inequalities + import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; @@ -211,12 +213,10 @@ contract RecurringCollector is RecurringCollectionAgreement calldata rca, bytes calldata signature ) external whenNotPaused returns (bytes16 agreementId) { - /* solhint-disable gas-strict-inequalities */ require( - rca.deadline >= block.timestamp, + block.timestamp <= rca.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) ); - /* solhint-enable gas-strict-inequalities */ bytes32 rcaHash; (agreementId, rcaHash) = _rcaIdAndHash(rca); @@ -325,12 +325,10 @@ contract RecurringCollector is function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external whenNotPaused { AgreementData storage agreement = _requireValidUpdateTarget(rcau.agreementId); - /* solhint-disable gas-strict-inequalities */ require( - rcau.deadline >= block.timestamp, + block.timestamp <= rcau.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rcau.deadline) ); - /* solhint-enable gas-strict-inequalities */ bytes32 rcauHash = _hashRCAU(rcau); @@ -658,12 +656,10 @@ contract RecurringCollector is if (_params.tokens != 0) { uint256 slippage = _params.tokens - tokensToCollect; - /* solhint-disable gas-strict-inequalities */ require( slippage <= _params.maxSlippage, RecurringCollectorExcessiveSlippage(_params.tokens, tokensToCollect, _params.maxSlippage) ); - /* solhint-enable gas-strict-inequalities */ } agreement.lastCollectionAt = uint64(block.timestamp); @@ -816,7 +812,6 @@ contract RecurringCollector is // Collection window needs to be at least MIN_SECONDS_COLLECTION_WINDOW require( _maxSecondsPerCollection > _minSecondsPerCollection && - // solhint-disable-next-line gas-strict-inequalities (_maxSecondsPerCollection - _minSecondsPerCollection >= MIN_SECONDS_COLLECTION_WINDOW), RecurringCollectorAgreementInvalidCollectionWindow( MIN_SECONDS_COLLECTION_WINDOW, @@ -827,7 +822,6 @@ contract RecurringCollector is // Agreement needs to last at least one min collection window require( - // solhint-disable-next-line gas-strict-inequalities _endsAt - block.timestamp >= _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, RecurringCollectorAgreementInvalidDuration( _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, @@ -881,7 +875,6 @@ contract RecurringCollector is block.timestamp > _agreement.endsAt; if (!canceledOrElapsed) { require( - // solhint-disable-next-line gas-strict-inequalities _collectionSeconds >= _agreement.minSecondsPerCollection, RecurringCollectorCollectionTooSoon( _agreementId, @@ -1253,7 +1246,6 @@ contract RecurringCollector is uint256 maxOngoingTokensPerSecond, uint256 maxInitialTokens ) private pure returns (uint256) { - // solhint-disable-next-line gas-strict-inequalities if (windowEnd <= windowStart) return 0; uint256 windowSeconds = windowEnd - windowStart; uint256 effectiveSeconds = windowSeconds < maxSecondsPerCollection ? windowSeconds : maxSecondsPerCollection; From 572853b01e5fe4262ed558568d4106748dac61fc Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 22 Apr 2026 14:50:51 +0000 Subject: [PATCH 111/157] fix(collector): validate offer terms against deadline, not block.timestamp Collection-window and duration checks now use the offer's acceptance deadline as the reference point instead of `block.timestamp`, making validation time-independent: if terms pass here they remain valid for any acceptance on or before `deadline`. Callers still enforce `block.timestamp <= deadline` at the acceptance entry point. - `_requireValidCollectionWindowParams` takes a `_deadline` parameter and becomes `pure`. `_endsAt > block.timestamp` becomes `_deadline < _endsAt`; `_endsAt - block.timestamp >= min + WINDOW` becomes `min + WINDOW <= _endsAt - _deadline`. - `_requireValidTerms` propagates `_deadline` to the window check. - Accept/update call sites pass the RCA/RCAU deadline. - Interface: replace `RecurringCollectorAgreementElapsedEndsAt` with `RecurringCollectorAgreementEndsBeforeDeadline(deadline, endsAt)`. Prerequisite for hash-keyed terms storage, where a single stored hash must remain validatable without re-checking against wall clock on every read. --- .../collectors/RecurringCollector.sol | 44 +++-- .../payments/recurring-collector/accept.t.sol | 167 ++++++++++++++++ .../acceptValidation.t.sol | 16 +- .../recurring-collector/afterCollection.t.sol | 2 +- .../recurring-collector/coverageGaps.t.sol | 73 +++++++ .../recurring-collector/getMaxNextClaim.t.sol | 184 ++++++++++++++++++ .../recurring-collector/hashRoundTrip.t.sol | 4 +- .../recurring-collector/mixedPath.t.sol | 83 +++++++- .../offerStorageLifecycle.t.sol | 35 ++-- .../recurring-collector/updateUnsigned.t.sol | 6 +- .../recurring-collector/upgradeScenario.t.sol | 2 +- .../recurring-collector/viewFunctions.t.sol | 17 +- .../contracts/horizon/IRecurringCollector.sol | 6 +- .../indexing-agreement/accept.t.sol | 58 ++++++ .../AgreementLifecycleAdvanced.t.sol | 82 ++++++++ 15 files changed, 711 insertions(+), 68 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 81fbe4fa0..79c8b4491 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -272,8 +272,13 @@ contract RecurringCollector is ); _requireValidTerms( - _rca.endsAt, _rca.minSecondsPerCollection, _rca.maxSecondsPerCollection, - _rca.payer, _rca.conditions, _rca.maxOngoingTokensPerSecond + _rca.deadline, + _rca.endsAt, + _rca.minSecondsPerCollection, + _rca.maxSecondsPerCollection, + _rca.payer, + _rca.conditions, + _rca.maxOngoingTokensPerSecond ); agreement.dataService = _rca.dataService; @@ -796,18 +801,23 @@ contract RecurringCollector is /** * @notice Requires that the collection window parameters are valid. - * + * @dev Validated against `_deadline` (the offer's acceptance deadline) rather than + * `block.timestamp`, making this check time-independent: if terms pass here they remain + * valid for any acceptance that happens on or before `_deadline`. Callers must enforce + * `block.timestamp <= _deadline` at the acceptance entry point. + * @param _deadline The offer's acceptance deadline * @param _endsAt The end time of the agreement * @param _minSecondsPerCollection The minimum seconds per collection * @param _maxSecondsPerCollection The maximum seconds per collection */ function _requireValidCollectionWindowParams( + uint64 _deadline, uint64 _endsAt, uint32 _minSecondsPerCollection, uint32 _maxSecondsPerCollection - ) private view { - // Agreement needs to end in the future - require(_endsAt > block.timestamp, RecurringCollectorAgreementElapsedEndsAt(block.timestamp, _endsAt)); + ) private pure { + // Agreement must end after the deadline + require(_deadline < _endsAt, RecurringCollectorAgreementEndsBeforeDeadline(_deadline, _endsAt)); // Collection window needs to be at least MIN_SECONDS_COLLECTION_WINDOW require( @@ -820,19 +830,21 @@ contract RecurringCollector is ) ); - // Agreement needs to last at least one min collection window + // Even if accepted at the deadline at least one min collection window must remain require( - _endsAt - block.timestamp >= _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, + _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW <= _endsAt - _deadline, RecurringCollectorAgreementInvalidDuration( _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW, - _endsAt - block.timestamp + _endsAt - _deadline ) ); } /** * @notice Validates offer terms: collection window, eligibility support, and overflow. - * @dev Called by _validateAndStoreAgreement and _validateAndStoreUpdate. + * @dev Called by _validateAndStoreAgreement and _validateAndStoreUpdate. Time-independent — + * validates against the offer's deadline so the check is stable across the offer's lifetime. + * @param _deadline The offer's acceptance deadline * @param _endsAt The end time of the agreement * @param _minSecondsPerCollection The minimum seconds per collection * @param _maxSecondsPerCollection The maximum seconds per collection @@ -841,6 +853,7 @@ contract RecurringCollector is * @param _maxOngoingTokensPerSecond The maximum ongoing tokens per second */ function _requireValidTerms( + uint64 _deadline, uint64 _endsAt, uint32 _minSecondsPerCollection, uint32 _maxSecondsPerCollection, @@ -848,7 +861,7 @@ contract RecurringCollector is uint16 _conditions, uint256 _maxOngoingTokensPerSecond ) private view { - _requireValidCollectionWindowParams(_endsAt, _minSecondsPerCollection, _maxSecondsPerCollection); + _requireValidCollectionWindowParams(_deadline, _endsAt, _minSecondsPerCollection, _maxSecondsPerCollection); _requirePayerToSupportEligibilityCheck(_payer, _conditions); // Reverts on overflow — rejecting excessive terms that could prevent collection _maxOngoingTokensPerSecond * _maxSecondsPerCollection * 1024; @@ -1045,8 +1058,13 @@ contract RecurringCollector is RecurringCollectorStorage storage $ = _getStorage(); _requireValidTerms( - _rcau.endsAt, _rcau.minSecondsPerCollection, _rcau.maxSecondsPerCollection, - _agreement.payer, _rcau.conditions, _rcau.maxOngoingTokensPerSecond + _rcau.deadline, + _rcau.endsAt, + _rcau.minSecondsPerCollection, + _rcau.maxSecondsPerCollection, + _agreement.payer, + _rcau.conditions, + _rcau.maxOngoingTokensPerSecond ); // Clean up stored replaced offer. oldHash is always non-zero for accepted agreements diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index d1742b690..f36eb50e0 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -65,5 +66,171 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { _recurringCollector.accept(acceptedRca, signature); } + /// @notice Re-accepting an already-accepted RCA at the same hash must still succeed after + /// the RCA's acceptance deadline has elapsed. The idempotent short-circuit runs before the + /// deadline check so signature lifetime is not consumed — this is the path the SubgraphService + /// relies on to rebind an agreement to a new allocation after the original acceptance window + /// has closed. + function test_Accept_Idempotent_AfterDeadline_SameHash(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes memory signature, + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + // Warp past the RCA's deadline — a fresh accept would now revert with + // RecurringCollectorAgreementDeadlineElapsed. + vm.warp(uint256(acceptedRca.deadline) + 1); + + vm.recordLogs(); + vm.prank(acceptedRca.dataService); + bytes16 returnedId = _recurringCollector.accept(acceptedRca, signature); + assertEq(returnedId, agreementId, "returns the same agreementId"); + assertEq(vm.getRecordedLogs().length, 0, "no event emitted on idempotent re-accept after deadline"); + + // Sanity: the collector-side agreement is still in Accepted state, unchanged by the no-op. + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(uint8(agreement.state), uint8(IRecurringCollector.AgreementState.Accepted)); + } + + /// @notice A fresh accept (no prior offer()) stores terms via _validateAndStoreTerms, which must + /// emit OfferStored. AgreementAccepted follows. Both events observable in order. + function test_Accept_EmitsOfferStored_WhenFreshTerms(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // OfferStored fires from _validateAndStoreTerms before _storeAgreement; AgreementAccepted + // follows the state transition at the end of accept(). + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, rcaHash); + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementAccepted( + rca.dataService, + rca.payer, + rca.serviceProvider, + agreementId, + rca.endsAt, + rca.maxInitialTokens, + rca.maxOngoingTokensPerSecond, + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + /// @notice A second RCA sharing the same agreementId seed (payer, dataService, serviceProvider, + /// deadline, nonce) but with different other fields — so different rcaHash — must not be + /// accepted against an already-Accepted agreement. The idempotent short-circuit only fires on + /// exact hash match; everything else must fall through to the state guard and revert. Proves + /// the short-circuit can't be abused as an overwrite path even in an imagined 128-bit + /// agreementId collision. + function test_Accept_Revert_WhenDifferentHashSameAgreementId(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + // Snapshot the original hash before constructing the variant. `variant = acceptedRca` in + // Solidity memory is a reference copy, so rebuild explicitly to vary one pricing field + // while keeping the 5 agreementId-seed fields (payer, dataService, serviceProvider, + // deadline, nonce) verbatim. + bytes32 originalHash = _recurringCollector.hashRCA(acceptedRca); + IRecurringCollector.RecurringCollectionAgreement memory variant = IRecurringCollector + .RecurringCollectionAgreement({ + deadline: acceptedRca.deadline, + endsAt: acceptedRca.endsAt, + payer: acceptedRca.payer, + dataService: acceptedRca.dataService, + serviceProvider: acceptedRca.serviceProvider, + maxInitialTokens: acceptedRca.maxInitialTokens + 1, // <-- vary + maxOngoingTokensPerSecond: acceptedRca.maxOngoingTokensPerSecond, + minSecondsPerCollection: acceptedRca.minSecondsPerCollection, + maxSecondsPerCollection: acceptedRca.maxSecondsPerCollection, + conditions: acceptedRca.conditions, + nonce: acceptedRca.nonce, + metadata: acceptedRca.metadata + }); + + bytes32 variantHash = _recurringCollector.hashRCA(variant); + assertTrue(originalHash != variantHash, "hashes must differ when any field differs"); + assertEq( + _recurringCollector.generateAgreementId( + variant.payer, + variant.dataService, + variant.serviceProvider, + variant.deadline, + variant.nonce + ), + agreementId, + "same agreementId seed yields same id" + ); + + (, bytes memory variantSig) = _recurringCollectorHelper.generateSignedRCA(variant, signerKey); + + // Short-circuit doesn't fire (hash differs); falls through to _storeAgreement's state guard. + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.Accepted + ) + ); + vm.prank(acceptedRca.dataService); + _recurringCollector.accept(variant, variantSig); + + // Post-revert sanity: storage reflects the original, not the variant. + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, originalHash, "activeTermsHash unchanged"); + } + + /// @notice After a cancellation, re-accepting the same RCA at the same hash must revert — the + /// short-circuit only fires when state == Accepted, so a cancelled agreement falls through to + /// the NotAccepted state guard. Proves cancelled is terminal and the short-circuit cannot + /// resurrect it. + function test_Accept_Revert_AfterCancellation_SameHash(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes memory signature, + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + vm.prank(acceptedRca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + assertEq( + uint8(_recurringCollector.getAgreement(agreementId).state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "precondition: cancelled" + ); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.CanceledByServiceProvider + ) + ); + vm.prank(acceptedRca.dataService); + _recurringCollector.accept(acceptedRca, signature); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol index 5e47e2fb4..91e3e0bdd 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol @@ -69,11 +69,11 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest _recurringCollector.accept(rca, signature); } - // ==================== endsAt validation (L545) ==================== + // ==================== endsAt validation ==================== - function test_Accept_Revert_WhenEndsAtInPast() public { + function test_Accept_Revert_WhenEndsAtNotAfterDeadline() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); - rca.endsAt = uint64(block.timestamp); // endsAt == now, fails "endsAt > block.timestamp" + rca.endsAt = rca.deadline; // endsAt == deadline, fails "endsAt > deadline" _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); @@ -81,8 +81,8 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest vm.expectRevert( abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementElapsedEndsAt.selector, - block.timestamp, + IRecurringCollector.RecurringCollectorAgreementEndsBeforeDeadline.selector, + rca.deadline, rca.endsAt ) ); @@ -142,12 +142,12 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest function test_Accept_Revert_WhenDurationTooShort() public { IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); - // Need: endsAt - now >= minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW + // Need: endsAt - deadline >= minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW // Set duration just under the minimum uint32 minWindow = _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(); rca.minSecondsPerCollection = 600; rca.maxSecondsPerCollection = 600 + minWindow; // valid window - rca.endsAt = uint64(block.timestamp + rca.minSecondsPerCollection + minWindow - 1); // 1 second too short + rca.endsAt = rca.deadline + rca.minSecondsPerCollection + minWindow - 1; // 1 second too short _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, SIGNER_KEY); (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, SIGNER_KEY); @@ -157,7 +157,7 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementInvalidDuration.selector, rca.minSecondsPerCollection + minWindow, - rca.endsAt - block.timestamp + uint256(rca.endsAt - rca.deadline) ) ); vm.prank(rca.dataService); diff --git a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol index 90ae638e7..5af9b3b0f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol @@ -166,7 +166,7 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { assertTrue(triggered, "Should have triggered InsufficientCallbackGas at some gas limit"); } - /// @notice TRST-L-9: the CALLBACK_GAS_OVERHEAD precheck also guards the eligibility staticcall + /// @notice The CALLBACK_GAS_OVERHEAD precheck also guards the eligibility staticcall /// (first of three callback prechecks). Binary-search for a gas limit that reaches the /// eligibility precheck and trips it, confirming the buffer logic applies there too. function test_Collect_Revert_WhenInsufficientCallbackGas_EligibilityPrecheck() public { diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index f81187662..977e08c34 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -849,6 +849,79 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { assertEq(dataAfter.length, 0, "Offer data should be empty after cancel"); } + function test_Cancel_PendingRcaAndRcau_IndependentOrder() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + + // Offer RCA (not yet accepted) + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = details.agreementId; + bytes32 rcaHash = details.versionHash; + + // Offer RCAU on top of the pending RCA + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory updateDetails = _recurringCollector.offer( + OFFER_TYPE_UPDATE, + abi.encode(rcau), + 0 + ); + bytes32 rcauHash = updateDetails.versionHash; + + // Cancel the RCA offer first — pending RCAU survives independently + vm.expectEmit(true, true, false, true); + emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcaHash); + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); + + IRecurringCollector.AgreementData memory after1 = _recurringCollector.getAgreement(agreementId); + assertEq(after1.activeTermsHash, bytes32(0), "active should be cleared"); + assertEq(after1.pendingTermsHash, rcauHash, "pending RCAU should survive RCA cancel"); + assertEq(after1.payer, address(approver), "agreement.payer persists for subsequent auth"); + + // Now cancel the pending RCAU — payer auth still works via persistent agreement.payer + vm.expectEmit(true, true, false, true); + emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcauHash); + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + (uint8 activeType, ) = _recurringCollector.getAgreementOfferAt(agreementId, 0); + assertEq(activeType, 0, "Active offer should be gone"); + (uint8 pendingType, ) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(pendingType, 0, "Pending offer should be gone"); + } + // ══════════════════════════════════════════════════════════════════════ // Gap 16 — _requirePayer: agreement not found (L528) // ══════════════════════════════════════════════════════════════════════ diff --git a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol index 58aa6961d..fb46ba2dc 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol @@ -505,5 +505,189 @@ contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { assertLt(windowSeconds, maxSecondsPerCollection, "Window should be smaller than maxSecondsPerCollection"); } + /// @notice Symmetry of the pending-deadline fix for the pre-acceptance active branch. + /// An agreement that has been offered but not yet accepted (state == NotAccepted, but + /// activeTermsHash set) is admissible for acceptance at exactly `terms.deadline` because + /// accept() gates on `block.timestamp <= rca.deadline`. RAM's reservation envelope must + /// therefore still cover the potential claim window at that block. One second past, accept() + /// would revert and the agreement is unreachable, so max-claim drops to zero. + function test_GetMaxNextClaim_PreAcceptanceActiveAtExactDeadline_StillCounts() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + // Build RCA manually so we control the exact deadline. + uint64 rcaDeadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: rcaDeadline, + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + // Agreement is in NotAccepted state — activeTermsHash is set (by offer) but no accept() yet. + assertEq( + uint8(_recurringCollector.getAgreement(agreementId).state), + uint8(IRecurringCollector.AgreementState.NotAccepted), + "precondition: NotAccepted" + ); + + // One second before the deadline: pre-acceptance active counts. + vm.warp(uint256(rcaDeadline) - 1); + assertGt(_recurringCollector.getMaxNextClaim(agreementId, 1), 0, "active counts before deadline"); + + // At the exact deadline: accept() is still admissible (<=), so the pre-acceptance window + // must still count in the reservation envelope. + vm.warp(uint256(rcaDeadline)); + assertGt(_recurringCollector.getMaxNextClaim(agreementId, 1), 0, "active should still count at exact deadline"); + + // One second past the deadline: accept() would revert, so max-claim drops to zero. + vm.warp(uint256(rcaDeadline) + 1); + assertEq(_recurringCollector.getMaxNextClaim(agreementId, 1), 0, "active zero one second past deadline"); + } + + /// @notice Boundary: the guard uses `block.timestamp <= terms.deadline` (inclusive) to match + /// {update}'s admissibility — at the exact deadline block, update() can still promote the + /// pending to active, so RAM must keep reserving for it. One second past the deadline, the + /// pending is no longer admissible and drops to zero. + function test_GetMaxNextClaim_PendingAtExactDeadline_StillCounts() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Build RCAU manually (not via sensibleRCAU, which overrides deadline to a tight window) + // so we can pick a deadline we control and warp exactly to its boundary. + uint64 pendingDeadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: pendingDeadline, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 10 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // One second before the deadline: pending counts. + vm.warp(uint256(pendingDeadline) - 1); + assertGt(_recurringCollector.getMaxNextClaim(agreementId, 2), 0, "pending counts before deadline"); + + // At the exact deadline: guard is inclusive `<=`, matching update()'s admissibility. + // update() can still promote the pending to active on this block, so RAM must keep it + // in the reservation envelope. + vm.warp(uint256(pendingDeadline)); + assertGt(_recurringCollector.getMaxNextClaim(agreementId, 2), 0, "pending counts at exact deadline"); + + // One second past the deadline: update() would revert, so pending drops to zero. + vm.warp(uint256(pendingDeadline) + 1); + assertEq(_recurringCollector.getMaxNextClaim(agreementId, 2), 0, "pending zero one second past deadline"); + } + + /// @notice An expired pending offer (deadline in the past, endsAt still in the future) must not + /// contribute to max-claim. {update} rejects past-deadline RCAUs so the pending can never be + /// promoted to active; counting it would over-reserve escrow in RAM. + function test_GetMaxNextClaim_PendingIgnored_AfterDeadline() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Pending RCAU with higher rate + short acceptance deadline but long endsAt. Build manually + // so we control the deadline exactly (sensibleRCAU would override it to a bounded window). + uint64 pendingDeadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: pendingDeadline, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 10 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + uint256 activeClaim = _recurringCollector.getMaxNextClaim(agreementId, 1); // SCOPE_ACTIVE + + // Before deadline: higher-rate pending dominates the combined claim. + uint256 beforeDeadline = _recurringCollector.getMaxNextClaim(agreementId); + assertGt(beforeDeadline, activeClaim, "live pending dominates before its deadline"); + + // Warp one second past the pending's deadline. endsAt is still well in the future, so + // _maxClaimForTerms would still return a large number — but the pending can no longer + // be accepted via update(), so it must not contribute. + vm.warp(uint256(pendingDeadline) + 1); + + uint256 pendingScopeAfter = _recurringCollector.getMaxNextClaim(agreementId, 2); // SCOPE_PENDING + assertEq(pendingScopeAfter, 0, "expired pending returns 0 under SCOPE_PENDING"); + + uint256 combinedAfter = _recurringCollector.getMaxNextClaim(agreementId); + uint256 activeAfter = _recurringCollector.getMaxNextClaim(agreementId, 1); + assertEq(combinedAfter, activeAfter, "combined scope falls back to active-only after pending expires"); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol index 7c5c73cbe..cc75e78d9 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/hashRoundTrip.t.sol @@ -177,8 +177,8 @@ contract RecurringCollectorHashRoundTripTest is RecurringCollectorSharedTest { IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash should be RCAU hash after update"); - // Stored update offer persists after update - _verifyOfferRoundTrip(agreementId, 1, rcauHash); + // After update, RCAU becomes the active version (VERSION_CURRENT = 0) + _verifyOfferRoundTrip(agreementId, 0, rcauHash); } // ==================== Cancel pending, active stays ==================== diff --git a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol index 120214815..659979dee 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol @@ -76,8 +76,7 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { // Verify updated terms IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.maxOngoingTokensPerSecond, rcau.maxOngoingTokensPerSecond); - assertEq(agreement.maxSecondsPerCollection, rcau.maxSecondsPerCollection); + assertEq(agreement.activeTermsHash, _recurringCollector.hashRCAU(rcau)); assertEq(agreement.updateNonce, 1); } @@ -195,9 +194,87 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { _recurringCollector.update(rcau, updateSig); IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.maxOngoingTokensPerSecond, rcau.maxOngoingTokensPerSecond); + assertEq(agreement.activeTermsHash, _recurringCollector.hashRCAU(rcau)); assertEq(agreement.updateNonce, 1); } + /// @notice Replacing the active offer preserves an independent pending RCAU. The update is + /// still a valid signed offer against the same agreementId; the payer may cancel it + /// explicitly if they don't want it. The contract shouldn't silently invalidate it. + function test_MixedPath_OfferNew_PreservesPendingRcau() public { + MockAgreementOwner approver = new MockAgreementOwner(); + + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: 0, + endsAt: 0, + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + // Derive the deterministic agreement ID from rca1's post-sensible fields. + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca1.payer, + rca1.dataService, + rca1.serviceProvider, + rca1.deadline, + rca1.nonce + ); + + // Step 1: offer RCA → active = hashRCA(rca1) + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca1), 0); + bytes32 rca1Hash = _recurringCollector.hashRCA(rca1); + + // Step 2: offer RCAU → pending = hashRCAU(rcau) + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: 0, + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + + // Pre-check: pending is set + IRecurringCollector.AgreementData memory before = _recurringCollector.getAgreement(agreementId); + assertEq(before.activeTermsHash, rca1Hash, "active should be rca1Hash after offer"); + assertEq(before.pendingTermsHash, rcauHash, "pending should be rcauHash after offer UPDATE"); + + // Step 3: offer different RCA with same primary fields (same agreementId, different terms) + IRecurringCollector.RecurringCollectionAgreement memory rca2 = rca1; + rca2.maxInitialTokens = 999 ether; // different terms → different hash, same agreementId + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca2), 0); + bytes32 rca2Hash = _recurringCollector.hashRCA(rca2); + + // Post-check: active replaced, pending preserved (still the original RCAU) + IRecurringCollector.AgreementData memory afterOffer = _recurringCollector.getAgreement(agreementId); + assertEq(afterOffer.activeTermsHash, rca2Hash, "active should be rca2Hash"); + assertEq(afterOffer.pendingTermsHash, rcauHash, "pending RCAU should still be queued"); + + // The pending offer's $.terms entry must still be retrievable — payer can still accept it + (uint8 pendingType, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); + assertEq(pendingType, OFFER_TYPE_UPDATE, "pending slot should still hold update offer"); + assertEq(keccak256(pendingData), keccak256(abi.encode(rcau)), "pending data should be the original RCAU"); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol index 0aece90ae..a4988b4b0 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol @@ -215,7 +215,7 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared /// @notice Pre-acceptance cancel of the RCA under SCOPE_PENDING deletes BOTH the RCA offer /// and any pending RCAU offer. After cascade, both slots are empty. - function test_CancelPreAcceptanceRca_CascadesDeleteRcau() public { + function test_CancelPreAcceptanceRca_PreservesPendingRcau() public { MockAgreementOwner approver = new MockAgreementOwner(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); bytes32 rcaHash = _recurringCollector.hashRCA(rca); @@ -239,7 +239,7 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared assertEq(preCurrentType, OFFER_TYPE_NEW, "RCA stored before cancel"); assertEq(preNextType, OFFER_TYPE_UPDATE, "RCAU stored before cancel"); - // Cancel the pre-acceptance RCA — one OfferCancelled event, both slots cleared + // Cancel the pre-acceptance RCA — one OfferCancelled event; pending RCAU survives vm.expectEmit(address(_recurringCollector)); emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcaHash); vm.prank(address(approver)); @@ -247,7 +247,7 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(agreement.activeTermsHash, bytes32(0), "activeTermsHash cleared"); - assertEq(agreement.pendingTermsHash, bytes32(0), "pendingTermsHash cascade-cleared"); + assertEq(agreement.pendingTermsHash, rcauHash, "pendingTermsHash survives RCA cancel"); (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( agreementId, @@ -257,19 +257,14 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared assertEq(currentData.length, 0, "RCA data empty"); (uint8 nextType, bytes memory nextData) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); - assertEq(nextType, OFFER_TYPE_NONE, "RCAU offer cascade-deleted"); - assertEq(nextData.length, 0, "RCAU data empty"); - - // The original rcauHash stored-offer entry is no longer referenced. No version hash - // resolves to it — confirmed above — so the cleanup is complete for view purposes. - rcauHash; // silence unused warning; kept for clarity in the narrative + assertEq(nextType, OFFER_TYPE_UPDATE, "RCAU offer still retrievable"); + assertEq(keccak256(nextData), keccak256(abi.encode(rcau)), "RCAU data intact"); } - /// @notice After a pre-acceptance cascade delete, a follow-up cancel targeting the orphan RCAU - /// hash must NOT revert: _requirePayerIfExists short-circuits because agreement.payer was - /// zeroed when activeTermsHash was cleared — but the agreement struct still exists. The cancel - /// is therefore a no-op targeting already-empty state. - function test_CancelPreAcceptanceRca_SubsequentRcauCancel_DoesNotRevert() public { + /// @notice Pre-acceptance RCA and pending RCAU can be cancelled in either order — + /// agreement.payer is a persistent field, so cancelling one doesn't un-authorize cancelling + /// the other. + function test_CancelPreAcceptance_EitherOrder() public { MockAgreementOwner approver = new MockAgreementOwner(); IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); bytes32 rcaHash = _recurringCollector.hashRCA(rca); @@ -287,15 +282,19 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared vm.prank(address(approver)); _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - // Cancel the RCA — cascades the RCAU + // Cancel the RCA first vm.prank(address(approver)); _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); - // The approver can still cancel(rcauHash) without reverting — the payer slot on the - // agreement is still set (clearing is by *termsHash*, not payer field), so the call - // enters the pending-hash branch, observes pendingTermsHash == 0, and exits silently. + // Then cancel the pending RCAU — must succeed because agreement.payer is persistent + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(address(approver), agreementId, rcauHash); vm.prank(address(approver)); _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); + assertEq(agreement.activeTermsHash, bytes32(0), "active cleared"); + assertEq(agreement.pendingTermsHash, bytes32(0), "pending cleared"); } /// @notice Pre-acceptance cancel with no pending RCAU still deletes the RCA offer and diff --git a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol index 84eab9b75..38652d81a 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol @@ -98,11 +98,7 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { _recurringCollector.update(rcau, ""); IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(rcau.endsAt, agreement.endsAt); - assertEq(rcau.maxInitialTokens, agreement.maxInitialTokens); - assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); - assertEq(rcau.minSecondsPerCollection, agreement.minSecondsPerCollection); - assertEq(rcau.maxSecondsPerCollection, agreement.maxSecondsPerCollection); + assertEq(agreement.activeTermsHash, _recurringCollector.hashRCAU(rcau)); assertEq(rcau.nonce, agreement.updateNonce); } diff --git a/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol b/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol index f65fe9464..82d2a1468 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/upgradeScenario.t.sol @@ -129,7 +129,7 @@ contract RecurringCollectorUpgradeScenarioTest is Test, Bounder { assertEq(v2Agreement.payer, payer, "payer lost"); assertEq(v2Agreement.serviceProvider, rca.serviceProvider, "serviceProvider lost"); assertEq(v2Agreement.dataService, rca.dataService, "dataService lost"); - assertEq(v2Agreement.maxOngoingTokensPerSecond, rca.maxOngoingTokensPerSecond, "terms lost"); + assertEq(v2Agreement.activeTermsHash, _recurringCollector.hashRCA(rca), "terms hash lost"); assertTrue(_recurringCollector.pauseGuardians(makeAddr("guardian")), "pause guardian lost"); } diff --git a/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol index 839cd146e..80445920b 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol @@ -15,10 +15,8 @@ contract RecurringCollectorViewFunctionsTest is RecurringCollectorSharedTest { function test_GetCollectionInfo_Accepted_AfterTime(FuzzyTestAccept calldata fuzzy) public { (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - - // Skip some time - skip(agreement.minSecondsPerCollection); + // Skip past the minimum collection window so collection is possible + skip(_recurringCollector.MIN_SECONDS_COLLECTION_WINDOW()); // Re-read agreement (timestamps don't change but view computes based on block.timestamp) (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); @@ -129,22 +127,13 @@ contract RecurringCollectorViewFunctionsTest is RecurringCollectorSharedTest { assertEq(agreement.payer, rca.payer, "payer should match"); assertEq(agreement.dataService, rca.dataService, "dataService should match"); assertEq(agreement.serviceProvider, rca.serviceProvider, "serviceProvider should match"); - assertEq(agreement.endsAt, rca.endsAt, "endsAt should match"); - assertEq(agreement.minSecondsPerCollection, rca.minSecondsPerCollection, "minSeconds should match"); - assertEq(agreement.maxSecondsPerCollection, rca.maxSecondsPerCollection, "maxSeconds should match"); - assertEq(agreement.maxInitialTokens, rca.maxInitialTokens, "maxInitialTokens should match"); - assertEq( - agreement.maxOngoingTokensPerSecond, - rca.maxOngoingTokensPerSecond, - "maxOngoingTokensPerSecond should match" - ); assertEq( uint8(agreement.state), uint8(IRecurringCollector.AgreementState.Accepted), "state should be Accepted" ); assertTrue(agreement.acceptedAt > 0, "acceptedAt should be set"); - assertTrue(agreement.activeTermsHash != bytes32(0), "activeTermsHash should be set"); + assertEq(agreement.activeTermsHash, _recurringCollector.hashRCA(rca), "activeTermsHash should match RCA hash"); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 6315033e2..74ccde753 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -316,11 +316,11 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { error RecurringCollectorAgreementAddressNotSet(); /** - * @notice Thrown when accepting or upgrading an agreement with an elapsed endsAt - * @param currentTimestamp The current timestamp + * @notice Thrown when an agreement's endsAt is not strictly after its acceptance deadline. + * @param deadline The offer acceptance deadline * @param endsAt The agreement end timestamp */ - error RecurringCollectorAgreementElapsedEndsAt(uint256 currentTimestamp, uint64 endsAt); + error RecurringCollectorAgreementEndsBeforeDeadline(uint64 deadline, uint64 endsAt); /** * @notice Thrown when accepting or upgrading an agreement with an elapsed endsAt diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol index b2853949d..77be7c67d 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/accept.t.sol @@ -473,5 +473,63 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg ); assertEq(afterOldClose.agreement.allocationId, secondAllocationId, "still bound to second allocation"); } + + /// @notice Rebinding an already-accepted agreement to a new allocation must still succeed after + /// the original RCA's acceptance deadline has elapsed. The collector's idempotent short-circuit + /// runs before the deadline check — same-hash re-accept is a no-op and does not consume the + /// signature's lifetime. Without this, indexers could not move agreements across allocations + /// after the typically-short RCA acceptance window closes. + function test_SubgraphService_AcceptIndexingAgreement_Rebinds_AfterRcaDeadline( + Seed memory seed, + uint256 secondAllocationKey + ) public { + Context storage ctx = _newCtx(seed); + IndexerState memory indexerState = _withIndexer(ctx); + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + bytes16 agreementId + ) = _withAcceptedIndexingAgreement(ctx, indexerState); + + // Top up provision and allocate a second allocation on the same subgraph deployment. + uint256 extraTokens = 10_000_000 ether; + deal({ token: address(token), to: indexerState.addr, give: extraTokens }); + resetPrank(indexerState.addr); + _addToProvision(indexerState.addr, extraTokens); + + secondAllocationKey = boundKey(secondAllocationKey); + address secondAllocationId = vm.addr(secondAllocationKey); + vm.assume(secondAllocationId != indexerState.allocationId); + vm.assume(ctx.allocations[secondAllocationId] == address(0)); + ctx.allocations[secondAllocationId] = indexerState.addr; + + bytes memory allocData = _createSubgraphAllocationData( + indexerState.addr, + indexerState.subgraphDeploymentId, + secondAllocationKey, + extraTokens + ); + _startService(indexerState.addr, allocData); + + // Warp past the RCA's acceptance deadline. A fresh accept would now revert with + // RecurringCollectorAgreementDeadlineElapsed — the rebind must take the idempotent path. + vm.warp(uint256(acceptedRca.deadline) + 1); + + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA( + acceptedRca, + ctx.payer.signerPrivateKey + ); + + resetPrank(indexerState.addr); + bytes16 returnedId = subgraphService.acceptIndexingAgreement(secondAllocationId, acceptedRca, signature); + assertEq(returnedId, agreementId, "rebind after deadline returns same agreementId"); + + IIndexingAgreement.AgreementWrapper memory rebound = subgraphService.getIndexingAgreement(agreementId); + assertEq(rebound.agreement.allocationId, secondAllocationId, "rebound to second allocation after deadline"); + assertEq( + uint8(rebound.collectorAgreement.state), + uint8(IRecurringCollector.AgreementState.Accepted), + "collector state still Accepted after post-deadline rebind" + ); + } /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol index d20a8e347..95f91f1a0 100644 --- a/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol +++ b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol @@ -600,11 +600,93 @@ contract AgreementLifecycleAdvancedTest is FullStackHarness { ); } + // ═══════════════════════════════════════════════════════════════════ + // Scenario 15: Rebind after cancellation — collector state authority + // ═══════════════════════════════════════════════════════════════════ + + /// @notice Cancellation is terminal at the collector. The SubgraphService rebind path must + /// defer to that authority: an attempt to rebind a cancelled agreement onto a fresh allocation + /// must revert, leaving both the collector state and SS state untouched. Exercises the full + /// offer → accept → cancel → open-second-allocation → rebind-attempt flow end-to-end with the + /// real contract stack. + function test_Scenario15_RebindAfterCancellation_Reverts() public { + IndexingAgreement.IndexingAgreementTermsV1 memory terms = IndexingAgreement.IndexingAgreementTermsV1({ + tokensPerSecond: 0.5 ether, + tokensPerEntityPerSecond: 0 + }); + IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCA(indexer, 0, 1 ether, 3600, terms); + bytes16 agreementId = _offerAndAccept(indexer, rca); + + // Cancel via the indexer path — CanceledByServiceProvider. + vm.prank(indexer.addr); + subgraphService.cancelIndexingAgreement(indexer.addr, agreementId); + assertEq( + uint8(recurringCollector.getAgreement(agreementId).state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "precondition: cancelled at collector" + ); + + // Open a second allocation on the same subgraph deployment. + (address secondAllocationId, address cancelRebindTarget) = _openSecondAllocationForIndexer( + indexer, + "cancel-rebind-alloc" + ); + assertEq(cancelRebindTarget, indexer.addr, "indexer owns the new allocation"); + + // Attempt rebind to the new allocation. SS would stage the bookkeeping, but collector + // rejects (state != NotAccepted), reverting the whole tx. Both layers stay clean. + vm.prank(indexer.addr); + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.CanceledByServiceProvider + ) + ); + subgraphService.acceptIndexingAgreement(secondAllocationId, rca, ""); + + // Post-revert: agreement still cancelled at collector, still bound to old allocation in SS. + assertEq( + uint8(recurringCollector.getAgreement(agreementId).state), + uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider), + "collector state unchanged" + ); + IIndexingAgreement.AgreementWrapper memory wrapper = subgraphService.getIndexingAgreement(agreementId); + assertEq(wrapper.agreement.allocationId, indexer.allocationId, "SS still bound to original allocation"); + } + // ── Helpers ── function _getHardcodedPoiMetadata() internal view returns (bytes memory) { return abi.encode(block.number, bytes32("PUBLIC_POI1"), uint8(0), uint8(0), uint256(0)); } + + /// @notice Top up the indexer's provision and open a second allocation on the same + /// subgraph deployment. Returns the new allocation's id plus the indexer that owns it + /// (both for readability and to let callers assert ownership in a single expression). + function _openSecondAllocationForIndexer( + IndexerSetup memory _indexer, + string memory _label + ) internal returns (address allocationId, address owner) { + uint256 extraTokens = MINIMUM_PROVISION_TOKENS; + _addProvisionTokens(_indexer, extraTokens); + + uint256 allocationKey; + (allocationId, allocationKey) = makeAddrAndKey(_label); + + bytes32 digest = subgraphService.encodeAllocationProof(_indexer.addr, allocationId); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(allocationKey, digest); + bytes memory allocationData = abi.encode( + _indexer.subgraphDeploymentId, + extraTokens, + allocationId, + abi.encodePacked(r, s, v) + ); + vm.prank(_indexer.addr); + subgraphService.startService(_indexer.addr, allocationData); + + owner = _indexer.addr; + } } /// @notice Mock eligibility oracle for testing From b6adbf16ba8fa165d29b11c20e1e449cc8dd31e0 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 11:42:40 +0000 Subject: [PATCH 112/157] refactor(collector): extract _getAgreementDetails/_versionHashAt helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preparatory step for TRST-L-11 (per-version semantics) and TRST-L-8 (SCOPE_SIGNED cancel) — minimizes thrash in those commits. Not the final correct implementation: index is passed through but only VERSION_CURRENT and VERSION_NEXT are distinguished, getAgreementOfferAt still uses OFFER_TYPE_* indexing, and _versionHashAt still keys VERSION_CURRENT off agreement.state because activeTermsHash is not yet persisted pre-acceptance (lands in TRST-L-7). - offer() routes through _getAgreementDetails(id, versionHash, index) using tuple-returning _offerNew/_offerUpdate (id, versionHash, index). The offer path supplies the hash it just produced; the helper avoids re-reading storage to recompute it. - _versionHashAt resolves the offer hash for the requested version: pre-acceptance CURRENT reads rcaOffers; post-acceptance CURRENT reads agreement.activeTermsHash; NEXT reads rcauOffers but skips when the stored RCAU is already the active version. - getAgreementDetails(id, index) looks up the hash via _versionHashAt and forwards to _getAgreementDetails. The helper returns empty when versionHash is zero, treating "no version exists" uniformly across both call sites. State semantics preserved: REGISTERED for pre-acceptance current, ACCEPTED for post-acceptance current, REGISTERED|UPDATE for any pending RCAU. --- .../collectors/RecurringCollector.sol | 108 ++++++++++++------ 1 file changed, 73 insertions(+), 35 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 79c8b4491..40dc65ba1 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -21,9 +21,10 @@ import { OFFER_TYPE_UPDATE, ACCEPTED, REGISTERED, - UPDATE, SCOPE_ACTIVE, - SCOPE_PENDING + SCOPE_PENDING, + VERSION_CURRENT, + VERSION_NEXT } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol"; @@ -423,46 +424,51 @@ contract RecurringCollector is bytes calldata data, uint16 /* options */ ) external whenNotPaused returns (AgreementDetails memory details) { - if (offerType == OFFER_TYPE_NEW) details = _offerNew(data); - else if (offerType == OFFER_TYPE_UPDATE) details = _offerUpdate(data); + bytes16 agreementId; + bytes32 versionHash; + uint256 index; + if (offerType == OFFER_TYPE_NEW) (agreementId, versionHash, index) = _offerNew(data); + else if (offerType == OFFER_TYPE_UPDATE) (agreementId, versionHash, index) = _offerUpdate(data); else revert RecurringCollectorInvalidCollectData(data); + + details = _getAgreementDetails(agreementId, versionHash, index); } /** * @notice Process a new offer (OFFER_TYPE_NEW). * @param _data The ABI-encoded RecurringCollectionAgreement - * @return details The agreement details + * @return agreementId The deterministic agreement ID + * @return versionHash The EIP-712 hash of the stored offer + * @return index The version index for the offered terms (always VERSION_CURRENT for NEW) */ - function _offerNew(bytes calldata _data) private returns (AgreementDetails memory details) { + function _offerNew(bytes calldata _data) private returns (bytes16 agreementId, bytes32 versionHash, uint256 index) { RecurringCollectorStorage storage $ = _getStorage(); RecurringCollectionAgreement memory rca = abi.decode(_data, (RecurringCollectionAgreement)); - (bytes16 agreementId, bytes32 rcaHash) = _rcaIdAndHash(rca); + (agreementId, versionHash) = _rcaIdAndHash(rca); require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); - $.rcaOffers[agreementId] = StoredOffer({ offerHash: rcaHash, data: _data }); - - details.agreementId = agreementId; - details.payer = rca.payer; - details.dataService = rca.dataService; - details.serviceProvider = rca.serviceProvider; - details.versionHash = rcaHash; - details.state = REGISTERED; + $.rcaOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); + emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, versionHash); - emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, rcaHash); + index = VERSION_CURRENT; } /** * @notice Process an update offer (OFFER_TYPE_UPDATE). * @param _data The ABI-encoded RecurringCollectionAgreementUpdate - * @return details The agreement details + * @return agreementId The agreement ID being updated + * @return versionHash The EIP-712 hash of the stored RCAU + * @return index VERSION_NEXT — the queued pending update */ - function _offerUpdate(bytes calldata _data) private returns (AgreementDetails memory details) { + function _offerUpdate( + bytes calldata _data + ) private returns (bytes16 agreementId, bytes32 versionHash, uint256 index) { RecurringCollectorStorage storage $ = _getStorage(); RecurringCollectionAgreementUpdate memory rcau = abi.decode(_data, (RecurringCollectionAgreementUpdate)); - bytes16 agreementId = rcau.agreementId; + agreementId = rcau.agreementId; // Payer check: look up the existing agreement or the stored RCA offer AgreementData storage agreement = $.agreements[agreementId]; @@ -478,25 +484,16 @@ contract RecurringCollector is (RecurringCollectionAgreement) ); payer = rca.payer; - details.dataService = rca.dataService; - details.serviceProvider = rca.serviceProvider; - } else { - details.dataService = agreement.dataService; - details.serviceProvider = agreement.serviceProvider; } require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); _requirePayerToSupportEligibilityCheck(payer, rcau.conditions); - bytes32 offerHash = _hashRCAU(rcau); - - $.rcauOffers[agreementId] = StoredOffer({ offerHash: offerHash, data: _data }); + versionHash = _hashRCAU(rcau); - details.agreementId = agreementId; - details.payer = payer; - details.versionHash = offerHash; - details.state = REGISTERED | UPDATE; + $.rcauOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); + emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, versionHash); - emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, offerHash); + index = VERSION_NEXT; } /// @inheritdoc IAgreementCollector @@ -542,10 +539,29 @@ contract RecurringCollector is } /// @inheritdoc IAgreementCollector - function getAgreementDetails( + function getAgreementDetails(bytes16 agreementId, uint256 index) external view returns (AgreementDetails memory) { + return _getAgreementDetails(agreementId, _versionHashAt(agreementId, index), index); + } + + /** + * @notice Builds AgreementDetails for the requested version. Shared by {offer} and + * {getAgreementDetails}. + * @dev Caller supplies the version hash. {offer} passes the hash returned by _offerNew / + * _offerUpdate (already known from the just-stored offer); {getAgreementDetails} resolves + * it via _versionHashAt. Returns empty details when versionHash is zero. The `index` + * parameter is plumbed through for TRST-L-11 (per-version flag composition) and is unused + * at this stage. + * @param agreementId The agreement ID + * @param versionHash The EIP-712 hash of the queried version, or bytes32(0) if none + * @return details AgreementDetails for the queried version, or empty when no version exists + */ + function _getAgreementDetails( bytes16 agreementId, + bytes32 versionHash, uint256 /* index */ - ) external view returns (AgreementDetails memory details) { + ) private view returns (AgreementDetails memory details) { + if (versionHash == bytes32(0)) return details; + RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; @@ -554,7 +570,7 @@ contract RecurringCollector is details.payer = agreement.payer; details.dataService = agreement.dataService; details.serviceProvider = agreement.serviceProvider; - details.versionHash = agreement.activeTermsHash; + details.versionHash = versionHash; details.state = ACCEPTED; return details; } @@ -572,6 +588,28 @@ contract RecurringCollector is } } + /** + * @notice Resolve the offer hash representing a given version (VERSION_CURRENT or VERSION_NEXT). + * @dev Returns bytes32(0) when no version exists at that index. + * @param agreementId The agreement ID + * @param index The version index (VERSION_CURRENT or VERSION_NEXT) + * @return hash The EIP-712 hash of the offer at that version, or bytes32(0) if none + */ + function _versionHashAt(bytes16 agreementId, uint256 index) private view returns (bytes32 hash) { + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage agreement = $.agreements[agreementId]; + + if (index == VERSION_CURRENT) + hash = (agreement.state == AgreementState.NotAccepted) + ? $.rcaOffers[agreementId].offerHash + : agreement.activeTermsHash; + else if (index == VERSION_NEXT) { + bytes32 rcauHash = $.rcauOffers[agreementId].offerHash; + // Skip when rcauOffers still holds an applied RCAU — that's the current version, not next. + if (rcauHash != agreement.activeTermsHash) hash = rcauHash; + } + } + /// @inheritdoc IAgreementCollector function getMaxNextClaim(bytes16 agreementId, uint8 agreementScope) external view returns (uint256) { return _getMaxNextClaimScoped(agreementId, agreementScope); From 8b48437be1336e7bb8e218a91eaec4c8caee3a71 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 11:47:10 +0000 Subject: [PATCH 113/157] fix(collector): persistent agreement.payer for independent cancellation (TRST-L-7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Persist agreement.payer (and dataService/serviceProvider) at offer time rather than waiting until accept(). _requirePayer is replaced by an inline payer check at the cancel() call site now that agreement.payer is the reliable authority — no more fallback decoding of stored RCA data on every cancel. Persistent agreement.payer makes cancelling a pre-acceptance RCA offer and cancelling a pending RCAU offer independent operations that may be performed in either order. Neither path leaves the other unreachable. _offerUpdate also simplifies: it reads agreement.payer/dataService/ serviceProvider directly (set by _offerNew) rather than decoding the stored RCA on every update offer. State guard relaxes to accept {NotAccepted, Accepted} so update offers work post-acceptance. cancel(by) clears any pending RCAU offer at cancellation time — pendingHash != activeTermsHash means the pending offer is now stale and can be reaped. offer() hoists the msg.sender == details.payer authorization out of both _offerNew and _offerUpdate now that details.payer is reliably populated by either path. accept() now stores the RCA offer idempotently (when not already present) so accept-without-prior-offer paths leave the same on-chain trail. update() does the same for RCAU storage. --- .../collectors/RecurringCollector.sol | 117 +++++++++--------- packages/issuance/audits/PR1301/TRST-L-7.md | 9 ++ 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 40dc65ba1..38e815a41 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -214,19 +214,26 @@ contract RecurringCollector is RecurringCollectionAgreement calldata rca, bytes calldata signature ) external whenNotPaused returns (bytes16 agreementId) { + bytes32 rcaHash; + (agreementId, rcaHash) = _rcaIdAndHash(rca); + + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage agreement = $.agreements[agreementId]; + require( block.timestamp <= rca.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) ); - bytes32 rcaHash; - (agreementId, rcaHash) = _rcaIdAndHash(rca); - _requireAuthorization(rca.payer, rcaHash, signature, agreementId, OFFER_TYPE_NEW); + if ($.rcaOffers[agreementId].offerHash != rcaHash) { + $.rcaOffers[agreementId] = StoredOffer({ offerHash: rcaHash, data: abi.encode(rca) }); + emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, rcaHash); + } + _validateAndStoreAgreement(rca, agreementId, rcaHash); - AgreementData storage agreement = _getStorage().agreements[agreementId]; require( agreement.state == AgreementState.NotAccepted, RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) @@ -302,7 +309,8 @@ contract RecurringCollector is * @dev Caller must be the data service for the agreement. */ function cancel(bytes16 agreementId, CancelAgreementBy by) external whenNotPaused { - AgreementData storage agreement = _getAgreementStorage(agreementId); + RecurringCollectorStorage storage $ = _getStorage(); + AgreementData storage agreement = $.agreements[agreementId]; require( agreement.state == AgreementState.Accepted, RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) @@ -318,6 +326,9 @@ contract RecurringCollector is agreement.state = AgreementState.CanceledByServiceProvider; } + bytes32 pendingHash = $.rcauOffers[agreementId].offerHash; + if (pendingHash != bytes32(0) && pendingHash != agreement.activeTermsHash) delete $.rcauOffers[agreementId]; + emit AgreementCanceled(agreement.dataService, agreement.payer, agreement.serviceProvider, agreementId, by); } @@ -346,6 +357,12 @@ contract RecurringCollector is RecurringCollectorInvalidUpdateNonce(rcau.agreementId, expectedNonce, rcau.nonce) ); + RecurringCollectorStorage storage $ = _getStorage(); + if ($.rcauOffers[rcau.agreementId].offerHash != rcauHash) { + $.rcauOffers[rcau.agreementId] = StoredOffer({ offerHash: rcauHash, data: abi.encode(rcau) }); + emit OfferStored(rcau.agreementId, agreement.payer, OFFER_TYPE_UPDATE, rcauHash); + } + _validateAndStoreUpdate(agreement, rcau, rcauHash); agreement.updateNonce = rcau.nonce; @@ -432,6 +449,7 @@ contract RecurringCollector is else revert RecurringCollectorInvalidCollectData(data); details = _getAgreementDetails(agreementId, versionHash, index); + require(msg.sender == details.payer, RecurringCollectorUnauthorizedCaller(msg.sender, details.payer)); } /** @@ -447,11 +465,26 @@ contract RecurringCollector is (agreementId, versionHash) = _rcaIdAndHash(rca); - require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); - _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); + if ($.rcaOffers[agreementId].offerHash != versionHash) { + AgreementData storage agreement = $.agreements[agreementId]; + require( + agreement.state == AgreementState.NotAccepted, + RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) + ); + require( + block.timestamp <= rca.deadline, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) + ); + _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); + + agreement.payer = rca.payer; + agreement.dataService = rca.dataService; + agreement.serviceProvider = rca.serviceProvider; + agreement.activeTermsHash = versionHash; - $.rcaOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); - emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, versionHash); + $.rcaOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); + emit OfferStored(agreementId, rca.payer, OFFER_TYPE_NEW, versionHash); + } index = VERSION_CURRENT; } @@ -468,30 +501,25 @@ contract RecurringCollector is ) private returns (bytes16 agreementId, bytes32 versionHash, uint256 index) { RecurringCollectorStorage storage $ = _getStorage(); RecurringCollectionAgreementUpdate memory rcau = abi.decode(_data, (RecurringCollectionAgreementUpdate)); + versionHash = _hashRCAU(rcau); agreementId = rcau.agreementId; - - // Payer check: look up the existing agreement or the stored RCA offer AgreementData storage agreement = $.agreements[agreementId]; - address payer = agreement.payer; - if (payer == address(0)) { - // Not yet accepted — check stored RCA offer payer + + if ($.rcauOffers[agreementId].offerHash != versionHash) { require( - $.rcaOffers[agreementId].offerHash != bytes32(0), - RecurringCollectorAgreementIncorrectState(agreementId, AgreementState.NotAccepted) + block.timestamp <= rcau.deadline, + RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rcau.deadline) ); - RecurringCollectionAgreement memory rca = abi.decode( - $.rcaOffers[agreementId].data, - (RecurringCollectionAgreement) + require( + agreement.payer != address(0) && + (agreement.state == AgreementState.NotAccepted || agreement.state == AgreementState.Accepted), + RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) ); - payer = rca.payer; - } - require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); - _requirePayerToSupportEligibilityCheck(payer, rcau.conditions); - - versionHash = _hashRCAU(rcau); + _requirePayerToSupportEligibilityCheck(agreement.payer, rcau.conditions); - $.rcauOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); - emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, versionHash); + $.rcauOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); + emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, versionHash); + } index = VERSION_NEXT; } @@ -500,44 +528,21 @@ contract RecurringCollector is function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external whenNotPaused { RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; - _requirePayer($, agreement, agreementId); + address payer = agreement.payer; + require(payer != address(0), RecurringCollectorAgreementNotFound(agreementId)); + require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); - if (agreement.activeTermsHash != termsHash) { - if (options & SCOPE_PENDING != 0) + if (agreement.activeTermsHash != termsHash || agreement.state == AgreementState.NotAccepted) { + if (options & SCOPE_PENDING != 0) { // Pending scope: delete stored offer if hash matches and terms are not currently active if ($.rcaOffers[agreementId].offerHash == termsHash) delete $.rcaOffers[agreementId]; else if ($.rcauOffers[agreementId].offerHash == termsHash) delete $.rcauOffers[agreementId]; + } } else if (options & SCOPE_ACTIVE != 0 && agreement.state == AgreementState.Accepted) // Active scope and hash matches: cancel accepted agreement IDataServiceAgreements(agreement.dataService).cancelIndexingAgreementByPayer(agreementId); } - /** - * @notice Requires that msg.sender is the payer for an agreement. - * @dev Checks the on-chain agreement first, then falls back to stored RCA offer. - * @param agreement The agreement data - * @param agreementId The agreement ID - */ - // solhint-disable-next-line use-natspec - function _requirePayer( - RecurringCollectorStorage storage $, - AgreementData storage agreement, - bytes16 agreementId - ) private view { - if (agreement.payer == msg.sender) return; - - // Not payer on accepted agreement — check stored RCA offer - StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; - if (rcaOffer.offerHash != bytes32(0)) { - RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); - require(msg.sender == rca.payer, RecurringCollectorUnauthorizedCaller(msg.sender, rca.payer)); - return; - } - if (agreement.payer == address(0)) revert RecurringCollectorAgreementNotFound(agreementId); - - revert RecurringCollectorUnauthorizedCaller(msg.sender, agreement.payer); - } - /// @inheritdoc IAgreementCollector function getAgreementDetails(bytes16 agreementId, uint256 index) external view returns (AgreementDetails memory) { return _getAgreementDetails(agreementId, _versionHashAt(agreementId, index), index); diff --git a/packages/issuance/audits/PR1301/TRST-L-7.md b/packages/issuance/audits/PR1301/TRST-L-7.md index 1eee39005..187e23e61 100644 --- a/packages/issuance/audits/PR1301/TRST-L-7.md +++ b/packages/issuance/audits/PR1301/TRST-L-7.md @@ -20,3 +20,12 @@ Extend `_requirePayer()` to also check `rcauOffers` for a payer match when neith TBD --- + +Resolved by persisting `agreement.payer` from the first `offer()` instead of waiting until +`accept()`. `_requirePayer` is replaced by an inline `agreement.payer` check at the +`cancel()` call site, reading the persisted address directly without falling back through +`rcaOffers`. `_offerUpdate` likewise reads `agreement.payer` instead of decoding the +stored RCA bytes on every update offer. As a consequence, cancelling a pre-acceptance +RCA offer and cancelling a pending RCAU offer are fully independent operations that may +be performed in either order — neither path leaves the other unreachable, because the +persistent `agreement.payer` continues to authorize the surviving offer. From 769b252e531af047b008a7d47e5e0ce62afcd88a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 10:08:12 +0000 Subject: [PATCH 114/157] feat(collector): idempotent accept/update/cancel-on-nothing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align re-accept, re-update, and cancel-on-nothing semantics so duplicate calls with the same signed terms are no-ops rather than reverts, and cancel against a nonexistent agreement is a silent no-op. - accept(): short-circuits when state == Accepted and the stored activeTermsHash already equals the incoming RCA hash. Re-accepting the same signed RCA is a no-op (skips deadline + auth). Cancelled agreements still revert — re-accept of a cancelled agreement is never valid. The state == NotAccepted require is dropped: the short-circuit handles re-accept-same, and _requireAuthorization handles re-accept-different (signature won't match a different hash). - update(): short-circuits when activeTermsHash already equals the RCAU hash, skipping deadline and authorization checks on the idempotent path. - cancel(): when no agreement or stored offer exists (agreement.payer == 0) the call returns silently instead of reverting with RecurringCollectorAgreementNotFound. Cancel against nothing is a no-op — same idempotent spirit. Built on top of TRST-L-7's persistent agreement.payer. --- .../collectors/RecurringCollector.sol | 17 ++-- .../payments/recurring-collector/accept.t.sol | 16 ++-- .../recurring-collector/acceptUnsigned.t.sol | 14 +-- .../recurring-collector/coverageGaps.t.sol | 8 +- .../payments/recurring-collector/update.t.sol | 86 +++++++++++++++++-- 5 files changed, 106 insertions(+), 35 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 38e815a41..d23276be0 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -220,6 +220,9 @@ contract RecurringCollector is RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; + // Idempotent: already accepted with the same hash → no-op (skip deadline + auth). + if (agreement.state == AgreementState.Accepted && agreement.activeTermsHash == rcaHash) return agreementId; + require( block.timestamp <= rca.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) @@ -234,10 +237,6 @@ contract RecurringCollector is _validateAndStoreAgreement(rca, agreementId, rcaHash); - require( - agreement.state == AgreementState.NotAccepted, - RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) - ); agreement.acceptedAt = uint64(block.timestamp); agreement.state = AgreementState.Accepted; @@ -342,13 +341,17 @@ contract RecurringCollector is function update(RecurringCollectionAgreementUpdate calldata rcau, bytes calldata signature) external whenNotPaused { AgreementData storage agreement = _requireValidUpdateTarget(rcau.agreementId); + bytes32 rcauHash = _hashRCAU(rcau); + + // Idempotent: already at this version (state is Accepted per _requireValidUpdateTarget). + // Skip deadline + auth since no state change happens. + if (agreement.activeTermsHash == rcauHash) return; + require( block.timestamp <= rcau.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rcau.deadline) ); - bytes32 rcauHash = _hashRCAU(rcau); - _requireAuthorization(agreement.payer, rcauHash, signature, rcau.agreementId, OFFER_TYPE_UPDATE); uint32 expectedNonce = agreement.updateNonce + 1; @@ -529,7 +532,7 @@ contract RecurringCollector is RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; address payer = agreement.payer; - require(payer != address(0), RecurringCollectorAgreementNotFound(agreementId)); + if (payer == address(0)) return; require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); if (agreement.activeTermsHash != termsHash || agreement.state == AgreementState.NotAccepted) { diff --git a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol index f36eb50e0..fb7c06cb1 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/accept.t.sol @@ -26,6 +26,8 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { ) public { // Ensure non-empty signature so the signed path is taken (which checks deadline first) vm.assume(fuzzySignature.length > 0); + // Pranking as the proxy admin hits ProxyDeniedAdminAccess before the deadline check. + vm.assume(fuzzyRCA.dataService != _proxyAdmin); // Generate deterministic agreement ID for validation bytes16 agreementId = _recurringCollector.generateAgreementId( fuzzyRCA.payer, @@ -48,7 +50,7 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { _recurringCollector.accept(fuzzyRCA, fuzzySignature); } - function test_Accept_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { + function test_Accept_Idempotent_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { ( IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, bytes memory signature, @@ -56,14 +58,12 @@ contract RecurringCollectorAcceptTest is RecurringCollectorSharedTest { bytes16 agreementId ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); - bytes memory expectedErr = abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, - agreementId, - IRecurringCollector.AgreementState.Accepted - ); - vm.expectRevert(expectedErr); + // Re-accepting the same RCA is a no-op — succeeds without reverting or re-emitting. + vm.recordLogs(); vm.prank(acceptedRca.dataService); - _recurringCollector.accept(acceptedRca, signature); + bytes16 returnedId = _recurringCollector.accept(acceptedRca, signature); + assertEq(returnedId, agreementId); + assertEq(vm.getRecordedLogs().length, 0, "no event emitted on idempotent re-accept"); } /// @notice Re-accepting an already-accepted RCA at the same hash must still succeed after diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol index fb26e3d99..e535cd130 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptUnsigned.t.sol @@ -128,7 +128,7 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { _recurringCollector.accept(rca, ""); } - function test_AcceptUnsigned_Revert_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { + function test_AcceptUnsigned_Idempotent_WhenAlreadyAccepted(FuzzyTestAccept calldata fuzzyTestAccept) public { MockAgreementOwner approver = _newApprover(); IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( fuzzyTestAccept.rca @@ -143,16 +143,10 @@ contract RecurringCollectorAcceptUnsignedTest is RecurringCollectorSharedTest { vm.prank(rca.dataService); bytes16 agreementId = _recurringCollector.accept(rca, ""); - // Stored offer persists, so authorization passes but state check fails - vm.expectRevert( - abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, - agreementId, - IRecurringCollector.AgreementState.Accepted - ) - ); + // Re-accepting the same RCA is a no-op — succeeds without reverting. vm.prank(rca.dataService); - _recurringCollector.accept(rca, ""); + bytes16 returnedId = _recurringCollector.accept(rca, ""); + assertEq(returnedId, agreementId); } function test_AcceptUnsigned_Revert_WhenDeadlineElapsed() public { diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index 977e08c34..8c724f30d 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -923,16 +923,14 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { } // ══════════════════════════════════════════════════════════════════════ - // Gap 16 — _requirePayer: agreement not found (L528) + // Gap 16 — cancel: silent no-op when agreement not found // ══════════════════════════════════════════════════════════════════════ - function test_Cancel_Revert_WhenAgreementNotFound() public { + function test_Cancel_NoOp_WhenAgreementNotFound() public { bytes16 fakeId = bytes16(keccak256("nonexistent")); address caller = makeAddr("randomCaller"); - vm.expectRevert( - abi.encodeWithSelector(IRecurringCollector.RecurringCollectorAgreementNotFound.selector, fakeId) - ); + // Should not revert — nothing exists on-chain, so cancel is a no-op vm.prank(caller); _recurringCollector.cancel(fakeId, bytes32(0), SCOPE_ACTIVE); } diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index 57e8f0ad3..158157554 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -153,11 +154,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { _recurringCollector.update(rcau, signature); IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(rcau.endsAt, agreement.endsAt); - assertEq(rcau.maxInitialTokens, agreement.maxInitialTokens); - assertEq(rcau.maxOngoingTokensPerSecond, agreement.maxOngoingTokensPerSecond); - assertEq(rcau.minSecondsPerCollection, agreement.minSecondsPerCollection); - assertEq(rcau.maxSecondsPerCollection, agreement.maxSecondsPerCollection); + assertEq(agreement.activeTermsHash, _recurringCollector.hashRCAU(rcau)); assertEq(rcau.nonce, agreement.updateNonce); } @@ -313,5 +310,84 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { assertEq(updatedAgreement2.updateNonce, 2); } + function test_Update_Idempotent_WhenAlreadyAtActiveHash(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = agreementId; + rcau.nonce = 1; + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCAU(rcau, signerKey); + + // First update consumes nonce 1 and sets activeTermsHash = hash(rcau). + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); + + IRecurringCollector.AgreementData memory afterFirst = _recurringCollector.getAgreement(agreementId); + assertEq(afterFirst.updateNonce, 1, "nonce advanced to 1 after first update"); + + // Re-submitting the same RCAU is a no-op — nonce does NOT advance, no event, no revert. + vm.recordLogs(); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(rcau, signature); + assertEq(vm.getRecordedLogs().length, 0, "no event emitted on idempotent re-update"); + + IRecurringCollector.AgreementData memory afterSecond = _recurringCollector.getAgreement(agreementId); + assertEq(afterSecond.updateNonce, 1, "nonce unchanged on idempotent re-update"); + assertEq(afterSecond.activeTermsHash, afterFirst.activeTermsHash, "activeTermsHash unchanged"); + } + + /// @notice Direct-apply update (no prior offer(UPDATE) that staged the RCAU as pending) writes + /// new terms via _validateAndStoreTerms, which must emit OfferStored. AgreementUpdated follows. + function test_Update_EmitsOfferStored_WhenDirectApplyFreshTerms(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory acceptedRca, + , + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = agreementId; + + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory signedRcau, + bytes memory signature + ) = _recurringCollectorHelper.generateSignedRCAUForAgreement(agreementId, rcau, signerKey); + bytes32 rcauHash = _recurringCollector.hashRCAU(signedRcau); + + // Pre-condition: no pending offer staged, so update() takes the direct-apply branch. + assertEq( + _recurringCollector.getAgreement(agreementId).pendingTermsHash, + bytes32(0), + "no pending before direct-apply" + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferStored(agreementId, acceptedRca.payer, OFFER_TYPE_UPDATE, rcauHash); + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.AgreementUpdated( + acceptedRca.dataService, + acceptedRca.payer, + acceptedRca.serviceProvider, + agreementId, + signedRcau.endsAt, + signedRcau.maxInitialTokens, + signedRcau.maxOngoingTokensPerSecond, + signedRcau.minSecondsPerCollection, + signedRcau.maxSecondsPerCollection + ); + vm.prank(acceptedRca.dataService); + _recurringCollector.update(signedRcau, signature); + } + /* solhint-enable graph/func-name-mixedcase */ } From f96b4ea6574c2e706861c420597391c8f1c025c9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 25 Apr 2026 18:06:21 +0000 Subject: [PATCH 115/157] feat(collector): add OfferCancelled event for SCOPE_PENDING cancellations Emit OfferCancelled when cancel() with SCOPE_PENDING deletes a stored RCA or RCAU offer entry. Provides off-chain observability of offer cancellations symmetric to OfferStored. The same event is also emitted by SCOPE_SIGNED cancellations (added in the TRST-L-8 commit on top of this one). --- .../contracts/payments/collectors/RecurringCollector.sol | 9 +++++++-- .../interfaces/contracts/horizon/IRecurringCollector.sol | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index d23276be0..2acad9862 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -538,8 +538,13 @@ contract RecurringCollector is if (agreement.activeTermsHash != termsHash || agreement.state == AgreementState.NotAccepted) { if (options & SCOPE_PENDING != 0) { // Pending scope: delete stored offer if hash matches and terms are not currently active - if ($.rcaOffers[agreementId].offerHash == termsHash) delete $.rcaOffers[agreementId]; - else if ($.rcauOffers[agreementId].offerHash == termsHash) delete $.rcauOffers[agreementId]; + if ($.rcaOffers[agreementId].offerHash == termsHash) { + delete $.rcaOffers[agreementId]; + emit OfferCancelled(msg.sender, agreementId, termsHash); + } else if ($.rcauOffers[agreementId].offerHash == termsHash) { + delete $.rcauOffers[agreementId]; + emit OfferCancelled(msg.sender, agreementId, termsHash); + } } } else if (options & SCOPE_ACTIVE != 0 && agreement.state == AgreementState.Accepted) // Active scope and hash matches: cancel accepted agreement diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 74ccde753..c296ddb68 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -444,6 +444,15 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ event OfferStored(bytes16 indexed agreementId, address indexed payer, uint8 indexed offerType, bytes32 offerHash); + /** + * @notice Emitted when a stored offer is cancelled via {IAgreementCollector.cancel}. + * @dev Fired for SCOPE_PENDING cancellations that delete a stored RCA or RCAU offer entry. + * @param caller The msg.sender of the cancel call (the payer for SCOPE_PENDING) + * @param agreementId The agreement ID + * @param hash The EIP-712 hash of the cancelled offer + */ + event OfferCancelled(address indexed caller, bytes16 indexed agreementId, bytes32 indexed hash); + /** * @notice Pauses the collector, blocking accept, update, collect, and cancel. * @dev Only callable by a pause guardian. Uses OpenZeppelin Pausable. From c1dfc34afa36147d15bcdc822a339b2aa77bdb22 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 11:54:33 +0000 Subject: [PATCH 116/157] feat(collector): per-version semantics in getAgreementDetails (TRST-L-11) Honor the index parameter in getAgreementDetails (previously ignored) and in getAgreementOfferAt (previously used OFFER_TYPE_* values). Per-version flag composition (the queried version, not the underlying agreement): - VERSION_CURRENT: REGISTERED for pre-acceptance offer; REGISTERED | ACCEPTED for accepted active terms; UPDATE additionally set when active terms came from update() (proxy: agreement.updateNonce > 0). Pre-acceptance reads identity from agreement storage (persistent payer from TRST-L-7). - VERSION_NEXT: REGISTERED | UPDATE when a pending RCAU exists, else empty. - index >= 2: empty struct. getAgreementOfferAt mirrored: VERSION_CURRENT returns the active offer (matched by activeTermsHash, RCA pre-update or RCAU post-update); VERSION_NEXT returns the pending RCAU when distinct from the active hash. _offerUpdate's pending result still returns REGISTERED | UPDATE without ACCEPTED. The queried version is the just-stored RCAU, which is not itself accepted (per-version semantics). The auditor's recommendation to OR ACCEPTED is rejected on this point and noted in the audit response. --- .../collectors/RecurringCollector.sol | 71 +++++++++---------- packages/issuance/audits/PR1301/TRST-L-11.md | 11 +++ 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 2acad9862..a44a75525 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -17,10 +17,12 @@ import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/ import { IAgreementOwner } from "@graphprotocol/interfaces/contracts/horizon/IAgreementOwner.sol"; import { IAgreementCollector, + OFFER_TYPE_NONE, OFFER_TYPE_NEW, OFFER_TYPE_UPDATE, ACCEPTED, REGISTERED, + UPDATE, SCOPE_ACTIVE, SCOPE_PENDING, VERSION_CURRENT, @@ -497,7 +499,7 @@ contract RecurringCollector is * @param _data The ABI-encoded RecurringCollectionAgreementUpdate * @return agreementId The agreement ID being updated * @return versionHash The EIP-712 hash of the stored RCAU - * @return index VERSION_NEXT — the queued pending update + * @return index VERSION_NEXT, or VERSION_CURRENT if the RCAU has already been applied */ function _offerUpdate( bytes calldata _data @@ -524,7 +526,9 @@ contract RecurringCollector is emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, versionHash); } - index = VERSION_NEXT; + // If the offered RCAU has already been applied, its hash matches activeTermsHash and the + // version is now CURRENT, not NEXT (_versionHashAt(NEXT) would return 0 in that case). + index = versionHash == agreement.activeTermsHash ? VERSION_CURRENT : VERSION_NEXT; } /// @inheritdoc IAgreementCollector @@ -540,6 +544,7 @@ contract RecurringCollector is // Pending scope: delete stored offer if hash matches and terms are not currently active if ($.rcaOffers[agreementId].offerHash == termsHash) { delete $.rcaOffers[agreementId]; + if (agreement.activeTermsHash == termsHash) agreement.activeTermsHash = bytes32(0); emit OfferCancelled(msg.sender, agreementId, termsHash); } else if ($.rcauOffers[agreementId].offerHash == termsHash) { delete $.rcauOffers[agreementId]; @@ -566,44 +571,35 @@ contract RecurringCollector is * at this stage. * @param agreementId The agreement ID * @param versionHash The EIP-712 hash of the queried version, or bytes32(0) if none + * @param index Version index (VERSION_CURRENT or VERSION_NEXT) — determines per-version flags * @return details AgreementDetails for the queried version, or empty when no version exists */ function _getAgreementDetails( bytes16 agreementId, bytes32 versionHash, - uint256 /* index */ + uint256 index ) private view returns (AgreementDetails memory details) { if (versionHash == bytes32(0)) return details; + details.versionHash = versionHash; - RecurringCollectorStorage storage $ = _getStorage(); - AgreementData storage agreement = $.agreements[agreementId]; + AgreementData storage agreement = _getStorage().agreements[agreementId]; - if (agreement.state != AgreementState.NotAccepted) { - details.agreementId = agreementId; - details.payer = agreement.payer; - details.dataService = agreement.dataService; - details.serviceProvider = agreement.serviceProvider; - details.versionHash = versionHash; - details.state = ACCEPTED; - return details; - } + if (index == VERSION_CURRENT) { + if (agreement.state != AgreementState.NotAccepted) + details.state = (0 < agreement.updateNonce) ? ACCEPTED | UPDATE : ACCEPTED; + } else details.state = UPDATE; - // Not yet accepted — check stored RCA offer - StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; - if (rcaOffer.offerHash != bytes32(0)) { - RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); - details.agreementId = agreementId; - details.payer = rca.payer; - details.dataService = rca.dataService; - details.serviceProvider = rca.serviceProvider; - details.versionHash = rcaOffer.offerHash; - details.state = REGISTERED; - } + details.state |= REGISTERED; + details.agreementId = agreementId; + details.payer = agreement.payer; + details.dataService = agreement.dataService; + details.serviceProvider = agreement.serviceProvider; } /** * @notice Resolve the offer hash representing a given version (VERSION_CURRENT or VERSION_NEXT). - * @dev Returns bytes32(0) when no version exists at that index. + * @dev Returns bytes32(0) when no version exists at that index. Pre-acceptance, activeTermsHash + * mirrors rcaOffers.offerHash, so VERSION_CURRENT works uniformly across pre- and post-acceptance. * @param agreementId The agreement ID * @param index The version index (VERSION_CURRENT or VERSION_NEXT) * @return hash The EIP-712 hash of the offer at that version, or bytes32(0) if none @@ -612,14 +608,10 @@ contract RecurringCollector is RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; - if (index == VERSION_CURRENT) - hash = (agreement.state == AgreementState.NotAccepted) - ? $.rcaOffers[agreementId].offerHash - : agreement.activeTermsHash; + if (index == VERSION_CURRENT) hash = agreement.activeTermsHash; else if (index == VERSION_NEXT) { bytes32 rcauHash = $.rcauOffers[agreementId].offerHash; - // Skip when rcauOffers still holds an applied RCAU — that's the current version, not next. - if (rcauHash != agreement.activeTermsHash) hash = rcauHash; + if (rcauHash != bytes32(0) && rcauHash != agreement.activeTermsHash) hash = rcauHash; } } @@ -633,14 +625,15 @@ contract RecurringCollector is bytes16 agreementId, uint256 index ) external view returns (uint8 offerType, bytes memory offerData) { + bytes32 hash = _versionHashAt(agreementId, index); + if (hash == bytes32(0)) return (OFFER_TYPE_NONE, ""); + RecurringCollectorStorage storage $ = _getStorage(); - if (index == OFFER_TYPE_NEW) { - StoredOffer storage rca = $.rcaOffers[agreementId]; - if (rca.offerHash != bytes32(0)) return (OFFER_TYPE_NEW, rca.data); - } else if (index == OFFER_TYPE_UPDATE) { - StoredOffer storage rcau = $.rcauOffers[agreementId]; - if (rcau.offerHash != bytes32(0)) return (OFFER_TYPE_UPDATE, rcau.data); - } + StoredOffer storage rca = $.rcaOffers[agreementId]; + if (rca.offerHash == hash) return (OFFER_TYPE_NEW, rca.data); + + StoredOffer storage rcau = $.rcauOffers[agreementId]; + if (rcau.offerHash == hash) return (OFFER_TYPE_UPDATE, rcau.data); } /** diff --git a/packages/issuance/audits/PR1301/TRST-L-11.md b/packages/issuance/audits/PR1301/TRST-L-11.md index ad0771c7e..c36a68d1a 100644 --- a/packages/issuance/audits/PR1301/TRST-L-11.md +++ b/packages/issuance/audits/PR1301/TRST-L-11.md @@ -24,3 +24,14 @@ In `_offerUpdate()`, OR the `ACCEPTED` bit into state when the underlying agreem TBD --- + +`getAgreementDetails()` previously ignored the `index` parameter and returned only `ACCEPTED` for any agreement past `NotAccepted`, regardless of whether a pending RCAU also existed. It now honors `index` as a generic version selector with two named aliases: + +- `VERSION_CURRENT = 0` — the active version. For an accepted agreement, returns agreement fields + `activeTermsHash` with `REGISTERED | ACCEPTED`, plus `UPDATE` when the active terms came from an update. Pre-acceptance, returns the stored RCA offer with `REGISTERED`. Identity (`payer`, `dataService`, `serviceProvider`) is read from agreement storage in both cases; these fields are now persisted in `offer()` (see TRST-L-7). +- `VERSION_NEXT = 1` — the next queued version: a pending RCAU awaiting acceptance. Returns `REGISTERED | UPDATE` when present; empty once accepted (at which point it has moved to `VERSION_CURRENT`). + +`getAgreementOfferAt()` mirrors the same per-version semantics: `VERSION_CURRENT` returns the offer that produced `activeTermsHash` (RCA pre-update or RCAU post-update); `VERSION_NEXT` returns the pending RCAU when distinct from the active hash. + +`offer()` and `getAgreementDetails()` share a state composer keyed by version index, so both surfaces report identical flags. Flags split into per-version (`REGISTERED`, `ACCEPTED`, `UPDATE`, `SETTLED`) and per-agreement (`NOTICE_GIVEN`, `BY_PAYER`, `BY_PROVIDER`) groups. `ACCEPTED` is set only when the queried version equals `activeTermsHash`; `SETTLED` is scoped to the version's own claim (active or pending) so a non-zero claim on one version does not suppress `SETTLED` on the other. + +After `update()` promotes an RCAU to active, those bytes live in the RCAU slot. A subsequent `offer(OFFER_TYPE_UPDATE)` with a different hash overwrites that slot and the active RCAU's bytes, therefore they cannot be returned by `getAgreementOfferAt(id, VERSION_CURRENT)`. Resolving this without a hash-keyed terms store would require a third storage slot or a flexible-type slot, both judged disproportionate to the observability concern. From 33d2cede22d4ce5f77fdb3bbe791325d2c6ebce8 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:56:31 +0000 Subject: [PATCH 117/157] feat(collector): compose cancel/settled flags in getAgreementDetails (TRST-R-12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Populate state flags beyond REGISTERED/ACCEPTED/UPDATE so agreement-scoped views distinguish cancelled from live and signal when nothing is currently claimable: - NOTICE_GIVEN + BY_PAYER / BY_PROVIDER — cancelled agreement, origin identified by the BY_* flag. - SETTLED — _getMaxNextClaimScoped(agreementId, 0) returns zero, meaning no tokens are claimable under either active or pending scope. Covers provider-cancelled agreements (immediately non-collectable), fully-collected agreements, and payer-cancelled agreements past their canceledAt window. --- .../collectors/RecurringCollector.sol | 18 +- .../agreementDetailsState.t.sol | 268 ++++++++++++++++++ .../getAgreementDetails.t.sol | 87 +++++- packages/issuance/audits/PR1301/TRST-R-11.md | 2 + packages/issuance/audits/PR1301/TRST-R-12.md | 10 + 5 files changed, 380 insertions(+), 5 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/agreementDetailsState.t.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index a44a75525..ded386dfa 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -22,6 +22,10 @@ import { OFFER_TYPE_UPDATE, ACCEPTED, REGISTERED, + NOTICE_GIVEN, + SETTLED, + BY_PAYER, + BY_PROVIDER, UPDATE, SCOPE_ACTIVE, SCOPE_PENDING, @@ -566,9 +570,7 @@ contract RecurringCollector is * {getAgreementDetails}. * @dev Caller supplies the version hash. {offer} passes the hash returned by _offerNew / * _offerUpdate (already known from the just-stored offer); {getAgreementDetails} resolves - * it via _versionHashAt. Returns empty details when versionHash is zero. The `index` - * parameter is plumbed through for TRST-L-11 (per-version flag composition) and is unused - * at this stage. + * it via _versionHashAt. Returns empty details when versionHash is zero. * @param agreementId The agreement ID * @param versionHash The EIP-712 hash of the queried version, or bytes32(0) if none * @param index Version index (VERSION_CURRENT or VERSION_NEXT) — determines per-version flags @@ -583,9 +585,10 @@ contract RecurringCollector is details.versionHash = versionHash; AgreementData storage agreement = _getStorage().agreements[agreementId]; + AgreementState agreementState = agreement.state; if (index == VERSION_CURRENT) { - if (agreement.state != AgreementState.NotAccepted) + if (agreementState != AgreementState.NotAccepted) details.state = (0 < agreement.updateNonce) ? ACCEPTED | UPDATE : ACCEPTED; } else details.state = UPDATE; @@ -594,6 +597,13 @@ contract RecurringCollector is details.payer = agreement.payer; details.dataService = agreement.dataService; details.serviceProvider = agreement.serviceProvider; + + if (agreementState == AgreementState.CanceledByPayer) details.state |= NOTICE_GIVEN | BY_PAYER; + else if (agreementState == AgreementState.CanceledByServiceProvider) + details.state |= NOTICE_GIVEN | BY_PROVIDER; + + if (_getMaxNextClaimScoped(agreementId, index == VERSION_CURRENT ? SCOPE_ACTIVE : SCOPE_PENDING) == 0) + details.state |= SETTLED; } /** diff --git a/packages/horizon/test/unit/payments/recurring-collector/agreementDetailsState.t.sol b/packages/horizon/test/unit/payments/recurring-collector/agreementDetailsState.t.sol new file mode 100644 index 000000000..0d3d03c98 --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/agreementDetailsState.t.sol @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + IAgreementCollector, + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PROVIDER, + UPDATE, + VERSION_CURRENT, + VERSION_NEXT +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; +import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; + +/// @notice State-flag semantics for AgreementDetails returned by offer() and getAgreementDetails(). +/// Pins down two properties: +/// 1. offer() reports the same lifecycle state as getAgreementDetails() for the queried version +/// (REGISTERED, ACCEPTED, UPDATE, NOTICE_GIVEN, BY_*, SETTLED) — not just the version-specific +/// bits. +/// 2. SETTLED is per-version: VERSION_CURRENT scopes to active terms, VERSION_NEXT to pending — +/// a non-zero claim on one version must not suppress SETTLED on the other. +contract RecurringCollectorAgreementDetailsStateTest is RecurringCollectorSharedTest { + /* solhint-disable graph/func-name-mixedcase */ + + function _makeRca(address payer) internal returns (IRecurringCollector.RecurringCollectionAgreement memory) { + return + _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: payer, + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + } + + function _makeRcau( + bytes16 agreementId, + IRecurringCollector.RecurringCollectionAgreement memory rca, + uint64 deadline + ) internal pure returns (IRecurringCollector.RecurringCollectionAgreementUpdate memory) { + return + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: deadline, + endsAt: rca.endsAt + 30 days, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond * 2, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 0, + nonce: 1, + metadata: "" + }); + } + + function _acceptUnsigned( + MockAgreementOwner approver, + IRecurringCollector.RecurringCollectionAgreement memory rca + ) internal returns (bytes16) { + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + return _recurringCollector.accept(rca, ""); + } + + // ────────────────────────────────────────────────────────────────────── + // offer() return state mirrors getAgreementDetails() + // ────────────────────────────────────────────────────────────────────── + + /// @notice Fresh offer(NEW) on a never-seen agreement returns REGISTERED only. + function test_OfferNew_FreshOffer_State_Registered() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + + assertEq(details.state, REGISTERED, "fresh offer(NEW): REGISTERED only"); + } + + /// @notice Fresh offer(UPDATE) on an accepted agreement returns REGISTERED|UPDATE only. + function test_OfferUpdate_FreshOffer_State_RegisteredUpdate() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau( + agreementId, + rca, + uint64(block.timestamp + 1 hours) + ); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_UPDATE, + abi.encode(rcau), + 0 + ); + + assertEq(details.state, REGISTERED | UPDATE, "fresh offer(UPDATE): REGISTERED|UPDATE"); + } + + /// @notice Re-offering an already-accepted RCA hits the idempotent path and must report + /// ACCEPTED — the offered version is the active accepted terms. + function test_OfferNew_AfterAccept_State_RegisteredAccepted() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _acceptUnsigned(approver, rca); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + + assertEq(details.state, REGISTERED | ACCEPTED, "re-offer(NEW) after accept: REGISTERED|ACCEPTED"); + } + + /// @notice Re-offering an already-applied RCAU hits the idempotent path; since the RCAU is + /// now the active terms, the queried version is CURRENT, so state is REGISTERED|ACCEPTED|UPDATE. + function test_OfferUpdate_AfterApply_State_RegisteredAcceptedUpdate() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes16 agreementId = _acceptUnsigned(approver, rca); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau( + agreementId, + rca, + uint64(block.timestamp + 1 hours) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_UPDATE, + abi.encode(rcau), + 0 + ); + + assertEq( + details.state, + REGISTERED | ACCEPTED | UPDATE, + "re-offer(UPDATE) after apply: REGISTERED|ACCEPTED|UPDATE" + ); + } + + /// @notice Re-offering an RCA after the agreement was canceled by the service provider must + /// surface NOTICE_GIVEN|BY_PROVIDER (and SETTLED, since active claim is zero in this state). + function test_OfferNew_AfterProviderCancel_State_FullyDecorated() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes16 agreementId = _acceptUnsigned(approver, rca); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory details = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + + assertEq( + details.state, + REGISTERED | ACCEPTED | NOTICE_GIVEN | BY_PROVIDER | SETTLED, + "re-offer(NEW) after provider cancel: REGISTERED|ACCEPTED|NOTICE_GIVEN|BY_PROVIDER|SETTLED" + ); + } + + // ────────────────────────────────────────────────────────────────────── + // SETTLED is per-version (active vs pending scoping) + // ────────────────────────────────────────────────────────────────────── + + /// @notice Pending RCAU past its deadline contributes 0 to claim. With per-version SETTLED + /// scoping, VERSION_NEXT reports SETTLED even though the active terms still have claim. + /// Pre-fix (unscoped getMaxNextClaim) would have suppressed SETTLED here. + function test_GetAgreementDetails_VersionNext_SettledIndependentOfActive() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + bytes16 agreementId = _acceptUnsigned(approver, rca); + + uint64 rcauDeadline = uint64(block.timestamp + 1 hours); + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, rcauDeadline); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Past pending deadline — pending claim is 0, but active claim still grows. + vm.warp(rcauDeadline + 1); + + IAgreementCollector.AgreementDetails memory next = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_NEXT + ); + IAgreementCollector.AgreementDetails memory current = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_CURRENT + ); + + assertEq(next.state & SETTLED, SETTLED, "VERSION_NEXT: SETTLED set when pending claim is 0"); + assertEq(current.state & SETTLED, 0, "VERSION_CURRENT: SETTLED not set when active claim is non-zero"); + } + + /// @notice Active terms past their offer deadline (still NotAccepted) have 0 active claim. + /// With per-version scoping, VERSION_CURRENT reports SETTLED even though a fresh pending + /// update still has non-zero claim. Pre-fix, the pending claim would have masked SETTLED. + function test_GetAgreementDetails_VersionCurrent_SettledIndependentOfPending() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + vm.prank(address(approver)); + IAgreementCollector.AgreementDetails memory offered = _recurringCollector.offer( + OFFER_TYPE_NEW, + abi.encode(rca), + 0 + ); + bytes16 agreementId = offered.agreementId; + + // Pending update with a far-future deadline — its claim stays non-zero after the warp. + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau( + agreementId, + rca, + uint64(block.timestamp + 30 days) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Past the RCA's offer deadline — active claim drops to 0 (state still NotAccepted, no + // valid pre-acceptance offer). + vm.warp(rca.deadline + 1); + + IAgreementCollector.AgreementDetails memory current = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_CURRENT + ); + IAgreementCollector.AgreementDetails memory next = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_NEXT + ); + + assertEq(current.state & SETTLED, SETTLED, "VERSION_CURRENT: SETTLED set when active claim is 0"); + assertEq(next.state & SETTLED, 0, "VERSION_NEXT: SETTLED not set when pending claim is non-zero"); + } +} diff --git a/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol index 91d788020..42c847394 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/getAgreementDetails.t.sol @@ -5,7 +5,13 @@ import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon import { IAgreementCollector, OFFER_TYPE_NEW, - REGISTERED + REGISTERED, + ACCEPTED, + NOTICE_GIVEN, + SETTLED, + BY_PAYER, + BY_PROVIDER, + VERSION_CURRENT } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -107,4 +113,83 @@ contract RecurringCollectorGetAgreementDetailsTest is RecurringCollectorSharedTe assertEq(details.serviceProvider, rca.serviceProvider); assertNotEq(details.versionHash, bytes32(0)); } + + // -- Cancel sets NOTICE_GIVEN + origin flag; provider cancel is always SETTLED -- + + function test_GetAgreementDetails_CanceledByServiceProvider_Flags(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.ServiceProvider); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_CURRENT + ); + + assertEq( + details.state, + REGISTERED | ACCEPTED | NOTICE_GIVEN | BY_PROVIDER | SETTLED, + "provider cancel: REGISTERED|ACCEPTED|NOTICE_GIVEN|BY_PROVIDER|SETTLED" + ); + } + + function test_GetAgreementDetails_CanceledByPayer_Flags(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_CURRENT + ); + + uint16 baseline = REGISTERED | ACCEPTED | NOTICE_GIVEN | BY_PAYER; + assertTrue( + details.state == baseline || details.state == (baseline | SETTLED), + "payer cancel: REGISTERED|ACCEPTED|NOTICE_GIVEN|BY_PAYER (+SETTLED if fully elapsed)" + ); + assertEq(details.state & NOTICE_GIVEN, NOTICE_GIVEN, "NOTICE_GIVEN set"); + assertEq(details.state & BY_PAYER, BY_PAYER, "BY_PAYER set"); + assertEq(details.state & BY_PROVIDER, 0, "BY_PROVIDER not set"); + } + + // -- Accepted agreement with nothing left to claim reports SETTLED -- + + function test_GetAgreementDetails_Accepted_ElapsedSetsSettled(FuzzyTestAccept calldata fuzzyTestAccept) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + , + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestAccept); + + // Jump past the agreement's end so no further collection is possible once lastCollectionAt + // catches up. Without any collections, _getMaxNextClaim still returns a non-zero value + // (late-collection semantics), so the clearest SETTLED case is via provider cancel — but + // we want to assert the non-cancel path here too. Simulate fully-collected state by + // advancing to endsAt + 1 and marking lastCollectionAt == endsAt via a well-formed path: + // easiest is a payer cancel far in the past (canceledAt in the past → window empty). + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + vm.warp(rca.endsAt + 1); + + IAgreementCollector.AgreementDetails memory details = _recurringCollector.getAgreementDetails( + agreementId, + VERSION_CURRENT + ); + + assertEq(details.state & SETTLED, SETTLED, "SETTLED set when nothing left to claim"); + } } diff --git a/packages/issuance/audits/PR1301/TRST-R-11.md b/packages/issuance/audits/PR1301/TRST-R-11.md index 0bc206182..f8169c789 100644 --- a/packages/issuance/audits/PR1301/TRST-R-11.md +++ b/packages/issuance/audits/PR1301/TRST-R-11.md @@ -11,3 +11,5 @@ Removed unused flags: `AUTO_UPDATE`, `AUTO_UPDATED`, `BY_DATA_SERVICE`, `WITH_NOTICE` and `IF_NOT_ACCEPTED` are dropped from the interface. NatSpec updated for remaining flags with new semantics. + +In RecurringCollector `NOTICE_GIVEN`, `SETTLED`, `BY_PAYER`, `BY_PROVIDER` are now set by `getAgreementDetails` to describe cancel origin and collectability (see TRST-R-12 fix). diff --git a/packages/issuance/audits/PR1301/TRST-R-12.md b/packages/issuance/audits/PR1301/TRST-R-12.md index a73ed9648..834cb66e8 100644 --- a/packages/issuance/audits/PR1301/TRST-R-12.md +++ b/packages/issuance/audits/PR1301/TRST-R-12.md @@ -5,3 +5,13 @@ ## Description In `getAgreementDetails()`, any agreement whose state is not `AgreementState.NotAccepted` is reported with state flag `ACCEPTED`. This includes agreements that have been cancelled (`CanceledByPayer` or `CanceledByServiceProvider`). Integrators inspecting the returned state cannot distinguish cancelled agreements from live ones without reading separate storage. Document this behavior in the interface, or extend the state bitmask with a `CANCELED` flag and return it for the non-active terminal states. + +--- + +Reusing the existing interface flags instead of adding a `CANCELED` flag. `getAgreementDetails` now composes cancel and collectability information: + +- `NOTICE_GIVEN` — set on cancelled agreements (collection window truncated). +- `BY_PAYER` / `BY_PROVIDER` — paired with `NOTICE_GIVEN` to identify the cancel origin. +- `SETTLED` — per-version: set when nothing is claimable under the queried version's terms (active claim for `VERSION_CURRENT`, pending claim for `VERSION_NEXT`). + +`ACCEPTED` is also narrowed: it is now only set on the active-slot version (`VERSION_CURRENT`) of agreements past `NotAccepted`, so pending updates (`VERSION_NEXT`) no longer report `ACCEPTED`. Integrators distinguish cancelled-vs-live by `NOTICE_GIVEN`, and stop-collecting-now via `SETTLED`. See the TRST-R-11 fix for the accompanying flag cleanup. From fe13b1128c8a8452b74355d8f7b7dddf9b581096 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:27:32 +0000 Subject: [PATCH 118/157] feat(collector): add SCOPE_SIGNED to cancel() for EOA offer revocation (TRST-L-8) Give EOA signers an on-chain revocation path via cancel(agreementId, termsHash, SCOPE_SIGNED). Records cancelledOffers[msg.sender][termsHash] = agreementId; _requireAuthorization rejects when the stored agreementId matches. Self-authenticating, idempotent, reversible (bytes16(0) undoes), and combinable with SCOPE_PENDING/SCOPE_ACTIVE. Builds on the version-indexed storage and idempotent cancel semantics from the preceding L-11 refactor: SCOPE_SIGNED is added as a new branch at the top of cancel() alongside the existing SCOPE_PENDING / SCOPE_ACTIVE handling, and the cancelledOffers lookup slots into _requireAuthorization's signed branch. --- .../collectors/RecurringCollector.sol | 34 ++- .../recurring-collector/cancelSignature.t.sol | 256 ++++++++++++++++++ .../contracts/horizon/IAgreementCollector.sol | 14 +- .../contracts/horizon/IRecurringCollector.sol | 7 + packages/issuance/audits/PR1301/TRST-L-8.md | 2 + 5 files changed, 304 insertions(+), 9 deletions(-) create mode 100644 packages/horizon/test/unit/payments/recurring-collector/cancelSignature.t.sol diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index ded386dfa..76f20062d 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -29,6 +29,7 @@ import { UPDATE, SCOPE_ACTIVE, SCOPE_PENDING, + SCOPE_SIGNED, VERSION_CURRENT, VERSION_NEXT } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; @@ -108,6 +109,9 @@ contract RecurringCollector is mapping(bytes16 agreementId => StoredOffer offer) rcaOffers; /// @notice Stored RCAU offers (pre-approval), keyed by agreement ID mapping(bytes16 agreementId => StoredOffer offer) rcauOffers; + /// @notice Cancelled offer hashes, keyed by signer then EIP-712 hash. + /// Stores the agreementId that is blocked; bytes16(0) means not cancelled. + mapping(address signer => mapping(bytes32 hash => bytes16 agreementId)) cancelledOffers; } /// @dev keccak256(abi.encode(uint256(keccak256("graphprotocol.storage.RecurringCollector")) - 1)) & ~bytes32(uint256(0xff)) @@ -536,11 +540,31 @@ contract RecurringCollector is } /// @inheritdoc IAgreementCollector + /// @dev This implementation targets only the payer side of the agreement. + /// SCOPE_PENDING and SCOPE_ACTIVE enforce `msg.sender == agreement.payer`. + /// SCOPE_SIGNED has no caller check in this function; the entry it writes is + /// self-keyed by msg.sender and is consulted only later, during payer + /// authorization of a signed accept or update. Extending cancel to data-service + /// or service-provider callers is left for a future revision. function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external whenNotPaused { RecurringCollectorStorage storage $ = _getStorage(); AgreementData storage agreement = $.agreements[agreementId]; + + // Signed scope: record cancelledOffers[msg.sender][termsHash] = agreementId. + // Self-authenticating — only blocks when msg.sender matches the recovered ECDSA signer. + // The stored agreementId is checked in _requireAuthorization (!=); calling again + // with bytes16(0) undoes the cancellation, calling with a different agreementId + // redirects it. + if (options & SCOPE_SIGNED != 0) { + if ($.cancelledOffers[msg.sender][termsHash] != agreementId) { + $.cancelledOffers[msg.sender][termsHash] = agreementId; + emit OfferCancelled(msg.sender, agreementId, termsHash); + } + } + + // Pending / active scopes require payer authorization. No-op if nothing exists on-chain. address payer = agreement.payer; - if (payer == address(0)) return; + if (options & (SCOPE_PENDING | SCOPE_ACTIVE) == 0 || payer == address(0)) return; require(msg.sender == payer, RecurringCollectorUnauthorizedCaller(msg.sender, payer)); if (agreement.activeTermsHash != termsHash || agreement.state == AgreementState.NotAccepted) { @@ -1068,9 +1092,11 @@ contract RecurringCollector is ) private view { RecurringCollectorStorage storage $ = _getStorage(); - if (0 < _signature.length) - require(_isAuthorized(_payer, ECDSA.recover(_hash, _signature)), RecurringCollectorInvalidSigner()); - else + if (0 < _signature.length) { + address signer = ECDSA.recover(_hash, _signature); + require(_isAuthorized(_payer, signer), RecurringCollectorInvalidSigner()); + require($.cancelledOffers[signer][_hash] != _agreementId, RecurringCollectorOfferCancelled(signer, _hash)); + } else // Check stored offer hash instead of callback require( (_offerType == OFFER_TYPE_NEW ? $.rcaOffers[_agreementId] : $.rcauOffers[_agreementId]).offerHash == diff --git a/packages/horizon/test/unit/payments/recurring-collector/cancelSignature.t.sol b/packages/horizon/test/unit/payments/recurring-collector/cancelSignature.t.sol new file mode 100644 index 000000000..9dadf2f6a --- /dev/null +++ b/packages/horizon/test/unit/payments/recurring-collector/cancelSignature.t.sol @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { + SCOPE_SIGNED, + SCOPE_ACTIVE, + SCOPE_PENDING +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; + +import { RecurringCollectorSharedTest } from "./shared.t.sol"; + +contract RecurringCollectorCancelSignedOfferTest is RecurringCollectorSharedTest { + /* + * TESTS + */ + + /* solhint-disable graph/func-name-mixedcase */ + + function test_CancelSigned_BlocksAccept(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED); + + // Accepting with the cancelled signature should revert + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorOfferCancelled.selector, signer, rcaHash) + ); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + function test_CancelSigned_EmitsEvent(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(signer, agreementId, rcaHash); + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED); + } + + function test_CancelSigned_BlocksUpdate(FuzzyTestUpdate calldata fuzzyTestUpdate) public { + ( + IRecurringCollector.RecurringCollectionAgreement memory rca, + , + uint256 signerKey, + bytes16 agreementId + ) = _sensibleAuthorizeAndAccept(fuzzyTestUpdate.fuzzyTestAccept); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + fuzzyTestUpdate.rcau + ); + rcau.agreementId = agreementId; + + ( + IRecurringCollector.RecurringCollectionAgreementUpdate memory signedRcau, + bytes memory rcauSig + ) = _recurringCollectorHelper.generateSignedRCAUForAgreement(agreementId, rcau, signerKey); + bytes32 rcauHash = _recurringCollector.hashRCAU(signedRcau); + address signer = vm.addr(signerKey); + + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_SIGNED); + + // Updating with the cancelled signature should revert + vm.expectRevert( + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorOfferCancelled.selector, signer, rcauHash) + ); + vm.prank(rca.dataService); + _recurringCollector.update(signedRcau, rcauSig); + } + + function test_CancelSigned_Idempotent(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED); + + // Second call succeeds silently — no revert, no event + vm.recordLogs(); + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED); + assertEq(vm.getRecordedLogs().length, 0); + } + + function test_CancelSigned_DoesNotAffectDifferentSigner( + FuzzyTestAccept calldata fuzzyTestAccept1, + FuzzyTestAccept calldata fuzzyTestAccept2 + ) public { + IRecurringCollector.RecurringCollectionAgreement memory rca1 = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept1.rca + ); + uint256 signerKey1 = boundKey(fuzzyTestAccept1.unboundedSignerKey); + + IRecurringCollector.RecurringCollectionAgreement memory rca2 = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept2.rca + ); + uint256 signerKey2 = boundKey(fuzzyTestAccept2.unboundedSignerKey); + + vm.assume(rca1.payer != rca2.payer); + vm.assume(vm.addr(signerKey1) != vm.addr(signerKey2)); + + _recurringCollectorHelper.authorizeSignerWithChecks(rca1.payer, signerKey1); + _recurringCollectorHelper.authorizeSignerWithChecks(rca2.payer, signerKey2); + + bytes32 rcaHash = _recurringCollector.hashRCA(rca1); + + // Signer1 cancels — should not affect signer2 + vm.prank(vm.addr(signerKey1)); + _recurringCollector.cancel(bytes16(0), rcaHash, SCOPE_SIGNED); + + // Signer2's signatures for the same hash are unaffected + // (signer-scoped, not hash-global) + } + + function test_CancelSigned_SelfAuthenticating(FuzzyTestAccept calldata fuzzyTestAccept, address anyAddress) public { + // Any address can call cancel with SCOPE_SIGNED — it only records for msg.sender + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + vm.assume(anyAddress != address(0)); + vm.assume(anyAddress != _proxyAdmin); + + // Should not revert — self-authenticating, no _requirePayer + vm.prank(anyAddress); + _recurringCollector.cancel(bytes16(0), rcaHash, SCOPE_SIGNED); + } + + function test_CancelSigned_CombinedWithActiveDoesNotRevert(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + // SCOPE_SIGNED | SCOPE_ACTIVE with no accepted agreement — should not revert. + // The signed recording succeeds; the active scope is skipped because nothing on-chain. + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(signer, agreementId, rcaHash); + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED | SCOPE_ACTIVE); + } + + function test_CancelSigned_CombinedWithPendingDoesNotRevert(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + // SCOPE_SIGNED | SCOPE_PENDING with no agreement — should not revert. + vm.expectEmit(address(_recurringCollector)); + emit IRecurringCollector.OfferCancelled(signer, agreementId, rcaHash); + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED | SCOPE_PENDING); + } + + function test_CancelSigned_UndoWithZero(FuzzyTestAccept calldata fuzzyTestAccept) public { + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + fuzzyTestAccept.rca + ); + uint256 signerKey = boundKey(fuzzyTestAccept.unboundedSignerKey); + _recurringCollectorHelper.authorizeSignerWithChecks(rca.payer, signerKey); + + (, bytes memory signature) = _recurringCollectorHelper.generateSignedRCA(rca, signerKey); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + address signer = vm.addr(signerKey); + bytes16 agreementId = _recurringCollector.generateAgreementId( + rca.payer, + rca.dataService, + rca.serviceProvider, + rca.deadline, + rca.nonce + ); + + // Cancel + vm.prank(signer); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_SIGNED); + + // Undo by calling with bytes16(0) + vm.prank(signer); + _recurringCollector.cancel(bytes16(0), rcaHash, SCOPE_SIGNED); + + // Accept should now succeed + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + _recurringCollector.accept(rca, signature); + } + + /* solhint-enable graph/func-name-mixedcase */ +} diff --git a/packages/interfaces/contracts/horizon/IAgreementCollector.sol b/packages/interfaces/contracts/horizon/IAgreementCollector.sol index 3e2d694fc..5595466c7 100644 --- a/packages/interfaces/contracts/horizon/IAgreementCollector.sol +++ b/packages/interfaces/contracts/horizon/IAgreementCollector.sol @@ -47,6 +47,8 @@ uint8 constant OFFER_TYPE_UPDATE = 2; uint8 constant SCOPE_ACTIVE = 1; /// @dev Cancel targets pending offers uint8 constant SCOPE_PENDING = 2; +/// @dev Cancel targets signed offers +uint8 constant SCOPE_SIGNED = 4; // -- Version indices (shared by getAgreementDetails and getAgreementOfferAt) -- // @@ -131,12 +133,14 @@ interface IAgreementCollector is IPaymentsCollector { function offer(uint8 offerType, bytes calldata data, uint16 options) external returns (AgreementDetails memory); /** - * @notice Cancel an agreement or revoke a pending offer. - * @dev Scopes can be combined. SCOPE_PENDING and SCOPE_ACTIVE require payer authorization - * and no-op if nothing exists on-chain. - * @param agreementId The agreement's ID. + * @notice Cancel an agreement, revoke a pending offer, or invalidate a signed offer. + * @dev Scopes can be combined. SCOPE_SIGNED is self-authenticating (keyed by msg.sender); + * SCOPE_PENDING and SCOPE_ACTIVE require payer authorization and no-op if nothing exists on-chain. + * @param agreementId The agreement's ID. For SCOPE_SIGNED, only blocks accept/update when + * the agreementId matches; passing bytes16(0) undoes a previous cancellation. * @param termsHash EIP-712 hash identifying which terms to cancel. - * @param options Bitmask — SCOPE_ACTIVE (1) active terms, SCOPE_PENDING (2) pending offers. + * @param options Bitmask — SCOPE_ACTIVE (1) active terms, SCOPE_PENDING (2) pending offers, + * SCOPE_SIGNED (4) signed offers. */ function cancel(bytes16 agreementId, bytes32 termsHash, uint16 options) external; diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index c296ddb68..747b38e44 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -417,6 +417,13 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ error RecurringCollectorPauseGuardianNoChange(address account, bool allowed); + /** + * @notice Thrown when accepting or updating with a hash that the signer cancelled via SCOPE_SIGNED + * @param signer The signer who cancelled the offer + * @param hash The cancelled EIP-712 hash + */ + error RecurringCollectorOfferCancelled(address signer, bytes32 hash); + /** * @notice Emitted when a pause guardian is set * @param account The address of the pause guardian diff --git a/packages/issuance/audits/PR1301/TRST-L-8.md b/packages/issuance/audits/PR1301/TRST-L-8.md index 90911d2d3..c85f413d0 100644 --- a/packages/issuance/audits/PR1301/TRST-L-8.md +++ b/packages/issuance/audits/PR1301/TRST-L-8.md @@ -20,3 +20,5 @@ Expose a `cancelSignature(bytes32 hash)` entry point that records the hash as in TBD --- + +Added `SCOPE_SIGNED` flag to `cancel()`, giving EOA signers an on-chain revocation path like contract payers already have via `SCOPE_PENDING`. The signer calls `cancel(agreementId, termsHash, SCOPE_SIGNED)` which records `cancelledOffers[msg.sender][termsHash] = agreementId`. When `accept()` or `update()` later processes a signature, `_requireAuthorization` recovers the signer via ECDSA and rejects if the stored agreementId matches. Self-authenticating (keyed by signer address), idempotent, reversible (calling again with `bytes16(0)` undoes the cancellation), and combinable with other scopes. Also made `cancel` no-op when nothing exists on-chain instead of reverting. From b13d9106cb5cca7b38220db8767ead5b552fc027 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 09:24:57 +0000 Subject: [PATCH 119/157] feat(issuance): expose getIssuanceAllocator on IIssuanceTarget Every issuance target should expose its allocator. Add getIssuanceAllocator() returning IIssuanceAllocationDistribution to IIssuanceTarget. Implement in RecurringAgreementManager (reads from storage), DirectAllocation (stores and returns), and RewardsManager (existing impl, moved from IRewardsManager to IIssuanceTarget). Also change IIssuanceTarget.setIssuanceAllocator parameter from address to IIssuanceAllocationDistribution for compile-time type safety. --- .../unit/rewards/rewards-interface.test.ts | 4 +- .../contracts/rewards/RewardsManager.sol | 17 ++-- packages/deployment/lib/abis.ts | 10 +- .../test/interface-id-stability.test.ts | 34 +++++++ .../recurring-collector/coverageGaps.t.sol | 7 +- .../recurring-collector/mixedPath.t.sol | 33 +++++-- .../payments/recurring-collector/update.t.sol | 4 +- .../contracts/rewards/IRewardsManager.sol | 8 -- .../issuance/allocate/IIssuanceTarget.sol | 15 ++- .../agreement/RecurringAgreementManager.sol | 21 +++-- .../contracts/allocate/DirectAllocation.sol | 66 ++++++++++++- .../test/allocate/MockNotificationTracker.sol | 8 +- .../test/allocate/MockReentrantTarget.sol | 9 +- .../test/allocate/MockRevertingTarget.sol | 10 +- .../test/allocate/MockSimpleTarget.sol | 8 +- .../unit/agreement-manager/approver.t.sol | 5 +- .../agreement-manager/branchCoverage.t.sol | 77 ++++++++++++++- .../unit/agreement-manager/callbackGas.t.sol | 3 +- .../agreement-manager/ensureDistributed.t.sol | 21 +++-- .../test/unit/allocator/distribution.t.sol | 3 +- .../unit/allocator/interfaceIdStability.t.sol | 2 +- .../direct-allocation/DirectAllocation.t.sol | 93 ++++++++++++++++++- .../test/harness/FullStackHarness.t.sol | 3 +- .../test/harness/RealStackHarness.t.sol | 3 +- 24 files changed, 390 insertions(+), 74 deletions(-) create mode 100644 packages/deployment/test/interface-id-stability.test.ts diff --git a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts index 63280f5e8..7bbfebe6b 100644 --- a/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts +++ b/packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts @@ -54,11 +54,11 @@ describe('RewardsManager interfaces', () => { }) it('IIssuanceTarget should have stable interface ID', () => { - expect(IIssuanceTarget__factory.interfaceId).to.equal('0xaee4dc43') + expect(IIssuanceTarget__factory.interfaceId).to.equal('0x19f6601a') }) it('IRewardsManager should have stable interface ID', () => { - expect(IRewardsManager__factory.interfaceId).to.equal('0x337b092e') + expect(IRewardsManager__factory.interfaceId).to.equal('0x8469b577') }) }) diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index a0ca5ca20..f251dc5f8 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -173,24 +173,25 @@ contract RewardsManager is * Note that the IssuanceAllocator can be set to the zero address to disable use of an allocator, and * use the local `issuancePerBlock` variable instead to control issuance. */ - function setIssuanceAllocator(address newIssuanceAllocator) external override onlyGovernor { - if (address(issuanceAllocator) != newIssuanceAllocator) { + function setIssuanceAllocator(IIssuanceAllocationDistribution newIssuanceAllocator) external override onlyGovernor { + if (issuanceAllocator != newIssuanceAllocator) { // Update rewards calculation before changing the issuance allocator updateAccRewardsPerSignal(); // Check that the contract supports the IIssuanceAllocationDistribution interface // Allow zero address to disable the allocator - if (newIssuanceAllocator != address(0)) { + if (address(newIssuanceAllocator) != address(0)) { // solhint-disable-next-line gas-small-strings require( - IERC165(newIssuanceAllocator).supportsInterface(type(IIssuanceAllocationDistribution).interfaceId), + IERC165(address(newIssuanceAllocator)).supportsInterface( + type(IIssuanceAllocationDistribution).interfaceId + ), "Contract does not support IIssuanceAllocationDistribution interface" ); } - address oldIssuanceAllocator = address(issuanceAllocator); - issuanceAllocator = IIssuanceAllocationDistribution(newIssuanceAllocator); - emit IssuanceAllocatorSet(oldIssuanceAllocator, newIssuanceAllocator); + emit IssuanceAllocatorSet(issuanceAllocator, newIssuanceAllocator); + issuanceAllocator = newIssuanceAllocator; } } @@ -325,7 +326,7 @@ contract RewardsManager is } /** - * @inheritdoc IRewardsManager + * @inheritdoc IIssuanceTarget */ function getIssuanceAllocator() external view override returns (IIssuanceAllocationDistribution) { return issuanceAllocator; diff --git a/packages/deployment/lib/abis.ts b/packages/deployment/lib/abis.ts index e9894d213..b7b0868b2 100644 --- a/packages/deployment/lib/abis.ts +++ b/packages/deployment/lib/abis.ts @@ -17,12 +17,12 @@ function loadAbi(artifactPath: string): Abi { return artifact.abi as Abi } -// Interface IDs - these match the generated values from TypeChain factories -// Verified by tests: packages/issuance/testing/tests/allocate/InterfaceIdStability.test.ts -// and packages/contracts-test/tests/unit/rewards/rewards-interface.test.ts +// Interface IDs - these mirror the values the compiler derives from the +// corresponding ABI. Cross-checked by test/interface-id-stability.test.ts; +// update both together whenever an interface changes. export const IERC165_INTERFACE_ID = '0x01ffc9a7' as const -export const IISSUANCE_TARGET_INTERFACE_ID = '0xaee4dc43' as const -export const IREWARDS_MANAGER_INTERFACE_ID = '0xa0a2f219' as const +export const IISSUANCE_TARGET_INTERFACE_ID = '0x19f6601a' as const +export const IREWARDS_MANAGER_INTERFACE_ID = '0x8469b577' as const export const REWARDS_MANAGER_ABI = loadAbi( '@graphprotocol/interfaces/artifacts/contracts/contracts/rewards/IRewardsManager.sol/IRewardsManager.json', diff --git a/packages/deployment/test/interface-id-stability.test.ts b/packages/deployment/test/interface-id-stability.test.ts new file mode 100644 index 000000000..5d0ed1225 --- /dev/null +++ b/packages/deployment/test/interface-id-stability.test.ts @@ -0,0 +1,34 @@ +import { expect } from 'chai' +import type { Abi } from 'viem' +import { toFunctionSelector } from 'viem' + +import { + IERC165_ABI, + IERC165_INTERFACE_ID, + IISSUANCE_TARGET_INTERFACE_ID, + IREWARDS_MANAGER_INTERFACE_ID, + ISSUANCE_TARGET_ABI, + REWARDS_MANAGER_ABI, +} from '../lib/abis.js' + +function computeInterfaceId(abi: Abi): `0x${string}` { + const xor = abi + .filter((item): item is Extract<(typeof abi)[number], { type: 'function' }> => item.type === 'function') + .map((f) => Number.parseInt(toFunctionSelector(f).slice(2), 16) >>> 0) + .reduce((a, s) => (a ^ s) >>> 0, 0) + return `0x${xor.toString(16).padStart(8, '0')}` +} + +describe('Interface ID Stability', function () { + it('IERC165_INTERFACE_ID matches the IERC165 ABI', function () { + expect(IERC165_INTERFACE_ID).to.equal(computeInterfaceId(IERC165_ABI)) + }) + + it('IISSUANCE_TARGET_INTERFACE_ID matches the IIssuanceTarget ABI', function () { + expect(IISSUANCE_TARGET_INTERFACE_ID).to.equal(computeInterfaceId(ISSUANCE_TARGET_ABI)) + }) + + it('IREWARDS_MANAGER_INTERFACE_ID matches the IRewardsManager ABI', function () { + expect(IREWARDS_MANAGER_INTERFACE_ID).to.equal(computeInterfaceId(REWARDS_MANAGER_ABI)) + }) +}) diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index 8c724f30d..6d9713cbf 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -9,6 +9,7 @@ import { OFFER_TYPE_UPDATE, SCOPE_ACTIVE, SCOPE_PENDING, + VERSION_NEXT, IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; @@ -907,7 +908,11 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { IRecurringCollector.AgreementData memory after1 = _recurringCollector.getAgreement(agreementId); assertEq(after1.activeTermsHash, bytes32(0), "active should be cleared"); - assertEq(after1.pendingTermsHash, rcauHash, "pending RCAU should survive RCA cancel"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + rcauHash, + "pending RCAU should survive RCA cancel" + ); assertEq(after1.payer, address(approver), "agreement.payer persists for subsequent auth"); // Now cancel the pending RCAU — payer auth still works via persistent agreement.payer diff --git a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol index 659979dee..9d4ed946a 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/mixedPath.t.sol @@ -2,7 +2,12 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; -import { OFFER_TYPE_NEW, OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { + OFFER_TYPE_NEW, + OFFER_TYPE_UPDATE, + VERSION_CURRENT, + VERSION_NEXT +} from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; @@ -254,9 +259,16 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); // Pre-check: pending is set - IRecurringCollector.AgreementData memory before = _recurringCollector.getAgreement(agreementId); - assertEq(before.activeTermsHash, rca1Hash, "active should be rca1Hash after offer"); - assertEq(before.pendingTermsHash, rcauHash, "pending should be rcauHash after offer UPDATE"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_CURRENT).versionHash, + rca1Hash, + "active should be rca1Hash after offer" + ); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + rcauHash, + "pending should be rcauHash after offer UPDATE" + ); // Step 3: offer different RCA with same primary fields (same agreementId, different terms) IRecurringCollector.RecurringCollectionAgreement memory rca2 = rca1; @@ -266,9 +278,16 @@ contract RecurringCollectorMixedPathTest is RecurringCollectorSharedTest { bytes32 rca2Hash = _recurringCollector.hashRCA(rca2); // Post-check: active replaced, pending preserved (still the original RCAU) - IRecurringCollector.AgreementData memory afterOffer = _recurringCollector.getAgreement(agreementId); - assertEq(afterOffer.activeTermsHash, rca2Hash, "active should be rca2Hash"); - assertEq(afterOffer.pendingTermsHash, rcauHash, "pending RCAU should still be queued"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_CURRENT).versionHash, + rca2Hash, + "active should be rca2Hash" + ); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + rcauHash, + "pending RCAU should still be queued" + ); // The pending offer's $.terms entry must still be retrievable — payer can still accept it (uint8 pendingType, bytes memory pendingData) = _recurringCollector.getAgreementOfferAt(agreementId, 1); diff --git a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol index 158157554..97716eca0 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/update.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/update.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; -import { OFFER_TYPE_UPDATE } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; +import { OFFER_TYPE_UPDATE, VERSION_NEXT } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { RecurringCollectorSharedTest } from "./shared.t.sol"; @@ -366,7 +366,7 @@ contract RecurringCollectorUpdateTest is RecurringCollectorSharedTest { // Pre-condition: no pending offer staged, so update() takes the direct-apply branch. assertEq( - _recurringCollector.getAgreement(agreementId).pendingTermsHash, + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, bytes32(0), "no pending before direct-apply" ); diff --git a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol index 205bde73c..688c9469d 100644 --- a/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol @@ -2,7 +2,6 @@ pragma solidity ^0.7.6 || ^0.8.0; -import { IIssuanceAllocationDistribution } from "../../issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IRewardsIssuer } from "./IRewardsIssuer.sol"; /** @@ -179,13 +178,6 @@ interface IRewardsManager { */ function subgraphService() external view returns (IRewardsIssuer); - /** - * @notice Get the issuance allocator address - * @dev When set, this allocator controls issuance distribution instead of issuancePerBlock - * @return The issuance allocator contract (zero address if not set) - */ - function getIssuanceAllocator() external view returns (IIssuanceAllocationDistribution); - /** * @notice Get the reclaim address for a specific reason * @param reason The reclaim reason identifier diff --git a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol index 90a311556..ed9f60b8f 100644 --- a/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol +++ b/packages/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol @@ -2,6 +2,8 @@ pragma solidity ^0.7.6 || ^0.8.0; +import { IIssuanceAllocationDistribution } from "./IIssuanceAllocationDistribution.sol"; + /** * @title IIssuanceTarget * @author Edge & Node @@ -13,7 +15,10 @@ interface IIssuanceTarget { * @param oldIssuanceAllocator Old issuance allocator address * @param newIssuanceAllocator New issuance allocator address */ - event IssuanceAllocatorSet(address indexed oldIssuanceAllocator, address indexed newIssuanceAllocator); + event IssuanceAllocatorSet( + IIssuanceAllocationDistribution indexed oldIssuanceAllocator, + IIssuanceAllocationDistribution indexed newIssuanceAllocator + ); /// @notice Emitted before the issuance allocation changes event BeforeIssuanceAllocationChange(); @@ -27,11 +32,17 @@ interface IIssuanceTarget { */ function beforeIssuanceAllocationChange() external; + /** + * @notice Returns the current issuance allocator + * @return The issuance allocator contract (zero address if not set) + */ + function getIssuanceAllocator() external view returns (IIssuanceAllocationDistribution); + /** * @notice Sets the issuance allocator for this target * @dev This function facilitates upgrades by providing a standard way for targets * to change their allocator. Implementations can define their own access control. * @param newIssuanceAllocator Address of the issuance allocator */ - function setIssuanceAllocator(address newIssuanceAllocator) external; + function setIssuanceAllocator(IIssuanceAllocationDistribution newIssuanceAllocator) external; } diff --git a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol index a5f3c40b0..4993ba3fe 100644 --- a/packages/issuance/contracts/agreement/RecurringAgreementManager.sol +++ b/packages/issuance/contracts/agreement/RecurringAgreementManager.sol @@ -275,6 +275,11 @@ contract RecurringAgreementManager is /// @inheritdoc IIssuanceTarget function beforeIssuanceAllocationChange() external virtual override {} + /// @inheritdoc IIssuanceTarget + function getIssuanceAllocator() external view virtual override returns (IIssuanceAllocationDistribution) { + return _getStorage().issuanceAllocator; + } + /// @inheritdoc IIssuanceTarget /// @dev The allocator is expected to call distributeIssuance() (bringing distribution up to /// the current block) before any configuration change. As a result, the same-block dedup in @@ -283,21 +288,23 @@ contract RecurringAgreementManager is /// in a standalone transaction to avoid interleaving with collection in the same block. /// Even if interleaved, the only effect is a one-block lag before the new allocator's /// distribution is picked up — corrected automatically on the next block. - function setIssuanceAllocator(address newIssuanceAllocator) external virtual override onlyRole(GOVERNOR_ROLE) { + function setIssuanceAllocator( + IIssuanceAllocationDistribution newIssuanceAllocator + ) external virtual override onlyRole(GOVERNOR_ROLE) { RecurringAgreementManagerStorage storage $ = _getStorage(); - if (address($.issuanceAllocator) == newIssuanceAllocator) return; + if (address($.issuanceAllocator) == address(newIssuanceAllocator)) return; - if (newIssuanceAllocator != address(0)) + if (address(newIssuanceAllocator) != address(0)) require( ERC165Checker.supportsInterface( - newIssuanceAllocator, + address(newIssuanceAllocator), type(IIssuanceAllocationDistribution).interfaceId ), - InvalidIssuanceAllocator(newIssuanceAllocator) + InvalidIssuanceAllocator(address(newIssuanceAllocator)) ); - emit IssuanceAllocatorSet(address($.issuanceAllocator), newIssuanceAllocator); - $.issuanceAllocator = IIssuanceAllocationDistribution(newIssuanceAllocator); + emit IssuanceAllocatorSet($.issuanceAllocator, newIssuanceAllocator); + $.issuanceAllocator = newIssuanceAllocator; } // -- IAgreementOwner -- diff --git a/packages/issuance/contracts/allocate/DirectAllocation.sol b/packages/issuance/contracts/allocate/DirectAllocation.sol index 91f153b5e..9df058eca 100644 --- a/packages/issuance/contracts/allocate/DirectAllocation.sol +++ b/packages/issuance/contracts/allocate/DirectAllocation.sol @@ -2,6 +2,9 @@ pragma solidity ^0.8.27; +import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; + +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; import { BaseUpgradeable } from "../common/BaseUpgradeable.sol"; @@ -24,6 +27,36 @@ import { ERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/int * @custom:security-contact Please email security+contracts@thegraph.com if you find any bugs. We might have an active bug bounty program. */ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { + // -- Namespaced Storage -- + + /// @notice ERC-7201 storage location for DirectAllocation + bytes32 private constant DIRECT_ALLOCATION_STORAGE_LOCATION = + // solhint-disable-next-line gas-small-strings + keccak256(abi.encode(uint256(keccak256("graphprotocol.storage.DirectAllocation")) - 1)) & + ~bytes32(uint256(0xff)); + + /// @notice Main storage structure for DirectAllocation using ERC-7201 namespaced storage + /// @param issuanceAllocator The issuance allocator that distributes tokens to this contract + /// @custom:storage-location erc7201:graphprotocol.storage.DirectAllocation + struct DirectAllocationData { + IIssuanceAllocationDistribution issuanceAllocator; + } + + /** + * @notice Returns the storage struct for DirectAllocation + * @return $ contract storage + */ + function _getDirectAllocationStorage() private pure returns (DirectAllocationData storage $) { + // solhint-disable-previous-line use-natspec + // Solhint does not support $ return variable in natspec + + bytes32 slot = DIRECT_ALLOCATION_STORAGE_LOCATION; + // solhint-disable-next-line no-inline-assembly + assembly { + $.slot := slot + } + } + // -- Custom Errors -- /// @notice Thrown when token transfer fails @@ -31,6 +64,10 @@ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { /// @param amount The amount of tokens that failed to transfer error SendTokensFailed(address to, uint256 amount); + /// @notice Thrown when the issuance allocator does not support IIssuanceAllocationDistribution + /// @param allocator The rejected allocator address + error InvalidIssuanceAllocator(address allocator); + // -- Events -- /// @notice Emitted when tokens are sent @@ -89,9 +126,28 @@ contract DirectAllocation is BaseUpgradeable, IIssuanceTarget, ISendTokens { */ function beforeIssuanceAllocationChange() external virtual override {} - /** - * @dev No-op for DirectAllocation; issuanceAllocator is not stored. - * @inheritdoc IIssuanceTarget - */ - function setIssuanceAllocator(address issuanceAllocator) external virtual override onlyRole(GOVERNOR_ROLE) {} + /// @inheritdoc IIssuanceTarget + function getIssuanceAllocator() external view virtual override returns (IIssuanceAllocationDistribution) { + return _getDirectAllocationStorage().issuanceAllocator; + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator( + IIssuanceAllocationDistribution newIssuanceAllocator + ) external virtual override onlyRole(GOVERNOR_ROLE) { + DirectAllocationData storage $ = _getDirectAllocationStorage(); + if (address(newIssuanceAllocator) == address($.issuanceAllocator)) return; + + if (address(newIssuanceAllocator) != address(0)) + require( + ERC165Checker.supportsInterface( + address(newIssuanceAllocator), + type(IIssuanceAllocationDistribution).interfaceId + ), + InvalidIssuanceAllocator(address(newIssuanceAllocator)) + ); + + emit IssuanceAllocatorSet($.issuanceAllocator, newIssuanceAllocator); + $.issuanceAllocator = newIssuanceAllocator; + } } diff --git a/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol b/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol index a33212282..2b5fb5aec 100644 --- a/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol +++ b/packages/issuance/contracts/test/allocate/MockNotificationTracker.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -30,7 +31,12 @@ contract MockNotificationTracker is IIssuanceTarget, ERC165 { } /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external pure override {} + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override {} /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { diff --git a/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol b/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol index 484648805..ffa4e5aae 100644 --- a/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockReentrantTarget.sol @@ -85,8 +85,13 @@ contract MockReentrantTarget is IIssuanceTarget, ERC165 { } /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external override { - issuanceAllocator = _issuanceAllocator; + function getIssuanceAllocator() external view override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(issuanceAllocator); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external override { + issuanceAllocator = address(_issuanceAllocator); } /// @inheritdoc ERC165 diff --git a/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol b/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol index 27522e5a4..eb0ec1734 100644 --- a/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockRevertingTarget.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -23,7 +24,14 @@ contract MockRevertingTarget is IIssuanceTarget, ERC165 { /** * @inheritdoc IIssuanceTarget */ - function setIssuanceAllocator(address _issuanceAllocator) external pure override { + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /** + * @inheritdoc IIssuanceTarget + */ + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override { // No-op } diff --git a/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol b/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol index 311e1f03c..fddaed78b 100644 --- a/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol +++ b/packages/issuance/contracts/test/allocate/MockSimpleTarget.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -15,7 +16,12 @@ contract MockSimpleTarget is IIssuanceTarget, ERC165 { function beforeIssuanceAllocationChange() external pure override {} /// @inheritdoc IIssuanceTarget - function setIssuanceAllocator(address _issuanceAllocator) external pure override {} + function getIssuanceAllocator() external pure override returns (IIssuanceAllocationDistribution) { + return IIssuanceAllocationDistribution(address(0)); + } + + /// @inheritdoc IIssuanceTarget + function setIssuanceAllocator(IIssuanceAllocationDistribution _issuanceAllocator) external pure override {} /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { diff --git a/packages/issuance/test/unit/agreement-manager/approver.t.sol b/packages/issuance/test/unit/agreement-manager/approver.t.sol index f38db6a7c..488b74729 100644 --- a/packages/issuance/test/unit/agreement-manager/approver.t.sol +++ b/packages/issuance/test/unit/agreement-manager/approver.t.sol @@ -8,6 +8,7 @@ import { IRecurringEscrowManagement } from "@graphprotocol/interfaces/contracts/ import { IProviderEligibilityManagement } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IProviderEligibilityManagement.sol"; import { IRecurringAgreements } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreements.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IAgreementCollector, OFFER_TYPE_NEW @@ -57,13 +58,13 @@ contract RecurringAgreementManagerApproverTest is RecurringAgreementManagerShare MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.expectRevert(); vm.prank(nonGovernor); - agreementManager.setIssuanceAllocator(address(alloc)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(alloc))); } function test_SetIssuanceAllocator_Governor() public { MockIssuanceAllocator alloc = new MockIssuanceAllocator(token, address(agreementManager)); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(alloc)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(alloc))); } // -- View Function Tests -- diff --git a/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol index 2b7db27a4..458e76347 100644 --- a/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol +++ b/packages/issuance/test/unit/agreement-manager/branchCoverage.t.sol @@ -7,6 +7,7 @@ import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IRecurringAgreementManagement } from "@graphprotocol/interfaces/contracts/issuance/agreement/IRecurringAgreementManagement.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; @@ -15,6 +16,7 @@ import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; import { IAgreementCollector } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { MockRecurringCollector } from "./mocks/MockRecurringCollector.sol"; +import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; /// @notice Targeted tests for uncovered branches in RecurringAgreementManager. contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManagerSharedTest { @@ -36,7 +38,7 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage address(recurringCollector) ) ); - agreementManager.setIssuanceAllocator(address(recurringCollector)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(recurringCollector))); } /// @notice Setting allocator to an EOA (no code) also fails ERC165 check. @@ -44,7 +46,7 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage address eoa = makeAddr("randomEOA"); vm.prank(governor); vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); - agreementManager.setIssuanceAllocator(eoa); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(eoa)); } // ══════════════════════════════════════════════════════════════════════ @@ -219,6 +221,52 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage // _withdrawAndRebalance — deposit deficit branch (L854/857–862) // ══════════════════════════════════════════════════════════════════════ + // ══════════════════════════════════════════════════════════════════════ + // getIssuanceAllocator — view getter (L281-282) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice getIssuanceAllocator returns the configured allocator and the + /// zero default prior to setIssuanceAllocator. + function test_GetIssuanceAllocator_ReturnsConfiguredValue() public { + assertEq(address(agreementManager.getIssuanceAllocator()), address(0), "Default allocator must be zero"); + + MockIssuanceAllocator allocator = new MockIssuanceAllocator(token, address(agreementManager)); + vm.prank(governor); + agreementManager.setIssuanceAllocator(allocator); + + assertEq( + address(agreementManager.getIssuanceAllocator()), + address(allocator), + "Configured allocator must be returned" + ); + } + + // ══════════════════════════════════════════════════════════════════════ + // offerAgreement — collector returns zero agreementId (L361) + // ══════════════════════════════════════════════════════════════════════ + + /// @notice A conformant collector must return a non-zero agreementId; RAM + /// enforces this invariant with AgreementIdZero. + function test_OfferAgreement_Revert_AgreementIdZero() public { + ZeroIdCollector rogue = new ZeroIdCollector(dataService, address(agreementManager), indexer); + vm.prank(governor); + agreementManager.grantRole(COLLECTOR_ROLE, address(rogue)); + + // Payload content is irrelevant — the mock returns a zero agreementId unconditionally. + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRCA( + 100 ether, + 1 ether, + 60, + 3600, + uint64(block.timestamp + 365 days) + ); + + token.mint(address(agreementManager), 1_000_000 ether); + vm.prank(operator); + vm.expectRevert(IRecurringAgreementManagement.AgreementIdZero.selector); + agreementManager.offerAgreement(IAgreementCollector(address(rogue)), OFFER_TYPE_NEW, abi.encode(rca)); + } + /// @notice When escrow balance drops below min (after collection), reconcile deposits the deficit. function test_WithdrawAndRebalance_DepositDeficit() public { // Offer agreement in Full mode — escrow gets fully funded @@ -268,3 +316,28 @@ contract RecurringAgreementManagerBranchCoverageTest is RecurringAgreementManage /* solhint-enable graph/func-name-mixedcase */ } + +/// @notice Minimal collector stub that returns a zero agreementId with valid +/// payer/dataService/serviceProvider, used to exercise RAM's AgreementIdZero guard. +contract ZeroIdCollector { + address private immutable _dataService; + address private immutable _payer; + address private immutable _serviceProvider; + + constructor(address dataService_, address payer_, address serviceProvider_) { + _dataService = dataService_; + _payer = payer_; + _serviceProvider = serviceProvider_; + } + + function offer( + uint8 /* offerType */, + bytes calldata /* data */, + uint16 /* options */ + ) external view returns (IAgreementCollector.AgreementDetails memory details) { + details.agreementId = bytes16(0); + details.payer = _payer; + details.dataService = _dataService; + details.serviceProvider = _serviceProvider; + } +} diff --git a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol index e4870924f..efe2abce6 100644 --- a/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol +++ b/packages/issuance/test/unit/agreement-manager/callbackGas.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.27; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { RecurringAgreementManagerSharedTest } from "./shared.t.sol"; import { MockIssuanceAllocator } from "./mocks/MockIssuanceAllocator.sol"; @@ -36,7 +37,7 @@ contract RecurringAgreementManagerCallbackGasTest is RecurringAgreementManagerSh vm.label(address(mockAllocator), "MockIssuanceAllocator"); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } // ==================== beforeCollection gas ==================== diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index d84782d37..ec9542977 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import { Vm } from "forge-std/Vm.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol"; import { RecurringAgreementManager } from "contracts/agreement/RecurringAgreementManager.sol"; @@ -23,7 +24,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.label(address(mockAllocator), "MockIssuanceAllocator"); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } // ==================== setIssuanceAllocator ==================== @@ -33,26 +34,26 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.prank(governor); vm.expectEmit(address(agreementManager)); - emit IIssuanceTarget.IssuanceAllocatorSet(address(mockAllocator), address(newAllocator)); - agreementManager.setIssuanceAllocator(address(newAllocator)); + emit IIssuanceTarget.IssuanceAllocatorSet(IIssuanceAllocationDistribution(address(mockAllocator)), IIssuanceAllocationDistribution(address(newAllocator))); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(newAllocator))); } function test_SetIssuanceAllocator_Revert_WhenNotGovernor() public { vm.prank(operator); vm.expectRevert(); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); } function test_SetIssuanceAllocator_CanSetToZero() public { vm.prank(governor); - agreementManager.setIssuanceAllocator(address(0)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(0))); // Should not revert — _ensureIncomingDistributionToCurrentBlock is a no-op with zero address } function test_SetIssuanceAllocator_NoopWhenUnchanged() public { vm.prank(governor); vm.recordLogs(); - agreementManager.setIssuanceAllocator(address(mockAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(mockAllocator))); Vm.Log[] memory logs = vm.getRecordedLogs(); assertEq(logs.length, 0, "should not emit when address unchanged"); } @@ -201,7 +202,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan function test_EnsureDistributed_NoopWhenAllocatorNotSet() public { // Clear allocator vm.prank(governor); - agreementManager.setIssuanceAllocator(address(0)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(0))); (IRecurringCollector.RecurringCollectionAgreement memory rca, ) = _makeRCAWithId( 100 ether, @@ -309,14 +310,14 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.expectRevert( abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, notAllocator) ); - agreementManager.setIssuanceAllocator(notAllocator); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(notAllocator)); } function test_SetIssuanceAllocator_Revert_WhenEOA() public { address eoa = makeAddr("eoa"); vm.prank(governor); vm.expectRevert(abi.encodeWithSelector(RecurringAgreementManager.InvalidIssuanceAllocator.selector, eoa)); - agreementManager.setIssuanceAllocator(eoa); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(eoa)); } // ==================== setIssuanceAllocator switches allocator ==================== @@ -334,7 +335,7 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan // Switch allocator MockIssuanceAllocator newAllocator = new MockIssuanceAllocator(token, address(agreementManager)); vm.prank(governor); - agreementManager.setIssuanceAllocator(address(newAllocator)); + agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(newAllocator))); // Next block: new allocator should be called via _updateEscrow vm.roll(block.number + 1); diff --git a/packages/issuance/test/unit/allocator/distribution.t.sol b/packages/issuance/test/unit/allocator/distribution.t.sol index fb94737de..196317dcf 100644 --- a/packages/issuance/test/unit/allocator/distribution.t.sol +++ b/packages/issuance/test/unit/allocator/distribution.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { TargetIssuancePerBlock, DistributionState, @@ -487,7 +488,7 @@ contract IssuanceAllocatorDistributionTest is IssuanceAllocatorSharedTest { _setIssuanceRate(ISSUANCE_PER_BLOCK); // Set up reentrant target - reentrantTarget.setIssuanceAllocator(address(allocator)); + reentrantTarget.setIssuanceAllocator(IIssuanceAllocationDistribution(address(allocator))); reentrantTarget.setReentrantAction(MockReentrantTarget.ReentrantAction.SetTargetAllocation1Param); // Adding the target should fail due to reentrancy in notification callback diff --git a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol index 463416bbd..aee42df80 100644 --- a/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol +++ b/packages/issuance/test/unit/allocator/interfaceIdStability.t.sol @@ -40,7 +40,7 @@ contract AllocateInterfaceIdStabilityTest is Test { // -- DirectAllocation / shared interfaces -- function test_InterfaceId_IIssuanceTarget() public pure { - assertEq(type(IIssuanceTarget).interfaceId, bytes4(0xaee4dc43)); + assertEq(type(IIssuanceTarget).interfaceId, bytes4(0x19f6601a)); } function test_InterfaceId_ISendTokens() public pure { diff --git a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol index 112126a38..d76204091 100644 --- a/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol +++ b/packages/issuance/test/unit/direct-allocation/DirectAllocation.t.sol @@ -8,6 +8,7 @@ import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.so import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; import { ISendTokens } from "@graphprotocol/interfaces/contracts/issuance/allocate/ISendTokens.sol"; @@ -15,6 +16,26 @@ import { BaseUpgradeable } from "../../../contracts/common/BaseUpgradeable.sol"; import { IGraphToken } from "../../../contracts/common/IGraphToken.sol"; import { DirectAllocation } from "../../../contracts/allocate/DirectAllocation.sol"; import { MockGraphToken } from "../mocks/MockGraphToken.sol"; +import { TargetIssuancePerBlock } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocatorTypes.sol"; + +/// @notice Minimal IIssuanceAllocationDistribution stub that advertises the interface via ERC-165. +/// Used to exercise DirectAllocation's ERC-165 acceptance path without pulling in heavier +/// allocator mocks from other test trees. +contract StubIssuanceAllocator is IIssuanceAllocationDistribution, IERC165 { + function distributeIssuance() external pure override returns (uint256) { + return 0; + } + + function getTargetIssuancePerBlock(address) external pure override returns (TargetIssuancePerBlock memory) { + return TargetIssuancePerBlock(0, 0, 0, 0); + } + + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return + interfaceId == type(IIssuanceAllocationDistribution).interfaceId || + interfaceId == type(IERC165).interfaceId; + } +} /// @notice Tests for DirectAllocation contract. contract DirectAllocationTest is Test { @@ -133,15 +154,81 @@ contract DirectAllocationTest is Test { directAlloc.beforeIssuanceAllocationChange(); } - function test_SetIssuanceAllocator_NoOp() public { + function test_GetIssuanceAllocator_InitiallyZero() public view { + assertEq(address(directAlloc.getIssuanceAllocator()), address(0)); + } + + function test_SetIssuanceAllocator_UpdatesGetter() public { + StubIssuanceAllocator allocator = new StubIssuanceAllocator(); + vm.prank(governor); + directAlloc.setIssuanceAllocator(allocator); + assertEq(address(directAlloc.getIssuanceAllocator()), address(allocator)); + } + + function test_SetIssuanceAllocator_EmitsEvent() public { + StubIssuanceAllocator allocator = new StubIssuanceAllocator(); + vm.prank(governor); + vm.expectEmit(address(directAlloc)); + emit IIssuanceTarget.IssuanceAllocatorSet(IIssuanceAllocationDistribution(address(0)), allocator); + directAlloc.setIssuanceAllocator(allocator); + } + + function test_SetIssuanceAllocator_EmitsEventWithOldValue() public { + StubIssuanceAllocator first = new StubIssuanceAllocator(); + StubIssuanceAllocator second = new StubIssuanceAllocator(); + vm.prank(governor); + directAlloc.setIssuanceAllocator(first); + + vm.prank(governor); + vm.expectEmit(address(directAlloc)); + emit IIssuanceTarget.IssuanceAllocatorSet(first, second); + directAlloc.setIssuanceAllocator(second); + } + + function test_SetIssuanceAllocator_SkipsWhenSameValue() public { + StubIssuanceAllocator allocator = new StubIssuanceAllocator(); + vm.prank(governor); + directAlloc.setIssuanceAllocator(allocator); + + vm.prank(governor); + vm.recordLogs(); + directAlloc.setIssuanceAllocator(allocator); + assertEq(vm.getRecordedLogs().length, 0); + } + + function test_SetIssuanceAllocator_AllowsZeroAddress() public { + // Zero-address bypasses the ERC165 check — clearing the allocator is always legal. + StubIssuanceAllocator allocator = new StubIssuanceAllocator(); + vm.prank(governor); + directAlloc.setIssuanceAllocator(allocator); + + vm.prank(governor); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(address(0))); + assertEq(address(directAlloc.getIssuanceAllocator()), address(0)); + } + + /// @notice An EOA (no code) fails the ERC-165 interface probe and must be rejected. Prevents + /// governance from accidentally wiring up a non-contract as the allocator. + function test_Revert_SetIssuanceAllocator_WhenEOA() public { + address eoa = makeAddr("eoa"); + vm.prank(governor); + vm.expectRevert(abi.encodeWithSelector(DirectAllocation.InvalidIssuanceAllocator.selector, eoa)); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(eoa)); + } + + /// @notice A contract that does not implement IIssuanceAllocationDistribution must be rejected. + /// Uses the MockGraphToken fixture — it has code but doesn't advertise the allocator interface. + function test_Revert_SetIssuanceAllocator_WhenWrongInterface() public { vm.prank(governor); - directAlloc.setIssuanceAllocator(makeAddr("allocator")); + vm.expectRevert(abi.encodeWithSelector(DirectAllocation.InvalidIssuanceAllocator.selector, address(token))); + directAlloc.setIssuanceAllocator(IIssuanceAllocationDistribution(address(token))); } function test_Revert_SetIssuanceAllocator_NonGovernor() public { + StubIssuanceAllocator allocator = new StubIssuanceAllocator(); vm.expectRevert(); vm.prank(unauthorized); - directAlloc.setIssuanceAllocator(makeAddr("allocator")); + directAlloc.setIssuanceAllocator(allocator); } // ==================== ERC-165 Interface Support ==================== diff --git a/packages/testing/test/harness/FullStackHarness.t.sol b/packages/testing/test/harness/FullStackHarness.t.sol index 842ebe1a1..d095804f0 100644 --- a/packages/testing/test/harness/FullStackHarness.t.sol +++ b/packages/testing/test/harness/FullStackHarness.t.sol @@ -27,6 +27,7 @@ import { OFFER_TYPE_NEW } from "@graphprotocol/interfaces/contracts/horizon/IAgreementCollector.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -291,7 +292,7 @@ abstract contract FullStackHarness is Test { ram.grantRole(OPERATOR_ROLE, operator); ram.grantRole(DATA_SERVICE_ROLE, address(subgraphService)); ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); - ram.setIssuanceAllocator(address(issuanceAllocator)); + ram.setIssuanceAllocator(IIssuanceAllocationDistribution(address(issuanceAllocator))); issuanceAllocator.setIssuancePerBlock(1 ether); issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); diff --git a/packages/testing/test/harness/RealStackHarness.t.sol b/packages/testing/test/harness/RealStackHarness.t.sol index db99ace6c..1d7cf6bcd 100644 --- a/packages/testing/test/harness/RealStackHarness.t.sol +++ b/packages/testing/test/harness/RealStackHarness.t.sol @@ -9,6 +9,7 @@ import { RecurringCollector } from "horizon/payments/collectors/RecurringCollect import { IssuanceAllocator } from "issuance/allocate/IssuanceAllocator.sol"; import { RecurringAgreementManager } from "issuance/agreement/RecurringAgreementManager.sol"; import { IIssuanceTarget } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceTarget.sol"; +import { IIssuanceAllocationDistribution } from "@graphprotocol/interfaces/contracts/issuance/allocate/IIssuanceAllocationDistribution.sol"; // Use the issuance IGraphToken for RAM/allocator (IERC20 + mint) import { IGraphToken as IssuanceIGraphToken } from "issuance/common/IGraphToken.sol"; @@ -123,7 +124,7 @@ abstract contract RealStackHarness is Test { ram.grantRole(OPERATOR_ROLE, operator); ram.grantRole(DATA_SERVICE_ROLE, dataService); ram.grantRole(COLLECTOR_ROLE, address(recurringCollector)); - ram.setIssuanceAllocator(address(issuanceAllocator)); + ram.setIssuanceAllocator(IIssuanceAllocationDistribution(address(issuanceAllocator))); // Configure allocator: set total issuance rate, then allocate to RAM issuanceAllocator.setIssuancePerBlock(1 ether); issuanceAllocator.setTargetAllocation(IIssuanceTarget(address(ram)), 1 ether); From e4cd9e026e2f270cc0f2799d4a3a863dcd44306a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:35:24 +0000 Subject: [PATCH 120/157] fix(collector): validate full terms at offer time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace _requirePayerToSupportEligibilityCheck in _offerNew/_offerUpdate with _requireValidTerms, so deadline/endsAt/min-max collection seconds and ongoing-rate are validated when the offer is registered, not only when the offer is accepted. Pre-acceptance views (getMaxNextClaim, getAgreementDetails) read terms from the stored RCA bytes, so an offer with malformed terms could otherwise be advertised — and surface non-zero pending caps — until accept() rejected it. --- .../collectors/RecurringCollector.sol | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 76f20062d..0a4b4daca 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -488,7 +488,15 @@ contract RecurringCollector is block.timestamp <= rca.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rca.deadline) ); - _requirePayerToSupportEligibilityCheck(rca.payer, rca.conditions); + _requireValidTerms( + rca.deadline, + rca.endsAt, + rca.minSecondsPerCollection, + rca.maxSecondsPerCollection, + rca.payer, + rca.conditions, + rca.maxOngoingTokensPerSecond + ); agreement.payer = rca.payer; agreement.dataService = rca.dataService; @@ -523,12 +531,21 @@ contract RecurringCollector is block.timestamp <= rcau.deadline, RecurringCollectorAgreementDeadlineElapsed(block.timestamp, rcau.deadline) ); + address payer = agreement.payer; require( - agreement.payer != address(0) && + payer != address(0) && (agreement.state == AgreementState.NotAccepted || agreement.state == AgreementState.Accepted), RecurringCollectorAgreementIncorrectState(agreementId, agreement.state) ); - _requirePayerToSupportEligibilityCheck(agreement.payer, rcau.conditions); + _requireValidTerms( + rcau.deadline, + rcau.endsAt, + rcau.minSecondsPerCollection, + rcau.maxSecondsPerCollection, + payer, + rcau.conditions, + rcau.maxOngoingTokensPerSecond + ); $.rcauOffers[agreementId] = StoredOffer({ offerHash: versionHash, data: _data }); emit OfferStored(agreementId, payer, OFFER_TYPE_UPDATE, versionHash); From 6772545f18467db362022e274b4b9b39636d13b2 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:01:13 +0000 Subject: [PATCH 121/157] fix(collector): respect deadlines in scoped claim cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _getMaxNextClaimScoped read offer deadlines incorrectly: - pre-acceptance used `block.timestamp < rca.deadline`, excluding the boundary; aligned with offer/accept which use `<=`. - SCOPE_PENDING had no deadline check at all — an expired pending RCAU still contributed to maxClaim. - SCOPE_PENDING also fired when the stored RCAU offer was already the active version (post-update), double-counting it against SCOPE_ACTIVE; skip when rcauOffer.offerHash == activeTermsHash. --- .../collectors/RecurringCollector.sol | 24 +++---- .../recurring-collector/coverageGaps.t.sol | 1 + .../recurring-collector/getMaxNextClaim.t.sol | 65 +++++++++++++++++++ 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 0a4b4daca..77ed57d0b 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -1309,8 +1309,7 @@ contract RecurringCollector is StoredOffer storage rcaOffer = $.rcaOffers[agreementId]; if (rcaOffer.offerHash != bytes32(0)) { RecurringCollectionAgreement memory rca = abi.decode(rcaOffer.data, (RecurringCollectionAgreement)); - // Use block.timestamp as proxy for acceptedAt, deadline as expiry - if (block.timestamp < rca.deadline) + if (block.timestamp <= rca.deadline) maxClaim = _maxClaim( block.timestamp, rca.endsAt, @@ -1324,21 +1323,22 @@ contract RecurringCollector is if (agreementScope & SCOPE_PENDING != 0) { StoredOffer storage rcauOffer = $.rcauOffers[agreementId]; - if (rcauOffer.offerHash != bytes32(0)) { + if (rcauOffer.offerHash != bytes32(0) && rcauOffer.offerHash != _a.activeTermsHash) { RecurringCollectionAgreementUpdate memory rcau = abi.decode( rcauOffer.data, (RecurringCollectionAgreementUpdate) ); - // Ongoing claim: time-capped from now to rcau.endsAt - uint256 maxPendingClaim = _maxClaim( - block.timestamp, - rcau.endsAt, - rcau.maxSecondsPerCollection, - rcau.maxOngoingTokensPerSecond, - _a.lastCollectionAt == 0 ? rcau.maxInitialTokens : 0 - ); - if (maxClaim < maxPendingClaim) maxClaim = maxPendingClaim; + if (block.timestamp <= rcau.deadline) { + uint256 maxPendingClaim = _maxClaim( + block.timestamp, + rcau.endsAt, + rcau.maxSecondsPerCollection, + rcau.maxOngoingTokensPerSecond, + _a.lastCollectionAt == 0 ? rcau.maxInitialTokens : 0 + ); + if (maxClaim < maxPendingClaim) maxClaim = maxPendingClaim; + } } } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index 6d9713cbf..9dd76355f 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -20,6 +20,7 @@ import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol import { RecurringCollectorSharedTest } from "./shared.t.sol"; import { MockAgreementOwner } from "./MockAgreementOwner.t.sol"; +import { BareAgreementOwner } from "./BareAgreementOwner.t.sol"; /// @notice A payer contract that supports ERC165 + IProviderEligibility at offer time, /// but returns malformed (< 32 bytes) data from isEligible at collection time. diff --git a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol index fb46ba2dc..fe792c059 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/getMaxNextClaim.t.sol @@ -689,5 +689,70 @@ contract RecurringCollectorGetMaxNextClaimTest is RecurringCollectorSharedTest { assertEq(combinedAfter, activeAfter, "combined scope falls back to active-only after pending expires"); } + /// @notice After update() promotes an RCAU to active, the rcauOffers slot still holds that + /// RCAU's bytes - but its hash now equals activeTermsHash. SCOPE_PENDING must skip it (the + /// guard is `rcauOffer.offerHash != activeTermsHash`); otherwise the active version would be + /// counted twice in the combined-scope envelope. + function test_GetMaxNextClaim_PostUpdate_PendingDoesNotDoubleCountActive() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds"), + serviceProvider: makeAddr("sp"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _recurringCollectorHelper.sensibleRCAU( + IRecurringCollector.RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: 0, + endsAt: uint64(block.timestamp + 730 days), + maxInitialTokens: 200 ether, + maxOngoingTokensPerSecond: 2 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 7200, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + + // Post-update invariant: rcauOffers slot holds the now-active RCAU, so offerHash == + // activeTermsHash. SCOPE_PENDING must report nothing claimable beyond the active version. + assertEq( + _recurringCollector.hashRCAU(rcau), + _recurringCollector.getAgreement(agreementId).activeTermsHash, + "precondition: RCAU promoted, rcauOffers.offerHash == activeTermsHash" + ); + + uint256 pendingScope = _recurringCollector.getMaxNextClaim(agreementId, 2); // SCOPE_PENDING + assertEq(pendingScope, 0, "post-update SCOPE_PENDING must be 0 (no stale double-count)"); + + uint256 activeScope = _recurringCollector.getMaxNextClaim(agreementId, 1); // SCOPE_ACTIVE + uint256 combined = _recurringCollector.getMaxNextClaim(agreementId); + assertEq(combined, activeScope, "combined scope equals active alone - pending contributes nothing"); + assertGt(activeScope, 0, "sanity: active scope claim is non-zero"); + } + /* solhint-enable graph/func-name-mixedcase */ } From 067168e4dbdc91c93e2014d69f24e0e7e0c12751 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:11:07 +0000 Subject: [PATCH 122/157] refactor(collector): collapse redundant state guard in _getMaxNextClaim The CanceledByServiceProvider early-return at the top of _getMaxNextClaim is fully subsumed by the next check (state must be Accepted or CanceledByPayer). Drop the redundant first check; the comprehensive guard catches CanceledByServiceProvider and any future non-collectable state. --- .../contracts/payments/collectors/RecurringCollector.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index 77ed57d0b..eb06ce743 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -1261,9 +1261,6 @@ contract RecurringCollector is * @return The maximum tokens that could be collected */ function _getMaxNextClaim(AgreementData storage _a) private view returns (uint256) { - // CanceledByServiceProvider = immediately non-collectable - if (_a.state == AgreementState.CanceledByServiceProvider) return 0; - // Only Accepted and CanceledByPayer are collectable if (_a.state != AgreementState.Accepted && _a.state != AgreementState.CanceledByPayer) return 0; uint256 collectionStart = _agreementCollectionStartAt(_a); From 757da417446150e478ae6d567c3aadd4e5058e2c Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Mon, 27 Apr 2026 11:30:43 +0000 Subject: [PATCH 123/157] fix(collector): use dedicated error for invalid offer type in offer() --- .../collectors/RecurringCollector.sol | 2 +- .../offerStorageLifecycle.t.sol | 350 +++++++++++++++++- .../recurring-collector/updateUnsigned.t.sol | 9 +- .../contracts/horizon/IRecurringCollector.sol | 6 + .../agreement-manager/ensureDistributed.t.sol | 5 +- 5 files changed, 352 insertions(+), 20 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index eb06ce743..cca28c494 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -459,7 +459,7 @@ contract RecurringCollector is uint256 index; if (offerType == OFFER_TYPE_NEW) (agreementId, versionHash, index) = _offerNew(data); else if (offerType == OFFER_TYPE_UPDATE) (agreementId, versionHash, index) = _offerUpdate(data); - else revert RecurringCollectorInvalidCollectData(data); + else revert RecurringCollectorInvalidOfferType(offerType); details = _getAgreementDetails(agreementId, versionHash, index); require(msg.sender == details.payer, RecurringCollectorUnauthorizedCaller(msg.sender, details.payer)); diff --git a/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol index a4988b4b0..24c2c01cf 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/offerStorageLifecycle.t.sol @@ -90,9 +90,17 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared assertEq(offerType, OFFER_TYPE_NEW, "stored entry at rcaHash"); assertTrue(offerData.length > 0, "stored data non-empty"); - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.activeTermsHash, rcaHash, "agreement.activeTermsHash points at offer hash"); - assertEq(agreement.pendingTermsHash, bytes32(0), "no pending before update"); + // Pre-acceptance, the offer's hash is reachable via the per-version view. + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_CURRENT).versionHash, + rcaHash, + "VERSION_CURRENT resolves to offer hash before acceptance" + ); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + bytes32(0), + "no pending before update" + ); } /// @notice Re-offering the identical RCA is idempotent — no second OfferStored event, storage unchanged. @@ -135,6 +143,126 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared assertTrue(offerData.length > 0, "accept preserves stored data"); } + /// @notice offer(OFFER_TYPE_NEW) on an Accepted agreement with a different-hash RCA must + /// not corrupt the agreement. Same agreementId + different-hash means a new RCA crafted + /// with the same identity (payer/dataService/serviceProvider/deadline/nonce) but altered + /// non-identity terms. Without a guard, the call would overwrite agreement.activeTermsHash + /// and replace rcaOffers contents — but agreement business fields (endsAt, maxInitialTokens, + /// etc.) stay as the originally-accepted values, leaving the trio out of sync. + function test_OfferNew_PostAccept_DifferentHash_Reverts() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + // Build a sibling RCA: same identity (same agreementId), different non-identity term. + // Reconstruct from rca's fields rather than `rcaB = rca;` — memory struct assignment + // is a reference, so a subsequent `rcaB.maxInitialTokens = …` would mutate rca. + IRecurringCollector.RecurringCollectionAgreement memory rcaB = IRecurringCollector + .RecurringCollectionAgreement({ + deadline: rca.deadline, + endsAt: rca.endsAt, + payer: rca.payer, + dataService: rca.dataService, + serviceProvider: rca.serviceProvider, + maxInitialTokens: rca.maxInitialTokens + 1, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: rca.conditions, + nonce: rca.nonce, + metadata: rca.metadata + }); + bytes32 rcaBHash = _recurringCollector.hashRCA(rcaB); + assertTrue(rcaBHash != rcaHash, "sibling has different hash"); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.Accepted + ) + ); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rcaB), 0); + + assertEq( + _recurringCollector.getAgreement(agreementId).activeTermsHash, + rcaHash, + "activeTermsHash unchanged after rejected offer" + ); + (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(currentType, OFFER_TYPE_NEW, "rcaOffers entry unchanged"); + assertEq(keccak256(currentData), keccak256(abi.encode(rca)), "rcaOffers bytes still original"); + } + + /// @notice cancel(SCOPE_PENDING, activeTermsHash) on an Accepted agreement is a no-op — + /// the active version's stored bytes must remain retrievable. SCOPE_PENDING addresses + /// non-active offers; deleting the active one would silently break hash round-trip. + function test_Cancel_ScopePending_OnAcceptedActiveHash_NoOp() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + bytes32 rcaHash = _recurringCollector.hashRCA(rca); + + // Try to cancel the active hash under SCOPE_PENDING — should be a no-op. + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); + + // Active version's bytes must still be retrievable. + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(offerType, OFFER_TYPE_NEW, "active offer entry preserved"); + assertTrue(offerData.length > 0, "active data preserved"); + assertEq(_recurringCollector.getAgreement(agreementId).activeTermsHash, rcaHash, "activeTermsHash unchanged"); + } + + /// @notice After update() promotes an RCAU to active, cancel(SCOPE_PENDING, activeTermsHash) + /// must remain a no-op. The active version's bytes (now in the RCAU slot) must be preserved. + function test_Cancel_ScopePending_OnPostUpdateActiveHash_NoOp() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + + vm.prank(address(approver)); + _recurringCollector.cancel(agreementId, rcauHash, SCOPE_PENDING); + + (uint8 offerType, bytes memory offerData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(offerType, OFFER_TYPE_UPDATE, "active offer (post-update RCAU) preserved"); + assertTrue(offerData.length > 0, "active data preserved"); + assertEq(_recurringCollector.getAgreement(agreementId).activeTermsHash, rcauHash, "activeTermsHash unchanged"); + } + /// @notice A successful update deletes the prior active offer from storage; the new RCAU terms /// become VERSION_CURRENT (OFFER_TYPE_UPDATE) and the pending slot clears. function test_Update_DeletesPriorActiveOffer_PromotesRcauToCurrent() public { @@ -161,7 +289,11 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared // We assert via getAgreementDetails: rcaHash is no longer a current version. IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(agreement.activeTermsHash, rcauHash, "activeTermsHash = rcauHash after update"); - assertEq(agreement.pendingTermsHash, bytes32(0), "pendingTermsHash cleared after update"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + bytes32(0), + "pending cleared after update" + ); (uint8 currentType, ) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_CURRENT); assertEq(currentType, OFFER_TYPE_UPDATE, "current offer type now OFFER_TYPE_UPDATE"); @@ -200,9 +332,6 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared vm.prank(address(approver)); _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcauB), 0); - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.pendingTermsHash, rcauBHash, "pending now points to rcauB"); - // Replaced rcauA entry no longer referenced by any version — VERSION_NEXT is now rcauB. bytes32 pendingHash = _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash; assertEq(pendingHash, rcauBHash, "VERSION_NEXT resolves to rcauB"); @@ -245,9 +374,11 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared vm.prank(address(approver)); _recurringCollector.cancel(agreementId, rcaHash, SCOPE_PENDING); - IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); - assertEq(agreement.activeTermsHash, bytes32(0), "activeTermsHash cleared"); - assertEq(agreement.pendingTermsHash, rcauHash, "pendingTermsHash survives RCA cancel"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + rcauHash, + "pending RCAU survives RCA cancel" + ); (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( agreementId, @@ -294,7 +425,11 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared IRecurringCollector.AgreementData memory agreement = _recurringCollector.getAgreement(agreementId); assertEq(agreement.activeTermsHash, bytes32(0), "active cleared"); - assertEq(agreement.pendingTermsHash, bytes32(0), "pending cleared"); + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + bytes32(0), + "pending cleared" + ); } /// @notice Pre-acceptance cancel with no pending RCAU still deletes the RCA offer and @@ -344,11 +479,202 @@ contract RecurringCollectorOfferStorageLifecycleTest is RecurringCollectorShared bytes memory data = abi.encode(rca); vm.expectRevert( - abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidCollectData.selector, data) + abi.encodeWithSelector(IRecurringCollector.RecurringCollectorInvalidOfferType.selector, OFFER_TYPE_NONE) ); vm.prank(address(approver)); _recurringCollector.offer(OFFER_TYPE_NONE, data, 0); } + /// @notice After update() promotes an RCAU to active, offering a fresh pending RCAU should + /// not erase the active RCAU's stored bytes — getAgreementOfferAt(VERSION_CURRENT) should + /// still return them and round-trip via hashRCAU. + /// @dev Skipped: the current implementation stores the pending RCAU in the same slot as + /// the active RCAU (a single rcauOffers entry per agreement), so a subsequent pending + /// offer overwrites the active version's bytes. The active hash remains queryable via + /// agreement.activeTermsHash and inline terms (endsAt, maxInitialTokens, etc.) are + /// preserved on AgreementData, but the original signed bytes are unreachable. + function test_OfferUpdate_PostUpdate_PreservesActiveRcauBytes() public { + vm.skip(true); + + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + // Accept RCA, then offer + apply RCAU1 (now the active version). + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau1), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau1, ""); + + bytes32 rcau1Hash = _recurringCollector.hashRCAU(rcau1); + assertEq( + _recurringCollector.getAgreement(agreementId).activeTermsHash, + rcau1Hash, + "active is rcau1 after update" + ); + + // Offer rcau2 as pending — different terms, different hash. + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRcau(agreementId, rca, 2); + rcau2.maxInitialTokens = rcau1.maxInitialTokens + 1; // ensure different hash + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau2), 0); + + // Active version's bytes should still be retrievable. + (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(currentType, OFFER_TYPE_UPDATE, "active offer type still UPDATE"); + assertTrue(currentData.length > 0, "active rcau bytes still retrievable"); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory decodedActive = abi.decode( + currentData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + assertEq(_recurringCollector.hashRCAU(decodedActive), rcau1Hash, "active rcau bytes round-trip to rcau1Hash"); + } + + /// @notice After update() promotes an RCAU to active, offering a fresh pending RCAU should + /// leave the pending retrievable via VERSION_NEXT while the active RCAU stays at VERSION_CURRENT. + /// @dev Skipped: same root cause as test_OfferUpdate_PostUpdate_PreservesActiveRcauBytes — + /// the single rcauOffers slot can only hold one entry, so when pending is stored the active + /// version's bytes are overwritten. + function test_OfferUpdate_PostUpdate_BothVersionsRetrievable() public { + vm.skip(true); + + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau1 = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau1), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau1, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau2 = _makeRcau(agreementId, rca, 2); + rcau2.maxInitialTokens = rcau1.maxInitialTokens + 1; + bytes32 rcau2Hash = _recurringCollector.hashRCAU(rcau2); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau2), 0); + + // VERSION_CURRENT: still rcau1 (active) + (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(currentType, OFFER_TYPE_UPDATE, "active offer type UPDATE"); + assertTrue(currentData.length > 0, "active rcau bytes retrievable"); + + // VERSION_NEXT: rcau2 (pending) + (uint8 nextType, bytes memory nextData) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); + assertEq(nextType, OFFER_TYPE_UPDATE, "pending offer type UPDATE"); + IRecurringCollector.RecurringCollectionAgreementUpdate memory decodedPending = abi.decode( + nextData, + (IRecurringCollector.RecurringCollectionAgreementUpdate) + ); + assertEq(_recurringCollector.hashRCAU(decodedPending), rcau2Hash, "pending rcau bytes round-trip"); + } + + /// @notice offer(OFFER_TYPE_UPDATE) on a cancelled agreement must revert. Persistent + /// agreement.payer leaves the payer authorization check satisfied, so a state guard is + /// required to keep stale pending offers from polluting view methods on a cancelled agreement. + function test_OfferUpdate_Revert_OnCancelledAgreement() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + bytes memory expectedErr = abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorAgreementIncorrectState.selector, + agreementId, + IRecurringCollector.AgreementState.CanceledByPayer + ); + vm.expectRevert(expectedErr); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + } + + /// @notice A pending RCAU stored before cancel() must be cleared by cancel(by) so that + /// SCOPE_PENDING and VERSION_NEXT correctly report no pending update after cancellation. + function test_Cancel_ClearsStalePendingRcau() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + + // Cancel before update() is called — RCAU remains queued + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + assertEq( + _recurringCollector.getAgreementDetails(agreementId, VERSION_NEXT).versionHash, + bytes32(0), + "pending RCAU cleared on cancel" + ); + (uint8 nextType, bytes memory nextData) = _recurringCollector.getAgreementOfferAt(agreementId, VERSION_NEXT); + assertEq(nextType, OFFER_TYPE_NONE, "no pending offer after cancel"); + assertEq(nextData.length, 0, "pending data empty after cancel"); + } + + /// @notice cancel() must not erase the active RCAU's stored bytes when the active terms came + /// from a successful update() — the rcauOffers entry holds the active version, not a pending one. + function test_Cancel_PreservesActiveRcauBytes() public { + MockAgreementOwner approver = new MockAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _makeRca(address(approver)); + _setupValidProvision(rca.serviceProvider, rca.dataService); + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeRcau(agreementId, rca, 1); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + vm.prank(rca.dataService); + _recurringCollector.update(rcau, ""); + bytes32 rcauHash = _recurringCollector.hashRCAU(rcau); + + vm.prank(rca.dataService); + _recurringCollector.cancel(agreementId, IRecurringCollector.CancelAgreementBy.Payer); + + // Active terms (rcauHash) preserved — VERSION_CURRENT still resolves the bytes. + (uint8 currentType, bytes memory currentData) = _recurringCollector.getAgreementOfferAt( + agreementId, + VERSION_CURRENT + ); + assertEq(currentType, OFFER_TYPE_UPDATE, "active offer type preserved"); + assertTrue(currentData.length > 0, "active rcau bytes preserved"); + assertEq(_recurringCollector.getAgreement(agreementId).activeTermsHash, rcauHash, "activeTermsHash unchanged"); + } + /* solhint-enable graph/func-name-mixedcase */ } diff --git a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol index 38652d81a..d91bb9a5c 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/updateUnsigned.t.sol @@ -213,20 +213,17 @@ contract RecurringCollectorUpdateUnsignedTest is RecurringCollectorSharedTest { IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = _makeSimpleRCAU(agreementId, 1); - // Set the update deadline in the past + // Set the update deadline in the past — offer() now rejects expired deadlines rcau.deadline = uint64(block.timestamp - 1); - vm.prank(address(approver)); - _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); - bytes memory expectedErr = abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementDeadlineElapsed.selector, block.timestamp, rcau.deadline ); vm.expectRevert(expectedErr); - vm.prank(rca.dataService); - _recurringCollector.update(rcau, ""); + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); } /* solhint-enable graph/func-name-mixedcase */ diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 747b38e44..87d48d437 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -296,6 +296,12 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { */ error RecurringCollectorInvalidCollectData(bytes invalidData); + /** + * @notice Thrown when offer() is called with an unrecognized offer type + * @param offerType The unrecognized offer type + */ + error RecurringCollectorInvalidOfferType(uint8 offerType); + /** * @notice Thrown when interacting with an agreement that has an incorrect state * @param agreementId The agreement ID diff --git a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol index ec9542977..d2b55efea 100644 --- a/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol +++ b/packages/issuance/test/unit/agreement-manager/ensureDistributed.t.sol @@ -34,7 +34,10 @@ contract RecurringAgreementManagerEnsureDistributedTest is RecurringAgreementMan vm.prank(governor); vm.expectEmit(address(agreementManager)); - emit IIssuanceTarget.IssuanceAllocatorSet(IIssuanceAllocationDistribution(address(mockAllocator)), IIssuanceAllocationDistribution(address(newAllocator))); + emit IIssuanceTarget.IssuanceAllocatorSet( + IIssuanceAllocationDistribution(address(mockAllocator)), + IIssuanceAllocationDistribution(address(newAllocator)) + ); agreementManager.setIssuanceAllocator(IIssuanceAllocationDistribution(address(newAllocator))); } From 048971bc7a67f012f7fa1dc8373e06449e16c23f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 09:38:56 +0000 Subject: [PATCH 124/157] feat(deployment): drive RM revertOnIneligible from network config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eligibility_revert.ts now reads RewardsManager.revertOnIneligible from config/.json5, defaulting to true (the expected target for all deployments). Idempotency check compares on-chain to desired instead of skipping when already true. Status check (getRewardsManagerChecks) compares the on-chain value against the same config-resolved desired value and shows ✓/✗ instead of a neutral info line, surfacing config-vs-chain drift in deploy:status. Extracts loadDeploymentConfigForChain(chainId) — a silent, sync, chainId-keyed loader — so the status task (which has no Environment) can read config too. The async env-based loadDeploymentConfig delegates to it. Drops the now-redundant RewardsManager block from all three network configs (arbitrumOne, arbitrumSepolia, localNetwork); the field remains in the DeploymentConfig type as an escape hatch. --- packages/deployment/config/arbitrumOne.json5 | 5 --- .../deployment/config/arbitrumSepolia.json5 | 5 --- packages/deployment/config/localNetwork.json5 | 5 --- .../deploy/gip/0088/eligibility_revert.ts | 28 ++++++++++----- packages/deployment/lib/deployment-config.ts | 34 ++++++++++++++----- packages/deployment/lib/status-detail.ts | 12 +++++-- .../deployment/tasks/deployment-status.ts | 2 +- 7 files changed, 55 insertions(+), 36 deletions(-) diff --git a/packages/deployment/config/arbitrumOne.json5 b/packages/deployment/config/arbitrumOne.json5 index 15ebcfdb1..661c9e5b2 100644 --- a/packages/deployment/config/arbitrumOne.json5 +++ b/packages/deployment/config/arbitrumOne.json5 @@ -10,11 +10,6 @@ "ramSelfMintingGrtPerBlock": "0" }, - "RewardsManager": { - // Revert reward claims for ineligible indexers - "revertOnIneligible": true - }, - "RecurringCollector": { // Pause guardian is read from Controller.pauseGuardian() at deploy time // (same as all other protocol contracts) diff --git a/packages/deployment/config/arbitrumSepolia.json5 b/packages/deployment/config/arbitrumSepolia.json5 index ee99ac660..72004193b 100644 --- a/packages/deployment/config/arbitrumSepolia.json5 +++ b/packages/deployment/config/arbitrumSepolia.json5 @@ -10,11 +10,6 @@ "ramSelfMintingGrtPerBlock": "0" }, - "RewardsManager": { - // Revert reward claims for ineligible indexers - "revertOnIneligible": false - }, - "RecurringCollector": { // Pause guardian is read from Controller.pauseGuardian() at deploy time // (same as all other protocol contracts) diff --git a/packages/deployment/config/localNetwork.json5 b/packages/deployment/config/localNetwork.json5 index a90664653..c9dcd90db 100644 --- a/packages/deployment/config/localNetwork.json5 +++ b/packages/deployment/config/localNetwork.json5 @@ -7,10 +7,5 @@ // Local network uses a high rate so agreements accumulate meaningful rewards quickly "ramAllocatorMintingGrtPerBlock": "6", "ramSelfMintingGrtPerBlock": "0" - }, - - "RewardsManager": { - // Revert reward claims for ineligible indexers (strict mode for testing) - "revertOnIneligible": false } } diff --git a/packages/deployment/deploy/gip/0088/eligibility_revert.ts b/packages/deployment/deploy/gip/0088/eligibility_revert.ts index 0d99b2e95..dda01e962 100644 --- a/packages/deployment/deploy/gip/0088/eligibility_revert.ts +++ b/packages/deployment/deploy/gip/0088/eligibility_revert.ts @@ -1,6 +1,7 @@ import { REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' +import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' import { ComponentTags, GoalTags, shouldSkipOptionalGoal } from '@graphprotocol/deployment/lib/deployment-tags.js' import { createGovernanceTxBuilder, @@ -15,13 +16,16 @@ import type { PublicClient } from 'viem' import { encodeFunctionData } from 'viem' /** - * GIP-0088:eligibility-revert — Enable revert on ineligible indexers + * GIP-0088:eligibility-revert — Configure RM revert-on-ineligible behaviour * - * Optional governance TX: RM.setRevertOnIneligible(true) + * Optional governance TX: RM.setRevertOnIneligible() + * + * Reads `RewardsManager.revertOnIneligible` from config/.json5, + * defaulting to `true` (the expected target for all deployments). * * Not activated by `all` — requires explicit `--tags GIP-0088:eligibility-revert`. * - * Idempotent: reads on-chain revertOnIneligible, skips if already true. + * Idempotent: skips if on-chain state already matches config. * * Usage: * pnpm hardhat deploy --tags GIP-0088:eligibility-revert --network @@ -36,8 +40,12 @@ const func: DeployScriptModule = async (env) => { env.showMessage(`\n========== GIP-0088: Eligibility Revert ==========`) env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rm.address}`) + const config = await loadDeploymentConfig(env) + const desired = config.RewardsManager?.revertOnIneligible ?? true + // Check current state env.showMessage('\n📋 Checking current configuration...\n') + env.showMessage(` Config: revertOnIneligible = ${desired}`) let revertOnIneligible: boolean try { @@ -53,10 +61,12 @@ const func: DeployScriptModule = async (env) => { ) return } - env.showMessage(` revertOnIneligible: ${revertOnIneligible ? '✓ true' : '✗ false'}`) + env.showMessage( + ` On-chain: revertOnIneligible = ${revertOnIneligible} ${revertOnIneligible === desired ? '✓' : '✗'}`, + ) - if (revertOnIneligible) { - env.showMessage(`\n✅ ${Contracts.horizon.RewardsManager.name} already configured\n`) + if (revertOnIneligible === desired) { + env.showMessage(`\n✅ ${Contracts.horizon.RewardsManager.name} already matches config\n`) return } @@ -69,15 +79,15 @@ const func: DeployScriptModule = async (env) => { const data = encodeFunctionData({ abi: REWARDS_MANAGER_ABI, functionName: 'setRevertOnIneligible', - args: [true], + args: [desired], }) builder.addTx({ to: rm.address, value: '0', data }) - env.showMessage(` + setRevertOnIneligible(true)`) + env.showMessage(` + setRevertOnIneligible(${desired})`) if (canSign) { env.showMessage('\n🔨 Executing configuration TX batch...\n') await executeTxBatchDirect(env, builder, governor) - env.showMessage(`\n✅ GIP-0088: revertOnIneligible enabled\n`) + env.showMessage(`\n✅ GIP-0088: revertOnIneligible set to ${desired}\n`) } else { saveGovernanceTx(env, builder, `GIP-0088: revertOnIneligible`) } diff --git a/packages/deployment/lib/deployment-config.ts b/packages/deployment/lib/deployment-config.ts index 96cea017c..e4b89990b 100644 --- a/packages/deployment/lib/deployment-config.ts +++ b/packages/deployment/lib/deployment-config.ts @@ -37,6 +37,26 @@ function stripComments(text: string): string { return text.replace(/^\s*\/\/.*$/gm, '').replace(/,(\s*[}\]])/g, '$1') } +/** + * Load deployment configuration for a chain ID. + * + * Reads from packages/deployment/config/.json5. + * Returns empty config when the chain is unknown or the file is missing/invalid. + * Silent — no logging — so it can be used from non-deploy contexts (e.g. status task). + */ +export function loadDeploymentConfigForChain(chainId: number): DeploymentConfig { + const networkName = CHAIN_CONFIG_MAP[chainId] + if (!networkName) return {} + + const configPath = resolve(__dirname, '..', 'config', `${networkName}.json5`) + try { + const raw = readFileSync(configPath, 'utf-8') + return JSON.parse(stripComments(raw)) as DeploymentConfig + } catch { + return {} + } +} + /** * Load deployment configuration for the target network. * @@ -52,15 +72,11 @@ export async function loadDeploymentConfig(env: Environment): Promise { @@ -215,10 +217,15 @@ export async function getRewardsManagerChecks( checks.push({ ok: null, label: 'providerEligibilityOracle: not set' }) } - // Revert on ineligible + // Revert on ineligible — compare against config (default: true) const revertOnIneligible = await rmRead('getRevertOnIneligible') if (revertOnIneligible !== null) { - checks.push({ ok: null, label: `revertOnIneligible: ${revertOnIneligible}` }) + const desired = loadDeploymentConfigForChain(chainId).RewardsManager?.revertOnIneligible ?? true + const matches = revertOnIneligible === desired + checks.push({ + ok: matches, + label: `revertOnIneligible: ${revertOnIneligible}${matches ? '' : ` (expected ${desired})`}`, + }) } // Default reclaim address @@ -1042,6 +1049,7 @@ export async function showDetailedComponentStatus( checks = await getRewardsManagerChecks( client, horizonBook, + chainId, issuanceBook, graph.getSubgraphServiceAddressBook(chainId), ) diff --git a/packages/deployment/tasks/deployment-status.ts b/packages/deployment/tasks/deployment-status.ts index fc612c154..373c0d9d4 100644 --- a/packages/deployment/tasks/deployment-status.ts +++ b/packages/deployment/tasks/deployment-status.ts @@ -282,7 +282,7 @@ const action: NewTaskActionFunction = async (taskArgs, hre) => { // Integration checks for RewardsManager (only if deployed) if (name === 'RewardsManager' && client && result.exists) { - const checks = await getRewardsManagerChecks(client, horizonAddressBook) + const checks = await getRewardsManagerChecks(client, horizonAddressBook, targetChainId) for (const check of checks) { printCheck(check) } From 2c06233ce7912d2cc438212a0f4a5a89c94e81c5 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 09:41:35 +0000 Subject: [PATCH 125/157] chore(deployment): remove vestigial RecurringCollector block from network configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The empty RecurringCollector block carried only a comment explaining why pause guardian is not config-driven — context that mattered when the per-network config was first introduced but is no longer load-bearing. The RecurringCollector entry in DeploymentConfig stays so eip712Name and revokeSignerThawingPeriod can be set per-network if a future deployment needs them; today both fall through to script defaults. --- packages/deployment/config/arbitrumOne.json5 | 5 ----- packages/deployment/config/arbitrumSepolia.json5 | 5 ----- 2 files changed, 10 deletions(-) diff --git a/packages/deployment/config/arbitrumOne.json5 b/packages/deployment/config/arbitrumOne.json5 index 661c9e5b2..2819769c4 100644 --- a/packages/deployment/config/arbitrumOne.json5 +++ b/packages/deployment/config/arbitrumOne.json5 @@ -8,10 +8,5 @@ // ramSelfMintingGrtPerBlock: 0 (RAM does not self-mint) "ramAllocatorMintingGrtPerBlock": "6", "ramSelfMintingGrtPerBlock": "0" - }, - - "RecurringCollector": { - // Pause guardian is read from Controller.pauseGuardian() at deploy time - // (same as all other protocol contracts) } } diff --git a/packages/deployment/config/arbitrumSepolia.json5 b/packages/deployment/config/arbitrumSepolia.json5 index 72004193b..5b3350e94 100644 --- a/packages/deployment/config/arbitrumSepolia.json5 +++ b/packages/deployment/config/arbitrumSepolia.json5 @@ -8,10 +8,5 @@ // ramSelfMintingGrtPerBlock: GRT per block (0 = RAM does not self-mint) "ramAllocatorMintingGrtPerBlock": "0.5", "ramSelfMintingGrtPerBlock": "0" - }, - - "RecurringCollector": { - // Pause guardian is read from Controller.pauseGuardian() at deploy time - // (same as all other protocol contracts) } } From 5843b6d7f379720eb77b3bff89a0875344f04326 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 09:46:22 +0000 Subject: [PATCH 126/157] refactor(deployment): centralise config resolution with ResolvedSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace per-call defaulting (config.X?.Y ?? defaultY scattered across deploy scripts and status checks) with a single getResolvedSettings(chainId) that returns a fully-resolved settings object. Defaults live in one DEFAULT_SETTINGS constant; consumers read concrete fields from a non-optional type. Eliminates the duplicated default for RewardsManager.revertOnIneligible (was in eligibility_revert.ts and status-detail.ts) and the same latent duplication risk for IssuanceAllocator and RecurringCollector fields. Removes the env-based loadDeploymentConfig and the chainId-only loadDeploymentConfigForChain in favour of getResolvedSettings(chainId) plus a thin getResolvedSettingsForEnv(env) convenience wrapper. Drops the per-call "Loaded config from..." log lines, which fired multiple times per deploy run with no useful signal. Per-network targeting is preserved — chainId remains the lookup key, networks override only what they need. Defaults are uniform across networks; if a network needs a different value, it states so explicitly. --- .../deploy/gip/0088/eligibility_revert.ts | 6 +- .../deploy/gip/0088/issuance_allocate.ts | 11 +- .../horizon/recurring-collector/01_deploy.ts | 9 +- packages/deployment/lib/deployment-config.ts | 110 +++++++++++++----- packages/deployment/lib/status-detail.ts | 6 +- 5 files changed, 97 insertions(+), 45 deletions(-) diff --git a/packages/deployment/deploy/gip/0088/eligibility_revert.ts b/packages/deployment/deploy/gip/0088/eligibility_revert.ts index dda01e962..8314213e4 100644 --- a/packages/deployment/deploy/gip/0088/eligibility_revert.ts +++ b/packages/deployment/deploy/gip/0088/eligibility_revert.ts @@ -1,7 +1,7 @@ import { REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' +import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' import { ComponentTags, GoalTags, shouldSkipOptionalGoal } from '@graphprotocol/deployment/lib/deployment-tags.js' import { createGovernanceTxBuilder, @@ -40,8 +40,8 @@ const func: DeployScriptModule = async (env) => { env.showMessage(`\n========== GIP-0088: Eligibility Revert ==========`) env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rm.address}`) - const config = await loadDeploymentConfig(env) - const desired = config.RewardsManager?.revertOnIneligible ?? true + const settings = await getResolvedSettingsForEnv(env) + const desired = settings.rewardsManager.revertOnIneligible // Check current state env.showMessage('\n📋 Checking current configuration...\n') diff --git a/packages/deployment/deploy/gip/0088/issuance_allocate.ts b/packages/deployment/deploy/gip/0088/issuance_allocate.ts index 689146b82..525970477 100644 --- a/packages/deployment/deploy/gip/0088/issuance_allocate.ts +++ b/packages/deployment/deploy/gip/0088/issuance_allocate.ts @@ -1,7 +1,7 @@ import { ACCESS_CONTROL_ENUMERABLE_ABI, SET_TARGET_ALLOCATION_ABI } from '@graphprotocol/deployment/lib/abis.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' +import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' import { ComponentTags, GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' import { createGovernanceTxBuilder, @@ -56,11 +56,10 @@ export default createActionModule( env.showMessage(`IA: ${ia.address}`) env.showMessage(`RAM: ${ram.address}`) - // Load config - const config = await loadDeploymentConfig(env) - const iaConfig = config.IssuanceAllocator ?? {} - const allocatorMintingRate = parseUnits(iaConfig.ramAllocatorMintingGrtPerBlock ?? '0', 18) - const selfMintingRate = parseUnits(iaConfig.ramSelfMintingGrtPerBlock ?? '0', 18) + // Load resolved settings + const settings = await getResolvedSettingsForEnv(env) + const allocatorMintingRate = parseUnits(settings.issuanceAllocator.ramAllocatorMintingGrtPerBlock, 18) + const selfMintingRate = parseUnits(settings.issuanceAllocator.ramSelfMintingGrtPerBlock, 18) if (allocatorMintingRate === 0n && selfMintingRate === 0n) { env.showMessage('\n⚠️ RAM allocation rates not configured (both 0).') diff --git a/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts b/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts index d85c02f99..4f96b4c35 100644 --- a/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts +++ b/packages/deployment/deploy/horizon/recurring-collector/01_deploy.ts @@ -1,5 +1,5 @@ import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { loadDeploymentConfig } from '@graphprotocol/deployment/lib/deployment-config.js' +import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' import { ComponentTags, DeploymentActions, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' import { deployProxyContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' @@ -30,11 +30,8 @@ const func: DeployScriptModule = async (env) => { throw new Error('Missing Controller deployment after sync.') } - const config = await loadDeploymentConfig(env) - const rcConfig = config.RecurringCollector ?? {} - const revokeSignerThawingPeriod = rcConfig.revokeSignerThawingPeriod ?? '28800' // ~1 day at 3s blocks - const eip712Name = rcConfig.eip712Name ?? 'RecurringCollector' - const eip712Version = rcConfig.eip712Version ?? '1' + const settings = await getResolvedSettingsForEnv(env) + const { revokeSignerThawingPeriod, eip712Name, eip712Version } = settings.recurringCollector env.showMessage(`\n📦 Deploying ${Contracts.horizon.RecurringCollector.name}`) diff --git a/packages/deployment/lib/deployment-config.ts b/packages/deployment/lib/deployment-config.ts index e4b89990b..7f845950d 100644 --- a/packages/deployment/lib/deployment-config.ts +++ b/packages/deployment/lib/deployment-config.ts @@ -14,7 +14,11 @@ const CHAIN_CONFIG_MAP: Record = { 421614: 'arbitrumSepolia', } -export interface DeploymentConfig { +/** + * Raw on-disk shape of `config/.json5`. Every field is optional — + * networks override only what they need; the rest comes from `DEFAULT_SETTINGS`. + */ +interface DeploymentConfigFile { IssuanceAllocator?: { ramAllocatorMintingGrtPerBlock?: string ramSelfMintingGrtPerBlock?: string @@ -29,6 +33,50 @@ export interface DeploymentConfig { } } +/** + * Fully-resolved deployment settings for a given chain. + * + * Every field is concrete — defaults from `DEFAULT_SETTINGS` are applied for + * any field a network's config file omits. Consumers (deploy scripts and + * status checks) read this directly without per-call `??` fallbacks, so the + * "expected value" lives in exactly one place per field. + */ +export interface ResolvedSettings { + rewardsManager: { + /** Revert on reward claim attempts by ineligible indexers. */ + revertOnIneligible: boolean + } + issuanceAllocator: { + /** GRT/block minted by IA and routed to RAM. `'0'` means unconfigured (skip allocation). */ + ramAllocatorMintingGrtPerBlock: string + /** GRT/block self-minted by RAM. `'0'` means RAM does not self-mint. */ + ramSelfMintingGrtPerBlock: string + } + recurringCollector: { + /** Signer revocation thaw period in seconds (constructor arg). */ + revokeSignerThawingPeriod: string + /** EIP-712 domain name (init arg). */ + eip712Name: string + /** EIP-712 domain version (init arg). */ + eip712Version: string + } +} + +const DEFAULT_SETTINGS: ResolvedSettings = { + rewardsManager: { + revertOnIneligible: true, + }, + issuanceAllocator: { + ramAllocatorMintingGrtPerBlock: '0', + ramSelfMintingGrtPerBlock: '0', + }, + recurringCollector: { + revokeSignerThawingPeriod: '28800', // ~1 day at 3s blocks + eip712Name: 'RecurringCollector', + eip712Version: '1', + }, +} + /** * Strip single-line // comments from JSON5-style content so it can be parsed * by JSON.parse. Preserves strings containing //. @@ -37,46 +85,54 @@ function stripComments(text: string): string { return text.replace(/^\s*\/\/.*$/gm, '').replace(/,(\s*[}\]])/g, '$1') } -/** - * Load deployment configuration for a chain ID. - * - * Reads from packages/deployment/config/.json5. - * Returns empty config when the chain is unknown or the file is missing/invalid. - * Silent — no logging — so it can be used from non-deploy contexts (e.g. status task). - */ -export function loadDeploymentConfigForChain(chainId: number): DeploymentConfig { +function loadConfigFile(chainId: number): DeploymentConfigFile { const networkName = CHAIN_CONFIG_MAP[chainId] if (!networkName) return {} const configPath = resolve(__dirname, '..', 'config', `${networkName}.json5`) try { const raw = readFileSync(configPath, 'utf-8') - return JSON.parse(stripComments(raw)) as DeploymentConfig + return JSON.parse(stripComments(raw)) as DeploymentConfigFile } catch { return {} } } /** - * Load deployment configuration for the target network. + * Get fully-resolved deployment settings for a chain. * - * Reads from packages/deployment/config/.json5. - * Falls back to empty config if file not found (local/fork mode). + * Reads `config/.json5` (if present) and applies `DEFAULT_SETTINGS` + * for any field the network omits. Pure / sync — safe to call from non-deploy + * contexts (e.g. the status task). Returns full defaults for unknown chains. */ -export async function loadDeploymentConfig(env: Environment): Promise { - const chainId = await getTargetChainIdFromEnv(env) - const networkName = CHAIN_CONFIG_MAP[chainId] - - if (!networkName) { - env.showMessage(` No deployment config for chain ${chainId}, using defaults`) - return {} +export function getResolvedSettings(chainId: number): ResolvedSettings { + const file = loadConfigFile(chainId) + return { + rewardsManager: { + revertOnIneligible: file.RewardsManager?.revertOnIneligible ?? DEFAULT_SETTINGS.rewardsManager.revertOnIneligible, + }, + issuanceAllocator: { + ramAllocatorMintingGrtPerBlock: + file.IssuanceAllocator?.ramAllocatorMintingGrtPerBlock ?? + DEFAULT_SETTINGS.issuanceAllocator.ramAllocatorMintingGrtPerBlock, + ramSelfMintingGrtPerBlock: + file.IssuanceAllocator?.ramSelfMintingGrtPerBlock ?? + DEFAULT_SETTINGS.issuanceAllocator.ramSelfMintingGrtPerBlock, + }, + recurringCollector: { + revokeSignerThawingPeriod: + file.RecurringCollector?.revokeSignerThawingPeriod ?? + DEFAULT_SETTINGS.recurringCollector.revokeSignerThawingPeriod, + eip712Name: file.RecurringCollector?.eip712Name ?? DEFAULT_SETTINGS.recurringCollector.eip712Name, + eip712Version: file.RecurringCollector?.eip712Version ?? DEFAULT_SETTINGS.recurringCollector.eip712Version, + }, } +} - const config = loadDeploymentConfigForChain(chainId) - if (Object.keys(config).length === 0) { - env.showMessage(` Config file not found or invalid: config/${networkName}.json5, using defaults`) - } else { - env.showMessage(` Loaded config from config/${networkName}.json5`) - } - return config +/** + * Convenience wrapper for deploy scripts that have an `env` but not a chainId. + */ +export async function getResolvedSettingsForEnv(env: Environment): Promise { + const chainId = await getTargetChainIdFromEnv(env) + return getResolvedSettings(chainId) } diff --git a/packages/deployment/lib/status-detail.ts b/packages/deployment/lib/status-detail.ts index 265ca0a29..b460271ce 100644 --- a/packages/deployment/lib/status-detail.ts +++ b/packages/deployment/lib/status-detail.ts @@ -28,7 +28,7 @@ import { supportsInterface, } from './contract-checks.js' import type { RegistryEntry } from './contract-registry.js' -import { loadDeploymentConfigForChain } from './deployment-config.js' +import { getResolvedSettings } from './deployment-config.js' import { countPendingGovernanceTxs } from './execute-governance.js' import { formatGRT } from './format.js' import { getContractStatusLine, type ContractStatusResult, type ProxyAdminOwnershipContext } from './sync-utils.js' @@ -217,10 +217,10 @@ export async function getRewardsManagerChecks( checks.push({ ok: null, label: 'providerEligibilityOracle: not set' }) } - // Revert on ineligible — compare against config (default: true) + // Revert on ineligible — compare against resolved settings const revertOnIneligible = await rmRead('getRevertOnIneligible') if (revertOnIneligible !== null) { - const desired = loadDeploymentConfigForChain(chainId).RewardsManager?.revertOnIneligible ?? true + const desired = getResolvedSettings(chainId).rewardsManager.revertOnIneligible const matches = revertOnIneligible === desired checks.push({ ok: matches, From 71e567fb1b68a17abbb52e74ea3c4d9676077b62 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 11:05:28 +0000 Subject: [PATCH 127/157] feat(deployment): bundle RM.setRevertOnIneligible into upgrade governance batch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds checkRMRevertOnIneligible precondition helper. 04_upgrade.ts now queues setRevertOnIneligible() into the governance batch when on-chain doesn't match config — gated on RM upgraded, alongside the existing setDefaultReclaimAddress block. upgrade/10_status.ts surfaces mismatch as a deferred issue alongside Reclaim, so the Next-step hint correctly accounts for it. No new goal or activation tag — revertOnIneligible is RM-side governance config that rides the existing upgrade governance batch, same shape as setDefaultReclaimAddress. The desired value flows from getResolvedSettings into deploy, status, verification, and per-component display. --- packages/deployment/deploy/gip/0088/09_end.ts | 23 +++- .../deployment/deploy/gip/0088/10_status.ts | 28 +---- .../deploy/gip/0088/eligibility_revert.ts | 100 ------------------ .../deploy/gip/0088/upgrade/04_upgrade.ts | 31 +++++- .../deploy/gip/0088/upgrade/10_status.ts | 10 ++ packages/deployment/lib/deployment-tags.ts | 1 - packages/deployment/lib/preconditions.ts | 26 +++++ 7 files changed, 86 insertions(+), 133 deletions(-) delete mode 100644 packages/deployment/deploy/gip/0088/eligibility_revert.ts diff --git a/packages/deployment/deploy/gip/0088/09_end.ts b/packages/deployment/deploy/gip/0088/09_end.ts index 85addeb08..2cb8b7fda 100644 --- a/packages/deployment/deploy/gip/0088/09_end.ts +++ b/packages/deployment/deploy/gip/0088/09_end.ts @@ -1,10 +1,11 @@ -import { PROVIDER_ELIGIBILITY_MANAGEMENT_ABI } from '@graphprotocol/deployment/lib/abis.js' +import { PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' import { addressEquals, checkIssuanceAllocatorActivation, isRewardsManagerUpgraded, } from '@graphprotocol/deployment/lib/contract-checks.js' import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' +import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' import { DeploymentActions, GoalTags, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' import { requireContracts } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' @@ -17,10 +18,10 @@ import type { PublicClient } from 'viem' * * Verifies all non-optional phases are complete: * - Upgrade: RM upgraded (supports IIssuanceTarget) - * - Eligibility: REO integrated with RM + * - Eligibility: REO integrated with RM, revertOnIneligible matches config * - Issuance: IA connected to RM, minter role granted * - * Does NOT verify optional goals (eligibility-revert, issuance-close-guard). + * Does NOT verify optional goals (issuance-close-guard). * * Usage: * pnpm hardhat deploy --tags GIP-0088,all --network @@ -75,6 +76,22 @@ const func: DeployScriptModule = async (env) => { failures.push('RewardsEligibilityOracleA not deployed') } + // Verify revertOnIneligible matches config + const settings = await getResolvedSettingsForEnv(env) + const desiredRevert = settings.rewardsManager.revertOnIneligible + try { + const onChainRevert = (await client.readContract({ + address: rewardsManager.address as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getRevertOnIneligible', + })) as boolean + if (onChainRevert !== desiredRevert) { + failures.push(`revertOnIneligible mismatch: on-chain=${onChainRevert}, config=${desiredRevert}`) + } + } catch { + failures.push('RM does not support getRevertOnIneligible (not upgraded?)') + } + if (failures.length > 0) { env.showMessage(`\n❌ GIP-0088 incomplete:`) for (const f of failures) env.showMessage(` - ${f}`) diff --git a/packages/deployment/deploy/gip/0088/10_status.ts b/packages/deployment/deploy/gip/0088/10_status.ts index 8810b054d..f55ac1713 100644 --- a/packages/deployment/deploy/gip/0088/10_status.ts +++ b/packages/deployment/deploy/gip/0088/10_status.ts @@ -1,17 +1,11 @@ import { IISSUANCE_TARGET_INTERFACE_ID, - IREWARDS_MANAGER_INTERFACE_ID, ISSUANCE_TARGET_ABI, PROVIDER_ELIGIBILITY_MANAGEMENT_ABI, - REWARDS_MANAGER_ABI, SUBGRAPH_SERVICE_CLOSE_GUARD_ABI, } from '@graphprotocol/deployment/lib/abis.js' import { getTargetChainIdFromEnv } from '@graphprotocol/deployment/lib/address-book-utils.js' -import { - addressEquals, - isRewardsManagerUpgraded, - supportsInterface, -} from '@graphprotocol/deployment/lib/contract-checks.js' +import { addressEquals, isRewardsManagerUpgraded } from '@graphprotocol/deployment/lib/contract-checks.js' import { Contracts, type RegistryEntry } from '@graphprotocol/deployment/lib/contract-registry.js' import { GoalTags } from '@graphprotocol/deployment/lib/deployment-tags.js' import { createStatusModule } from '@graphprotocol/deployment/lib/script-factories.js' @@ -155,25 +149,6 @@ export default createStatusModule(GoalTags.GIP_0088, async (env) => { // --- Optional status --- env.showMessage('\n--- Optional (not planned) ---') - // eligibility-revert - if (rm) { - const supportsLatestRM = await supportsInterface(client, rm.address, IREWARDS_MANAGER_INTERFACE_ID) - if (supportsLatestRM) { - const revertOnIneligible = (await client.readContract({ - address: rm.address as `0x${string}`, - abi: REWARDS_MANAGER_ABI, - functionName: 'getRevertOnIneligible', - })) as boolean - env.showMessage( - ` ${revertOnIneligible ? '✓' : '○'} eligibility-revert: revertOnIneligible = ${revertOnIneligible}`, - ) - } else { - env.showMessage(` ○ eligibility-revert: RM not upgraded`) - } - } else { - env.showMessage(` ○ eligibility-revert: RM not deployed`) - } - // issuance-close-guard const ss = env.getOrNull('SubgraphService') if (ss) { @@ -200,7 +175,6 @@ export default createStatusModule(GoalTags.GIP_0088, async (env) => { env.showMessage(' --tags GIP-0088:issuance-connect') env.showMessage(' --tags GIP-0088:issuance-allocate') env.showMessage(' Optional:') - env.showMessage(' --tags GIP-0088:eligibility-revert') env.showMessage(' --tags GIP-0088:issuance-close-guard') showPendingGovernanceTxs(env) diff --git a/packages/deployment/deploy/gip/0088/eligibility_revert.ts b/packages/deployment/deploy/gip/0088/eligibility_revert.ts deleted file mode 100644 index 8314213e4..000000000 --- a/packages/deployment/deploy/gip/0088/eligibility_revert.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { REWARDS_MANAGER_ABI } from '@graphprotocol/deployment/lib/abis.js' -import { Contracts } from '@graphprotocol/deployment/lib/contract-registry.js' -import { canSignAsGovernor } from '@graphprotocol/deployment/lib/controller-utils.js' -import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' -import { ComponentTags, GoalTags, shouldSkipOptionalGoal } from '@graphprotocol/deployment/lib/deployment-tags.js' -import { - createGovernanceTxBuilder, - executeTxBatchDirect, - saveGovernanceTx, -} from '@graphprotocol/deployment/lib/execute-governance.js' -import { requireContract } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' -import { syncComponentsFromRegistry } from '@graphprotocol/deployment/lib/sync-utils.js' -import { graph } from '@graphprotocol/deployment/rocketh/deploy.js' -import type { DeployScriptModule } from '@rocketh/core/types' -import type { PublicClient } from 'viem' -import { encodeFunctionData } from 'viem' - -/** - * GIP-0088:eligibility-revert — Configure RM revert-on-ineligible behaviour - * - * Optional governance TX: RM.setRevertOnIneligible() - * - * Reads `RewardsManager.revertOnIneligible` from config/.json5, - * defaulting to `true` (the expected target for all deployments). - * - * Not activated by `all` — requires explicit `--tags GIP-0088:eligibility-revert`. - * - * Idempotent: skips if on-chain state already matches config. - * - * Usage: - * pnpm hardhat deploy --tags GIP-0088:eligibility-revert --network - */ -const func: DeployScriptModule = async (env) => { - if (shouldSkipOptionalGoal(GoalTags.GIP_0088_ELIGIBILITY_REVERT)) return - await syncComponentsFromRegistry(env, [Contracts.horizon.RewardsManager]) - - const client = graph.getPublicClient(env) as PublicClient - const rm = requireContract(env, Contracts.horizon.RewardsManager) - - env.showMessage(`\n========== GIP-0088: Eligibility Revert ==========`) - env.showMessage(`${Contracts.horizon.RewardsManager.name}: ${rm.address}`) - - const settings = await getResolvedSettingsForEnv(env) - const desired = settings.rewardsManager.revertOnIneligible - - // Check current state - env.showMessage('\n📋 Checking current configuration...\n') - env.showMessage(` Config: revertOnIneligible = ${desired}`) - - let revertOnIneligible: boolean - try { - revertOnIneligible = (await client.readContract({ - address: rm.address as `0x${string}`, - abi: REWARDS_MANAGER_ABI, - functionName: 'getRevertOnIneligible', - })) as boolean - } catch { - // Function not available — RM not upgraded, skip (matches eligibility_integrate) - env.showMessage( - `\n ○ ${Contracts.horizon.RewardsManager.name} does not support getRevertOnIneligible — skipping\n`, - ) - return - } - env.showMessage( - ` On-chain: revertOnIneligible = ${revertOnIneligible} ${revertOnIneligible === desired ? '✓' : '✗'}`, - ) - - if (revertOnIneligible === desired) { - env.showMessage(`\n✅ ${Contracts.horizon.RewardsManager.name} already matches config\n`) - return - } - - const { governor, canSign } = await canSignAsGovernor(env) - - env.showMessage('\n🔨 Building configuration TX batch...\n') - - const builder = await createGovernanceTxBuilder(env, `gip-0088-eligibility-revert`) - - const data = encodeFunctionData({ - abi: REWARDS_MANAGER_ABI, - functionName: 'setRevertOnIneligible', - args: [desired], - }) - builder.addTx({ to: rm.address, value: '0', data }) - env.showMessage(` + setRevertOnIneligible(${desired})`) - - if (canSign) { - env.showMessage('\n🔨 Executing configuration TX batch...\n') - await executeTxBatchDirect(env, builder, governor) - env.showMessage(`\n✅ GIP-0088: revertOnIneligible set to ${desired}\n`) - } else { - saveGovernanceTx(env, builder, `GIP-0088: revertOnIneligible`) - } -} - -func.tags = [GoalTags.GIP_0088_ELIGIBILITY_REVERT] -func.dependencies = [ComponentTags.REWARDS_MANAGER] -func.skip = async () => shouldSkipOptionalGoal(GoalTags.GIP_0088_ELIGIBILITY_REVERT) - -export default func diff --git a/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts b/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts index 4f333f0c7..2dbc35825 100644 --- a/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts +++ b/packages/deployment/deploy/gip/0088/upgrade/04_upgrade.ts @@ -17,6 +17,7 @@ import { Contracts, } from '@graphprotocol/deployment/lib/contract-registry.js' import { canSignAsGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { getResolvedSettingsForEnv, type ResolvedSettings } from '@graphprotocol/deployment/lib/deployment-config.js' import { DeploymentActions, GoalTags, shouldSkipAction } from '@graphprotocol/deployment/lib/deployment-tags.js' import { createGovernanceTxBuilder, @@ -30,6 +31,7 @@ import { checkRAMConfigured, checkReclaimRMIntegration, checkReclaimRoles, + checkRMRevertOnIneligible, } from '@graphprotocol/deployment/lib/preconditions.js' import { runFullSync } from '@graphprotocol/deployment/lib/sync-utils.js' import type { TxBuilder } from '@graphprotocol/deployment/lib/tx-builder.js' @@ -81,8 +83,10 @@ const func: DeployScriptModule = async (env) => { const proxyCount = await collectProxyUpgrades(env, builder, targetChainId) + const settings = await getResolvedSettingsForEnv(env) + env.showMessage('\nOutstanding configuration:') - const existingCount = await collectExistingContractConfig(env, builder, client, pauseGuardian) + const existingCount = await collectExistingContractConfig(env, builder, client, pauseGuardian, settings) const newCount = await collectDeferredNewContractConfig(env, builder, client, targetChainId, governor, pauseGuardian) const total = proxyCount + existingCount + newCount @@ -161,16 +165,20 @@ async function collectProxyUpgrades(env: Environment, builder: TxBuilder, target /** * Bundle the few governance-only configure items on contracts that already - * existed before this deployment (deployer never had GOVERNOR_ROLE on them): + * existed before this deployment (typically the deployer does not hold + * GOVERNOR_ROLE on them — true on networks where RM was deployed by separate + * horizon-Ignition infrastructure; the dynamic role check is the source of truth): * * - RC.setPauseGuardian * - RM.setDefaultReclaimAddress (only when RM has been upgraded) + * - RM.setRevertOnIneligible (driven by config; only when RM has been upgraded) */ async function collectExistingContractConfig( env: Environment, builder: TxBuilder, client: PublicClient, pauseGuardian: string, + settings: ResolvedSettings, ): Promise { let added = 0 @@ -218,6 +226,25 @@ async function collectExistingContractConfig( } } + // RM.setRevertOnIneligible — driven by config; only after RM upgrade lands + if (rm) { + const desiredRevert = settings.rewardsManager.revertOnIneligible + const revertCheck = await checkRMRevertOnIneligible(client, rm.address, desiredRevert) + if (!revertCheck.done && revertCheck.reason !== 'RM not upgraded') { + builder.addTx({ + to: rm.address, + value: '0', + data: encodeFunctionData({ + abi: REWARDS_MANAGER_ABI, + functionName: 'setRevertOnIneligible', + args: [desiredRevert], + }), + }) + env.showMessage(` + ${Contracts.horizon.RewardsManager.name}.setRevertOnIneligible(${desiredRevert})`) + added++ + } + } + return added } diff --git a/packages/deployment/deploy/gip/0088/upgrade/10_status.ts b/packages/deployment/deploy/gip/0088/upgrade/10_status.ts index 0107b3eb9..352b04d4f 100644 --- a/packages/deployment/deploy/gip/0088/upgrade/10_status.ts +++ b/packages/deployment/deploy/gip/0088/upgrade/10_status.ts @@ -8,6 +8,7 @@ import { } from '@graphprotocol/deployment/lib/contract-checks.js' import { Contracts, type RegistryEntry } from '@graphprotocol/deployment/lib/contract-registry.js' import { getGovernor, getPauseGuardian } from '@graphprotocol/deployment/lib/controller-utils.js' +import { getResolvedSettingsForEnv } from '@graphprotocol/deployment/lib/deployment-config.js' import { ComponentTags, GoalTags, noTagsRequested } from '@graphprotocol/deployment/lib/deployment-tags.js' import { getDeployer, getProxyAdminAddress } from '@graphprotocol/deployment/lib/issuance-deploy-utils.js' import { @@ -18,6 +19,7 @@ import { checkRAMConfigured, checkReclaimRMIntegration, checkReclaimRoles, + checkRMRevertOnIneligible, } from '@graphprotocol/deployment/lib/preconditions.js' import { showDetailedComponentStatus, showPendingGovernanceTxs } from '@graphprotocol/deployment/lib/status-detail.js' import { checkAllProxyStates, getContractStatusLine, runFullSync } from '@graphprotocol/deployment/lib/sync-utils.js' @@ -222,6 +224,14 @@ const func: DeployScriptModule = async (env) => { deferredIssues.push(`Reclaim: ${reclaimRMCheck.reason}`) } + // RM.setRevertOnIneligible — config-driven; same deferred-only treatment as + // setDefaultReclaimAddress (target is RM, governance-only setter). + const settings = await getResolvedSettingsForEnv(env) + const revertCheck = await checkRMRevertOnIneligible(client, rm.address, settings.rewardsManager.revertOnIneligible) + if (!revertCheck.done && revertCheck.reason !== 'RM not upgraded') { + deferredIssues.push(`RM: ${revertCheck.reason}`) + } + // REO configure const issuanceBook = graph.getIssuanceAddressBook(targetChainId) const hasNetworkOperator = issuanceBook.entryExists('NetworkOperator') diff --git a/packages/deployment/lib/deployment-tags.ts b/packages/deployment/lib/deployment-tags.ts index 6d2c4f6aa..9db4bbdad 100644 --- a/packages/deployment/lib/deployment-tags.ts +++ b/packages/deployment/lib/deployment-tags.ts @@ -78,7 +78,6 @@ export const GoalTags = { GIP_0088_ISSUANCE_ALLOCATE: 'GIP-0088:issuance-allocate', // Optional goals (not activated by `all`) - GIP_0088_ELIGIBILITY_REVERT: 'GIP-0088:eligibility-revert', GIP_0088_ISSUANCE_CLOSE_GUARD: 'GIP-0088:issuance-close-guard', } as const diff --git a/packages/deployment/lib/preconditions.ts b/packages/deployment/lib/preconditions.ts index 37adc5638..8f000597a 100644 --- a/packages/deployment/lib/preconditions.ts +++ b/packages/deployment/lib/preconditions.ts @@ -252,6 +252,32 @@ export async function checkReclaimRMIntegration( } } +/** + * Check whether RM.getRevertOnIneligible() matches the desired value from config. + * + * Governance-only setter on RM — failure is deferred to the upgrade governance batch + * unless the deployer holds GOVERNOR_ROLE on RM (true on fresh networks where RM is + * deployed from scratch with the deployer as initial governor; false on networks + * where RM was deployed by separate horizon-Ignition infrastructure). + */ +export async function checkRMRevertOnIneligible( + client: PublicClient, + rmAddress: string, + desired: boolean, +): Promise { + try { + const onChain = (await client.readContract({ + address: rmAddress as `0x${string}`, + abi: REWARDS_MANAGER_ABI, + functionName: 'getRevertOnIneligible', + })) as boolean + if (onChain === desired) return { done: true } + return { done: false, reason: `revertOnIneligible=${onChain}, expected ${desired}` } + } catch { + return { done: false, reason: 'RM not upgraded' } + } +} + /** * Check if ReclaimedRewards is fully configured (roles + RM integration) * From 2828d64846370d06f4a0d9b4f70b22a5b82afe5f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:06:24 +0000 Subject: [PATCH 128/157] fix(deployment): gate sync rocketh-record seeding on artifact verification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When syncing a non-proxy address-book entry that has no rocketh deployment record, sync was unconditionally seeding rocketh's record from the local artifact's bytecode. If the artifact had drifted from on-chain (source recompiled since the impl was deployed), this masked the change: rocketh's native bytecode comparison then matched its (just-seeded) record against the artifact and returned newlyDeployed=false. The address book never advanced, proxy scripts saw no impl-address change, and shared-impl proxies (DefaultAllocation, ReclaimedRewards) ended up with code-changed status but no pendingImplementation set — so the upgrade orchestrator skipped them. Mirror the gate the proxy path already uses for ${name}_Implementation: seed only when the local artifact's bytecode hash matches the address book's stored hash. When it doesn't, leave rocketh's record absent so the next deployFn sees no prior bytecode and produces newlyDeployed=true, propagating the new impl address through to proxy pending-upgrade detection naturally. Scope of the gate: - Only registered registry names — proxy sync recurses with synthetic names (e.g. RewardsManager_Implementation) that aren't real address-book entries; the proxy path has its own hashMatches gate before recursing. - Only non-prerequisites — externally-deployed contracts (L2GraphToken) are never run through deployFn, so the dedup-masking concern doesn't apply and they still need an env record for downstream reads. Also replace the silent fall-through in deployProxyContract's shared-impl branch with a throw when env.getOrNull(sharedImplementation.name) returns null. With the sync fix in place, missing implDep is no longer a routine state masking drift; it's a real signal that the impl deploy script didn't run or didn't produce a record. --- .../deployment/lib/issuance-deploy-utils.ts | 77 +++++++++-------- packages/deployment/lib/sync-utils.ts | 82 ++++++++++++++----- 2 files changed, 103 insertions(+), 56 deletions(-) diff --git a/packages/deployment/lib/issuance-deploy-utils.ts b/packages/deployment/lib/issuance-deploy-utils.ts index 2d0ff45ba..a7ac62727 100644 --- a/packages/deployment/lib/issuance-deploy-utils.ts +++ b/packages/deployment/lib/issuance-deploy-utils.ts @@ -304,44 +304,53 @@ export async function deployProxyContract( env.showMessage(` Uses shared implementation: ${sharedImplementation.name}`) const implDep = env.getOrNull(sharedImplementation.name) - if (implDep) { - const client = graph.getPublicClient(env) - const onChainImpl = await getOnChainImplementation(client, existingProxy.address, 'transparent') - - if (onChainImpl.toLowerCase() !== implDep.address.toLowerCase()) { - // Shared implementation changed — store as pending for governance upgrade - const targetChainId = await getTargetChainIdFromEnv(env) - const addressBook: AnyAddressBookOps = - contract.addressBook === 'horizon' - ? graph.getHorizonAddressBook(targetChainId) - : graph.getIssuanceAddressBook(targetChainId) - - // Get deployment metadata from the shared implementation's address book entry - const implMetadata = addressBook.getDeploymentMetadata(sharedImplementation.name) - addressBook.setPendingImplementationWithMetadata( - contract.name, - implDep.address, - implMetadata ?? { txHash: '', bytecodeHash: '' }, - ) - - env.showMessage(``) - env.showMessage(`⚠️ UPGRADE REQUIRED`) - env.showMessage(` Proxy: ${existingProxy.address}`) - env.showMessage(` Current (on-chain): ${onChainImpl}`) - env.showMessage(` New implementation: ${implDep.address}`) - env.showMessage(``) - env.showMessage(` Stored as pending — run upgrade task to generate governance TX.`) - - return { - address: existingProxy.address, - newlyDeployed: false, - upgraded: true, - } + if (!implDep) { + // Missing impl record means the impl's deploy script didn't run, or sync + // skipped seeding because the artifact couldn't be verified against the + // address book. Either way, silently treating this as "no change" would + // mask a drift between artifact and on-chain bytecode (the shared impl + // bug fixed alongside this guard). Fail loud instead. + throw new Error( + `${contract.name}: shared implementation ${sharedImplementation.name} not in env. ` + + `Ensure ${sharedImplementation.name} is listed in dependencies and its deploy script ran successfully.`, + ) + } + + const client = graph.getPublicClient(env) + const onChainImpl = await getOnChainImplementation(client, existingProxy.address, 'transparent') + + if (onChainImpl.toLowerCase() !== implDep.address.toLowerCase()) { + // Shared implementation changed — store as pending for governance upgrade + const targetChainId = await getTargetChainIdFromEnv(env) + const addressBook: AnyAddressBookOps = + contract.addressBook === 'horizon' + ? graph.getHorizonAddressBook(targetChainId) + : graph.getIssuanceAddressBook(targetChainId) + + // Get deployment metadata from the shared implementation's address book entry + const implMetadata = addressBook.getDeploymentMetadata(sharedImplementation.name) + addressBook.setPendingImplementationWithMetadata( + contract.name, + implDep.address, + implMetadata ?? { txHash: '', bytecodeHash: '' }, + ) + + env.showMessage(``) + env.showMessage(`⚠️ UPGRADE REQUIRED`) + env.showMessage(` Proxy: ${existingProxy.address}`) + env.showMessage(` Current (on-chain): ${onChainImpl}`) + env.showMessage(` New implementation: ${implDep.address}`) + env.showMessage(``) + env.showMessage(` Stored as pending — run upgrade task to generate governance TX.`) + + return { + address: existingProxy.address, + newlyDeployed: false, + upgraded: true, } } // No change — check existing pending status - const client = graph.getPublicClient(env) await checkPendingUpgrade(env, client, contract, existingProxy.address, 'transparent') return { diff --git a/packages/deployment/lib/sync-utils.ts b/packages/deployment/lib/sync-utils.ts index aa42c3f48..83695957a 100644 --- a/packages/deployment/lib/sync-utils.ts +++ b/packages/deployment/lib/sync-utils.ts @@ -824,31 +824,69 @@ export async function syncContract( statusNotes.push('re-imported') } + // Verify the local artifact reflects what was last deployed before seeding + // rocketh from it. The address-book stored bytecodeHash is recorded at deploy + // time, so a local-to-stored hash match is our proxy for "artifact == on-chain". + // When verification fails for a contract we deploy, skip the seed: leaving + // rocketh's record absent lets deployFn deploy fresh rather than masking a + // drift between artifact and on-chain bytecode. + // + // Scope of the gate: + // - Only registered registry names — proxy sync recurses with synthetic names + // like `${proxyName}_Implementation` that aren't real address-book entries; + // the proxy path has already gated on hashMatches before recursing. + // - Only non-prerequisites — prerequisites (e.g. L2GraphToken) are deployed + // externally; we never call deployFn on them, so the dedup-masking concern + // doesn't apply and we still need them in env for downstream reads. + const registeredForVerify = getContractMetadata(spec.addressBookType, spec.name) + const gateApplies = !!registeredForVerify && !spec.prerequisite && !!spec.artifact + let artifactVerified = false + let canVerify = false + if (gateApplies) { + const chainIdForVerify = await getTargetChainIdFromEnv(env) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const addressBookForVerify: any = getAddressBookForType(spec.addressBookType, chainIdForVerify) + if (addressBookForVerify.entryExists(spec.name)) { + const { codeChanged, localHash } = checkCodeChanged(spec.artifact!, addressBookForVerify, spec.name) + artifactVerified = !codeChanged && !!localHash + canVerify = true + } + } + if (!existing) { - // No existing record - create from artifact - let abi: readonly unknown[] = [] - let bytecode: `0x${string}` = '0x' - let deployedBytecode: `0x${string}` | undefined - if (spec.artifact) { - const artifact = loadArtifactFromSource(spec.artifact) - if (artifact?.abi) { - abi = artifact.abi - } - if (artifact?.bytecode) { - bytecode = artifact.bytecode as `0x${string}` - } - if (artifact?.deployedBytecode) { - deployedBytecode = artifact.deployedBytecode as `0x${string}` + if (!canVerify || artifactVerified) { + // Either no artifact to compare (legacy/external entry) or hash verified — + // safe to seed rocketh from the artifact. + let abi: readonly unknown[] = [] + let bytecode: `0x${string}` = '0x' + let deployedBytecode: `0x${string}` | undefined + if (spec.artifact) { + const artifact = loadArtifactFromSource(spec.artifact) + if (artifact?.abi) { + abi = artifact.abi + } + if (artifact?.bytecode) { + bytecode = artifact.bytecode as `0x${string}` + } + if (artifact?.deployedBytecode) { + deployedBytecode = artifact.deployedBytecode as `0x${string}` + } } + await env.save(spec.name, { + address: spec.address as `0x${string}`, + abi: abi as typeof abi & readonly unknown[], + bytecode, + deployedBytecode, + argsData: (spec.deploymentArgsData ?? '0x') as `0x${string}`, + metadata: '', + } as unknown as Parameters[1]) + } else { + // Cannot verify artifact matches what's on-chain — leave the rocketh + // record absent so the next deployFn detects no prior bytecode and + // deploys fresh. Seeding from a stale or new artifact would mask the + // drift: rocketh would compare new artifact to itself and skip redeploy. + statusNotes.push('seed skipped (artifact unverified)') } - await env.save(spec.name, { - address: spec.address as `0x${string}`, - abi: abi as typeof abi & readonly unknown[], - bytecode, - deployedBytecode, - argsData: (spec.deploymentArgsData ?? '0x') as `0x${string}`, - metadata: '', - } as unknown as Parameters[1]) } else if (addressChanged) { // Address changed - update address but preserve existing bytecode let abi: readonly unknown[] = existing.abi as readonly unknown[] From 26c13c84da1227f46bc47700c1a838fa72b9927e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:25:03 +0000 Subject: [PATCH 129/157] test(deployment): cover shouldSeedRocketh gate truth table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract the inline gate from syncContract's non-proxy seed path into a pure shouldSeedRocketh helper and pin its truth table. The helper already had three known failure modes during this fix's development: it had to let unregistered synthetic names through (proxy sync recurses with `${name}_Implementation` names), let prerequisites through (L2GraphToken-style external deployments), and skip the seed only on a *verified* mismatch — not whenever any signal is missing. Each of those is a regression test: getting the gate wrong on any of them broke a real deploy run. --- packages/deployment/lib/sync-utils.ts | 82 +++++++----- .../test/should-seed-rocketh.test.ts | 126 ++++++++++++++++++ 2 files changed, 178 insertions(+), 30 deletions(-) create mode 100644 packages/deployment/test/should-seed-rocketh.test.ts diff --git a/packages/deployment/lib/sync-utils.ts b/packages/deployment/lib/sync-utils.ts index 83695957a..a5022a177 100644 --- a/packages/deployment/lib/sync-utils.ts +++ b/packages/deployment/lib/sync-utils.ts @@ -277,6 +277,50 @@ function checkCodeChanged( return { codeChanged: false, localHash } } +/** + * Decide whether sync should seed rocketh's record from the local artifact. + * + * Seeding writes the local artifact's bytecode into rocketh's deployment + * record. That's correct when the artifact reflects what's deployed on-chain, + * and harmful when the artifact has drifted: rocketh's native bytecode + * comparison would then match its (just-seeded) record against the artifact + * and skip the redeploy that the drift demands — the address book never + * advances, and proxies that depend on the impl miss their pendingImplementation. + * + * Gate (only contracts we ourselves deploy carry the dedup-masking risk): + * - Synthetic names not in the registry → seed (proxy sync recurses with + * `${name}_Implementation` names that aren't real entries; the proxy path + * already has its own hashMatches gate before recursing). + * - Prerequisites → seed (deployed externally; never run through deployFn). + * - No artifact → seed (no local bytecode to compare against). + * + * Within the gated set: skip the seed only on a *verified mismatch* — i.e. + * we have a stored hash and the local artifact's hash differs. If there's no + * stored hash at all (no entry, or entry without a hash), fall through to + * the legacy seed: there's nothing to mask. + */ +export function shouldSeedRocketh( + spec: ContractSpec, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + addressBook: any, +): { seed: boolean; reason: string } { + const registered = getContractMetadata(spec.addressBookType, spec.name) + if (!registered) return { seed: true, reason: 'unregistered name (legacy seed)' } + if (spec.prerequisite) return { seed: true, reason: 'prerequisite (legacy seed)' } + if (!spec.artifact) return { seed: true, reason: 'no artifact (legacy seed)' } + + if (!addressBook?.entryExists?.(spec.name)) { + return { seed: true, reason: 'no entry, nothing to mask (legacy seed)' } + } + + const storedHash = addressBook.getDeploymentMetadata?.(spec.name)?.bytecodeHash + const { codeChanged, localHash } = checkCodeChanged(spec.artifact, addressBook, spec.name) + + if (!storedHash || !localHash) return { seed: true, reason: 'no hash to compare (legacy seed)' } + if (codeChanged) return { seed: false, reason: 'artifact unverified vs. address book' } + return { seed: true, reason: 'artifact verified' } +} + /** * Proxy admin ownership state */ @@ -824,37 +868,15 @@ export async function syncContract( statusNotes.push('re-imported') } - // Verify the local artifact reflects what was last deployed before seeding - // rocketh from it. The address-book stored bytecodeHash is recorded at deploy - // time, so a local-to-stored hash match is our proxy for "artifact == on-chain". - // When verification fails for a contract we deploy, skip the seed: leaving - // rocketh's record absent lets deployFn deploy fresh rather than masking a - // drift between artifact and on-chain bytecode. - // - // Scope of the gate: - // - Only registered registry names — proxy sync recurses with synthetic names - // like `${proxyName}_Implementation` that aren't real address-book entries; - // the proxy path has already gated on hashMatches before recursing. - // - Only non-prerequisites — prerequisites (e.g. L2GraphToken) are deployed - // externally; we never call deployFn on them, so the dedup-masking concern - // doesn't apply and we still need them in env for downstream reads. - const registeredForVerify = getContractMetadata(spec.addressBookType, spec.name) - const gateApplies = !!registeredForVerify && !spec.prerequisite && !!spec.artifact - let artifactVerified = false - let canVerify = false - if (gateApplies) { - const chainIdForVerify = await getTargetChainIdFromEnv(env) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const addressBookForVerify: any = getAddressBookForType(spec.addressBookType, chainIdForVerify) - if (addressBookForVerify.entryExists(spec.name)) { - const { codeChanged, localHash } = checkCodeChanged(spec.artifact!, addressBookForVerify, spec.name) - artifactVerified = !codeChanged && !!localHash - canVerify = true - } - } + // Decide whether to seed rocketh's record from the local artifact (see + // `shouldSeedRocketh` for the rationale and gate). + const chainIdForVerify = await getTargetChainIdFromEnv(env) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const addressBookForVerify: any = getAddressBookForType(spec.addressBookType, chainIdForVerify) + const seedDecision = shouldSeedRocketh(spec, addressBookForVerify) if (!existing) { - if (!canVerify || artifactVerified) { + if (seedDecision.seed) { // Either no artifact to compare (legacy/external entry) or hash verified — // safe to seed rocketh from the artifact. let abi: readonly unknown[] = [] @@ -885,7 +907,7 @@ export async function syncContract( // record absent so the next deployFn detects no prior bytecode and // deploys fresh. Seeding from a stale or new artifact would mask the // drift: rocketh would compare new artifact to itself and skip redeploy. - statusNotes.push('seed skipped (artifact unverified)') + statusNotes.push(`seed skipped (${seedDecision.reason})`) } } else if (addressChanged) { // Address changed - update address but preserve existing bytecode diff --git a/packages/deployment/test/should-seed-rocketh.test.ts b/packages/deployment/test/should-seed-rocketh.test.ts new file mode 100644 index 000000000..a982d02e0 --- /dev/null +++ b/packages/deployment/test/should-seed-rocketh.test.ts @@ -0,0 +1,126 @@ +import { expect } from 'chai' + +import { getLibraryResolver, loadDirectAllocationArtifact } from '../lib/artifact-loaders.js' +import { computeBytecodeHash } from '../lib/bytecode-utils.js' +import { Contracts } from '../lib/contract-registry.js' +import { type ContractSpec, shouldSeedRocketh } from '../lib/sync-utils.js' + +/** + * shouldSeedRocketh — gate that decides whether sync should write rocketh's + * deployment record from the local artifact. + * + * The gate exists to prevent a silent failure mode: seeding rocketh from a + * stale local artifact masks rocketh's bytecode-change detection on the next + * deployFn call (it ends up comparing the new artifact to itself), so the + * impl never gets redeployed and dependent proxies never receive a pending + * implementation. Concretely, this caused shared-impl proxies (DefaultAllocation, + * ReclaimedRewards) to get stuck on stale code with no upgrade triggered. + * + * The rules below are the truth table that pins the gate against future + * regressions of any of those failure modes. + */ + +const sharedImpl = Contracts.issuance.DirectAllocation_Implementation + +function specForSharedImpl(overrides: Partial = {}): ContractSpec { + return { + name: sharedImpl.name, + addressBookType: 'issuance', + address: '0x0000000000000000000000000000000000000aaa', + prerequisite: false, + artifact: sharedImpl.artifact, + ...overrides, + } +} + +function localArtifactHash(): string { + const artifact = loadDirectAllocationArtifact() + return computeBytecodeHash( + artifact.deployedBytecode ?? '0x', + artifact.deployedLinkReferences, + getLibraryResolver('issuance'), + ) +} + +describe('shouldSeedRocketh', () => { + it('seeds when name is unregistered (proxy-recursion synthetic name passthrough)', () => { + // Regression: my first attempt of this gate broke RewardsManager sync because + // the proxy path recurses with `${name}_Implementation` synthetic names that + // aren't real registry entries. The gate must let those fall through. + const spec = specForSharedImpl({ name: 'RewardsManager_Implementation' }) + const result = shouldSeedRocketh(spec, {}) + expect(result.seed).to.be.true + expect(result.reason).to.match(/unregistered/) + }) + + it('seeds when contract is a prerequisite (e.g. L2GraphToken passthrough)', () => { + // Regression: prerequisites are deployed externally and never run through + // deployFn, so dedup-masking doesn't apply. They still need an env record + // for downstream reads. Skipping the seed broke L2GraphToken. + const spec = specForSharedImpl({ prerequisite: true }) + const result = shouldSeedRocketh(spec, {}) + expect(result.seed).to.be.true + expect(result.reason).to.match(/prerequisite/) + }) + + it('seeds when no artifact is configured (legacy entries with no comparison possible)', () => { + const spec = specForSharedImpl({ artifact: undefined }) + const result = shouldSeedRocketh(spec, {}) + expect(result.seed).to.be.true + expect(result.reason).to.match(/no artifact/) + }) + + it('seeds when address-book has no entry (nothing to mask)', () => { + const spec = specForSharedImpl() + const addressBook = { entryExists: () => false } + const result = shouldSeedRocketh(spec, addressBook) + expect(result.seed).to.be.true + expect(result.reason).to.match(/no entry/) + }) + + it('seeds when entry exists but has no stored bytecodeHash', () => { + const spec = specForSharedImpl() + const addressBook = { + entryExists: () => true, + getDeploymentMetadata: () => undefined, + } + const result = shouldSeedRocketh(spec, addressBook) + expect(result.seed).to.be.true + expect(result.reason).to.match(/no hash/) + }) + + it('seeds when stored hash matches local artifact hash (artifact verified)', () => { + const spec = specForSharedImpl() + const addressBook = { + entryExists: () => true, + getDeploymentMetadata: () => ({ + bytecodeHash: localArtifactHash(), + txHash: '', + argsData: '0x', + }), + } + const result = shouldSeedRocketh(spec, addressBook) + expect(result.seed).to.be.true + expect(result.reason).to.match(/verified/) + }) + + it('skips seed when stored hash does not match local artifact hash', () => { + // The core bug. Without this skip, sync seeds rocketh with the local + // artifact bytecode; rocketh then sees its own seeded bytecode == artifact + // and reports newlyDeployed=false on the next deployFn — masking the drift + // and stranding any proxy that depends on this impl with code-changed but + // no pendingImplementation. + const spec = specForSharedImpl() + const addressBook = { + entryExists: () => true, + getDeploymentMetadata: () => ({ + bytecodeHash: '0xstalehashfromearlierdeployment', + txHash: '', + argsData: '0x', + }), + } + const result = shouldSeedRocketh(spec, addressBook) + expect(result.seed).to.be.false + expect(result.reason).to.match(/unverified/) + }) +}) From 95965d62428cd512e3795632cf2f733796693d7b Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 24 Apr 2026 18:43:58 +0000 Subject: [PATCH 130/157] ci(publish): add interfaces/toolshed, dry-run, and release tagging Consolidates publish.yml improvements (address-book choice, Read package info, Tag release) from reo-deployment branches plus new interfaces and toolshed package choices and a dry_run boolean input so auth/packaging can be verified without burning a version. --- .github/workflows/publish.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2348142fd..8293bf6d9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,12 +10,19 @@ on: options: - address-book - contracts + - interfaces - sdk + - toolshed tag: description: 'Tag to publish' required: true type: string default: latest + dry_run: + description: 'Dry-run (validate only, no publish or git tag)' + required: false + type: boolean + default: false jobs: publish: @@ -41,8 +48,9 @@ jobs: shell: bash run: | pushd packages/${{ inputs.package }} - pnpm publish --tag ${{ inputs.tag }} --access public --no-git-checks + pnpm publish --tag ${{ inputs.tag }} --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || '' }} - name: Tag release + if: ${{ !inputs.dry_run }} run: | git tag ${{ steps.pkg.outputs.tag }} git push origin ${{ steps.pkg.outputs.tag }} From 2b542068e8b5067ecc63b23018e46e1e984a6a12 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 24 Apr 2026 19:36:23 +0000 Subject: [PATCH 131/157] ci(publish): switch to OIDC trusted publishing Replace GRAPHPROTOCOL_NPM_TOKEN with GitHub OIDC (id-token: write) and pnpm --provenance so the workflow mints a short-lived credential and attaches a SLSA build attestation. Each target package needs its own Trusted Publisher entry on npmjs.com (owner: graphprotocol, repo: contracts, workflow: publish.yml); verify per-package via a dry_run dispatch before a real publish. Pattern follows graphprotocol/graph-node#6460. contents: write is retained so the existing Tag release step can push the annotated tag. --- .github/workflows/publish.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8293bf6d9..16fcf402d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,6 +28,9 @@ jobs: publish: name: Publish package runs-on: ubuntu-latest + permissions: + id-token: write + contents: write steps: - name: Checkout uses: actions/checkout@v4 @@ -35,8 +38,6 @@ jobs: submodules: recursive - name: Set up environment uses: ./.github/actions/setup - - name: Set npm token for publishing - run: pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.GRAPHPROTOCOL_NPM_TOKEN }} - name: Read package info id: pkg shell: bash @@ -48,7 +49,7 @@ jobs: shell: bash run: | pushd packages/${{ inputs.package }} - pnpm publish --tag ${{ inputs.tag }} --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || '' }} + pnpm publish --provenance --tag ${{ inputs.tag }} --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || '' }} - name: Tag release if: ${{ !inputs.dry_run }} run: | From 41360349a1509bd58c671239682ad9700029a654 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 24 Apr 2026 19:50:36 +0000 Subject: [PATCH 132/157] ci(publish): upgrade npm before OIDC publish for trusted-publisher auth pnpm publish delegates registry auth to the underlying npm CLI, which needs to be >= 11.5.1 to exchange the GitHub OIDC token for an npm publish credential. The shared setup action brings Node 22 which ships an older npm; install the latest npm globally in the publish job before pnpm publish runs. Pattern follows eslint/config-inspector#174. --- .github/workflows/publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 16fcf402d..7ac494227 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,6 +38,10 @@ jobs: submodules: recursive - name: Set up environment uses: ./.github/actions/setup + - name: Upgrade npm for OIDC trusted publishing + # pnpm publish delegates registry auth to the underlying npm CLI; + # npm >= 11.5.1 is required to support OIDC trusted publishing. + run: npm install -g npm@latest - name: Read package info id: pkg shell: bash From 248c0004d44600223fdc08061797fbdd26135ddd Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 24 Apr 2026 20:12:45 +0000 Subject: [PATCH 133/157] ci(setup): bump pnpm from 10.17.0 to 10.28.0 to match packageManager The repo's root package.json declares pnpm@10.28.0 as the packageManager, but the shared setup action's corepack prepare step pinned the older 10.17.0. Resolve the drift by matching the declared version. Minor-version bump within pnpm 10.x; affects lint, build-test, verifydeployed, and publish workflows that share this setup. --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 301183cba..5d80603c5 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,7 +21,7 @@ runs: cache: 'pnpm' - name: Set up pnpm via Corepack shell: bash - run: corepack prepare pnpm@10.17.0 --activate + run: corepack prepare pnpm@10.28.0 --activate - name: Install dependencies shell: bash run: pnpm install --frozen-lockfile From 4e0262a9b45a35e87fbe38a272f5f79a6693ae81 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Sat, 25 Apr 2026 11:31:59 +0000 Subject: [PATCH 134/157] ci(publish): pin npm to 11.13.0 instead of latest Reproducibility: pinning avoids surprise behavior changes or Node engine bumps from a future npm "latest". Bump the pin intentionally; only constraint is npm >= 11.5.1 for OIDC trusted publishing. --- .github/workflows/publish.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7ac494227..fb85a42a9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,9 +39,10 @@ jobs: - name: Set up environment uses: ./.github/actions/setup - name: Upgrade npm for OIDC trusted publishing - # pnpm publish delegates registry auth to the underlying npm CLI; - # npm >= 11.5.1 is required to support OIDC trusted publishing. - run: npm install -g npm@latest + # pnpm publish delegates registry auth to the underlying npm CLI. + # OIDC trusted publishing requires npm >= 11.5.1; pinned to a known-good + # version for reproducibility — safe to bump as long as it stays >= 11.5.1. + run: npm install -g npm@11.13.0 - name: Read package info id: pkg shell: bash From af3acd7a191cc31ca129b4d1886b44681d5409da Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:16:41 +0000 Subject: [PATCH 135/157] ci: bump actions to latest stable and switch to Node 24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - actions/setup-node: v4 → v6, node-version 22 → 24 - actions/checkout: v3/v4 → v6 - actions/upload-artifact: v3 → v7 (v3 was sunset by GitHub) - actions/download-artifact: v3 → v8 (v3 was sunset by GitHub) - actions/github-script: v7 → v9 - codecov/codecov-action: v3 → v6 - Add description: field to setup composite action (schema) Fixes the npm install -g npm@11.13.0 cross-major self-upgrade crash seen on Node 22 — Node 24 ships npm 11.x, so this is now an 11→11 swap. Also clears the Node 20 runtime deprecation warning on JS actions. cache: 'pnpm' on setup-node@v6 verified: v6's "limit automatic caching to npm" change only affects auto-detection when cache is unset; explicit cache: 'pnpm' is unaffected. --- .github/actions/setup/action.yml | 5 +++-- .github/workflows/build-test.yml | 4 ++-- .github/workflows/lint.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/require-audit-label.yml | 2 +- .github/workflows/verifydeployed.yml | 8 ++++---- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 5d80603c5..caff8b6c8 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,4 +1,5 @@ name: Setup +description: Install system deps, Foundry, Node.js, pnpm, and the workspace's dependencies. runs: using: composite @@ -15,9 +16,9 @@ runs: shell: bash run: corepack enable - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 22 + node-version: 24 cache: 'pnpm' - name: Set up pnpm via Corepack shell: bash diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b57c6e0e4..bc35bc4f2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive @@ -40,7 +40,7 @@ jobs: - name: Upload coverage reports if: steps.coverage_files.outputs.files != '' - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} files: ${{ steps.coverage_files.outputs.files }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d9828f1e4..729e38f6c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 # Needed to get all history for comparing changes diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fb85a42a9..9bc5548cf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,7 +33,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Set up environment diff --git a/.github/workflows/require-audit-label.yml b/.github/workflows/require-audit-label.yml index 6b93738b5..826c229ad 100644 --- a/.github/workflows/require-audit-label.yml +++ b/.github/workflows/require-audit-label.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Get changed files id: changed - uses: actions/github-script@v7 + uses: actions/github-script@v9 with: script: | const { data: files } = await github.rest.pulls.listFiles({ diff --git a/.github/workflows/verifydeployed.yml b/.github/workflows/verifydeployed.yml index ba682fc21..d61ecd95a 100644 --- a/.github/workflows/verifydeployed.yml +++ b/.github/workflows/verifydeployed.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 with: submodules: recursive - name: Set up environment @@ -36,7 +36,7 @@ jobs: pnpm build - name: Save build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v7 with: name: contract-artifacts path: | @@ -49,7 +49,7 @@ jobs: needs: build steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set up environment uses: ./.github/actions/setup - name: Build @@ -57,7 +57,7 @@ jobs: pushd packages/contracts pnpm build || pnpm build - name: Get build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v8 with: name: contract-artifacts From 5affcc40bddab7f9fa5b22eee8888c9eda6e3526 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:20:30 +0000 Subject: [PATCH 136/157] ci(publish): drop explicit npm upgrade step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node 24 ships npm 11.x bundled (24.15.0 → npm 11.12.1), which already satisfies the OIDC trusted-publishing requirement of npm >= 11.5.1. The explicit `npm install -g npm@11.13.0` step was a Node 22 workaround and is now redundant. Pinning the Node version effectively pins npm; if stricter pinning is ever needed it can be reintroduced. --- .github/workflows/publish.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9bc5548cf..e9d0a89eb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,11 +38,6 @@ jobs: submodules: recursive - name: Set up environment uses: ./.github/actions/setup - - name: Upgrade npm for OIDC trusted publishing - # pnpm publish delegates registry auth to the underlying npm CLI. - # OIDC trusted publishing requires npm >= 11.5.1; pinned to a known-good - # version for reproducibility — safe to bump as long as it stays >= 11.5.1. - run: npm install -g npm@11.13.0 - name: Read package info id: pkg shell: bash From ee558054b1f920b27dfd54d5f147fa5c4f5c3de2 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 07:26:30 +0000 Subject: [PATCH 137/157] chore(interfaces): bump to 0.7.0-test.0 for trusted-publishing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump from 0.6.6 → 0.7.0-test.0 to validate the OIDC trusted-publishing flow end-to-end. Prerelease tag (-test.0) keeps it off the latest dist-tag and makes it easy to discard if the test reveals issues. Real 0.7.0 release will follow once trusted publishing is verified; 0.6.6 → 0.7.0 reflects the breaking changes accumulated since 0.6.6 (deleted IDataServiceFees/Rescuable/IHorizonStakingExtension, renamed IRewardsEligibility → IProviderEligibility, reworked IRewardsManager). --- packages/interfaces/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index afcd157f4..64e99da55 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/interfaces", - "version": "0.6.6", + "version": "0.7.0-test.0", "publishConfig": { "access": "public" }, From a61ed9a129e07a189730d7a180fec70b92aac20c Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 07:54:02 +0000 Subject: [PATCH 138/157] chore(interfaces): add repository field for npm provenance verification npm's trusted-publishing flow cross-checks package.json's repository.url against the source repo recorded in the Sigstore provenance attestation. Without this field, publish fails at the registry side after provenance has already been signed: Failed to validate repository information: package.json: "repository.url" is "", expected to match "https://github.com/graphprotocol/contracts" from provenance Mirrors the shape used in @graphprotocol/contracts; adds directory for proper monorepo source linking. --- packages/interfaces/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 64e99da55..04bbcee2c 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -5,6 +5,11 @@ "access": "public" }, "description": "Contract interfaces for The Graph protocol", + "repository": { + "type": "git", + "url": "git+https://github.com/graphprotocol/contracts", + "directory": "packages/interfaces" + }, "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", "exports": { From d29ea286e1ca527eabc746da6388d427d608bb9a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:03:44 +0000 Subject: [PATCH 139/157] chore: pin Node via .nvmrc and engines, switch CI to node-version-file Single source of truth for the Node version. Local fnm reads .nvmrc and auto-switches; CI setup-node reads the same file via node-version-file. Corepack picks pnpm from the packageManager field, so the explicit `corepack prepare pnpm@X.Y.Z --activate` step is no longer needed. - Add .nvmrc (24) - Add .npmrc (engine-strict=true) so pnpm refuses wrong Node/pnpm - package.json: add engines (node ^24, pnpm ^10.28) - .github/actions/setup/action.yml: switch to node-version-file: '.nvmrc', drop the redundant Corepack prepare step --- .github/actions/setup/action.yml | 5 +---- .npmrc | 1 + .nvmrc | 1 + package.json | 4 ++++ 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .npmrc create mode 100644 .nvmrc diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index caff8b6c8..5a7def0ac 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -18,11 +18,8 @@ runs: - name: Install Node.js uses: actions/setup-node@v6 with: - node-version: 24 + node-version-file: '.nvmrc' cache: 'pnpm' - - name: Set up pnpm via Corepack - shell: bash - run: corepack prepare pnpm@10.28.0 --activate - name: Install dependencies shell: bash run: pnpm install --frozen-lockfile diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..b6f27f135 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..a45fd52cc --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/package.json b/package.json index 1c6e12e86..a6615fed9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "repository": "git@github.com:graphprotocol/contracts.git", "author": "Edge & Node", "packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48", + "engines": { + "node": "^24", + "pnpm": "^10.28" + }, "scripts": { "postinstall": "husky", "clean": "pnpm -r run clean", From d2fd16af90b26fd1f30352151eec020bf884a303 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:49:43 +0000 Subject: [PATCH 140/157] chore(interfaces): bump to 0.7.1-dips.0 for audit-fix-2 dips publish --- packages/interfaces/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 04bbcee2c..a25e678a1 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/interfaces", - "version": "0.7.0-test.0", + "version": "0.7.1-dips.0", "publishConfig": { "access": "public" }, From feac96762d307b48a716c16da4665b401b94debf Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:51:50 +0000 Subject: [PATCH 141/157] chore(toolshed): bump to 1.2.1-dips.0 for audit-fix-2 dips publish --- packages/toolshed/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolshed/package.json b/packages/toolshed/package.json index d0ad9a152..ba2f541f1 100644 --- a/packages/toolshed/package.json +++ b/packages/toolshed/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/toolshed", - "version": "1.1.2", + "version": "1.2.1-dips.0", "publishConfig": { "access": "public" }, From c8ca9ebf572846a441d97489b6e0b757e494b9a6 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:23:02 +0000 Subject: [PATCH 142/157] chore(toolshed): add repository field for npm provenance verification npm's trusted-publishing flow cross-checks package.json's repository.url against the source repo recorded in the Sigstore provenance attestation. Without this field, publish fails at the registry side after provenance has already been signed: Failed to validate repository information: package.json: "repository.url" is "", expected to match "https://github.com/graphprotocol/contracts" from provenance Mirrors the shape applied to @graphprotocol/interfaces in a61ed9a12; adds directory for proper monorepo source linking. --- packages/toolshed/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/toolshed/package.json b/packages/toolshed/package.json index ba2f541f1..ad88d8cfb 100644 --- a/packages/toolshed/package.json +++ b/packages/toolshed/package.json @@ -7,6 +7,11 @@ "description": "A collection of tools and utilities for the Graph Protocol Typescript components", "author": "Tomás Migone ", "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/graphprotocol/contracts", + "directory": "packages/toolshed" + }, "main": "./dist/core/index.js", "types": "./dist/core/index.d.ts", "exports": { From 99575aa25d6246a4e16f49f18502812d2e14702e Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:50:27 +0000 Subject: [PATCH 143/157] chore(address-book): add repository field for npm provenance verification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors the fix applied to interfaces (a61ed9a12) and toolshed (9ba6366a3). Without this field, OIDC trusted-publishing will fail at the registry's provenance verification step: Failed to validate repository information: package.json: "repository.url" is "", expected to match "https://github.com/graphprotocol/contracts" from provenance Preemptive — address-book has not been republished since the OIDC switch, but the workflow lists it as a choice. --- packages/address-book/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/address-book/package.json b/packages/address-book/package.json index 471e51052..152071cff 100644 --- a/packages/address-book/package.json +++ b/packages/address-book/package.json @@ -7,6 +7,11 @@ "description": "Contract addresses for The Graph Protocol", "author": "Edge & Node", "license": "GPL-2.0-or-later", + "repository": { + "type": "git", + "url": "git+https://github.com/graphprotocol/contracts", + "directory": "packages/address-book" + }, "exports": { "./horizon/addresses.json": "./src/horizon/addresses.json", "./issuance/addresses.json": "./src/issuance/addresses.json", From b38c5c01a52678dba972f22932bad72598a4a6e9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:50:46 +0000 Subject: [PATCH 144/157] ci(publish): drop sdk from package choices @graphprotocol/sdk was extracted to its own repo in 32ef00ca6 ("chore: move sdk to own repo, update versions"); packages/sdk/ no longer exists in this monorepo. Dispatching package=sdk would fail at the Read package info step trying to require a non-existent package.json. --- .github/workflows/publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e9d0a89eb..b4ac50dfa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,6 @@ on: - address-book - contracts - interfaces - - sdk - toolshed tag: description: 'Tag to publish' From 41816a35a37abd53281287ad6d8ccb4de13e5e81 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:51:09 +0000 Subject: [PATCH 145/157] chore(contracts): normalize repository field for npm provenance + monorepo source linking Drop the .git suffix from repository.url and add directory: packages/contracts to match the shape used in interfaces (a61ed9a12), toolshed (9ba6366a3), and address-book (c3e219ba1). The .git suffix is normalized away by npm's provenance verification, so the previous shape would likely have worked, but this keeps the four publishable packages consistent and gives npmjs.com a correct subfolder link. --- packages/contracts/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/contracts/package.json b/packages/contracts/package.json index c9b002afb..a7a4933c8 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -8,7 +8,8 @@ "main": "index.js", "repository": { "type": "git", - "url": "git+https://github.com/graphprotocol/contracts.git" + "url": "git+https://github.com/graphprotocol/contracts", + "directory": "packages/contracts" }, "author": "Edge & Node", "license": "GPL-2.0-or-later", From 4e8cfa6482c6e167219c9a4d3bb5f7ddbe70ba72 Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Wed, 25 Feb 2026 16:34:02 -0300 Subject: [PATCH 146/157] feat: add RecurringCollector type and DIPs helpers to toolshed - Add IRecurringCollector to GraphHorizonContracts interface - Re-export IRecurringCollector from interfaces main entrypoint - Add encodeCollectIndexingFeesData() helper for indexing fee collection - Add decoders: decodeSignedRCA, decodeAcceptIndexingAgreementMetadata, decodeIndexingAgreementTermsV1 - Add round-trip tests for all decoders and encoder --- packages/interfaces/src/types/horizon.ts | 1 + packages/toolshed/src/core/index.ts | 1 + .../toolshed/src/core/recurring-collector.ts | 83 +++++++++ .../toolshed/src/core/subgraph-service.ts | 15 ++ .../toolshed/test/recurring-collector.test.ts | 176 ++++++++++++++++++ packages/toolshed/tsconfig.json | 3 +- 6 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 packages/toolshed/src/core/recurring-collector.ts create mode 100644 packages/toolshed/test/recurring-collector.test.ts diff --git a/packages/interfaces/src/types/horizon.ts b/packages/interfaces/src/types/horizon.ts index 7bd9ca1db..dd93f99a2 100644 --- a/packages/interfaces/src/types/horizon.ts +++ b/packages/interfaces/src/types/horizon.ts @@ -31,5 +31,6 @@ export { IPaymentsEscrowToolshed as PaymentsEscrow, IRecurringCollector as RecurringCollector, IRewardsManagerToolshed as RewardsManager, + IRecurringCollector, ISubgraphNFT as SubgraphNFT, } diff --git a/packages/toolshed/src/core/index.ts b/packages/toolshed/src/core/index.ts index 3934ed378..7dbbb79ba 100644 --- a/packages/toolshed/src/core/index.ts +++ b/packages/toolshed/src/core/index.ts @@ -6,5 +6,6 @@ export * from './custom-errors' export * from './disputes' export * from './graph-tally' export * from './poi' +export * from './recurring-collector' export * from './subgraph-service' export * from './types' diff --git a/packages/toolshed/src/core/recurring-collector.ts b/packages/toolshed/src/core/recurring-collector.ts new file mode 100644 index 000000000..9ddf5af98 --- /dev/null +++ b/packages/toolshed/src/core/recurring-collector.ts @@ -0,0 +1,83 @@ +import { BytesLike, ethers } from 'ethers' + +// -- ABI tuple types for decoding -- + +const RCA_TUPLE = + 'tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata)' + +const SIGNED_RCA_TUPLE = `tuple(${RCA_TUPLE} rca, bytes signature)` + +const ACCEPT_METADATA_TUPLE = 'tuple(bytes32 subgraphDeploymentId, uint8 version, bytes terms)' + +const TERMS_V1_TUPLE = 'tuple(uint256 tokensPerSecond, uint256 tokensPerEntityPerSecond)' + +// -- Return types -- + +export interface RecurringCollectionAgreement { + deadline: bigint + endsAt: bigint + payer: string + dataService: string + serviceProvider: string + maxInitialTokens: bigint + maxOngoingTokensPerSecond: bigint + minSecondsPerCollection: bigint + maxSecondsPerCollection: bigint + nonce: bigint + metadata: string +} + +export interface SignedRCA { + rca: RecurringCollectionAgreement + signature: string +} + +export interface AcceptIndexingAgreementMetadata { + subgraphDeploymentId: string + version: bigint + terms: string +} + +export interface IndexingAgreementTermsV1 { + tokensPerSecond: bigint + tokensPerEntityPerSecond: bigint +} + +// -- Decoders -- + +export function decodeSignedRCA(data: BytesLike): SignedRCA { + const [decoded] = ethers.AbiCoder.defaultAbiCoder().decode([SIGNED_RCA_TUPLE], data) + return { + rca: { + deadline: decoded.rca.deadline, + endsAt: decoded.rca.endsAt, + payer: decoded.rca.payer, + dataService: decoded.rca.dataService, + serviceProvider: decoded.rca.serviceProvider, + maxInitialTokens: decoded.rca.maxInitialTokens, + maxOngoingTokensPerSecond: decoded.rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: decoded.rca.minSecondsPerCollection, + maxSecondsPerCollection: decoded.rca.maxSecondsPerCollection, + nonce: decoded.rca.nonce, + metadata: decoded.rca.metadata, + }, + signature: decoded.signature, + } +} + +export function decodeAcceptIndexingAgreementMetadata(data: BytesLike): AcceptIndexingAgreementMetadata { + const [decoded] = ethers.AbiCoder.defaultAbiCoder().decode([ACCEPT_METADATA_TUPLE], data) + return { + subgraphDeploymentId: decoded.subgraphDeploymentId, + version: decoded.version, + terms: decoded.terms, + } +} + +export function decodeIndexingAgreementTermsV1(data: BytesLike): IndexingAgreementTermsV1 { + const [decoded] = ethers.AbiCoder.defaultAbiCoder().decode([TERMS_V1_TUPLE], data) + return { + tokensPerSecond: decoded.tokensPerSecond, + tokensPerEntityPerSecond: decoded.tokensPerEntityPerSecond, + } +} diff --git a/packages/toolshed/src/core/subgraph-service.ts b/packages/toolshed/src/core/subgraph-service.ts index b4301900f..03a7840d0 100644 --- a/packages/toolshed/src/core/subgraph-service.ts +++ b/packages/toolshed/src/core/subgraph-service.ts @@ -32,6 +32,21 @@ export function encodeCollectQueryFeesData(rav: RAV, signature: string, tokensTo ) } +export function encodeCollectIndexingFeesData( + agreementId: string, + entities: bigint, + poi: BytesLike, + poiBlockNumber: bigint, + metadata: BytesLike, + maxSlippage: bigint, +) { + const innerData = ethers.AbiCoder.defaultAbiCoder().encode( + ['uint256', 'bytes32', 'uint256', 'bytes', 'uint256'], + [entities, poi, poiBlockNumber, metadata, maxSlippage], + ) + return ethers.AbiCoder.defaultAbiCoder().encode(['bytes16', 'bytes'], [agreementId, innerData]) +} + export function encodeStopServiceData(allocationId: string) { return ethers.AbiCoder.defaultAbiCoder().encode(['address'], [allocationId]) } diff --git a/packages/toolshed/test/recurring-collector.test.ts b/packages/toolshed/test/recurring-collector.test.ts new file mode 100644 index 000000000..51c28b509 --- /dev/null +++ b/packages/toolshed/test/recurring-collector.test.ts @@ -0,0 +1,176 @@ +import assert from 'node:assert/strict' +import { ethers } from 'ethers' + +import { + decodeSignedRCA, + decodeAcceptIndexingAgreementMetadata, + decodeIndexingAgreementTermsV1, + encodeCollectIndexingFeesData, +} from '../dist/core/index.js' + +const coder = ethers.AbiCoder.defaultAbiCoder() + +// -- decodeSignedRCA round-trip -- + +{ + const rca = { + deadline: 1000000n, + endsAt: 2000000n, + payer: '0x1111111111111111111111111111111111111111', + dataService: '0x2222222222222222222222222222222222222222', + serviceProvider: '0x3333333333333333333333333333333333333333', + maxInitialTokens: 500n * 10n ** 18n, + maxOngoingTokensPerSecond: 1n * 10n ** 15n, + minSecondsPerCollection: 3600n, + maxSecondsPerCollection: 86400n, + nonce: 42n, + metadata: '0xdeadbeef', + } + const signature = '0x' + 'ab'.repeat(65) + + const encoded = coder.encode( + [ + 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata) rca, bytes signature)', + ], + [{ rca, signature }], + ) + + const decoded = decodeSignedRCA(encoded) + + assert.equal(decoded.rca.deadline, rca.deadline) + assert.equal(decoded.rca.endsAt, rca.endsAt) + assert.equal(decoded.rca.payer, rca.payer) + assert.equal(decoded.rca.dataService, rca.dataService) + assert.equal(decoded.rca.serviceProvider, rca.serviceProvider) + assert.equal(decoded.rca.maxInitialTokens, rca.maxInitialTokens) + assert.equal(decoded.rca.maxOngoingTokensPerSecond, rca.maxOngoingTokensPerSecond) + assert.equal(decoded.rca.minSecondsPerCollection, rca.minSecondsPerCollection) + assert.equal(decoded.rca.maxSecondsPerCollection, rca.maxSecondsPerCollection) + assert.equal(decoded.rca.nonce, rca.nonce) + assert.equal(decoded.rca.metadata, rca.metadata) + assert.equal(decoded.signature, signature) + console.log('PASS: decodeSignedRCA round-trip') +} + +// -- decodeSignedRCA with empty metadata -- + +{ + const rca = { + deadline: 100n, + endsAt: 200n, + payer: '0x' + '00'.repeat(20), + dataService: '0x' + '00'.repeat(20), + serviceProvider: '0x' + '00'.repeat(20), + maxInitialTokens: 0n, + maxOngoingTokensPerSecond: 0n, + minSecondsPerCollection: 0n, + maxSecondsPerCollection: 0n, + nonce: 0n, + metadata: '0x', + } + const signature = '0x' + + const encoded = coder.encode( + [ + 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata) rca, bytes signature)', + ], + [{ rca, signature }], + ) + + const decoded = decodeSignedRCA(encoded) + assert.equal(decoded.rca.metadata, '0x') + assert.equal(decoded.signature, '0x') + console.log('PASS: decodeSignedRCA with empty metadata') +} + +// -- decodeAcceptIndexingAgreementMetadata round-trip -- + +{ + const subgraphDeploymentId = ethers.id('my-subgraph') + const version = 0n // V1 = 0 in the enum + const terms = coder.encode(['uint256', 'uint256'], [1000n, 2000n]) + + const encoded = coder.encode( + ['tuple(bytes32 subgraphDeploymentId, uint8 version, bytes terms)'], + [{ subgraphDeploymentId, version, terms }], + ) + + const decoded = decodeAcceptIndexingAgreementMetadata(encoded) + + assert.equal(decoded.subgraphDeploymentId, subgraphDeploymentId) + assert.equal(decoded.version, version) + assert.equal(decoded.terms, terms) + console.log('PASS: decodeAcceptIndexingAgreementMetadata round-trip') +} + +// -- decodeAcceptIndexingAgreementMetadata with empty terms -- + +{ + const encoded = coder.encode( + ['tuple(bytes32 subgraphDeploymentId, uint8 version, bytes terms)'], + [{ subgraphDeploymentId: ethers.ZeroHash, version: 0, terms: '0x' }], + ) + + const decoded = decodeAcceptIndexingAgreementMetadata(encoded) + assert.equal(decoded.terms, '0x') + console.log('PASS: decodeAcceptIndexingAgreementMetadata with empty terms') +} + +// -- decodeAcceptIndexingAgreementMetadata with unknown version -- + +{ + const encoded = coder.encode( + ['tuple(bytes32 subgraphDeploymentId, uint8 version, bytes terms)'], + [{ subgraphDeploymentId: ethers.ZeroHash, version: 255, terms: '0x' }], + ) + + const decoded = decodeAcceptIndexingAgreementMetadata(encoded) + assert.equal(decoded.version, 255n) + console.log('PASS: decodeAcceptIndexingAgreementMetadata with unknown version') +} + +// -- decodeIndexingAgreementTermsV1 round-trip -- + +{ + const tokensPerSecond = 1000n * 10n ** 18n + const tokensPerEntityPerSecond = 5n * 10n ** 15n + + const encoded = coder.encode(['tuple(uint256 tokensPerSecond, uint256 tokensPerEntityPerSecond)'], [{ tokensPerSecond, tokensPerEntityPerSecond }]) + + const decoded = decodeIndexingAgreementTermsV1(encoded) + + assert.equal(decoded.tokensPerSecond, tokensPerSecond) + assert.equal(decoded.tokensPerEntityPerSecond, tokensPerEntityPerSecond) + console.log('PASS: decodeIndexingAgreementTermsV1 round-trip') +} + +// -- encodeCollectIndexingFeesData round-trip -- + +{ + const agreementId = '0x' + 'ab'.repeat(16) + const entities = 1000n + const poi = ethers.id('test-poi') + const poiBlockNumber = 12345n + const metadata = '0xdeadbeef' + const maxSlippage = 100n + + const encoded = encodeCollectIndexingFeesData(agreementId, entities, poi, poiBlockNumber, metadata, maxSlippage) + + // Decode outer: (bytes16, bytes) + const [decodedAgreementId, innerData] = coder.decode(['bytes16', 'bytes'], encoded) + assert.equal(decodedAgreementId, agreementId) + + // Decode inner: CollectIndexingFeeDataV1 + const [decodedEntities, decodedPoi, decodedPoiBlockNumber, decodedMetadata, decodedMaxSlippage] = coder.decode( + ['uint256', 'bytes32', 'uint256', 'bytes', 'uint256'], + innerData, + ) + assert.equal(decodedEntities, entities) + assert.equal(decodedPoi, poi) + assert.equal(decodedPoiBlockNumber, poiBlockNumber) + assert.equal(decodedMetadata, metadata) + assert.equal(decodedMaxSlippage, maxSlippage) + console.log('PASS: encodeCollectIndexingFeesData round-trip') +} + +console.log('\nAll tests passed.') diff --git a/packages/toolshed/tsconfig.json b/packages/toolshed/tsconfig.json index f6387508a..8d3b58663 100644 --- a/packages/toolshed/tsconfig.json +++ b/packages/toolshed/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "outDir": "dist" }, - "include": ["src/**/*.ts", "test/**/*.ts"] + "include": ["src/**/*.ts"], + "exclude": ["test/**/*.ts"] } From 4a77260733ccab4e09963f0bc3f10313d31fc03d Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Thu, 16 Apr 2026 18:13:38 +0100 Subject: [PATCH 147/157] fix(toolshed): add conditions field to RCA decoder tuple The audit-branch RecurringCollectionAgreement struct added a uint16 conditions field at position 9 (between maxSecondsPerCollection and nonce). The toolshed decoder tuple was missing it, so decodeSignedRCA read 10 fields against 11 ABI-encoded fields: nonce read what was actually conditions, metadata read the wrong offset, decode threw. The indexer-agent relies on this decoder to read pending RCA proposals the indexer-service persists. Without the fix, every proposal logs "Failed to decode pending RCA proposal" and is skipped, so the agent never calls acceptIndexingAgreement on-chain and DIPs agreements expire in dipper's DB. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/toolshed/src/core/recurring-collector.ts | 4 +++- packages/toolshed/test/recurring-collector.test.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/toolshed/src/core/recurring-collector.ts b/packages/toolshed/src/core/recurring-collector.ts index 9ddf5af98..9be27f44b 100644 --- a/packages/toolshed/src/core/recurring-collector.ts +++ b/packages/toolshed/src/core/recurring-collector.ts @@ -3,7 +3,7 @@ import { BytesLike, ethers } from 'ethers' // -- ABI tuple types for decoding -- const RCA_TUPLE = - 'tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata)' + 'tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint16 conditions, uint256 nonce, bytes metadata)' const SIGNED_RCA_TUPLE = `tuple(${RCA_TUPLE} rca, bytes signature)` @@ -23,6 +23,7 @@ export interface RecurringCollectionAgreement { maxOngoingTokensPerSecond: bigint minSecondsPerCollection: bigint maxSecondsPerCollection: bigint + conditions: bigint nonce: bigint metadata: string } @@ -58,6 +59,7 @@ export function decodeSignedRCA(data: BytesLike): SignedRCA { maxOngoingTokensPerSecond: decoded.rca.maxOngoingTokensPerSecond, minSecondsPerCollection: decoded.rca.minSecondsPerCollection, maxSecondsPerCollection: decoded.rca.maxSecondsPerCollection, + conditions: decoded.rca.conditions, nonce: decoded.rca.nonce, metadata: decoded.rca.metadata, }, diff --git a/packages/toolshed/test/recurring-collector.test.ts b/packages/toolshed/test/recurring-collector.test.ts index 51c28b509..1bbc9ceb5 100644 --- a/packages/toolshed/test/recurring-collector.test.ts +++ b/packages/toolshed/test/recurring-collector.test.ts @@ -23,6 +23,7 @@ const coder = ethers.AbiCoder.defaultAbiCoder() maxOngoingTokensPerSecond: 1n * 10n ** 15n, minSecondsPerCollection: 3600n, maxSecondsPerCollection: 86400n, + conditions: 0n, nonce: 42n, metadata: '0xdeadbeef', } @@ -30,7 +31,7 @@ const coder = ethers.AbiCoder.defaultAbiCoder() const encoded = coder.encode( [ - 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata) rca, bytes signature)', + 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint16 conditions, uint256 nonce, bytes metadata) rca, bytes signature)', ], [{ rca, signature }], ) @@ -46,6 +47,7 @@ const coder = ethers.AbiCoder.defaultAbiCoder() assert.equal(decoded.rca.maxOngoingTokensPerSecond, rca.maxOngoingTokensPerSecond) assert.equal(decoded.rca.minSecondsPerCollection, rca.minSecondsPerCollection) assert.equal(decoded.rca.maxSecondsPerCollection, rca.maxSecondsPerCollection) + assert.equal(decoded.rca.conditions, rca.conditions) assert.equal(decoded.rca.nonce, rca.nonce) assert.equal(decoded.rca.metadata, rca.metadata) assert.equal(decoded.signature, signature) @@ -65,6 +67,7 @@ const coder = ethers.AbiCoder.defaultAbiCoder() maxOngoingTokensPerSecond: 0n, minSecondsPerCollection: 0n, maxSecondsPerCollection: 0n, + conditions: 0n, nonce: 0n, metadata: '0x', } @@ -72,7 +75,7 @@ const coder = ethers.AbiCoder.defaultAbiCoder() const encoded = coder.encode( [ - 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint256 nonce, bytes metadata) rca, bytes signature)', + 'tuple(tuple(uint64 deadline, uint64 endsAt, address payer, address dataService, address serviceProvider, uint256 maxInitialTokens, uint256 maxOngoingTokensPerSecond, uint32 minSecondsPerCollection, uint32 maxSecondsPerCollection, uint16 conditions, uint256 nonce, bytes metadata) rca, bytes signature)', ], [{ rca, signature }], ) From bc895c6f3ead6bbe2dab87c44ec1495138caacae Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:28:59 +0000 Subject: [PATCH 148/157] chore(toolshed): bump to 1.2.1-dips.1 for recurring-collector decoders Re-publish needed because 1.2.1-dips.0 from audit-fix-2 was missing the recurring-collector module (decodeSignedRCA, decodeAcceptIndexingAgreementMetadata, decodeIndexingAgreementTermsV1, SignedRCA type). Cherry-picked from mb9/dips-local-testing-fixes: - 25c0b8825 feat: add RecurringCollector type and DIPs helpers to toolshed - 3e739a388 fix(toolshed): add conditions field to RCA decoder tuple These decoders are imported by indexer-common's pending-rca-consumer and types modules; without them indexer-agent's yarn prepare fails. --- packages/toolshed/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolshed/package.json b/packages/toolshed/package.json index ad88d8cfb..055d13936 100644 --- a/packages/toolshed/package.json +++ b/packages/toolshed/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/toolshed", - "version": "1.2.1-dips.0", + "version": "1.2.1-dips.1", "publishConfig": { "access": "public" }, From 9f826f358cf1744bb520ca998823e3e16c2c8270 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:31:57 +0000 Subject: [PATCH 149/157] chore: lint fixes --- packages/interfaces/src/types/horizon.ts | 2 +- packages/toolshed/test/recurring-collector.test.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/interfaces/src/types/horizon.ts b/packages/interfaces/src/types/horizon.ts index dd93f99a2..afed43e2c 100644 --- a/packages/interfaces/src/types/horizon.ts +++ b/packages/interfaces/src/types/horizon.ts @@ -23,6 +23,7 @@ export { IGraphProxyAdmin as GraphProxyAdmin, IGraphTallyCollectorToolshed as GraphTallyCollector, IHorizonStakingToolshed as HorizonStaking, + IRecurringCollector, IL2CurationToolshed as L2Curation, IL2GNSToolshed as L2GNS, IGraphToken as L2GraphToken, @@ -31,6 +32,5 @@ export { IPaymentsEscrowToolshed as PaymentsEscrow, IRecurringCollector as RecurringCollector, IRewardsManagerToolshed as RewardsManager, - IRecurringCollector, ISubgraphNFT as SubgraphNFT, } diff --git a/packages/toolshed/test/recurring-collector.test.ts b/packages/toolshed/test/recurring-collector.test.ts index 1bbc9ceb5..9a8e7efd7 100644 --- a/packages/toolshed/test/recurring-collector.test.ts +++ b/packages/toolshed/test/recurring-collector.test.ts @@ -1,10 +1,11 @@ import assert from 'node:assert/strict' + import { ethers } from 'ethers' import { - decodeSignedRCA, decodeAcceptIndexingAgreementMetadata, decodeIndexingAgreementTermsV1, + decodeSignedRCA, encodeCollectIndexingFeesData, } from '../dist/core/index.js' @@ -138,7 +139,10 @@ const coder = ethers.AbiCoder.defaultAbiCoder() const tokensPerSecond = 1000n * 10n ** 18n const tokensPerEntityPerSecond = 5n * 10n ** 15n - const encoded = coder.encode(['tuple(uint256 tokensPerSecond, uint256 tokensPerEntityPerSecond)'], [{ tokensPerSecond, tokensPerEntityPerSecond }]) + const encoded = coder.encode( + ['tuple(uint256 tokensPerSecond, uint256 tokensPerEntityPerSecond)'], + [{ tokensPerSecond, tokensPerEntityPerSecond }], + ) const decoded = decodeIndexingAgreementTermsV1(encoded) From 0f8f6dc8be3ab9b0329fb18cac0004f6b9ea1334 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:40:33 +0000 Subject: [PATCH 150/157] fix(deployment): align localNetwork migrate governor with deploy modules' ACCOUNT1 Phase 1 deploy modules hardcode m.getAccount(1) (ACCOUNT1) when transferring ProxyAdmin ownership for new proxies, but migrate.localNetwork.json5 declared ACCOUNT0 as governor. New ProxyAdmins minted by the GIP-0088 upgrade phase therefore landed with ACCOUNT0 as owner, while local-network's issuance.run.sh signs upgrade txs with GOVERNOR_KEY=ACCOUNT1_SECRET, causing OwnableUnauthorizedAccount reverts mid-batch. Align migrate config with the deploy modules and the run-script. --- packages/horizon/ignition/configs/migrate.localNetwork.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/horizon/ignition/configs/migrate.localNetwork.json5 b/packages/horizon/ignition/configs/migrate.localNetwork.json5 index 8b052634d..21f34880e 100644 --- a/packages/horizon/ignition/configs/migrate.localNetwork.json5 +++ b/packages/horizon/ignition/configs/migrate.localNetwork.json5 @@ -1,7 +1,7 @@ { "$global": { // Accounts already configured in the original Graph Protocol - Local Network values - "governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "governor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", // Addresses for contracts deployed in the original Graph Protocol - Local Network values "graphProxyAdminAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", From 7453b59b87187df410cce8d819b2a6ec70245597 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:57:00 +0000 Subject: [PATCH 151/157] fix(subgraph-service): align localNetwork protocol governor with deploy modules' ACCOUNT1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit deploy:protocol Phase 1.3 (Deploy2Module → DisputeManager.ts / SubgraphService.ts) transfers the freshly-minted ProxyAdmins to m.getParameter('governor'), which on localNetwork resolved to ACCOUNT0. Local-network's issuance.run.sh signs subsequent upgradeAndCall txs with GOVERNOR_KEY=ACCOUNT1_SECRET, so the DisputeManager / SubgraphService PA upgrades reverted with OwnableUnauthorizedAccount. Bumping the SS-side protocol-config governor to ACCOUNT1 brings local-network into alignment with both the run-script and the m.getAccount(1) convention horizon's deploy modules already use. Production migrate paths (migrate..json5) are unaffected. --- .../ignition/configs/protocol.localNetwork.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/subgraph-service/ignition/configs/protocol.localNetwork.json5 b/packages/subgraph-service/ignition/configs/protocol.localNetwork.json5 index 1b35b18c1..867873db1 100644 --- a/packages/subgraph-service/ignition/configs/protocol.localNetwork.json5 +++ b/packages/subgraph-service/ignition/configs/protocol.localNetwork.json5 @@ -1,7 +1,7 @@ { "$global": { // Accounts for new deployment - derived from local network mnemonic - "governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", // index 0 + "governor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", // index 1 "arbitrator": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", // index 2 "pauseGuardian": "0x90F79bf6EB2c4f870365E785982E1f101E93b906", // index 3 From 3117e9433f3ae4204296bf92b9dc3f6b48035ee0 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:01:25 +0000 Subject: [PATCH 152/157] chore(subgraph-service): align localNetwork migrate governor with horizon sibling Mirror the earlier horizon migrate-config bump on the SS side so both migrate.localNetwork.json5 files use ACCOUNT1 as governor. Not load-bearing for any current flow (the migrate path isn't run on local-network), but keeps the two sibling files in sync and consistent with the m.getAccount(1) convention used by horizon's deploy modules. --- .../ignition/configs/migrate.localNetwork.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/subgraph-service/ignition/configs/migrate.localNetwork.json5 b/packages/subgraph-service/ignition/configs/migrate.localNetwork.json5 index c71d70a8f..9c93e1087 100644 --- a/packages/subgraph-service/ignition/configs/migrate.localNetwork.json5 +++ b/packages/subgraph-service/ignition/configs/migrate.localNetwork.json5 @@ -1,7 +1,7 @@ { "$global": { // Accounts already configured in the original Graph Protocol - Local Network values - "governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", // index 0 + "governor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", // index 1 "arbitrator": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", // index 2 "pauseGuardian": "0x90F79bf6EB2c4f870365E785982E1f101E93b906", // index 3 From 567a01816d93887c512178452b170154de442333 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:18:29 +0000 Subject: [PATCH 153/157] fix(horizon): correct localNetwork pauseGuardian and subgraphAvailabilityOracle addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The header comment claims addresses are derived from the hardhat default mnemonic, but the values were copied from protocol.default.json5 which uses the older 'myth like bonus' mnemonic. Replace with the correct hardhat-default-mnemonic addresses at the stated indices. Latent — both values are passed to setPauseGuardian / setSubgraph- AvailabilityOracle on local-network, but no current local-network test exercises pause or availability-oracle functionality, so the mismatch hadn't surfaced. Caught while building the cross-package config reconciliation test. --- packages/horizon/ignition/configs/protocol.localNetwork.json5 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/horizon/ignition/configs/protocol.localNetwork.json5 b/packages/horizon/ignition/configs/protocol.localNetwork.json5 index 2d3c08b39..5b5ea1e2c 100644 --- a/packages/horizon/ignition/configs/protocol.localNetwork.json5 +++ b/packages/horizon/ignition/configs/protocol.localNetwork.json5 @@ -1,8 +1,8 @@ { "$global": { // Accounts for new deployment - derived from hardhat default mnemonic - "pauseGuardian": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d", // index 3 - "subgraphAvailabilityOracle": "0xd03ea8624C8C5987235048901fB614fDcA89b117", // index 4 + "pauseGuardian": "0x90F79bf6EB2c4f870365E785982E1f101E93b906", // index 3 + "subgraphAvailabilityOracle": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", // index 4 // Placeholder address for a standalone Horizon deployment, see README.md for more details "subgraphServiceAddress": "0x0000000000000000000000000000000000000000", From eee73221cb7a81ae413b973f13ea43be4b347e27 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:42:25 +0000 Subject: [PATCH 154/157] test(deployment): add cross-package config reconciliation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static unit test that catches drift between per-network Ignition config files in packages/horizon/ignition/configs/ and packages/subgraph-service/ignition/configs/. Four checks: 1. Cross-package sibling agreement. For each (prefix, network) pair where both packages have a file (e.g. both migrate.arbitrumOne.json5), every overlapping non-empty $global field must match. 2. localNetwork all-files $global agreement. For localNetwork specifically (one stack, one governor) every $global field meaningfully declared in more than one of the four {horizon,subgraph-service}/{migrate,protocol}.localNetwork.json5 files must match across all of them. Stricter than #1 — catches same-package cross-prefix drift. 3. localNetwork same-package cross-prefix sub-object agreement. Each package's per-contract config blocks (e.g. "DisputeManager": { ... }, "RecurringCollector": { ... }) must agree leaf-by-leaf between migrate and protocol. Catches drift in fields like eip712Name / eip712Version (signature verification breakers) and disputePeriod / disputeDeposit parameters. Restricted to localNetwork because for other networks (notably default) migrate and protocol are intentionally different templates. 4. localNetwork mnemonic-index correctness. Lines like "governor": "0x70997970…", // index 1 must have an address that derives from the hardhat default mnemonic at the stated BIP44 index. Catches copy-paste mistakes where the value updates but the comment doesn't, or vice versa. Verified to fail on the SS protocol governor drift the test was designed against: reverting governor in subgraph-service/ignition/configs/protocol.localNetwork.json5 to ACCOUNT0 produces a clean three-way mismatch report from check #2. Adds json5 as a direct devDep (was transitively available via toolshed but not declarable that way under pnpm strict mode). --- packages/deployment/package.json | 1 + .../test/config-reconciliation.test.ts | 231 ++++++++++++++++++ pnpm-lock.yaml | 3 + 3 files changed, 235 insertions(+) create mode 100644 packages/deployment/test/config-reconciliation.test.ts diff --git a/packages/deployment/package.json b/packages/deployment/package.json index a1feebbef..9cd1d0e5f 100644 --- a/packages/deployment/package.json +++ b/packages/deployment/package.json @@ -51,6 +51,7 @@ "@types/node": "^20.0.0", "chai": "^4.3.0", "hardhat-deploy": "2.0.0-next.61", + "json5": "^2.2.3", "mocha": "^10.7.0", "rocketh": "^0.17.13", "tsx": "^4.19.0", diff --git a/packages/deployment/test/config-reconciliation.test.ts b/packages/deployment/test/config-reconciliation.test.ts new file mode 100644 index 000000000..2ea3fd131 --- /dev/null +++ b/packages/deployment/test/config-reconciliation.test.ts @@ -0,0 +1,231 @@ +import { expect } from 'chai' +import { HDNodeWallet } from 'ethers' +import fs from 'fs' +import JSON5 from 'json5' +import path from 'path' +import { fileURLToPath } from 'url' + +/** + * Deployment config reconciliation + * + * Catches drift between the per-network Ignition config files in + * `packages/horizon/ignition/configs/` and `packages/subgraph-service/ignition/configs/`. + * + * Four checks: + * + * 1. Cross-package sibling agreement. For each `(prefix, network)` pair where both + * horizon and subgraph-service have a config file (e.g. both `migrate.arbitrumOne.json5`), + * every overlapping non-empty `$global` field must match. Catches the failure mode where + * one package is updated but the sibling drifts. + * + * 2. localNetwork all-files `$global` agreement. For localNetwork specifically (one stack, + * one governor) every `$global` field meaningfully declared in more than one of the four + * `{horizon,subgraph-service}/{migrate,protocol}.localNetwork.json5` files must match + * across all of them. Stricter than #1 — catches same-package cross-prefix drift. + * + * 3. localNetwork same-package cross-prefix sub-object agreement. For localNetwork, each + * package's per-contract config blocks (e.g. `"DisputeManager": { ... }`) must agree + * leaf-by-leaf between `migrate` and `protocol`. Catches drift in things like + * `eip712Name`/`eip712Version` (which would silently break signature verification) and + * `disputePeriod`/`disputeDeposit` parameters. Restricted to localNetwork because for + * other networks (notably `default`) migrate and protocol are intentionally different + * templates with different parameter values. + * + * 4. localNetwork mnemonic-index correctness. Lines like + * "governor": "0x70997970…", // index 1 + * must have an address that derives from the hardhat default mnemonic at the stated + * BIP44 index. Catches copy-paste mistakes where someone updates the value but not the + * comment, or vice versa. + */ + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + +const HARDHAT_DEFAULT_MNEMONIC = 'test test test test test test test test test test test junk' +const PACKAGES_DIR = path.resolve(__dirname, '../..') +const PACKAGES = ['horizon', 'subgraph-service'] as const +const CONFIG_FILE_RE = /^(migrate|protocol)\.(.+)\.json5$/ + +type ConfigPrefix = 'migrate' | 'protocol' + +interface ConfigFile { + package: string + network: string + prefix: ConfigPrefix + filePath: string + globalFields: Record + subObjects: Record> + rawText: string +} + +function discoverConfigs(): ConfigFile[] { + const out: ConfigFile[] = [] + for (const pkg of PACKAGES) { + const dir = path.join(PACKAGES_DIR, pkg, 'ignition/configs') + if (!fs.existsSync(dir)) continue + for (const file of fs.readdirSync(dir)) { + const m = CONFIG_FILE_RE.exec(file) + if (!m) continue + const filePath = path.join(dir, file) + const rawText = fs.readFileSync(filePath, 'utf8') + const parsed = JSON5.parse>(rawText) + const globalFields = (parsed.$global ?? {}) as Record + const subObjects: Record> = {} + for (const [k, v] of Object.entries(parsed)) { + if (k === '$global') continue + if (typeof v === 'object' && v !== null && !Array.isArray(v)) { + subObjects[k] = v as Record + } + } + out.push({ + package: pkg, + network: m[2], + prefix: m[1] as ConfigPrefix, + filePath, + globalFields, + subObjects, + rawText, + }) + } + } + return out +} + +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' + +function isMeaningful(value: unknown): boolean { + if (value === '' || value === null || value === undefined) return false + if (typeof value === 'string' && value.toLowerCase() === ZERO_ADDRESS) return false + return true +} + +function deriveHardhatAddress(index: number): string { + return HDNodeWallet.fromPhrase(HARDHAT_DEFAULT_MNEMONIC, undefined, `m/44'/60'/0'/0/${index}`).address +} + +function groupByPrefixAndNetwork(configs: ConfigFile[]): Map { + const out = new Map() + for (const c of configs) { + const key = `${c.prefix}.${c.network}` + if (!out.has(key)) out.set(key, []) + out.get(key)!.push(c) + } + return out +} + +describe('Deployment Config Reconciliation', () => { + const configs = discoverConfigs() + const grouped = groupByPrefixAndNetwork(configs) + + describe('Cross-package sibling agreement', () => { + for (const [key, files] of grouped) { + if (files.length < 2) continue + + it(`${key}.json5: overlapping $global fields agree across packages`, () => { + const overlap = new Set() + for (const field of Object.keys(files[0].globalFields)) { + if (files.every((f) => isMeaningful(f.globalFields[field]))) overlap.add(field) + } + + const mismatches: string[] = [] + for (const field of overlap) { + const distinct = new Set(files.map((f) => JSON.stringify(f.globalFields[field]))) + if (distinct.size > 1) { + const summary = files.map((f) => ` ${f.package}: ${JSON.stringify(f.globalFields[field])}`).join('\n') + mismatches.push(` ${field}:\n${summary}`) + } + } + + expect(mismatches, `Cross-package mismatches in ${key}.json5:\n${mismatches.join('\n')}`).to.have.lengthOf(0) + }) + } + }) + + describe('localNetwork all-files agreement', () => { + const localNetworkFiles = configs.filter((c) => c.network === 'localNetwork') + + if (localNetworkFiles.length >= 2) { + it('localNetwork: $global identity fields agree across all (package, prefix) files', () => { + const allFields = new Set() + for (const f of localNetworkFiles) { + for (const [k, v] of Object.entries(f.globalFields)) { + if (isMeaningful(v)) allFields.add(k) + } + } + + const mismatches: string[] = [] + for (const field of allFields) { + const present = localNetworkFiles.filter((f) => isMeaningful(f.globalFields[field])) + if (present.length < 2) continue + const distinct = new Set(present.map((f) => JSON.stringify(f.globalFields[field]))) + if (distinct.size > 1) { + const summary = present + .map((f) => ` ${f.package}/${f.prefix}.localNetwork.json5: ${JSON.stringify(f.globalFields[field])}`) + .join('\n') + mismatches.push(` ${field}:\n${summary}`) + } + } + + expect( + mismatches, + `localNetwork identity-field mismatches across files:\n${mismatches.join('\n')}`, + ).to.have.lengthOf(0) + }) + } + }) + + describe('localNetwork same-package cross-prefix sub-object agreement', () => { + // localNetwork-only: one stack, so per-contract config in protocol and migrate must agree. + // For other networks (e.g. `default`), migrate and protocol are different templates with + // intentionally different parameter values. + for (const pkg of PACKAGES) { + const migrate = configs.find((c) => c.package === pkg && c.network === 'localNetwork' && c.prefix === 'migrate') + const protocol = configs.find((c) => c.package === pkg && c.network === 'localNetwork' && c.prefix === 'protocol') + if (!migrate || !protocol) continue + + it(`${pkg}/localNetwork: per-contract sub-object leaves agree across migrate and protocol`, () => { + const sharedKeys = Object.keys(migrate.subObjects).filter((k) => k in protocol.subObjects) + + const mismatches: string[] = [] + for (const subKey of sharedKeys) { + const m = migrate.subObjects[subKey] + const p = protocol.subObjects[subKey] + for (const leaf of new Set([...Object.keys(m), ...Object.keys(p)])) { + if (!(leaf in m) || !(leaf in p)) continue // declared in only one side + if (JSON.stringify(m[leaf]) !== JSON.stringify(p[leaf])) { + mismatches.push( + ` ${subKey}.${leaf}: migrate=${JSON.stringify(m[leaf])} protocol=${JSON.stringify(p[leaf])}`, + ) + } + } + } + + expect( + mismatches, + `Sub-object leaf mismatches in ${pkg}/localNetwork:\n${mismatches.join('\n')}`, + ).to.have.lengthOf(0) + }) + } + }) + + describe('localNetwork mnemonic-index comments', () => { + const indexCommentRe = /"(0x[a-fA-F0-9]{40})"\s*,?\s*\/\/\s*index\s+(\d+)/g + + for (const cfg of configs) { + if (cfg.network !== 'localNetwork') continue + + it(`${cfg.package}/${path.basename(cfg.filePath)}: addresses match // index N comments`, () => { + const errors: string[] = [] + for (const match of cfg.rawText.matchAll(indexCommentRe)) { + const [, address, indexStr] = match + const index = Number.parseInt(indexStr, 10) + const expected = deriveHardhatAddress(index) + if (address.toLowerCase() !== expected.toLowerCase()) { + errors.push(`address ${address} marked "// index ${index}" should be ${expected}`) + } + } + expect(errors, errors.join('\n')).to.have.lengthOf(0) + }) + } + }) +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50a49f3d5..079ba0d9b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -819,6 +819,9 @@ importers: hardhat-deploy: specifier: 2.0.0-next.61 version: 2.0.0-next.61(@rocketh/node@0.17.16(bufferutil@4.0.9)(rocketh@0.17.13(patch_hash=9922612567456c164edd9dd5a0c9304bfd66babcebfe7c39dca333659ff1248f)(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(hardhat@3.1.5(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + json5: + specifier: ^2.2.3 + version: 2.2.3 lint-staged: specifier: 'catalog:' version: 16.2.7 From 87ee8b6df59d44e39458111831c4e92ddd3a29f5 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 1 May 2026 10:43:00 +0000 Subject: [PATCH 155/157] chore(collector): make module-level constants internal to free EIP-170 headroom Drops the auto-generated public getters for MIN_SECONDS_COLLECTION_WINDOW, CONDITION_ELIGIBILITY_CHECK, EIP712_RCA_TYPEHASH, and EIP712_RCAU_TYPEHASH (~50 bytes each) so the contract stays under the EIP-170 24576-byte limit when later additions land. Tests that read these via the public ABI switch to the literal value with a naming comment. Mirrors the dropped constants and EIP-712 typestrings under @graphprotocol/toolshed/core/recurring-collector so off-chain agents constructing offers have a typed source of truth. --- .../collectors/RecurringCollector.sol | 8 ++-- .../RecurringCollectorHelper.t.sol | 8 ++-- .../acceptValidation.t.sol | 6 +-- .../recurring-collector/viewFunctions.t.sol | 2 +- .../AgreementLifecycleAdvanced.t.sol | 4 +- packages/toolshed/src/core/index.ts | 1 + .../toolshed/src/core/recurring-collector.ts | 37 +++++++++++++++++++ 7 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 packages/toolshed/src/core/recurring-collector.ts diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index cca28c494..df06075cb 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -63,10 +63,10 @@ contract RecurringCollector is using PPMMath for uint256; /// @notice The minimum number of seconds that must be between two collections - uint32 public constant MIN_SECONDS_COLLECTION_WINDOW = 600; + uint32 internal constant MIN_SECONDS_COLLECTION_WINDOW = 600; /// @notice Condition flag: agreement requires eligibility checks before collection - uint16 public constant CONDITION_ELIGIBILITY_CHECK = 1; + uint16 internal constant CONDITION_ELIGIBILITY_CHECK = 1; /// @notice Maximum gas forwarded to payer contract callbacks (beforeCollection / afterCollection). /// Caps gas available to payer implementations, preventing 63/64-rule gas siphoning attacks @@ -81,13 +81,13 @@ contract RecurringCollector is /* solhint-disable gas-small-strings */ /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct - bytes32 public constant EIP712_RCA_TYPEHASH = + bytes32 internal constant EIP712_RCA_TYPEHASH = keccak256( "RecurringCollectionAgreement(uint64 deadline,uint64 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint256 nonce,bytes metadata)" ); /// @notice The EIP712 typehash for the RecurringCollectionAgreementUpdate struct - bytes32 public constant EIP712_RCAU_TYPEHASH = + bytes32 internal constant EIP712_RCAU_TYPEHASH = keccak256( "RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint32 nonce,bytes metadata)" ); diff --git a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol index 5914b422d..a512d0321 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol @@ -158,11 +158,9 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { return rcau; } + /// @dev 600 == RecurringCollector.MIN_SECONDS_COLLECTION_WINDOW function _sensibleDeadline(uint256 _seed) internal view returns (uint64) { - return - uint64( - bound(_seed, block.timestamp + 1, block.timestamp + uint256(collector.MIN_SECONDS_COLLECTION_WINDOW())) - ); // between now and +MIN_SECONDS_COLLECTION_WINDOW + return uint64(bound(_seed, block.timestamp + 1, block.timestamp + 600)); } function _sensibleEndsAt(uint256 _seed, uint32 _maxSecondsPerCollection) internal view returns (uint64) { @@ -184,7 +182,7 @@ contract RecurringCollectorHelper is AuthorizableHelper, Bounder { uint32( bound( _seed, - _minSecondsPerCollection + uint256(collector.MIN_SECONDS_COLLECTION_WINDOW()), + _minSecondsPerCollection + 600, // 600 == MIN_SECONDS_COLLECTION_WINDOW 60 * 60 * 24 * 30 ) // between minSecondsPerCollection + 2h and 30 days ); diff --git a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol index 91e3e0bdd..790869907 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/acceptValidation.t.sol @@ -106,7 +106,7 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest vm.expectRevert( abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementInvalidCollectionWindow.selector, - _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(), + uint32(600), // MIN_SECONDS_COLLECTION_WINDOW rca.minSecondsPerCollection, rca.maxSecondsPerCollection ) @@ -129,7 +129,7 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest vm.expectRevert( abi.encodeWithSelector( IRecurringCollector.RecurringCollectorAgreementInvalidCollectionWindow.selector, - _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(), + uint32(600), // MIN_SECONDS_COLLECTION_WINDOW rca.minSecondsPerCollection, rca.maxSecondsPerCollection ) @@ -144,7 +144,7 @@ contract RecurringCollectorAcceptValidationTest is RecurringCollectorSharedTest IRecurringCollector.RecurringCollectionAgreement memory rca = _makeValidRCA(); // Need: endsAt - deadline >= minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW // Set duration just under the minimum - uint32 minWindow = _recurringCollector.MIN_SECONDS_COLLECTION_WINDOW(); + uint32 minWindow = 600; // MIN_SECONDS_COLLECTION_WINDOW rca.minSecondsPerCollection = 600; rca.maxSecondsPerCollection = 600 + minWindow; // valid window rca.endsAt = rca.deadline + rca.minSecondsPerCollection + minWindow - 1; // 1 second too short diff --git a/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol index 80445920b..902572a29 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/viewFunctions.t.sol @@ -16,7 +16,7 @@ contract RecurringCollectorViewFunctionsTest is RecurringCollectorSharedTest { (, , , bytes16 agreementId) = _sensibleAuthorizeAndAccept(fuzzy); // Skip past the minimum collection window so collection is possible - skip(_recurringCollector.MIN_SECONDS_COLLECTION_WINDOW()); + skip(600); // MIN_SECONDS_COLLECTION_WINDOW // Re-read agreement (timestamps don't change but view computes based on block.timestamp) (bool isCollectable, uint256 collectionSeconds, ) = _recurringCollector.getCollectionInfo(agreementId); diff --git a/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol index 95f91f1a0..9ad69b1a9 100644 --- a/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol +++ b/packages/testing/test/integration/AgreementLifecycleAdvanced.t.sol @@ -406,7 +406,7 @@ contract AgreementLifecycleAdvancedTest is FullStackHarness { tokensPerEntityPerSecond: 0 }); - uint16 eligibilityCondition = recurringCollector.CONDITION_ELIGIBILITY_CHECK(); + uint16 eligibilityCondition = 1; // CONDITION_ELIGIBILITY_CHECK IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCAEx( indexer, 0, @@ -442,7 +442,7 @@ contract AgreementLifecycleAdvancedTest is FullStackHarness { tokensPerEntityPerSecond: 0 }); - uint16 eligibilityCondition = recurringCollector.CONDITION_ELIGIBILITY_CHECK(); + uint16 eligibilityCondition = 1; // CONDITION_ELIGIBILITY_CHECK IRecurringCollector.RecurringCollectionAgreement memory rca = _buildRCAEx( indexer, 0, diff --git a/packages/toolshed/src/core/index.ts b/packages/toolshed/src/core/index.ts index 3934ed378..7dbbb79ba 100644 --- a/packages/toolshed/src/core/index.ts +++ b/packages/toolshed/src/core/index.ts @@ -6,5 +6,6 @@ export * from './custom-errors' export * from './disputes' export * from './graph-tally' export * from './poi' +export * from './recurring-collector' export * from './subgraph-service' export * from './types' diff --git a/packages/toolshed/src/core/recurring-collector.ts b/packages/toolshed/src/core/recurring-collector.ts new file mode 100644 index 000000000..42c1bc7be --- /dev/null +++ b/packages/toolshed/src/core/recurring-collector.ts @@ -0,0 +1,37 @@ +/** + * Constants for constructing RCA / RCAU offers against `RecurringCollector`. + * + * Source of truth for off-chain agents — the on-chain values are declared as + * `internal constant` in RecurringCollector.sol (no ABI getters), so consumers + * import these instead of querying the contract. + * + * EIP-712 typehashes are derived: `keccak256(toUtf8Bytes(typestring))`. Typed-data + * signing helpers (e.g. ethers `signTypedData`) take the field tuples directly — + * derive those from the typestring at the call site. + */ + +/** Minimum seconds between collections enforced by the collector window check. */ +export const RC_MIN_SECONDS_COLLECTION_WINDOW = 600 + +/** Conditions bitmask: agreement requires payer eligibility check (IProviderEligibility). */ +export const RC_CONDITION_ELIGIBILITY_CHECK = 1 << 0 + +/** + * Conditions bitmask: agreement uses IAgreementOwner callbacks + * (beforeCollection / afterCollection). Validated via ERC-165 at acceptance, + * so callback dispatch is locked to acceptance time and unaffected by + * post-acceptance payer code changes (e.g. EIP-7702 delegation swaps). + * + * Off-chain agents constructing RCAs against a contract payer that relies on + * these callbacks (such as RecurringAgreementManager for JIT escrow top-up) + * must set this bit; otherwise the callbacks are skipped silently. + */ +export const RC_CONDITION_AGREEMENT_OWNER = 1 << 1 + +/** EIP-712 typestring for a RecurringCollectionAgreement (RCA). */ +export const RC_EIP712_RCA_TYPESTRING = + 'RecurringCollectionAgreement(uint64 deadline,uint64 endsAt,address payer,address dataService,address serviceProvider,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint256 nonce,bytes metadata)' + +/** EIP-712 typestring for a RecurringCollectionAgreementUpdate (RCAU). */ +export const RC_EIP712_RCAU_TYPESTRING = + 'RecurringCollectionAgreementUpdate(bytes16 agreementId,uint64 deadline,uint64 endsAt,uint256 maxInitialTokens,uint256 maxOngoingTokensPerSecond,uint32 minSecondsPerCollection,uint32 maxSecondsPerCollection,uint16 conditions,uint32 nonce,bytes metadata)' From f44fc5a4c74fa5190fd2892ae15a083b79f715f3 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 1 May 2026 10:43:26 +0000 Subject: [PATCH 156/157] feat(collector): add CONDITION_AGREEMENT_OWNER for ERC-165-validated callback opt-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the live `payer.code.length != 0` callback dispatch in _preCollectCallbacks/_postCollectCallback with a stored condition flag. An offer that sets CONDITION_AGREEMENT_OWNER is only acceptable when the payer declares ERC-165 support for IAgreementOwner; the flag is then read at collection time, so callback dispatch is frozen to acceptance and unaffected by post-acceptance code changes such as EIP-7702 delegation swaps. This closes the gas-estimator griefing vector where an EOA payer could attach delegation between estimation and execution and cause collect() to revert. Consolidates the two interface-support errors into a single RecurringCollectorPayerDoesNotSupportInterface(payer, interfaceId). Renames _requirePayerToSupportEligibilityCheck to _requirePayerInterfaceSupport and folds both ERC-165 checks into it. Test coverage: - offer(NEW) reverts when CONDITION_AGREEMENT_OWNER is set on a payer that does not declare IAgreementOwner via ERC-165. - offer(UPDATE) re-validates ERC-165 support when an RCAU adds the flag to an already-accepted agreement, and reverts if the payer doesn't declare it. - collect skips both beforeCollection and afterCollection when the flag is unset, even with a contract payer — proves dispatch gates on the stored flag, not live payer.code.length. Addresses TRST-L-10. --- .../collectors/RecurringCollector.sol | 54 ++++++++--- .../MockAgreementOwner.t.sol | 5 +- .../recurring-collector/afterCollection.t.sol | 47 +++++++++ .../recurring-collector/coverageGaps.t.sol | 97 ++++++++++++++++++- .../contracts/horizon/IAgreementOwner.sol | 8 +- .../contracts/horizon/IRecurringCollector.sol | 13 ++- packages/issuance/audits/PR1301/TRST-L-10.md | 7 +- .../test/harness/FullStackHarness.t.sol | 4 +- 8 files changed, 206 insertions(+), 29 deletions(-) diff --git a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol index df06075cb..ba4d2ff6a 100644 --- a/packages/horizon/contracts/payments/collectors/RecurringCollector.sol +++ b/packages/horizon/contracts/payments/collectors/RecurringCollector.sol @@ -66,7 +66,13 @@ contract RecurringCollector is uint32 internal constant MIN_SECONDS_COLLECTION_WINDOW = 600; /// @notice Condition flag: agreement requires eligibility checks before collection - uint16 internal constant CONDITION_ELIGIBILITY_CHECK = 1; + uint16 internal constant CONDITION_ELIGIBILITY_CHECK = 1 << 0; + + /// @notice Condition flag: agreement uses the IAgreementOwner callbacks + /// (beforeCollection / afterCollection). Validated via ERC-165 at acceptance, so the + /// callback dispatch decision is frozen to acceptance time and immune to post-acceptance + /// payer code changes (e.g. EIP-7702 delegation swaps). + uint16 internal constant CONDITION_AGREEMENT_OWNER = 1 << 1; /// @notice Maximum gas forwarded to payer contract callbacks (beforeCollection / afterCollection). /// Caps gas available to payer implementations, preventing 63/64-rule gas siphoning attacks @@ -763,12 +769,14 @@ contract RecurringCollector is } agreement.lastCollectionAt = uint64(block.timestamp); + address payer = agreement.payer; + if (0 < tokensToCollect) { _preCollectCallbacks(agreement, _params.agreementId, tokensToCollect); _graphPaymentsEscrow().collect( _paymentType, - agreement.payer, + payer, agreement.serviceProvider, tokensToCollect, agreement.dataService, @@ -780,7 +788,7 @@ contract RecurringCollector is emit PaymentCollected( _paymentType, _params.collectionId, - agreement.payer, + payer, agreement.serviceProvider, agreement.dataService, tokensToCollect @@ -788,7 +796,7 @@ contract RecurringCollector is emit RCACollected( agreement.dataService, - agreement.payer, + payer, agreement.serviceProvider, _params.agreementId, _params.collectionId, @@ -796,21 +804,30 @@ contract RecurringCollector is _params.dataServiceCut ); - if (0 < tokensToCollect) _postCollectCallback(agreement.payer, _params.agreementId, tokensToCollect); + if (0 < tokensToCollect) + _postCollectCallback(payer, agreement.conditions, _params.agreementId, tokensToCollect); return tokensToCollect; } /* solhint-enable function-max-lines */ /** - * @notice Validates that a contract payer supports IProviderEligibility via ERC-165. + * @notice Validates that the payer supports the interfaces required by the conditions bitmask. + * @dev Each set condition bit requires the payer to declare ERC-165 support for the matching + * interface. * @param payer The payer address to validate * @param conditions The conditions bitmask */ - function _requirePayerToSupportEligibilityCheck(address payer, uint16 conditions) private view { + function _requirePayerInterfaceSupport(address payer, uint16 conditions) private view { if (conditions & CONDITION_ELIGIBILITY_CHECK != 0) { require( ERC165Checker.supportsInterface(payer, type(IProviderEligibility).interfaceId), - RecurringCollectorPayerDoesNotSupportEligibilityInterface(payer) + RecurringCollectorPayerDoesNotSupportInterface(payer, type(IProviderEligibility).interfaceId) + ); + } + if (conditions & CONDITION_AGREEMENT_OWNER != 0) { + require( + ERC165Checker.supportsInterface(payer, type(IAgreementOwner).interfaceId), + RecurringCollectorPayerDoesNotSupportInterface(payer, type(IAgreementOwner).interfaceId) ); } } @@ -829,12 +846,13 @@ contract RecurringCollector is ) private { address payer = agreement.payer; address provider = agreement.serviceProvider; + uint16 conditions = agreement.conditions; // Eligibility gate (opt-in via conditions bitmask). Assembly staticcall caps returndata // copy to 32 bytes, preventing returndata bombing. Only an explicit return of 0 blocks // collection; reverts, short returndata, and malformed responses are treated as "no // opinion" (collection proceeds). - if ((agreement.conditions & CONDITION_ELIGIBILITY_CHECK) != 0) { + if ((conditions & CONDITION_ELIGIBILITY_CHECK) != 0) { if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); bytes memory cd = abi.encodeCall(IProviderEligibility.isEligible, (provider)); @@ -854,7 +872,7 @@ contract RecurringCollector is } // Assembly call copies 0 bytes of returndata, preventing returndata bombing. - if (payer.code.length != 0 && payer != msg.sender) { + if ((conditions & CONDITION_AGREEMENT_OWNER) != 0 && payer != msg.sender) { if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); bytes memory cd = abi.encodeCall(IAgreementOwner.beforeCollection, (agreementId, tokensToCollect)); @@ -871,12 +889,18 @@ contract RecurringCollector is * @notice Executes post-collection callback: afterCollection notification. * @dev Extracted from _collect to reduce stack depth for coverage builds. * @param payer The payer address + * @param conditions The agreement conditions bitmask * @param agreementId The agreement ID * @param tokensToCollect The amount of tokens collected */ - function _postCollectCallback(address payer, bytes16 agreementId, uint256 tokensToCollect) private { + function _postCollectCallback( + address payer, + uint16 conditions, + bytes16 agreementId, + uint256 tokensToCollect + ) private { // Notify contract payers so they can reconcile escrow in the same transaction. - if (payer != msg.sender && payer.code.length != 0) { + if (payer != msg.sender && (conditions & CONDITION_AGREEMENT_OWNER) != 0) { // 64/63 accounts for EIP-150 63/64 gas forwarding rule. if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63 + CALLBACK_GAS_OVERHEAD) revert RecurringCollectorInsufficientCallbackGas(); @@ -936,14 +960,14 @@ contract RecurringCollector is } /** - * @notice Validates offer terms: collection window, eligibility support, and overflow. + * @notice Validates offer terms: collection window, payer interface support, and overflow. * @dev Called by _validateAndStoreAgreement and _validateAndStoreUpdate. Time-independent — * validates against the offer's deadline so the check is stable across the offer's lifetime. * @param _deadline The offer's acceptance deadline * @param _endsAt The end time of the agreement * @param _minSecondsPerCollection The minimum seconds per collection * @param _maxSecondsPerCollection The maximum seconds per collection - * @param _payer The payer address (for eligibility validation) + * @param _payer The payer address (for interface validation) * @param _conditions The conditions bitmask * @param _maxOngoingTokensPerSecond The maximum ongoing tokens per second */ @@ -957,7 +981,7 @@ contract RecurringCollector is uint256 _maxOngoingTokensPerSecond ) private view { _requireValidCollectionWindowParams(_deadline, _endsAt, _minSecondsPerCollection, _maxSecondsPerCollection); - _requirePayerToSupportEligibilityCheck(_payer, _conditions); + _requirePayerInterfaceSupport(_payer, _conditions); // Reverts on overflow — rejecting excessive terms that could prevent collection _maxOngoingTokensPerSecond * _maxSecondsPerCollection * 1024; } diff --git a/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol index 3d8db160e..4ce043a29 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/MockAgreementOwner.t.sol @@ -66,6 +66,9 @@ contract MockAgreementOwner is IAgreementOwner, IProviderEligibility, IERC165 { // -- IERC165 -- function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { - return interfaceId == type(IProviderEligibility).interfaceId || interfaceId == type(IERC165).interfaceId; + return + interfaceId == type(IAgreementOwner).interfaceId || + interfaceId == type(IProviderEligibility).interfaceId || + interfaceId == type(IERC165).interfaceId; } } diff --git a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol index 5af9b3b0f..61a5ac87d 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/afterCollection.t.sol @@ -33,6 +33,8 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { metadata: "" }) ); + // sensibleRCA zeroes conditions unconditionally; opt back in for callback dispatch. + rca.conditions = 2; // CONDITION_AGREEMENT_OWNER vm.prank(address(approver)); _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); @@ -103,6 +105,51 @@ contract RecurringCollectorAfterCollectionTest is RecurringCollectorSharedTest { assertEq(approver.lastCollectedTokens(), tokens); } + /// @notice With CONDITION_AGREEMENT_OWNER unset, callback dispatch is gated off + /// regardless of whether the payer happens to be a contract. Verifies the new + /// dispatch reads the stored flag rather than `payer.code.length`, closing the + /// EIP-7702 surprise-callback vector. + function test_AfterCollection_NoCallbacks_WhenAgreementOwnerConditionUnset() public { + MockAgreementOwner approver = _newApprover(); + IRecurringCollector.RecurringCollectionAgreement memory rca = _recurringCollectorHelper.sensibleRCA( + IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(approver), + dataService: makeAddr("ds-no-cb"), + serviceProvider: makeAddr("sp-no-cb"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, + nonce: 1, + metadata: "" + }) + ); + // sensibleRCA zeroes conditions; leave it zero to assert callbacks are skipped. + + vm.prank(address(approver)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + _setupValidProvision(rca.serviceProvider, rca.dataService); + vm.prank(rca.dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + skip(rca.minSecondsPerCollection); + uint256 tokens = 1 ether; + bytes memory data = _generateCollectData(_generateCollectParams(rca, agreementId, bytes32("col1"), tokens, 0)); + + vm.prank(rca.dataService); + uint256 collected = _recurringCollector.collect(IGraphPayments.PaymentTypes.IndexingFee, data); + assertEq(collected, tokens); + + // Neither callback fired — mock state is still default + assertEq(approver.lastBeforeCollectionAgreementId(), bytes16(0), "beforeCollection must be skipped"); + assertEq(approver.lastBeforeCollectionTokens(), 0, "beforeCollection must be skipped"); + assertEq(approver.lastCollectedAgreementId(), bytes16(0), "afterCollection must be skipped"); + assertEq(approver.lastCollectedTokens(), 0, "afterCollection must be skipped"); + } + function test_AfterCollection_CollectionSucceedsWhenCallbackReverts() public { MockAgreementOwner approver = _newApprover(); (IRecurringCollector.RecurringCollectionAgreement memory rca, bytes16 agreementId) = _acceptUnsignedAgreement( diff --git a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol index 9dd76355f..689cf5b48 100644 --- a/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol +++ b/packages/horizon/test/unit/payments/recurring-collector/coverageGaps.t.sol @@ -1139,14 +1139,102 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { vm.expectRevert( abi.encodeWithSelector( - IRecurringCollector.RecurringCollectorPayerDoesNotSupportEligibilityInterface.selector, - address(bare) + IRecurringCollector.RecurringCollectorPayerDoesNotSupportInterface.selector, + address(bare), + type(IProviderEligibility).interfaceId ) ); vm.prank(address(bare)); _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); } + /// @notice When an RCA enables CONDITION_AGREEMENT_OWNER, the payer must support + /// IAgreementOwner via ERC-165. BareAgreementOwner implements IAgreementOwner + /// methods but not IERC165, so ERC165Checker.supportsInterface returns false and + /// the require fires at offer time. + function test_OfferNew_Revert_WhenAgreementOwnerConditionAndPayerLacksInterface() public { + BareAgreementOwner bare = new BareAgreementOwner(); + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(bare), + dataService: makeAddr("ds-ao-bare"), + serviceProvider: makeAddr("sp-ao-bare"), + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 2, // CONDITION_AGREEMENT_OWNER + nonce: 1, + metadata: "" + }); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorPayerDoesNotSupportInterface.selector, + address(bare), + type(IAgreementOwner).interfaceId + ) + ); + vm.prank(address(bare)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + } + + /// @notice An RCAU that adds CONDITION_AGREEMENT_OWNER to an accepted agreement + /// must re-validate ERC-165 support against the current payer. If the payer + /// does not declare IAgreementOwner via ERC-165, the update reverts at offer time. + function test_OfferUpdate_Revert_WhenAgreementOwnerConditionAddedAndPayerLacksInterface() public { + BareAgreementOwner bare = new BareAgreementOwner(); + address dataService = makeAddr("ds-ao-update"); + address serviceProvider = makeAddr("sp-ao-update"); + + IRecurringCollector.RecurringCollectionAgreement memory rca = IRecurringCollector.RecurringCollectionAgreement({ + deadline: uint64(block.timestamp + 1 hours), + endsAt: uint64(block.timestamp + 365 days), + payer: address(bare), + dataService: dataService, + serviceProvider: serviceProvider, + maxInitialTokens: 100 ether, + maxOngoingTokensPerSecond: 1 ether, + minSecondsPerCollection: 600, + maxSecondsPerCollection: 3600, + conditions: 0, // no flags — passes acceptance with no ERC-165 check + nonce: 1, + metadata: "" + }); + + vm.prank(address(bare)); + _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); + vm.prank(dataService); + bytes16 agreementId = _recurringCollector.accept(rca, ""); + + // Now submit RCAU adding CONDITION_AGREEMENT_OWNER — should revert because + // BareAgreementOwner does not declare IAgreementOwner via ERC-165. + IRecurringCollector.RecurringCollectionAgreementUpdate memory rcau = IRecurringCollector + .RecurringCollectionAgreementUpdate({ + agreementId: agreementId, + deadline: uint64(block.timestamp + 1 hours), + endsAt: rca.endsAt, + maxInitialTokens: rca.maxInitialTokens, + maxOngoingTokensPerSecond: rca.maxOngoingTokensPerSecond, + minSecondsPerCollection: rca.minSecondsPerCollection, + maxSecondsPerCollection: rca.maxSecondsPerCollection, + conditions: 2, // CONDITION_AGREEMENT_OWNER + nonce: 1, + metadata: "" + }); + + vm.expectRevert( + abi.encodeWithSelector( + IRecurringCollector.RecurringCollectorPayerDoesNotSupportInterface.selector, + address(bare), + type(IAgreementOwner).interfaceId + ) + ); + vm.prank(address(bare)); + _recurringCollector.offer(OFFER_TYPE_UPDATE, abi.encode(rcau), 0); + } + // ══════════════════════════════════════════════════════════════════════ // Gap 22 / 23 — Callback-gas prechecks (deterministic single-call) // @@ -1225,11 +1313,14 @@ contract RecurringCollectorCoverageGapsTest is RecurringCollectorSharedTest { maxOngoingTokensPerSecond: 1 ether, minSecondsPerCollection: 600, maxSecondsPerCollection: 3600, - conditions: 0, // no eligibility — skip first precheck + conditions: 0, nonce: 1, metadata: "" }) ); + // sensibleRCA zeroes conditions unconditionally; opt into agreement-owner callbacks + // (without eligibility) so the beforeCollection precheck is the first to fire. + rca.conditions = 2; // CONDITION_AGREEMENT_OWNER vm.prank(address(approver)); _recurringCollector.offer(OFFER_TYPE_NEW, abi.encode(rca), 0); diff --git a/packages/interfaces/contracts/horizon/IAgreementOwner.sol b/packages/interfaces/contracts/horizon/IAgreementOwner.sol index 03750789d..88d74b513 100644 --- a/packages/interfaces/contracts/horizon/IAgreementOwner.sol +++ b/packages/interfaces/contracts/horizon/IAgreementOwner.sol @@ -4,8 +4,12 @@ pragma solidity ^0.8.22; /** * @title Interface for contract payer callbacks from RecurringCollector * @author Edge & Node - * @notice Callbacks that RecurringCollector invokes on contract payers (payers with - * deployed code, as opposed to EOA payers that use ECDSA signatures). + * @notice Callbacks that RecurringCollector invokes on contract payers that opt in + * via the CONDITION_AGREEMENT_OWNER offer condition. + * + * @dev Opt-in is enforced at acceptance: an offer that sets CONDITION_AGREEMENT_OWNER + * is only acceptable if the payer reports support for this interface via ERC-165 + * (`supportsInterface(type(IAgreementOwner).interfaceId)` returns true). * * Collection callbacks: * - {beforeCollection}: called before PaymentsEscrow.collect() so the payer can top up diff --git a/packages/interfaces/contracts/horizon/IRecurringCollector.sol b/packages/interfaces/contracts/horizon/IRecurringCollector.sol index 87d48d437..18f89f00b 100644 --- a/packages/interfaces/contracts/horizon/IRecurringCollector.sol +++ b/packages/interfaces/contracts/horizon/IRecurringCollector.sol @@ -50,7 +50,8 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection - * @param conditions Bitmask of payer-declared conditions (e.g. CONDITION_ELIGIBILITY_CHECK) + * @param conditions Bitmask of payer-declared conditions + * (e.g. CONDITION_ELIGIBILITY_CHECK, CONDITION_AGREEMENT_OWNER) * @param nonce A unique nonce for preventing collisions (user-chosen) * @param metadata Arbitrary metadata to extend functionality if a data service requires it * @@ -82,7 +83,8 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { * except for the first collection * @param minSecondsPerCollection The minimum amount of seconds that must pass between collections * @param maxSecondsPerCollection The maximum seconds of service that can be collected in a single collection - * @param conditions Bitmask of payer-declared conditions (e.g. CONDITION_ELIGIBILITY_CHECK) + * @param conditions Bitmask of payer-declared conditions + * (e.g. CONDITION_ELIGIBILITY_CHECK, CONDITION_AGREEMENT_OWNER) * @param nonce The nonce for preventing replay attacks (must be current nonce + 1) * @param metadata Arbitrary metadata to extend functionality if a data service requires it */ @@ -392,11 +394,12 @@ interface IRecurringCollector is IAuthorizable, IAgreementCollector { error RecurringCollectorCollectionNotEligible(bytes16 agreementId, address serviceProvider); /** - * @notice Thrown when an offer sets CONDITION_ELIGIBILITY_CHECK but the payer - * does not support IProviderEligibility (via ERC-165) + * @notice Thrown when an offer sets a condition flag whose corresponding + * interface is not declared by the payer (via ERC-165) * @param payer The payer address + * @param interfaceId The ERC-165 interface id the payer must declare for the set condition */ - error RecurringCollectorPayerDoesNotSupportEligibilityInterface(address payer); + error RecurringCollectorPayerDoesNotSupportInterface(address payer, bytes4 interfaceId); /** * @notice Thrown when the caller does not provide enough gas for the payer callback diff --git a/packages/issuance/audits/PR1301/TRST-L-10.md b/packages/issuance/audits/PR1301/TRST-L-10.md index 919cda91d..0eda2ba7a 100644 --- a/packages/issuance/audits/PR1301/TRST-L-10.md +++ b/packages/issuance/audits/PR1301/TRST-L-10.md @@ -21,6 +21,9 @@ TBD --- -Using `CONDITION_ELIGIBILITY_CHECK` for callback dispatch does not seem appropriate. The eligibility check is an agreement term, not a proxy for payer type and contract payers can legitimately offer agreements without this condition. The provider agreeing to the check requires greater trust in the payer. Gating callbacks on this flag would deny `beforeCollection`/`afterCollection` to contract payers for agreements without eligibility gating. +Reusing `CONDITION_ELIGIBILITY_CHECK` for callback dispatch avoided because the eligibility checking is a different concern with different trust assumptions. An agreement can legitimately have one without the other. -With the returndata bombing fix (TRST-M-4), the gas impact of an EIP-7702 EOA gaining callbacks is bounded and predictable. We do not believe this as a significant attack vector. The `beforeCollection`/`afterCollection` callbacks are non-reverting and non-blocking. A payer adding code via EIP-7702 to better handle escrow reconciliation could be a valid use case and in the best interests of all parties. +Introduced `CONDITION_AGREEMENT_OWNER` flag that mirrors the eligibility pattern: + +- `_requirePayerInterfaceSupport` validates `IERC165(payer).supportsInterface(type(IAgreementOwner).interfaceId)` if the flag is set, alongside the existing eligibility check. +- `_preCollectCallbacks` and `_postCollectCallback` dispatch on `agreement.conditions & CONDITION_AGREEMENT_OWNER`, replacing the `payer.code.length` check. diff --git a/packages/testing/test/harness/FullStackHarness.t.sol b/packages/testing/test/harness/FullStackHarness.t.sol index d095804f0..b02735288 100644 --- a/packages/testing/test/harness/FullStackHarness.t.sol +++ b/packages/testing/test/harness/FullStackHarness.t.sol @@ -391,6 +391,8 @@ abstract contract FullStackHarness is Test { // ── RAM agreement helpers ────────────────────────────────────────── /// @notice Build an RCA with RAM as payer, targeting a specific indexer + SS + /// @dev Sets CONDITION_AGREEMENT_OWNER (=2) so RAM receives beforeCollection / + /// afterCollection — JIT escrow top-up and reconciliation depend on these callbacks. function _buildRCA( IndexerSetup memory indexer, uint256 maxInitialTokens, @@ -410,7 +412,7 @@ abstract contract FullStackHarness is Test { minSecondsPerCollection: 60, maxSecondsPerCollection: maxSecondsPerCollection, nonce: 1, - conditions: 0, + conditions: 2, // CONDITION_AGREEMENT_OWNER metadata: abi.encode( IndexingAgreement.AcceptIndexingAgreementMetadata({ subgraphDeploymentId: indexer.subgraphDeploymentId, From 17466cfa516efa8e8b1db2b5fc5dc590455ce24f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 1 May 2026 12:57:42 +0000 Subject: [PATCH 157/157] chore(toolshed): bump to 1.2.1-dips.2 for collector audit-fix-3 constants --- packages/toolshed/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolshed/package.json b/packages/toolshed/package.json index 055d13936..375bb36ff 100644 --- a/packages/toolshed/package.json +++ b/packages/toolshed/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/toolshed", - "version": "1.2.1-dips.1", + "version": "1.2.1-dips.2", "publishConfig": { "access": "public" },

?v_DjzqNG-dHgz_|j?h6wY4lKKqVpt}10{bv^~gVb?(K z_%l6ZEF&llF3@YaHJ<5^{xp8Qes)6`2dPF)K%aXCF0pa{G`fSvo4w`9N2Ny}^l!IS z**QI;2*e+#tzUFQJTs}T*G!`0ZP9&1w^6$AVKrZGqG^=~VC@#dr$Vy&8PFl-pOTOCuM?(`EI{#%1f*IuDC@O_p1s$Gj)MZR zQjqZwT5D2K-y}_<98SV1fBs%i+R@&Z89mD#jy}hq@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 100644 --- a/packages/issuance/audits/PR1301/README.md +++ b/packages/issuance/audits/PR1301/README.md @@ -1,35 +1,53 @@ -# Trust Security Audit - PR #1301 +# Trust Security Audit - PR #1301 / #1312 **Auditor:** Trust Security **Period:** 2026-03-03 to 2026-03-19 **Commit:** 7405c9d5f73bce04734efb3f609b76d95ffb520e -**Report:** [Graph_PR1301_v01.pdf](Graph_PR1301_v01.pdf) +**Fix review commit:** 0bbb476f37f85d042927e84d8764fa58eb020ccf +**Report:** [Graph_PR1301_v02.pdf](Graph_PR1301_v02.pdf) ## Findings Summary -| ID | Title | Severity | -| ----------------------- | -------------------------------------------------------- | -------- | -| [TRST-H-1](TRST-H-1.md) | Malicious payer gas siphoning via 63/64 rule | High | -| [TRST-H-2](TRST-H-2.md) | Invalid supportsInterface() returndata escapes try/catch | High | -| [TRST-H-3](TRST-H-3.md) | Stale escrow snapshot causes perpetual revert loop | High | -| [TRST-H-4](TRST-H-4.md) | EOA payer can block collection via EIP-7702 | High | -| [TRST-M-1](TRST-M-1.md) | Micro-thaw griefing via permissionless depositTo() | Medium | -| [TRST-M-2](TRST-M-2.md) | tempJit fallback in beforeCollection() unreachable | Medium | -| [TRST-M-3](TRST-M-3.md) | Instant escrow mode degradation via agreement offer | Medium | -| [TRST-L-1](TRST-L-1.md) | Insufficient gas for afterCollection callback | Low | -| [TRST-L-2](TRST-L-2.md) | Pending update over-reserves escrow | Low | -| [TRST-L-3](TRST-L-3.md) | Unsafe approveAgreement behavior during pause | Low | -| [TRST-L-4](TRST-L-4.md) | Pair tracking removal blocked by 1 wei donation | Low | -| [TRST-L-5](TRST-L-5.md) | \_computeMaxFirstClaim overestimates near deadline | Low | +| ID | Title | Severity | Status | +| ------------------------- | -------------------------------------------------------- | -------- | ------------ | +| [TRST-H-1](TRST-H-1.md) | Malicious payer gas siphoning via 63/64 rule | High | Fixed | +| [TRST-H-2](TRST-H-2.md) | Invalid supportsInterface() returndata escapes try/catch | High | Fixed | +| [TRST-H-3](TRST-H-3.md) | Stale escrow snapshot causes perpetual revert loop | High | Fixed | +| [TRST-H-4](TRST-H-4.md) | EOA payer can block collection via EIP-7702 | High | Fixed | +| [TRST-M-1](TRST-M-1.md) | Micro-thaw griefing via permissionless depositTo() | Medium | Open | +| [TRST-M-2](TRST-M-2.md) | tempJit fallback in beforeCollection() unreachable | Medium | Fixed | +| [TRST-M-3](TRST-M-3.md) | Instant escrow mode degradation via agreement offer | Medium | Acknowledged | +| [TRST-M-4](TRST-M-4.md) | Returndata bombing via payer callbacks | Medium | Open | +| [TRST-M-5](TRST-M-5.md) | Perpetual thaw griefing via micro deposits | Medium | Open | +| [TRST-L-1](TRST-L-1.md) | Insufficient gas for afterCollection callback | Low | Fixed | +| [TRST-L-2](TRST-L-2.md) | Pending update over-reserves escrow | Low | Fixed | +| [TRST-L-3](TRST-L-3.md) | Unsafe approveAgreement behavior during pause | Low | Fixed | +| [TRST-L-4](TRST-L-4.md) | Pair tracking removal blocked by 1 wei donation | Low | Acknowledged | +| [TRST-L-5](TRST-L-5.md) | \_computeMaxFirstClaim overestimates near deadline | Low | Fixed | +| [TRST-L-6](TRST-L-6.md) | Update offer cleanup bypassed via planted offer | Low | Open | +| [TRST-L-7](TRST-L-7.md) | cancel() order sensitivity leaves RCAU offer unreachable | Low | Open | +| [TRST-L-8](TRST-L-8.md) | EOA payer signatures cannot be revoked before deadline | Low | Open | +| [TRST-L-9](TRST-L-9.md) | Callback gas precheck does not account for overhead | Low | Open | +| [TRST-L-10](TRST-L-10.md) | EIP-7702 payer code change enables callback gas griefing | Low | Open | +| [TRST-L-11](TRST-L-11.md) | Inaccurate state flags in getAgreementDetails() | Low | Open | ## Recommendations -| ID | Title | -| ----------------------- | ---------------------------------------------- | -| [TRST-R-1](TRST-R-1.md) | Avoid redeployment of RewardsEligibilityOracle | -| [TRST-R-2](TRST-R-2.md) | Improve stale documentation | -| [TRST-R-3](TRST-R-3.md) | Incorporate defensive coding best practices | -| [TRST-R-4](TRST-R-4.md) | Document critical assumptions in the RAM | +| ID | Title | +| ------------------------- | --------------------------------------------------------------- | +| [TRST-R-1](TRST-R-1.md) | Avoid redeployment of RewardsEligibilityOracle | +| [TRST-R-2](TRST-R-2.md) | Improve stale documentation | +| [TRST-R-3](TRST-R-3.md) | Incorporate defensive coding best practices | +| [TRST-R-4](TRST-R-4.md) | Document critical assumptions in the RAM | +| [TRST-R-5](TRST-R-5.md) | Ambiguous return value in getAgreementOfferAt() | +| [TRST-R-6](TRST-R-6.md) | Dead code guard in \_validateAndStoreUpdate() | +| [TRST-R-7](TRST-R-7.md) | Remove consumed offers in accept() and update() | +| [TRST-R-8](TRST-R-8.md) | Align pause documentation with callback behavior in the RAM | +| [TRST-R-9](TRST-R-9.md) | \_isAuthorized() override trusts itself for any authorizer | +| [TRST-R-10](TRST-R-10.md) | Document role-change semantics for existing agreements | +| [TRST-R-11](TRST-R-11.md) | Remove or implement unused state flags in IAgreementCollector | +| [TRST-R-12](TRST-R-12.md) | Document ACCEPTED state returned for cancelled agreements | +| [TRST-R-13](TRST-R-13.md) | Document reclaim reason change for stale allocation force-close | ## Centralization Risks diff --git a/packages/issuance/audits/PR1301/TRST-H-1.md b/packages/issuance/audits/PR1301/TRST-H-1.md index f250ee55c..7c15cd250 100644 --- a/packages/issuance/audits/PR1301/TRST-H-1.md +++ b/packages/issuance/audits/PR1301/TRST-H-1.md @@ -3,7 +3,7 @@ - **Severity:** High - **Category:** Gas-related issues - **Source:** RecurringCollector.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ Enforce a minimum gas reservation before each callback. Before calling `beforeCo ## Team Response -TBD +Fixed. + +## Mitigation Review + +Issue has been fixed as suggested. --- diff --git a/packages/issuance/audits/PR1301/TRST-H-2.md b/packages/issuance/audits/PR1301/TRST-H-2.md index 0f2acbffa..3f8eea841 100644 --- a/packages/issuance/audits/PR1301/TRST-H-2.md +++ b/packages/issuance/audits/PR1301/TRST-H-2.md @@ -3,7 +3,7 @@ - **Severity:** High - **Category:** Logical flaws - **Source:** RecurringCollector.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ Avoid receiving and decoding values from untrusted contract calls. This can be d ## Team Response -TBD +Fixed. + +## Mitigation Review + +Fixed. The affected code has been refactored, addressing the issue. --- diff --git a/packages/issuance/audits/PR1301/TRST-H-3.md b/packages/issuance/audits/PR1301/TRST-H-3.md index 5fac18493..66bddea4d 100644 --- a/packages/issuance/audits/PR1301/TRST-H-3.md +++ b/packages/issuance/audits/PR1301/TRST-H-3.md @@ -3,7 +3,7 @@ - **Severity:** High - **Category:** Logical flaws - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -21,7 +21,11 @@ Read the fresh escrow balance inside `_escrowMinMax()` when computing the defici ## Team Response -TBD +Fixed. + +## Mitigation Review + +The new code has a `_setEscrowSnap()` call before `_escrowMinMax()`, ensuring the snapshot is updated and fixing the root cause. --- diff --git a/packages/issuance/audits/PR1301/TRST-H-4.md b/packages/issuance/audits/PR1301/TRST-H-4.md index 80b4c4195..dda0b4f17 100644 --- a/packages/issuance/audits/PR1301/TRST-H-4.md +++ b/packages/issuance/audits/PR1301/TRST-H-4.md @@ -3,7 +3,7 @@ - **Severity:** High - **Category:** Type confusion - **Source:** RecurringCollector.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -21,7 +21,11 @@ Record whether the payer had code at agreement acceptance time by adding a bool ## Team Response -TBD +Fixed. + +## Mitigation Review + +Fixed under the assumption that a provider setting `CONDITION_ELIGIBILITY_CHECK` to true must trust the payer contract. The statement in the fix comment that "An EOA cannot pass this check, so an EOA cannot create an agreement with eligibility gating enabled" is inaccurate, because an EOA can always change its code back and forth via EIP-7702 to pass interface checks. The correct security boundary is that the provider trusts the payer contract when opting into eligibility, not that the payer cannot be an EOA. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-1.md b/packages/issuance/audits/PR1301/TRST-L-1.md index 512e00e98..ed4cd9f11 100644 --- a/packages/issuance/audits/PR1301/TRST-L-1.md +++ b/packages/issuance/audits/PR1301/TRST-L-1.md @@ -3,7 +3,7 @@ - **Severity:** Low - **Category:** Time sensitivity flaw - **Source:** RecurringCollector.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ Enforce a minimum gas forwarding requirement for the `afterCollection()` callbac ## Team Response -TBD +Fixed. + +## Mitigation Review + +Fixed as suggested. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-10.md b/packages/issuance/audits/PR1301/TRST-L-10.md new file mode 100644 index 000000000..385b4ee0c --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-10.md @@ -0,0 +1,22 @@ +# TRST-L-10: EIP-7702 payer code change enables callback gas griefing after acceptance + +- **Severity:** Low +- **Category:** Type confusion +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +Under EIP-7702, which is live on Ethereum mainnet and Arbitrum, an EOA can install arbitrary code via a delegation transaction. `_preCollectCallbacks()` and `_postCollectCallback()` dispatch the `beforeCollection()` and `afterCollection()` callbacks only when `payer.code.length != 0`. A payer who accepted an agreement as an EOA can later acquire code, and have the callbacks dispatched against delegated code that the service provider never considered at acceptance time. + +The callbacks are low level calls with a `MAX_PAYER_CALLBACK_GAS` budget, and they are vulnerable to the returndata bombing vector described in TRST-M-4, on top of the baseline call costs. Service providers estimate gas for `collect()` under the assumption that the payer is an EOA with no callbacks. If the payer is a contract at collection time, the provider's gas estimate may be insufficient and the transaction will revert with griefed gas. This is a distinct attack surface from TRST-H-4, which targeted the eligibility gate rather than the callback path. + +## Recommended Mitigation + +Use the introduced `CONDITION_ELIGIBILITY_CHECK` flag in place of the live `code.length` check in `_preCollectCallbacks()` and `_postCollectCallback()`. This freezes the contract-versus-EOA determination to the state the service provider observed at acceptance. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-L-11.md b/packages/issuance/audits/PR1301/TRST-L-11.md new file mode 100644 index 000000000..ad0771c7e --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-11.md @@ -0,0 +1,26 @@ +# TRST-L-11: Inaccurate state flags returned by getAgreementDetails() and \_offerUpdate() + +- **Severity:** Low +- **Category:** Logical flaws +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +The `IAgreementCollector` interface defines state bit flags including `ACCEPTED` and `UPDATE`, with the documented convention that `UPDATE` is ORed into the state returned by `getAgreementDetails()` for pending versions (index 1). Two deviations from the specification were observed. + +First, in `_offerUpdate()` (lines 417 to 455), when an update is offered against an already accepted agreement, the returned `AgreementDetails` sets state to `REGISTERED | UPDATE` without ORing `ACCEPTED`. Callers that inspect the returned state to determine whether the agreement is already live will misread the underlying agreement as not accepted. + +Second, in `getAgreementDetails()` (lines 500 to 528), the `UPDATE` bit is never ORed into the returned state for the pending version path. The interface documentation promises this behavior for pending versions, but the implementation returns `REGISTERED` or `ACCEPTED` without regard to whether an RCAU offer is pending. + +Neither deviation changes on-chain accounting, but integrators relying on the declared state semantics will receive misleading data. + +## Recommended Mitigation + +In `_offerUpdate()`, OR the `ACCEPTED` bit into state when the underlying agreement is in the Accepted state. In `getAgreementDetails()`, OR the `UPDATE` bit into the returned state when a pending RCAU offer exists for the agreement. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-L-2.md b/packages/issuance/audits/PR1301/TRST-L-2.md index 3fd0d45e4..f3eee05c5 100644 --- a/packages/issuance/audits/PR1301/TRST-L-2.md +++ b/packages/issuance/audits/PR1301/TRST-L-2.md @@ -3,7 +3,7 @@ - **Severity:** Low - **Category:** Arithmetic issues - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ The `pendingMaxNextClaim` should be computed as stated above, then reduced by th ## Team Response -TBD +Fixed. + +## Mitigation Review + +Refactored so that at any point, the accurate worst-case collection is reflected. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-3.md b/packages/issuance/audits/PR1301/TRST-L-3.md index ff8edd1a8..92a21e7e4 100644 --- a/packages/issuance/audits/PR1301/TRST-L-3.md +++ b/packages/issuance/audits/PR1301/TRST-L-3.md @@ -3,7 +3,7 @@ - **Severity:** Low - **Category:** Access control issues - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ Add a pause check to `approveAgreement()` that returns `bytes4(0)` when the cont ## Team Response -TBD +Fixed. + +## Mitigation Review + +Fixed. Underlying code has been refactored, addressing the issue. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-4.md b/packages/issuance/audits/PR1301/TRST-L-4.md index 71ea33109..4df8bbef9 100644 --- a/packages/issuance/audits/PR1301/TRST-L-4.md +++ b/packages/issuance/audits/PR1301/TRST-L-4.md @@ -3,7 +3,7 @@ - **Severity:** Low - **Category:** Donation attacks - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Acknowledged ## Description @@ -19,7 +19,7 @@ In `_reconcilePairTracking()`, base the removal decision on `pairAgreementCount` ## Team Response -TBD +Accepted limitation. Orphaned tracking entries do not affect correctness or funds safety. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-5.md b/packages/issuance/audits/PR1301/TRST-L-5.md index 812ac5c35..2533503e0 100644 --- a/packages/issuance/audits/PR1301/TRST-L-5.md +++ b/packages/issuance/audits/PR1301/TRST-L-5.md @@ -3,7 +3,7 @@ - **Severity:** Low - **Category:** Logical flaw - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ Align `_computeMaxFirstClaim()` with the RecurringCollector's `getMaxNextClaim() ## Team Response -TBD +Fixed. + +## Mitigation Review + +Fixed. The RecurringCollector now calculates the effective window correctly. --- diff --git a/packages/issuance/audits/PR1301/TRST-L-6.md b/packages/issuance/audits/PR1301/TRST-L-6.md new file mode 100644 index 000000000..c0792c908 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-6.md @@ -0,0 +1,24 @@ +# TRST-L-6: Update offer cleanup bypassed via planted offer matching active terms + +- **Severity:** Low +- **Category:** Logical flaws +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +In `_validateAndStoreUpdate()` (lines 854-858), cleanup of stored offers after an update uses an if / else if chain keyed on the prior `activeTermsHash`. The first branch deletes a matching entry from `rcaOffers`; the second deletes a matching entry from `rcauOffers`. + +A payer who observes a pending update can call `offer()` with `OFFER_TYPE_NEW` and parameters that reproduce the agreement's currently active RCA terms. The resulting entry in `rcaOffers` hashes to the same `oldHash` value. When `update()` later reaches the cleanup block, the first branch matches and deletes the planted entry, and the else if branch that would have cleaned up the corresponding `rcauOffers` entry is skipped. The pending update offer is then orphaned in storage. + +The `updateNonce` check elsewhere in `_validateAndStoreUpdate()` prevents the orphaned RCAU from being re-accepted, so the issue does not translate to a direct economic exploit. However, it introduces a divergence between the documented invariant that replaced offers are cleaned up and the actual storage state, which could surface as a correctness issue in future features that rely on offer presence. + +## Recommended Mitigation + +Delete both `rcaOffers[agreementId]` and `rcauOffers[agreementId]` unconditionally at the end of `_validateAndStoreUpdate()`. After a successful update the agreement's active terms have changed and any pre-existing offer entries for the same `agreementId` are stale by definition. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-L-7.md b/packages/issuance/audits/PR1301/TRST-L-7.md new file mode 100644 index 000000000..1eee39005 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-7.md @@ -0,0 +1,22 @@ +# TRST-L-7: The cancel() function order sensitivity leaves RCAU offer unreachable + +- **Severity:** Low +- **Category:** Time-sensitivity issues +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +When a payer has both a pending RCA offer and a pending RCAU offer for the same `agreementId` and neither has been accepted, the order of cancellations matters. The `cancel()` overload that takes a terms hash delegates authorization to `_requirePayer()` (lines 480-497), which first checks the accepted agreement's payer and then the stored `rcaOffers` entry's payer. It does not fall back to `rcauOffers`. + +If the payer first cancels the RCA offer under `SCOPE_PENDING`, the entry in `rcaOffers` is deleted. A subsequent attempt to cancel the RCAU offer then fails: `_requirePayer()` finds no accepted agreement and no RCA offer, and reverts with `RecurringCollectorAgreementNotFound`. The orphaned RCAU offer remains in storage and unreachable by the payer. If the same parameters are later re-used to offer a new RCA, the orphaned RCAU is associated with it. The `updateNonce` check prevents immediate acceptance of the stale RCAU, but the payer has lost the ability to clean up state they own. + +## Recommended Mitigation + +Extend `_requirePayer()` to also check `rcauOffers` for a payer match when neither an accepted agreement nor an RCA offer is present. Alternatively, enforce symmetric cleanup so that deleting an RCA offer under `SCOPE_PENDING` also deletes any `rcauOffers` entry with the same `agreementId`. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-L-8.md b/packages/issuance/audits/PR1301/TRST-L-8.md new file mode 100644 index 000000000..90911d2d3 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-8.md @@ -0,0 +1,22 @@ +# TRST-L-8: EOA payer signatures cannot be revoked before deadline + +- **Severity:** Low +- **Category:** Functionality flaws +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +Payers approve agreements through two paths: an ECDSA signature consumed by `accept()` or `update()`, and a stored offer placed by a contract payer via `offer()` and consumed against the stored hash. Contract payers can revoke a pending offer by calling `cancel()` with `SCOPE_PENDING`, which deletes the matching entry from `rcaOffers` or `rcauOffers`. + +EOA payers have no equivalent revocation path. Once an RCA or RCAU has been signed, the signature is accepted by the collector at any time before the `deadline` field expires. A payer that wishes to cancel a signature-based offer before the deadline (for example, to renegotiate terms) has no mechanism to do so. The only remaining option to ensure no duplicate agreement risk is to wait out the deadline (and hope their unintended offer is not matched), or to revoke the signer via the Authorizable thawing and revocation flow, which affects all agreements authorized by that signer rather than an individual offer. + +## Recommended Mitigation + +Expose a `cancelSignature(bytes32 hash)` entry point that records the hash as invalidated on-chain, and have `_requireAuthorization()` reject any hash that has been invalidated. Alternatively, use a per-signer nonce that the payer can bump to invalidate all outstanding signatures for that signer. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-L-9.md b/packages/issuance/audits/PR1301/TRST-L-9.md new file mode 100644 index 000000000..d53f195b7 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-L-9.md @@ -0,0 +1,22 @@ +# TRST-L-9: Callback gas precheck does not account for intermediate overhead + +- **Severity:** Low +- **Category:** Gas-related issues +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +Both `_preCollectCallbacks()` and `_postCollectCallback()` guard each payer callback with a precheck of the form `if (gasleft() < (MAX_PAYER_CALLBACK_GAS * 64) / 63) revert`. The intent is to ensure that `MAX_PAYER_CALLBACK_GAS` remains available to the callee after applying the EIP-150 63/64 rule. + +However, the precheck is performed before the CALL or STATICCALL opcode itself, and additional gas is consumed between the comparison and the opcode: local Solidity operations, stack and memory setup, calldata encoding, and the fixed cost of the CALL or STATICCALL instruction. The actual gas forwarded to the callee can fall below `MAX_PAYER_CALLBACK_GAS`. An honest callee may perform incorrect logic under the assumption of available gas. One can refer to Optimism's CrossDomainMessenger, which adds explicit buffer constants (`RELAY_GAS_CHECK_BUFFER` and `RELAY_CALL_OVERHEAD`) for this exact reason. + +## Recommended Mitigation + +Add explicit buffer constants to the precheck so that the comparison accounts for the CALL/STATICCALL cost and the intervening Solidity overhead. Size the buffer so that at least `MAX_PAYER_CALLBACK_GAS` is forwarded to the callee when the check passes. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-M-1.md b/packages/issuance/audits/PR1301/TRST-M-1.md index 6ff77952f..6b10edb96 100644 --- a/packages/issuance/audits/PR1301/TRST-M-1.md +++ b/packages/issuance/audits/PR1301/TRST-M-1.md @@ -23,7 +23,11 @@ Add a minimum thaw threshold in `_updateEscrow()`. Amounts below the threshold s ## Team Response -TBD +Fixed. + +## Mitigation Review + +The griefing path remains reachable. Before any agreement is offered, a 1 wei donation to the (collector, provider) escrow account, followed by a permissionless call to `_reconcilePairTracking()` reaches `_updateEscrow()` with min and max at zero, and the thaw threshold is also at zero. Any positive excess passes the `thawThreshold <= excess` check, causing an `adjustThaw(thawTarget = 1)`. The same sequence also occurs after the final collection of an agreement, when `sumMaxNextClaim` transitions to zero via `afterCollection()` -> `_reconcileAndUpdateEscrow()` -> `_reconcileAgreement()`. There should be a nominal, non-negligible minimum thaw amount on top of the fraction check, applied in both `_reconcileProviderEscrow()` and `_withdrawAndRebalance()`. When `escrowBasis` is JustInTime, override the nominal skip so that dust can still be thawed out for solvency. --- diff --git a/packages/issuance/audits/PR1301/TRST-M-2.md b/packages/issuance/audits/PR1301/TRST-M-2.md index 9fc633fa5..df5ca47c6 100644 --- a/packages/issuance/audits/PR1301/TRST-M-2.md +++ b/packages/issuance/audits/PR1301/TRST-M-2.md @@ -3,7 +3,7 @@ - **Severity:** Medium - **Category:** Logical flaw - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Fixed ## Description @@ -19,7 +19,11 @@ The original intention cannot be truly fulfilled without major redesign of multi ## Team Response -TBD +Fixed. + +## Mitigation Review + +The new setup is schematically sound. Admin intervention to trigger JustInTime may still be required to satisfy requests when the system is in OnDemand but insufficient liquidity is being thawed or minted into the contract. --- diff --git a/packages/issuance/audits/PR1301/TRST-M-3.md b/packages/issuance/audits/PR1301/TRST-M-3.md index ea3c6f7da..7654bbe6c 100644 --- a/packages/issuance/audits/PR1301/TRST-M-3.md +++ b/packages/issuance/audits/PR1301/TRST-M-3.md @@ -3,7 +3,7 @@ - **Severity:** Medium - **Category:** Logical flaw - **Source:** RecurringAgreementManager.sol -- **Status:** Open +- **Status:** Acknowledged ## Description @@ -19,7 +19,7 @@ Add a separate configuration flag (e.g., `allowModeDegradation`) that must be ex ## Team Response -TBD +Acknowledged. The risk is documented, including the operator caution about pre-offer headroom checks. --- diff --git a/packages/issuance/audits/PR1301/TRST-M-4.md b/packages/issuance/audits/PR1301/TRST-M-4.md new file mode 100644 index 000000000..4da7a926a --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-M-4.md @@ -0,0 +1,24 @@ +# TRST-M-4: Returndata bombing via payer callbacks in \_preCollectCallbacks and \_postCollectCallback + +- **Severity:** Medium +- **Category:** Gas-related issues +- **Source:** RecurringCollector.sol +- **Status:** Open + +## Description + +All three payer callbacks reachable from `_collect()` (the eligibility staticcall in `_preCollectCallbacks()` at line 633, the `beforeCollection()` call in the same function at line 646, and the `afterCollection()` call in `_postCollectCallback()` at line 666) use Solidity's default low-level call pattern, which copies the full returndata buffer into the caller's memory. Note that RETURNDATACOPY is emitted even when the returned bytes are discarded via the `(bool ok, )` tuple pattern. + +With a forwarded budget of `MAX_PAYER_CALLBACK_GAS` (1,500,000) per callback, a malicious payer can expand callee memory and return roughly 850 KB of data. The caller's RETURNDATACOPY and the associated memory expansion then consume approximately 1,500,000 gas in the `_collect()` frame for each callback. Across the three callbacks, a single `collect()` call can be forced to burn about 4,500,000 gas beyond the nominal callback budget. + +The impact is an inflated collection cost that is not reflected in off-chain gas estimates. This is gas griefing rather than a collection block, and gas costs remain manageable. + +## Recommended Mitigation + +Replace the affected high-level call sites with inline assembly that performs the call and bounds the amount of returndata copied. For the eligibility check, copy at most 32 bytes into scratch memory and read the result. For `beforeCollection()` and `afterCollection()`, copy zero bytes since the return value is unused. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-M-5.md b/packages/issuance/audits/PR1301/TRST-M-5.md new file mode 100644 index 000000000..34890fba2 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-M-5.md @@ -0,0 +1,24 @@ +# TRST-M-5: Perpetual thaw griefing via micro deposits in \_reconcileProviderEscrow + +- **Severity:** Medium +- **Category:** Griefing attacks +- **Source:** RecurringAgreementManager.sol +- **Status:** Open + +## Description + +The `_reconcileProviderEscrow()` and symmetrically `_withdrawAndRebalance()` functions compare the escrow excess against a fraction-based threshold derived from `sumMaxNextClaim`. The check is structured as `thawThreshold <= excess`, which permits a thaw whenever the cumulative excess is at least the threshold. Because the threshold is keyed on `sumMaxNextClaim` and not on the amount being added to `thawingTarget` in the current round, the check behaves like a one-time gate rather than a per-round qualifier. + +An attacker can grief the RAM in two phases. First, they make a single non-negligible donation via the permissionless `PaymentsEscrow.depositTo()` that pushes the escrow balance for a (collector, provider) pair above `initial_excess > thawThreshold`. This bootstrap round costs the attacker an amount on the order of the threshold and triggers the initial `adjustThaw()` call, starting the thaw timer with `thawingTarget = initial_excess`. Second, the attacker repeatedly donates 1 wei and triggers reconciliation. The bootstrap excess is still present, so `excess > thawThreshold` continues to hold. Each round passes the check, calls `adjustThaw()` with `thawingTarget` incremented by 1 wei, and resets the thaw timer. Legitimate larger thaws issued by the RAM while the griefing is active are blocked for the duration of the thawing period because the timer keeps resetting. + +The per-round cost to the attacker after the bootstrap is 1 wei plus gas. The griefing causes spurious thaws, consumes gas on every reconciliation, and interacts with `PaymentsEscrow.adjustThaw()` timer semantics to indefinitely delay legitimate thaws for the targeted pair. + +## Recommended Mitigation + +Gate the check on the incremental amount being added to `thawingTarget` in the current round rather than on the cumulative excess over the maximum. A round should only pass the threshold check when the new delta to `thawingTarget` is non-trivial. Combine this with an absolute nominal minimum thaw amount applied in both `_reconcileProviderEscrow()` and `_withdrawAndRebalance()` so that sub-nominal dust increments cannot reset the thaw timer even after the bootstrap. + +## Team Response + +TBD + +--- diff --git a/packages/issuance/audits/PR1301/TRST-R-10.md b/packages/issuance/audits/PR1301/TRST-R-10.md new file mode 100644 index 000000000..219698e5f --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-10.md @@ -0,0 +1,7 @@ +# TRST-R-10: Document role-change semantics for existing agreements + +- **Severity:** Recommendation + +## Description + +Changes to `DATA_SERVICE_ROLE` and `COLLECTOR_ROLE` on the RecurringAgreementManager do not affect agreements that have already been offered or accepted through the previously authorized addresses. This is by design (revoking a role should not invalidate settled obligations), but the behavior is not documented. Record this invariant in the RAM documentation so that operators and integrators understand the effect of role changes. diff --git a/packages/issuance/audits/PR1301/TRST-R-11.md b/packages/issuance/audits/PR1301/TRST-R-11.md new file mode 100644 index 000000000..014f20625 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-11.md @@ -0,0 +1,7 @@ +# TRST-R-11: Remove or implement unused state flags in IAgreementCollector + +- **Severity:** Recommendation + +## Description + +`IAgreementCollector` defines state flag constants that are not currently used in the RecurringCollector implementation, including `NOTICE_GIVEN`, `SETTLED`, `BY_PAYER`, `BY_PROVIDER`, `BY_DATA_SERVICE`, `AUTO_UPDATE`, and `AUTO_UPDATED`. Unused public interface constants are a source of confusion for integrators, who may code against documented semantics that the implementation does not honor. Either remove the unused flags from the interface, or implement the behaviors they describe in the collector. diff --git a/packages/issuance/audits/PR1301/TRST-R-12.md b/packages/issuance/audits/PR1301/TRST-R-12.md new file mode 100644 index 000000000..a73ed9648 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-12.md @@ -0,0 +1,7 @@ +# TRST-R-12: Document ACCEPTED state returned for cancelled agreements + +- **Severity:** Recommendation + +## Description + +In `getAgreementDetails()`, any agreement whose state is not `AgreementState.NotAccepted` is reported with state flag `ACCEPTED`. This includes agreements that have been cancelled (`CanceledByPayer` or `CanceledByServiceProvider`). Integrators inspecting the returned state cannot distinguish cancelled agreements from live ones without reading separate storage. Document this behavior in the interface, or extend the state bitmask with a `CANCELED` flag and return it for the non-active terminal states. diff --git a/packages/issuance/audits/PR1301/TRST-R-13.md b/packages/issuance/audits/PR1301/TRST-R-13.md new file mode 100644 index 000000000..6b9b090c0 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-13.md @@ -0,0 +1,7 @@ +# TRST-R-13: Document reclaim reason change for stale allocation force-close + +- **Severity:** Recommendation + +## Description + +Before the PR's refactor, `forceCloseStaleAllocation()` closed the allocation via `_closeAllocation()` and caused a reclaim with reason `CLOSE_ALLOCATION`. Post refactor, the force close path goes through `_resizeAllocation(allocationId, 0, ...)`, which triggers a reclaim with reason `STALE_POI` instead. The reclaim still occurs, but the reason code exposed to reclaim address configuration changes. Document this change so that operators are able to prepare accordingly and have funding paths line up with intention. diff --git a/packages/issuance/audits/PR1301/TRST-R-5.md b/packages/issuance/audits/PR1301/TRST-R-5.md new file mode 100644 index 000000000..f3d5ac72e --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-5.md @@ -0,0 +1,7 @@ +# TRST-R-5: Ambiguous return value in getAgreementOfferAt() + +- **Severity:** Recommendation + +## Description + +`getAgreementOfferAt()` returns `(uint8 offerType, bytes memory offerData)`. The offer type constant `OFFER_TYPE_NEW` is defined as 0, which is also the default Solidity return value when no stored offer exists for the given `agreementId` and index. A caller receiving `offerType == 0` cannot distinguish between a stored new-type offer existing and no offer existing. Consider redefining offer type constants with 1-indexed values, or adding an explicit `bool found` return parameter. diff --git a/packages/issuance/audits/PR1301/TRST-R-6.md b/packages/issuance/audits/PR1301/TRST-R-6.md new file mode 100644 index 000000000..9fa653c5f --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-6.md @@ -0,0 +1,7 @@ +# TRST-R-6: Dead code guard in \_validateAndStoreUpdate() + +- **Severity:** Recommendation + +## Description + +In `_validateAndStoreUpdate()` (line 855), the guard `if (oldHash != bytes32(0))` is unreachable as a false branch. Only agreements in the Accepted state may be updated, and every accepted agreement has a non-zero `activeTermsHash` written during `accept()` or a prior `update()`. The guard can be removed or converted into an invariant comment documenting this assumption. diff --git a/packages/issuance/audits/PR1301/TRST-R-7.md b/packages/issuance/audits/PR1301/TRST-R-7.md new file mode 100644 index 000000000..903eaaea7 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-7.md @@ -0,0 +1,7 @@ +# TRST-R-7: Remove consumed offers in accept() and update() + +- **Severity:** Recommendation + +## Description + +After `accept()` or `update()` consumes a stored offer, the corresponding entry in `rcaOffers` or `rcauOffers` becomes stale. Currently only `_validateAndStoreUpdate()` cleans up the previously active offer by looking up the old `activeTermsHash`; the offer whose terms were just accepted is not deleted. This is a storage hygiene concern: stale offer entries remain in storage indefinitely until explicitly replaced or matched by a future update. Consider deleting the consumed offer entry inside `accept()` and `update()` after it has been applied. diff --git a/packages/issuance/audits/PR1301/TRST-R-8.md b/packages/issuance/audits/PR1301/TRST-R-8.md new file mode 100644 index 000000000..dd2ea9619 --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-8.md @@ -0,0 +1,7 @@ +# TRST-R-8: Align pause documentation with callback behavior in the RAM + +- **Severity:** Recommendation + +## Description + +The RecurringAgreementManager documentation header states that pausing the contract "stops all permissionless escrow management". In practice, the `whenNotPaused` modifier also applies to `beforeCollection()` and `afterCollection()`, so pause also halts the callback path used during `collect()`. Update the documentation to reflect that callbacks are affected, or narrow the modifier application so that behavior matches the prose. diff --git a/packages/issuance/audits/PR1301/TRST-R-9.md b/packages/issuance/audits/PR1301/TRST-R-9.md new file mode 100644 index 000000000..b78e271fe --- /dev/null +++ b/packages/issuance/audits/PR1301/TRST-R-9.md @@ -0,0 +1,7 @@ +# TRST-R-9: \_isAuthorized() override in RecurringCollector trusts itself for any authorizer + +- **Severity:** Recommendation + +## Description + +The `_isAuthorized(address authorizer, address signer)` override in RecurringCollector returns true whenever `signer == address(this)`, regardless of `authorizer`. This enables RecurringCollector to call `dataService.cancelIndexingAgreementByPayer()` on the payer's behalf. The semantics are safe in the current integration with SubgraphService, but they widen the trust surface: any future consumer that relies on `RecurringCollector.isAuthorized()` for access control will grant access when the signer is the collector itself. Consider tightening the override to scope trust to specific callers, or explicitly document the integration contract so it is not misapplied by future consumers. diff --git a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol index 0b5463cd4..3a8d0340f 100644 --- a/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol +++ b/packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol @@ -250,9 +250,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg // solhint-disable-next-line graph/func-name-mixedcase /// @notice An indexer whose provision drops below minimum should still be able /// to cancel their indexing agreement. Cancel is an exit path. - function test_SubgraphService_CancelIndexingAgreement_OK_WhenProvisionBelowMinimum( - Seed memory seed - ) public { + function test_SubgraphService_CancelIndexingAgreement_OK_WhenProvisionBelowMinimum(Seed memory seed) public { Context storage ctx = _newCtx(seed); IndexerState memory indexerState = _withIndexer(ctx); ( From 322d61372a54021d3f9f66b7eaa3ace098d80df8 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 15:48:12 +0000 Subject: [PATCH 083/157] chore: update arbitrumSepolia addresses and deployment metadata --- packages/horizon/addresses.json | 71 +++++++++++-- packages/issuance/addresses.json | 125 +++++++++++++++++++++-- packages/subgraph-service/addresses.json | 26 +++-- 3 files changed, 199 insertions(+), 23 deletions(-) diff --git a/packages/horizon/addresses.json b/packages/horizon/addresses.json index bc91b724c..f386a84a3 100644 --- a/packages/horizon/addresses.json +++ b/packages/horizon/addresses.json @@ -71,7 +71,18 @@ "address": "0x4b5D3Da463F7E076bb7CDF5030960bf123245681", "proxy": "transparent", "proxyAdmin": "0x36dFE73C38e0340C8925BA6a68aE706b74340156", - "implementation": "0x36a194135E41a556ad6F4Dbad6b7F8F0e884ba1d" + "implementation": "0x25cf4a6ccd1f829d346cfda69112cd66639aaaa8", + "implementationDeployment": { + "txHash": "0x38c2d58d65e7ba66779cc2c45a9348d6ecb8ecedf80703be5769a3259311db02", + "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca6950000000000000000000000000000000000000000000000000000000000002a30", + "bytecodeHash": "0xc422e0b089ad8479e55a9a768d5bbea929745c83067496ff60a8f47dc2a08d90", + "blockNumber": 258351112, + "timestamp": "2026-04-10T15:30:13.000Z", + "verified": "https://sepolia.arbiscan.io/address/0x25cf4a6ccd1f829d346cfda69112cd66639aaaa8#code" + }, + "proxyDeployment": { + "verified": "https://sepolia.arbiscan.io/address/0x4b5D3Da463F7E076bb7CDF5030960bf123245681#code" + } }, "Controller": { "address": "0x9DB3ee191681f092607035d9BDA6e59FbEaCa695" @@ -79,7 +90,18 @@ "L2Curation": { "address": "0xDe761f075200E75485F4358978FB4d1dC8644FD5", "proxy": "graph", - "implementation": "0xbC8F4355f346e47eef8A0DBFF4a58616ACf7DaCA" + "implementation": "0x42e7b4b418672e890b460ca5e83ff47ad5717f02", + "implementationDeployment": { + "txHash": "0x774d6402b982c6a04245715efa92d0d40d47bf06ba95f3e02bc3d2dea3cba409", + "argsData": "0x", + "bytecodeHash": "0xaad16b82ef09b39624235fcc47361da5bd2c6cb0f3926a4aa2d9d11f88a3e238", + "blockNumber": 258322205, + "timestamp": "2026-04-10T13:12:51.000Z", + "verified": "https://sepolia.arbiscan.io/address/0x42e7b4b418672e890b460ca5e83ff47ad5717f02#code" + }, + "proxyDeployment": { + "verified": "https://sepolia.arbiscan.io/address/0xDe761f075200E75485F4358978FB4d1dC8644FD5#code" + } }, "L2GNS": { "address": "0x3133948342F35b8699d8F94aeE064AbB76eDe965", @@ -92,22 +114,34 @@ "RewardsManager": { "address": "0x1F49caE7669086c8ba53CC35d1E9f80176d67E79", "proxy": "graph", - "implementation": "0x4946332c0743a848d66ae10efa65fa226d82bf2f", + "implementation": "0xeffc5bb9b46dfbda6f8b0f297d12880674a6717e", "proxyDeployment": { "verified": "https://sepolia.arbiscan.io/address/0x1F49caE7669086c8ba53CC35d1E9f80176d67E79#code" }, "implementationDeployment": { - "txHash": "0x48000c64255c968ae765263c4c57b228cc47645897e32fa998107606cf0c4a10", + "txHash": "0x9be5cd5335eec0ae8305d149f13d79ff4015d2327bbeed0a47d444e29fbbfd7a", "argsData": "0x", - "bytecodeHash": "0x9cee99fc8f8e3ed8ce5a804b519117743d62b42f3cb0b2fd7d9687ccc134bdc4", - "blockNumber": 250570693, - "timestamp": "2026-03-16T09:47:05.000Z" + "bytecodeHash": "0xd0cd3f4b7ce4ce4fe6ea8ee8ecd4e74bb683c64de2696c9e5ad7f74ef4c16f4e", + "blockNumber": 258336594, + "timestamp": "2026-04-10T14:19:51.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xeffc5bb9b46dfbda6f8b0f297d12880674a6717e#code" } }, "HorizonStaking": { "address": "0x865365C425f3A593Ffe698D9c4E6707D14d51e08", "proxy": "graph", - "implementation": "0x2AF6F51e119A79497C3A3FFf012B5889da489764" + "implementation": "0x2333c59d080c5641c804579165641d0162a7249b", + "implementationDeployment": { + "txHash": "0x0cb033e6595517c53daf5e0c736c9a8b49e92e830a894ac05f9fdd81acd6fcfb", + "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca695000000000000000000000000c24a3dac5d06d771f657a48b20ce1a671b78f26b", + "bytecodeHash": "0x4fcc568f70748b19c8a90480ea1521870bac358681074768388098ef263ed559", + "blockNumber": 258348283, + "timestamp": "2026-04-10T15:16:25.000Z", + "verified": "https://sepolia.arbiscan.io/address/0x2333c59d080c5641c804579165641d0162a7249b#code" + }, + "proxyDeployment": { + "verified": "https://sepolia.arbiscan.io/address/0x865365C425f3A593Ffe698D9c4E6707D14d51e08#code" + } }, "GraphTallyCollector": { "address": "0x382863e7B662027117449bd2c49285582bbBd21B" @@ -129,6 +163,27 @@ "address": "0xB24Ce0f8c18c4DdDa584A7EeC132F49C966813bb", "proxy": "graph", "implementation": "0x3C2eB5E561f70c0573E5f6c92358e988E32cb5eC" + }, + "RecurringCollector": { + "address": "0x0b18befc60455121ad66ae6e4a647955fcde3900", + "proxy": "transparent", + "proxyAdmin": "0x59d83d4bd5f880c5e635273e4fb12e0a8e827f1d", + "implementation": "0xf4f75d6e1021db1b83b8bccfefa1a0ea06989fa1", + "implementationDeployment": { + "txHash": "0x579640729801f30ddec1e85b7ae6b7b9c51cc2502c1d96a0b698dbb553a1dafa", + "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca6950000000000000000000000000000000000000000000000000000000000007080", + "bytecodeHash": "0xe475513d113bac487d6c2a5504f73e8c1a7962dd611aa981e09cf04ebb0c5486", + "blockNumber": 258348301, + "timestamp": "2026-04-10T15:16:30.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xf4f75d6e1021db1b83b8bccfefa1a0ea06989fa1#code" + }, + "proxyDeployment": { + "txHash": "0x6fb822cdafa22542bed36045d77705c1354770feed50d67ef69ecde1bf668e28", + "argsData": "0x000000000000000000000000763a83af638f1ea6a4033868bc24994f9bd62617000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c44cd88b76000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000012526563757272696e67436f6c6c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322094, + "verified": "https://sepolia.arbiscan.io/address/0x0b18befc60455121ad66ae6e4a647955fcde3900#code" + } } } } diff --git a/packages/issuance/addresses.json b/packages/issuance/addresses.json index cddcf9b96..28942d3e1 100644 --- a/packages/issuance/addresses.json +++ b/packages/issuance/addresses.json @@ -32,30 +32,139 @@ "address": "0x6ba849fbd33257162552578b2a432d30784f2f80", "proxy": "transparent", "proxyAdmin": "0xfd76b74d4da4ef5b9c2379b9c8dbd79575b0fdda", - "implementation": "0x24901750b48ad049b914f13e1855dc71ecf8397a", + "implementation": "0xd6f2acf352f655b72cc32a056edf7ca97ec3e9e4", "implementationDeployment": { - "txHash": "0xc2bdcd2b9d40f9932f231e04bae0a8248745ee1a3514851e5e25ee17ef5f1fa7", + "txHash": "0xbf484964670ce105ce4de7f97d3617dbccede17d6ab806174c49fa36c1483950", "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac04", "bytecodeHash": "0x8ff7d1a6e22cf7f074c4688d9c84394ee151531de3f219ceabf66f0386201412", - "blockNumber": 250569158 + "blockNumber": 258351189, + "timestamp": "2026-04-10T15:30:34.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xd6f2acf352f655b72cc32a056edf7ca97ec3e9e4#code" }, "proxyDeployment": { "txHash": "0xcf2995a0f7142be957a71da0bc3f63e93939d7442dcab8f549e7765585464ce1", "argsData": "0x00000000000000000000000024901750b48ad049b914f13e1855dc71ecf8397a00000000000000000000000072ee30d43fb5a90b3fe983156c5d2fbe6f6d07b300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de800000000000000000000000072ee30d43fb5a90b3fe983156c5d2fbe6f6d07b300000000000000000000000000000000000000000000000000000000", "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", - "blockNumber": 250569166 + "blockNumber": 250569166, + "verified": "https://sepolia.arbiscan.io/address/0x6ba849fbd33257162552578b2a432d30784f2f80#code" } }, "IssuanceAllocator": { "address": "0x76a0d75651d4db83f74ac502b86a0ae4e19ac38b", "proxy": "transparent", "proxyAdmin": "0x9a3e5bd36a72a6306c63dce573a8100992479bfa", - "implementation": "0x50782d395e32300f57f6446951cf6734ae22c68d", + "implementation": "0x96baa229e1a0bdb750330617876cb9f40d9c2632", "implementationDeployment": { - "txHash": "0x4cf7787b81d88786893c7aca5da193d9041c3272995f3c1cdd202d87919e47e6", + "txHash": "0x2175ca7acce3d792681391f98458190c7a1983d9222856ec28663a13df98577a", "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac04", - "bytecodeHash": "0x94b490cdb340cdf9f601e618fdb7e21608969ba1a0dee05a3b017efa4ad36ad0", - "blockNumber": 250574005 + "bytecodeHash": "0xf16079c15a15d3ae077bfadf40e4865fe5c73bb213486831e129b725a8554092", + "blockNumber": 258351131, + "timestamp": "2026-04-10T15:30:19.000Z", + "verified": "https://sepolia.arbiscan.io/address/0x96baa229e1a0bdb750330617876cb9f40d9c2632#code" + }, + "proxyDeployment": { + "txHash": "0xd633a88e947568883f1f38be269f63f061d764550ebae189402b11a376f7e973", + "argsData": "0x00000000000000000000000050782d395e32300f57f6446951cf6734ae22c68d00000000000000000000000072ee30d43fb5a90b3fe983156c5d2fbe6f6d07b300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de800000000000000000000000072ee30d43fb5a90b3fe983156c5d2fbe6f6d07b300000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 250574013, + "verified": "https://sepolia.arbiscan.io/address/0x76a0d75651d4db83f74ac502b86a0ae4e19ac38b#code" + } + }, + "DefaultAllocation": { + "address": "0xa0eab4367d753314840c09313a5c6d27174bd541", + "proxy": "transparent", + "proxyAdmin": "0x6b09a6fcef85b1df540c922af2c9b64847ff8ae6", + "implementation": "0xd5de0951759b8306226fa370a9ecca40a31aa2d3", + "proxyDeployment": { + "txHash": "0xde2ebe4a22d0b6473736cea55f335bb5debfc6086a4de4f7261d6b3d0ff6952a", + "argsData": "0x000000000000000000000000d5de0951759b8306226fa370a9ecca40a31aa2d3000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322247, + "verified": "https://sepolia.arbiscan.io/address/0xa0eab4367d753314840c09313a5c6d27174bd541#code" + } + }, + "ReclaimedRewards": { + "address": "0xe01bb1bba83d3d5b823877d85bc3ba9fd7835c6d", + "proxy": "transparent", + "proxyAdmin": "0xb2201d01a41c1afc76fa9e598f3c57b5733dc7dc", + "implementation": "0xd5de0951759b8306226fa370a9ecca40a31aa2d3", + "proxyDeployment": { + "txHash": "0x26a5e9dbce77a2b88906321c51505ae4ea8b570b5d86d161fa68753553eb23ee", + "argsData": "0x000000000000000000000000d5de0951759b8306226fa370a9ecca40a31aa2d3000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322261, + "verified": "https://sepolia.arbiscan.io/address/0xe01bb1bba83d3d5b823877d85bc3ba9fd7835c6d#code" + } + }, + "RecurringAgreementManager": { + "address": "0x590dbbbdb1b6261e39bcc1fe88bffc21c847a68e", + "proxy": "transparent", + "proxyAdmin": "0xc80b101a601d38b3f72e22c613fdafb594d82f2e", + "implementation": "0xcea9350703c07dc1a92516f472d4769092e26e21", + "implementationDeployment": { + "txHash": "0xd182846b059c7441dd76172a343d51185184a74a5a834e546a493429ef8096b1", + "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac040000000000000000000000004b5d3da463f7e076bb7cdf5030960bf123245681", + "bytecodeHash": "0x8d7d7208240cb7032d538818a2879ac2b6102267d80258c943469b16d7794d3f", + "blockNumber": 258351168, + "timestamp": "2026-04-10T15:30:28.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xcea9350703c07dc1a92516f472d4769092e26e21#code" + }, + "proxyDeployment": { + "txHash": "0x8b6a8b30950715a5be3c95159949a2dc2bf7368684022a8f305eb711c5667e85", + "argsData": "0x0000000000000000000000002b114f3a63715224c1b5722f17fd84b6417a794a000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322276, + "verified": "https://sepolia.arbiscan.io/address/0x590dbbbdb1b6261e39bcc1fe88bffc21c847a68e#code" + } + }, + "RewardsEligibilityOracleB": { + "address": "0xcc70eae4001b36029fecb285ba6e8bbfd753e3da", + "proxy": "transparent", + "proxyAdmin": "0x6bbf45ff96b1acfbb04645c42783d8115c4befde", + "implementation": "0x35150110d11199e746fc1529f1647f162fb6c785", + "implementationDeployment": { + "txHash": "0xc60d3032c9c4825115e4d7432784dcf69e2c59557bae4607165a416b59792a35", + "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac04", + "bytecodeHash": "0x8ff7d1a6e22cf7f074c4688d9c84394ee151531de3f219ceabf66f0386201412", + "blockNumber": 258351208, + "timestamp": "2026-04-10T15:30:40.000Z", + "verified": "https://sepolia.arbiscan.io/address/0x35150110d11199e746fc1529f1647f162fb6c785#code" + }, + "proxyDeployment": { + "txHash": "0xccaf5e98ca9b1112ef332119c5ad2830d4b7d951d1ba4319f6fb3538dff4eff1", + "argsData": "0x000000000000000000000000b23e0463b930523ff34b32b28f32ff0484a8e0dc000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322322, + "verified": "https://sepolia.arbiscan.io/address/0xcc70eae4001b36029fecb285ba6e8bbfd753e3da#code" + } + }, + "RewardsEligibilityOracleMock": { + "address": "0x69b0f3c6a19beaf1ba59405f7179e188c64b4e06", + "proxy": "transparent", + "proxyAdmin": "0xca303d77c53c1e8aaec32d1a81e5a359ea2bb308", + "implementation": "0xa9336216cd501c554c76f1dcd85b90e84ebbf972", + "implementationDeployment": { + "txHash": "0x7c12fea73aac7421b49f41508ef87f9c542e7fa7001152850a57d63797e94109", + "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac04", + "bytecodeHash": "0x7048d139b92b2e2638c66eca026737eddd064e85ebf20e0438bdef81232ea320", + "blockNumber": 258351227, + "timestamp": "2026-04-10T15:30:46.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xa9336216cd501c554c76f1dcd85b90e84ebbf972#code" + }, + "proxyDeployment": { + "txHash": "0xff444e8f13200eed55e7499b4cbdf4d4363f3e6db2c9913bc19ee5b0abbf75ec", + "argsData": "0x0000000000000000000000009e67aff526f1446455cc3e154c813100048c0ee5000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000ade6b8eb69a49b56929c1d4f4b428d791861db6f00000000000000000000000000000000000000000000000000000000", + "bytecodeHash": "0x6b4ba3015667741610274b7c196ec5d7767235d85865912f7ac680eac3011c54", + "blockNumber": 258322343, + "verified": "https://sepolia.arbiscan.io/address/0x69b0f3c6a19beaf1ba59405f7179e188c64b4e06#code" + } + }, + "DirectAllocation_Implementation": { + "address": "0xd5de0951759b8306226fa370a9ecca40a31aa2d3", + "deployment": { + "txHash": "", + "argsData": "0x000000000000000000000000f8c05dcf59e8b28bfd5eed176c562bebcfc7ac04", + "bytecodeHash": "0xf11b102de39fbe66879f57214393c7ff7438e050f77802e2c08c71a000002003" } } } diff --git a/packages/subgraph-service/addresses.json b/packages/subgraph-service/addresses.json index bffbb167c..60a90dec8 100644 --- a/packages/subgraph-service/addresses.json +++ b/packages/subgraph-service/addresses.json @@ -37,13 +37,14 @@ "address": "0xc24A3dAC5d06d771f657A48B20cE1a671B78f26b", "proxy": "transparent", "proxyAdmin": "0x15737D9f8635cAcd43e110327c930bd5EC1fe098", - "implementation": "0x1e91024a6afc5a6c5cdd3caff900120ac90ae420", + "implementation": "0xe549fe68aab5a251f2b76c325c497461ec244bd9", "implementationDeployment": { - "txHash": "0xef8fd7c012cc9d304e118bca035562fbef92aff23252b5b16704dac8b558aa63", - "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca69500000000000000000000000096e1b86b2739e8a3d59f40f2532cadf9ce8da088000000000000000000000000382863e7b662027117449bd2c49285582bbbd21b000000000000000000000000de761f075200e75485f4358978fb4d1dc8644fd5", - "bytecodeHash": "0x6a936cfc4845d1fefa610aff4f060592a4a0ceb41232c368a089a5aa21efb957", - "blockNumber": 246430101, - "timestamp": "2026-03-02T20:38:09.000Z" + "txHash": "0xcea5fab7372ecbb7d3810d5b01f347b6da71e1a52eacb625dd76385099f8e0ea", + "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca69500000000000000000000000096e1b86b2739e8a3d59f40f2532cadf9ce8da088000000000000000000000000382863e7b662027117449bd2c49285582bbbd21b000000000000000000000000de761f075200e75485f4358978fb4d1dc8644fd50000000000000000000000000b18befc60455121ad66ae6e4a647955fcde3900", + "bytecodeHash": "0x8d08acc2dc16818f457d86cdf7bf86d1903a3786cd3f4ec430239dd553473926", + "blockNumber": 258351073, + "timestamp": "2026-04-10T15:30:03.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xe549fe68aab5a251f2b76c325c497461ec244bd9#code" }, "proxyDeployment": { "verified": "https://sepolia.arbiscan.io/address/0xc24A3dAC5d06d771f657A48B20cE1a671B78f26b#code" @@ -53,7 +54,18 @@ "address": "0x96e1b86b2739e8A3d59F40F2532caDF9cE8Da088", "proxy": "transparent", "proxyAdmin": "0x154a73CB6ebB5717a15f203d6E160E6F41ecC527", - "implementation": "0x28A0cFDE10e8Ea5C7f3E80981728E3eA1228D338" + "implementation": "0xa2016b450af51c356295388ba944f1396ae0ab35", + "implementationDeployment": { + "txHash": "0xb81c006bdfe70d834309bf6bbc32ba8b659508ab4a8283f99c41af52b6933a45", + "argsData": "0x0000000000000000000000009db3ee191681f092607035d9bda6e59fbeaca695", + "bytecodeHash": "0xff6852f3bcaeb2e092067b1c8239a93f36d945f0bbca82cb721d65b5a953ab25", + "blockNumber": 258351091, + "timestamp": "2026-04-10T15:30:08.000Z", + "verified": "https://sepolia.arbiscan.io/address/0xa2016b450af51c356295388ba944f1396ae0ab35#code" + }, + "proxyDeployment": { + "verified": "https://sepolia.arbiscan.io/address/0x96e1b86b2739e8A3d59F40F2532caDF9cE8Da088#code" + } }, "L2Curation": { "address": "0xDe761f075200E75485F4358978FB4d1dC8644FD5", From 0a2933018c2e641d0feea141c7b2fd2e1d7461a7 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 20:46:45 +0000 Subject: [PATCH 084/157] fix(deployment): register governor as rocketh named account for local/test TX signing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deploy scripts that send TXs as the protocol governor (e.g. RC setPauseGuardian) need a signer in rocketh's addressSigners map. Only named accounts get registered, so the governor address (mnemonic index 1) was missing — causing a TypeError in tx(). - Add `governor: { default: 1 }` named account in rocketh config - Use named account reference in RC configure script (avoids address case mismatch) - Add consistency assertion in canSignAsGovernor() — fails fast if the named account diverges from Controller.getGovernor() on-chain - Add localNetwork.json5 config for GIP-0088 local deployment testing --- packages/deployment/config/localNetwork.json5 | 16 ++++++++++++++++ .../horizon/recurring-collector/04_configure.ts | 4 ++-- packages/deployment/lib/controller-utils.ts | 13 +++++++++++++ packages/deployment/lib/deploy-implementation.ts | 4 +++- packages/deployment/lib/issuance-deploy-utils.ts | 7 ++++--- packages/deployment/lib/sync-utils.ts | 8 ++++---- packages/deployment/rocketh/config.ts | 10 ++++++++-- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 packages/deployment/config/localNetwork.json5 diff --git a/packages/deployment/config/localNetwork.json5 b/packages/deployment/config/localNetwork.json5 new file mode 100644 index 000000000..a90664653 --- /dev/null +++ b/packages/deployment/config/localNetwork.json5 @@ -0,0 +1,16 @@ +{ + // Deployment configuration for local-network (docker-compose dev stack) + // Local network uses generous rates for fast iteration and testing. + + "IssuanceAllocator": { + // RAM allocation: how much issuance flows to RecurringAgreementManager + // Local network uses a high rate so agreements accumulate meaningful rewards quickly + "ramAllocatorMintingGrtPerBlock": "6", + "ramSelfMintingGrtPerBlock": "0" + }, + + "RewardsManager": { + // Revert reward claims for ineligible indexers (strict mode for testing) + "revertOnIneligible": false + } +} diff --git a/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts b/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts index 0513c788f..023e95ef3 100644 --- a/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts +++ b/packages/deployment/deploy/horizon/recurring-collector/04_configure.ts @@ -41,7 +41,7 @@ export default createActionModule(Contracts.horizon.RecurringCollector, Deployme return } - const { governor, canSign } = await canSignAsGovernor(env) + const { canSign } = await canSignAsGovernor(env) if (!canSign) { env.showMessage(` ○ Pause guardian not set — will be configured in upgrade step (governance TX)\n`) return @@ -50,7 +50,7 @@ export default createActionModule(Contracts.horizon.RecurringCollector, Deployme env.showMessage('\n🔨 Setting pause guardian as governor...\n') const txFn = tx(env) await txFn({ - account: governor as `0x${string}`, + account: 'governor', to: rc.address as `0x${string}`, data: encodeFunctionData({ abi: RECURRING_COLLECTOR_PAUSE_ABI, diff --git a/packages/deployment/lib/controller-utils.ts b/packages/deployment/lib/controller-utils.ts index 5a058e9cc..4dce12c4a 100644 --- a/packages/deployment/lib/controller-utils.ts +++ b/packages/deployment/lib/controller-utils.ts @@ -19,6 +19,19 @@ export async function canSignAsGovernor(env: Environment): Promise<{ governor: s const governor = await getGovernor(env) const accounts = (await env.network.provider.request({ method: 'eth_accounts' })) as string[] const canSign = accounts.some((a) => a.toLowerCase() === governor.toLowerCase()) + + // Verify the rocketh named account 'governor' matches the on-chain governor. + // If they disagree, tx({ account: 'governor' }) would send from the wrong address. + if (canSign && env.namedAccounts['governor']) { + const named = env.namedAccounts['governor'] as string + if (named.toLowerCase() !== governor.toLowerCase()) { + throw new Error( + `Named account 'governor' (${named}) does not match Controller.getGovernor() (${governor}). ` + + `Check rocketh account config — mnemonic index may not match the on-chain governor.`, + ) + } + } + return { governor, canSign } } diff --git a/packages/deployment/lib/deploy-implementation.ts b/packages/deployment/lib/deploy-implementation.ts index e5702ef4c..ef2608578 100644 --- a/packages/deployment/lib/deploy-implementation.ts +++ b/packages/deployment/lib/deploy-implementation.ts @@ -304,7 +304,9 @@ export async function deployImplementation( // Rocketh's comparison can false-positive when sync creates bare records (e.g., wrong // argsData, unlinked library bytecodes). The content-aware bytecodeHash handles both // cases — it strips CBOR metadata and resolves library references by content hash. - const contractEntry = addressBookInstance.entryExists(contractName) ? addressBookInstance.getEntry(contractName) : null + const contractEntry = addressBookInstance.entryExists(contractName) + ? addressBookInstance.getEntry(contractName) + : null const pendingImpl = contractEntry?.pendingImplementation const storedMetadata = pendingImpl?.deployment ?? addressBookInstance.getDeploymentMetadata(contractName) diff --git a/packages/deployment/lib/issuance-deploy-utils.ts b/packages/deployment/lib/issuance-deploy-utils.ts index b41b51af0..2d0ff45ba 100644 --- a/packages/deployment/lib/issuance-deploy-utils.ts +++ b/packages/deployment/lib/issuance-deploy-utils.ts @@ -311,9 +311,10 @@ export async function deployProxyContract( if (onChainImpl.toLowerCase() !== implDep.address.toLowerCase()) { // Shared implementation changed — store as pending for governance upgrade const targetChainId = await getTargetChainIdFromEnv(env) - const addressBook: AnyAddressBookOps = contract.addressBook === 'horizon' - ? graph.getHorizonAddressBook(targetChainId) - : graph.getIssuanceAddressBook(targetChainId) + const addressBook: AnyAddressBookOps = + contract.addressBook === 'horizon' + ? graph.getHorizonAddressBook(targetChainId) + : graph.getIssuanceAddressBook(targetChainId) // Get deployment metadata from the shared implementation's address book entry const implMetadata = addressBook.getDeploymentMetadata(sharedImplementation.name) diff --git a/packages/deployment/lib/sync-utils.ts b/packages/deployment/lib/sync-utils.ts index a67574bad..aa42c3f48 100644 --- a/packages/deployment/lib/sync-utils.ts +++ b/packages/deployment/lib/sync-utils.ts @@ -421,9 +421,7 @@ export function buildContractSpec( // Get deployment argsData from address book for accurate rocketh record seeding let deploymentArgsData: string | undefined if (entry) { - const deploymentMeta = entry.proxy - ? entry.implementationDeployment - : entry.deployment + const deploymentMeta = entry.proxy ? entry.implementationDeployment : entry.deployment if (deploymentMeta?.argsData && deploymentMeta.argsData !== '0x') { deploymentArgsData = deploymentMeta.argsData } @@ -1412,7 +1410,9 @@ export async function getContractStatusLine( } // Non-proxy contract — check for code changes against stored bytecodeHash - const { codeChanged } = meta?.artifact ? checkCodeChanged(meta.artifact, addressBook, entryName) : { codeChanged: false } + const { codeChanged } = meta?.artifact + ? checkCodeChanged(meta.artifact, addressBook, entryName) + : { codeChanged: false } const icon = codeChanged ? '△' : '✓' return { line: `${icon} ${contractName} @ ${formatAddress(entry.address)}`, exists: true, codeChanged } } catch (e) { diff --git a/packages/deployment/rocketh/config.ts b/packages/deployment/rocketh/config.ts index c9cfffdc5..e0ef1b47b 100644 --- a/packages/deployment/rocketh/config.ts +++ b/packages/deployment/rocketh/config.ts @@ -17,8 +17,14 @@ export const accounts = { deployer: { default: 0, }, - // Note: Governor address is queried from Controller contract via Controller.getGovernor() - // See lib/controller-utils.ts for helper functions + // Governor — second mnemonic account on local/test networks. + // On mainnet, governance is a multisig (not available via mnemonic). + // The on-chain source of truth is Controller.getGovernor() — see lib/controller-utils.ts. + // This named account exists so rocketh registers a signer, allowing deploy + // scripts to send TXs as governor via tx(). + governor: { + default: 1, + }, } as const satisfies UserConfig['accounts'] // Network-specific data (can be extended as needed) From 70366d0d577b62eda870f7adf387a011eccc2c85 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Fri, 10 Apr 2026 21:10:24 +0000 Subject: [PATCH 085/157] fix(ignition): update HorizonStaking and SubgraphService modules for localNetwork MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HorizonStaking was missing the `after: [GraphPeripheryModule, HorizonProxiesModule]` dependency that other GraphDirectory consumers already have — constructor reverts if Controller contracts aren't registered yet. SubgraphService module updated for current contract: 5-arg constructor (added recurringCollector), explicit library linking (StakeClaims, AllocationHandler, IndexingAgreement chain), and recurringCollectorAddress wired through deploy task. --- .../ignition/modules/core/HorizonStaking.ts | 16 +++++---- .../ignition/modules/SubgraphService.ts | 36 ++++++++++++++++--- packages/subgraph-service/tasks/deploy.ts | 1 + 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/packages/horizon/ignition/modules/core/HorizonStaking.ts b/packages/horizon/ignition/modules/core/HorizonStaking.ts index a7bec9076..ec98c1066 100644 --- a/packages/horizon/ignition/modules/core/HorizonStaking.ts +++ b/packages/horizon/ignition/modules/core/HorizonStaking.ts @@ -15,12 +15,16 @@ export default buildModule('HorizonStaking', (m) => { const subgraphServiceAddress = m.getParameter('subgraphServiceAddress') const maxThawingPeriod = m.getParameter('maxThawingPeriod') - // Deploy HorizonStaking implementation - const HorizonStakingImplementation = deployImplementation(m, { - name: 'HorizonStaking', - artifact: HorizonStakingArtifact, - constructorArgs: [Controller, subgraphServiceAddress], - }) + // Deploy HorizonStaking implementation - requires periphery and proxies to be registered in the controller + const HorizonStakingImplementation = deployImplementation( + m, + { + name: 'HorizonStaking', + artifact: HorizonStakingArtifact, + constructorArgs: [Controller, subgraphServiceAddress], + }, + { after: [GraphPeripheryModule, HorizonProxiesModule] }, + ) // Upgrade proxy to implementation contract const HorizonStaking = upgradeGraphProxy(m, GraphProxyAdmin, HorizonStakingProxy, HorizonStakingImplementation, { diff --git a/packages/subgraph-service/ignition/modules/SubgraphService.ts b/packages/subgraph-service/ignition/modules/SubgraphService.ts index 8efb6800b..2ecc0c901 100644 --- a/packages/subgraph-service/ignition/modules/SubgraphService.ts +++ b/packages/subgraph-service/ignition/modules/SubgraphService.ts @@ -1,4 +1,4 @@ -import { deployImplementation, upgradeTransparentUpgradeableProxy } from '@graphprotocol/horizon/ignition' +import { upgradeTransparentUpgradeableProxy } from '@graphprotocol/horizon/ignition' import { buildModule } from '@nomicfoundation/hardhat-ignition/modules' import ProxyAdminArtifact from '@openzeppelin/contracts/build/contracts/ProxyAdmin.json' import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json' @@ -15,6 +15,7 @@ export default buildModule('SubgraphService', (m) => { const disputeManagerProxyAddress = m.getParameter('disputeManagerProxyAddress') const graphTallyCollectorAddress = m.getParameter('graphTallyCollectorAddress') const curationProxyAddress = m.getParameter('curationProxyAddress') + const recurringCollectorAddress = m.getParameter('recurringCollectorAddress') const minimumProvisionTokens = m.getParameter('minimumProvisionTokens') const maximumDelegationRatio = m.getParameter('maximumDelegationRatio') const stakeToFeesRatio = m.getParameter('stakeToFeesRatio') @@ -28,12 +29,37 @@ export default buildModule('SubgraphService', (m) => { subgraphServiceProxyAddress, ) - // Deploy implementation - const SubgraphServiceImplementation = deployImplementation(m, { - name: 'SubgraphService', - constructorArgs: [controllerAddress, disputeManagerProxyAddress, graphTallyCollectorAddress, curationProxyAddress], + // Deploy libraries required by SubgraphService + const StakeClaims = m.library('StakeClaims') + const AllocationHandler = m.library('AllocationHandler') + const IndexingAgreementDecoderRaw = m.library('IndexingAgreementDecoderRaw') + const IndexingAgreementDecoder = m.library('IndexingAgreementDecoder', { + libraries: { IndexingAgreementDecoderRaw }, + }) + const IndexingAgreement = m.library('IndexingAgreement', { + libraries: { IndexingAgreementDecoder }, }) + // Deploy implementation + const SubgraphServiceImplementation = m.contract( + 'SubgraphService', + [ + controllerAddress, + disputeManagerProxyAddress, + graphTallyCollectorAddress, + curationProxyAddress, + recurringCollectorAddress, + ], + { + libraries: { + StakeClaims, + AllocationHandler, + IndexingAgreement, + IndexingAgreementDecoder, + }, + }, + ) + // Upgrade implementation const SubgraphService = upgradeTransparentUpgradeableProxy( m, diff --git a/packages/subgraph-service/tasks/deploy.ts b/packages/subgraph-service/tasks/deploy.ts index 581138439..860e8c67b 100644 --- a/packages/subgraph-service/tasks/deploy.ts +++ b/packages/subgraph-service/tasks/deploy.ts @@ -91,6 +91,7 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string, subgraphServiceProxyAdminAddress: proxiesDeployment.Transparent_ProxyAdmin_SubgraphService.target as string, graphTallyCollectorAddress: horizonDeployment.GraphTallyCollector.target as string, + recurringCollectorAddress: horizonDeployment.Transparent_Proxy_RecurringCollector.target as string, gnsProxyAddress: horizonDeployment.Graph_Proxy_L2GNS.target as string, gnsImplementationAddress: horizonDeployment.Implementation_L2GNS.target as string, subgraphNFTAddress: horizonDeployment.SubgraphNFT.target as string, From 6114cded180bb14b12d7714f44540bc81ae0e05e Mon Sep 17 00:00:00 2001 From: operagxoksana Date: Thu, 5 Mar 2026 17:50:11 +0200 Subject: [PATCH 086/157] docs: fix broken badge and link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e267273fe..1879b2895 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Build - - CI-Contracts + + Lint

^GBW(MaW45$Wtps}g(~JnZo-p{ z;iq}yoHF@QURf^CVql9|21Kt|Y77YRbrz4t$TEqo&Fvf0R(IRxO!a73!Xl0`cZ7Sw ze&AgyoynlTH%|OY;9y&#Ix)1jx%==?G#JF=w3H%2pGX(R;&FFPhtJ<#>xtIFIBXAi z=Yv4s16Uk8j&hRXz$?0a-loymf(!VDtO>K}PO8$b6)@D%YI2 zBt>!T3ev!()}7?RHB=m^IfdIuaGg8y0PmhN%O2v*M@q|dLH#aY+p1Lc%V=081WPr) zh=W#L;eKtTy*ijldgOAc+8eE|cR%z{sBeE~H*kb*r@A_QHGUmIVOC41rNXFSl{%~4 zqE^c22OjF4TT>D4p03k$_nX2sPH5Bp#CPy#7&}&ntw-a~S}mqFF5u%?O-0ZveYonN z_YvbG6*Kn3>KQbCkryV8ypeofm~f!4l0M8=9jx#^!dDoIhi#K8wf-0el{*4>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