Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions bitcoin-core-sv2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ async-channel = "1.5.1"
stratum-core = { git = "https://github.com/stratum-mining/stratum", branch = "main" }

bitcoin-capnp-types = "0.1.0"

4 changes: 2 additions & 2 deletions docker/config/jdc-config.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ max_supported_version = 2
min_supported_version = 2

# Auth keys for open encrypted connection downstream
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
authority_public_key = "<AUTHORITY_PUBLIC_KEY>"
authority_secret_key = "<AUTHORITY_SECRET_KEY>"
cert_validity_sec = 3600


Expand Down
4 changes: 2 additions & 2 deletions docker/config/pool-jds-config.toml.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SRI Pool config
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
authority_public_key = "<AUTHORITY_PUBLIC_KEY>"
authority_secret_key = "<AUTHORITY_SECRET_KEY>"
cert_validity_sec = 3600
listen_address = "0.0.0.0:3333"

Expand Down
4 changes: 2 additions & 2 deletions docker/docker_env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ JDC_SIGNATURE=Sv2MinerSignature
JDC_COINBASE_REWARD_SCRIPT=addr(tb1qr8xjkrx46yfsch7q2ts2g007haufq48n9pe6qc)
JDC_FEE_THRESHOLD=100
JDC_MIN_INTERVAL=5
JDC_UPSTREAM_AUTHORITY_PUBKEY=9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72
JDC_UPSTREAM_AUTHORITY_PUBKEY=<AUTHORITY_PUBLIC_KEY>
JDC_POOL_ADDRESS=pool_sv2
JDC_POOL_PORT=3333
JDC_UPSTREAM_JDS_ADDRESS=pool_sv2 # JDS is now embbeded in the pool
Expand All @@ -30,5 +30,5 @@ TPROXY_SHARES_PER_MINUTE=6.0
TPROXY_ENABLE_VARDIFF=true
TPROXY_UPSTREAM_ADDRESS=jd_client_sv2 # Use jd_client_sv2 for pool_and_miner_apps, pool_sv2 for pool_and_miner_apps_no_jd
TPROXY_UPSTREAM_PORT=34265 # Use 34265 for pool_and_miner_apps, 3333 for pool_and_miner_apps_no_jd
TPROXY_UPSTREAM_AUTHORITY_PUBKEY=9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72
TPROXY_UPSTREAM_AUTHORITY_PUBKEY=<AUTHORITY_PUBLIC_KEY>

30 changes: 16 additions & 14 deletions integration-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ tokio-util = { version = "0.7", default-features = false }
tracing = { version = "0.1.41", default-features = false }
tracing-subscriber = { version = "0.3.19", default-features = false }
hex = "0.4.3"
secp256k1 = { version = "0.28.2", features = ["rand", "rand-std"] }
rand = "0.8.5"


[lib]
path = "lib/mod.rs"

56 changes: 22 additions & 34 deletions integration-tests/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use jd_client_sv2::JobDeclaratorClient;
use mining_device::Secp256k1PublicKey as MiningDeviceSecp256k1PublicKey;
use once_cell::sync::OnceCell;
use pool_sv2::PoolSv2;
use rand;
use secp256k1;
use std::{
convert::TryFrom,
net::{Ipv4Addr, SocketAddr},
time::Duration,
};
Expand Down Expand Up @@ -49,6 +50,19 @@ const POOL_COINBASE_REWARD_DESCRIPTOR: &str = "addr(tb1qa0sm0hxzj0x25rh8gw5xlzwl
const JDC_COINBASE_REWARD_DESCRIPTOR: &str = "addr(tb1qpusf5256yxv50qt0pm0tue8k952fsu5lzsphft)";

static LOGGER: OnceCell<()> = OnceCell::new();
static AUTHORITY_KEYPAIR: OnceCell<(Secp256k1PublicKey, Secp256k1SecretKey)> = OnceCell::new();

/// Get or initialize the shared authority keypair for integration tests.
pub fn get_authority_keypair() -> &'static (Secp256k1PublicKey, Secp256k1SecretKey) {
AUTHORITY_KEYPAIR.get_or_init(|| {
let mut rng = rand::thread_rng();
let secp = secp256k1::Secp256k1::new();
let (secret_key, public_key) = secp.generate_keypair(&mut rng);
let (x_only, _) = public_key.x_only_public_key();

(Secp256k1PublicKey(x_only), Secp256k1SecretKey(secret_key))
})
}

/// Helper to create Sv2Tp config for Pool/JDC with default public key.
pub fn sv2_tp_config(address: SocketAddr) -> TemplateProviderType {
Expand Down Expand Up @@ -121,14 +135,7 @@ pub async fn start_pool(
) -> (PoolSv2, SocketAddr, Option<SocketAddr>) {
use pool_sv2::config::PoolConfig;
let listening_address = get_available_address();
let authority_public_key = Secp256k1PublicKey::try_from(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(),
)
.expect("failed");
let authority_secret_key = Secp256k1SecretKey::try_from(
"mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n".to_string(),
)
.expect("failed");
let (authority_public_key, authority_secret_key) = get_authority_keypair().clone();
let cert_validity_sec = 3600;
let coinbase_reward_script =
CoinbaseRewardScript::from_descriptor(POOL_COINBASE_REWARD_DESCRIPTOR).unwrap();
Expand Down Expand Up @@ -199,20 +206,11 @@ pub fn start_jdc(
let jdc_address = get_available_address();
let max_supported_version = 2;
let min_supported_version = 2;
let authority_public_key = Secp256k1PublicKey::try_from(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(),
)
.unwrap();
let authority_secret_key = Secp256k1SecretKey::try_from(
"mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n".to_string(),
)
.unwrap();
let (authority_public_key, authority_secret_key) = get_authority_keypair().clone();
let coinbase_reward_script =
CoinbaseRewardScript::from_descriptor(JDC_COINBASE_REWARD_DESCRIPTOR).unwrap();
let authority_pubkey = Secp256k1PublicKey::try_from(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(),
)
.unwrap();
let (authority_pubkey, _) = get_authority_keypair();
let authority_pubkey = authority_pubkey.clone();
let upstreams = pool
.iter()
.map(|(pool_addr, jds_addr)| {
Expand Down Expand Up @@ -275,14 +273,7 @@ pub async fn start_pool_with_jds(
let pool_address = get_available_address();
let jds_address = get_available_address();

let authority_public_key = Secp256k1PublicKey::try_from(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(),
)
.expect("failed");
let authority_secret_key = Secp256k1SecretKey::try_from(
"mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n".to_string(),
)
.expect("failed");
let (authority_public_key, authority_secret_key) = get_authority_keypair().clone();
let cert_validity_sec = 3600;
let coinbase_reward_script =
CoinbaseRewardScript::from_descriptor(POOL_COINBASE_REWARD_DESCRIPTOR).unwrap();
Expand Down Expand Up @@ -341,15 +332,12 @@ pub async fn start_sv2_translator(
.map(|upstream| {
let upstream_address = upstream.ip().to_string();
let upstream_port = upstream.port();
let upstream_authority_pubkey = Secp256k1PublicKey::try_from(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(),
)
.expect("failed");
let (upstream_authority_pubkey, _) = get_authority_keypair();

translator_sv2::config::Upstream::new(
upstream_address,
upstream_port,
upstream_authority_pubkey,
upstream_authority_pubkey.clone(),
)
})
.collect();
Expand Down
14 changes: 3 additions & 11 deletions integration-tests/lib/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::{
sync::{Arc, Mutex},
};
use stratum_apps::{
key_utils::{Secp256k1PublicKey, Secp256k1SecretKey},
network_helpers::noise_connection::Connection,
stratum_core::{
codec_sv2::{HandshakeRole, StandardEitherFrame},
Expand Down Expand Up @@ -71,16 +70,9 @@ pub async fn wait_for_client(listen_socket: SocketAddr) -> tokio::net::TcpStream
pub async fn create_downstream(
stream: tokio::net::TcpStream,
) -> Option<(Receiver<MessageFrame>, Sender<MessageFrame>)> {
let pub_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
.to_string()
.parse::<Secp256k1PublicKey>()
.unwrap()
.into_bytes();
let prv_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
.to_string()
.parse::<Secp256k1SecretKey>()
.unwrap()
.into_bytes();
let (pubkey, seckey) = crate::get_authority_keypair();
let pub_key = pubkey.clone().into_bytes();
let prv_key = seckey.clone().into_bytes();
let responder =
Responder::from_authority_kp(&pub_key, &prv_key, std::time::Duration::from_secs(10000))
.unwrap();
Expand Down
32 changes: 16 additions & 16 deletions miner-apps/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions miner-apps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
[workspace]
resolver="2"

members = [
"jd-client",
"translator",
]

exclude = [
"mining-device"
]

[profile.dev]
# Required by super_safe_lock
opt-level = 1

[profile.test]
# Required by super_safe_lock
opt-level = 1
opt-level = 1
Loading