feat(config): introduce config tree with souces - #4
Open
jayrmotta wants to merge 6 commits into
Open
Conversation
jayrmotta
force-pushed
the
feat/mip001-pool-config
branch
2 times, most recently
from
July 29, 2026 17:22
9babf72 to
3f07c5f
Compare
jayrmotta
force-pushed
the
feat/mip001-pool-config
branch
2 times, most recently
from
August 5, 2026 16:31
a335804 to
e30cb3f
Compare
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
force-pushed
the
feat/mip001-pool-config
branch
from
August 5, 2026 18:58
e30cb3f to
07040ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Configstub with a real tree, populated from env vars./api/v0HTTP API.Closes 256foundation#83.
Scope
Read-only, in-memory, no persistence, no write path for now.
MIP-0001 DR-1:
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
Configis now populated byConfig::from_env(), anddaemon.rsbuilds its job source directly from the tree instead of readingMUJINA_POOL_*env vars itself.stratum_v1::StratumV1PoolConfig(renamed fromPoolConfig) rather than defining a second, near-identical type for the API. That's the DR-1 point above applied literally:daemon.rsno longer hand-converts one pool-config shape into another before constructing aStratumV1Source— the value extracted from the tree already is the type the wire client needs.StratumV1PoolConfig.passwordis nowOption<String>, so an unset password stays distinguishable from an explicitly empty one; the wire-level"x"default moved from the daemon intoStratumV1Client::authorize(), the one place it's actually needed.GET /api/v0/configreturns the full configuration tree;GET /api/v0/sourcesandGET /api/v0/sources/{name}return the configured job sources, replacing the old telemetry-backed/sources.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 (thejob_sourcemodule,SourceRegistration,SourceEvent), so the config tree's naming now matches it.Comments
256fdnas 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.