Skip to content

feat(config): introduce config tree with souces - #4

Open
jayrmotta wants to merge 6 commits into
mainfrom
feat/mip001-pool-config
Open

feat(config): introduce config tree with souces#4
jayrmotta wants to merge 6 commits into
mainfrom
feat/mip001-pool-config

Conversation

@jayrmotta

@jayrmotta jayrmotta commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the first two phases of the incremental plan agreed on in mujina-mips#1 for MIP-0001 (configuration & API), using pool configuration as the pilot feature per Ryan's suggestion on #83:

  1. Replace the unimplemented Config stub with a real tree, populated from env vars.
  2. Serve that tree read-only over the existing /api/v0 HTTP API.

Closes 256foundation#83.

Scope

Read-only, in-memory, no persistence, no write path for now.

MIP-0001 DR-1:

There is no separate "API shape" and "internal shape" of configuration that the daemon has to keep in sync, and no conversion code between them.

Structs serialize directly and do include the plaintext pool password. The trust model remains the same, as the API has no authentication or authorization yet.

What changed

  • Config is now populated by Config::from_env(), and daemon.rs builds its job source directly from the tree instead of reading MUJINA_POOL_* env vars itself.
  • The config tree reuses stratum_v1::StratumV1PoolConfig (renamed from PoolConfig) rather than defining a second, near-identical type for the API. That's the DR-1 point above applied literally: daemon.rs no longer hand-converts one pool-config shape into another before constructing a StratumV1Source — the value extracted from the tree already is the type the wire client needs.
  • StratumV1PoolConfig.password is now Option<String>, so an unset password stays distinguishable from an explicitly empty one; the wire-level "x" default moved from the daemon into StratumV1Client::authorize(), the one place it's actually needed.
  • GET /api/v0/config returns the full configuration tree; GET /api/v0/sources and GET /api/v0/sources/{name} return the configured job sources, replacing the old telemetry-backed /sources.
  • Sources are typed as a kind-tagged enum (SourceKind) rather than assuming every source is a pool. "stratum_v1" is the only kind today; the tag lets a future consumer respond additively as new kinds are added — the dummy source used when none is configured, and, over time, other protocols — instead of needing a breaking shape change later. "Source" is also the vocabulary the rest of the codebase already uses for this concept (the job_source module, SourceRegistration, SourceEvent), so the config tree's naming now matches it.

Comments

  • The spec mentions 256fdn as a possible name for a source, but since we don't have an env var to name a source, nor a more advanced config file system yet, we only assign an incrementing character like a, b, c, and so on. We could introduce a name property with its own env var, or simply skip it for now and wait for config files to land.

@jayrmotta
jayrmotta force-pushed the feat/mip001-pool-config branch 2 times, most recently from 9babf72 to 3f07c5f Compare July 29, 2026 17:22
@jayrmotta jayrmotta changed the title Feat/mip001 pool config feat(mip001): pool config Jul 29, 2026
@jayrmotta jayrmotta changed the title feat(mip001): pool config feat(config): add pool config as a tree Jul 29, 2026
@jayrmotta jayrmotta changed the title feat(config): add pool config as a tree feat(config): add config tree with pools Jul 29, 2026
@jayrmotta
jayrmotta force-pushed the feat/mip001-pool-config branch 2 times, most recently from a335804 to e30cb3f Compare August 5, 2026 16:31
Prepares this type to be shared with the miner's configuration
tree, where a bare "PoolConfig" name would collide with other
job source kinds. Pure rename, no behavior change.
Change StratumV1PoolConfig.password from String to Option<String>
so an unset password stays distinguishable from an explicitly
empty one -- useful once this type is shared with the config
tree, which needs to report whether an operator configured a
password at all. The wire-level default ("x") moves from callers
into authorize(), the one place it's actually needed.

Also hand-implement Debug instead of deriving it: this type
carries a plaintext password, so the derived Debug would print
it in trace logs.
Replace the unimplemented Config stub with a tree read from
MUJINA_POOL_URL/_USER/_PASS, wired into job-source selection in
daemon.rs. Reuses stratum_v1::StratumV1PoolConfig directly rather
than defining a separate config-tree type, so daemon.rs no longer
hand-converts one shape into the other before constructing a
StratumV1Source.
Config's pool list assumed every job source is a pool. "Source"
is already the vocabulary the rest of the codebase uses for this
concept (the job_source module, SourceRegistration, SourceEvent),
and it covers more than pool connections: the dummy source used
when none is configured, and, over time, other protocols.

Rename Config.pools to Config.sources and change its type from
Vec<StratumV1PoolConfig> to Vec<SourceKind>, an enum tagged by
`kind` with a single StratumV1 variant today. The tag lets a
future consumer of the tree respond additively as source kinds
are added, instead of needing a breaking shape change later.
Config's sources had no identifying field, so nothing could
address one individually. Wrap SourceKind in a SourceConfig
struct carrying a name, assigned by position (a, b, c, ...)
until a source can be named explicitly.
…ources

Per MIP-0001's read-only config API phase: mirror config::Config
over HTTP the same way /miner already mirrors scheduler state.
GET /api/v0/config returns the full tree, /api/v0/sources the
configured sources, and /api/v0/sources/{name} a single one.
@jayrmotta
jayrmotta force-pushed the feat/mip001-pool-config branch from e30cb3f to 07040ff Compare August 5, 2026 18:58
@jayrmotta jayrmotta changed the title feat(config): add config tree with pools feat(config): introduce config tree with souces Aug 5, 2026
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.

feat: pool configuration via MIP-001 configuration and API

1 participant