diff --git a/integration-tests/Cargo.lock b/integration-tests/Cargo.lock index 63b6566d9..ef51b0fe7 100644 --- a/integration-tests/Cargo.lock +++ b/integration-tests/Cargo.lock @@ -1025,7 +1025,7 @@ checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[package]] name = "binary_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "buffer_sv2", "derive_codec_sv2", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "buffer_sv2" version = "3.0.1" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "aes-gcm", ] @@ -1347,7 +1347,7 @@ dependencies = [ [[package]] name = "channels_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -1460,7 +1460,7 @@ dependencies = [ [[package]] name = "codec_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1489,7 +1489,7 @@ dependencies = [ [[package]] name = "common_messages_sv2" version = "9.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1790,7 +1790,7 @@ dependencies = [ [[package]] name = "derive_codec_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" [[package]] name = "digest" @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "extensions_sv2" version = "0.3.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -2042,7 +2042,7 @@ dependencies = [ [[package]] name = "framing_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "handlers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -2826,7 +2826,7 @@ dependencies = [ [[package]] name = "job_declaration_sv2" version = "10.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -3071,7 +3071,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mining_sv2" version = "12.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -3124,7 +3124,7 @@ dependencies = [ [[package]] name = "noise_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "chacha20poly1305", "rand 0.8.6", @@ -3285,7 +3285,7 @@ dependencies = [ [[package]] name = "parsers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -4398,7 +4398,7 @@ dependencies = [ [[package]] name = "stratum-core" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -4421,7 +4421,7 @@ dependencies = [ [[package]] name = "stratum_translation" version = "0.5.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -4468,7 +4468,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sv1_api" version = "6.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -4536,7 +4536,7 @@ dependencies = [ [[package]] name = "template_distribution_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] diff --git a/integration-tests/tests/jd_integration.rs b/integration-tests/tests/jd_integration.rs index 4684aa0d1..1893c17d2 100644 --- a/integration-tests/tests/jd_integration.rs +++ b/integration-tests/tests/jd_integration.rs @@ -262,6 +262,124 @@ async fn jds_reject_setup_connection_without_declare_tx_data_flag() { shutdown_all!(pool); } +// This test verifies that JDS rejects SetupConnection requesting only protocol version 3, +// since JDS only supports version 2, responding with a SetupConnectionError carrying the +// protocol-version-mismatch error code. +#[tokio::test] +async fn jds_reject_setup_connection_with_unsupported_version() { + start_tracing(); + let (tp, _tp_addr) = start_template_provider(None, DifficultyLevel::Low); + let (pool, _pool_addr, jds_addr, _) = + start_pool_with_jds(tp.bitcoin_core(), vec![], vec![], false).await; + let (sniffer, sniffer_addr) = start_sniffer("mock-jds", jds_addr, false, vec![], None); + let _mock_downstream = MockDownstream::new( + sniffer_addr, + WithSetup::yes(SetupConnectionOwned { + protocol: Protocol::JobDeclarationProtocol, + min_version: 3, + max_version: 3, + flags: 0, + endpoint_host: "0.0.0.0".try_into().unwrap(), + endpoint_port: 0, + vendor: "integration-test".try_into().unwrap(), + hardware_version: "".try_into().unwrap(), + firmware: "".try_into().unwrap(), + device_id: "".try_into().unwrap(), + }), + ) + .start() + .await; + + sniffer + .wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION) + .await; + sniffer + .wait_for_message_type( + MessageDirection::ToDownstream, + MESSAGE_TYPE_SETUP_CONNECTION_ERROR, + ) + .await; + + let setup_connection_error = sniffer.next_message_from_upstream(); + let setup_connection_error = match setup_connection_error { + Some(( + _, + AnyMessageOwned::Common(parsers_sv2::CommonMessagesOwned::SetupConnectionError(msg)), + )) => msg, + msg => panic!("Expected SetupConnectionError message, found: {:?}", msg), + }; + assert_eq!( + setup_connection_error.error_code.as_utf8_or_hex(), + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, + "SetupConnectionError message error code should be protocol-version-mismatch" + ); + + shutdown_all!(pool); +} + +// This test verifies that JDC rejects a downstream SetupConnection requesting only protocol +// version 3, since JDC only supports version 2 on its downstream interface, responding with a +// SetupConnectionError carrying the protocol-version-mismatch error code. +#[tokio::test] +async fn jdc_reject_downstream_setup_connection_with_unsupported_version() { + start_tracing(); + let (tp, tp_addr) = start_template_provider(None, DifficultyLevel::Low); + let (pool, pool_addr, jds_addr, _) = + start_pool_with_jds(tp.bitcoin_core(), vec![], vec![], false).await; + let (jdc, jdc_addr, _) = start_jdc( + &[(pool_addr, jds_addr)], + sv2_tp_config(tp_addr), + vec![], + vec![], + false, + None, + ); + let (sniffer, sniffer_addr) = start_sniffer("mock-jdc", jdc_addr, false, vec![], None); + let _mock_downstream = MockDownstream::new( + sniffer_addr, + WithSetup::yes(SetupConnectionOwned { + protocol: Protocol::MiningProtocol, + min_version: 3, + max_version: 3, + flags: 0, + endpoint_host: "0.0.0.0".try_into().unwrap(), + endpoint_port: 0, + vendor: "integration-test".try_into().unwrap(), + hardware_version: "".try_into().unwrap(), + firmware: "".try_into().unwrap(), + device_id: "".try_into().unwrap(), + }), + ) + .start() + .await; + + sniffer + .wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION) + .await; + sniffer + .wait_for_message_type( + MessageDirection::ToDownstream, + MESSAGE_TYPE_SETUP_CONNECTION_ERROR, + ) + .await; + + let setup_connection_error = sniffer.next_message_from_upstream(); + let setup_connection_error = match setup_connection_error { + Some(( + _, + AnyMessageOwned::Common(parsers_sv2::CommonMessagesOwned::SetupConnectionError(msg)), + )) => msg, + msg => panic!("Expected SetupConnectionError message, found: {:?}", msg), + }; + assert_eq!( + setup_connection_error.error_code.as_utf8_or_hex(), + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, + "SetupConnectionError message error code should be protocol-version-mismatch" + ); + + shutdown_all!(jdc, pool); +} + #[tokio::test] async fn jdc_coinbase_only_mode_rejected_by_jds() { start_tracing(); diff --git a/integration-tests/tests/pool_integration.rs b/integration-tests/tests/pool_integration.rs index 6b4fd5f3b..c7dada5dd 100644 --- a/integration-tests/tests/pool_integration.rs +++ b/integration-tests/tests/pool_integration.rs @@ -454,6 +454,56 @@ async fn pool_reject_setup_connection_with_non_mining_protocol() { shutdown_all!(translator, pool); } +// The test runs a pool and a mock downstream that sends a SetupConnection message requesting +// only protocol version 3. Since the pool only supports version 2, this test asserts that the +// pool responds with a SetupConnectionError carrying the protocol-version-mismatch error code. +#[tokio::test] +async fn pool_reject_setup_connection_with_unsupported_version() { + start_tracing(); + let (_tp, tp_addr) = start_template_provider(None, DifficultyLevel::Low); + let (pool, pool_addr, _) = start_pool(sv2_tp_config(tp_addr), vec![], vec![], false).await; + let (sniffer, sniffer_addr) = start_sniffer("0", pool_addr, false, vec![], None); + let _mock_downstream = MockDownstream::new( + sniffer_addr, + WithSetup::yes(SetupConnectionOwned { + protocol: Protocol::MiningProtocol, + min_version: 3, + max_version: 3, + flags: 0, + endpoint_host: "0.0.0.0".try_into().unwrap(), + endpoint_port: 0, + vendor: "integration-test".try_into().unwrap(), + hardware_version: "".try_into().unwrap(), + firmware: "".try_into().unwrap(), + device_id: "".try_into().unwrap(), + }), + ) + .start() + .await; + + sniffer + .wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION) + .await; + sniffer + .wait_for_message_type( + MessageDirection::ToDownstream, + MESSAGE_TYPE_SETUP_CONNECTION_ERROR, + ) + .await; + + let setup_connection_error = sniffer.next_message_from_upstream(); + let setup_connection_error = match setup_connection_error { + Some((_, AnyMessageOwned::Common(CommonMessagesOwned::SetupConnectionError(msg)))) => msg, + msg => panic!("Expected SetupConnectionError message, found: {:?}", msg), + }; + assert_eq!( + setup_connection_error.error_code.as_utf8_or_hex(), + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, + "SetupConnectionError message error code should be protocol-version-mismatch" + ); + shutdown_all!(pool); +} + // This test verifies that pool rejects SetCustomMiningJob when it is started without embedded JDS // (`start_pool` with no `[jds]` config). #[tokio::test] diff --git a/miner-apps/Cargo.lock b/miner-apps/Cargo.lock index 4f0a88eab..730a33fe9 100644 --- a/miner-apps/Cargo.lock +++ b/miner-apps/Cargo.lock @@ -839,7 +839,7 @@ checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[package]] name = "binary_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "buffer_sv2", "derive_codec_sv2", @@ -1005,7 +1005,7 @@ dependencies = [ [[package]] name = "buffer_sv2" version = "3.0.1" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "aes-gcm", ] @@ -1136,7 +1136,7 @@ dependencies = [ [[package]] name = "channels_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -1228,7 +1228,7 @@ dependencies = [ [[package]] name = "codec_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1266,7 +1266,7 @@ dependencies = [ [[package]] name = "common_messages_sv2" version = "9.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1476,7 +1476,7 @@ dependencies = [ [[package]] name = "derive_codec_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" [[package]] name = "digest" @@ -1644,7 +1644,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "extensions_sv2" version = "0.3.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1712,7 +1712,7 @@ dependencies = [ [[package]] name = "framing_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "handlers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -2405,7 +2405,7 @@ dependencies = [ [[package]] name = "job_declaration_sv2" version = "10.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -2597,7 +2597,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mining_sv2" version = "12.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -2637,7 +2637,7 @@ dependencies = [ [[package]] name = "noise_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "chacha20poly1305", "rand 0.8.5", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "parsers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "stratum-core" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3793,7 +3793,7 @@ dependencies = [ [[package]] name = "stratum_translation" version = "0.5.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3840,7 +3840,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sv1_api" version = "6.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3896,7 +3896,7 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" [[package]] name = "template_distribution_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] diff --git a/miner-apps/jd-client/src/lib/downstream/common_message_handler.rs b/miner-apps/jd-client/src/lib/downstream/common_message_handler.rs index ccd3f07b6..21568dbb4 100644 --- a/miner-apps/jd-client/src/lib/downstream/common_message_handler.rs +++ b/miner-apps/jd-client/src/lib/downstream/common_message_handler.rs @@ -8,6 +8,7 @@ use stratum_apps::monitoring::client::Sv2ClientKind; use stratum_apps::{ stratum_core::{ common_messages_sv2::{ + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_FEATURE_FLAGS, ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_PROTOCOL, Protocol, SetupConnectionErrorOwned, SetupConnectionOwned, SetupConnectionSuccess, has_requires_std_job, has_work_selection, @@ -15,7 +16,7 @@ use stratum_apps::{ handlers_sv2::HandleCommonMessagesFromClientOwnedAsync, parsers_sv2::{AnyMessageOwned, Tlv}, }, - utils::types::Sv2Frame, + utils::types::{SUPPORTED_PROTOCOL_VERSION, Sv2Frame}, }; use tracing::{error, info}; @@ -39,16 +40,22 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { // - If the client requests another protocol, the connection is rejected with a // [`SetupConnectionError`] (`unsupported-protocol`). // - // 2. Feature flag validation + // 2. Protocol version validation + // - The supported version (2) must fall within the client's requested + // `[min_version, max_version]` range. + // - Otherwise, the connection is rejected with a [`SetupConnectionError`] + // (`protocol-version-mismatch`). + // + // 3. Feature flag validation // - Work selection (`work_selection`) is not allowed. // - If requested, the connection is rejected with a [`SetupConnectionError`] // (`unsupported-feature-flags`). // - // 3. Standard job requirement + // 4. Standard job requirement // - If the downstream sets the `requires_standard_job` flag, it is recorded in // [`Downstream::require_std_job`]. // - // 4. Successful setup + // 5. Successful setup // - If all validations pass, a [`SetupConnectionSuccess`] message is async fn handle_setup_connection( &mut self, @@ -85,6 +92,36 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { )); } + if SUPPORTED_PROTOCOL_VERSION < msg.min_version + || SUPPORTED_PROTOCOL_VERSION > msg.max_version + { + info!( + "Rejecting connection: no supported protocol version in requested range [{}, {}] (supported: {SUPPORTED_PROTOCOL_VERSION}).", + msg.min_version, msg.max_version + ); + let response = SetupConnectionErrorOwned { + flags: 0, + error_code: ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH + .to_string() + .try_into() + .map_err(JDCError::shutdown)?, + }; + let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) + .try_into() + .map_err(JDCError::shutdown)?; + if let Err(e) = self.downstream_io.downstream_sender.send(frame).await { + error!( + "Failed to send SetupConnectionError to downstream {}: {e}", + self.downstream_id + ); + } + + return Err(JDCError::disconnect( + JDCErrorKind::SetupConnectionError, + self.downstream_id, + )); + } + if has_work_selection(msg.flags) { info!("Rejecting: work selection not allowed."); let response = SetupConnectionErrorOwned { @@ -127,7 +164,7 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { } let response = SetupConnectionSuccess { - used_version: 2, + used_version: SUPPORTED_PROTOCOL_VERSION, flags: 0, // !REQUIRES_FIXED_VERSION, !REQUIRES_EXTENDED_CHANNELS }; let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) diff --git a/pool-apps/Cargo.lock b/pool-apps/Cargo.lock index ba0ab94f8..78fde5780 100644 --- a/pool-apps/Cargo.lock +++ b/pool-apps/Cargo.lock @@ -273,7 +273,7 @@ checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[package]] name = "binary_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "buffer_sv2", "derive_codec_sv2", @@ -430,7 +430,7 @@ dependencies = [ [[package]] name = "buffer_sv2" version = "3.0.1" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "aes-gcm", ] @@ -542,7 +542,7 @@ dependencies = [ [[package]] name = "channels_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -612,7 +612,7 @@ checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "codec_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -640,7 +640,7 @@ dependencies = [ [[package]] name = "common_messages_sv2" version = "9.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -808,7 +808,7 @@ dependencies = [ [[package]] name = "derive_codec_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" [[package]] name = "digest" @@ -937,7 +937,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "extensions_sv2" version = "0.3.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -998,7 +998,7 @@ dependencies = [ [[package]] name = "framing_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1133,7 +1133,7 @@ dependencies = [ [[package]] name = "handlers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -1533,7 +1533,7 @@ dependencies = [ [[package]] name = "job_declaration_sv2" version = "10.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1653,7 +1653,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mining_sv2" version = "12.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1693,7 +1693,7 @@ dependencies = [ [[package]] name = "noise_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "chacha20poly1305", "rand", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "parsers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -2475,7 +2475,7 @@ dependencies = [ [[package]] name = "stratum-core" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -2542,7 +2542,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "template_distribution_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] diff --git a/pool-apps/jd-server/src/lib/error.rs b/pool-apps/jd-server/src/lib/error.rs index b8aa313c7..1fba17aaa 100644 --- a/pool-apps/jd-server/src/lib/error.rs +++ b/pool-apps/jd-server/src/lib/error.rs @@ -117,6 +117,7 @@ pub enum JDSErrorKind { PendingDeclareMiningJobNotFound(RequestId), UnsupportedProtocol, UnsupportedConnectionFlags, + ProtocolVersionMismatch, OneshotRecv(tokio::sync::oneshot::error::RecvError), InvalidConfig(String), PoisonLock, diff --git a/pool-apps/jd-server/src/lib/job_declarator/downstream/common_message_handler.rs b/pool-apps/jd-server/src/lib/job_declarator/downstream/common_message_handler.rs index 6940fb385..01bd95195 100644 --- a/pool-apps/jd-server/src/lib/job_declarator/downstream/common_message_handler.rs +++ b/pool-apps/jd-server/src/lib/job_declarator/downstream/common_message_handler.rs @@ -7,13 +7,14 @@ use stratum_apps::{ stratum_core::{ common_messages_sv2::{ ERROR_CODE_SETUP_CONNECTION_MISSING_DECLARE_TX_DATA_FLAG, + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_PROTOCOL, Protocol, SetupConnectionErrorOwned, SetupConnectionOwned, SetupConnectionSuccess, }, handlers_sv2::HandleCommonMessagesFromClientOwnedAsync, parsers_sv2::{AnyMessageOwned, Tlv}, }, - utils::types::Sv2Frame, + utils::types::{SUPPORTED_PROTOCOL_VERSION, Sv2Frame}, }; use tracing::info; @@ -35,8 +36,8 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { _tlv_fields: Option<&[Tlv]>, ) -> Result<(), Self::Error> { info!( - "Received `SetupConnection`: version={}, flags={:b}", - msg.min_version, msg.flags + "Received `SetupConnection`: min_version={}, max_version={}, flags={:b}", + msg.min_version, msg.max_version, msg.flags ); let downstream_id = client_id.expect("downstream id should be present"); @@ -67,6 +68,35 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { )); } + if SUPPORTED_PROTOCOL_VERSION < msg.min_version + || SUPPORTED_PROTOCOL_VERSION > msg.max_version + { + info!( + "Rejecting connection from {downstream_id}: no supported protocol version in requested range [{}, {}] (supported: {SUPPORTED_PROTOCOL_VERSION}).", + msg.min_version, msg.max_version + ); + let response = SetupConnectionErrorOwned { + flags: 0, + error_code: ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH + .to_string() + .try_into() + .map_err(JDSError::shutdown)?, + }; + let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) + .try_into() + .map_err(JDSError::shutdown)?; + self.downstream_io + .to_downstream_sender + .send(frame) + .await + .map_err(|e| JDSError::disconnect(e, downstream_id))?; + + return Err(JDSError::disconnect( + JDSErrorKind::ProtocolVersionMismatch, + downstream_id, + )); + } + // todo: add this to `common_messages_sv2` // see https://github.com/stratum-mining/stratum/issues/2117 let has_declare_tx_data = { @@ -102,7 +132,7 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { } let response = SetupConnectionSuccess { - used_version: 2, + used_version: SUPPORTED_PROTOCOL_VERSION, flags: 0, }; let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) diff --git a/pool-apps/pool/src/lib/downstream/common_message_handler.rs b/pool-apps/pool/src/lib/downstream/common_message_handler.rs index 95b5ea05c..0e8c457eb 100644 --- a/pool-apps/pool/src/lib/downstream/common_message_handler.rs +++ b/pool-apps/pool/src/lib/downstream/common_message_handler.rs @@ -6,13 +6,14 @@ use std::{convert::TryInto, sync::atomic::Ordering}; use stratum_apps::{ stratum_core::{ common_messages_sv2::{ + ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_PROTOCOL, Protocol, SetupConnectionErrorOwned, SetupConnectionOwned, SetupConnectionSuccess, has_requires_std_job, has_work_selection, }, handlers_sv2::HandleCommonMessagesFromClientOwnedAsync, parsers_sv2::{AnyMessageOwned, Tlv}, }, - utils::types::Sv2Frame, + utils::types::{SUPPORTED_PROTOCOL_VERSION, Sv2Frame}, }; use tracing::info; @@ -36,8 +37,8 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { _tlv_fields: Option<&[Tlv]>, ) -> Result<(), Self::Error> { info!( - "Received `SetupConnection`: version={}, flags={:b}", - msg.min_version, msg.flags + "Received `SetupConnection`: min_version={}, max_version={}, flags={:b}", + msg.min_version, msg.max_version, msg.flags ); let downstream_id = client_id.expect("downstream id should be present"); @@ -70,6 +71,37 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { )); } + if SUPPORTED_PROTOCOL_VERSION < msg.min_version + || SUPPORTED_PROTOCOL_VERSION > msg.max_version + { + info!( + "Rejecting connection from {downstream_id}: no supported protocol version in requested range [{}, {}] (supported: {SUPPORTED_PROTOCOL_VERSION}).", + msg.min_version, msg.max_version + ); + let response = SetupConnectionErrorOwned { + flags: 0, + error_code: ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH + .to_string() + .try_into() + .expect("error code must be valid string"), + }; + let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) + .try_into() + .map_err(PoolError::shutdown)?; + self.downstream_io + .downstream_sender + .send(frame) + .await + .map_err(|_| { + PoolError::disconnect(PoolErrorKind::ChannelErrorSender, downstream_id) + })?; + + return Err(PoolError::disconnect( + PoolErrorKind::SetupConnectionError, + downstream_id, + )); + } + self.requires_custom_work .store(has_work_selection(msg.flags), Ordering::SeqCst); self.requires_standard_jobs @@ -89,7 +121,7 @@ impl HandleCommonMessagesFromClientOwnedAsync for Downstream { response_flags |= 0x02; // REQUIRES_EXTENDED_CHANNELS } let response = SetupConnectionSuccess { - used_version: 2, + used_version: SUPPORTED_PROTOCOL_VERSION, flags: response_flags, }; let frame: Sv2Frame = AnyMessageOwned::Common(response.into()) diff --git a/stratum-apps/Cargo.lock b/stratum-apps/Cargo.lock index a36f8e9b2..a63f822e2 100644 --- a/stratum-apps/Cargo.lock +++ b/stratum-apps/Cargo.lock @@ -774,7 +774,7 @@ checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[package]] name = "binary_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "buffer_sv2", "derive_codec_sv2", @@ -940,7 +940,7 @@ dependencies = [ [[package]] name = "buffer_sv2" version = "3.0.1" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "aes-gcm", ] @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "channels_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -1117,7 +1117,7 @@ dependencies = [ [[package]] name = "codec_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1140,7 +1140,7 @@ dependencies = [ [[package]] name = "common_messages_sv2" version = "9.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "derive_codec_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" [[package]] name = "digest" @@ -1482,7 +1482,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "extensions_sv2" version = "0.3.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -1540,7 +1540,7 @@ dependencies = [ [[package]] name = "framing_sv2" version = "8.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "buffer_sv2", @@ -1711,7 +1711,7 @@ dependencies = [ [[package]] name = "handlers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -2140,7 +2140,7 @@ dependencies = [ [[package]] name = "job_declaration_sv2" version = "10.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -2328,7 +2328,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mining_sv2" version = "12.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] @@ -2368,7 +2368,7 @@ dependencies = [ [[package]] name = "noise_sv2" version = "2.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "chacha20poly1305", "rand 0.8.5", @@ -2491,7 +2491,7 @@ dependencies = [ [[package]] name = "parsers_sv2" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "common_messages_sv2", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "stratum-core" version = "0.6.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "stratum_translation" version = "0.5.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3505,7 +3505,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sv1_api" version = "6.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", "bitcoin", @@ -3561,7 +3561,7 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" [[package]] name = "template_distribution_sv2" version = "7.0.0" -source = "git+https://github.com/stratum-mining/stratum?branch=main#9b0454ec30e69912732eaee8312e75000b514215" +source = "git+https://github.com/stratum-mining/stratum?branch=main#be9ce53498ebcd7e5b89341e950687c3a14b54dc" dependencies = [ "binary_sv2", ] diff --git a/stratum-apps/src/utils/types.rs b/stratum-apps/src/utils/types.rs index 5676181de..a37fcdc40 100644 --- a/stratum-apps/src/utils/types.rs +++ b/stratum-apps/src/utils/types.rs @@ -2,6 +2,9 @@ use stratum_core::{codec_sv2::StandardSv2Frame, parsers_sv2::AnyMessageOwned}; pub const GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS: u64 = 5; +/// The SV2 protocol version supported by the apps in this workspace. +pub const SUPPORTED_PROTOCOL_VERSION: u16 = 2; + pub type TemplateId = u64; pub type UpstreamJobId = u32; pub type JobId = u32;