Skip to content

Conversation

@frrist
Copy link
Member

@frrist frrist commented Jan 26, 2026

Summary

Introduce a dynamic configuration system that allows operators to tune the aggregation manager's behavior at runtime without restarting piri. This enables gas usage optimization by adjusting how frequently the manager polls for work and how many roots it batches together when adding to the chain.

Motivation

The aggregation manager is responsible for batching aggregated roots and submitting them on-chain. The cost of these operations depends on:

  • Poll interval: How frequently the manager checks for pending work
  • Batch size: How many roots are aggregated into a single on-chain submission

Previously, changing these values required editing the config file and restarting piri. This PR enables operators to:

  1. Adjust configuration at runtime via CLI or HTTP API
  2. Optionally persist changes to the config file
  3. Reload configuration from file without restart

Changes

Core Dynamic Config Infrastructure (pkg/config/dynamic/)

Key design decisions:

  • Schemas handle both parsing (string → typed) and validation in one step
  • Updates are atomic: validate all values before applying any
  • Persist failures trigger automatic rollback of in-memory changes
  • Observer notifications happen outside the lock to prevent deadlocks

Manager Integration (pkg/pdp/aggregation/manager/)

Dynamic behavior:

  • PollInterval: When changed, the manager's ticker immediately resets to the new interval
  • BatchSize: Read on each poll cycle, no subscription needed

HTTP API (pkg/admin/httpapi/)

Endpoint Method Description
/admin/config GET List all dynamic config values
/admin/config PATCH Update config values (with optional persist)
/admin/config/reload POST Reload config from file

CLI Commands (cmd/cli/client/admin/config/)

# List all dynamic config values
piri client admin config list

# Get a specific value
piri client admin config get pdp.aggregation.manager.poll_interval

# Set a value (in-memory only)
piri client admin config set pdp.aggregation.manager.poll_interval 5m

# Set and persist to config file
piri client admin config set pdp.aggregation.manager.poll_interval 5m --persist

# Reload config from file
piri client admin config reload

Config Keys

Key Type Range Default
pdp.aggregation.manager.poll_interval Duration 1s - 1 year 30s (unchanged)
pdp.aggregation.manager.batch_size Uint 1 - 500 10 (unchanged)

Example Usage

Scenario: Operator wants to reduce gas costs by batching more roots together and polling less frequently.

# Check current values
$ piri client admin config list
{
  "pdp.aggregation.manager.batch_size": 100,
  "pdp.aggregation.manager.poll_interval": "30s"
}

# Increase batch size and poll interval, persist to survive restart
$ piri client admin config set pdp.aggregation.manager.batch_size 200 --persist
$ piri client admin config set pdp.aggregation.manager.poll_interval 2m --persist

# Changes take effect immediately - no restart needed

@frrist frrist linked an issue Jan 26, 2026 that may be closed by this pull request
@frrist frrist self-assigned this Jan 26, 2026
- allow the aggregation manager to be configured dynamicly without
  needing to restart piri for configuration to take effect.
@frrist frrist linked an issue Jan 27, 2026 that may be closed by this pull request
@frrist frrist marked this pull request as ready for review January 27, 2026 21:22
@frrist frrist requested a review from alanshaw as a code owner January 27, 2026 21:22
the changes without restarting the server.

Note: This only reloads values that are set in the config file. Values that
were set via the API but not persisted will remain unchanged.`,
Copy link
Member

Choose a reason for hiding this comment

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

Values that were set via the API but not persisted will remain unchanged.

How does that work? Do they not get replaced by the contents of the config file?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gas optimizations Allow Root Publishing Manager to be configurable

3 participants