Skip to content

Remove statics from tproxy and jdc#432

Merged
Shourya742 merged 5 commits intostratum-mining:mainfrom
Shourya742:2026-04-15-remove-statics-from-tproxy-and-jdc
Apr 24, 2026
Merged

Remove statics from tproxy and jdc#432
Shourya742 merged 5 commits intostratum-mining:mainfrom
Shourya742:2026-04-15-remove-statics-from-tproxy-and-jdc

Conversation

@Shourya742
Copy link
Copy Markdown
Member

This PR removes the use of static variables that were previously used to specify the operating mode (in JDC: FullTemplate / CoinbaseOnly / SoloMining, and in Tproxy: Aggregated / NonAggregated). While static approach works fine in production where a single binary simulates the process, it does not work well in integration tests (IT), where these components are used as libraries. In such cases, the test harness is built once, and static global variables are placed in the binary’s data section, remaining valid for the entire runtime. However, for testing, we need the ability to change this value dynamically in accordance to start method invocation. Although it is technically possible to mutate these values (as done in JDC), doing so can introduce non-deterministic behavior. When multiple such tasks run in parallel, they may modify the shared state concurrently without proper coordination, leading to unpredictable results.

This PR updates both Tproxy and JDC to eliminate statics and instead initialize the mode locally within the start method.

closes: #430

@Shourya742 Shourya742 force-pushed the 2026-04-15-remove-statics-from-tproxy-and-jdc branch from 8dfe1b6 to 27c48c0 Compare April 15, 2026 14:59
@Shourya742 Shourya742 requested review from GitGab19 and plebhash April 16, 2026 15:23
@Shourya742 Shourya742 force-pushed the 2026-04-15-remove-statics-from-tproxy-and-jdc branch from 27c48c0 to 5007a00 Compare April 22, 2026 07:52
@Shourya742
Copy link
Copy Markdown
Member Author

I think Gimballock's AI explained the issue here: #373 (comment)

Comment thread miner-apps/jd-client/src/lib/channel_manager/downstream_message_handler.rs Outdated
Comment thread miner-apps/jd-client/src/lib/jd_mode.rs Outdated
@plebhash
Copy link
Copy Markdown
Member

plebhash commented Apr 23, 2026

a similar integration test to avoid JDC regressions: ea9e7f3

@Shourya742 Shourya742 force-pushed the 2026-04-15-remove-statics-from-tproxy-and-jdc branch from 5007a00 to 0b4daf8 Compare April 24, 2026 06:44
@Shourya742
Copy link
Copy Markdown
Member Author

a similar integration test to avoid JDC regressions: ea9e7f3

Picked, thanks

Comment thread miner-apps/jd-client/src/lib/jd_mode.rs Outdated
@Shourya742 Shourya742 force-pushed the 2026-04-15-remove-statics-from-tproxy-and-jdc branch from 0b4daf8 to ae61b15 Compare April 24, 2026 14:53
Comment thread miner-apps/jd-client/src/lib/job_declarator/message_handler.rs
Comment thread miner-apps/jd-client/src/lib/jd_mode.rs
@Shourya742 Shourya742 force-pushed the 2026-04-15-remove-statics-from-tproxy-and-jdc branch from ae61b15 to 7b4a82a Compare April 24, 2026 16:05
@Shourya742 Shourya742 merged commit 319b66c into stratum-mining:main Apr 24, 2026
11 checks passed
@Shourya742 Shourya742 deleted the 2026-04-15-remove-statics-from-tproxy-and-jdc branch April 24, 2026 16:32
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.

TranslatorSv2::start() panics on second call due to process-wide OnceLock statics (breaks sequential integration tests)

3 participants