diff --git a/crates/salvium-miner/Cargo.lock b/crates/salvium-miner/Cargo.lock new file mode 100644 index 0000000..876cdd8 --- /dev/null +++ b/crates/salvium-miner/Cargo.lock @@ -0,0 +1,1738 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cc" +version = "1.2.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "clap" +version = "4.5.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75ca66430e33a14957acc24c5077b503e7d374151b2b4b3a10c83b4ceb4be0e" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793207c7fa6300a0608d1080b858e5fdbe713cdc1c8db9fb17777d8a13e63df0" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" + +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "randomx-rs" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d108ec2b3f83ea06f8290685fa4a20c8f0803b1de43c2301639d7a0592474554" +dependencies = [ + "bitflags 1.3.2", + "cmake", + "libc", + "thiserror", +] + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +dependencies = [ + "bitflags 2.10.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "salvium-miner" +version = "0.1.0" +dependencies = [ + "clap", + "hex", + "libc", + "num_cpus", + "randomx-rs", + "reqwest", + "serde", + "serde_json", +] + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.10.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.10.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags 2.10.0", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[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.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1966f8ac2c1f76987d69a74d0e0f929241c10e78136434e3be70ff7f58f64214" diff --git a/crates/salvium-miner/Cargo.toml b/crates/salvium-miner/Cargo.toml new file mode 100644 index 0000000..2b997cb --- /dev/null +++ b/crates/salvium-miner/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "salvium-miner" +version = "0.1.0" +edition = "2021" +description = "Native RandomX CPU miner for Salvium cryptocurrency" + +[[bin]] +name = "salvium-miner" +path = "src/main.rs" + +[dependencies] +randomx-rs = "1.4" +reqwest = { version = "0.12", features = ["blocking", "json"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +clap = { version = "4", features = ["derive"] } +hex = "0.4" +num_cpus = "1" +libc = "0.2" + +[profile.release] +opt-level = 3 +lto = "thin" diff --git a/crates/salvium-miner/src/daemon.rs b/crates/salvium-miner/src/daemon.rs new file mode 100644 index 0000000..0f83f17 --- /dev/null +++ b/crates/salvium-miner/src/daemon.rs @@ -0,0 +1,129 @@ +//! Salvium daemon JSON-RPC client +//! +//! Implements the subset of RPC methods needed for solo mining: +//! get_block_template, submit_block, get_info + +use reqwest::blocking::Client; +use serde::{Deserialize, Serialize}; +use serde_json::Value; + +pub struct DaemonClient { + url: String, + client: Client, +} + +#[derive(Debug, Deserialize)] +pub struct BlockTemplate { + pub difficulty: u64, + pub wide_difficulty: Option, + pub height: u64, + pub seed_hash: String, + pub next_seed_hash: Option, + pub blocktemplate_blob: String, + pub blockhashing_blob: String, + pub expected_reward: u64, + pub prev_hash: String, + pub reserved_offset: u32, +} + +#[derive(Debug, Deserialize)] +pub struct DaemonInfo { + pub height: u64, + pub difficulty: u64, + pub wide_difficulty: Option, + pub testnet: bool, + pub mainnet: bool, + pub synchronized: bool, + pub status: String, +} + +#[derive(Serialize)] +struct JsonRpcRequest { + jsonrpc: &'static str, + id: &'static str, + method: String, + params: Value, +} + +#[derive(Deserialize)] +struct JsonRpcResponse { + result: Option, + error: Option, +} + +impl DaemonClient { + pub fn new(url: &str) -> Self { + Self { + url: url.trim_end_matches('/').to_string(), + client: Client::builder() + .timeout(std::time::Duration::from_secs(30)) + .build() + .expect("Failed to create HTTP client"), + } + } + + fn call(&self, method: &str, params: Value) -> Result { + let req = JsonRpcRequest { + jsonrpc: "2.0", + id: "0", + method: method.to_string(), + params, + }; + + let resp = self + .client + .post(&format!("{}/json_rpc", self.url)) + .json(&req) + .send() + .map_err(|e| format!("HTTP error: {}", e))?; + + let body: JsonRpcResponse = resp.json().map_err(|e| format!("JSON parse error: {}", e))?; + + if let Some(err) = body.error { + return Err(format!("RPC error: {}", err)); + } + + body.result.ok_or_else(|| "No result in response".to_string()) + } + + pub fn get_info(&self) -> Result { + let result = self.call("get_info", serde_json::json!({}))?; + serde_json::from_value(result).map_err(|e| format!("Parse error: {}", e)) + } + + pub fn get_block_template(&self, address: &str, reserve_size: u32) -> Result { + let result = self.call( + "get_block_template", + serde_json::json!({ + "wallet_address": address, + "reserve_size": reserve_size + }), + )?; + serde_json::from_value(result).map_err(|e| format!("Parse error: {}", e)) + } + + pub fn submit_block(&self, block_blob_hex: &str) -> Result<(), String> { + // submit_block takes an array of hex strings (not a JSON-RPC params object) + let req = JsonRpcRequest { + jsonrpc: "2.0", + id: "0", + method: "submit_block".to_string(), + params: serde_json::json!([block_blob_hex]), + }; + + let resp = self + .client + .post(&format!("{}/json_rpc", self.url)) + .json(&req) + .send() + .map_err(|e| format!("HTTP error: {}", e))?; + + let body: JsonRpcResponse = resp.json().map_err(|e| format!("JSON parse error: {}", e))?; + + if let Some(err) = body.error { + return Err(format!("Block rejected: {}", err)); + } + + Ok(()) + } +} diff --git a/crates/salvium-miner/src/ipc.rs b/crates/salvium-miner/src/ipc.rs new file mode 100644 index 0000000..39420a2 --- /dev/null +++ b/crates/salvium-miner/src/ipc.rs @@ -0,0 +1,333 @@ +//! IPC mode: JSON-lines protocol over stdin/stdout +//! +//! The parent process (Node.js/browser bridge) sends commands on stdin +//! and receives events on stdout. All messages are single-line JSON. +//! +//! ## Protocol +//! +//! ### Parent → Miner (stdin) +//! +//! **init** — Initialize RandomX with a seed hash. Must be sent first. +//! ```json +//! {"method":"init","seed_hash":"abc123..."} +//! ``` +//! +//! **job** — Start mining a new job. +//! ```json +//! {"method":"job","job_id":"1","hashing_blob":"...","template_blob":"...","difficulty":99401,"height":46} +//! ``` +//! +//! **stop** — Stop mining (keeps engine alive for next job). +//! ```json +//! {"method":"stop"} +//! ``` +//! +//! **shutdown** — Exit the process. +//! ```json +//! {"method":"shutdown"} +//! ``` +//! +//! ### Miner → Parent (stdout) +//! +//! **ready** — Engine initialized, workers spawned. +//! ```json +//! {"event":"ready","threads":7,"mode":"full"} +//! ``` +//! +//! **hashrate** — Periodic stats (every 5s). +//! ```json +//! {"event":"hashrate","hashrate":2720.5,"hashes":54570,"elapsed":20.1} +//! ``` +//! +//! **block** — Block found! +//! ```json +//! {"event":"block","job_id":"1","nonce":12345,"hash":"...","blob_hex":"..."} +//! ``` +//! +//! **error** — Something went wrong. +//! ```json +//! {"event":"error","message":"..."} +//! ``` +//! +//! **stopped** — Mining stopped (in response to stop command). +//! ```json +//! {"event":"stopped"} +//! ``` + +use crate::miner::{MiningEngine, MiningJob}; +use serde::{Deserialize, Serialize}; +use std::io::{self, BufRead, Write}; +use std::sync::atomic::Ordering; +use std::sync::mpsc; +use std::time::{Duration, Instant}; + +#[derive(Deserialize)] +struct InMessage { + method: String, + #[serde(default)] + seed_hash: String, + #[serde(default)] + job_id: String, + #[serde(default)] + hashing_blob: String, + #[serde(default)] + template_blob: String, + #[serde(default)] + difficulty: u64, + #[serde(default)] + wide_difficulty: Option, + #[serde(default)] + height: u64, +} + +#[derive(Serialize)] +struct OutMessage { + event: String, + #[serde(skip_serializing_if = "Option::is_none")] + threads: Option, + #[serde(skip_serializing_if = "Option::is_none")] + mode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + hashrate: Option, + #[serde(skip_serializing_if = "Option::is_none")] + hashes: Option, + #[serde(skip_serializing_if = "Option::is_none")] + elapsed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + job_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + nonce: Option, + #[serde(skip_serializing_if = "Option::is_none")] + hash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + blob_hex: Option, + #[serde(skip_serializing_if = "Option::is_none")] + message: Option, +} + +impl OutMessage { + fn new(event: &str) -> Self { + Self { + event: event.to_string(), + threads: None, + mode: None, + hashrate: None, + hashes: None, + elapsed: None, + job_id: None, + nonce: None, + hash: None, + blob_hex: None, + message: None, + } + } +} + +fn send(msg: &OutMessage) { + let mut stdout = io::stdout().lock(); + let _ = serde_json::to_writer(&mut stdout, msg); + let _ = stdout.write_all(b"\n"); + let _ = stdout.flush(); +} + +fn send_error(msg: &str) { + let mut out = OutMessage::new("error"); + out.message = Some(msg.to_string()); + send(&out); +} + +/// Stdin line or EOF signal +enum StdinEvent { + Line(String), + Eof, +} + +pub fn run_ipc(threads: usize, light: bool) { + let mode_str = if light { "light" } else { "full" }; + eprintln!("[IPC] Waiting for commands on stdin (threads={}, mode={})", threads, mode_str); + + // Read stdin on a dedicated thread so the main loop stays non-blocking + let (stdin_tx, stdin_rx) = mpsc::channel::(); + std::thread::spawn(move || { + let stdin = io::stdin(); + let reader = stdin.lock(); + for line in reader.lines() { + match line { + Ok(l) => { + if stdin_tx.send(StdinEvent::Line(l)).is_err() { + break; + } + } + Err(_) => break, + } + } + let _ = stdin_tx.send(StdinEvent::Eof); + }); + + let mut engine: Option = None; + let mut current_job_id = String::new(); + let mut start_time = Instant::now(); + let mut last_stats = Instant::now(); + + loop { + // Check for found blocks + if let Some(ref eng) = engine { + while let Some(block) = eng.try_recv_block() { + let mut out = OutMessage::new("block"); + out.job_id = Some(current_job_id.clone()); + out.nonce = Some(block.nonce); + out.hash = Some(hex::encode(&block.hash)); + out.blob_hex = Some(block.blob_hex); + send(&out); + } + + // Send hashrate stats every 5 seconds + if last_stats.elapsed() > Duration::from_secs(5) { + let elapsed = start_time.elapsed().as_secs_f64(); + let total = eng.hash_count.load(Ordering::Relaxed); + let hr = if elapsed > 0.0 { total as f64 / elapsed } else { 0.0 }; + + let mut out = OutMessage::new("hashrate"); + out.hashrate = Some(hr); + out.hashes = Some(total); + out.elapsed = Some(elapsed); + send(&out); + last_stats = Instant::now(); + } + } + + // Poll stdin (non-blocking, 100ms timeout) + let event = stdin_rx.recv_timeout(Duration::from_millis(100)); + let line = match event { + Ok(StdinEvent::Line(l)) => l, + Ok(StdinEvent::Eof) => { + eprintln!("[IPC] stdin closed, shutting down"); + if let Some(ref eng) = engine { + eng.stop(); + } + break; + } + Err(mpsc::RecvTimeoutError::Timeout) => continue, + Err(mpsc::RecvTimeoutError::Disconnected) => { + eprintln!("[IPC] stdin thread disconnected"); + break; + } + }; + + let line = line.trim(); + if line.is_empty() { + continue; + } + + let msg: InMessage = match serde_json::from_str(line) { + Ok(m) => m, + Err(e) => { + send_error(&format!("Invalid JSON: {}", e)); + continue; + } + }; + + match msg.method.as_str() { + "init" => { + if let Some(ref eng) = engine { + eng.stop(); + } + + let seed_bytes = match hex::decode(&msg.seed_hash) { + Ok(b) => b, + Err(e) => { + send_error(&format!("Invalid seed_hash hex: {}", e)); + continue; + } + }; + + eprintln!("[IPC] Initializing RandomX (seed={}...)", &msg.seed_hash[..16.min(msg.seed_hash.len())]); + + let result = if light { + MiningEngine::new_light(threads, &seed_bytes) + } else { + MiningEngine::new_full(threads, &seed_bytes) + }; + + match result { + Ok(eng) => { + engine = Some(eng); + start_time = Instant::now(); + last_stats = Instant::now(); + + let mut out = OutMessage::new("ready"); + out.threads = Some(threads); + out.mode = Some(mode_str.to_string()); + send(&out); + } + Err(e) => { + send_error(&format!("Init failed: {}", e)); + } + } + } + + "job" => { + let eng = match engine { + Some(ref e) => e, + None => { + send_error("Engine not initialized. Send 'init' first."); + continue; + } + }; + + let hashing_blob = match hex::decode(&msg.hashing_blob) { + Ok(b) => b, + Err(e) => { + send_error(&format!("Invalid hashing_blob hex: {}", e)); + continue; + } + }; + let template_blob = match hex::decode(&msg.template_blob) { + Ok(b) => b, + Err(e) => { + send_error(&format!("Invalid template_blob hex: {}", e)); + continue; + } + }; + + let difficulty = crate::miner::parse_difficulty( + msg.difficulty, + msg.wide_difficulty.as_deref(), + ); + + current_job_id = msg.job_id.clone(); + + eng.hash_count.store(0, Ordering::Relaxed); + start_time = Instant::now(); + last_stats = Instant::now(); + + eng.send_job(MiningJob { + job_id: 0, + hashing_blob, + template_blob, + difficulty, + height: msg.height, + }); + + eprintln!("[IPC] Job {} started (height={}, diff={})", current_job_id, msg.height, difficulty); + } + + "stop" => { + eprintln!("[IPC] Mining stopped"); + send(&OutMessage::new("stopped")); + } + + "shutdown" => { + eprintln!("[IPC] Shutdown requested"); + if let Some(ref eng) = engine { + eng.stop(); + } + break; + } + + other => { + send_error(&format!("Unknown method: {}", other)); + } + } + } +} diff --git a/crates/salvium-miner/src/main.rs b/crates/salvium-miner/src/main.rs new file mode 100644 index 0000000..747a423 --- /dev/null +++ b/crates/salvium-miner/src/main.rs @@ -0,0 +1,330 @@ +use clap::Parser; +use std::sync::atomic::Ordering; +use std::time::{Duration, Instant}; + +mod daemon; +mod ipc; +mod miner; +mod stratum; + +use daemon::DaemonClient; +use miner::{MiningEngine, MiningJob}; + +#[derive(Parser)] +#[command(name = "salvium-miner")] +#[command(about = "Native RandomX CPU miner for Salvium")] +struct Args { + /// Daemon RPC URL + #[arg(short, long, default_value = "http://127.0.0.1:29081")] + daemon: String, + + /// Wallet address for mining rewards (not required in IPC mode) + #[arg(short, long, default_value = "")] + wallet: String, + + /// Number of mining threads + #[arg(short, long, default_value_t = default_threads())] + threads: usize, + + /// Use light mode (256MB per thread instead of 2GB shared dataset) + #[arg(long)] + light: bool, + + /// Run benchmark for 20 seconds and exit + #[arg(long)] + benchmark: bool, + + /// IPC mode: read jobs from stdin, write results to stdout (JSON lines) + #[arg(long)] + ipc: bool, +} + +fn default_threads() -> usize { + std::cmp::max(1, num_cpus::get().saturating_sub(1)) +} + +fn format_hashrate(hr: f64) -> String { + if hr >= 1_000_000.0 { + format!("{:.2} MH/s", hr / 1_000_000.0) + } else if hr >= 1_000.0 { + format!("{:.2} KH/s", hr / 1_000.0) + } else { + format!("{:.2} H/s", hr) + } +} + +fn main() { + let args = Args::parse(); + + if args.ipc { + ipc::run_ipc(args.threads, args.light); + return; + } + + if args.wallet.is_empty() { + eprintln!("Error: --wallet is required (unless using --ipc mode)"); + std::process::exit(1); + } + + eprintln!("Salvium Native RandomX Miner"); + eprintln!("============================"); + eprintln!("Daemon: {}", args.daemon); + eprintln!("Wallet: {}...", &args.wallet[..20.min(args.wallet.len())]); + eprintln!("Threads: {}", args.threads); + eprintln!("Mode: {}", if args.light { "light (256MB/thread)" } else { "full (2GB shared dataset)" }); + eprintln!(); + + // Connect to daemon + let client = DaemonClient::new(&args.daemon); + + let info = match client.get_info() { + Ok(i) => i, + Err(e) => { + eprintln!("Cannot connect to daemon: {}", e); + std::process::exit(1); + } + }; + + eprintln!("Daemon height: {}, difficulty: {}", info.height, info.difficulty); + + // Get initial block template + let template = match client.get_block_template(&args.wallet, 8) { + Ok(t) => t, + Err(e) => { + eprintln!("Failed to get block template: {}", e); + std::process::exit(1); + } + }; + + let difficulty = miner::parse_difficulty( + template.difficulty, + template.wide_difficulty.as_deref(), + ); + + eprintln!("Template: height={}, difficulty={}", template.height, difficulty); + + let seed_bytes = hex::decode(&template.seed_hash).unwrap_or_else(|_| vec![0u8; 32]); + let hashing_blob = hex::decode(&template.blockhashing_blob).expect("Invalid hashing blob"); + let template_blob = hex::decode(&template.blocktemplate_blob).expect("Invalid template blob"); + + // Initialize mining engine + let engine = if args.light { + MiningEngine::new_light(args.threads, &seed_bytes) + } else { + MiningEngine::new_full(args.threads, &seed_bytes) + }; + + let engine = match engine { + Ok(e) => e, + Err(e) => { + eprintln!("Failed to initialize mining engine: {}", e); + std::process::exit(1); + } + }; + + // Set up SIGINT handler + let running = engine.running.clone(); + ctrlc_handler(running.clone()); + + eprintln!(); + eprintln!("Mining started. Press Ctrl+C to stop."); + eprintln!(); + + // Send initial job + let mut job_id = 0u64; + let mut current_height = template.height; + let mut current_difficulty = difficulty; + let current_seed = template.seed_hash.clone(); + + engine.send_job(MiningJob { + job_id, + hashing_blob: hashing_blob.clone(), + template_blob: template_blob.clone(), + difficulty, + height: template.height, + }); + + let start_time = Instant::now(); + let mut last_template_fetch = Instant::now(); + let mut last_stats = Instant::now(); + let mut blocks_found = 0u64; + + let mut current_prev_hash = template.prev_hash.clone(); + + // Main loop + while engine.running.load(Ordering::Relaxed) { + // Check for found blocks — submit only the first, discard rest + let mut block_found = false; + if let Some(block) = engine.try_recv_block() { + // Skip stale blocks from old jobs + if block.job_id != job_id { + continue; + } + block_found = true; + + // Drain any stale blocks + let mut drained = 0; + while engine.try_recv_block().is_some() { drained += 1; } + + eprintln!(); + eprintln!("*** BLOCK FOUND at height {}! nonce={} ***", current_height, block.nonce); + + match client.submit_block(&block.blob_hex) { + Ok(()) => { + blocks_found += 1; + eprintln!("Block accepted! Total: {}", blocks_found); + } + Err(e) => { + eprintln!("Block rejected: {}", e); + } + } + if drained > 0 { + eprintln!("(discarded {} stale blocks)", drained); + } + + // Drain stale blocks, then immediately fetch new template. + while engine.try_recv_block().is_some() {} + + if let Ok(tmpl) = client.get_block_template(&args.wallet, 8) { + let new_diff = miner::parse_difficulty( + tmpl.difficulty, + tmpl.wide_difficulty.as_deref(), + ); + + if tmpl.seed_hash != current_seed { + eprintln!("Seed hash changed — need to restart with new dataset"); + engine.stop(); + break; + } + + // Drain again right before sending new job + while engine.try_recv_block().is_some() {} + + current_height = tmpl.height; + current_difficulty = new_diff; + current_prev_hash = tmpl.prev_hash.clone(); + job_id += 1; + + let hb = hex::decode(&tmpl.blockhashing_blob).unwrap_or_default(); + let tb = hex::decode(&tmpl.blocktemplate_blob).unwrap_or_default(); + + engine.send_job(MiningJob { + job_id, + hashing_blob: hb, + template_blob: tb, + difficulty: new_diff, + height: tmpl.height, + }); + + eprintln!("Template: height={} diff={} prev={:.16}...", + tmpl.height, new_diff, tmpl.prev_hash); + } + last_template_fetch = Instant::now(); + } + + // Refresh template every 5 seconds (routine poll) + if !block_found && last_template_fetch.elapsed() > Duration::from_secs(5) { + if let Ok(tmpl) = client.get_block_template(&args.wallet, 8) { + let new_diff = miner::parse_difficulty( + tmpl.difficulty, + tmpl.wide_difficulty.as_deref(), + ); + + if tmpl.seed_hash != current_seed { + eprintln!("\nSeed hash changed — need to restart with new dataset"); + engine.stop(); + break; + } + + // Send new job if anything changed + if tmpl.prev_hash != current_prev_hash || tmpl.height != current_height || new_diff != current_difficulty { + current_height = tmpl.height; + current_difficulty = new_diff; + current_prev_hash = tmpl.prev_hash.clone(); + job_id += 1; + + let hb = hex::decode(&tmpl.blockhashing_blob).unwrap_or_default(); + let tb = hex::decode(&tmpl.blocktemplate_blob).unwrap_or_default(); + + engine.send_job(MiningJob { + job_id, + hashing_blob: hb, + template_blob: tb, + difficulty: new_diff, + height: tmpl.height, + }); + } + } + last_template_fetch = Instant::now(); + } + + // Print stats every 10 seconds + if last_stats.elapsed() > Duration::from_secs(10) { + let elapsed = start_time.elapsed().as_secs_f64(); + let total = engine.hash_count.load(Ordering::Relaxed); + let hr = total as f64 / elapsed; + let est_block = current_difficulty as f64 / hr; + + eprint!( + "\r[H={}] {} | Hashes: {} | Blocks: {} | Diff: {} | Est: {:.0}s/block ", + current_height, + format_hashrate(hr), + total, + blocks_found, + current_difficulty, + est_block + ); + last_stats = Instant::now(); + + // Benchmark mode: exit after 20 seconds + if args.benchmark && elapsed > 20.0 { + eprintln!(); + eprintln!(); + eprintln!("=== Benchmark Results ==="); + eprintln!("Threads: {}", args.threads); + eprintln!("Mode: {}", if args.light { "light" } else { "full" }); + eprintln!("Duration: {:.1}s", elapsed); + eprintln!("Hashes: {}", total); + eprintln!("Hashrate: {} ({:.1} H/s per thread)", + format_hashrate(hr), hr / args.threads as f64); + engine.stop(); + break; + } + } + + std::thread::sleep(Duration::from_millis(50)); + } + + // Final stats + let elapsed = start_time.elapsed().as_secs_f64(); + let total = engine.hash_count.load(Ordering::Relaxed); + eprintln!(); + eprintln!("Shutting down..."); + eprintln!("Total hashes: {}", total); + eprintln!("Blocks found: {}", blocks_found); + eprintln!("Avg hashrate: {}", format_hashrate(total as f64 / elapsed)); + + engine.stop(); +} + +fn ctrlc_handler(running: std::sync::Arc) { + let _ = std::thread::spawn(move || {}); + + #[cfg(unix)] + unsafe { + libc::signal(libc::SIGINT, handle_sigint as *const () as libc::sighandler_t); + RUNNING_FLAG.store(running.as_ref() as *const _ as usize, Ordering::SeqCst); + } +} + +#[cfg(unix)] +static RUNNING_FLAG: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + +#[cfg(unix)] +extern "C" fn handle_sigint(_: libc::c_int) { + let ptr = RUNNING_FLAG.load(Ordering::SeqCst); + if ptr != 0 { + let flag = unsafe { &*(ptr as *const std::sync::atomic::AtomicBool) }; + flag.store(false, Ordering::Relaxed); + } +} diff --git a/crates/salvium-miner/src/miner.rs b/crates/salvium-miner/src/miner.rs new file mode 100644 index 0000000..7959ea4 --- /dev/null +++ b/crates/salvium-miner/src/miner.rs @@ -0,0 +1,454 @@ +//! Multi-threaded RandomX mining engine +//! +//! Full mode: uses direct C FFI to share a single 2GB dataset across worker VMs. +//! Light mode: uses randomx-rs Rust API with per-thread 256MB caches. + +use randomx_rs::{RandomXCache, RandomXFlag, RandomXVM}; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::mpsc; +use std::sync::Arc; +use std::thread; + +// Direct C FFI for dataset sharing (the Rust wrapper doesn't support this) +extern "C" { + fn randomx_alloc_dataset(flags: u32) -> *mut std::ffi::c_void; + fn randomx_init_dataset( + dataset: *mut std::ffi::c_void, + cache: *mut std::ffi::c_void, + start_item: u64, + item_count: u64, + ); + fn randomx_dataset_item_count() -> u64; + fn randomx_create_vm( + flags: u32, + cache: *mut std::ffi::c_void, + dataset: *mut std::ffi::c_void, + ) -> *mut std::ffi::c_void; + fn randomx_destroy_vm(vm: *mut std::ffi::c_void); + fn randomx_calculate_hash( + vm: *mut std::ffi::c_void, + input: *const u8, + input_size: u64, + output: *mut u8, + ); + fn randomx_alloc_cache(flags: u32) -> *mut std::ffi::c_void; + fn randomx_init_cache( + cache: *mut std::ffi::c_void, + key: *const u8, + key_size: u64, + ); + fn randomx_release_cache(cache: *mut std::ffi::c_void); + fn randomx_release_dataset(dataset: *mut std::ffi::c_void); + fn randomx_get_flags() -> u32; +} + +/// A found block ready for submission +pub struct FoundBlock { + pub nonce: u32, + pub hash: Vec, + pub blob_hex: String, + pub job_id: u64, +} + +/// Job data sent to worker threads +#[derive(Clone)] +pub struct MiningJob { + pub job_id: u64, + pub hashing_blob: Vec, + pub template_blob: Vec, + pub difficulty: u128, + pub height: u64, +} + +/// Wrapper to send raw pointers across threads. +/// Safety: RandomX dataset is read-only after init; VMs are per-thread. +struct RawPtr(*mut std::ffi::c_void); +unsafe impl Send for RawPtr {} +unsafe impl Sync for RawPtr {} + +/// Mining engine managing worker threads +pub struct MiningEngine { + pub hash_count: Arc, + pub running: Arc, + result_rx: mpsc::Receiver, + job_senders: Vec>, + _handles: Vec>, +} + +impl MiningEngine { + /// Initialize the mining engine with full mode (shared 2GB dataset, direct C FFI) + pub fn new_full( + num_threads: usize, + seed_hash: &[u8], + ) -> Result { + let flags = unsafe { randomx_get_flags() } + | 0x4 // FLAG_FULL_MEM + | 0x8; // FLAG_JIT + + eprintln!("RandomX flags: 0x{:x}", flags); + + // Allocate and init cache via C FFI + let cache_ptr = unsafe { randomx_alloc_cache(flags) }; + if cache_ptr.is_null() { + return Err("Failed to allocate RandomX cache".to_string()); + } + unsafe { + randomx_init_cache(cache_ptr, seed_hash.as_ptr(), seed_hash.len() as u64); + } + eprintln!("Cache initialized (256MB)"); + + // Allocate and init dataset + let dataset_ptr = unsafe { randomx_alloc_dataset(flags) }; + if dataset_ptr.is_null() { + unsafe { randomx_release_cache(cache_ptr); } + return Err("Failed to allocate RandomX dataset (need ~2GB free RAM)".to_string()); + } + + let item_count = unsafe { randomx_dataset_item_count() }; + eprintln!("Generating dataset ({} items, ~2GB)...", item_count); + let start = std::time::Instant::now(); + + // Initialize dataset using multiple threads for speed + let items_per_thread = item_count / num_threads as u64; + let ds_shared = Arc::new(RawPtr(dataset_ptr)); + let ca_shared = Arc::new(RawPtr(cache_ptr)); + let mut init_handles = Vec::new(); + for i in 0..num_threads { + let ds = Arc::clone(&ds_shared); + let ca = Arc::clone(&ca_shared); + let start_item = i as u64 * items_per_thread; + let count = if i == num_threads - 1 { + item_count - start_item + } else { + items_per_thread + }; + init_handles.push(thread::spawn(move || unsafe { + randomx_init_dataset(ds.0, ca.0, start_item, count); + })); + } + for h in init_handles { + let _ = h.join(); + } + + eprintln!("Dataset ready in {:.1}s", start.elapsed().as_secs_f64()); + + // Now create per-thread VMs sharing the dataset + let hash_count = Arc::new(AtomicU64::new(0)); + let running = Arc::new(AtomicBool::new(true)); + let (result_tx, result_rx) = mpsc::channel(); + let mut job_senders = Vec::new(); + let mut handles = Vec::new(); + + for worker_id in 0..num_threads { + let (job_tx, job_rx) = mpsc::channel::(); + job_senders.push(job_tx); + + let hash_count = Arc::clone(&hash_count); + let running = Arc::clone(&running); + let result_tx = result_tx.clone(); + let ds = Arc::clone(&ds_shared); + let nonce_start = (worker_id as u64 * (u32::MAX as u64 / num_threads as u64)) as u32; + + let handle = thread::spawn(move || { + let vm_ptr = unsafe { + randomx_create_vm(flags, std::ptr::null_mut(), ds.0) + }; + if vm_ptr.is_null() { + eprintln!("Worker {} failed to create VM", worker_id); + return; + } + + eprintln!("Worker {} ready", worker_id); + + worker_loop( + vm_ptr, &job_rx, &running, &hash_count, &result_tx, nonce_start, + ); + + unsafe { randomx_destroy_vm(vm_ptr); } + }); + + handles.push(handle); + } + + // Release cache (dataset is self-contained after init) + unsafe { randomx_release_cache(cache_ptr); } + + // NOTE: dataset_ptr is intentionally leaked — it must outlive all worker VMs. + // In a long-running miner this is fine; the OS reclaims on exit. + + Ok(Self { + hash_count, + running, + result_rx, + job_senders, + _handles: handles, + }) + } + + /// Initialize light mode (each thread has own 256MB cache via Rust API) + pub fn new_light( + num_threads: usize, + seed_hash: &[u8], + ) -> Result { + let flags = RandomXFlag::get_recommended_flags(); + + let hash_count = Arc::new(AtomicU64::new(0)); + let running = Arc::new(AtomicBool::new(true)); + let (result_tx, result_rx) = mpsc::channel(); + let mut job_senders = Vec::new(); + let mut handles = Vec::new(); + + let seed = seed_hash.to_vec(); + + for worker_id in 0..num_threads { + let (job_tx, job_rx) = mpsc::channel::(); + job_senders.push(job_tx); + + let hash_count = Arc::clone(&hash_count); + let running = Arc::clone(&running); + let result_tx = result_tx.clone(); + let seed = seed.clone(); + let nonce_start = (worker_id as u64 * (u32::MAX as u64 / num_threads as u64)) as u32; + + let handle = thread::spawn(move || { + let cache = match RandomXCache::new(flags, &seed) { + Ok(c) => c, + Err(e) => { + eprintln!("Worker {} cache init failed: {:?}", worker_id, e); + return; + } + }; + let mut vm = match RandomXVM::new(flags, Some(cache), None) { + Ok(v) => v, + Err(e) => { + eprintln!("Worker {} VM init failed: {:?}", worker_id, e); + return; + } + }; + + eprintln!("Worker {} ready (light mode)", worker_id); + + while running.load(Ordering::Relaxed) { + let job = match job_rx.recv_timeout(std::time::Duration::from_millis(100)) { + Ok(j) => j, + Err(mpsc::RecvTimeoutError::Timeout) => continue, + Err(_) => break, + }; + + let nonce_offset = find_nonce_offset(&job.hashing_blob); + mine_job_rust(&mut vm, &job, &running, &hash_count, &result_tx, nonce_start, nonce_offset); + } + }); + + handles.push(handle); + } + + Ok(Self { + hash_count, + running, + result_rx, + job_senders, + _handles: handles, + }) + } + + pub fn send_job(&self, job: MiningJob) { + for tx in &self.job_senders { + let _ = tx.send(job.clone()); + } + } + + pub fn try_recv_block(&self) -> Option { + self.result_rx.try_recv().ok() + } + + pub fn stop(&self) { + self.running.store(false, Ordering::Relaxed); + } +} + +/// Worker loop using raw C FFI VM pointer (full mode) +fn worker_loop( + vm_ptr: *mut std::ffi::c_void, + job_rx: &mpsc::Receiver, + running: &AtomicBool, + hash_count: &AtomicU64, + result_tx: &mpsc::Sender, + nonce_start: u32, +) { + let mut hash_out = [0u8; 32]; + + while running.load(Ordering::Relaxed) { + // Wait for a job + let mut job = match job_rx.recv_timeout(std::time::Duration::from_millis(100)) { + Ok(j) => j, + Err(mpsc::RecvTimeoutError::Timeout) => continue, + Err(_) => break, + }; + + let mut nonce_offset = find_nonce_offset(&job.hashing_blob); + let mut nonce = nonce_start; + let mut blob = job.hashing_blob.clone(); + let mut blob_len = blob.len(); + + loop { + if !running.load(Ordering::Relaxed) { + break; + } + + // Check for new job (non-blocking) + if let Ok(new_job) = job_rx.try_recv() { + job = new_job; + nonce_offset = find_nonce_offset(&job.hashing_blob); + nonce = nonce_start; + blob = job.hashing_blob.clone(); + blob_len = blob.len(); + continue; + } + + // Set nonce + set_nonce(&mut blob, nonce_offset, nonce); + + // Hash + unsafe { + randomx_calculate_hash( + vm_ptr, + blob.as_ptr(), + blob_len as u64, + hash_out.as_mut_ptr(), + ); + } + + hash_count.fetch_add(1, Ordering::Relaxed); + + if check_hash(&hash_out, job.difficulty) { + let mut template = job.template_blob.clone(); + let tmpl_offset = find_nonce_offset(&template); + set_nonce(&mut template, tmpl_offset, nonce); + + let _ = result_tx.send(FoundBlock { + nonce, + hash: hash_out.to_vec(), + blob_hex: hex::encode(&template), + job_id: job.job_id, + }); + } + + nonce = nonce.wrapping_add(1); + if nonce == nonce_start { + break; // exhausted nonce space + } + } + } +} + +/// Mine a single job using the Rust RandomXVM wrapper (light mode) +fn mine_job_rust( + vm: &mut RandomXVM, + job: &MiningJob, + running: &AtomicBool, + hash_count: &AtomicU64, + result_tx: &mpsc::Sender, + nonce_start: u32, + nonce_offset: usize, +) { + let mut nonce = nonce_start; + + loop { + if !running.load(Ordering::Relaxed) { + break; + } + + let mut blob = job.hashing_blob.clone(); + set_nonce(&mut blob, nonce_offset, nonce); + + let hash = match vm.calculate_hash(&blob) { + Ok(h) => h, + Err(_) => { + nonce = nonce.wrapping_add(1); + continue; + } + }; + + hash_count.fetch_add(1, Ordering::Relaxed); + + if check_hash(&hash, job.difficulty) { + let mut template = job.template_blob.clone(); + let tmpl_offset = find_nonce_offset(&template); + set_nonce(&mut template, tmpl_offset, nonce); + + let _ = result_tx.send(FoundBlock { + nonce, + hash: hash.clone(), + blob_hex: hex::encode(&template), + job_id: job.job_id, + }); + } + + nonce = nonce.wrapping_add(1); + if nonce == nonce_start { + break; + } + } +} + +fn set_nonce(blob: &mut [u8], offset: usize, nonce: u32) { + blob[offset] = (nonce & 0xff) as u8; + blob[offset + 1] = ((nonce >> 8) & 0xff) as u8; + blob[offset + 2] = ((nonce >> 16) & 0xff) as u8; + blob[offset + 3] = ((nonce >> 24) & 0xff) as u8; +} + +/// Find nonce offset in block hashing blob. +/// Layout: major_version(varint) + minor_version(varint) + timestamp(varint) + prev_id(32 bytes) + nonce(4 bytes) +pub fn find_nonce_offset(blob: &[u8]) -> usize { + let mut offset = 0; + // Skip 3 varints (major_version, minor_version, timestamp) + for _ in 0..3 { + while blob[offset] & 0x80 != 0 { + offset += 1; + } + offset += 1; + } + // Skip prev_id (32 bytes) + offset += 32; + offset +} + +/// Check if hash meets difficulty target. +/// CryptoNote convention: interpret hash as little-endian 256-bit integer, +/// block is valid if hash * difficulty < 2^256. +fn check_hash(hash: &[u8], difficulty: u128) -> bool { + if difficulty == 0 { + return false; + } + // Read hash as little-endian u128 pair [low, high] + let mut lo = 0u128; + let mut hi = 0u128; + for i in 0..16 { + lo |= (hash[i] as u128) << (i * 8); + } + for i in 0..16 { + hi |= (hash[16 + i] as u128) << (i * 8); + } + + // Check: hash * difficulty < 2^256 + // Multiply as 256-bit: result = [lo*diff, hi*diff + carry] + let (_, lo_overflow) = lo.overflowing_mul(difficulty); + let hi_prod = match hi.checked_mul(difficulty) { + Some(h) => h, + None => return false, + }; + let carry = if lo_overflow { difficulty } else { 0 }; + hi_prod.checked_add(carry).is_some() +} + +/// Parse difficulty from wide_difficulty hex string or u64 +pub fn parse_difficulty(difficulty: u64, wide_difficulty: Option<&str>) -> u128 { + if let Some(wide) = wide_difficulty { + let hex_str = wide.strip_prefix("0x").unwrap_or(wide); + u128::from_str_radix(hex_str, 16).unwrap_or(difficulty as u128) + } else { + difficulty as u128 + } +} diff --git a/crates/salvium-miner/src/stratum.rs b/crates/salvium-miner/src/stratum.rs new file mode 100644 index 0000000..f33a25c --- /dev/null +++ b/crates/salvium-miner/src/stratum.rs @@ -0,0 +1,21 @@ +//! Stratum protocol client (stub for future implementation) +//! +//! TODO: Implement stratum+tcp/ssl for pool mining +//! - Login (mining.subscribe, mining.authorize) +//! - Job reception (mining.notify) +//! - Share submission (mining.submit) +//! - Keepalive +//! - TLS support + +/// Placeholder for future stratum pool client +pub struct StratumClient { + _pool_url: String, +} + +impl StratumClient { + pub fn new(pool_url: &str) -> Self { + Self { + _pool_url: pool_url.to_string(), + } + } +} diff --git a/mine-testnet.js b/mine-testnet.js new file mode 100644 index 0000000..56060dc --- /dev/null +++ b/mine-testnet.js @@ -0,0 +1,187 @@ +#!/usr/bin/env bun +/** + * Local RandomX miner against remote Salvium daemon + * + * Uses our WASM RandomX (full mode, 2GB dataset) + daemon RPC. + * Single-threaded but with full dataset for maximum per-thread hashrate. + * + * Usage: + * bun mine-testnet.js [mode] + * mode: "full" (default, 2GB dataset, ~30-50 H/s) or "light" (256MB, ~10 H/s) + */ + +import { DaemonRPC } from './src/rpc/daemon.js'; +import { RandomXContext } from './src/randomx/index.js'; +import { RandomXFullMode } from './src/randomx/full-mode.js'; +import { + parseBlockTemplate, + findNonceOffset, + setNonce, + checkHash, + formatBlockForSubmission, + formatHashrate, +} from './src/mining.js'; +import { hexToBytes, bytesToHex } from './src/address.js'; + +// ============================================================================ +// Configuration +// ============================================================================ + +const DAEMON_URL = process.env.DAEMON_URL || 'http://web.whiskymine.io:29081'; +const WALLET_FILE = process.env.WALLET_FILE || `${process.env.HOME}/testnet-wallet/wallet.json`; +const MODE = process.argv[2] || 'full'; +const TEMPLATE_REFRESH_MS = 5000; + +// ============================================================================ +// Main +// ============================================================================ + +const wallet = JSON.parse(await Bun.file(WALLET_FILE).text()); +const daemon = new DaemonRPC({ url: DAEMON_URL }); + +console.log('Salvium Local RandomX Miner'); +console.log('==========================='); +console.log(`Daemon: ${DAEMON_URL}`); +console.log(`Wallet: ${wallet.address.slice(0, 20)}...`); +console.log(`Mode: ${MODE} (${MODE === 'full' ? '2GB dataset' : '256MB cache'})`); +console.log(''); + +// Verify daemon +const info = await daemon.getInfo(); +if (!info.success) { + console.error('Cannot connect to daemon'); + process.exit(1); +} +console.log(`Daemon height: ${info.result.height}, difficulty: ${info.result.difficulty}`); +console.log(''); + +// Get block template +let template = await daemon.getBlockTemplate(wallet.address, 8); +if (!template.success) { + console.error('Failed to get block template:', template.error); + process.exit(1); +} + +let parsed = parseBlockTemplate(template.result); +console.log(`Template: height=${parsed.height}, difficulty=${parsed.difficulty}`); + +// Initialize RandomX +const seedBytes = parsed.seedHash ? hexToBytes(parsed.seedHash) : new Uint8Array(32); +let rx; + +if (MODE === 'full') { + console.log('Initializing RandomX full mode (256MB cache + 2GB dataset)...'); + console.log('This will take 30-60 seconds...'); + rx = new RandomXFullMode(); + await rx.init(seedBytes, { + onProgress: (pct, phase) => { + process.stdout.write(`\r ${phase}: ${pct}% `); + } + }); + console.log(''); +} else { + console.log('Initializing RandomX light mode (256MB cache)...'); + rx = new RandomXContext(); + await rx.init(seedBytes); +} + +console.log('RandomX ready.\n'); + +// ============================================================================ +// Mining loop +// ============================================================================ + +let totalHashes = 0; +let blocksFound = 0; +const startTime = Date.now(); +let lastTemplateFetch = Date.now(); +let lastStatsPrint = Date.now(); +let currentSeedHash = parsed.seedHash; +let running = true; + +process.on('SIGINT', () => { + running = false; + console.log('\nShutting down...'); + const elapsed = (Date.now() - startTime) / 1000; + console.log(`Total hashes: ${totalHashes.toLocaleString()}`); + console.log(`Blocks found: ${blocksFound}`); + console.log(`Avg hashrate: ${formatHashrate(totalHashes / elapsed)}`); + process.exit(0); +}); + +console.log('Mining started. Press Ctrl+C to stop.\n'); + +while (running) { + const hashingBlob = parsed.blockhashingBytes; + const nonceOffset = findNonceOffset(hashingBlob); + const difficulty = parsed.difficulty; + const templateBlob = parsed.blocktemplateBytes; + + // Random starting nonce + const startNonce = Math.floor(Math.random() * 0xFFFFFFFF); + + for (let i = 0; i < 256 && running; i++) { + const nonce = (startNonce + i) & 0xFFFFFFFF; + const blob = setNonce(hashingBlob, nonce, nonceOffset); + const hash = rx.hash(blob); + totalHashes++; + + if (checkHash(hash, difficulty)) { + const blockHex = formatBlockForSubmission(templateBlob, nonce, + findNonceOffset(templateBlob)); + + console.log(`\n*** BLOCK FOUND at height ${parsed.height}! nonce=${nonce} ***`); + + const submitResult = await daemon.submitBlock([blockHex]); + if (submitResult.success) { + blocksFound++; + console.log(`Block accepted! Total: ${blocksFound}`); + } else { + console.log(`Rejected: ${JSON.stringify(submitResult.error || submitResult.result)}`); + } + + // New template immediately + lastTemplateFetch = 0; + break; + } + } + + // Refresh template + const now = Date.now(); + if (now - lastTemplateFetch > TEMPLATE_REFRESH_MS) { + try { + const newTemplate = await daemon.getBlockTemplate(wallet.address, 8); + if (newTemplate.success) { + const newParsed = parseBlockTemplate(newTemplate.result); + if (newParsed.seedHash !== currentSeedHash) { + console.log(`\nSeed changed, re-initializing RandomX...`); + if (MODE === 'full') { + await rx.init(hexToBytes(newParsed.seedHash), {}); + } else { + await rx.init(hexToBytes(newParsed.seedHash)); + } + currentSeedHash = newParsed.seedHash; + } + parsed = newParsed; + } + lastTemplateFetch = now; + } catch (e) { + // Keep mining + } + } + + // Stats every 10s + if (now - lastStatsPrint > 10000) { + const elapsed = (now - startTime) / 1000; + const hr = totalHashes / elapsed; + const estBlockTime = Number(parsed.difficulty) / hr; + process.stdout.write( + `\r[H=${parsed.height}] ${formatHashrate(hr)} | ` + + `Hashes: ${totalHashes.toLocaleString()} | ` + + `Blocks: ${blocksFound} | ` + + `Diff: ${parsed.difficulty} | ` + + `Est: ${isFinite(estBlockTime) ? estBlockTime.toFixed(0) + 's' : '...'} ` + ); + lastStatsPrint = now; + } +} diff --git a/mine-worker.js b/mine-worker.js new file mode 100644 index 0000000..4d16cc3 --- /dev/null +++ b/mine-worker.js @@ -0,0 +1,64 @@ +/** + * Mining worker thread - runs its own RandomX context and mines independently + */ +import { parentPort, workerData } from 'worker_threads'; +import { RandomXContext } from './src/randomx/index.js'; +import { findNonceOffset, setNonce, checkHash } from './src/mining.js'; +import { hexToBytes, bytesToHex } from './src/address.js'; + +const { workerId, seedHash } = workerData; + +// Initialize RandomX +const rx = new RandomXContext(); +await rx.init(hexToBytes(seedHash)); +parentPort.postMessage({ type: 'ready', workerId }); + +let hashCount = 0; +let currentJob = null; + +// Listen for jobs from main thread +parentPort.on('message', (msg) => { + if (msg.type === 'job') { + currentJob = msg; + mine(msg); + } else if (msg.type === 'stop') { + process.exit(0); + } else if (msg.type === 'newSeed') { + rx.init(hexToBytes(msg.seedHash)).then(() => { + parentPort.postMessage({ type: 'seedReady', workerId }); + }); + } +}); + +async function mine(job) { + const hashingBlob = hexToBytes(job.hashingBlobHex); + const nonceOffset = findNonceOffset(hashingBlob); + const difficulty = BigInt(job.difficulty); + const jobId = job.jobId; + + // Each worker starts at a different offset to avoid overlap + let nonce = (workerId * 0x20000000 + Math.floor(Math.random() * 0x1FFFFFFF)) >>> 0; + + while (currentJob && currentJob.jobId === jobId) { + const blob = setNonce(hashingBlob, nonce, nonceOffset); + const hash = rx.hash(blob); + hashCount++; + + if (checkHash(hash, difficulty)) { + parentPort.postMessage({ + type: 'block', + workerId, + nonce, + hash: bytesToHex(hash), + jobId, + }); + } + + nonce = (nonce + 1) >>> 0; + + // Report hashrate every 64 hashes + if (hashCount % 64 === 0) { + parentPort.postMessage({ type: 'hashes', workerId, count: 64 }); + } + } +} diff --git a/package.json b/package.json index fee9186..e6ce4f7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,9 @@ "scripts": { "test": "node test/run.js", "build:wasm": "asc assembly/index.ts --outFile build/randomx.wasm --optimize --enable simd --initialMemory 16 --maximumMemory 8192", - "build:wasm-crypto": "cd crates/salvium-crypto && PATH=\"$HOME/.cargo/bin:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH\" RUSTUP_HOME=\"$HOME/.rustup\" CARGO_HOME=\"$HOME/.cargo\" RUSTFLAGS=\"-Ctarget-feature=+simd128\" wasm-pack build --target web --out-dir ../../src/crypto/wasm" + "build:wasm-crypto": "cd crates/salvium-crypto && PATH=\"$HOME/.cargo/bin:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH\" RUSTUP_HOME=\"$HOME/.rustup\" CARGO_HOME=\"$HOME/.cargo\" RUSTFLAGS=\"-Ctarget-feature=+simd128\" wasm-pack build --target web --out-dir ../../src/crypto/wasm", + "build:miner": "cd crates/salvium-miner && PATH=\"$HOME/.cargo/bin:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH\" RUSTUP_HOME=\"$HOME/.rustup\" CARGO_HOME=\"$HOME/.cargo\" cargo build --release", + "mine": "crates/salvium-miner/target/release/salvium-miner" }, "files": [ "src/", diff --git a/src/wallet-sync.js b/src/wallet-sync.js index b707763..6c533aa 100644 --- a/src/wallet-sync.js +++ b/src/wallet-sync.js @@ -362,12 +362,6 @@ export class WalletSync { // Process blocks in batches using batch RPC for better performance const BLOCK_BATCH_SIZE = 100; // Fetch 100 blocks per RPC call - // Debug: log first syncBatch call - if (this._syncBatchCount === undefined) this._syncBatchCount = 0; - this._syncBatchCount++; - if (this._syncBatchCount === 1) { - console.log(`[DEBUG] First _syncBatch call, headers count=${headers.length}`); - } for (let i = 0; i < headers.length; i += BLOCK_BATCH_SIZE) { if (this._stopRequested) break; @@ -378,10 +372,6 @@ export class WalletSync { // Batch fetch all blocks at once const blocksResponse = await this.daemon.getBlocksByHeight(heights); - // Debug: log batch response status - if (this._syncBatchCount === 1 && i === 0) { - console.log(`[DEBUG] Batch fetch response: success=${blocksResponse.success}, has blocks=${!!blocksResponse.result?.blocks}, blocks count=${blocksResponse.result?.blocks?.length || 0}`); - } if (!blocksResponse.success || !blocksResponse.result?.blocks) { // Fallback to individual fetches if batch fails @@ -457,20 +447,10 @@ export class WalletSync { // blockData from get_blocks_by_height.bin contains block blob // We need to parse it or use the included transactions - // Debug: log batch processing status - if (this._batchDebugCount === undefined) this._batchDebugCount = 0; - this._batchDebugCount++; - if (this._batchDebugCount <= 3) { - console.log(`[DEBUG] _processBlockFromBatch at height ${header.height}`); - console.log(`[DEBUG] blockData keys: ${blockData ? Object.keys(blockData).join(', ') : 'null'}`); - } // If blockData has the structure we need, use it directly // Otherwise fall back to individual fetch if (!blockData || !blockData.block) { - if (this._batchDebugCount <= 3) { - console.log(`[DEBUG] Falling back to individual fetch for height ${header.height}`); - } return this._processBlock(header); } @@ -543,9 +523,6 @@ export class WalletSync { * @param {Object} header - Block header */ async _processBlock(header) { - // Debug: count blocks processed via individual fetch - if (this._individualBlockCount === undefined) this._individualBlockCount = 0; - this._individualBlockCount++; // Get full block data - includes miner_tx and protocol_tx in JSON const blockResponse = await this.daemon.getBlock({ height: header.height }); @@ -566,14 +543,6 @@ export class WalletSync { } } - // Debug: log first few blocks' miner_tx structure - if (this._individualBlockCount <= 3 && blockJson?.miner_tx) { - console.log(`[DEBUG] Block ${header.height} miner_tx keys: ${Object.keys(blockJson.miner_tx).join(', ')}`); - console.log(`[DEBUG] miner_tx.vout count: ${(blockJson.miner_tx.vout || []).length}`); - if (blockJson.miner_tx.vout?.[0]?.target) { - console.log(`[DEBUG] First vout target keys: ${Object.keys(blockJson.miner_tx.vout[0].target).join(', ')}`); - } - } // Process miner_tx (coinbase - block reward) if (blockJson?.miner_tx && block.miner_tx_hash) { @@ -637,15 +606,6 @@ export class WalletSync { async _processEmbeddedTransaction(txJson, txHash, header, options = {}) { const { isMinerTx = false, isProtocolTx = false } = options; - // Debug: count embedded txs processed - if (this._embeddedTxCount === undefined) this._embeddedTxCount = 0; - this._embeddedTxCount++; - if (this._embeddedTxCount <= 3) { - console.log(`[DEBUG] Processing embedded tx at height ${header.height}, isMinerTx=${isMinerTx}, vout count=${(txJson.vout || []).length}`); - if (txJson.extra) { - console.log(`[DEBUG] extra field type: ${Array.isArray(txJson.extra) ? 'array' : typeof txJson.extra}, length=${txJson.extra.length || 0}`); - } - } // Check if we already have this transaction const existing = await this.storage.getTransaction(txHash); @@ -659,11 +619,6 @@ export class WalletSync { const txPubKey = extractTxPubKey(tx); const paymentId = extractPaymentId(tx); - // Debug: log txPubKey extraction - if (this._embeddedTxCount <= 3) { - console.log(`[DEBUG] txPubKey extracted: ${txPubKey ? bytesToHex(txPubKey) : 'null'}`); - console.log(`[DEBUG] converted vout count: ${(tx.prefix?.vout || []).length}`); - } // Determine transaction type const txType = isMinerTx ? 'miner' : (isProtocolTx ? 'protocol' : this._getTxType(tx)); @@ -816,10 +771,17 @@ export class WalletSync { viewTag }; } else if (target?.key) { + // target.key can be a string (plain key) or object {key, asset_type, unlock_time} + // The latter appears in genesis/pre-tagged_key blocks + const keyVal = typeof target.key === 'object' ? target.key.key : target.key; + const assetType = typeof target.key === 'object' ? (target.key.asset_type || 'SAL') : 'SAL'; + const unlockTime = typeof target.key === 'object' ? (target.key.unlock_time || 0) : 0; return { amount: this._safeBigInt(out.amount), type: 0x02, // TXOUT_TYPE.KEY - key: hexToBytes(target.key) + key: hexToBytes(keyVal), + assetType, + unlockTime }; } return { amount: this._safeBigInt(out.amount), type: 0 }; @@ -880,12 +842,6 @@ export class WalletSync { _convertExtraJson(extraArray) { // Extra in JSON is just an array of bytes if (!Array.isArray(extraArray) || extraArray.length === 0) { - // Debug: log if extra is empty or wrong format - if (this._extraDebugCount === undefined) this._extraDebugCount = 0; - this._extraDebugCount++; - if (this._extraDebugCount <= 3) { - console.log(`[DEBUG] _convertExtraJson: extraArray is ${Array.isArray(extraArray) ? 'array of length ' + extraArray.length : typeof extraArray}`); - } return []; } @@ -893,12 +849,6 @@ export class WalletSync { const extraBytes = new Uint8Array(extraArray); const parsed = []; - // Debug: log first few bytes - if (this._extraDebugCount === undefined) this._extraDebugCount = 0; - this._extraDebugCount++; - if (this._extraDebugCount <= 3) { - console.log(`[DEBUG] _convertExtraJson: extraBytes length=${extraBytes.length}, first bytes: ${Array.from(extraBytes.slice(0, 5)).map(b => b.toString(16)).join(' ')}`); - } let offset = 0; while (offset < extraBytes.length) { @@ -971,12 +921,6 @@ export class WalletSync { const txHash = txData.tx_hash; const txBlob = txData.as_hex; - // Debug: count regular txs processed - if (this._regularTxCount === undefined) this._regularTxCount = 0; - this._regularTxCount++; - if (this._regularTxCount <= 3) { - console.log(`[DEBUG] _processTransaction at height ${header.height}, tx ${txHash.slice(0, 16)}...`); - } // Check if we already have this transaction const existing = await this.storage.getTransaction(txHash); @@ -990,10 +934,6 @@ export class WalletSync { const txPubKey = extractTxPubKey(tx); const paymentId = extractPaymentId(tx); - // Debug: log tx structure - if (this._regularTxCount <= 3) { - console.log(`[DEBUG] Regular tx: txPubKey=${txPubKey ? bytesToHex(txPubKey).slice(0, 16) + '...' : 'null'}, vout count=${(tx.prefix?.vout || []).length}`); - } // Determine transaction type (Salvium-specific) // For miner_tx and protocol_tx, use the type from the prefix @@ -1095,24 +1035,6 @@ export class WalletSync { const ownedOutputs = []; const outputs = tx.prefix?.vout || tx.outputs || []; - // Debug: log first 3 calls unconditionally - if (this._scanOutputsCount === undefined) this._scanOutputsCount = 0; - this._scanOutputsCount++; - if (this._scanOutputsCount <= 3) { - console.log(`\n=== _scanOutputs call #${this._scanOutputsCount} at height ${header.height} ===`); - console.log(`txHash: ${txHash}`); - console.log(`txPubKey: ${txPubKey ? bytesToHex(txPubKey) : 'NULL'}`); - console.log(`outputs count: ${outputs.length}`); - console.log(`txType: ${txType}`); - if (outputs.length > 0) { - const firstOutput = outputs[0]; - console.log(`first output type: ${firstOutput.type}`); - console.log(`first output keys: ${Object.keys(firstOutput).join(', ')}`); - const firstKey = this._extractOutputPubKey(firstOutput); - console.log(`first output pubkey: ${firstKey ? bytesToHex(firstKey).slice(0, 32) + '...' : 'NULL'}`); - } - console.log(`===\n`); - } for (let i = 0; i < outputs.length; i++) { const output = outputs[i]; @@ -1220,13 +1142,6 @@ export class WalletSync { ? hexToBytes(firstKi) : firstKi; inputContext = makeInputContext(firstKeyImage); - // Debug: show first key image - if (header.height >= 405588 && header.height <= 405590 && this._inputContextDebug === undefined) { - this._inputContextDebug = true; - console.log(`[INPUT CONTEXT DEBUG] height=${header.height} txHash=${txHash.slice(0,16)}...`); - console.log(` firstKeyImage: ${bytesToHex(firstKeyImage)}`); - console.log(` inputContext: ${bytesToHex(inputContext)}`); - } } else { // Coinbase transaction: input_context = 'C' || block_height inputContext = makeInputContextCoinbase(header.height); @@ -1269,15 +1184,6 @@ export class WalletSync { encryptedAmount: tx.rct?.ecdhInfo?.[outputIndex]?.amount }; - // Debug CARROT scanning inputs - if (header.height >= 405585 && header.height <= 405595) { - console.log(`[DEBUG CARROT SCAN] height=${header.height} outputIndex=${outputIndex}`); - console.log(` key: ${outputForScan.key ? bytesToHex(outputForScan.key).slice(0,16) + '...' : 'NULL'}`); - console.log(` viewTag: ${outputForScan.viewTag}`); - console.log(` enoteEphemeralPubkey: ${outputForScan.enoteEphemeralPubkey ? (typeof outputForScan.enoteEphemeralPubkey === 'string' ? outputForScan.enoteEphemeralPubkey.slice(0,16) : bytesToHex(outputForScan.enoteEphemeralPubkey).slice(0,16)) + '...' : 'NULL'}`); - console.log(` amountCommitment: ${amountCommitment ? bytesToHex(amountCommitment).slice(0,16) + '...' : 'NULL'}`); - console.log(` carrotKeys: viewIncomingKey=${this.carrotKeys?.viewIncomingKey ? 'SET' : 'NULL'}, accountSpendPubkey=${this.carrotKeys?.accountSpendPubkey ? 'SET' : 'NULL'}`); - } // Scan with CARROT algorithm let result; @@ -1370,33 +1276,21 @@ export class WalletSync { * @private */ async _scanCNOutput(output, outputIndex, tx, txHash, txPubKey, header) { - // Debug: count CN scan attempts - if (this._cnScanCount === undefined) this._cnScanCount = 0; - this._cnScanCount++; const outputPubKey = this._extractOutputPubKey(output); if (!outputPubKey) { - if (this._cnScanCount <= 3) { - console.log(`[DEBUG] _scanCNOutput: no outputPubKey for output ${outputIndex}`); - } return null; } // Compute key derivation: D = 8 * viewSecretKey * txPubKey const derivation = generateKeyDerivation(txPubKey, this.keys.viewSecretKey); if (!derivation) { - if (this._cnScanCount <= 3) { - console.log(`[DEBUG] _scanCNOutput: derivation failed`); - } return null; } // Check view tag FIRST (if available) for fast rejection if (output.viewTag !== undefined) { const expectedViewTag = deriveViewTag(derivation, outputIndex); - if (this._cnScanCount <= 3) { - console.log(`[DEBUG] _scanCNOutput: viewTag check - output.viewTag=${output.viewTag}, expected=${expectedViewTag}`); - } if (output.viewTag !== expectedViewTag) { return null; // Not our output - skip expensive operations } @@ -1407,9 +1301,6 @@ export class WalletSync { // This gives us the spend pubkey that was used to create this output const derivedSpendPubKey = deriveSubaddressPublicKey(outputPubKey, derivation, outputIndex); if (!derivedSpendPubKey) { - if (this._cnScanCount <= 3) { - console.log(`[DEBUG] _scanCNOutput: deriveSubaddressPublicKey failed`); - } return null; } @@ -1421,12 +1312,6 @@ export class WalletSync { subaddressIndex = this.subaddresses.get(derivedSpendPubKeyHex); } - // Debug: log first few lookups - if (this._cnScanCount <= 3) { - console.log(`[DEBUG] _scanCNOutput: derived spend key=${derivedSpendPubKeyHex.slice(0, 16)}...`); - console.log(`[DEBUG] _scanCNOutput: subaddress map size=${this.subaddresses?.size || 0}`); - console.log(`[DEBUG] _scanCNOutput: found in map=${!!subaddressIndex}`); - } if (!subaddressIndex) { return null; // Not our output @@ -1500,9 +1385,6 @@ export class WalletSync { const spentOutputs = []; const inputs = tx.prefix?.vin || tx.inputs || []; - // Debug: log first few checks - if (this._spentCheckCount === undefined) this._spentCheckCount = 0; - this._spentCheckCount++; for (const input of inputs) { // Parsed transactions use input.keyImage directly @@ -1517,13 +1399,8 @@ export class WalletSync { // Check if this key image belongs to one of our outputs const output = await this.storage.getOutput(keyImage); - // Debug: log when we find a potential match or at specific heights - if (output || (header.height >= 270510 && header.height <= 270530)) { - console.log(`[DEBUG] _checkSpentOutputs height=${header.height} keyImage=${keyImage.slice(0,16)}... found=${!!output}`); - } if (output && !output.isSpent) { - console.log(`[SPENT] Output spent at height ${header.height}: keyImage=${keyImage.slice(0,16)}... amount=${output.amount}`); await this.storage.markOutputSpent(keyImage, txHash, header.height); spentOutputs.push(output); }