Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = true

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = false

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = true

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = false

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = true

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = true

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = false

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ user_identity = "your_username_here"
# Aggregate channels: if true, all miners share one upstream channel; if false, each miner gets its own channel
aggregate_channels = true

# Attach worker identity TLV to share submissions for per-worker hashrate tracking
# (extension 0x0002). Disable when using Bitcoin addresses as user_identity, since
# addresses exceed the 32-byte TLV limit.
enable_worker_identity_tlv = true

# Enable this option to set a predefined log file path.
# When enabled, logs will always be written to this file.
# The CLI option --log-file (or -f) will override this setting if provided.
Expand Down
16 changes: 16 additions & 0 deletions miner-apps/translator/src/lib/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ pub struct TranslatorConfig {
/// If the upstream server doesn't support these, the translator will fail over to another
/// upstream.
pub required_extensions: Vec<u16>,
/// Whether to attach a UserIdentity TLV to SubmitSharesExtended messages for per-worker
/// hashrate tracking (extension 0x0002). When enabled, the user_identity must fit within
/// the 32-byte TLV limit. Disable this when using Bitcoin addresses as user_identity,
/// since addresses exceed 32 bytes.
#[serde(default = "default_enable_worker_identity_tlv")]
pub enable_worker_identity_tlv: bool,
/// The path to the log file for the Translator.
#[serde(default, deserialize_with = "opt_path_from_toml")]
log_file: Option<PathBuf>,
Expand All @@ -63,6 +69,10 @@ fn default_monitoring_cache_refresh_secs() -> u64 {
15
}

fn default_enable_worker_identity_tlv() -> bool {
true
}

#[derive(Debug, Deserialize, Clone)]
pub struct Upstream {
/// The address of the upstream server.
Expand Down Expand Up @@ -100,6 +110,7 @@ impl TranslatorConfig {
aggregate_channels: bool,
supported_extensions: Vec<u16>,
required_extensions: Vec<u16>,
enable_worker_identity_tlv: bool,
) -> Self {
Self {
upstreams,
Expand All @@ -113,6 +124,7 @@ impl TranslatorConfig {
aggregate_channels,
supported_extensions,
required_extensions,
enable_worker_identity_tlv,
log_file: None,
monitoring_address: None,
monitoring_cache_refresh_secs: 15,
Expand Down Expand Up @@ -222,6 +234,7 @@ mod tests {
true,
vec![],
vec![],
true,
);

assert_eq!(config.upstreams.len(), 1);
Expand Down Expand Up @@ -254,6 +267,7 @@ mod tests {
false,
vec![],
vec![],
true,
);

assert!(config.log_dir().is_none());
Expand Down Expand Up @@ -288,6 +302,7 @@ mod tests {
true,
vec![],
vec![],
true,
);

assert_eq!(config.upstreams.len(), 2);
Expand Down Expand Up @@ -315,6 +330,7 @@ mod tests {
false,
vec![],
vec![],
true,
);

assert!(!config.downstream_difficulty_config.enable_vardiff);
Expand Down
10 changes: 6 additions & 4 deletions miner-apps/translator/src/lib/sv1/sv1_server/sv1_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,19 @@ impl Sv1Server {
)
.map_err(|_| TproxyError::shutdown(TproxyErrorKind::SV1Error))?;

// Only add TLV fields with user identity in non-aggregated mode
let tlv_fields = if is_non_aggregated() {
// Only add TLV fields with user identity in non-aggregated mode when enabled.
// When disabled (or when user_identity exceeds the 32-byte TLV limit, e.g. Bitcoin
// addresses), the TLV is omitted and shares are sent without per-worker identity.
let tlv_fields = if self.config.enable_worker_identity_tlv && is_non_aggregated() {
let user_identity_string = self
.downstreams
.get(&message.downstream_id)
.unwrap()
.downstream_data
.super_safe_lock(|d| d.user_identity.clone());
UserIdentity::new(&user_identity_string)
.unwrap()
.to_tlv()
.ok()
.and_then(|ui| ui.to_tlv().ok())
.map(|tlv| vec![tlv])
} else {
None
Expand Down Expand Up @@ -1246,6 +1247,7 @@ mod tests {
true, // aggregate_channels
vec![], // supported_extensions
vec![], // required_extensions
true, // enable_worker_identity_tlv
)
}

Expand Down