Skip to content

refactor: restructure config to support both networks#468

Closed
silent-cipher wants to merge 5 commits into
refactor/add-network-to-schemafrom
refactor/mulit-network-config
Closed

refactor: restructure config to support both networks#468
silent-cipher wants to merge 5 commits into
refactor/add-network-to-schemafrom
refactor/mulit-network-config

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

Overview

This PR restructures the dealbot configuration system to support running checks across multiple Filecoin networks (calibration and mainnet) simultaneously from a single deployment. Previously, each deployment was locked to a single network via the NETWORK env var.

Motivation

  • Multi-network support: Enable a single dealbot instance to monitor both calibration and mainnet
  • Network isolation: Each network maintains its own wallet, RPC endpoint, scheduling parameters, and SP blocklists
  • Operational flexibility: Reduce infrastructure overhead by consolidating deployments
  • Backward compatibility: Existing single-network deployments continue to work via legacy env var translation

Changes

Configuration System Refactor

New Structure:

  • Replaced monolithic app.config.ts (431 lines) with modular config system:
    • config/types.ts - TypeScript interfaces for all config sections
    • config/env.schema.ts - Joi validation schemas with per-network rules
    • config/loader.ts - Config loading and assembly logic
    • config/env.parsers.ts - Domain-specific env var parsers
    • config/env.helpers.ts - Primitive env var accessors
    • config/constants.ts - Default values and network prefixes

Environment Variables:

  • New NETWORKS env var (comma-separated list, e.g., "calibration,mainnet")
  • Per-network prefixed vars: <NETWORK>_WALLET_ADDRESS, <NETWORK>_RPC_URL, etc.

Legacy Compatibility:

  • config/legacy-env-compat.ts - Automatic translation of old unprefixed vars to new prefixed format
  • Existing deployments work without config changes (single-network mode)
  • Translation runs before validation, transparent to application code

API Changes

/api/config endpoint:

// Before:
{
  network: "calibration",
  jobs: { dealsPerSpPerHour: 4, ... }
}

// After:
{
  networks: [
    {
      network: "calibration",
      dealsPerSpPerHour: 4,
      retrievalsPerSpPerHour: 2,
      ...
    },
    {
      network: "mainnet",
      dealsPerSpPerHour: 2,
      retrievalsPerSpPerHour: 1,
      ...
    }
  ]
}

@FilOzzy FilOzzy added this to FOC Apr 23, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 23, 2026
@silent-cipher silent-cipher self-assigned this Apr 23, 2026
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC Apr 24, 2026
@BigLep BigLep added this to the M4.5: GA Fast Follows milestone Apr 27, 2026
@BigLep BigLep moved this from ⌨️ In Progress to 🐱 Todo in FOC May 3, 2026
@silent-cipher
Copy link
Copy Markdown
Collaborator Author

closing this in favor of #570

@github-project-automation github-project-automation Bot moved this from 🐱 Todo to 🎉 Done in FOC May 25, 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.

3 participants