Skip to content

Refactor(jd-client): replace monolithic start loop with JdcRuntime typestate machine - #633

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

Refactor(jd-client): replace monolithic start loop with JdcRuntime typestate machine#633
nulllpc wants to merge 1 commit into
stratum-mining:mainfrom
nulllpc:npc/refactor-jdc-start

Conversation

@nulllpc

@nulllpc nulllpc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

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

Fixes #526

@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch 3 times, most recently from 27713eb to 45f79e5 Compare July 20, 2026 20:22
@nulllpc

nulllpc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

A note: in the initial sketch, ChannelManagerReady was put after SoloMiningReady and UpstreamReady but then I realized we need the ChannelManager to start first so we could send CoinbaseOutputConstraints to the template provider so I changed the order. Conceptually, I think there's no major problem there, just want to highlight this just in case.

@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch 2 times, most recently from 7dcc7ee to 5dd1782 Compare July 20, 2026 20:35

// Stop retrying and fail immediately if a shutdown signal is encountered,
// as retries are only intended for fallback scenarios.
if e.action == Action::Shutdown {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: this is a point from my old PR which I think is worth bringing over. Let me know if you think otherwise

@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch from 5dd1782 to ec4544a Compare July 22, 2026 17:15
Comment thread miner-apps/jd-client/src/lib/mod.rs Outdated
Comment thread miner-apps/jd-client/src/lib/error.rs Outdated
Comment thread miner-apps/jd-client/src/lib/jdc_runtime.rs Outdated
Comment thread miner-apps/jd-client/src/lib/jdc_runtime.rs Outdated
Comment thread miner-apps/jd-client/src/lib/jdc_runtime.rs
Comment thread miner-apps/jd-client/src/lib/jdc_runtime.rs
@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch 2 times, most recently from 537c0ef to 2f72d3f Compare July 25, 2026 16:21
Comment thread miner-apps/jd-client/src/lib/jdc_runtime.rs Outdated
Comment thread miner-apps/jd-client/src/main.rs Outdated
Comment thread miner-apps/jd-client/src/lib/mod.rs Outdated
Comment thread miner-apps/jd-client/src/lib/mod.rs Outdated
Comment thread miner-apps/jd-client/src/lib/error.rs Outdated
@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch 2 times, most recently from cd17528 to 94901fa Compare July 30, 2026 19:04
@plebhash

Copy link
Copy Markdown
Member

@nulllpc looks like fmt CI is broken, likely due to the fact that #651 was just merged

@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch 2 times, most recently from 58c6041 to 76461a0 Compare July 31, 2026 18:31

@plebhash plebhash left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@nulllpc can you please squash all commits into 1?

@nulllpc
nulllpc force-pushed the npc/refactor-jdc-start branch from 50b7941 to 93be0b3 Compare August 1, 2026 04:31
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 JobDeclaratorClient::start

3 participants