diff --git a/.gitignore b/.gitignore index f104bcfa92..341e3cd477 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ lcov.info *.py **/conf/** cobertura.xml +/roles/*/*-config.toml diff --git a/protocols/v2/noise-sv2/Cargo.toml b/protocols/v2/noise-sv2/Cargo.toml index 567889b2bc..c6ce441c17 100644 --- a/protocols/v2/noise-sv2/Cargo.toml +++ b/protocols/v2/noise-sv2/Cargo.toml @@ -12,7 +12,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -secp256k1 = { version = "0.27.0", default-features = false, features =["bitcoin_hashes","alloc","rand","rand-std"] } +secp256k1 = { version = "0.28.1", default-features = false, features =["hashes", "alloc","rand","rand-std"] } rand = {version = "0.8.5", default-features = false, features = ["std","std_rng"] } aes-gcm = "0.10.2" chacha20poly1305 = "0.10.1" diff --git a/protocols/v2/noise-sv2/src/handshake.rs b/protocols/v2/noise-sv2/src/handshake.rs index d0d79b2d33..3ab0213740 100644 --- a/protocols/v2/noise-sv2/src/handshake.rs +++ b/protocols/v2/noise-sv2/src/handshake.rs @@ -3,7 +3,7 @@ use chacha20poly1305::ChaCha20Poly1305; use secp256k1::{ ecdh::SharedSecret, hashes::{sha256::Hash as Sha256Hash, Hash}, - rand, KeyPair, Secp256k1, SecretKey, XOnlyPublicKey, + rand, Keypair, Secp256k1, SecretKey, XOnlyPublicKey, }; pub trait HandshakeOp: CipherState { @@ -24,10 +24,10 @@ pub trait HandshakeOp: CipherState { *h = Sha256Hash::hash(&to_hash).to_byte_array(); } - fn generate_key() -> KeyPair { + fn generate_key() -> Keypair { let secp = Secp256k1::new(); let (secret_key, _) = secp.generate_keypair(&mut rand::thread_rng()); - let kp = KeyPair::from_secret_key(&secp, &secret_key); + let kp = Keypair::from_secret_key(&secp, &secret_key); if kp.x_only_public_key().1 == crate::PARITY { kp } else { @@ -348,9 +348,9 @@ mod test { } #[derive(Clone, Debug)] - struct KeyPairWrapper(pub Option); + struct KeypairWrapper(pub Option); - impl Arbitrary for KeyPairWrapper { + impl Arbitrary for KeypairWrapper { fn arbitrary(g: &mut quickcheck::Gen) -> Self { let secp = Secp256k1::new(); let mut secret = Vec::::arbitrary(g); @@ -365,14 +365,14 @@ mod test { assert!(secret.len() == 32); let secret: [u8; 32] = secret.try_into().unwrap(); match SecretKey::from_slice(&secret) { - Ok(secret) => KeyPairWrapper(Some(KeyPair::from_secret_key(&secp, &secret))), - Err(_) => KeyPairWrapper(None), + Ok(secret) => KeypairWrapper(Some(Keypair::from_secret_key(&secp, &secret))), + Err(_) => KeypairWrapper(None), } } } #[quickcheck_macros::quickcheck] - fn test_ecdh_1(kp1: KeyPairWrapper, kp2: KeyPairWrapper) -> TestResult { + fn test_ecdh_1(kp1: KeypairWrapper, kp2: KeypairWrapper) -> TestResult { let (kp1, kp2) = match (kp1.0, kp2.0) { (Some(kp1), Some(kp2)) => (kp1, kp2), _ => return TestResult::discard(), diff --git a/protocols/v2/noise-sv2/src/initiator.rs b/protocols/v2/noise-sv2/src/initiator.rs index d10b5d98be..938fc480cc 100644 --- a/protocols/v2/noise-sv2/src/initiator.rs +++ b/protocols/v2/noise-sv2/src/initiator.rs @@ -9,7 +9,7 @@ use crate::{ }; use aes_gcm::KeyInit; use chacha20poly1305::ChaCha20Poly1305; -use secp256k1::{KeyPair, XOnlyPublicKey}; +use secp256k1::{Keypair, XOnlyPublicKey}; pub struct Initiator { handshake_cipher: Option, @@ -20,7 +20,7 @@ pub struct Initiator { // Handshake hash h: [u8; 32], // ephemeral keypair - e: KeyPair, + e: Keypair, // upstream pub key #[allow(unused)] pk: XOnlyPublicKey, diff --git a/protocols/v2/noise-sv2/src/responder.rs b/protocols/v2/noise-sv2/src/responder.rs index 54e3558370..1c459be5ce 100644 --- a/protocols/v2/noise-sv2/src/responder.rs +++ b/protocols/v2/noise-sv2/src/responder.rs @@ -9,7 +9,7 @@ use crate::{ }; use aes_gcm::KeyInit; use chacha20poly1305::ChaCha20Poly1305; -use secp256k1::{KeyPair, Secp256k1, SecretKey}; +use secp256k1::{Keypair, Secp256k1, SecretKey}; const VERSION: u16 = 0; @@ -22,9 +22,9 @@ pub struct Responder { // Handshake hash h: [u8; 32], // ephemeral keypair - e: KeyPair, + e: Keypair, // Static pub keypair - s: KeyPair, + s: Keypair, c1: Option, c2: Option, cert_validity: u32, @@ -94,7 +94,7 @@ impl Responder { ) -> Result, Error> { let secp = Secp256k1::new(); let secret = SecretKey::from_slice(private).map_err(|_| Error::InvalidRawPrivateKey)?; - let kp = KeyPair::from_secret_key(&secp, &secret); + let kp = Keypair::from_secret_key(&secp, &secret); let pub_ = kp.x_only_public_key().0.serialize(); if public == &pub_[..] { Ok(Self::new(kp, cert_validity.as_secs() as u32)) @@ -103,7 +103,7 @@ impl Responder { } } - pub fn new(s: KeyPair, cert_validity: u32) -> Box { + pub fn new(s: Keypair, cert_validity: u32) -> Box { let mut self_ = Self { handshake_cipher: None, k: None, diff --git a/protocols/v2/noise-sv2/src/signature_message.rs b/protocols/v2/noise-sv2/src/signature_message.rs index 5f39f3e149..cacc9a7c61 100644 --- a/protocols/v2/noise-sv2/src/signature_message.rs +++ b/protocols/v2/noise-sv2/src/signature_message.rs @@ -1,4 +1,4 @@ -use secp256k1::{hashes::sha256, schnorr::Signature, KeyPair, Message, Secp256k1, XOnlyPublicKey}; +use secp256k1::{hashes::sha256, schnorr::Signature, Keypair, Message, Secp256k1, XOnlyPublicKey}; use std::{convert::TryInto, time::SystemTime}; pub struct SignatureNoiseMessage { @@ -42,7 +42,7 @@ impl SignatureNoiseMessage { false } } - pub fn sign(msg: &mut [u8; 74], kp: &KeyPair) { + pub fn sign(msg: &mut [u8; 74], kp: &Keypair) { let secp = Secp256k1::signing_only(); let m = Message::from_hashed_data::(&msg[0..10]); let signature = secp.sign_schnorr(&m, kp); diff --git a/protocols/v2/roles-logic-sv2/src/utils.rs b/protocols/v2/roles-logic-sv2/src/utils.rs index 8f3c6393d0..d9fa117920 100644 --- a/protocols/v2/roles-logic-sv2/src/utils.rs +++ b/protocols/v2/roles-logic-sv2/src/utils.rs @@ -20,7 +20,7 @@ use stratum_common::{ uint::{Uint128, Uint256}, BitArray, }, - PublicKey, Script, Transaction, + PublicKey, Script, Transaction, XOnlyPublicKey, }, }; use tracing::error; @@ -237,12 +237,13 @@ impl TryFrom for Script { // Conceptually, every Taproot output corresponds to a combination of // a single public key condition (the internal key), // and zero or more general conditions encoded in scripts organized in a tree. - let pub_key = PublicKey::from_str(&value.output_script_value) + let pub_key = XOnlyPublicKey::from_str(&value.output_script_value) .map_err(|_| Error::InvalidOutputScript)?; - Ok({ - let (pubkey_only, _) = pub_key.inner.x_only_public_key(); - Script::new_v1_p2tr::(&Secp256k1::::new(), pubkey_only, None) - }) + Ok(Script::new_v1_p2tr::( + &Secp256k1::::new(), + pub_key, + None, + )) } _ => Err(Error::UnknownOutputScriptType), } diff --git a/roles/Cargo.lock b/roles/Cargo.lock new file mode 100644 index 0000000000..289802111b --- /dev/null +++ b/roles/Cargo.lock @@ -0,0 +1,2213 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" + +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.3", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +dependencies = [ + "async-lock 3.3.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.1", + "futures-lite 2.2.0", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.1.1", + "async-executor", + "async-io 2.2.2", + "async-lock 3.3.0", + "blocking", + "futures-lite 2.2.0", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" +dependencies = [ + "async-lock 3.3.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.2.0", + "parking", + "polling 3.3.2", + "rustix 0.38.30", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-recursion" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-task" +version = "4.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "binary_codec_sv2" +version = "0.1.4" +dependencies = [ + "buffer_sv2", +] + +[[package]] +name = "binary_sv2" +version = "0.1.6" +dependencies = [ + "binary_codec_sv2", + "derive_codec_sv2", + "tracing", +] + +[[package]] +name = "bitcoin" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" +dependencies = [ + "bech32", + "bitcoin_hashes 0.11.0", + "secp256k1 0.24.3", +] + +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + +[[package]] +name = "bitcoin_hashes" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b7a2e9773ee7ae7f2560f0426c938f57902dcb9e39321b0cbd608f47ed579a4" +dependencies = [ + "byteorder", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" + +[[package]] +name = "bitcoin_hashes" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" +dependencies = [ + "bitcoin-private", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel 2.1.1", + "async-lock 3.3.0", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.2.0", + "piper", + "tracing", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +dependencies = [ + "sha2 0.9.9", +] + +[[package]] +name = "buffer_sv2" +version = "0.1.2" +dependencies = [ + "aes-gcm", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + +[[package]] +name = "codec_sv2" +version = "1.0.0" +dependencies = [ + "binary_sv2", + "buffer_sv2", + "const_sv2", + "framing_sv2", + "noise_sv2", + "tracing", +] + +[[package]] +name = "common_messages_sv2" +version = "0.1.5" +dependencies = [ + "binary_sv2", + "const_sv2", +] + +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const_sv2" +version = "0.1.2" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "derive_codec_sv2" +version = "0.1.3" +dependencies = [ + "binary_codec_sv2", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "error_handling" +version = "0.1.0" + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "framing_sv2" +version = "0.1.5" +dependencies = [ + "binary_sv2", + "buffer_sv2", + "const_sv2", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" +dependencies = [ + "ahash 0.3.8", + "autocfg", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.7", + "serde", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.3", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "jd_client" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 0.3.2", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "error_handling", + "framing_sv2", + "futures", + "key-utils", + "network_helpers", + "nohash-hasher", + "roles_logic_sv2", + "secp256k1 0.27.0", + "serde", + "stratum-common", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "jd_server" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 1.0.5", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "const_sv2", + "error_handling", + "hashbrown 0.11.2", + "hex", + "jsonrpc", + "key-utils", + "network_helpers", + "nohash-hasher", + "noise_sv2", + "rand", + "roles_logic_sv2", + "secp256k1 0.27.0", + "serde", + "serde_json", + "siphasher", + "stratum-common", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "job_declaration_sv2" +version = "0.1.0" +dependencies = [ + "binary_sv2", + "const_sv2", +] + +[[package]] +name = "js-sys" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpc" +version = "0.16.0" +dependencies = [ + "base64", + "serde", + "serde_json", +] + +[[package]] +name = "key-utils" +version = "1.0.0" +dependencies = [ + "bs58", + "secp256k1 0.27.0", + "serde", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +dependencies = [ + "value-bag", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "mining-device" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 0.3.2", + "async-std", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "const_sv2", + "futures", + "network_helpers", + "rand", + "roles_logic_sv2", + "stratum-common", +] + +[[package]] +name = "mining_proxy_sv2" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 0.3.2", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "const_sv2", + "futures", + "key-utils", + "network_helpers", + "nohash-hasher", + "once_cell", + "roles_logic_sv2", + "serde", + "stratum-common", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "mining_sv2" +version = "0.1.0" +dependencies = [ + "binary_sv2", + "const_sv2", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "network_helpers" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-std", + "binary_sv2", + "codec_sv2", + "futures", + "tokio", + "tracing", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "noise_sv2" +version = "1.0.0" +dependencies = [ + "aes-gcm", + "chacha20poly1305", + "const_sv2", + "rand", + "rand_chacha", + "secp256k1 0.27.0", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.3", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.30", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "pool_sv2" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 1.0.5", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "const_sv2", + "error_handling", + "hex", + "key-utils", + "network_helpers", + "nohash-hasher", + "noise_sv2", + "rand", + "roles_logic_sv2", + "secp256k1 0.27.0", + "serde", + "stratum-common", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "proc-macro2" +version = "1.0.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "roles_logic_sv2" +version = "0.1.0" +dependencies = [ + "binary_sv2", + "chacha20poly1305", + "common_messages_sv2", + "const_sv2", + "framing_sv2", + "job_declaration_sv2", + "mining_sv2", + "nohash-hasher", + "siphasher", + "stratum-common", + "template_distribution_sv2", + "tracing", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "bitcoin_hashes 0.11.0", + "secp256k1-sys 0.6.1", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "bitcoin_hashes 0.12.0", + "rand", + "secp256k1-sys 0.8.1", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + +[[package]] +name = "serde" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "siphasher" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "stratum-common" +version = "0.1.0" +dependencies = [ + "bitcoin", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "sv1-mining-device" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-std", + "num-bigint", + "num-traits", + "roles_logic_sv2", + "serde", + "serde_json", + "stratum-common", + "sv1_api", +] + +[[package]] +name = "sv1_api" +version = "0.1.1" +dependencies = [ + "binary_sv2", + "bitcoin_hashes 0.3.2", + "byteorder", + "hex", + "log", + "pretty_env_logger", + "serde", + "serde_json", + "tracing", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "template_distribution_sv2" +version = "0.1.5" +dependencies = [ + "binary_sv2", + "const_sv2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tokio" +version = "1.35.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.5", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "toml" +version = "0.5.6" +source = "git+https://github.com/diondokter/toml-rs?rev=c4161aa#c4161aa70202b3992dbec79b76e7a8659713b604" +dependencies = [ + "hashbrown 0.7.2", + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "translator_sv2" +version = "0.1.0" +dependencies = [ + "async-channel 1.9.0", + "async-recursion 0.3.2", + "async-std", + "binary_sv2", + "buffer_sv2", + "codec_sv2", + "error_handling", + "framing_sv2", + "futures", + "key-utils", + "network_helpers", + "once_cell", + "rand", + "roles_logic_sv2", + "serde", + "serde_json", + "sha2 0.10.8", + "stratum-common", + "sv1_api", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "value-bag" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" + +[[package]] +name = "web-sys" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/roles/jd-client/Cargo.toml b/roles/jd-client/Cargo.toml index 8d8b6da633..f62503a08e 100644 --- a/roles/jd-client/Cargo.toml +++ b/roles/jd-client/Cargo.toml @@ -6,6 +6,10 @@ description = "TODO" license = "MIT OR Apache-2.0" repository = "https://github.com/stratum-mining/stratum" +[lib] +name = "jd_client" +path = "src/lib/mod.rs" + [dependencies] stratum-common = { path = "../../common" } async-channel = "1.5.1" diff --git a/roles/jd-client/config-examples/proxy-config-hosted-example.toml b/roles/jd-client/config-examples/jdc-config-hosted-example.toml similarity index 100% rename from roles/jd-client/config-examples/proxy-config-hosted-example.toml rename to roles/jd-client/config-examples/jdc-config-hosted-example.toml diff --git a/roles/jd-client/config-examples/proxy-config-local-example.toml b/roles/jd-client/config-examples/jdc-config-local-example.toml similarity index 100% rename from roles/jd-client/config-examples/proxy-config-local-example.toml rename to roles/jd-client/config-examples/jdc-config-local-example.toml diff --git a/roles/jd-client/jdc-config.toml b/roles/jd-client/jdc-config.toml deleted file mode 100644 index 160f93a9e3..0000000000 --- a/roles/jd-client/jdc-config.toml +++ /dev/null @@ -1,63 +0,0 @@ -# SRI JDC config -downstream_address = "0.0.0.0" -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 -test_only_do_not_send_solution_to_tp = false - -# Auth keys for open encrypted connection downstream -authority_public_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -authority_secret_key = "7qbpUjScc865jyX2kiB4NVJANoC7GA7TAJupdzXWkc62" -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 = "89.116.25.191:8442" -tp_authority_pub_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -# Hosted regtest TP -# tp_address = "75.119.150.111:8442" - -# 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 BIP32 extended public key is needed -coinbase_outputs = [ - { output_script_type = "P2WPKH", 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 = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -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" - -# [[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" diff --git a/roles/jd-client/src/downstream.rs b/roles/jd-client/src/lib/downstream.rs similarity index 99% rename from roles/jd-client/src/downstream.rs rename to roles/jd-client/src/lib/downstream.rs index 46df59ce7d..a89222a620 100644 --- a/roles/jd-client/src/downstream.rs +++ b/roles/jd-client/src/lib/downstream.rs @@ -1,5 +1,4 @@ -use crate::{ - error, +use super::{ job_declarator::JobDeclarator, status::{self, State}, upstream_sv2::Upstream as UpstreamMiningNode, @@ -20,7 +19,7 @@ use roles_logic_sv2::{ template_distribution_sv2::{NewTemplate, SubmitSolution}, utils::Mutex, }; -use tracing::{debug, info, warn}; +use tracing::{debug, error, info, warn}; use codec_sv2::{Frame, HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; @@ -352,7 +351,7 @@ impl DownstreamMiningNode { pool_output: &[u8], ) -> Result<(), Error> { if !self_mutex.safe_lock(|s| s.status.have_channel()).unwrap() { - crate::IS_NEW_TEMPLATE_HANDLED.store(true, std::sync::atomic::Ordering::Release); + super::IS_NEW_TEMPLATE_HANDLED.store(true, std::sync::atomic::Ordering::Release); return Ok(()); } let mut pool_out = &pool_output[0..]; @@ -387,7 +386,7 @@ impl DownstreamMiningNode { } // See coment on the definition of the global for memory // ordering - crate::IS_NEW_TEMPLATE_HANDLED.store(true, std::sync::atomic::Ordering::Release); + super::IS_NEW_TEMPLATE_HANDLED.store(true, std::sync::atomic::Ordering::Release); Ok(()) } diff --git a/roles/jd-client/src/error.rs b/roles/jd-client/src/lib/error.rs similarity index 100% rename from roles/jd-client/src/error.rs rename to roles/jd-client/src/lib/error.rs diff --git a/roles/jd-client/src/job_declarator/message_handler.rs b/roles/jd-client/src/lib/job_declarator/message_handler.rs similarity index 98% rename from roles/jd-client/src/job_declarator/message_handler.rs rename to roles/jd-client/src/lib/job_declarator/message_handler.rs index 11b3da0bfb..c05393c64f 100644 --- a/roles/jd-client/src/job_declarator/message_handler.rs +++ b/roles/jd-client/src/lib/job_declarator/message_handler.rs @@ -1,4 +1,4 @@ -use crate::job_declarator::JobDeclarator; +use super::JobDeclarator; use roles_logic_sv2::{ handlers::{job_declaration::ParseServerJobDeclarationMessages, SendTo_}, job_declaration_sv2::{ diff --git a/roles/jd-client/src/job_declarator/mod.rs b/roles/jd-client/src/lib/job_declarator/mod.rs similarity index 99% rename from roles/jd-client/src/job_declarator/mod.rs rename to roles/jd-client/src/lib/job_declarator/mod.rs index 6cdcc7def3..c3ade34a3a 100644 --- a/roles/jd-client/src/job_declarator/mod.rs +++ b/roles/jd-client/src/lib/job_declarator/mod.rs @@ -37,7 +37,7 @@ pub type StdFrame = StandardSv2Frame; mod setup_connection; use setup_connection::SetupConnectionHandler; -use crate::{error::Error, proxy_config::ProxyConfig, upstream_sv2::Upstream}; +use super::{error::Error, proxy_config::ProxyConfig, upstream_sv2::Upstream}; #[derive(Debug, Clone)] pub struct LastDeclareJob { diff --git a/roles/jd-client/src/job_declarator/setup_connection.rs b/roles/jd-client/src/lib/job_declarator/setup_connection.rs similarity index 100% rename from roles/jd-client/src/job_declarator/setup_connection.rs rename to roles/jd-client/src/lib/job_declarator/setup_connection.rs diff --git a/roles/jd-client/src/lib/mod.rs b/roles/jd-client/src/lib/mod.rs new file mode 100644 index 0000000000..489759420e --- /dev/null +++ b/roles/jd-client/src/lib/mod.rs @@ -0,0 +1,66 @@ +pub mod downstream; +pub mod error; +pub mod job_declarator; +pub mod proxy_config; +pub mod status; +pub mod template_receiver; +pub mod upstream_sv2; + +use std::{sync::atomic::AtomicBool, time::Duration}; + +/// Is used by the template receiver and the downstream. When a NewTemplate is received the context +/// that is running the template receiver set this value to false and then the message is sent to +/// the context that is running the Downstream that do something and then set it back to true. +/// +/// In the meantime if the context that is running the template receiver receives a SetNewPrevHash +/// it wait until the value of this global is true before doing anything. +/// +/// Acuire and Release memory ordering is used. +/// +/// Memory Ordering Explanation: +/// We use Acquire-Release ordering instead of SeqCst or Relaxed for the following reasons: +/// 1. Acquire in template receiver context ensures we see all operations before the Release store +/// the downstream. +/// 2. Within the same execution context (template receiver), a Relaxed store followed by an Acquire +/// load is sufficient. This is because operations within the same context execute in the order +/// they appear in the code. +/// 3. The combination of Release in downstream and Acquire in template receiver contexts establishes +/// a happens-before relationship, guaranteeing that we handle the SetNewPrevHash message after +/// that downstream have finished handling the NewTemplate. +/// 3. SeqCst is overkill we only need to synchronize two contexts, a globally agreed-upon order +/// between all the contexts is not necessary. +pub static IS_NEW_TEMPLATE_HANDLED: AtomicBool = AtomicBool::new(true); + +#[derive(Debug)] +pub struct PoolChangerTrigger { + timeout: Duration, + task: Option>, +} + +impl PoolChangerTrigger { + pub fn new(timeout: Duration) -> Self { + Self { + timeout, + task: None, + } + } + + pub fn start(&mut self, sender: status::Sender) { + let timeout = self.timeout; + let task = tokio::task::spawn(async move { + tokio::time::sleep(timeout).await; + let _ = sender + .send(status::Status { + state: status::State::UpstreamRogue, + }) + .await; + }); + self.task = Some(task); + } + + pub fn stop(&mut self) { + if let Some(task) = self.task.take() { + task.abort(); + } + } +} diff --git a/roles/jd-client/src/proxy_config.rs b/roles/jd-client/src/lib/proxy_config.rs similarity index 100% rename from roles/jd-client/src/proxy_config.rs rename to roles/jd-client/src/lib/proxy_config.rs diff --git a/roles/jd-client/src/status.rs b/roles/jd-client/src/lib/status.rs similarity index 99% rename from roles/jd-client/src/status.rs rename to roles/jd-client/src/lib/status.rs index af3d2355b8..44e6056d26 100644 --- a/roles/jd-client/src/status.rs +++ b/roles/jd-client/src/lib/status.rs @@ -1,4 +1,4 @@ -use crate::error::{self, Error}; +use super::error::{self, Error}; #[derive(Debug)] pub enum Sender { diff --git a/roles/jd-client/src/template_receiver/message_handler.rs b/roles/jd-client/src/lib/template_receiver/message_handler.rs similarity index 97% rename from roles/jd-client/src/template_receiver/message_handler.rs rename to roles/jd-client/src/lib/template_receiver/message_handler.rs index b5bca2ebbe..e9231f4470 100644 --- a/roles/jd-client/src/template_receiver/message_handler.rs +++ b/roles/jd-client/src/lib/template_receiver/message_handler.rs @@ -1,4 +1,4 @@ -use crate::template_receiver::TemplateRx; +use super::TemplateRx; use roles_logic_sv2::{ errors::Error, handlers::template_distribution::{ParseServerTemplateDistributionMessages, SendTo}, diff --git a/roles/jd-client/src/template_receiver/mod.rs b/roles/jd-client/src/lib/template_receiver/mod.rs similarity index 92% rename from roles/jd-client/src/template_receiver/mod.rs rename to roles/jd-client/src/lib/template_receiver/mod.rs index d01e42b36c..43275fda85 100644 --- a/roles/jd-client/src/template_receiver/mod.rs +++ b/roles/jd-client/src/lib/template_receiver/mod.rs @@ -1,33 +1,31 @@ -use codec_sv2::{HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; +use super::{job_declarator::JobDeclarator, status, PoolChangerTrigger}; +use async_channel::{Receiver, Sender}; +use codec_sv2::{Frame, HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; +use error_handling::handle_result; use key_utils::Secp256k1PublicKey; +use network_helpers::noise_connection_tokio::Connection; use roles_logic_sv2::{ + handlers::{template_distribution::ParseServerTemplateDistributionMessages, SendTo_}, job_declaration_sv2::AllocateMiningJobTokenSuccess, - template_distribution_sv2::{NewTemplate, RequestTransactionData}, + parsers::{PoolMessages, TemplateDistribution}, + template_distribution_sv2::{ + CoinbaseOutputDataSize, NewTemplate, RequestTransactionData, SubmitSolution, + }, utils::Mutex, }; +use setup_connection::SetupConnectionHandler; +use std::{convert::TryInto, net::SocketAddr, sync::Arc}; +use stratum_common::bitcoin::{consensus::Encodable, TxOut}; +use tokio::task::AbortHandle; +use tracing::{error, info}; + +mod message_handler; +mod setup_connection; -use codec_sv2::Frame; -use roles_logic_sv2::{ - handlers::{template_distribution::ParseServerTemplateDistributionMessages, SendTo_}, - parsers::{PoolMessages, TemplateDistribution}, - template_distribution_sv2::{CoinbaseOutputDataSize, SubmitSolution}, -}; pub type SendTo = SendTo_, ()>; -//use messages_sv2::parsers::JobDeclaration; pub type Message = PoolMessages<'static>; pub type StdFrame = StandardSv2Frame; pub type EitherFrame = StandardEitherFrame; -use async_channel::{Receiver, Sender}; -use network_helpers::noise_connection_tokio::Connection; -use std::{convert::TryInto, net::SocketAddr, sync::Arc}; -use tokio::task::AbortHandle; -mod message_handler; -mod setup_connection; -use crate::{job_declarator::JobDeclarator, status, PoolChangerTrigger}; -use error_handling::handle_result; -use setup_connection::SetupConnectionHandler; -use stratum_common::bitcoin::{consensus::Encodable, TxOut}; -use tracing::{error, info}; pub struct TemplateRx { receiver: Receiver, @@ -35,8 +33,8 @@ pub struct TemplateRx { /// Allows the tp recv to communicate back to the main thread any status updates /// that would interest the main thread for error handling tx_status: status::Sender, - jd: Option>>, - down: Arc>, + jd: Option>>, + down: Arc>, task_collector: Arc>>, new_template_message: Option>, pool_chaneger_trigger: Arc>, @@ -50,8 +48,8 @@ impl TemplateRx { address: SocketAddr, solution_receiver: Receiver>, tx_status: status::Sender, - jd: Option>>, - down: Arc>, + jd: Option>>, + down: Arc>, task_collector: Arc>>, pool_chaneger_trigger: Arc>, miner_coinbase_outputs: Vec, @@ -134,7 +132,7 @@ impl TemplateRx { miner_coinbase_output: &[u8], ) -> AllocateMiningJobTokenSuccess<'static> { if let Some(jd) = jd { - crate::job_declarator::JobDeclarator::get_last_token(&jd).await + super::job_declarator::JobDeclarator::get_last_token(&jd).await } else { AllocateMiningJobTokenSuccess { request_id: 0, @@ -202,7 +200,7 @@ impl TemplateRx { Some(TemplateDistribution::NewTemplate(m)) => { // See coment on the definition of the global for memory // ordering - crate::IS_NEW_TEMPLATE_HANDLED + super::IS_NEW_TEMPLATE_HANDLED .store(false, std::sync::atomic::Ordering::Release); Self::send_tx_data_request(&self_mutex, m.clone()).await; self_mutex @@ -210,7 +208,7 @@ impl TemplateRx { .unwrap(); let token = last_token.clone().unwrap(); let pool_output = token.coinbase_output.to_vec(); - crate::downstream::DownstreamMiningNode::on_new_template( + super::downstream::DownstreamMiningNode::on_new_template( &down, m.clone(), &pool_output[..], @@ -222,19 +220,19 @@ impl TemplateRx { info!("Received SetNewPrevHash, waiting for IS_NEW_TEMPLATE_HANDLED"); // See coment on the definition of the global for memory // ordering - while !crate::IS_NEW_TEMPLATE_HANDLED + while !super::IS_NEW_TEMPLATE_HANDLED .load(std::sync::atomic::Ordering::Acquire) { tokio::task::yield_now().await; } info!("IS_NEW_TEMPLATE_HANDLED ok"); if let Some(jd) = jd.as_ref() { - crate::job_declarator::JobDeclarator::on_set_new_prev_hash( + super::job_declarator::JobDeclarator::on_set_new_prev_hash( jd.clone(), m.clone(), ); } - crate::downstream::DownstreamMiningNode::on_set_new_prev_hash( + super::downstream::DownstreamMiningNode::on_set_new_prev_hash( &down, m, ) .await @@ -255,7 +253,7 @@ impl TemplateRx { let mining_token = token.mining_job_token.to_vec(); let pool_coinbase_out = token.coinbase_output.to_vec(); if let Some(jd) = jd.as_ref() { - crate::job_declarator::JobDeclarator::on_new_template( + super::job_declarator::JobDeclarator::on_new_template( jd, m.clone(), mining_token, diff --git a/roles/jd-client/src/template_receiver/setup_connection.rs b/roles/jd-client/src/lib/template_receiver/setup_connection.rs similarity index 100% rename from roles/jd-client/src/template_receiver/setup_connection.rs rename to roles/jd-client/src/lib/template_receiver/setup_connection.rs diff --git a/roles/jd-client/src/upstream_sv2/mod.rs b/roles/jd-client/src/lib/upstream_sv2/mod.rs similarity index 100% rename from roles/jd-client/src/upstream_sv2/mod.rs rename to roles/jd-client/src/lib/upstream_sv2/mod.rs diff --git a/roles/jd-client/src/upstream_sv2/upstream.rs b/roles/jd-client/src/lib/upstream_sv2/upstream.rs similarity index 97% rename from roles/jd-client/src/upstream_sv2/upstream.rs rename to roles/jd-client/src/lib/upstream_sv2/upstream.rs index b1951c3d3d..9942d3ae64 100644 --- a/roles/jd-client/src/upstream_sv2/upstream.rs +++ b/roles/jd-client/src/lib/upstream_sv2/upstream.rs @@ -1,10 +1,13 @@ -use crate::downstream::DownstreamMiningNode as Downstream; +use super::super::downstream::DownstreamMiningNode as Downstream; -use crate::{ - error::Error::{CodecNoise, PoisonLock, UpstreamIncoming}, +use super::super::{ + error::{ + Error::{CodecNoise, PoisonLock, UpstreamIncoming}, + ProxyResult, + }, status, upstream_sv2::{EitherFrame, Message, StdFrame}, - PoolChangerTrigger, ProxyResult, + PoolChangerTrigger, }; use async_channel::{Receiver, Sender}; use binary_sv2::{Seq0255, U256}; @@ -130,7 +133,9 @@ impl Upstream { .map_err(|_| PoisonLock)?; let either_frame = sv2_frame.into(); sender.send(either_frame).await.map_err(|e| { - crate::Error::ChannelErrorSender(crate::error::ChannelSendError::General(e.to_string())) + super::super::error::Error::ChannelErrorSender( + super::super::error::ChannelSendError::General(e.to_string()), + ) })?; Ok(()) } @@ -319,9 +324,12 @@ impl Upstream { let mut incoming: StdFrame = handle_result!(tx_status, incoming.try_into()); // On message receive, get the message type from the message header and get the // message payload - let message_type = incoming.get_header().ok_or( - crate::error::Error::FramingSv2(framing_sv2::Error::ExpectedSv2Frame), - ); + let message_type = + incoming + .get_header() + .ok_or(super::super::error::Error::FramingSv2( + framing_sv2::Error::ExpectedSv2Frame, + )); let message_type = handle_result!(tx_status, message_type).msg_type(); diff --git a/roles/jd-client/src/main.rs b/roles/jd-client/src/main.rs index 1d4196eb4d..4b11763a5e 100644 --- a/roles/jd-client/src/main.rs +++ b/roles/jd-client/src/main.rs @@ -1,20 +1,21 @@ +#![allow(special_module_name)] + mod args; -mod downstream; -mod error; -mod job_declarator; -mod proxy_config; -mod status; -mod template_receiver; -mod upstream_sv2; -use args::Args; -use error::{Error, ProxyResult}; -use job_declarator::JobDeclarator; -use proxy_config::ProxyConfig; -use roles_logic_sv2::utils::Mutex; -use template_receiver::TemplateRx; +mod lib; + +use lib::{ + error::{Error, ProxyResult}, + job_declarator::JobDeclarator, + proxy_config::ProxyConfig, + status, + template_receiver::TemplateRx, + PoolChangerTrigger, +}; +use args::Args; use async_channel::{bounded, unbounded}; use futures::{select, FutureExt}; +use roles_logic_sv2::utils::Mutex; use std::{ net::{IpAddr, SocketAddr}, str::FromStr, @@ -23,68 +24,8 @@ use std::{ }; use tokio::task::AbortHandle; -use crate::status::{State, Status}; -use std::sync::atomic::AtomicBool; use tracing::{error, info}; -/// -/// Is used by the template receiver and the downstream. When a NewTemplate is received the context -/// that is running the template receiver set this value to false and then the message is sent to -/// the context that is running the Downstream that do something and then set it back to true. -/// -/// In the meantime if the context that is running the template receiver receives a SetNewPrevHash -/// it wait until the value of this global is true before doing anything. -/// -/// Acuire and Release memory ordering is used. -/// -/// Memory Ordering Explanation: -/// We use Acquire-Release ordering instead of SeqCst or Relaxed for the following reasons: -/// 1. Acquire in template receiver context ensures we see all operations before the Release store -/// the downstream. -/// 2. Within the same execution context (template receiver), a Relaxed store followed by an Acquire -/// load is sufficient. This is because operations within the same context execute in the order -/// they appear in the code. -/// 3. The combination of Release in downstream and Acquire in template receiver contexts establishes -/// a happens-before relationship, guaranteeing that we handle the SetNewPrevHash message after -/// that downstream have finished handling the NewTemplate. -/// 3. SeqCst is overkill we only need to synchronize two contexts, a globally agreed-upon order -/// between all the contexts is not necessary. -pub static IS_NEW_TEMPLATE_HANDLED: AtomicBool = AtomicBool::new(true); - -#[derive(Debug)] -pub struct PoolChangerTrigger { - timeout: Duration, - task: Option>, -} - -impl PoolChangerTrigger { - pub fn new(timeout: Duration) -> Self { - Self { - timeout, - task: None, - } - } - - pub fn start(&mut self, sender: status::Sender) { - let timeout = self.timeout; - let task = tokio::task::spawn(async move { - tokio::time::sleep(timeout).await; - let _ = sender - .send(status::Status { - state: status::State::UpstreamRogue, - }) - .await; - }); - self.task = Some(task); - } - - pub fn stop(&mut self) { - if let Some(task) = self.task.take() { - task.abort(); - } - } -} - /// Process CLI args, if any. #[allow(clippy::result_large_err)] fn process_cli_args<'a>() -> ProxyResult<'a, ProxyConfig> { @@ -208,11 +149,11 @@ async fn main() { std::process::exit(0); } }; - let task_status: Status = task_status.unwrap(); + let task_status: status::Status = task_status.unwrap(); match task_status.state { // Should only be sent by the downstream listener - State::DownstreamShutdown(err) => { + status::State::DownstreamShutdown(err) => { error!("SHUTDOWN from: {}", err); tokio::time::sleep(std::time::Duration::from_secs(1)).await; task_collector @@ -225,7 +166,7 @@ async fn main() { tokio::time::sleep(std::time::Duration::from_secs(1)).await; break; } - State::UpstreamShutdown(err) => { + status::State::UpstreamShutdown(err) => { error!("SHUTDOWN from: {}", err); tokio::time::sleep(std::time::Duration::from_secs(1)).await; task_collector @@ -238,7 +179,7 @@ async fn main() { tokio::time::sleep(std::time::Duration::from_secs(1)).await; break; } - State::UpstreamRogue => { + status::State::UpstreamRogue => { error!("Changin Pool"); tokio::time::sleep(std::time::Duration::from_secs(1)).await; task_collector @@ -252,7 +193,7 @@ async fn main() { tokio::time::sleep(std::time::Duration::from_secs(1)).await; break; } - State::Healthy(msg) => { + status::State::Healthy(msg) => { info!("HEALTHY message: {}", msg); } } @@ -260,12 +201,12 @@ async fn main() { } } async fn initialize_jd_as_solo_miner( - tx_status: async_channel::Sender>, + tx_status: async_channel::Sender>, task_collector: Arc>>, timeout: Duration, ) { let proxy_config = process_cli_args().unwrap(); - let miner_tx_out = crate::proxy_config::get_coinbase_output(&proxy_config).unwrap(); + let miner_tx_out = lib::proxy_config::get_coinbase_output(&proxy_config).unwrap(); // When Downstream receive a share that meets bitcoin target it transformit in a // SubmitSolution and send it to the TemplateReceiver @@ -278,7 +219,7 @@ async fn initialize_jd_as_solo_miner( ); // Wait for downstream to connect - let downstream = downstream::listen_for_downstream_mining( + let downstream = lib::downstream::listen_for_downstream_mining( downstream_addr, None, send_solution, @@ -315,9 +256,9 @@ async fn initialize_jd_as_solo_miner( } async fn initialize_jd( - tx_status: async_channel::Sender>, + tx_status: async_channel::Sender>, task_collector: Arc>>, - upstream_config: proxy_config::Upstream, + upstream_config: lib::proxy_config::Upstream, timeout: Duration, ) { let proxy_config = process_cli_args().unwrap(); @@ -345,7 +286,7 @@ async fn initialize_jd( let (send_solution, recv_solution) = bounded(10); // Instantiate a new `Upstream` (SV2 Pool) - let upstream = match upstream_sv2::Upstream::new( + let upstream = match lib::upstream_sv2::Upstream::new( upstream_addr, upstream_config.authority_pubkey.clone(), 0, // TODO @@ -364,12 +305,12 @@ async fn initialize_jd( }; // Start receiving messages from the SV2 Upstream role - if let Err(e) = upstream_sv2::Upstream::parse_incoming(upstream.clone()) { + if let Err(e) = lib::upstream_sv2::Upstream::parse_incoming(upstream.clone()) { error!("failed to create sv2 parser: {}", e); panic!() } - match upstream_sv2::Upstream::setup_connection( + match lib::upstream_sv2::Upstream::setup_connection( upstream.clone(), proxy_config.min_supported_version, proxy_config.max_supported_version, @@ -409,8 +350,8 @@ async fn initialize_jd( Ok(c) => c, Err(e) => { let _ = tx_status - .send(Status { - state: State::UpstreamShutdown(e), + .send(status::Status { + state: status::State::UpstreamShutdown(e), }) .await; return; @@ -418,7 +359,7 @@ async fn initialize_jd( }; // Wait for downstream to connect - let downstream = downstream::listen_for_downstream_mining( + let downstream = lib::downstream::listen_for_downstream_mining( downstream_addr, Some(upstream), send_solution, diff --git a/roles/jd-server/Cargo.toml b/roles/jd-server/Cargo.toml index 592bd66faf..e2708e11a8 100644 --- a/roles/jd-server/Cargo.toml +++ b/roles/jd-server/Cargo.toml @@ -5,6 +5,10 @@ edition = "2018" license = "MIT OR Apache-2.0" repository = "https://github.com/stratum-mining/stratum" +[lib] +name = "jd_server" +path = "src/lib/mod.rs" + [dependencies] stratum-common = { path = "../../common" } async-channel = "1.5.1" diff --git a/roles/jd-server/jds-config.toml b/roles/jd-server/jds-config.toml deleted file mode 100644 index 05b2356a0f..0000000000 --- a/roles/jd-server/jds-config.toml +++ /dev/null @@ -1,24 +0,0 @@ -# SRI Pool config -authority_public_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -authority_secret_key = "7qbpUjScc865jyX2kiB4NVJANoC7GA7TAJupdzXWkc62" -cert_validity_sec = 3600 - -# 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 BIP32 extended public key is needed -coinbase_outputs = [ - { output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, -] - -# SRI Pool JD config -listen_jd_address = "0.0.0.0:34264" -# RPC config for mempool (it can be also the same TP if correctly configured) -core_rpc_url = "http://127.0.0.1" -#core_rpc_port = 18443 -core_rpc_port = 18332 -core_rpc_user = "username" -core_rpc_pass = "password" -# Timeout used for JDS mempool update -[mempool_update_timeout] -unit = "secs" -value = 1 diff --git a/roles/jd-server/src/error.rs b/roles/jd-server/src/lib/error.rs similarity index 100% rename from roles/jd-server/src/error.rs rename to roles/jd-server/src/lib/error.rs diff --git a/roles/jd-server/src/lib/job_declarator/message_handler.rs b/roles/jd-server/src/lib/job_declarator/message_handler.rs index 849e4f8f03..db8c0e2038 100644 --- a/roles/jd-server/src/lib/job_declarator/message_handler.rs +++ b/roles/jd-server/src/lib/job_declarator/message_handler.rs @@ -17,7 +17,7 @@ use roles_logic_sv2::{errors::Error, parsers::PoolMessages as AllMessages}; use stratum_common::bitcoin::consensus::Decodable; use tracing::warn; -use crate::lib::job_declarator::signed_token; +use super::signed_token; use stratum_common::bitcoin::consensus::encode::serialize; use super::JobDeclaratorDownstream; diff --git a/roles/jd-server/src/lib/job_declarator/mod.rs b/roles/jd-server/src/lib/job_declarator/mod.rs index c041d2134b..57d45c0276 100644 --- a/roles/jd-server/src/lib/job_declarator/mod.rs +++ b/roles/jd-server/src/lib/job_declarator/mod.rs @@ -1,7 +1,5 @@ pub mod message_handler; -use crate::{ - error::JdsError, lib::mempool::JDsMempool, status, Configuration, EitherFrame, StdFrame, -}; +use super::{error::JdsError, mempool::JDsMempool, status, Configuration, EitherFrame, StdFrame}; use async_channel::{Receiver, Sender}; use binary_sv2::{B0255, U256}; use codec_sv2::{Frame, HandshakeRole, Responder}; @@ -51,7 +49,7 @@ impl JobDeclaratorDownstream { // TODO: use next variables let token_to_job_map = HashMap::with_hasher(BuildNoHashHasher::default()); let tokens = Id::new(); - crate::get_coinbase_output(config).expect("Invalid coinbase output in config")[0] + super::get_coinbase_output(config).expect("Invalid coinbase output in config")[0] .consensus_encode(&mut coinbase_output) .expect("Invalid coinbase output in config"); diff --git a/roles/jd-server/src/lib/mempool/rpc_client.rs b/roles/jd-server/src/lib/mempool/rpc_client.rs index b422af5cd3..762732429d 100644 --- a/roles/jd-server/src/lib/mempool/rpc_client.rs +++ b/roles/jd-server/src/lib/mempool/rpc_client.rs @@ -1,4 +1,4 @@ -use crate::lib::mempool::{hex_iterator::HexIterator, Amount, BlockHash}; +use super::{hex_iterator::HexIterator, Amount, BlockHash}; use bitcoin::{blockdata::transaction::Transaction, consensus::Decodable}; use jsonrpc::{error::Error as JsonRpcError, Client as JosnRpcClient}; use serde::Deserialize; diff --git a/roles/jd-server/src/lib/mod.rs b/roles/jd-server/src/lib/mod.rs index b688e612af..33142b454c 100644 --- a/roles/jd-server/src/lib/mod.rs +++ b/roles/jd-server/src/lib/mod.rs @@ -1,2 +1,66 @@ +pub mod error; pub mod job_declarator; pub mod mempool; +pub mod status; + +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; +use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; +use roles_logic_sv2::{ + errors::Error, parsers::PoolMessages as JdsMessages, utils::CoinbaseOutput as CoinbaseOutput_, +}; +use serde::Deserialize; +use std::convert::{TryFrom, TryInto}; +use stratum_common::bitcoin::{Script, TxOut}; + +pub type Message = JdsMessages<'static>; +pub type StdFrame = StandardSv2Frame; +pub type EitherFrame = StandardEitherFrame; + +pub fn get_coinbase_output(config: &Configuration) -> Result, Error> { + let mut result = Vec::new(); + for coinbase_output_pool in &config.coinbase_outputs { + let coinbase_output: CoinbaseOutput_ = coinbase_output_pool.try_into()?; + let output_script: Script = coinbase_output.try_into()?; + result.push(TxOut { + value: 0, + script_pubkey: output_script, + }); + } + match result.is_empty() { + true => Err(Error::EmptyCoinbaseOutputs), + _ => Ok(result), + } +} + +impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ { + type Error = Error; + + fn try_from(pool_output: &CoinbaseOutput) -> Result { + match pool_output.output_script_type.as_str() { + "P2PK" | "P2PKH" | "P2WPKH" | "P2SH" | "P2WSH" | "P2TR" => Ok(CoinbaseOutput_ { + output_script_type: pool_output.clone().output_script_type, + output_script_value: pool_output.clone().output_script_value, + }), + _ => Err(Error::UnknownOutputScriptType), + } + } +} + +#[derive(Debug, Deserialize, Clone)] +pub struct CoinbaseOutput { + output_script_type: String, + output_script_value: String, +} + +#[derive(Debug, Deserialize, Clone)] +pub struct Configuration { + pub listen_jd_address: String, + pub authority_public_key: Secp256k1PublicKey, + pub authority_secret_key: Secp256k1SecretKey, + pub cert_validity_sec: u64, + pub coinbase_outputs: Vec, + pub core_rpc_url: String, + pub core_rpc_port: u16, + pub core_rpc_user: String, + pub core_rpc_pass: String, +} diff --git a/roles/jd-server/src/status.rs b/roles/jd-server/src/lib/status.rs similarity index 99% rename from roles/jd-server/src/status.rs rename to roles/jd-server/src/lib/status.rs index dbe125bf28..b05294e47b 100644 --- a/roles/jd-server/src/status.rs +++ b/roles/jd-server/src/lib/status.rs @@ -1,6 +1,6 @@ use roles_logic_sv2::parsers::Mining; -use crate::error::JdsError; +use super::error::JdsError; /// Each sending side of the status channel /// should be wrapped with this enum to allow diff --git a/roles/jd-server/src/main.rs b/roles/jd-server/src/main.rs index b4a38fc4e2..a2b6162c74 100644 --- a/roles/jd-server/src/main.rs +++ b/roles/jd-server/src/main.rs @@ -1,4 +1,5 @@ #![allow(special_module_name)] +use crate::lib::{mempool, status, Configuration}; use async_channel::unbounded; use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; @@ -15,45 +16,6 @@ use tracing::{error, info, warn}; use crate::lib::mempool; use roles_logic_sv2::utils::Mutex; use std::{sync::Arc, time::Duration}; - -mod error; -mod lib; -mod status; - -pub type Message = JdsMessages<'static>; -pub type StdFrame = StandardSv2Frame; -pub type EitherFrame = StandardEitherFrame; - -pub fn get_coinbase_output(config: &Configuration) -> Result, Error> { - let mut result = Vec::new(); - for coinbase_output_pool in &config.coinbase_outputs { - let coinbase_output: CoinbaseOutput_ = coinbase_output_pool.try_into()?; - let output_script: Script = coinbase_output.try_into()?; - result.push(TxOut { - value: 0, - script_pubkey: output_script, - }); - } - match result.is_empty() { - true => Err(Error::EmptyCoinbaseOutputs), - _ => Ok(result), - } -} - -impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ { - type Error = Error; - - fn try_from(pool_output: &CoinbaseOutput) -> Result { - match pool_output.output_script_type.as_str() { - "P2PK" | "P2PKH" | "P2WPKH" | "P2SH" | "P2WSH" | "P2TR" => Ok(CoinbaseOutput_ { - output_script_type: pool_output.clone().output_script_type, - output_script_value: pool_output.clone().output_script_value, - }), - _ => Err(Error::UnknownOutputScriptType), - } - } -} - use tokio::{select, task}; use crate::{lib::job_declarator::JobDeclarator, status::Status}; @@ -251,7 +213,7 @@ async fn main() { break; } }; - let task_status: Status = task_status.unwrap(); + let task_status: status::Status = task_status.unwrap(); match task_status.state { // Should only be sent by the downstream listener diff --git a/roles/mining-proxy/Cargo.toml b/roles/mining-proxy/Cargo.toml index 5a792d9460..715c9e227d 100644 --- a/roles/mining-proxy/Cargo.toml +++ b/roles/mining-proxy/Cargo.toml @@ -7,6 +7,10 @@ description = "SV2 mining proxy role" license = "MIT OR Apache-2.0" repository = "https://github.com/stratum-mining/stratum" +[lib] +name = "mining_proxy_sv2" +path = "src/lib/mod.rs" + [dependencies] stratum-common = { path = "../../common" } async-channel = "1.8.0" diff --git a/roles/mining-proxy/proxy-config-example.toml b/roles/mining-proxy/config-examples/proxy-config-example.toml similarity index 100% rename from roles/mining-proxy/proxy-config-example.toml rename to roles/mining-proxy/config-examples/proxy-config-example.toml diff --git a/roles/mining-proxy/proxy-config.toml b/roles/mining-proxy/proxy-config.toml deleted file mode 100644 index d38aabf55e..0000000000 --- a/roles/mining-proxy/proxy-config.toml +++ /dev/null @@ -1,15 +0,0 @@ -upstreams = [ - { channel_kind = "Extended", address = "127.0.0.1", port = 34265, pub_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign"}, - # { channel_kind = "Group", address = "127.0.0.1", port = 34254, pub_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign"}, -] -listen_address = "127.0.0.1" -listen_mining_port = 34255 -max_supported_version = 2 -min_supported_version = 2 -downstream_share_per_minute = 1 -coinbase_reward_sat = 5_000_000_000 -# This value is used by the proxy to communicate to the pool the expected hash rate when we open an -# extended channel, based on it the pool will set a target for the channel -expected_total_downstream_hr = 10_000 -# If set to true the proxy will try to reconnect to an upstream that drop the connection -reconnect = true diff --git a/roles/mining-proxy/src/lib/downstream_mining.rs b/roles/mining-proxy/src/lib/downstream_mining.rs index 442bd49d57..1974710ba2 100644 --- a/roles/mining-proxy/src/lib/downstream_mining.rs +++ b/roles/mining-proxy/src/lib/downstream_mining.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use super::upstream_mining::{StdFrame as UpstreamFrame, UpstreamMiningNode}; use async_channel::{Receiver, SendError, Sender}; use roles_logic_sv2::{ @@ -229,7 +231,7 @@ impl DownstreamMiningNode { let message_type = incoming.get_header().unwrap().msg_type(); let payload = incoming.payload(); - let routing_logic = crate::get_routing_logic(); + let routing_logic = super::get_routing_logic(); let next_message_to_send = ParseDownstreamMiningMessages::handle_message_mining( self_mutex.clone(), @@ -463,7 +465,7 @@ impl result: Option>, ) -> Result { let (data, message) = result.unwrap().unwrap(); - let upstream = match crate::get_routing_logic() { + let upstream = match super::get_routing_logic() { roles_logic_sv2::routing_logic::MiningRoutingLogic::Proxy(proxy_routing) => { proxy_routing .safe_lock(|r| r.downstream_to_upstream_map.get(&data).unwrap()[0].clone()) @@ -499,7 +501,7 @@ pub async fn listen_for_downstream_mining(address: SocketAddr) { let mut incoming: StdFrame = node.receiver.recv().await.unwrap().try_into().unwrap(); let message_type = incoming.get_header().unwrap().msg_type(); let payload = incoming.payload(); - let routing_logic = crate::get_common_routing_logic(); + let routing_logic = super::get_common_routing_logic(); let node = Arc::new(Mutex::new(node)); // Call handle_setup_connection or fail diff --git a/roles/mining-proxy/src/lib/mod.rs b/roles/mining-proxy/src/lib/mod.rs index b588bbdf38..353799aca6 100644 --- a/roles/mining-proxy/src/lib/mod.rs +++ b/roles/mining-proxy/src/lib/mod.rs @@ -1,3 +1,147 @@ pub mod downstream_mining; pub mod error; pub mod upstream_mining; + +use once_cell::sync::OnceCell; +use roles_logic_sv2::{ + routing_logic::{CommonRoutingLogic, MiningProxyRoutingLogic, MiningRoutingLogic}, + selectors::GeneralMiningSelector, + utils::{GroupId, Id, Mutex}, +}; +use serde::Deserialize; +use std::{net::SocketAddr, sync::Arc}; +use upstream_mining::UpstreamMiningNode; + +type RLogic = MiningProxyRoutingLogic< + downstream_mining::DownstreamMiningNode, + upstream_mining::UpstreamMiningNode, + upstream_mining::ProxyRemoteSelector, +>; + +/// Panic whene we are looking one of this 2 global mutex would force the proxy to go down as every +/// part of the program depend on them. +/// SAFTEY note: we use global mutable memory instead of a dedicated struct that use a dedicated +/// task to change the mutable state and communicate with the other parts of the program via +/// messages cause it is impossible for a task to panic while is using one of the two below Mutex. +/// So it make sense to use shared mutable memory to lower the complexity of the codebase and to +/// have some performance gain. +pub static ROUTING_LOGIC: OnceCell> = OnceCell::new(); +static MIN_EXTRANONCE_SIZE: u16 = 6; +static EXTRANONCE_RANGE_1_LENGTH: usize = 4; + +pub async fn initialize_upstreams(min_version: u16, max_version: u16) { + let upstreams = ROUTING_LOGIC + .get() + .expect("BUG: ROUTING_LOGIC has not been set yet") + .safe_lock(|r_logic| r_logic.upstream_selector.upstreams.clone()) + .unwrap(); + let available_upstreams = upstream_mining::scan(upstreams, min_version, max_version).await; + ROUTING_LOGIC + .get() + .unwrap() + .safe_lock(|rl| rl.upstream_selector.update_upstreams(available_upstreams)) + .unwrap(); +} + +fn remove_upstream(id: u32) { + let upstreams = ROUTING_LOGIC + .get() + .expect("BUG: ROUTING_LOGIC has not been set yet") + .safe_lock(|r_logic| r_logic.upstream_selector.upstreams.clone()) + .unwrap(); + let mut updated_upstreams = vec![]; + for upstream in upstreams { + if upstream.safe_lock(|s| s.get_id()).unwrap() != id { + updated_upstreams.push(upstream) + } + } + ROUTING_LOGIC + .get() + .unwrap() + .safe_lock(|rl| rl.upstream_selector.update_upstreams(updated_upstreams)) + .unwrap(); +} + +pub fn get_routing_logic() -> MiningRoutingLogic< + downstream_mining::DownstreamMiningNode, + upstream_mining::UpstreamMiningNode, + upstream_mining::ProxyRemoteSelector, + RLogic, +> { + MiningRoutingLogic::Proxy( + ROUTING_LOGIC + .get() + .expect("BUG: ROUTING_LOGIC was not set yet"), + ) +} +pub fn get_common_routing_logic() -> CommonRoutingLogic { + CommonRoutingLogic::Proxy( + ROUTING_LOGIC + .get() + .expect("BUG: ROUTING_LOGIC was not set yet"), + ) +} + +#[derive(Debug, Deserialize, Clone)] +pub struct UpstreamMiningValues { + address: String, + port: u16, + pub_key: key_utils::Secp256k1PublicKey, + channel_kind: ChannelKind, +} + +#[derive(Debug, Deserialize, Clone, Copy)] +pub enum ChannelKind { + Group, + Extended, +} + +#[derive(Debug, Deserialize, Clone)] +pub struct Config { + pub upstreams: Vec, + pub listen_address: String, + pub listen_mining_port: u16, + pub max_supported_version: u16, + pub min_supported_version: u16, + downstream_share_per_minute: f32, + expected_total_downstream_hr: f32, + reconnect: bool, +} +pub async fn initialize_r_logic( + upstreams: &[UpstreamMiningValues], + group_id: Arc>, + config: Config, +) -> RLogic { + let channel_ids = Arc::new(Mutex::new(Id::new())); + let mut upstream_mining_nodes = Vec::with_capacity(upstreams.len()); + for (index, upstream_) in upstreams.iter().enumerate() { + let socket = SocketAddr::new(upstream_.address.parse().unwrap(), upstream_.port); + + let upstream = Arc::new(Mutex::new(UpstreamMiningNode::new( + index as u32, + socket, + upstream_.pub_key.clone().into_bytes(), + upstream_.channel_kind, + group_id.clone(), + channel_ids.clone(), + config.downstream_share_per_minute, + None, + None, + config.expected_total_downstream_hr, + config.reconnect, + ))); + + match upstream_.channel_kind { + ChannelKind::Group => (), + ChannelKind::Extended => (), + } + + upstream_mining_nodes.push(upstream); + } + let upstream_selector = GeneralMiningSelector::new(upstream_mining_nodes); + MiningProxyRoutingLogic { + upstream_selector, + downstream_id_generator: Id::new(), + downstream_to_upstream_map: std::collections::HashMap::new(), + } +} diff --git a/roles/mining-proxy/src/lib/upstream_mining.rs b/roles/mining-proxy/src/lib/upstream_mining.rs index d6ab5ddc0d..d49700348e 100644 --- a/roles/mining-proxy/src/lib/upstream_mining.rs +++ b/roles/mining-proxy/src/lib/upstream_mining.rs @@ -1,4 +1,6 @@ -use crate::EXTRANONCE_RANGE_1_LENGTH; +#![allow(dead_code)] + +use super::EXTRANONCE_RANGE_1_LENGTH; use roles_logic_sv2::utils::Id; use super::downstream_mining::{Channel, DownstreamMiningNode, StdFrame as DownstreamFrame}; @@ -102,11 +104,11 @@ impl ChannelKind { } } -impl From for ChannelKind { - fn from(v: crate::ChannelKind) -> Self { +impl From for ChannelKind { + fn from(v: super::ChannelKind) -> Self { match v { - crate::ChannelKind::Group => Self::Group(GroupChannels::new()), - crate::ChannelKind::Extended => Self::Extended(None), + super::ChannelKind::Group => Self::Group(GroupChannels::new()), + super::ChannelKind::Extended => Self::Extended(None), } } } @@ -198,7 +200,7 @@ impl UpstreamMiningNode { id: u32, address: SocketAddr, authority_public_key: [u8; 32], - channel_kind: crate::ChannelKind, + channel_kind: super::ChannelKind, group_id: Arc>, channel_ids: Arc>, downstream_share_per_minute: f32, @@ -272,7 +274,7 @@ impl UpstreamMiningNode { pub async fn send( self_mutex: Arc>, sv2_frame: StdFrame, - ) -> Result<(), crate::lib::error::Error> { + ) -> Result<(), super::error::Error> { let (has_sv2_connection, mut connection, address) = self_mutex .safe_lock(|self_| { ( @@ -331,7 +333,7 @@ impl UpstreamMiningNode { } } - async fn receive(self_mutex: Arc>) -> Result { + async fn receive(self_mutex: Arc>) -> Result { let mut connection = self_mutex .safe_lock(|self_| self_.connection.clone()) .unwrap(); @@ -341,7 +343,7 @@ impl UpstreamMiningNode { Err(_) => { let address = self_mutex.safe_lock(|s| s.address).unwrap(); error!("Upstream node {} is not available", address); - Err(crate::lib::error::Error::UpstreamNotAvailabe(address)) + Err(super::error::Error::UpstreamNotAvailabe(address)) } }, None => { @@ -351,7 +353,7 @@ impl UpstreamMiningNode { } } - async fn connect(self_mutex: Arc>) -> Result<(), crate::lib::error::Error> { + async fn connect(self_mutex: Arc>) -> Result<(), super::error::Error> { let has_connection = self_mutex .safe_lock(|self_| self_.connection.is_some()) .unwrap(); @@ -363,7 +365,7 @@ impl UpstreamMiningNode { .unwrap(); let socket = TcpStream::connect(address).await.map_err(|_| { error!("Upstream node {} is not available", address); - crate::lib::error::Error::UpstreamNotAvailabe(address) + super::error::Error::UpstreamNotAvailabe(address) })?; info!( "Connected to upstream node {}: now handling noise handshake", @@ -455,7 +457,7 @@ impl UpstreamMiningNode { fn exit(self_: Arc>) { if !self_.safe_lock(|s| s.reconnect).unwrap() { - crate::remove_upstream(self_.safe_lock(|s| s.id).unwrap()); + super::remove_upstream(self_.safe_lock(|s| s.id).unwrap()); } let downstreams = self_ .safe_lock(|s| s.downstream_selector.get_all_downstreams()) @@ -578,7 +580,7 @@ impl UpstreamMiningNode { let message_type = incoming.get_header().unwrap().msg_type(); let payload = incoming.payload(); - let routing_logic = crate::get_routing_logic(); + let routing_logic = super::get_routing_logic(); let next_message_to_send = UpstreamMiningNode::handle_message_mining( self_mutex.clone(), @@ -595,7 +597,7 @@ impl UpstreamMiningNode { flags: Option, min_version: u16, max_version: u16, - ) -> Result<(), crate::lib::error::Error> { + ) -> Result<(), super::error::Error> { let flags = flags.unwrap_or(0b0000_0000_0000_0000_0000_0000_0000_0110); let (frame, downstream_hr) = self_mutex .safe_lock(|self_| { @@ -648,9 +650,7 @@ impl UpstreamMiningNode { let error_message = std::str::from_utf8(m.error_code.inner_as_ref()) .unwrap() .to_string(); - Err(crate::lib::error::Error::SetupConnectionError( - error_message, - )) + Err(super::error::Error::SetupConnectionError(error_message)) } } Ok(_) => todo!(), @@ -669,7 +669,7 @@ impl UpstreamMiningNode { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ] .into(), - min_extranonce_size: crate::MIN_EXTRANONCE_SIZE, + min_extranonce_size: super::MIN_EXTRANONCE_SIZE, }, )); Self::send(self_mutex.clone(), message.try_into().unwrap()) @@ -1274,7 +1274,7 @@ mod tests { id, address, authority_public_key, - crate::ChannelKind::Group, + super::super::ChannelKind::Group, ids, channel_ids, 10.0, diff --git a/roles/mining-proxy/src/main.rs b/roles/mining-proxy/src/main.rs index 8b0ba246c3..0725c189b1 100644 --- a/roles/mining-proxy/src/main.rs +++ b/roles/mining-proxy/src/main.rs @@ -19,150 +19,11 @@ //! #![allow(special_module_name)] mod lib; -use lib::upstream_mining::UpstreamMiningNode; -use once_cell::sync::OnceCell; -use roles_logic_sv2::{ - routing_logic::{CommonRoutingLogic, MiningProxyRoutingLogic, MiningRoutingLogic}, - selectors::GeneralMiningSelector, - utils::{GroupId, Id, Mutex}, -}; -use serde::Deserialize; + +use lib::Config; +use roles_logic_sv2::utils::{GroupId, Mutex}; use std::{net::SocketAddr, sync::Arc}; use tracing::{error, info}; -type RLogic = MiningProxyRoutingLogic< - crate::lib::downstream_mining::DownstreamMiningNode, - crate::lib::upstream_mining::UpstreamMiningNode, - crate::lib::upstream_mining::ProxyRemoteSelector, ->; - -/// Panic whene we are looking one of this 2 global mutex would force the proxy to go down as every -/// part of the program depend on them. -/// SAFTEY note: we use global mutable memory instead of a dedicated struct that use a dedicated -/// task to change the mutable state and communicate with the other parts of the program via -/// messages cause it is impossible for a task to panic while is using one of the two below Mutex. -/// So it make sense to use shared mutable memory to lower the complexity of the codebase and to -/// have some performance gain. -static ROUTING_LOGIC: OnceCell> = OnceCell::new(); -static MIN_EXTRANONCE_SIZE: u16 = 6; -static EXTRANONCE_RANGE_1_LENGTH: usize = 4; - -async fn initialize_upstreams(min_version: u16, max_version: u16) { - let upstreams = ROUTING_LOGIC - .get() - .expect("BUG: ROUTING_LOGIC has not been set yet") - .safe_lock(|r_logic| r_logic.upstream_selector.upstreams.clone()) - .unwrap(); - let available_upstreams = - crate::lib::upstream_mining::scan(upstreams, min_version, max_version).await; - ROUTING_LOGIC - .get() - .unwrap() - .safe_lock(|rl| rl.upstream_selector.update_upstreams(available_upstreams)) - .unwrap(); -} - -fn remove_upstream(id: u32) { - let upstreams = ROUTING_LOGIC - .get() - .expect("BUG: ROUTING_LOGIC has not been set yet") - .safe_lock(|r_logic| r_logic.upstream_selector.upstreams.clone()) - .unwrap(); - let mut updated_upstreams = vec![]; - for upstream in upstreams { - if upstream.safe_lock(|s| s.get_id()).unwrap() != id { - updated_upstreams.push(upstream) - } - } - ROUTING_LOGIC - .get() - .unwrap() - .safe_lock(|rl| rl.upstream_selector.update_upstreams(updated_upstreams)) - .unwrap(); -} - -pub fn get_routing_logic() -> MiningRoutingLogic< - crate::lib::downstream_mining::DownstreamMiningNode, - crate::lib::upstream_mining::UpstreamMiningNode, - crate::lib::upstream_mining::ProxyRemoteSelector, - RLogic, -> { - MiningRoutingLogic::Proxy( - ROUTING_LOGIC - .get() - .expect("BUG: ROUTING_LOGIC was not set yet"), - ) -} -pub fn get_common_routing_logic() -> CommonRoutingLogic { - CommonRoutingLogic::Proxy( - ROUTING_LOGIC - .get() - .expect("BUG: ROUTING_LOGIC was not set yet"), - ) -} - -#[derive(Debug, Deserialize, Clone)] -pub struct UpstreamMiningValues { - address: String, - port: u16, - pub_key: key_utils::Secp256k1PublicKey, - channel_kind: ChannelKind, -} - -#[derive(Debug, Deserialize, Clone, Copy)] -pub enum ChannelKind { - Group, - Extended, -} - -#[derive(Debug, Deserialize, Clone)] -pub struct Config { - upstreams: Vec, - listen_address: String, - listen_mining_port: u16, - max_supported_version: u16, - min_supported_version: u16, - downstream_share_per_minute: f32, - expected_total_downstream_hr: f32, - reconnect: bool, -} -pub async fn initialize_r_logic( - upstreams: &[UpstreamMiningValues], - group_id: Arc>, - config: Config, -) -> RLogic { - let channel_ids = Arc::new(Mutex::new(Id::new())); - let mut upstream_mining_nodes = Vec::with_capacity(upstreams.len()); - for (index, upstream_) in upstreams.iter().enumerate() { - let socket = SocketAddr::new(upstream_.address.parse().unwrap(), upstream_.port); - - let upstream = Arc::new(Mutex::new(UpstreamMiningNode::new( - index as u32, - socket, - upstream_.pub_key.clone().into_bytes(), - upstream_.channel_kind, - group_id.clone(), - channel_ids.clone(), - config.downstream_share_per_minute, - None, - None, - config.expected_total_downstream_hr, - config.reconnect, - ))); - - match upstream_.channel_kind { - ChannelKind::Group => (), - ChannelKind::Extended => (), - } - - upstream_mining_nodes.push(upstream); - } - let upstream_selector = GeneralMiningSelector::new(upstream_mining_nodes); - MiningProxyRoutingLogic { - upstream_selector, - downstream_id_generator: Id::new(), - downstream_to_upstream_map: std::collections::HashMap::new(), - } -} mod args { use std::path::PathBuf; @@ -260,13 +121,13 @@ async fn main() { }; let group_id = Arc::new(Mutex::new(GroupId::new())); - ROUTING_LOGIC + lib::ROUTING_LOGIC .set(Mutex::new( - initialize_r_logic(&config.upstreams, group_id, config.clone()).await, + lib::initialize_r_logic(&config.upstreams, group_id, config.clone()).await, )) .expect("BUG: Failed to set ROUTING_LOGIC"); info!("PROXY INITIALIZING"); - initialize_upstreams(config.min_supported_version, config.max_supported_version).await; + lib::initialize_upstreams(config.min_supported_version, config.max_supported_version).await; info!("PROXY INITIALIZED"); // Wait for downstream connection diff --git a/roles/pool/Cargo.toml b/roles/pool/Cargo.toml index 7c246ada5e..7b1a99fe17 100644 --- a/roles/pool/Cargo.toml +++ b/roles/pool/Cargo.toml @@ -6,6 +6,10 @@ description = "SV2 pool role" license = "MIT OR Apache-2.0" repository = "https://github.com/stratum-mining/stratum" +[lib] +name = "pool_sv2" +path = "src/lib/mod.rs" + [dependencies] stratum-common = { path = "../../common" } async-channel = "1.5.1" @@ -28,7 +32,6 @@ nohash-hasher = "0.2.0" key-utils = { version = "^1.0.0", path = "../../utils/key-utils" } secp256k1 = { version = "0.27.0", default-features = false, features =["bitcoin_hashes","alloc","rand","rand-std"] } - [dev-dependencies] hex = "0.4.3" diff --git a/roles/pool/config.toml b/roles/pool/config.toml deleted file mode 100644 index d2f36743e0..0000000000 --- a/roles/pool/config.toml +++ /dev/null @@ -1,30 +0,0 @@ -# SRI Pool config -authority_public_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -authority_secret_key = "7qbpUjScc865jyX2kiB4NVJANoC7GA7TAJupdzXWkc62" -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" -# Hosted testnet TP -tp_address = "89.116.25.191:8442" -# Hosted regtest TP -# tp_address = "75.119.150.111:8442" - diff --git a/roles/pool/pool-config.toml b/roles/pool/pool-config.toml deleted file mode 100644 index 30e1501881..0000000000 --- a/roles/pool/pool-config.toml +++ /dev/null @@ -1,30 +0,0 @@ - -# SRI Pool config -authority_public_key = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" -authority_secret_key = "7qbpUjScc865jyX2kiB4NVJANoC7GA7TAJupdzXWkc62" -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" -# Hosted testnet TP -tp_address = "89.116.25.191:8442" -# Hosted regtest TP -# tp_address = "75.119.150.111:8442" diff --git a/roles/pool/src/error.rs b/roles/pool/src/lib/error.rs similarity index 100% rename from roles/pool/src/error.rs rename to roles/pool/src/lib/error.rs diff --git a/roles/pool/src/lib/mining_pool/message_handler.rs b/roles/pool/src/lib/mining_pool/message_handler.rs index 8bec900e2c..8d8b1ce882 100644 --- a/roles/pool/src/lib/mining_pool/message_handler.rs +++ b/roles/pool/src/lib/mining_pool/message_handler.rs @@ -1,4 +1,4 @@ -use crate::lib::mining_pool::Downstream; +use super::super::mining_pool::Downstream; use roles_logic_sv2::{ errors::Error, handlers::mining::{ParseDownstreamMiningMessages, SendTo, SupportedChannelTypes}, diff --git a/roles/pool/src/lib/mining_pool/mod.rs b/roles/pool/src/lib/mining_pool/mod.rs index d1cc95a9a1..1b100ce892 100644 --- a/roles/pool/src/lib/mining_pool/mod.rs +++ b/roles/pool/src/lib/mining_pool/mod.rs @@ -1,11 +1,12 @@ -use crate::{ +use super::{ error::{PoolError, PoolResult}, - status, Configuration, EitherFrame, StdFrame, + status, }; use async_channel::{Receiver, Sender}; use binary_sv2::U256; -use codec_sv2::{Frame, HandshakeRole, Responder}; +use codec_sv2::{Frame, HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; use error_handling::handle_result; +use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; use network_helpers::noise_connection_tokio::Connection; use nohash_hasher::BuildNoHashHasher; use roles_logic_sv2::{ @@ -18,9 +19,16 @@ use roles_logic_sv2::{ parsers::{Mining, PoolMessages}, routing_logic::MiningRoutingLogic, template_distribution_sv2::{NewTemplate, SetNewPrevHash, SubmitSolution}, - utils::Mutex, + utils::{CoinbaseOutput as CoinbaseOutput_, Mutex}, }; -use std::{collections::HashMap, convert::TryInto, net::SocketAddr, sync::Arc}; +use serde::Deserialize; +use std::{ + collections::HashMap, + convert::{TryFrom, TryInto}, + net::SocketAddr, + sync::Arc, +}; +use stratum_common::bitcoin::{Script, TxOut}; use tokio::{net::TcpListener, task}; use tracing::{debug, error, info, warn}; @@ -29,6 +37,61 @@ use setup_connection::SetupConnectionHandler; pub mod message_handler; +pub type Message = PoolMessages<'static>; +pub type StdFrame = StandardSv2Frame; +pub type EitherFrame = StandardEitherFrame; + +pub fn get_coinbase_output(config: &Configuration) -> Result, Error> { + let mut result = Vec::new(); + for coinbase_output_pool in &config.coinbase_outputs { + let coinbase_output: CoinbaseOutput_ = coinbase_output_pool.try_into()?; + let output_script: Script = coinbase_output.try_into()?; + result.push(TxOut { + value: 0, + script_pubkey: output_script, + }); + } + match result.is_empty() { + true => Err(Error::EmptyCoinbaseOutputs), + _ => Ok(result), + } +} + +#[derive(Debug, Deserialize, Clone)] +pub struct CoinbaseOutput { + output_script_type: String, + output_script_value: String, +} + +impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ { + type Error = Error; + + fn try_from(pool_output: &CoinbaseOutput) -> Result { + match pool_output.output_script_type.as_str() { + "TEST" | "P2PK" | "P2PKH" | "P2WPKH" | "P2SH" | "P2WSH" | "P2TR" => { + Ok(CoinbaseOutput_ { + output_script_type: pool_output.clone().output_script_type, + output_script_value: pool_output.clone().output_script_value, + }) + } + _ => Err(Error::UnknownOutputScriptType), + } + } +} + +#[derive(Debug, Deserialize, Clone)] +pub struct Configuration { + pub listen_address: String, + pub tp_address: String, + pub authority_public_key: Secp256k1PublicKey, + pub authority_secret_key: Secp256k1SecretKey, + pub cert_validity_sec: u64, + pub coinbase_outputs: Vec, + pub pool_signature: String, + #[cfg(feature = "test_only_allow_unencrypted")] + pub test_only_listen_adress_plain: String, +} + #[derive(Debug)] pub struct Downstream { // Either group or channel id @@ -469,7 +532,7 @@ impl Pool { end: extranonce_len, }; let ids = Arc::new(Mutex::new(roles_logic_sv2::utils::GroupId::new())); - let pool_coinbase_outputs = crate::get_coinbase_output(&config); + let pool_coinbase_outputs = get_coinbase_output(&config); info!("PUB KEY: {:?}", pool_coinbase_outputs); let extranonces = ExtendedExtranonce::new(range_0, range_1, range_2); let creator = JobsCreators::new(extranonce_len as u8); @@ -609,7 +672,7 @@ mod test { #[test] fn test_coinbase_outputs_from_config() { // Load config - let config: crate::Configuration = toml::from_str( + let config: super::Configuration = toml::from_str( &std::fs::read_to_string("./config-examples/pool-config-local-tp-example.toml") .unwrap(), ) @@ -623,7 +686,7 @@ mod test { let _coinbase_tx_value_remaining: u64 = 625000000; let _coinbase_tx_outputs_count = 0; let coinbase_tx_locktime = 0; - let coinbase_tx_outputs: Vec = crate::get_coinbase_output(&config).unwrap(); + let coinbase_tx_outputs: Vec = super::get_coinbase_output(&config).unwrap(); // extranonce len set to max_extranonce_size in `ChannelFactory::new_extended_channel()` let extranonce_len = 32; diff --git a/roles/pool/src/lib/mining_pool/setup_connection.rs b/roles/pool/src/lib/mining_pool/setup_connection.rs index 73d7f7bbf6..8e684a190c 100644 --- a/roles/pool/src/lib/mining_pool/setup_connection.rs +++ b/roles/pool/src/lib/mining_pool/setup_connection.rs @@ -1,6 +1,6 @@ -use crate::{ +use super::super::{ error::{PoolError, PoolResult}, - EitherFrame, StdFrame, + mining_pool::{EitherFrame, StdFrame}, }; use async_channel::{Receiver, Sender}; use codec_sv2::Frame; @@ -23,6 +23,12 @@ pub struct SetupConnectionHandler { header_only: Option, } +impl Default for SetupConnectionHandler { + fn default() -> Self { + Self::new() + } +} + impl SetupConnectionHandler { pub fn new() -> Self { Self { header_only: None } diff --git a/roles/pool/src/lib/mod.rs b/roles/pool/src/lib/mod.rs index e705460ed8..2d8417842d 100644 --- a/roles/pool/src/lib/mod.rs +++ b/roles/pool/src/lib/mod.rs @@ -1,2 +1,4 @@ +pub mod error; pub mod mining_pool; +pub mod status; pub mod template_receiver; diff --git a/roles/pool/src/status.rs b/roles/pool/src/lib/status.rs similarity index 99% rename from roles/pool/src/status.rs rename to roles/pool/src/lib/status.rs index 3a13cc0981..4dfabb9435 100644 --- a/roles/pool/src/status.rs +++ b/roles/pool/src/lib/status.rs @@ -1,6 +1,6 @@ use roles_logic_sv2::parsers::Mining; -use crate::error::PoolError; +use super::error::PoolError; /// Each sending side of the status channel /// should be wrapped with this enum to allow diff --git a/roles/pool/src/lib/template_receiver/message_handler.rs b/roles/pool/src/lib/template_receiver/message_handler.rs index 9b0d1a52d1..c3adab9e27 100644 --- a/roles/pool/src/lib/template_receiver/message_handler.rs +++ b/roles/pool/src/lib/template_receiver/message_handler.rs @@ -1,4 +1,4 @@ -use crate::lib::template_receiver::TemplateRx; +use super::TemplateRx; use roles_logic_sv2::{ errors::Error, handlers::template_distribution::{ParseServerTemplateDistributionMessages, SendTo}, diff --git a/roles/pool/src/lib/template_receiver/mod.rs b/roles/pool/src/lib/template_receiver/mod.rs index 457dd6d801..5ab06c56a3 100644 --- a/roles/pool/src/lib/template_receiver/mod.rs +++ b/roles/pool/src/lib/template_receiver/mod.rs @@ -1,6 +1,7 @@ -use crate::{ +use super::{ error::{PoolError, PoolResult}, - status, EitherFrame, StdFrame, + mining_pool::{EitherFrame, StdFrame}, + status, }; use async_channel::{Receiver, Sender}; use codec_sv2::{Frame, HandshakeRole, Initiator}; diff --git a/roles/pool/src/lib/template_receiver/setup_connection.rs b/roles/pool/src/lib/template_receiver/setup_connection.rs index 08439e88ef..60c3cb4f84 100644 --- a/roles/pool/src/lib/template_receiver/setup_connection.rs +++ b/roles/pool/src/lib/template_receiver/setup_connection.rs @@ -1,6 +1,6 @@ -use crate::{ +use super::super::{ error::{PoolError, PoolResult}, - EitherFrame, StdFrame, + mining_pool::{EitherFrame, StdFrame}, }; use async_channel::{Receiver, Sender}; use codec_sv2::Frame; diff --git a/roles/pool/src/main.rs b/roles/pool/src/main.rs index 5d7dd13415..729fd5e64f 100644 --- a/roles/pool/src/main.rs +++ b/roles/pool/src/main.rs @@ -1,81 +1,16 @@ #![allow(special_module_name)] use async_channel::{bounded, unbounded}; -use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; -use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; -//use error::OutputScriptError; -use roles_logic_sv2::{ - errors::Error, parsers::PoolMessages, utils::CoinbaseOutput as CoinbaseOutput_, -}; -use serde::Deserialize; -use std::convert::{TryFrom, TryInto}; -use stratum_common::bitcoin::{Script, TxOut}; use tracing::{error, info, warn}; -mod error; mod lib; -mod status; - -use lib::{mining_pool::Pool, template_receiver::TemplateRx}; - -pub type Message = PoolMessages<'static>; -pub type StdFrame = StandardSv2Frame; -pub type EitherFrame = StandardEitherFrame; - -pub fn get_coinbase_output(config: &Configuration) -> Result, Error> { - let mut result = Vec::new(); - for coinbase_output_pool in &config.coinbase_outputs { - let coinbase_output: CoinbaseOutput_ = coinbase_output_pool.try_into()?; - let output_script: Script = coinbase_output.try_into()?; - result.push(TxOut { - value: 0, - script_pubkey: output_script, - }); - } - match result.is_empty() { - true => Err(Error::EmptyCoinbaseOutputs), - _ => Ok(result), - } -} - -impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ { - type Error = Error; - - fn try_from(pool_output: &CoinbaseOutput) -> Result { - match pool_output.output_script_type.as_str() { - "TEST" | "P2PK" | "P2PKH" | "P2WPKH" | "P2SH" | "P2WSH" | "P2TR" => { - Ok(CoinbaseOutput_ { - output_script_type: pool_output.clone().output_script_type, - output_script_value: pool_output.clone().output_script_value, - }) - } - _ => Err(Error::UnknownOutputScriptType), - } - } -} +use lib::{ + mining_pool::{get_coinbase_output, Configuration, Pool}, + status, + template_receiver::TemplateRx, +}; use tokio::select; -use crate::status::Status; - -#[derive(Debug, Deserialize, Clone)] -pub struct CoinbaseOutput { - output_script_type: String, - output_script_value: String, -} - -#[derive(Debug, Deserialize, Clone)] -pub struct Configuration { - pub listen_address: String, - pub tp_address: String, - pub authority_public_key: Secp256k1PublicKey, - pub authority_secret_key: Secp256k1SecretKey, - pub cert_validity_sec: u64, - pub coinbase_outputs: Vec, - pub pool_signature: String, - #[cfg(feature = "test_only_allow_unencrypted")] - pub test_only_listen_adress_plain: String, -} - mod args { use std::path::PathBuf; @@ -225,7 +160,7 @@ async fn main() { break; } }; - let task_status: Status = task_status.unwrap(); + let task_status: status::Status = task_status.unwrap(); match task_status.state { // Should only be sent by the downstream listener diff --git a/roles/translator/Cargo.toml b/roles/translator/Cargo.toml index 937f5e175b..8086ec70b2 100644 --- a/roles/translator/Cargo.toml +++ b/roles/translator/Cargo.toml @@ -6,6 +6,10 @@ description = "Server used to bridge SV1 miners to SV2 pools" license = "MIT OR Apache-2.0" repository = "https://github.com/stratum-mining/stratum" +[lib] +name = "translator_sv2" +path = "src/lib/mod.rs" + [dependencies] stratum-common = { path = "../../common" } async-channel = "1.5.1" diff --git a/roles/translator/config-examples/proxy-config-local-jdc-example.toml b/roles/translator/config-examples/tproxy-config-local-jdc-example.toml similarity index 77% rename from roles/translator/config-examples/proxy-config-local-jdc-example.toml rename to roles/translator/config-examples/tproxy-config-local-jdc-example.toml index d71a9f303d..fd1ac92379 100644 --- a/roles/translator/config-examples/proxy-config-local-jdc-example.toml +++ b/roles/translator/config-examples/tproxy-config-local-jdc-example.toml @@ -25,13 +25,13 @@ coinbase_reward_sat = 5_000_000_000 # Difficulty params [downstream_difficulty_config] -# hashes/s of the weakest miner that will be connecting -min_individual_miner_hashrate=5_000_000.0 +# 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 -channel_nominal_hashrate = 5_000_000.0 +# 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 diff --git a/roles/translator/config-examples/proxy-config-local-pool-example.toml b/roles/translator/config-examples/tproxy-config-local-pool-example.toml similarity index 77% rename from roles/translator/config-examples/proxy-config-local-pool-example.toml rename to roles/translator/config-examples/tproxy-config-local-pool-example.toml index 3a1f78cfab..6da9c3a518 100644 --- a/roles/translator/config-examples/proxy-config-local-pool-example.toml +++ b/roles/translator/config-examples/tproxy-config-local-pool-example.toml @@ -25,13 +25,13 @@ coinbase_reward_sat = 5_000_000_000 # Difficulty params [downstream_difficulty_config] -# hashes/s of the weakest miner that will be connecting -min_individual_miner_hashrate=5_000_000.0 +# 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 -channel_nominal_hashrate = 5_000_000.0 +# 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 diff --git a/roles/translator/proxy-config.toml b/roles/translator/proxy-config.toml deleted file mode 100644 index b83fd15e79..0000000000 --- a/roles/translator/proxy-config.toml +++ /dev/null @@ -1,39 +0,0 @@ -# Braiins Pool Upstream Connection -# upstream_authority_pubkey = "u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt" -# upstream_address = "18.196.32.109" -# upstream_port = 3336 - -# Local SRI Pool Upstream Connection -upstream_address = "127.0.0.1" -upstream_port = 34254 -upstream_authority_pubkey = "3VANfft6ei6jQq1At7d8nmiZzVhBFS4CiQujdgim1ign" - -# 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 -coinbase_reward_sat = 5_000_000_000 - -# Difficulty params -[downstream_difficulty_config] -# hashes/s of the weakest miner that will be connecting -min_individual_miner_hashrate=500_000.0 -# minimum number of shares needed before a mining.set_difficulty is sent for updating targets -miner_num_submits_before_update=5 -# 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 = 10 -# estimated accumulated hashrate of all downstream miners -channel_nominal_hashrate = 50_000.0 diff --git a/roles/translator/src/downstream_sv1/diff_management.rs b/roles/translator/src/lib/downstream_sv1/diff_management.rs similarity index 99% rename from roles/translator/src/downstream_sv1/diff_management.rs rename to roles/translator/src/lib/downstream_sv1/diff_management.rs index db121deda4..e534af4439 100644 --- a/roles/translator/src/downstream_sv1/diff_management.rs +++ b/roles/translator/src/lib/downstream_sv1/diff_management.rs @@ -1,6 +1,6 @@ use super::{Downstream, DownstreamMessages, SetDownstreamTarget}; -use crate::{error::Error, ProxyResult}; +use super::super::error::{Error, ProxyResult}; use roles_logic_sv2::utils::Mutex; use std::{ops::Div, sync::Arc}; use v1::json_rpc; diff --git a/roles/translator/src/downstream_sv1/downstream.rs b/roles/translator/src/lib/downstream_sv1/downstream.rs similarity index 99% rename from roles/translator/src/downstream_sv1/downstream.rs rename to roles/translator/src/lib/downstream_sv1/downstream.rs index 426dce6ed5..719bc117a1 100644 --- a/roles/translator/src/downstream_sv1/downstream.rs +++ b/roles/translator/src/lib/downstream_sv1/downstream.rs @@ -367,7 +367,7 @@ impl Downstream { async fn handle_incoming_sv1( self_: Arc>, message_sv1: json_rpc::Message, - ) -> Result<(), crate::error::Error<'static>> { + ) -> Result<(), super::super::error::Error<'static>> { // `handle_message` in `IsServer` trait + calls `handle_request` // TODO: Map err from V1Error to Error::V1Error let response = self_.safe_lock(|s| s.handle_message(message_sv1)).unwrap(); diff --git a/roles/translator/src/downstream_sv1/mod.rs b/roles/translator/src/lib/downstream_sv1/mod.rs similarity index 100% rename from roles/translator/src/downstream_sv1/mod.rs rename to roles/translator/src/lib/downstream_sv1/mod.rs diff --git a/roles/translator/src/error.rs b/roles/translator/src/lib/error.rs similarity index 100% rename from roles/translator/src/error.rs rename to roles/translator/src/lib/error.rs diff --git a/roles/translator/src/lib/mod.rs b/roles/translator/src/lib/mod.rs new file mode 100644 index 0000000000..2075e4569d --- /dev/null +++ b/roles/translator/src/lib/mod.rs @@ -0,0 +1,7 @@ +pub mod downstream_sv1; +pub mod error; +pub mod proxy; +pub mod proxy_config; +pub mod status; +pub mod upstream_sv2; +pub mod utils; diff --git a/roles/translator/src/proxy/bridge.rs b/roles/translator/src/lib/proxy/bridge.rs similarity index 99% rename from roles/translator/src/proxy/bridge.rs rename to roles/translator/src/lib/proxy/bridge.rs index 589b8f96c3..8cd00ab04b 100644 --- a/roles/translator/src/proxy/bridge.rs +++ b/roles/translator/src/lib/proxy/bridge.rs @@ -12,10 +12,13 @@ use std::sync::Arc; use tokio::sync::broadcast; use v1::{client_to_server::Submit, server_to_client, utils::HexU32Be}; -use crate::{ +use super::super::{ downstream_sv1::{DownstreamMessages, SetDownstreamTarget, SubmitShareWithChannelId}, - error::Error::{self, PoisonLock}, - status, ProxyResult, + error::{ + Error::{self, PoisonLock}, + ProxyResult, + }, + status, }; use error_handling::handle_result; use roles_logic_sv2::{channel_logic::channel_factory::OnNewShare, Error as RolesLogicError}; diff --git a/roles/translator/src/proxy/mod.rs b/roles/translator/src/lib/proxy/mod.rs similarity index 100% rename from roles/translator/src/proxy/mod.rs rename to roles/translator/src/lib/proxy/mod.rs diff --git a/roles/translator/src/proxy/next_mining_notify.rs b/roles/translator/src/lib/proxy/next_mining_notify.rs similarity index 100% rename from roles/translator/src/proxy/next_mining_notify.rs rename to roles/translator/src/lib/proxy/next_mining_notify.rs diff --git a/roles/translator/src/proxy_config.rs b/roles/translator/src/lib/proxy_config.rs similarity index 100% rename from roles/translator/src/proxy_config.rs rename to roles/translator/src/lib/proxy_config.rs diff --git a/roles/translator/src/status.rs b/roles/translator/src/lib/status.rs similarity index 100% rename from roles/translator/src/status.rs rename to roles/translator/src/lib/status.rs diff --git a/roles/translator/src/upstream_sv2/diff_management.rs b/roles/translator/src/lib/upstream_sv2/diff_management.rs similarity index 83% rename from roles/translator/src/upstream_sv2/diff_management.rs rename to roles/translator/src/lib/upstream_sv2/diff_management.rs index bf8d8cd779..830bf28d8f 100644 --- a/roles/translator/src/upstream_sv2/diff_management.rs +++ b/roles/translator/src/lib/upstream_sv2/diff_management.rs @@ -1,9 +1,8 @@ use super::Upstream; -use crate::{ - error::Error::PoisonLock, +use super::super::{ + error::{Error::PoisonLock, ProxyResult}, upstream_sv2::{EitherFrame, Message, StdFrame}, - ProxyResult, }; use binary_sv2::u256_from_int; use roles_logic_sv2::{ @@ -23,7 +22,7 @@ impl Upstream { ) }) .map_err(|_e| PoisonLock)?; - let channel_id = channel_id_option.ok_or(crate::Error::RolesSv2Logic( + let channel_id = channel_id_option.ok_or(super::super::error::Error::RolesSv2Logic( RolesLogicError::NotFoundChannelId, ))?; let (timeout, new_hashrate) = diff_mgmt @@ -40,7 +39,9 @@ impl Upstream { let frame: EitherFrame = either_frame.into(); tx_frame.send(frame).await.map_err(|e| { - crate::Error::ChannelErrorSender(crate::error::ChannelSendError::General(e.to_string())) + super::super::error::Error::ChannelErrorSender( + super::super::error::ChannelSendError::General(e.to_string()), + ) })?; async_std::task::sleep(Duration::from_secs(timeout as u64)).await; Ok(()) diff --git a/roles/translator/src/upstream_sv2/mod.rs b/roles/translator/src/lib/upstream_sv2/mod.rs similarity index 100% rename from roles/translator/src/upstream_sv2/mod.rs rename to roles/translator/src/lib/upstream_sv2/mod.rs diff --git a/roles/translator/src/upstream_sv2/upstream.rs b/roles/translator/src/lib/upstream_sv2/upstream.rs similarity index 95% rename from roles/translator/src/upstream_sv2/upstream.rs rename to roles/translator/src/lib/upstream_sv2/upstream.rs index 9cbd0c6f06..fb5fd97155 100644 --- a/roles/translator/src/upstream_sv2/upstream.rs +++ b/roles/translator/src/lib/upstream_sv2/upstream.rs @@ -1,10 +1,12 @@ use crate::{ downstream_sv1::Downstream, - error::Error::{CodecNoise, InvalidExtranonce, PoisonLock, UpstreamIncoming}, + error::{ + Error::{CodecNoise, InvalidExtranonce, PoisonLock, UpstreamIncoming}, + ProxyResult, + }, proxy_config::UpstreamDifficultyConfig, status, upstream_sv2::{EitherFrame, Message, StdFrame, UpstreamConnection}, - ProxyResult, }; use async_channel::{Receiver, Sender}; use async_std::{net::TcpStream, task}; @@ -295,9 +297,12 @@ impl Upstream { let mut incoming: StdFrame = handle_result!(tx_status, incoming.try_into()); // On message receive, get the message type from the message header and get the // message payload - let message_type = incoming.get_header().ok_or(crate::error::Error::FramingSv2( - framing_sv2::Error::ExpectedSv2Frame, - )); + let message_type = + incoming + .get_header() + .ok_or(super::super::error::Error::FramingSv2( + framing_sv2::Error::ExpectedSv2Frame, + )); let message_type = handle_result!(tx_status, message_type).msg_type(); @@ -332,8 +337,8 @@ impl Upstream { handle_result!( tx_status, tx_frame.send(frame).await.map_err(|e| { - crate::Error::ChannelErrorSender( - crate::error::ChannelSendError::General(e.to_string()), + super::super::error::Error::ChannelErrorSender( + super::super::error::ChannelSendError::General(e.to_string()), ) }) ); @@ -359,7 +364,7 @@ impl Upstream { // range 1 is the extranonce1 added by the tproxy // range 2 is the extranonce2 used by the miner for rolling // range 0 + range 1 is the extranonce1 sent to the miner - let tproxy_e1_len = crate::utils::proxy_extranonce1_len( + let tproxy_e1_len = super::super::utils::proxy_extranonce1_len( m.extranonce_size as usize, miner_extranonce2_size, ); @@ -434,15 +439,17 @@ impl Upstream { #[allow(clippy::result_large_err)] fn get_job_id( self_: &Arc>, - ) -> Result>, crate::error::Error<'static>> { + ) -> Result>, super::super::error::Error<'static>> + { self_ .safe_lock(|s| { if s.is_work_selection_enabled() { - s.last_job_id.ok_or(crate::error::Error::RolesSv2Logic( - RolesLogicError::NoValidTranslatorJob, - )) + s.last_job_id + .ok_or(super::super::error::Error::RolesSv2Logic( + RolesLogicError::NoValidTranslatorJob, + )) } else { - s.job_id.ok_or(crate::error::Error::RolesSv2Logic( + s.job_id.ok_or(super::super::error::Error::RolesSv2Logic( RolesLogicError::NoValidJob, )) } @@ -470,9 +477,10 @@ impl Upstream { let channel_id = self_ .safe_lock(|s| { - s.channel_id.ok_or(crate::error::Error::RolesSv2Logic( - RolesLogicError::NotFoundChannelId, - )) + s.channel_id + .ok_or(super::super::error::Error::RolesSv2Logic( + RolesLogicError::NotFoundChannelId, + )) }) .map_err(|_e| PoisonLock); sv2_submit.channel_id = @@ -490,12 +498,11 @@ impl Upstream { let frame: EitherFrame = frame.into(); handle_result!( tx_status, - tx_frame - .send(frame) - .await - .map_err(|e| crate::Error::ChannelErrorSender( - crate::error::ChannelSendError::General(e.to_string()) - )) + tx_frame.send(frame).await.map_err(|e| { + super::super::error::Error::ChannelErrorSender( + super::super::error::ChannelSendError::General(e.to_string()), + ) + }) ); } }); @@ -642,7 +649,7 @@ impl ParseUpstreamMiningMessages Result, RolesLogicError> { - let tproxy_e1_len = crate::utils::proxy_extranonce1_len( + let tproxy_e1_len = super::super::utils::proxy_extranonce1_len( m.extranonce_size as usize, self.min_extranonce_size.into(), ) as u16; diff --git a/roles/translator/src/upstream_sv2/upstream_connection.rs b/roles/translator/src/lib/upstream_sv2/upstream_connection.rs similarity index 83% rename from roles/translator/src/upstream_sv2/upstream_connection.rs rename to roles/translator/src/lib/upstream_sv2/upstream_connection.rs index 9d83782161..49392b78e4 100644 --- a/roles/translator/src/upstream_sv2/upstream_connection.rs +++ b/roles/translator/src/lib/upstream_sv2/upstream_connection.rs @@ -1,5 +1,4 @@ -use super::{EitherFrame, StdFrame}; -use crate::ProxyResult; +use super::{super::error::ProxyResult, EitherFrame, StdFrame}; use async_channel::{Receiver, Sender}; /// Handles the sending and receiving of messages to and from an SV2 Upstream role (most typically @@ -22,7 +21,9 @@ impl UpstreamConnection { pub async fn send(&mut self, sv2_frame: StdFrame) -> ProxyResult<'static, ()> { let either_frame = sv2_frame.into(); self.sender.send(either_frame).await.map_err(|e| { - crate::Error::ChannelErrorSender(crate::error::ChannelSendError::General(e.to_string())) + super::super::error::Error::ChannelErrorSender( + super::super::error::ChannelSendError::General(e.to_string()), + ) })?; Ok(()) } diff --git a/roles/translator/src/utils.rs b/roles/translator/src/lib/utils.rs similarity index 100% rename from roles/translator/src/utils.rs rename to roles/translator/src/lib/utils.rs diff --git a/roles/translator/src/main.rs b/roles/translator/src/main.rs index e4c05886c2..c155623088 100644 --- a/roles/translator/src/main.rs +++ b/roles/translator/src/main.rs @@ -1,13 +1,10 @@ +#![allow(special_module_name)] mod args; -mod downstream_sv1; -mod error; -mod proxy; -mod proxy_config; -mod status; -mod upstream_sv2; -mod utils; +mod lib; + use args::Args; use error::{Error, ProxyResult}; +use lib::{downstream_sv1, error, proxy, proxy_config, status, upstream_sv2}; use proxy_config::ProxyConfig; use roles_logic_sv2::utils::Mutex; diff --git a/utils/Cargo.lock b/utils/Cargo.lock index b7d0aa18f6..0cda4a0807 100644 --- a/utils/Cargo.lock +++ b/utils/Cargo.lock @@ -52,6 +52,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -79,7 +85,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 4.0.1", + "event-listener 4.0.3", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -91,11 +97,11 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 2.1.0", + "futures-lite 2.2.0", "slab", ] @@ -108,9 +114,9 @@ dependencies = [ "async-channel 2.1.1", "async-executor", "async-io 2.2.2", - "async-lock 3.2.0", + "async-lock 3.3.0", "blocking", - "futures-lite 2.1.0", + "futures-lite 2.2.0", "once_cell", ] @@ -140,14 +146,14 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.1.0", + "futures-lite 2.2.0", "parking", - "polling 3.3.1", - "rustix 0.38.28", + "polling 3.3.2", + "rustix 0.38.30", "slab", "tracing", "windows-sys 0.52.0", @@ -164,11 +170,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ - "event-listener 4.0.1", + "event-listener 4.0.3", "event-listener-strategy", "pin-project-lite", ] @@ -201,20 +207,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.6.0" +version = "4.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46" - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "atomic-waker" @@ -299,6 +294,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "blocking" version = "1.5.1" @@ -306,15 +310,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel 2.1.1", - "async-lock 3.2.0", + "async-lock 3.3.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 2.1.0", + "futures-lite 2.2.0", "piper", "tracing", ] +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +dependencies = [ + "sha2", +] + [[package]] name = "buffer_sv2" version = "0.1.2" @@ -433,9 +446,9 @@ version = "0.1.2" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -478,35 +491,28 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.16" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crypto-common" @@ -556,6 +562,15 @@ dependencies = [ "binary_codec_sv2", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "either" version = "1.9.0" @@ -584,9 +599,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "4.0.1" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f2cdcf274580f2d63697192d744727b3198894b1bf02923643bf59e2c26712" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" dependencies = [ "concurrent-queue", "parking", @@ -599,7 +614,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.1", + "event-listener 4.0.3", "pin-project-lite", ] @@ -630,9 +645,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -645,9 +660,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -655,15 +670,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -672,9 +687,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -693,9 +708,9 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" dependencies = [ "fastrand 2.0.1", "futures-core", @@ -706,9 +721,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -717,21 +732,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -757,9 +772,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -800,6 +815,16 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "hashbrown" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" +dependencies = [ + "ahash", + "autocfg", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -867,13 +892,23 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] +[[package]] +name = "key-utils" +version = "1.0.0" +dependencies = [ + "bs58", + "secp256k1", + "serde", + "toml", +] + [[package]] name = "kv-log-macro" version = "1.0.7" @@ -891,9 +926,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "linux-raw-sys" @@ -928,18 +963,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "miniz_oxide" @@ -967,7 +993,6 @@ version = "0.1.0" dependencies = [ "async-channel 1.9.0", "async-std", - "async-trait", "binary_sv2", "codec_sv2", "futures", @@ -1009,9 +1034,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1132,14 +1157,14 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.28", + "rustix 0.38.30", "tracing", "windows-sys 0.52.0", ] @@ -1175,18 +1200,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1301,9 +1326,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ "bitflags 2.4.1", "errno", @@ -1355,9 +1380,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -1374,9 +1399,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", @@ -1385,9 +1410,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1402,6 +1427,19 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1422,9 +1460,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "socket2" @@ -1454,9 +1492,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.41" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1512,6 +1550,15 @@ dependencies = [ "syn", ] +[[package]] +name = "toml" +version = "0.5.6" +source = "git+https://github.com/diondokter/toml-rs?rev=c4161aa#c4161aa70202b3992dbec79b76e7a8659713b604" +dependencies = [ + "hashbrown", + "serde", +] + [[package]] name = "tracing" version = "0.1.40" @@ -1573,9 +1620,9 @@ dependencies = [ [[package]] name = "value-bag" -version = "1.4.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72e1902dde2bd6441347de2b70b7f5d59bf157c6c62f0c44572607a1d55bbe" +checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" [[package]] name = "version_check" @@ -1607,9 +1654,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1617,9 +1664,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -1632,9 +1679,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -1644,9 +1691,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1654,9 +1701,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -1667,15 +1714,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen",