Skip to content

Make the SRS and circuit key cache directories configurable #3422

Open

Description

@jpraynaud

Why

Both caches are hardcoded under std::env::temp_dir(). On a node, /tmp can be a tmpfs, can be wiped on reboot and is not sized for a multi hundred megabyte SRS, so an operator has no way to place the cache on suitable storage.

What

Let the cache location be chosen by the caller, and keep the current temporary directory only as the default.

How

  • Expose the cache root of KeyProvider instead of hardcoding std::env::temp_dir() (circuits/key_provider.rs, for_non_recursive_circuit and for_recursive_circuit)
  • Expose the cache root of TrustedSetupProvider instead of hardcoding it in its Default implementation (circuits/trusted_setup.rs)
  • Thread the configured location from the aggregator and the signer down to Clerk (protocol/aggregate_signature/clerk.rs)
  • Document the disk space and the persistence expectations of the cache directory

Activity

  1. HusseinAdeiza commented on Sep 27, 2026

    @HusseinAdeiza
    Contributor

    I'd like to take this one. The scope is bounded and I can work from the checklist as written.

    Checked against main at cf1bb36ed. All three hardcoded sites are still live:

    • mithril-stm/src/circuits/key_provider.rs:350 and :373, KeyProvider::for_non_recursive_circuit and for_recursive_circuit, both pass std::env::temp_dir() to KeyProvider::new
    • mithril-stm/src/circuits/trusted_setup.rs:101, TrustedSetupProvider::with_downloader, joins MITHRIL_CIRCUIT_CACHE_FOLDER onto std::env::temp_dir(); Default at :237 delegates to it

    One small correction to the issue's wording: the hardcoded path in trusted_setup.rs is in with_downloader, not in the Default impl itself. Default calls with_downloader(Arc::new(NoTrustedSetupDownload)), so making the root a parameter on with_downloader covers both without touching Default.

    Plan, following the checklist order:

    1. Add a cache-root parameter to KeyProvider::for_non_recursive_circuit and for_recursive_circuit, keeping std::env::temp_dir() as the value the existing production call sites pass, so behaviour is unchanged.
    2. Add an equivalent constructor parameter to TrustedSetupProvider::with_downloader for the same reason.
    3. Thread the configured location from the aggregator and signer configuration down through the dependency-injection builder to Clerk. I will add a configuration field rather than an environment variable, since the aggregator and signer already carry their settings in config structs and that is where an operator would expect it. Default stays the temporary directory.
    4. Add the disk-space and persistence note to the existing SNARK runbook docs, which is where the cache layout is already described.

    On the test side: I will add unit coverage that a non-default cache root actually lands under the configured directory, for both the key provider and the trusted setup provider, rather than only asserting the default. Those two constructors are reachable from a unit test without a network, an SRS download or a clock, so this stays a narrow diff inside mithril-stm plus the configuration plumbing.

    If you would rather this landed as the library-level change only, with the aggregator and signer configuration in a follow-up, say so and I will scope it to items 1, 2 and 4 and leave item 3 alone.

  2. HusseinAdeiza commented on Sep 28, 2026

    @HusseinAdeiza
    Contributor

    Releasing this one, no code started.

    @jpraynaud and @hjeljeli32 asked me to keep to one issue at a time, and #3470 is still in flight with #3566 open and awaiting review. Parking three claims at once is not fair to the queue.

    I have not opened a branch, so there is nothing to hand over. The re-read in my comment above still applies if this gets picked up later: all three hardcoded sites (key_provider.rs:350 and :373, trusted_setup.rs:101 in with_downloader) were live on main at cf1bb36ed.

    Happy to re-claim once #3566 lands, or to pick it up now if you would rather I go ahead.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions