Skip to content

feat: add full-rate and trickle SP testing tiers - #682

Merged
silent-cipher merged 4 commits into
mainfrom
fix/fund-draining-from-new-sps
Aug 24, 2026
Merged

feat: add full-rate and trickle SP testing tiers#682
silent-cipher merged 4 commits into
mainfrom
fix/fund-draining-from-new-sps

Conversation

@silent-cipher

Copy link
Copy Markdown
Collaborator

Part of #681

Summary

  • Classify eligible storage provider into full-rate and trickle testing tiers.
  • Keep approved providers and configured expected-approval candidates at the network-configured rates.
  • Limit other eligible provider to 1 deal and 1 data-set creation attempt every 4 hours, with a target of 1 dataset.
  • Add per-network expected-approved providerID and address configuration.
  • Apply the tier specific dataset target during scheduling, provisioning, and deal dataset selection.
  • Schedule dataset lifecycle checks only for full-rate providers, remove stale lifecycle schedules after a downgrade, and recheck eligibility when queued lifecycle jobs execute.
  • Leave retrieval, sample retrieval, pull-check, and cleanup cadences unchanged.

USE_ONLY_APPROVED_PROVIDERS remain the outer provider-eligibility gate. when enabled, expected-approved provider lists do not admit unapproved providers.

Out of scope

  • Terminating existing datasets or payment rails above the new trickle target. This requires a dedicated on-chain termination job.
  • Changing pull-check scheduling. Pull-check signing is used for authorization validation and does not itself submit the wallet-spending contract call.
  • Cancelling or skipping the general deal jobs that were queued before a tier downgrade.

@silent-cipher
silent-cipher requested a review from beck-8 as a code owner August 17, 2026 08:11
Copilot AI lite review requested due to automatic review settings August 17, 2026 08:11
@FilOzzy FilOzzy added this to FOC Aug 17, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 17, 2026
@silent-cipher
silent-cipher requested a review from SgtPooki August 17, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements provider testing tiering to reduce wallet-spend exposure from newly registered/ephemeral storage providers by running only “full-rate” providers at configured rates and throttling all other eligible providers to a fixed “trickle” rate per network.

Changes:

  • Adds per-network “expected approved” allowlists (IDs + addresses) and a shared isFullRateTier helper to classify providers into full-rate vs trickle tiers.
  • Applies tier-specific scheduling and dataset targeting (deals + dataset creation rates, min dataset targets), and restricts dataset lifecycle checks to full-rate providers (including stale-schedule cleanup and runtime re-eligibility checks).
  • Updates configuration loading/validation, docs, and examples to describe and support the new tiering knobs.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/environment-variables.md Documents tiering behavior and adds expected-approved env vars.
apps/backend/.env.example Adds example expected-approved vars and tiering notes.
apps/backend/src/config/constants.ts Introduces fixed trickleTierRates constants.
apps/backend/src/config/env.schema.ts Adds env validation for expected-approved lists.
apps/backend/src/config/loader.ts Loads expected-approved ID/address lists into per-network config.
apps/backend/src/config/network-fields.ts Registers expected-approved vars as per-network + chain-specific.
apps/backend/src/config/types.ts Extends network config types with expected-approved sets.
apps/backend/src/common/sp-tier.ts Adds helper to classify providers into full-rate tier.
apps/backend/src/providers/repositories/storage-provider.repository.ts Extends active-provider projection to include isApproved for tiering.
apps/backend/src/providers/repositories/storage-provider.repository.spec.ts Updates repository tests for new projection shape.
apps/backend/src/jobs/repositories/job-schedule.repository.ts Adds deletion helper for per-address schedules (used to clear stale lifecycle schedules after downgrades).
apps/backend/src/jobs/jobs.service.ts Applies tiering to scheduling + dataset targets; gates lifecycle schedules and re-checks tier at job execution.
apps/backend/src/jobs/jobs.service.spec.ts Updates and adds tests for lifecycle scheduling behavior under tiering.
apps/backend/src/deal/deal.service.ts Applies tier-specific min-dataset target to deal dataset selection.
apps/backend/src/deal/deal.service.spec.ts Updates tests for the new minDataSets parameter path.
apps/backend/src/wallet-sdk/wallet-sdk.service.spec.ts Updates base network config test fixtures for expected-approved fields.
Suppressed comments (2)

apps/backend/src/jobs/jobs.service.spec.ts:1543

  • The findActiveAddresses repository contract includes providerId, and ensureScheduleRows passes it into isSpBlocked(...) / tiering. This test mock omits providerId, which can hide regressions in ID-based blocklisting and diverges from the runtime shape.
    providerRegistryRepositoryMock.findActiveAddresses.mockResolvedValueOnce([{ address: "0xaaa", isApproved: true }]);

apps/backend/src/jobs/jobs.service.spec.ts:1569

  • The findActiveAddresses repository contract includes providerId, and ensureScheduleRows passes it into isSpBlocked(...) / tiering. This test mock omits providerId, which can hide regressions in ID-based blocklisting and diverges from the runtime shape.
    providerRegistryRepositoryMock.findActiveAddresses.mockResolvedValueOnce([{ address: "0xaaa", isApproved: false }]);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/backend/src/jobs/repositories/job-schedule.repository.ts
Comment thread apps/backend/src/jobs/jobs.service.spec.ts Outdated

@SgtPooki SgtPooki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

in general lgtm, but I left a few comments

Comment thread apps/backend/src/common/sp-tier.ts Outdated
Comment thread apps/backend/src/config/constants.ts
Comment thread apps/backend/src/config/env.schema.ts Outdated
Comment thread docs/environment-variables.md Outdated
@silent-cipher

Copy link
Copy Markdown
Collaborator Author

I'll merge this after https://github.com/FilOzone/infra/pull/367

@SgtPooki SgtPooki moved this from 📌 Triage to ⌨️ In Progress in FOC Aug 18, 2026
@BigLep BigLep moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FOC Aug 19, 2026
@silent-cipher
silent-cipher merged commit 24ed2b6 into main Aug 24, 2026
9 checks passed
@silent-cipher
silent-cipher deleted the fix/fund-draining-from-new-sps branch August 24, 2026 04:39
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants