Skip to content

Indexing payments with escrow management and post-Horizon cleanup#1300

Closed
RembrandtK wants to merge 11 commits intomainfrom
indexing-payments
Closed

Indexing payments with escrow management and post-Horizon cleanup#1300
RembrandtK wants to merge 11 commits intomainfrom
indexing-payments

Conversation

@RembrandtK
Copy link
Contributor

@RembrandtK RembrandtK commented Feb 27, 2026

Content out of date, will get a force push soon.

@RembrandtK RembrandtK requested a review from Copilot February 27, 2026 18:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs post-Horizon cleanup by removing legacy transition period code and consolidating version management for indexing payments with escrow handling.

Changes:

  • Removed legacy allocation/delegation code and HorizonStakingExtension
  • Updated Solidity version from 0.8.33 to ^0.8.27 across packages
  • Replaced MathUtils library with OpenZeppelin's Math
  • Added indexing fee dispute mechanism and agreement management
  • Refactored test infrastructure to remove transition period tests

Reviewed changes

Copilot reviewed 212 out of 259 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/subgraph-service/contracts/DisputeManager.sol Removed legacy dispute creation, added indexing fee dispute V1
packages/subgraph-service/contracts/SubgraphServiceStorage.sol Added indexingFeesCut storage variable
packages/horizon/contracts/staking/HorizonStakingBase.sol Replaced MathUtils with OpenZeppelin Math, removed extension references
packages/horizon/contracts/utilities/GraphDirectory.sol Removed deprecated Curation contract references
packages/issuance/test/unit/agreement-manager/*.t.sol Added comprehensive test coverage for agreement management
packages/horizon/test/integration/during-transition-period/*.test.ts Removed all transition period integration tests
packages/contracts/contracts/rewards/RewardsManager.sol Removed staking contract as rewards issuer, SubgraphService only

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@openzeppelin-code
Copy link

openzeppelin-code bot commented Feb 27, 2026

Indexing payments with escrow management and post-Horizon cleanup

Generated at commit: 1013fb02522147053081d736323f7cd81f74936d

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
5
0
14
37
59
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 97.42268% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.96%. Comparing base (ddee12b) to head (1013fb0).

Files with missing lines Patch % Lines
...ntracts/payments/collectors/RecurringCollector.sol 93.33% 6 Missing and 6 partials ⚠️
...s/horizon/contracts/staking/HorizonStakingBase.sol 87.50% 2 Missing ⚠️
...n/contracts/data-service/libraries/StakeClaims.sol 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1300      +/-   ##
==========================================
+ Coverage   88.55%   89.96%   +1.40%     
==========================================
  Files          75       79       +4     
  Lines        4615     4953     +338     
  Branches      981     1052      +71     
==========================================
+ Hits         4087     4456     +369     
+ Misses        507      464      -43     
- Partials       21       33      +12     
Flag Coverage Δ
unittests 89.96% <97.42%> (+1.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
Previously audited implementation of indexing agreements for the
Graph Protocol's recurring payment system. Adds RecurringCollector,
IndexingAgreement library, and integrates indexing fee collection
into SubgraphService and DisputeManager.

Includes all TRST audit fixes:
- TRST-H-1: IndexingAgreement.collect() on CanceledByPayer
- TRST-H-2: Only agreement owner can collect indexing fee
- TRST-H-3: collect() checks provision
- TRST-M-1: correct TYPEHASH string for RCAU
- TRST-M-2: shared collection window logic + improve _getCollectionInfo
- TRST-M-3: Add nonce-based replay protection
- TRST-L-3: Add deterministic agreement ID
- TRST-L-5: Add slippage protection
- TRST-L-6: Proper agreement version check
- TRST-L-7: update() documentation
- TRST-L-9: Cancel agreement if over-allocated
- TRST-R-1: minor fixes
- TRST-R-4: CEI violation
- TRST-R-5: Terms validation
- TRST-R-6: Configurable indexing fees cut

Re-based from indexing-payments-baseline commits a7fb875..a9b500a
Remove HorizonStakingExtension, ExponentialRebates, LibFixedMath,
MathUtils, and all transition-period guard logic. Simplify
HorizonStaking to direct implementation without delegatecall split.
Clean up RewardsManager multi-issuer model to single subgraphService.
Remove legacy allocation/dispute code from SubgraphService.

Includes OZ audit fixes:
- OZ L-01: re-validate thawingPeriod when accepting provision parameters
- OZ L-02: return correct result for getThawedTokens for delegations
- OZ N-01: remove more deprecated code
- OZ N-02: outdated documentation

Adds force withdraw for legacy stake and delegations.
Replaces MathUtils.min with OpenZeppelin Math.min throughout.

Original commits on rem-horizon-cleanup-merge (f65877e..5b9463f)
Plus housekeeping commits 8f5d93449 and ae9f59513
Add isAllocation() to HorizonStaking to check for allocation ID
collisions with pre-Horizon legacy allocations. Updates
LegacyAllocation.revertIfExists() to also check the staking contract.

Original commits on rem-baseline-merge (edf40dc, b558574)
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
… 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.
Make thaw, cancelThaw, and withdraw idempotent so callers need not
track escrow state before invoking these operations. Thaw accepts an
evenIfTimerReset flag and a tokensThawing parameter for precise control.
Refactor IPaymentsEscrow interface to match.
Add IContractApprover 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 IContractApprover.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.
Extract IDataServiceAgreements from ISubgraphService with
cancelIndexingAgreementByPayer and bitmask-dispatched enforce pattern.
Add ProvisionManager support for data-service callback verification.
Add RecurringAgreementManager (RAM) with full agreement lifecycle:
register/remove indexers, create/revoke offers, reconcile escrow,
and cancel agreements via IDataServiceAgreements. Includes configurable
funding modes (JustInTime/Active/Full) with eligibility oracle,
per-agreement collector with 2D escrow storage, contract approver
collection callbacks, and comprehensive test suite.
@RembrandtK RembrandtK closed this Mar 2, 2026
@RembrandtK RembrandtK deleted the indexing-payments branch March 2, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants