Skip to content

refactor(translator): replace monolithic start loop with TranslatorRuntime typestate machine - #644

Open
nulllpc wants to merge 1 commit into
stratum-mining:mainfrom
nulllpc:npc/refactor-translator-start
Open

refactor(translator): replace monolithic start loop with TranslatorRuntime typestate machine#644
nulllpc wants to merge 1 commit into
stratum-mining:mainfrom
nulllpc:npc/refactor-translator-start

Conversation

@nulllpc

@nulllpc nulllpc commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Refactors the monolithic start function inside the Pool (miner-apps/translator) into a structured, typestate-based state machine (TranslatorRuntime) to manage bootstrap, component lifecycles, and graceful shutdown.

This PR also properly handles errors instead of calling unwrap or expect

Fixes #527

Comment thread miner-apps/translator/src/lib/error.rs Outdated
Comment thread miner-apps/translator/src/lib/mod.rs Outdated
Comment thread miner-apps/translator/src/lib/mod.rs
Comment thread miner-apps/translator/src/lib/translator_runtime.rs
Comment thread miner-apps/translator/src/lib/translator_runtime.rs Outdated

@par1ram par1ram left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I found a blocking integration regression on the latest merge with main. cargo check -p translator_sv2 fails with two E0308 type mismatches in bootstrap_sv1_server and bootstrap_channel_manager, while the same command passes on the current base commit (44af69e55). The existing green checks are from July 23 and do not cover the refreshed merge. Please rebase and update the new Io channel types to the current Sv1Server/ChannelManager interfaces, then rerun CI.

Comment thread miner-apps/translator/src/lib/translator_runtime.rs Outdated
…ntime typestate machine

Overhauls the Translator initialization sequence to align its API and behavior with JdcRuntime and PoolRuntime.

- Typestate Machine: Replaces the monolithic startup logic with strict Init -> IoReady -> ChannelManagerReady -> Sv1ServerReady -
  > UpstreamReady -> Running state transitions.
- Separation of Concerns: Constructs the Sv1Server, ChannelManager, and core IO channels during bootstrap, but explicitly
  activates their background execution loops later in start_services.
- Error Propagation: Ensures all startup errors cascade cleanly via Result signatures instead of failing silently or relying on
  background cancellations, allowing mod.rs to gracefully tear down partially initialized state.
- State Optimization: Reorders instantiation so ChannelManager is bootstrapped before the SV1 server, preventing unused state
  from being unnecessarily carried through early transitions.
@nulllpc
nulllpc force-pushed the npc/refactor-translator-start branch from f1478d9 to 9ac56e0 Compare August 13, 2026 20:28
@nulllpc

nulllpc commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

PR is ready for review @plebhash @bit-aloo

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.

need to refactor TranslatorSv2::start

3 participants