|
| 1 | +# Stratum V2 Extension: Worker-Specific Hashrate Tracking |
| 2 | + |
| 3 | +## 0. Abstract |
| 4 | + |
| 5 | +This document proposes a Stratum V2 extension to enable mining pools to track individual workers (`user_identity`) within extended channels. By extending the `SubmitSharesExtended` message via `Type-Length-Value (TLV)` encoding, pools can track worker-specific hashrate while preserving the existing channel structure. |
| 6 | + |
| 7 | +Terms like "MUST," "MUST NOT," "REQUIRED," etc., follow RFC2119 standards. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 1. Extension Overview |
| 12 | + |
| 13 | +This extension modifies the existing `SubmitSharesExtended` message by introducing a **new TLV field** that contains the `user_identity` (worker name). The extension follows the [Stratum V2 TLV encoding model](../03-Protocol-Overview.md#341-stratum-v2-tlv-encoding-model), where each extension is assigned a `Type (U16)` identifier negotiated between the client and server. |
| 14 | + |
| 15 | +### 1.1 TLV Format for `user_identity` |
| 16 | +When this extension is enabled, the client MUST append the following TLV field to `SubmitSharesExtended`: |
| 17 | + |
| 18 | +| Field | Size | Description | |
| 19 | +|------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 20 | +| Type (U16 \| U8) | 3 bytes | Unique identifier for the TLV field, structured as: <br> - **Extension Type (U16)**: `0x0002` (Worker-Specific Hashrate Tracking) <br> - **Field Type (U8)**: `0x01` (`user_identity`) | |
| 21 | +| Length (U16) | 2 bytes | Length of the value (max **32 bytes**) | |
| 22 | +| Value | `N` bytes | UTF-8 encoded `user_identity` (worker name) | |
| 23 | + |
| 24 | +If `user_identity` is shorter than **32 bytes**, it MUST NOT be padded. The `Length` field MUST indicate the actual byte size. |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +### **Example TLV Encoding** |
| 29 | + |
| 30 | +``` |
| 31 | +[TYPE: 0x0002|0x01] [LENGTH: 0x000A] [VALUE: "Worker_001"] |
| 32 | +``` |
| 33 | +(Where `"Worker_001"` is 10 bytes long) |
| 34 | + |
| 35 | +**Breaking it down:** |
| 36 | +- `0x0002|0x01` → **Type (U16 | U8)** |
| 37 | + - `0x0002` (**U16 - Extension Type**) → Worker-Specific Hashrate Tracking |
| 38 | + - `0x01` (**U8 - Field Type**) → `user_identity` |
| 39 | +- `0x000A` → **Length** (10 bytes) |
| 40 | +- `"Worker_001"` → **Value** (UTF-8 encoded string) |
| 41 | + |
| 42 | +### 1.2 Extension Activation (Negotiation Process) |
| 43 | + |
| 44 | +To enable this extension, the initiator MUST send a `RequestExtensions` message immediately after the `SetupConnection` message, requesting extension `0x0002`. If the receiver supports it, it responds with a `RequestExtensions.Success` message. |
| 45 | + |
| 46 | +#### Message Exchange Example |
| 47 | + |
| 48 | +1. **Connection Setup**: |
| 49 | + ``` |
| 50 | + Client --- SetupConnection (connection details) ---> Server |
| 51 | + Client <--- SetupConnection.Success (connection accepted) ---- Server |
| 52 | + ``` |
| 53 | +
|
| 54 | +2. **Extension Request**: |
| 55 | + ``` |
| 56 | + Client --- RequestExtensions [0x0002] ---> Server |
| 57 | + ``` |
| 58 | +
|
| 59 | +3. **Server Response**: |
| 60 | + - If successful: |
| 61 | + ``` |
| 62 | + Client <--- RequestExtensions.Success [0x0002] ---- Server |
| 63 | + ``` |
| 64 | + - If an error occurs: |
| 65 | + ``` |
| 66 | + Client <--- RequestExtensions.Error [0x0002] ---- Server |
| 67 | + ``` |
| 68 | +
|
| 69 | +Once negotiated, the client MUST append the TLV containing `user_identity` to every `SubmitSharesExtended` message. |
| 70 | +
|
| 71 | +### 1.3 Behavior Based on Negotiation |
| 72 | +
|
| 73 | +- **If the extension is negotiated**: |
| 74 | + - The `user_identity` field **MUST** be included in `SubmitSharesExtended` as a TLV with Type `0x0002`. |
| 75 | +- **If the extension is not negotiated**: |
| 76 | + - The `user_identity` field **MUST** not be included. |
| 77 | + - The server **MUST** ignore any unexpected TLV fields. |
| 78 | +
|
| 79 | +Since all extensions are negotiated before use, **the order of TLV fields is not relevant**. The receiver **MUST** scan for TLV fields corresponding to known negotiated extensions. |
| 80 | +
|
| 81 | +--- |
| 82 | +
|
| 83 | +### 2. Extended `SubmitSharesExtended` Message Format |
| 84 | +After negotiation, the client appends TLV fields at the end of `SubmitSharesExtended`. |
| 85 | +Example with the `user_identity` extension enabled: |
| 86 | +``` |
| 87 | +[SubmitSharesExtended Base Fields] + [0x0002|0x01] [LENGTH] ["Worker_001"] |
| 88 | +``` |
| 89 | +Example Message in Bytes: |
| 90 | +``` |
| 91 | +<BASE PAYLOAD> + 00 02 01 00 0A 57 6F 72 6B 65 72 5F 30 30 31 |
| 92 | +``` |
| 93 | +Where: |
| 94 | +
|
| 95 | +- `00 02 01 ` → TLV Type (U16 | U8) (`extension_type = 0x0002`, `field_type = 0x01`) |
| 96 | +- `00 0A` → Length (10 bytes) |
| 97 | +- `57 6F 72 6B 65 72 5F 30 30 31` → "Worker_001" (UTF-8 encoded) |
| 98 | +
|
| 99 | +--- |
| 100 | +
|
| 101 | +### 3. Bandwidth Consideration |
| 102 | +
|
| 103 | +Including the `user_identity` field in each share submission increases message size, depending on the length of the identifier (up to 32 bytes). |
| 104 | +
|
| 105 | +For example: |
| 106 | +- **Without `user_identity`**: Share message size ~70 bytes. |
| 107 | +- **With maximum `user_identity` (32 bytes)**: Share message size ~102 bytes. |
| 108 | +
|
| 109 | +In a scenario with 10 shares per minute per channel: |
| 110 | +- **Maximum increase**: 32 bytes × 10 = 320 bytes/min, or 19.2 KB/hour. |
| 111 | +- **Average increase (20 bytes)**: 200 bytes/min, or 12 KB/hour. |
| 112 | +
|
| 113 | +--- |
| 114 | +
|
| 115 | +## 4. Implementation Notes |
| 116 | +
|
| 117 | +### 4.1 Job Difficulty Management |
| 118 | +
|
| 119 | +As the number of workers in a single extended channel increases, the time required to receive shares from all individual machines also increases. If a server wants to offer this monitoring, it should manage job difficulty accordingly to ensure timely processing of shares. |
| 120 | +
|
| 121 | +### 4.2 Privacy Considerations |
| 122 | +
|
| 123 | +Mining farms should be aware that sharing per-worker data with pools could reveal operational insights. This could potentially compromise the privacy of the mining farm's operations. |
| 124 | +
|
| 125 | +--- |
0 commit comments