Skip to content

Fix tProxy issues found by Loupe - #741

Merged
bit-aloo merged 8 commits into
stratum-mining:mainfrom
GitGab19:fix/tproxy-loupe-followups
Sep 11, 2026
Merged

bit-aloo merged 8 commits into
stratum-mining:mainfrom
GitGab19:fix/tproxy-loupe-followups

Conversation

@GitGab19

@GitGab19 GitGab19 commented Aug 19, 2026

Copy link
Copy Markdown
Member

This PR:

  • Clarify the intentional vardiff target-ordering policy.
  • Make SV1 handshake completion idempotent.
  • Continue difficulty broadcasts after an individual downstream disconnects.
  • Bound SV1 handshake messages buffered before channel establishment.
  • Document that payout verification defaults to disabled and that this trusts the upstream payout policy.
  • Reject upstream channel and group identifiers that collide in non-aggregated mode.
  • Generate and retain one shared aggregated keepalive job per tick, then deliver it to every eligible downstream.

Closes project-loupe/audit-sv2-apps#26
Closes #743
Closes project-loupe/audit-sv2-apps#126
Closes project-loupe/audit-sv2-apps#127
Closes #744
Closes project-loupe/audit-sv2-apps#130
Closes #745
Closes project-loupe/audit-sv2-apps#187
Closes project-loupe/audit-sv2-apps#185
Closes #811
Closes project-loupe/audit-sv2-apps#188
Closes #812
Closes project-loupe/audit-sv2-apps#195
Closes #813

@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch 3 times, most recently from d08e12b to 639735c Compare August 24, 2026 09:17

@bit-aloo bit-aloo 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.

I need to think around the reconnect design.

Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs
Comment thread miner-apps/translator/src/lib/sv1/downstream.rs Outdated
Comment thread miner-apps/translator/src/lib/translator_runtime.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs Outdated
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from 639735c to 2c00d65 Compare August 25, 2026 13:38
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from 2c00d65 to fe92ddd Compare August 25, 2026 13:40
@GitGab19
GitGab19 marked this pull request as draft August 27, 2026 09:28
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from fe92ddd to c6a57a5 Compare August 27, 2026 10:07
@GitGab19
GitGab19 marked this pull request as ready for review August 27, 2026 10:08
@GitGab19

Copy link
Copy Markdown
Member Author

Just pushed three more commits to cover the new #811, #812, and #813 found by Loupe.

@GitGab19
GitGab19 requested a review from bit-aloo August 27, 2026 10:12
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs
Comment thread miner-apps/translator/src/lib/sv2/channel_manager/mining_message_handler.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs Outdated
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from c6a57a5 to 733d19d Compare August 27, 2026 12:36
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch 2 times, most recently from c5e7015 to ba90896 Compare August 27, 2026 14:43
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from ba90896 to b5e41c1 Compare August 31, 2026 04:14
Comment thread integration-tests/tests/bitcoin_core_ipc_jdp_io.rs
Comment thread miner-apps/translator/README.md Outdated
@plebhash

plebhash commented Sep 8, 2026

Copy link
Copy Markdown
Member

d713bdc seems to be going in a different direction than what the scope of #811 proposes

no hard opinions on which direction is best, just pointing out the contradiction in case its not intentional

@plebhash

plebhash commented Sep 8, 2026

Copy link
Copy Markdown
Member

commits have titles but no message bodies

as described on this link listed on CONTRIBUTING.md, we should start enforcing this on all commits, so that we always have in-tree documented rationales for all code changes

(highly recommended to have this on AGENTS.md/CLAUDE.md)

@GitGab19

GitGab19 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

d713bdc seems to be going in a different direction than what the scope of #811 proposes

no hard opinions on which direction is best, just pointing out the contradiction in case its not intentional

Yeah it's intentional, but thanks for pointing it out.

commits have titles but no message bodies

Completely agree, I'll add bodies soon.

@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch 2 times, most recently from d5ea928 to 471ce4b Compare September 9, 2026 08:46
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch 3 times, most recently from 02e572c to 3dafaf3 Compare September 9, 2026 19:49
@GitGab19

GitGab19 commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

I just modified the keepalive jobs commit: 3dafaf3a.

Keepalive jobs now go only to miners whose own interval has elapsed, reusing the shared job when no new mutation is due. Late joiners also receive the latest shared job without resetting its history or rewinding nTime.

@bit-aloo bit-aloo 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.

Few questions and suggestions..

Comment thread miner-apps/translator/src/lib/sv1/downstream.rs
Comment thread miner-apps/translator/src/lib/sv2/channel_manager/mining_message_handler.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/downstream.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/downstream.rs
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs Outdated
Comment thread miner-apps/translator/src/lib/sv1/sv1_server/mod.rs Outdated
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from 3dafaf3 to e386164 Compare September 10, 2026 10:21
Document that a new vardiff target takes effect with the next
mining.notify rather than immediately. This preserves the difficulty
advertised with each job so late shares are not checked against a
newer target.
The authorize-triggered notification flush must run only once. Keep
Pending, Completing, and Complete with the notification cache under
one lock so newer work cannot overtake the flush or remain stranded
when normal forwarding is enabled.

Flush cached mining notifications in difficulty-before-notify order;
these are not repeated handshake responses. Preserve the existing
difficulty and clean-jobs policy.
A failed send to one disconnected miner previously aborted
the broadcast and starved healthy downstreams of their new
difficulty. Finish the fan-out before returning the disconnect action
for the failed peer.
An SV1 miner can pipeline setup traffic while its SV2 channel is
opening. Cap that per-downstream queue at eight messages and disconnect
on the ninth so an unauthenticated peer cannot grow it without bound.
Keep the existing Bitcoin Core IPC integration test aligned with
rustfmt output. This is a formatting-only change with no runtime
behavior impact.
Make the default trust boundary explicit: payout verification is
disabled unless configured, so tProxy otherwise accepts the upstream
payout policy. Operators can then make an informed choice when enabling
the check.
Channel and group identifiers share routing state, so accepting a
reused or reserved identifier can reinterpret later messages for
the wrong owner. Reject collisions transactionally, including the
aggregated sentinel ID.
Aggregated miners share job history, but keepalive delivery follows
each miner's own idle interval. Bound shared nTime mutation by
wall-clock time and reuse the latest keepalive for miners that
become due between mutations.

Replay the current shared job for late joiners without clearing
history, rewinding nTime, or restarting the aggregate timer. Normal
upstream jobs remain on their normal delivery path.
@GitGab19
GitGab19 force-pushed the fix/tproxy-loupe-followups branch from e386164 to 912a11a Compare September 11, 2026 09:20

@bit-aloo bit-aloo 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.

ACK. Clanker suggested some non blocker, but I don't think they were interesting to block work here.

@bit-aloo
bit-aloo merged commit 6278601 into stratum-mining:main Sep 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants