diff --git a/.github/actions/monerod-regtest/action.yml b/.github/actions/monerod-regtest/action.yml deleted file mode 100644 index 73551b29..00000000 --- a/.github/actions/monerod-regtest/action.yml +++ /dev/null @@ -1,62 +0,0 @@ -# MIT License -# -# Copyright (c) 2022-2023 Luke Parker -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# Initially taken from Serai Dex: https://github.com/serai-dex/serai/blob/b823413c9b7ae6747b9af99e18379cfc49f4271a/.github/actions/monero/action.yml. - - - -name: monero-regtest -description: Spawns a regtest Monero daemon - -inputs: - version: - description: "Version to download and run" - required: false - default: v0.18.2.0 - -runs: - using: "composite" - steps: - - name: Monero Daemon Cache - id: cache-monerod - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 - with: - path: monerod - key: monerod-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }} - - - name: Download the Monero Daemon - if: steps.cache-monerod.outputs.cache-hit != 'true' - # Calculates OS/ARCH to demonstrate it, yet then locks to linux-x64 due - # to the contained folder not following the same naming scheme and - # requiring further expansion not worth doing right now - shell: bash - run: | - RUNNER_OS=${{ runner.os }} - RUNNER_ARCH=${{ runner.arch }} - - RUNNER_OS=${RUNNER_OS,,} - RUNNER_ARCH=${RUNNER_ARCH,,} - - RUNNER_OS=linux - RUNNER_ARCH=x64 - - FILE=monero-$RUNNER_OS-$RUNNER_ARCH-${{ inputs.version }}.tar.bz2 - wget https://downloads.getmonero.org/cli/$FILE - tar -xvf $FILE - - mv monero-x86_64-linux-gnu-${{ inputs.version }}/monerod monerod - - - name: Monero Regtest Daemon - shell: bash - run: ./monerod --regtest --fixed-difficulty=1 --detach --out-peers 0 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa214a9d..008562da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_dispatch: env: CARGO_TERM_COLOR: always @@ -14,76 +15,85 @@ env: RUST_MIN_STACK: 8000000 jobs: + # Run format separately. fmt: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Format + run: cargo fmt --all --check - - name: Fmt - run: cargo fmt --all --check + # All other CI. + ci: + runs-on: ${{ matrix.os }} - build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + include: + - os: windows-latest + shell: msys2 {0} + - os: macos-latest + shell: bash + - os: ubuntu-latest + shell: bash + + defaults: + run: + shell: ${{ matrix.shell }} steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive - - uses: actions/cache@v3 - id: cache - with: - path: target - key: ${{ runner.os }}-cache + - name: Cache + uses: actions/cache@v3 + with: + path: | + target + ~/.cargo + ~/.rustup + key: ${{ matrix.os }} - - name: Install dependencies - run: sudo apt install -y libboost-dev + # Packages other than `Boost` used by `Monero` are listed here. + # https://github.com/monero-project/monero/blob/c444a7e002036e834bfb4c68f04a121ce1af5825/.github/workflows/build.yml#L71 - - name: Build - run: cargo build --all-features --all-targets --workspace + - name: Install dependencies (Linux) + if: matrix.os == 'ubuntu-latest' + run: sudo apt install -y libboost-dev - - uses: actions/cache/save@v3 - id: cache-save-short-term - with: - path: target - key: ${{ runner.os }}-cache-${{ github.sha }} + - name: Install dependencies (macOS) + if: matrix.os == 'macos-latest' + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost - clippy: - runs-on: ubuntu-latest - needs: build + - name: Install dependencies (Windows) + if: matrix.os == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + path-type: inherit + update: true + install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost msys2-runtime-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja - steps: - - uses: actions/checkout@v3 + - name: Switch target (Windows) + if: matrix.os == 'windows-latest' + run: rustup toolchain install stable-x86_64-pc-windows-gnu -c clippy && rustup set default-host x86_64-pc-windows-gnu && rustup default stable-x86_64-pc-windows-gnu - - uses: actions/cache/restore@v3 - id: cache - with: - path: target - key: ${{ runner.os }}-cache-${{ github.sha }} + - name: Clippy (fail on warnings) + run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - name: Install dependencies - run: sudo apt install -y libboost-dev + - name: Test + run: cargo test --all-features --workspace --all-targets - - name: Clippy - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - tests: - runs-on: ubuntu-latest - needs: build - - steps: - - uses: actions/checkout@v3 - - - uses: actions/cache/restore@v3 - id: cache - with: - path: target - key: ${{ runner.os }}-cache-${{ github.sha }} - - - name: Spawn monerod - uses: ./.github/actions/monerod-regtest - - - name: Install dependencies - run: sudo apt install -y libboost-dev - - - name: Test - run: cargo test --all-features --workspace --all-targets && cargo test --all-features --workspace --doc + # TODO: upload binaries with `actions/upload-artifact@v3` + - name: Build + run: cargo build --all-features --all-targets --workspace \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5b939ef9..90691967 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target/ .vscode -monerod diff --git a/Cargo.lock b/Cargo.lock index 49fd30c3..88cff0ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.7" @@ -60,9 +71,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -256,12 +267,34 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -279,21 +312,31 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.48.5", + "windows-targets 0.52.0", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", ] [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -301,9 +344,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", @@ -313,9 +356,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", @@ -325,9 +368,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -344,6 +387,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "core-foundation" version = "0.9.4" @@ -369,6 +418,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam" version = "0.8.4" @@ -489,16 +547,23 @@ version = "0.1.0" dependencies = [ "async-trait", "borsh", + "bytes", + "bzip2", "futures", "monero-p2p", "monero-wire", + "rand", + "reqwest", + "tar", + "tokio", + "zip", ] [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ "cfg-if", "cpufeatures", @@ -527,7 +592,7 @@ dependencies = [ [[package]] name = "dalek-ff-group" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "crypto-bigint", "curve25519-dalek", @@ -540,6 +605,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.10.7" @@ -588,7 +662,7 @@ dependencies = [ [[package]] name = "dleq" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "digest", "ff", @@ -606,6 +680,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + [[package]] name = "epee-encoding" version = "0.5.0" @@ -675,9 +758,21 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" + +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.52.0", +] [[package]] name = "fixed-bytes" @@ -687,10 +782,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flexible-transcript" version = "0.3.2" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "blake2", "digest", @@ -706,6 +811,30 @@ 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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "funty" version = "2.0.0" @@ -827,6 +956,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -850,9 +998,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -919,6 +1067,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "httparse", @@ -948,10 +1097,23 @@ dependencies = [ ] [[package]] -name = "iana-time-zone" -version = "0.1.59" +name = "hyper-tls" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -970,6 +1132,16 @@ dependencies = [ "cc", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -982,14 +1154,29 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "itoa" version = "1.0.10" @@ -997,10 +1184,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] -name = "js-sys" -version = "0.3.67" +name = "jobserver" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1031,9 +1227,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libm" @@ -1058,6 +1254,16 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.20" @@ -1093,10 +1299,16 @@ dependencies = [ ] [[package]] -name = "miniz_oxide" -version = "0.7.1" +name = "mime" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -1156,7 +1368,7 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -1198,7 +1410,7 @@ dependencies = [ [[package]] name = "monero-serai" version = "0.1.4-alpha" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "async-lock", "async-trait", @@ -1213,7 +1425,7 @@ dependencies = [ "hex-literal", "monero-generators", "multiexp", - "pbkdf2", + "pbkdf2 0.12.2", "rand", "rand_chacha", "rand_core", @@ -1244,7 +1456,7 @@ dependencies = [ [[package]] name = "multiexp" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "ff", "group", @@ -1254,6 +1466,24 @@ dependencies = [ "zeroize", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1265,10 +1495,16 @@ dependencies = [ ] [[package]] -name = "num-traits" -version = "0.2.17" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -1299,12 +1535,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +dependencies = [ + "bitflags 2.4.2", + "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 2.0.48", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -1323,6 +1597,40 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "password-hash" version = "0.5.0" @@ -1340,6 +1648,18 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest", + "hmac", + "password-hash 0.4.2", + "sha2", +] + [[package]] name = "pbkdf2" version = "0.12.2" @@ -1348,24 +1668,30 @@ checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest", "hmac", - "password-hash", + "password-hash 0.5.0", "sha2", ] [[package]] -name = "pin-project" -version = "1.1.3" +name = "percent-encoding" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -1384,12 +1710,24 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" + [[package]] name = "platforms" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1541,7 +1879,7 @@ dependencies = [ [[package]] name = "randomx-rs" version = "1.3.0" -source = "git+https://github.com/Cuprate/randomx-rs.git?rev=6496a61#6496a61208852a020575dafc160080cf50bda67f" +source = "git+https://github.com/Cuprate/randomx-rs.git?rev=0028464#002846452ed79b0b9568235a1a4100dcf2a5f9ba" dependencies = [ "bitflags 1.3.2", "libc", @@ -1614,6 +1952,46 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "reqwest" +version = "0.11.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "ring" version = "0.17.7" @@ -1645,9 +2023,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -1731,6 +2109,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "sct" version = "0.7.1" @@ -1784,18 +2168,18 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -1804,15 +2188,38 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", "serde", ] +[[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 = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1843,10 +2250,19 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "simple-request" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "hyper", "hyper-rustls", @@ -1887,7 +2303,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "std-shims" version = "0.1.1" -source = "git+https://github.com/Cuprate/serai.git?rev=a59966b#a59966b736ca988c13bd6eb33a9f2204bdf747fb" +source = "git+https://github.com/Cuprate/serai.git?rev=f3429ec1ef386da1458f4ed244402f38e3e12930#f3429ec1ef386da1458f4ed244402f38e3e12930" dependencies = [ "hashbrown 0.14.3", "spin", @@ -1895,9 +2311,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "subtle" @@ -1939,6 +2355,33 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -1946,14 +2389,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "tempfile" -version = "3.9.0" +name = "tar" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -1988,6 +2441,25 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -1998,16 +2470,34 @@ dependencies = [ ] [[package]] -name = "tokio" -version = "1.35.1" +name = "tinyvec" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", + "bytes", "libc", "mio", "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.48.0", @@ -2024,6 +2514,16 @@ dependencies = [ "syn 2.0.48", ] +[[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.24.1" @@ -2068,11 +2568,11 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.2", "toml_datetime", "winnow", ] @@ -2184,18 +2684,44 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -2208,6 +2734,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -2240,9 +2772,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2250,9 +2782,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -2264,10 +2796,22 @@ dependencies = [ ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.90" +name = "wasm-bindgen-futures" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2275,9 +2819,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -2288,9 +2832,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + +[[package]] +name = "web-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +dependencies = [ + "js-sys", + "wasm-bindgen", +] [[package]] name = "winapi" @@ -2467,13 +3021,23 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wyz" version = "0.5.1" @@ -2483,6 +3047,17 @@ dependencies = [ "tap", ] +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] + [[package]] name = "zerocopy" version = "0.7.32" @@ -2522,3 +3097,52 @@ dependencies = [ "quote", "syn 2.0.48", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2 0.11.0", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.9+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 4b333c86..834e5ba8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,16 +43,15 @@ chrono = { version = "0.4.31", default-features = false } crypto-bigint = { version = "0.5.5", default-features = false } crossbeam = { version = "0.8.4", default-features = false } curve25519-dalek = { version = "4.1.1", default-features = false } -dalek-ff-group = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false } +dalek-ff-group = { git = "https://github.com/Cuprate/serai.git", rev = "f3429ec1ef386da1458f4ed244402f38e3e12930", default-features = false } dirs = { version = "5.0.1", default-features = false } futures = { version = "0.3.29", default-features = false } hex = { version = "0.4.3", default-features = false } hex-literal = { version = "0.4", default-features = false } -monero-epee-bin-serde = { git = "https://github.com/monero-rs/monero-epee-bin-serde.git", rev = "fae7a23", default-features = false } -monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false } -multiexp = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false } +monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "f3429ec1ef386da1458f4ed244402f38e3e12930", default-features = false } +multiexp = { git = "https://github.com/Cuprate/serai.git", rev = "f3429ec1ef386da1458f4ed244402f38e3e12930", default-features = false } pin-project = { version = "1.1.3", default-features = false } -randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "6496a61", default-features = false } +randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "0028464", default-features = false } rand = { version = "0.8.5", default-features = false } rayon = { version = "1.8.0", default-features = false } serde_bytes = { version = "0.11.12", default-features = false } @@ -68,8 +67,9 @@ tracing-subscriber = { version = "0.3.17", default-features = false } tracing = { version = "0.1.40", default-features = false } ## workspace.dev-dependencies -proptest = { version = "1" } -proptest-derive = { version = "0.4.0" } +reqwest = { version = "0.11.24" } +proptest = { version = "1" } +proptest-derive = { version = "0.4.0" } ## TODO: diff --git a/cryptonight/Cargo.toml b/cryptonight/Cargo.toml index 72786a53..7cd1cd41 100644 --- a/cryptonight/Cargo.toml +++ b/cryptonight/Cargo.toml @@ -14,4 +14,4 @@ thiserror = "1" cc = "1" [dev-dependencies] -hex = "0.4" \ No newline at end of file +hex = "0.4" diff --git a/cryptonight/build.rs b/cryptonight/build.rs index f6f211dd..0950d94c 100644 --- a/cryptonight/build.rs +++ b/cryptonight/build.rs @@ -19,10 +19,10 @@ fn main() { .file("c/keccak.c") .file("c/oaes_lib.c") .file("c/skein.c") + .file("c/memwipe.c") .file("c/slow-hash.c") .file("c/CryptonightR_JIT.c") - .flag("-O3") - .flag("-fexceptions") + .flag_if_supported("-fexceptions") // c/oaes_lib.c: In function ‘oaes_get_seed’: // c/oaes_lib.c:515:9: warning: ‘ftime’ is deprecated: Use gettimeofday or clock_gettime instead [-Wdeprecated-declarations] // 515 | ftime (&timer); @@ -31,13 +31,18 @@ fn main() { // /usr/include/sys/timeb.h:29:12: note: declared here // 29 | extern int ftime (struct timeb *__timebuf) // | ^~~~~ - .flag("-Wno-deprecated-declarations"); + // This flag doesn't work on MSVC and breaks CI. + .flag_if_supported("-Wno-deprecated-declarations"); + + // Optimization flags are automatically added. + // https://docs.rs/cc/latest/cc/struct.Build.html#method.opt_level let target = env::var("TARGET").unwrap(); if target.contains("x86_64") { + // FIXME: what are the equivalent flags for MSVC? cfg.file("c/CryptonightR_template.S") - .flag("-maes") - .flag("-msse2"); + .flag_if_supported("-maes") + .flag_if_supported("-msse2"); } cfg.compile("cryptonight") diff --git a/cryptonight/c/blake256.c b/cryptonight/c/blake256.c index 83161fbb..e39c3485 100644 --- a/cryptonight/c/blake256.c +++ b/cryptonight/c/blake256.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include "memwipe.h" #include "blake256.h" #define U8TO32(p) \ diff --git a/cryptonight/c/memwipe.c b/cryptonight/c/memwipe.c new file mode 100644 index 00000000..27dfb28a --- /dev/null +++ b/cryptonight/c/memwipe.c @@ -0,0 +1,115 @@ +// Copyright (c) 2017-2023, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Parts of this file Copyright (c) 2009-2015 The Bitcoin Core developers + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include +#ifdef HAVE_EXPLICIT_BZERO +#include +#endif +#include "memwipe.h" + +#if defined(_MSC_VER) +#define SCARECROW \ + __asm; +#else +#define SCARECROW \ + __asm__ __volatile__("" : : "r"(ptr) : "memory"); +#endif + +#ifdef HAVE_MEMSET_S + +void *memwipe(void *ptr, size_t n) +{ + if (n > 0 && memset_s(ptr, n, 0, n)) + { +#ifdef NDEBUG + fprintf(stderr, "Error: memset_s failed\n"); + _exit(1); +#else + abort(); +#endif + } + SCARECROW // might as well... + return ptr; +} + +#elif defined HAVE_EXPLICIT_BZERO + +void *memwipe(void *ptr, size_t n) +{ + if (n > 0) + explicit_bzero(ptr, n); + SCARECROW + return ptr; +} + +#else + +/* The memory_cleanse implementation is taken from Bitcoin */ + +/* Compilers have a bad habit of removing "superfluous" memset calls that + * are trying to zero memory. For example, when memset()ing a buffer and + * then free()ing it, the compiler might decide that the memset is + * unobservable and thus can be removed. + * + * Previously we used OpenSSL which tried to stop this by a) implementing + * memset in assembly on x86 and b) putting the function in its own file + * for other platforms. + * + * This change removes those tricks in favour of using asm directives to + * scare the compiler away. As best as our compiler folks can tell, this is + * sufficient and will continue to be so. + * + * Adam Langley + * Commit: ad1907fe73334d6c696c8539646c21b11178f20f + * BoringSSL (LICENSE: ISC) + */ +static void memory_cleanse(void *ptr, size_t len) +{ + memset(ptr, 0, len); + + /* As best as we can tell, this is sufficient to break any optimisations that + might try to eliminate "superfluous" memsets. If there's an easy way to + detect memset_s, it would be better to use that. */ + SCARECROW +} + +void *memwipe(void *ptr, size_t n) +{ + if (n > 0) + memory_cleanse(ptr, n); + SCARECROW + return ptr; +} + +#endif diff --git a/helper/src/thread.rs b/helper/src/thread.rs index bf3b565c..25673307 100644 --- a/helper/src/thread.rs +++ b/helper/src/thread.rs @@ -80,7 +80,9 @@ pub fn low_priority_thread() { // SAFETY: calling C. // We are _lowering_ our priority, not increasing, so this function should never fail. - unsafe { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE) }; + unsafe { + let _ = SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); + } } #[cfg(target_family = "unix")] @@ -91,7 +93,9 @@ pub fn low_priority_thread() { // SAFETY: calling C. // We are _lowering_ our priority, not increasing, so this function should never fail. - unsafe { libc::nice(NICE_MAX) }; + unsafe { + let _ = libc::nice(NICE_MAX); + } } } diff --git a/net/monero-wire/src/p2p/admin.rs b/net/monero-wire/src/p2p/admin.rs index 95d2f1b0..d31ffdfa 100644 --- a/net/monero-wire/src/p2p/admin.rs +++ b/net/monero-wire/src/p2p/admin.rs @@ -84,7 +84,7 @@ epee_object!( ); /// The status field of an okay ping response -pub const PING_OK_RESPONSE_STATUS_TEXT: Bytes = Bytes::from_static("OK".as_bytes()); +pub static PING_OK_RESPONSE_STATUS_TEXT: Bytes = Bytes::from_static("OK".as_bytes()); /// A Ping Response #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/p2p/monero-p2p/tests/handshake.rs b/p2p/monero-p2p/tests/handshake.rs index 4f0f2287..45e97f27 100644 --- a/p2p/monero-p2p/tests/handshake.rs +++ b/p2p/monero-p2p/tests/handshake.rs @@ -1,5 +1,4 @@ use std::sync::Arc; -use std::{net::SocketAddr, str::FromStr}; use futures::{channel::mpsc, StreamExt}; use tokio::sync::{broadcast, Semaphore}; @@ -14,7 +13,10 @@ use monero_p2p::{ ConnectionDirection, }; -use cuprate_test_utils::test_netzone::{TestNetZone, TestNetZoneAddr}; +use cuprate_test_utils::{ + monerod::monerod, + test_netzone::{TestNetZone, TestNetZoneAddr}, +}; use monero_p2p::client::InternalPeerID; mod utils; @@ -104,12 +106,16 @@ async fn handshake_cuprate_to_cuprate() { } #[tokio::test] -async fn handshake() { +async fn handshake_cuprate_to_monerod() { let (broadcast_tx, _) = broadcast::channel(1); // this isn't actually used in this test. let semaphore = Arc::new(Semaphore::new(10)); let permit = semaphore.acquire_owned().await.unwrap(); - let addr = "127.0.0.1:18080"; + let (monerod, _) = monerod( + vec!["--fixed-difficulty=1".into(), "--out-peers=0".into()], + false, + ) + .await; let our_basic_node_data = BasicNodeData { my_port: 0, @@ -135,7 +141,7 @@ async fn handshake() { .await .unwrap() .call(ConnectRequest { - addr: SocketAddr::from_str(addr).unwrap(), + addr: monerod, permit, }) .await diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index 8c0320ca..01a3fba3 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -9,5 +9,17 @@ monero-p2p = {path = "../p2p/monero-p2p", features = ["borsh"] } futures = { workspace = true, features = ["std"] } async-trait = { workspace = true } +tokio = { workspace = true, features = ["full"] } +reqwest = { workspace = true } +bytes = { workspace = true, features = ["std"] } -borsh = { workspace = true, features = ["derive"]} \ No newline at end of file +borsh = { workspace = true, features = ["derive"]} + +rand = { workspace = true, features = ["std", "std_rng"] } + +[target.'cfg(unix)'.dependencies] +tar = "0.4.40" +bzip2 = "0.4.4" + +[target.'cfg(windows)'.dependencies] +zip = "0.6" \ No newline at end of file diff --git a/test-utils/README.MD b/test-utils/README.MD new file mode 100644 index 00000000..2d643cb3 --- /dev/null +++ b/test-utils/README.MD @@ -0,0 +1,7 @@ +# Test Utils + +This crate contains code that can be shared across multiple Cuprate crates tests, this crate should not be included in any +Cuprate crate, only in tests. + +It currently contains code to spawn monerod instances and a testing network zone. + diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index e3870a64..d8fb8674 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -1 +1,2 @@ +pub mod monerod; pub mod test_netzone; diff --git a/test-utils/src/monerod.rs b/test-utils/src/monerod.rs new file mode 100644 index 00000000..6b103aca --- /dev/null +++ b/test-utils/src/monerod.rs @@ -0,0 +1,172 @@ +//! Monerod Module +//! +//! This module contains a function [`monerod`] to start `monerod` - the core Monero node. Cuprate can then use +//! this to test compatibility with monerod. +//! +use std::{ + collections::HashMap, + net::{IpAddr, Ipv4Addr, SocketAddr}, + path::PathBuf, + process::Stdio, + sync::OnceLock, + time::Duration, +}; + +use rand::Rng; +use tokio::{ + process::{Child, Command}, + sync::{mpsc, oneshot}, +}; + +mod download; + +const LOCAL_HOST: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); +const MONEROD_VERSION: &str = "v0.18.3.1"; + +#[allow(clippy::type_complexity)] +static MONEROD_HANDLER_CHANNEL: OnceLock< + mpsc::Sender<(MoneroDRequest, oneshot::Sender<(SocketAddr, SocketAddr)>)>, +> = OnceLock::new(); + +/// Spawns monerod and returns the p2p address and rpc address. +/// +/// When spawning monerod, this module will try to use an already spawned instance to reduce the amount +/// of instances that need to be spawned. +/// +/// This function will set `regtest` and the P2P/ RPC ports so these can't be included in the flags. +pub async fn monerod(flags: Vec, mutable: bool) -> (SocketAddr, SocketAddr) { + // TODO: sort flags so the same flags in a different order will give the same monerod? + + // We only actually need these channels on first run so this might be wasteful + let (tx, rx) = mpsc::channel(3); + let mut should_spwan = false; + + let monero_handler_tx = MONEROD_HANDLER_CHANNEL.get_or_init(|| { + should_spwan = true; + tx + }); + + if should_spwan { + // If this call was the first call to start a monerod instance then start the handler. + let manager = MoneroDManager::new().await; + tokio::task::spawn(manager.run(rx)); + } + + let (tx, rx) = oneshot::channel(); + + monero_handler_tx + .send((MoneroDRequest { mutable, flags }, tx)) + .await + .unwrap(); + + // Give monerod some time to start + tokio::time::sleep(Duration::from_secs(5)).await; + rx.await.unwrap() +} + +/// A request sent to get an address to a monerod instance. +struct MoneroDRequest { + /// Whether we plan to change the state of the spawned monerod's blockchain. + mutable: bool, + /// Start flags to start monerod with. + flags: Vec, +} + +/// A struct representing a spawned monerod. +struct SpwanedMoneroD { + /// A marker for if the test that spawned this monerod is going to mutate it. + mutable: bool, + /// A handle to the monerod process, monerod will be stopped when this is dropped. + #[allow(dead_code)] + process: Child, + /// The RPC port of the monerod instance. + rpc_port: u16, + /// The P2P port of the monerod instance. + p2p_port: u16, +} + +/// A manger of spawned monerods. +struct MoneroDManager { + /// A map of start flags to monerods. + monerods: HashMap, Vec>, + /// The path to the monerod binary. + path_to_monerod: PathBuf, +} + +impl MoneroDManager { + pub async fn new() -> Self { + let path_to_monerod = download::check_download_monerod().await.unwrap(); + + Self { + monerods: Default::default(), + path_to_monerod, + } + } + + pub async fn run( + mut self, + mut rx: mpsc::Receiver<(MoneroDRequest, oneshot::Sender<(SocketAddr, SocketAddr)>)>, + ) { + while let Some((req, tx)) = rx.recv().await { + let (p2p_port, rpc_port) = self.get_monerod_with_flags(req.flags, req.mutable); + let _ = tx.send(( + SocketAddr::new(LOCAL_HOST, p2p_port), + SocketAddr::new(LOCAL_HOST, rpc_port), + )); + } + } + + /// Trys to get a current monerod instance or spans one if there is not an appropriate one to use. + /// Returns the p2p port and then the RPC port of the spawned monerd. + fn get_monerod_with_flags(&mut self, flags: Vec, mutable: bool) -> (u16, u16) { + // If we need to mutate monerod's blockchain then we can't reuse one. + if !mutable { + if let Some(monerods) = &self.monerods.get(&flags) { + for monerod in monerods.iter() { + if !monerod.mutable { + return (monerod.p2p_port, monerod.rpc_port); + } + } + } + } + + let mut rng = rand::thread_rng(); + // Use random ports and *hope* we don't get a collision (TODO: just keep a counter and increment?) + let rpc_port: u16 = rng.gen_range(1500..u16::MAX); + let p2p_port: u16 = rng.gen_range(1500..u16::MAX); + + // TODO: set a different DB location per node + let monerod = Command::new(&self.path_to_monerod) + .stdout(Stdio::null()) + .stdin(Stdio::piped()) + .args(&flags) + .arg("--regtest") + .arg(format!("--p2p-bind-port={}", p2p_port)) + .arg(format!("--rpc-bind-port={}", rpc_port)) + .kill_on_drop(true) + .spawn() + .unwrap(); + + let spawned_monerd = SpwanedMoneroD { + mutable, + process: monerod, + rpc_port, + p2p_port, + }; + + self.monerods + .entry(flags.clone()) + .or_default() + .push(spawned_monerd); + let Some(monerods) = self.monerods.get(&flags) else { + unreachable!() + }; + + for monerod in monerods { + if !monerod.mutable { + return (monerod.p2p_port, monerod.rpc_port); + } + } + unreachable!() + } +} diff --git a/test-utils/src/monerod/download.rs b/test-utils/src/monerod/download.rs new file mode 100644 index 00000000..f9a0b032 --- /dev/null +++ b/test-utils/src/monerod/download.rs @@ -0,0 +1,97 @@ +//! Downloading Monerod Module +//! +//! This module handles finding the right monerod file to download, downloading it and extracting it. +//! +use std::{ + env::{ + consts::{ARCH, OS}, + current_dir, + }, + fs::read_dir, + path::{Path, PathBuf}, +}; + +#[cfg(unix)] +use bytes::Buf; +use reqwest::{get, Error as ReqError}; + +use super::MONEROD_VERSION; + +/// Returns the file name to download and the expected extracted folder name. +fn file_name(version: &str) -> (String, String) { + let download_file = match (OS, ARCH) { + ("windows", "x64") | ("windows", "x86_64") => format!("monero-win-x64-{}.zip", version), + ("windows", "x86") => format!("monero-win-x86-{}.zip", version), + ("linux", "x64") | ("linux", "x86_64") => format!("monero-linux-x64-{}.tar.bz2", version), + ("linux", "x86") => format!("monero-linux-x86-{}.tar.bz2", version), + ("macos", "x64") | ("macos", "x86_64") => format!("monero-mac-x64-{}.tar.bz2", version), + _ => panic!("Can't get monerod for {OS}, {ARCH}."), + }; + + let extracted_dir = match (OS, ARCH) { + ("windows", "x64") | ("windows", "x86_64") => { + format!("monero-x86_64-w64-mingw32-{}", version) + } + ("windows", "x86") => format!("monero-i686-w64-mingw32-{}", version), + ("linux", "x64") | ("linux", "x86_64") => format!("monero-x86_64-linux-gnu-{}", version), + ("linux", "x86") => format!("monero-i686-linux-gnu-{}", version), + ("macos", "x64") | ("macos", "x86_64") => { + format!("monero-x86_64-apple-darwin11-{}", version) + } + _ => panic!("Can't get monerod for {OS}, {ARCH}."), + }; + + (download_file, extracted_dir) +} + +/// Downloads the monerod file provided, extracts it and puts the extracted folder into `path_to_store`. +async fn download_monerod(file_name: &str, path_to_store: &Path) -> Result<(), ReqError> { + let res = get(format!("https://downloads.getmonero.org/cli/{}", file_name)).await?; + let monerod_archive = res.bytes().await.unwrap(); + + #[cfg(unix)] + { + let bzip_decomp = bzip2::read::BzDecoder::new(monerod_archive.reader()); + let mut tar_archive = tar::Archive::new(bzip_decomp); + tar_archive.unpack(path_to_store).unwrap(); + } + #[cfg(windows)] + { + let mut zip = zip::ZipArchive::new(std::io::Cursor::new(monerod_archive.as_ref())).unwrap(); + zip.extract(path_to_store).unwrap(); + } + + Ok(()) +} + +/// Finds the `target` directory, this will work up from the current directory until +/// it finds a `target` directory. +fn find_target() -> PathBuf { + let mut current_dir = current_dir().unwrap(); + loop { + let potential_target = current_dir.join("target"); + if read_dir(current_dir.join("target")).is_ok() { + return potential_target; + } else if !current_dir.pop() { + panic!("Could not find ./target"); + } + } +} + +/// Checks if we have monerod or downloads it if we don't and then returns the path to it. +pub async fn check_download_monerod() -> Result { + let path_to_store = find_target(); + + let (file_name, dir_name) = file_name(MONEROD_VERSION); + + let path_to_monerod = path_to_store.join(dir_name); + + // Check if we already have monerod + if read_dir(&path_to_monerod).is_ok() { + return Ok(path_to_monerod.join("monerod")); + } + + download_monerod(&file_name, &path_to_store).await?; + + Ok(path_to_monerod.join("monerod")) +} diff --git a/test-utils/src/test_netzone.rs b/test-utils/src/test_netzone.rs index d5fe39b6..d5e2ad54 100644 --- a/test-utils/src/test_netzone.rs +++ b/test-utils/src/test_netzone.rs @@ -1,3 +1,8 @@ +//! Test NetZone +//! +//! This module contains a test network zone, this network zone use channels as the network layer to simulate p2p +//! communication. +//! use std::{ fmt::Formatter, io::Error, @@ -16,6 +21,7 @@ use monero_wire::{ use monero_p2p::{NetZoneAddress, NetworkZone}; +/// An address on the test network #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, BorshSerialize, BorshDeserialize)] pub struct TestNetZoneAddr(pub u32); @@ -56,6 +62,7 @@ impl TryFrom for TestNetZoneAddr { } } +/// A wrapper around [`futures::channel::mpsc::Sender`] that changes the error to [`BucketError`]. pub struct Sender { inner: InnerSender, }