Skip to content

Define the progressive rollout strategy of the IPFS distribution #3607

Closed

Description

@jpraynaud

Why

As long as the Mithril infrastructure is the only seeder, IPFS is at best equivalent to a cloud storage download. Sending all the clients to IPFS before enough peers serve the archives would degrade the downloads.

What

Define how the share of downloads served by IPFS grows with the number of peers serving the Mithril artifacts.

How

  • Define the phases of the rollout (networks, share of IPFS downloads) and the criteria to move from one phase to the next
  • Decide where the distribution ratio is controlled (hard-coded, user level or protocol level)
  • Define the metrics needed to follow the rollout (number of providers, download time, failure rate)
  • Document the strategy

Activity

  1. self-assigned this
    on Oct 15, 2026
  2. Alenar commented on Oct 19, 2026

    @Alenar
    Collaborator

    IPFS distribution: progressive rollout strategy

    Important

    All thresholds below are placeholders, to calibrate with the #3608 results.

    Note

    ipfs-share is the percentage of the immutable files of each download that the client fetches from IPFS rather than
    from cloud storage.

    1. Context

    • Today IPFS is all or nothing. A client with an IPFS RPC URL (behind --unstable) tries IPFS first for 100%
      of the immutable files, because Ipfs sorts before CloudStorage in ImmutablesLocation
      (internal_downloader.rs#L182). A circuit breaker switches the rest of the download to cloud
      storage when IPFS is unreachable.
    • The Mithril seed node is the only provider. Until third parties rehost the archives, IPFS traffic is limited by
      one VM and costs about the same as the cloud traffic. Sending all clients to IPFS now would degrade the downloads.
    • The aggregator publishes one cumulative directory to IPNS (ipfs_uploader.rs, see the
      IPNS signing key runbook). Pinners will be instructed to follow the IPNS name and pin the whole
      directory, and an existing archive is never re-uploaded, so the CIDs are stable across snapshots.
    • The IPFS client requires a user-run Kubo node for now. The MVP adds an auto-managed Kubo node, downloaded and run
      by the client for the duration of the download (separate issue). From then on, IPFS reaches every CLI user and the
      ipfs-share becomes the only limit on the IPFS traffic.

    IPFS only brings its full value (a lower cloud storage cost and a distribution that no longer rests on the Mithril
    infrastructure alone) once the community seeds the archives. Until then, sending more downloads to IPFS would only make
    them slower. The share of IPFS downloads must therefore grow with this supply, without degrading the download quality.

    This document defines how: where this share is controlled (§2), the rollout
    phases and the criteria to move from one to the next (§3), the metrics behind these criteria
    (§4), and the follow-up issues (§5).

    2. Where the ipfs-share is controlled

    Decision: the aggregator advertises the ipfs-share in its root route (AggregatorFeaturesMessage).

    pub struct AggregatorCapabilities {
        // ... existing fields ...
        #[serde(skip_serializing_if = "Option::is_none")]
        pub ipfs_distribution: Option<IpfsDistributionCapabilities>,
    }
    
    pub struct IpfsDistributionCapabilities {
        /// Percentage (0 to 100) of the immutable files of a download to fetch from IPFS
        pub ipfs_share: u8,
    }
    • Live and per network: one value per aggregator, changed with an infrastructure-only redeployment
      (ADR 11). It applies at once to every snapshot, including the existing ones.
    • No change to the artifact messages: the value only matters during the rollout, so it stays out of the long-lived
      artifact API.
    • Kill switch: ipfs_share: 0. Removing ipfs_distribution is not a kill switch: the client then uses its
      hard-coded default.
    • Client side:
      • The client fetches the root route before a download (one more small HTTP call).
      • Without an ipfs-share, or if the call fails, it uses a conservative hard-coded default (for example, 5%, TBD).
      • The user can override it with the --ipfs-share CLI parameter (and the equivalent library builder option), which
        accepts a number (0 to 100), prefer (an alias of 100, for pinners and testers), disabled (an alias of 0), or
        fallback (cloud first for every file, IPFS only when cloud fails).

    Options considered and set aside:

    Option Why not
    Hard-coded in the client changes only with releases (6 to 12 weeks), cannot react to peers joining or leaving; kept as the fallback
    User level only users have no information to pick a value; kept as an override
    A field in the artifact message frozen per artifact (artifacts are stored as JSON when built), and a temporary field in a long-lived API
    Protocol level (ADR 13, on-chain markers) clients don't read the chain, epoch granularity, and the ipfs-share is not a protocol parameter
    Adaptive client, no fixed ipfs-share complex, noisy measurements, and no global control of the seed node load

    Which immutables go to IPFS

    Problem: Having a share does not say which immutables are fetched from IPFS. We need an algorithm to decide which
    files are selected.

    Decision: Random draw per file, with one seed per download batch: each immutable file goes to IPFS with probability
    ipfs-share. The seed is drawn once for the whole batch, not per immutable file: each immutable file's archive (the
    trio of chunk, primary and secondary files) is fetched separately, and all of them are drawn from the same seed. Every
    file still lists both locations, so a failed IPFS file falls back to cloud storage as today; only the first location
    tried changes.

    • Simplest: no hash scheme to specify. Over the thousands of files of a download, the share stays close to the
      ipfs-share.
    • Spread over all the files: every archive gets IPFS demand, instead of a fixed subset. This fits the IPNS model,
      where every pinner holds every file.
    • Reproducible when needed: the seed is logged, and the selection takes it as an internal parameter, so tests can
      fix it (exposing it as a CLI option may come later).

    3. Rollout phases

    The feature phases set the software maturity. The ipfs-share ramp runs inside phases 2 and 3 and follows the metrics.

    Networks:   testing-preview / pre-release-preview  ──►  release-preprod  ──►  release-mainnet
    Software:   [1. unstable] ──────────────► [2. feature complete / beta] ──────► [3. stable]
    Traffic:    [opt-in only] ──► [ipfs-share ramp: 5 → 25 → 50 → 80+ % on mainnet, gated by the metrics]
    Supply:     upload + IPNS on all networks, mainnet included, from phase 1
    

    Phase 1: unstable

    • Traffic: opt-in users only (--unstable --ipfs-rpc-url), on testing-preview and pre-release-preview, with a test
      ipfs-share (for example, 10%, TBD). They can force --ipfs-share prefer to test IPFS alone. On preprod and mainnet,
      the ipfs-share is 0, but the aggregator already uploads and publishes to IPNS, so pinners can start seeding
      mainnet months before any client depends on it. The synthetic restore job already runs there, and gives the baseline
      of the quality gates before any user is sent to IPFS.
    • To build (blocking for phase 2):
      • the per-file split, replacing the implicit sort() priority, and the user override;
      • the ipfs_distribution capability and its per-network configuration;
      • the probe job and the synthetic restore job (§4), with a dashboard;
      • the pinner guide (resolve the IPNS name, pin the new directory, unpin the previous one).
    • Exit criteria: e2e green, synthetic restore job live on every network, probe job live on mainnet, kill switch
      tested, IPFS uploads enabled on mainnet, and the Measure the download time of a mainnet Cardano database with IPFS on dev-mainnet #3608 estimate shows that a mainnet restore through IPFS is within an
      acceptable factor of cloud (for example, ≤ 1.5×) when enough pinners exist.

    Phase 2: feature complete / beta on mainnet

    • Software: the --unstable gate is removed, and IPFS is on by default for every CLI user through the
      auto-managed Kubo node. This release must already honor the ipfs-share (the same goes for any release that
      uses IPFS outside --unstable): otherwise its clients fetch 100% of the files from IPFS, and the ipfs-share can no
      longer limit the IPFS traffic.
    • Traffic: mainnet ramps through the tiers below. Testing-preview and preprod go directly to T1 and stay there (see
      the rules below).
    Tier ipfs-share Supply gate (mainnet only)¹ Quality gate, measured in the previous tier²
    T0 5% the Mithril seed node none, the baseline comes from phase 1
    T1 25% ≥ 3 independent pinners restore ≤ 1.3× cloud only; fallback < 10%
    T2 50% ≥ 10 independent pinners restore ≤ 1.1× cloud only; fallback < 5%
    T3 80–100% ≥ 25 independent pinners restore ≤ cloud only; fallback < 2%

    ¹ An independent pinner is a non-Mithril node that provides a recent directory CID and from which the probe job
    actually fetched data.
    ² Measured by the synthetic restore job (§4): the median restore time of an IPFS-only restore, compared
    with a cloud-only restore of the same files, and the share of the IPFS files that fell back to cloud storage. The failed
    restorations must also stay at the cloud-only level.

    • Test networks stay at T1 (25%). Testing-preview and preprod have no third-party pinners to wait for: the Mithril
      seed node will probably be their only pinner, so a higher ipfs-share would only load it. They enter phase 2
      directly at T1 and stay there. Higher shares are exercised with --ipfs-share prefer and the e2e tests, since the
      code path is the same whatever the value.
    • Minimum time per tier (mainnet): one full week on each tier before moving up, to see the weekday and weekend
      patterns.
    • Step down: a gate breached for a sustained period (for example, 24 h) drops one tier; a sharp breach (a fallback
      rate above 25%) drops to T0. Manual, with an alert.

    Phase 3: stable

    • Advertised as stable on mainnet once the mechanism ran one full release cycle without a rollback caused by a bug.
      Reaching T3 is not required: the ramp simply continues.
    • Cloud storage stays as the fallback, and the traffic it serves drops with the tier reached.

    4. Metrics

    What the tier gates need:

    Metric Source Exists?
    Independent pinners (serving) probe job: list the providers of the recent directory CIDs³, then fetch a block from each⁴ ❌
    Restore time vs cloud only, fallback and failure rates synthetic restore job⁵ ❌

    ³ Kubo CLI: ipfs routing findprovs. A provider record is only a claim, so it gives the candidates,
    not the count.
    ⁴ For example ipfs swarm connect then ipfs block get with a timeout. A
    provider that does not answer is not counted.
    ⁵ See Synthetic restore job below.

    Synthetic restore job

    A scheduled job, on each network, that restores the same fixed range of immutable files twice in a row:

    1. once from IPFS only (--ipfs-share prefer);
    2. once from cloud storage only.

    It exports to Prometheus both restore times, the IPFS files that fell back to cloud storage (from the client output),
    and the failures.

    • Why force IPFS: it measures what the swarm can deliver, whatever the current tier, even while the ipfs-share is
      still 0.
    • Why a fixed range: a complete restoration would make the job long and costly.
    • Keep the range small: the seed node serves its IPFS traffic without being counted as a complete restoration, so a
      large range would distort the third-party traffic estimate.

    Traffic served by the third-party pinners (estimate)

    This shows how much traffic the pinners take off the Mithril infrastructure. A rough estimate is enough, and it can be
    computed from data that is already collected:

    Input Source Exists?
    Number of complete restorations per day⁶ aggregator statistics (mithril_aggregator_cardano_db_complete_restoration_since_startup) ✅
    Size of the immutable archives the artifact, or the cumulative size of the IPFS directory ✅
    ipfs-share advertised by the aggregator aggregator configuration ✅
    Seed node outbound traffic Kubo Prometheus endpoint ✅

    ⁶ The daily increase of this counter, which counts since the aggregator started.

    expected IPFS traffic   = complete restorations × archives size × ipfs-share
    third-party traffic     ≈ expected IPFS traffic − seed node outbound traffic
    

    For example, 10 complete restorations in a day, of 50 GB of immutable archives each, with an ipfs-share of 20%: about
    10 × 50 × 20% = 100 GB are expected from IPFS. If the seed node served 20 GB that day, about 80 GB came from third-party
    pinners.

    • Complete restorations only: a partial restoration fetches an unknown subset of the files, which would make the
      computation more complex than needed for a rough idea.
    • A rough figure: clients that force their share (--ipfs-share) or fall back to cloud storage are not taken into
      account, and the seed node traffic also includes the pinners fetching the new files.
    • The GCS download traffic, already monitored too, shows the matching cost saving.

    Alternative: new client statistics

    Add optional fields to the existing CardanoDatabaseImmutableFilesRestoredMessage (backward compatible): the
    ipfs-share applied (and whether forced by the user), the files, bytes and download time per source, the restore time,
    the fallbacks and circuit breaker trips, and the success. The quality gates and the traffic per source would then be
    measured on every real download, instead of a synthetic job and an estimate.

    • ✅ Precise, measured on the users' networks, and includes the partial restorations.
    • ❌ New statistics in the client and the aggregator, only useful during the rollout, so to be discarded later.
    • ❌ It relies on every client reporting.

    5. Follow-up issues

    1. Client: per-file split of the immutables (random draw, one seed per download batch, logged and injectable in the
      tests), the --ipfs-share user override, and the hard-coded default.
    2. Common, aggregator and client: ipfs_distribution capability in AggregatorFeaturesMessage, per-network
      configuration, fetched by the client before a download.
    3. Infra: synthetic restore job on each network, with Prometheus export; dashboard (including the third-party
      traffic estimate).
    4. Infra: probe job (serving independent pinners), with Prometheus export.
    5. Infra: dark launch, the aggregator uploads to IPFS and publishes to IPNS on preprod and mainnet, with an ipfs-share
      of 0.
    6. Docs: pinner guide, and the rollout tiers and gates once calibrated.

    The auto-managed Kubo node has its own MVP issue. The points that matter for this rollout: it must start with
    providing disabled (a node that lives only for the download must not announce content, or its stale records would send
    other clients to a peer that no longer exists), it gets the Mithril seed node as a direct peer, and it must ship with
    the ipfs-share (§3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

spike 📡

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions