-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test connection between hosted
JDClient
,
`TranslatorSv2` and `PoolSv2`
- Loading branch information
Showing
8 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ members = [ | |
"translator", | ||
"jd-client", | ||
"jd-server", | ||
"tests-integration", | ||
] | ||
|
||
[profile.dev] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SRI JDC config | ||
downstream_address = "127.0.0.1" | ||
downstream_port = 34265 | ||
|
||
# Version support | ||
max_supported_version = 2 | ||
min_supported_version = 2 | ||
|
||
# Minimum extranonce2 size for downstream | ||
# Max value: 16 (leaves 0 bytes for search space splitting of downstreams) | ||
# Max value for CGminer: 8 | ||
# Min value: 2 | ||
min_extranonce2_size = 8 | ||
|
||
# Withhold | ||
withhold = false | ||
|
||
# Auth keys for open encrypted connection downstream | ||
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" | ||
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" | ||
cert_validity_sec = 3600 | ||
|
||
# How many time the JDC try to reinitialize itself after a failure | ||
retry = 10 | ||
|
||
# Template Provider config | ||
# Local TP (this is pointing to localhost so you must run a TP locally for this configuration to work) | ||
# tp_address = "127.0.0.1:8442" | ||
# Hosted testnet TP | ||
tp_address = "75.119.150.111:8442" | ||
tp_authority_public_key = "9azQdassggC7L3YMVcZyRJmK7qrFDj5MZNHb4LkaUrJRUhct92W" | ||
|
||
# Solo Mining config | ||
# List of coinbase outputs used to build the coinbase tx in case of Solo Mining (as last-resort solution of the pools fallback system) | ||
# ! Put your Extended Public Key or Script as output_script_value ! | ||
# ! Right now only one output is supported, so comment all the ones you don't need ! | ||
# For P2PK, P2PKH, P2WPKH, P2TR a public key is needed. For P2SH and P2WSH, a redeem script is needed. | ||
coinbase_outputs = [ | ||
#{ output_script_type = "P2PK", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" }, | ||
#{ output_script_type = "P2PKH", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" }, | ||
#{ output_script_type = "P2SH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" }, | ||
#{ output_script_type = "P2WSH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" }, | ||
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, | ||
#{ output_script_type = "P2TR", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, | ||
] | ||
|
||
[timeout] | ||
unit = "secs" | ||
value = 1 | ||
|
||
# List of upstreams (JDS) used as backup endpoints | ||
# In case of shares refused by the JDS, the fallback system will propose the same job to the next upstream in this list | ||
[[upstreams]] | ||
# authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" | ||
# pool_address = "75.119.150.111:34254" | ||
|
||
# ** Modified Here | ||
authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" | ||
pool_address = "127.0.0.1:34254" | ||
|
||
jd_address = "75.119.150.111:34264" | ||
# Pool signature (string to be included in coinbase tx) | ||
pool_signature = "Stratum v2 SRI Pool" | ||
|
||
# [[upstreams]] | ||
# authority_pubkey = "2di19GHYQnAZJmEpoUeP7C3Eg9TCcksHr23rZCC83dvUiZgiDL" | ||
# pool_address = "127.0.0.1:34254" | ||
# jd_address = "127.0.0.1:34264" | ||
# Pool signature (string to be included in coinbase tx) | ||
# pool_signature = "Stratum v2 SRI Pool" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SRI Pool config | ||
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" | ||
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" | ||
cert_validity_sec = 3600 | ||
test_only_listen_adress_plain = "0.0.0.0:34250" | ||
listen_address = "0.0.0.0:34254" | ||
|
||
# List of coinbase outputs used to build the coinbase tx | ||
# ! Right now only one output is supported, so comment all the ones you don't need ! | ||
# For P2PK, P2PKH, P2WPKH, P2TR a public key is needed. For P2SH and P2WSH, a redeem script is needed. | ||
coinbase_outputs = [ | ||
#{ output_script_type = "P2PK", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" }, | ||
#{ output_script_type = "P2PKH", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" }, | ||
#{ output_script_type = "P2SH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" }, | ||
#{ output_script_type = "P2WSH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" }, | ||
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, | ||
#{ output_script_type = "P2TR", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, | ||
] | ||
|
||
# Pool signature (string to be included in coinbase tx) | ||
pool_signature = "Stratum v2 SRI Pool" | ||
|
||
# Template Provider config | ||
# Local TP (this is pointing to localhost so you must run a TP locally for this configuration to work) | ||
# tp_address = "127.0.0.1:8442" | ||
|
||
tp_address = "75.119.150.111:8442" | ||
tp_authority_public_key = "9azQdassggC7L3YMVcZyRJmK7qrFDj5MZNHb4LkaUrJRUhct92W" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "tests-integration" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
tokio = "1.38.1" | ||
|
||
[dev-dependencies] | ||
jd_client = { version = "0.1.1", path = "../jd-client" } | ||
translator_sv2 = { version = "0.1.0", path = "../translator" } | ||
pool_sv2 = { version = "0.1.1", path = "../pool" } | ||
async-channel = "1.5.1" | ||
async-std = { version = "1.8.0" } | ||
|
||
[[test]] | ||
name = "jd_client_integration" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use async_channel::unbounded; | ||
use async_std::net::TcpStream; | ||
|
||
use jd_client::{toml, JobDeclaratorClient, Mutex}; | ||
use translator_sv2::TranslatorSv2; | ||
|
||
use pool_sv2::{mining_pool, PoolSv2}; | ||
|
||
use std::sync::Arc; | ||
|
||
async fn start_pool_sv2() { | ||
let config_path = "../pool/config-examples/integration-tests.toml"; | ||
let config = std::fs::read_to_string(config_path).unwrap(); | ||
let config = toml::from_str::<mining_pool::Configuration>(&config).expect("Failed to parse config"); | ||
PoolSv2::start(config).await; | ||
} | ||
|
||
async fn start_hosted_jd_client() -> (JobDeclaratorClient, jd_client::ProxyConfig) { | ||
let config_path = "../jd-client/config-examples/integration-tests.toml"; | ||
let config = std::fs::read_to_string(config_path).unwrap(); | ||
let config = toml::from_str::<jd_client::ProxyConfig>(&config).expect("Failed to parse config"); | ||
let task_collector = Arc::new(Mutex::new(Vec::new())); | ||
let client = JobDeclaratorClient::new(config.clone(), task_collector); | ||
(client, config) | ||
} | ||
|
||
async fn connect_to_jd_client(address: String) -> Result<TcpStream, ()> { | ||
loop { | ||
match TcpStream::connect(address.clone()).await { | ||
Ok(stream) => return Ok(stream), | ||
Err(_e) => { | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Test that the Job Declarator Client and the Translator SV2 can communicate with each other | ||
#[tokio::test] | ||
async fn test_jd_client_translator_sv2_pool_sv2_integration() { | ||
start_pool_sv2().await; | ||
let (jd_client, jd_client_config) = start_hosted_jd_client().await; | ||
let (tx_status, _rx_status) = unbounded(); | ||
let upstream = jd_client_config.upstreams.clone(); | ||
let upstream = upstream.get(0).cloned().unwrap(); | ||
let address = format!( | ||
"{}:{}", | ||
jd_client_config.downstream_address, jd_client_config.downstream_port | ||
); | ||
jd_client | ||
.clone() | ||
.initialize_jd(tx_status, upstream.clone()) | ||
.await; | ||
let stream = connect_to_jd_client(address.clone()).await; | ||
let translator_v2 = TranslatorSv2::new(stream.unwrap()); | ||
let translator_config = "../translator/config-examples/integration-tests.toml"; | ||
let translator_config = std::fs::read_to_string(translator_config).unwrap(); | ||
let translator_config = | ||
toml::from_str::<translator_sv2::proxy_config::ProxyConfig>(&translator_config).unwrap(); | ||
let (tx_status, _rx_status) = unbounded(); | ||
translator_v2.start(translator_config, tx_status).await; | ||
let upstream_address = translator_v2.upstream_address().unwrap(); | ||
assert_eq!(jd_client.downstream_address(), upstream_address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Braiins Pool Upstream Connection | ||
# upstream_authority_pubkey = "u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt" | ||
# upstream_address = "18.196.32.109" | ||
# upstream_port = 3336 | ||
|
||
# Local SRI JDC Upstream Connection | ||
upstream_address = "127.0.0.1" | ||
upstream_port = 34265 | ||
upstream_authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" | ||
|
||
# Local Mining Device Downstream Connection | ||
downstream_address = "0.0.0.0" | ||
downstream_port = 34255 | ||
|
||
# Version support | ||
max_supported_version = 2 | ||
min_supported_version = 2 | ||
|
||
# Minimum extranonce2 size for downstream | ||
# Max value: 16 (leaves 0 bytes for search space splitting of downstreams) | ||
# Max value for CGminer: 8 | ||
# Min value: 2 | ||
min_extranonce2_size = 8 | ||
|
||
# Difficulty params | ||
[downstream_difficulty_config] | ||
# hashes/s of the weakest miner that will be connecting (e.g.: 10 Th/s = 10_000_000_000_000.0) | ||
min_individual_miner_hashrate=10_000_000_000_000.0 | ||
# target number of shares per minute the miner should be sending | ||
shares_per_minute = 6.0 | ||
|
||
[upstream_difficulty_config] | ||
# interval in seconds to elapse before updating channel hashrate with the pool | ||
channel_diff_update_interval = 60 | ||
# estimated accumulated hashrate of all downstream miners (e.g.: 10 Th/s = 10_000_000_000_000.0) | ||
channel_nominal_hashrate = 10_000_000_000_000.0 |