fix: validate username and truncate worker name at authorize time#197
fix: validate username and truncate worker name at authorize time#197average-gary wants to merge 1 commit intostratum-mining:mainfrom
Conversation
67bf1cf to
190ec4c
Compare
|
Rebased onto #162 Pr ot that branch here: |
190ec4c to
30d4718
Compare
miner-apps/translator/src/lib/sv1/sv1_server/downstream_message_handler.rs
Outdated
Show resolved
Hide resolved
| MAX_USER_IDENTITY_LENGTH, | ||
| username.len() | ||
| ); | ||
| return false; |
There was a problem hiding this comment.
Is there a more specific error type we should use here?
There was a problem hiding this comment.
The return type is defined upstream in stratum_core::sv2_api
miner-apps/translator/src/lib/sv1/sv1_server/downstream_message_handler.rs
Show resolved
Hide resolved
8acdf30 to
9583132
Compare
|
I think we have some misconceptions, and that's probably due to how we called and managed some fields in the We currently have Here the changes I would apply:
Does it make sense to you @average-gary ? |
Refactor user identity handling in the translator to properly separate channel identity from worker identity for TLV extension. Changes: - Rename authorized_worker_name to worker_name_from_authorize for clarity - Store only worker suffix (part after '.') in user_identity for TLV use - Remove username length validation at authorize time (username is ignored) - Disconnect client at share submission if worker suffix exceeds 32 bytes - Remove config-based user_identity overwrite in open_extended_mining_channel - Update integration tests to reflect new behavior The user_identity in TLV now contains only the worker portion from mining.authorize (e.g., 'worker1' from 'user.worker1'), enabling pass-through of worker identification for hashrate tracking. The channel identity sent in OpenExtendedMiningChannel continues to use the translator's config value, which is separate from the TLV worker identity.
9583132 to
1010f9a
Compare
|
Yes. I see now. But why are we waiting for share submission to fail?
We should know. The |
I'm not sure about this assertion, are you? In general, if there's an easy way to get the negotiated extensions from there, I guess we can eventually refuse the |
Ah, I see, it's just a request extension message we're sending and then we handle messages. Is there a reason we don't fully negotiate extensions in connection setup? |
I don't remember exactly why I implemented it in that way tbh. |
|
Closing in favor of #276. |
The UserIdentity TLV field has a protocol-specified maximum of 32 bytes. When downstream miners send mining.authorize with long worker names, the translator would panic on unwrap().
This fix: