Skip to content

feat(aggregator): better ipfs timeouts handling - #3746

Merged
Alenar merged 8 commits into
mainfrom
djo/3712/aggregator-ipfs-better-timeout-handling
Dec 4, 2026
Merged

Alenar merged 8 commits into
mainfrom
djo/3712/aggregator-ipfs-better-timeout-handling

Conversation

@Alenar

@Alenar Alenar commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Content

This PR fixes the IPFS upload of the immutable files archives failing after a restart of the Kubo node. When it failed, the Cardano database artifact was certified without an IPFS location, and the aggregator kept advertising an IPFS share.

Root cause

  • IpfsUploader::batch_upload_to_dir lists the whole MFS directory (files/ls /mithril) to find which archives are already uploaded. The request had the default 10s timeout.
  • On testing-preview, the directory holds about 30 000 immutable archives, so Kubo stores it as a HAMT-sharded directory (made of 5 448 blocks).
    • Looking up a single entry reads about 3 blocks.
    • A full listing reads all of them.
  • After a restart, the Kubo caches are empty. When the shard blocks are no longer in the host page cache, the listing reads them from a slow disk (about 85 blocks/s).
  • Measured on testing-preview right after a restart, files ls took between about 1s and 12.5s. A warm node answers in 0.8s.
  • The cost grows with the number of immutables, about 0.18 blocks per immutable.
  • Creating and listing the directory were not covered by the uploader retry policy, so a single slow call failed the whole IPFS upload.

Changes

  • IPFS uploader:
    • The files/ls query uses the slow-query timeout (3 min per attempt) instead of the default 10s.
    • The creation and the listing of the MFS directory are retried with the uploader retry policy.
  • New metrics in the aggregator:
    • mithril_aggregator_cardano_db_immutables_upload_total_failed_since_startup: failed upload attempts of the immutable files archives, labelled by location_type (ipfs, cloud_storage). This reports an artifact certified without one of its locations.
      • It counts each failing uploader on every upload attempt. An artifact whose creation is retried can therefore count twice.
      • To get the label, the ImmutableFilesUploader trait has a new location_type() method.
      • The ImmutableArtifactBuilder now receives the MetricsService. Tests use the new new_for_test constructor.
    • mithril_aggregator_artifact_total_failed_since_startup: artifact creation tasks that returned an error, labelled by signed_entity_type. Until now these failures only appeared as a warning log.
  • The new metrics are added to the aggregator metrics table of the documentation website.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update documentation website (if relevant)
    • No new TODOs introduced

Comments

  • The issue's fallback, failing the Cardano database artifact when IPFS returns no location, is not implemented. The timeout and retries fix the cold-node case, and the new upload failure metric lets the monitoring alert if an artifact is still certified without an IPFS location.

Issue(s)

Closes #3712

@Alenar Alenar self-assigned this Dec 4, 2026
@Alenar Alenar added the optimization 🛠️ Optimization and/or small enhancements label Dec 4, 2026
@jpraynaud
jpraynaud requested a lite review from Copilot December 4, 2026 11:05

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.

🟡 Changes recommended

Active critical and documentation issues remain, including a failure counter that never records errors and an unupdated maintained documentation copy.

3 open issues
What changed in this PR

Improves aggregator resilience to slow or cold Kubo nodes and adds metrics for upload and artifact creation failures.

Changes:

  • Extends IPFS directory-listing timeouts and adds retries.
  • Adds labelled upload and artifact failure metrics.
  • Updates documentation and changelog.
File Description
mithril-aggregator/​src/​tools/​kubo_rpc_client/​query/​ipfs_files_ls.rs Uses the slow-query timeout for IPFS directory listings.
mithril-aggregator/​src/​services/​signed_entity.rs Records artifact creation failures through the metrics service.
mithril-aggregator/​src/​metrics/​service.rs Defines metrics for immutable upload and artifact creation failures.
mithril-aggregator/​src/​file_uploaders/​ipfs_uploader.rs Retries IPFS directory creation and listing operations.
mithril-aggregator/​src/​dependency_injection/​builder/​protocol/​artifacts.rs Injects the metrics service into artifact construction.
mithril-aggregator/​src/​artifact_builder/​cardano_database.rs Updates cardano database artifact test construction.
mithril-aggregator/​src/​artifact_builder/​cardano_database_artifacts/​immutable.rs Records immutable upload failures by location type.
docs/​website/​root/​manual/​operate/​run-aggregator-node.md Documents the new aggregator failure metrics.
CHANGELOG.md Records the IPFS timeout, retry, and metrics changes.

Review effort: Lite

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Test Results

     5 files  ± 0     211 suites  ±0   48m 10s ⏱️ - 4m 41s
 4 857 tests + 6   4 857 ✅ + 6  0 💤 ±0  0 ❌ ±0 
16 041 runs  +12  16 041 ✅ +12  0 💤 ±0  0 ❌ ±0 

Results for commit 5d1b126. ± Comparison against base commit b254d7e.

♻️ This comment has been updated with latest results.

@Alenar
Alenar deployed to testing-2-preview December 4, 2026 11:16 — with GitHub Actions Active
@Alenar
Alenar deployed to testing-preview December 4, 2026 11:16 — with GitHub Actions Active
Listing the immutables MFS directory, a HAMT shard of several thousand
blocks, can exceed the default 10s timeout when the Kubo node cache is
cold, e.g. after a restart of the node.
Creating the MFS directory can fail on a Kubo node that was just
restarted, which made the whole IPFS upload fail without retrying.
Listing the immutables MFS directory can time out when the Kubo node
cache is cold, which made the whole IPFS upload fail without retrying.
…ifact builder

Add a test-only `new_for_test` constructor to limit the impact on the
tests.
… location type

Allows the monitoring to detect a Cardano database artifact certified
without one of its immutable files locations, e.g. IPFS when the Kubo
node is unreachable.
… signed entity type

Artifact creation failures were only visible as a warning log, they can
now be monitored alongside the produced artifacts counters.
@Alenar
Alenar force-pushed the djo/3712/aggregator-ipfs-better-timeout-handling branch from 2d144ab to f02a939 Compare December 4, 2026 14:08

@jpraynaud jpraynaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@turmelclem turmelclem 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.

LGTM 👍

@damrobi damrobi 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.

LGTM 👍

* mithril-aggregator from `0.11.4` to `0.11.5`
@Alenar
Alenar deployed to testing-preview December 4, 2026 15:00 — with GitHub Actions Active
@Alenar
Alenar deployed to testing-2-preview December 4, 2026 15:00 — with GitHub Actions Active
@Alenar
Alenar merged commit 761d730 into main Dec 4, 2026
53 checks passed
@Alenar
Alenar deleted the djo/3712/aggregator-ipfs-better-timeout-handling branch December 4, 2026 15:04

This branch was successfully deployed

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

Labels

optimization 🛠️ Optimization and/or small enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some Cardano database artifacts don't have IPFS locations for immutables

5 participants