diff --git a/.github/workflows/linux-ci-rust.yml b/.github/workflows/linux-ci-rust.yml index 02e1b7955b3..9de4326f918 100644 --- a/.github/workflows/linux-ci-rust.yml +++ b/.github/workflows/linux-ci-rust.yml @@ -34,7 +34,6 @@ jobs: - name: Cache Rust uses: Swatinem/rust-cache@v2 with: - key: "build-and-test" workspaces: | rust @@ -54,19 +53,9 @@ jobs: - name: Run tests run: | - cargo llvm-cov nextest --profile ci --no-fail-fast --lcov --output-path coverage.info + cargo llvm-cov test --no-fail-fast --lcov --output-path coverage.info working-directory: rust - - name: Rust Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() - continue-on-error: true - with: - name: Rust Tests - path: | - rust/target/nextest/ci/junit.xml - reporter: java-junit - - name: Gather and check Rust code coverage run: | tools/check-coverage rust/coverage.stats rust/coverage.info @@ -87,7 +76,6 @@ jobs: - name: Cache Rust uses: Swatinem/rust-cache@v2 with: - key: "test-wasm" workspaces: | rust @@ -100,3 +88,74 @@ jobs: - name: Run tests in WASM run: tools/rust-test wasm + + check-binary-sizes: + permissions: + contents: read + pull-requests: write + runs-on: macos-latest-xlarge + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + - name: Install system dependencies + run: | + tools/install-sys-dependencies-mac + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + rust + + - name: Install Rust dependencies + run: tools/install-rust-dependencies + + - name: Install emsdk + run: tools/install-wasm-dependencies + + - name: Compile release binaries + run: | + mkdir -p build/local/lib + source emsdk/emsdk_env.sh + tools/rust-bindgen + + - name: Generate release report + run: | + ./tools/release-size measure-rust > release-report.json + + - name: Upload release report + uses: actions/upload-artifact@v2 + with: + name: release_report + path: release-report.json + + # Download previous release report, compare the release binary sizes, and post/update a comment at the Pull Request. + - name: Download previous release report + if: github.event_name == 'pull_request' + uses: dawidd6/action-download-artifact@v3 + with: + commit: ${{github.event.pull_request.base.sha}} + path: previous + if_no_artifact_found: warn + # Same artifact name as at the "Upload release report" step. + name: release_report + # Ignore status or conclusion in the search. + workflow_conclusion: "" + + - name: Craft Comment Body + if: github.event_name == 'pull_request' + run: | + # Please note `previous/release-report.json` may not exist if the previous report was not found. + ./tools/release-size compare --before previous/release-report.json --current release-report.json > report-diff.md + + - name: Create or Update Comment + uses: edumserrano/find-create-or-update-comment@v2 + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: "Binary size comparison" + comment-author: 'github-actions[bot]' + edit-mode: replace + body-path: 'report-diff.md' diff --git a/rust/.config/nextest.toml b/rust/.config/nextest.toml deleted file mode 100644 index 76fd74b5d7f..00000000000 --- a/rust/.config/nextest.toml +++ /dev/null @@ -1,2 +0,0 @@ -[profile.ci.junit] -path = "junit.xml" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index fe167147af0..22843571589 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -26,6 +26,12 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "arbitrary" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" + [[package]] name = "arbitrary" version = "1.3.0" @@ -211,22 +217,10 @@ version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" dependencies = [ - "funty 1.1.0", - "radium 0.6.2", + "funty", + "radium", "tap", - "wyz 0.2.0", -] - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty 2.0.0", - "radium 0.7.0", - "tap", - "wyz 0.5.1", + "wyz", ] [[package]] @@ -242,13 +236,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.9.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", + "digest 0.10.6", ] [[package]] @@ -397,9 +389,9 @@ checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -417,7 +409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -433,26 +425,31 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "curve25519-dalek" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ - "generic-array", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.6", + "fiat-crypto", + "platforms", + "rustc_version", "subtle", + "zeroize", ] [[package]] -name = "curve25519-dalek" -version = "3.2.0" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.37", ] [[package]] @@ -547,7 +544,7 @@ dependencies = [ "group", "hkdf", "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", @@ -584,29 +581,23 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] -name = "fixed-hash" -version = "0.7.0" +name = "fiat-crypto" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] name = "fixed-hash" -version = "0.8.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ - "arbitrary", + "arbitrary 0.4.7", "byteorder", "rand", "rustc-hex", @@ -619,12 +610,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.6" @@ -636,17 +621,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.9" @@ -656,7 +630,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -676,7 +650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -752,16 +726,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" dependencies = [ - "parity-scale-codec 2.3.1", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec 3.5.0", + "parity-scale-codec", ] [[package]] @@ -828,7 +793,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2 0.10.6", + "sha2", "signature", ] @@ -849,9 +814,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" @@ -885,7 +850,7 @@ dependencies = [ "hex", "num", "once_cell", - "primitive-types 0.10.1", + "primitive-types", "rand", "ref-cast", "serde", @@ -985,12 +950,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "p256" version = "0.13.2" @@ -1000,7 +959,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.6", + "sha2", ] [[package]] @@ -1010,24 +969,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" dependencies = [ "arrayvec", - "bitvec 0.20.4", + "bitvec", "byte-slice-cast", "impl-trait-for-tuples", - "parity-scale-codec-derive 2.3.1", - "serde", -] - -[[package]] -name = "parity-scale-codec" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" -dependencies = [ - "arrayvec", - "bitvec 1.0.1", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive 3.1.4", + "parity-scale-codec-derive", "serde", ] @@ -1043,18 +988,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "parity-scale-codec-derive" -version = "3.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.107", -] - [[package]] name = "paste" version = "1.0.11" @@ -1083,6 +1016,12 @@ dependencies = [ "spki", ] +[[package]] +name = "platforms" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1104,23 +1043,12 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" dependencies = [ - "fixed-hash 0.7.0", - "impl-codec 0.5.1", + "fixed-hash", + "impl-codec", "impl-serde", "uint", ] -[[package]] -name = "primitive-types" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" -dependencies = [ - "fixed-hash 0.8.0", - "impl-codec 0.6.0", - "uint", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -1202,12 +1130,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -1216,7 +1138,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1226,16 +1148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1244,7 +1157,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom", ] [[package]] @@ -1457,19 +1370,6 @@ dependencies = [ "digest 0.10.6", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.6" @@ -1498,7 +1398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.6", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1530,7 +1430,7 @@ dependencies = [ "num-integer", "num-traits", "rfc6979", - "sha2 0.10.6", + "sha2", "starknet-crypto-codegen", "starknet-curve", "starknet-ff", @@ -1566,7 +1466,7 @@ dependencies = [ "ark-ff", "bigdecimal", "crypto-bigint", - "getrandom 0.2.9", + "getrandom", "hex", "serde", ] @@ -1891,7 +1791,7 @@ dependencies = [ name = "tw_encoding" version = "0.1.0" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "bcs", "bech32", "bs58", @@ -1956,7 +1856,7 @@ dependencies = [ name = "tw_hash" version = "0.1.0" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "blake-hash", "blake2b-ref", "digest 0.10.6", @@ -1966,7 +1866,7 @@ dependencies = [ "serde", "serde_json", "sha1", - "sha2 0.10.6", + "sha2", "sha3", "tw_encoding", "tw_memory", @@ -1992,11 +1892,11 @@ dependencies = [ name = "tw_keypair" version = "0.1.0" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "blake2", "curve25519-dalek", "der", - "digest 0.9.0", + "digest 0.10.6", "ecdsa", "k256", "lazy_static", @@ -2006,7 +1906,7 @@ dependencies = [ "ring", "serde", "serde_json", - "sha2 0.9.9", + "sha2", "starknet-crypto", "starknet-ff", "tw_encoding", @@ -2057,9 +1957,9 @@ dependencies = [ name = "tw_number" version = "0.1.0" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "lazy_static", - "primitive-types 0.12.1", + "primitive-types", "serde", "tw_encoding", "tw_hash", @@ -2070,7 +1970,7 @@ dependencies = [ name = "tw_proto" version = "0.1.0" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "pb-rs", "quick-protobuf", "tw_encoding", @@ -2143,7 +2043,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ - "arbitrary", + "arbitrary 1.3.0", "byteorder", "crunchy", "hex", @@ -2207,12 +2107,6 @@ dependencies = [ "tw_solana", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2338,15 +2232,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "zeroize" version = "1.6.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index a98ff23da18..bcd400d3e1f 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -29,6 +29,11 @@ members = [ "wallet_core_rs", ] +[profile.release] +strip = true +codegen-units = 1 +panic = "abort" + [profile.wasm-test] inherits = "release" # Fixes an incredibly slow compilation of `curve25519-dalek` package. diff --git a/rust/chains/tw_solana/src/modules/tx_signer.rs b/rust/chains/tw_solana/src/modules/tx_signer.rs index ee190af6063..f1bb7c2a0fd 100644 --- a/rust/chains/tw_solana/src/modules/tx_signer.rs +++ b/rust/chains/tw_solana/src/modules/tx_signer.rs @@ -24,7 +24,7 @@ impl TxSigner { let message_encoded = Self::preimage_versioned(&unsigned_msg)?; // Add external signatures first, so they can be overriden if corresponding private keys are specified. - key_signs.extend(external_signatures.clone().into_iter()); + key_signs.extend(external_signatures.clone()); // Sign the message with all given private keys. for private_key in keys { diff --git a/rust/tw_bitcoin/src/modules/legacy/build_and_sign.rs b/rust/tw_bitcoin/src/modules/legacy/build_and_sign.rs index 17dbaa03638..e488b1b76a7 100644 --- a/rust/tw_bitcoin/src/modules/legacy/build_and_sign.rs +++ b/rust/tw_bitcoin/src/modules/legacy/build_and_sign.rs @@ -44,7 +44,7 @@ pub fn taproot_build_and_sign_transaction( } else { legacy .private_key - .get(0) + .first() .ok_or_else(|| Error::from(Proto::Error::Error_legacy_no_private_key))? }; @@ -79,7 +79,7 @@ pub fn taproot_build_and_sign_transaction( version: 2, private_key: legacy .private_key - .get(0) + .first() .map(|pk| pk.to_vec().into()) .unwrap_or_default(), lock_time: Some(lock_time), diff --git a/rust/tw_bitcoin/src/modules/transactions/brc20.rs b/rust/tw_bitcoin/src/modules/transactions/brc20.rs index e67b81f24bb..e7e8816a15a 100644 --- a/rust/tw_bitcoin/src/modules/transactions/brc20.rs +++ b/rust/tw_bitcoin/src/modules/transactions/brc20.rs @@ -31,12 +31,12 @@ struct BRC20TransferPayload { } impl BRC20TransferPayload { - const PROTOCOL_ID: &str = "brc-20"; - const MIME: &[u8] = b"text/plain;charset=utf-8"; + const PROTOCOL_ID: &'static str = "brc-20"; + const MIME: &'static [u8] = b"text/plain;charset=utf-8"; } impl BRC20TransferPayload { - const OPERATION: &str = "transfer"; + const OPERATION: &'static str = "transfer"; fn new(ticker: Brc20Ticker, amount: String) -> Self { BRC20TransferPayload { diff --git a/rust/tw_evm/src/abi/decode.rs b/rust/tw_evm/src/abi/decode.rs index fc1489433d4..0b13d192076 100644 --- a/rust/tw_evm/src/abi/decode.rs +++ b/rust/tw_evm/src/abi/decode.rs @@ -27,7 +27,7 @@ pub fn decode_params(params: &[Param], data: &[u8]) -> AbiResult let named_tokens: Vec<_> = params .iter() - .zip(decoded_tokens.into_iter()) + .zip(decoded_tokens) .map(|(param, value)| NamedToken::with_param_and_token(param, value)) .collect(); Ok(named_tokens) diff --git a/rust/tw_evm/src/abi/function.rs b/rust/tw_evm/src/abi/function.rs index d4359e378b4..93a4d3d0441 100644 --- a/rust/tw_evm/src/abi/function.rs +++ b/rust/tw_evm/src/abi/function.rs @@ -60,6 +60,6 @@ impl Function { let signed = short_signature(&self.name, &input_param_types); let encoded = encode_tokens(tokens); - Ok(signed.into_iter().chain(encoded.into_iter()).collect()) + Ok(signed.into_iter().chain(encoded).collect()) } } diff --git a/rust/tw_evm/src/message/eip712/eip712_message.rs b/rust/tw_evm/src/message/eip712/eip712_message.rs index ceb3815d328..ccb3f1bea91 100644 --- a/rust/tw_evm/src/message/eip712/eip712_message.rs +++ b/rust/tw_evm/src/message/eip712/eip712_message.rs @@ -188,7 +188,7 @@ fn encode_array( // Check if the type definition actually matches the length of items to be encoded. if expected_len.is_some() && Some(elements.len()) != expected_len { - return Err(MessageSigningError::TypeValueMismatch)?; + return Err(MessageSigningError::TypeValueMismatch); } let mut encoded_items = vec![]; diff --git a/rust/tw_evm/src/modules/tx_builder.rs b/rust/tw_evm/src/modules/tx_builder.rs index a6cfc382528..5d23f9afa20 100644 --- a/rust/tw_evm/src/modules/tx_builder.rs +++ b/rust/tw_evm/src/modules/tx_builder.rs @@ -190,7 +190,7 @@ impl TxBuilder { erc4337_payload: Data, ) -> SigningResult { let Some(ref user_op) = input.user_operation else { - return Err(SigningError(CommonError::Error_invalid_params)) + return Err(SigningError(CommonError::Error_invalid_params)); }; let nonce = U256::from_big_endian_slice(&input.nonce)?; diff --git a/rust/tw_keypair/Cargo.toml b/rust/tw_keypair/Cargo.toml index d29ab7b89b3..b332c1e4aa4 100644 --- a/rust/tw_keypair/Cargo.toml +++ b/rust/tw_keypair/Cargo.toml @@ -25,10 +25,10 @@ p256 = { version = "0.13.0", features = ["ecdsa", "std"], default-features = fal pkcs8 = "0.10.2" rfc6979 = "0.4.0" # ED25519 specific: -blake2 = "0.9" -curve25519-dalek = "3" -digest = "0.9.0" -sha2 = "0.9" +blake2 = "0.10.6" +curve25519-dalek = { version = "4.1", features = ["digest", "legacy_compatibility"] } +digest = "0.10" +sha2 = "0.10.6" [dev-dependencies] serde_json = "1.0" diff --git a/rust/tw_keypair/src/ed25519/mod.rs b/rust/tw_keypair/src/ed25519/mod.rs index c12af906a36..3c34d4ff6ec 100644 --- a/rust/tw_keypair/src/ed25519/mod.rs +++ b/rust/tw_keypair/src/ed25519/mod.rs @@ -26,11 +26,11 @@ pub mod sha512 { /// `ed25519` implementation using `BLAKE2B` hash function. pub mod blake2b { - use blake2::Blake2b; + use blake2::Blake2b512; - pub type KeyPair = crate::ed25519::keypair::KeyPair; - pub type PrivateKey = crate::ed25519::private::PrivateKey; - pub type PublicKey = crate::ed25519::public::PublicKey; + pub type KeyPair = crate::ed25519::keypair::KeyPair; + pub type PrivateKey = crate::ed25519::private::PrivateKey; + pub type PublicKey = crate::ed25519::public::PublicKey; } /// A hash function that returns 64 length output. diff --git a/rust/tw_keypair/src/ed25519/public.rs b/rust/tw_keypair/src/ed25519/public.rs index c0de54f0c12..edee119dd0e 100644 --- a/rust/tw_keypair/src/ed25519/public.rs +++ b/rust/tw_keypair/src/ed25519/public.rs @@ -98,7 +98,8 @@ impl PublicKey { /// /// Source: https://github.com/dalek-cryptography/ed25519-dalek/blob/1.0.1/src/public.rs#L157-L160 fn multiply_by_basepoint_to_produce_public_key(bits: [u8; 32]) -> PublicKey { - let point = &Scalar::from_bits(bits) * &constants::ED25519_BASEPOINT_TABLE; + #[allow(deprecated)] + let point = &Scalar::from_bits(bits) * constants::ED25519_BASEPOINT_TABLE; PublicKey::with_edwards_point(point) } } diff --git a/rust/tw_keypair/src/ed25519/secret.rs b/rust/tw_keypair/src/ed25519/secret.rs index ca45153f84c..c1419e9fe92 100644 --- a/rust/tw_keypair/src/ed25519/secret.rs +++ b/rust/tw_keypair/src/ed25519/secret.rs @@ -39,8 +39,10 @@ impl ExpandedSecretKey { let (mut lower, upper): (H256, H256) = hash.split(); mangle_scalar(lower.deref_mut()); + #[allow(deprecated)] + let key = Scalar::from_bits(lower.take()); ExpandedSecretKey { - key: Scalar::from_bits(lower.take()), + key, nonce: upper, _phantom: PhantomData, } @@ -79,7 +81,7 @@ impl ExpandedSecretKey { h.update(message); let r = Scalar::from_hash(h); - let R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress(); + let R = (&r * constants::ED25519_BASEPOINT_TABLE).compress(); h = H::new(); h.update(R.as_bytes()); diff --git a/rust/tw_keypair/src/ed25519/signature.rs b/rust/tw_keypair/src/ed25519/signature.rs index 85374bb2ff6..43051c4325e 100644 --- a/rust/tw_keypair/src/ed25519/signature.rs +++ b/rust/tw_keypair/src/ed25519/signature.rs @@ -84,10 +84,11 @@ fn get_scalar(bytes: H256) -> KeyPairResult { // This succeed-fast trick should succeed for roughly half of all scalars. let last_byte = bytes.last().expect("H256 is exactly 32 length"); if last_byte & SIGNIFICANT_BITS_MASK == 0 { + #[allow(deprecated)] return Ok(Scalar::from_bits(bytes.take())); } - match Scalar::from_canonical_bytes(bytes.take()) { + match Scalar::from_canonical_bytes(bytes.take()).into() { Some(x) => Ok(x), None => Err(KeyPairError::InvalidSignature), } diff --git a/rust/tw_number/Cargo.toml b/rust/tw_number/Cargo.toml index d76f8b6ed6d..6f32da2d9b1 100644 --- a/rust/tw_number/Cargo.toml +++ b/rust/tw_number/Cargo.toml @@ -11,7 +11,7 @@ helpers = [] [dependencies] arbitrary = { version = "1", features = ["derive"], optional = true } lazy_static = "1.4.0" -primitive-types = "0.12.1" +primitive-types = "0.10.1" serde = { version = "1.0", features = ["derive"], optional = true } tw_hash = { path = "../tw_hash" } tw_memory = { path = "../tw_memory" } diff --git a/rust/wallet_core_rs/src/ffi/bitcoin/legacy.rs b/rust/wallet_core_rs/src/ffi/bitcoin/legacy.rs index 3b94034dae9..0997ed88857 100644 --- a/rust/wallet_core_rs/src/ffi/bitcoin/legacy.rs +++ b/rust/wallet_core_rs/src/ffi/bitcoin/legacy.rs @@ -303,7 +303,7 @@ pub unsafe extern "C" fn tw_bitcoin_legacy_taproot_build_and_sign_transaction( }; let serialized = tw_proto::serialize(&error).expect("failed to serialize error message"); - return CByteArray::from(serialized) + return CByteArray::from(serialized); }; // Serialize SigningOutput and return. diff --git a/samples/kmp/shared/build.gradle.kts b/samples/kmp/shared/build.gradle.kts index 461c09d9882..89fb86c4634 100644 --- a/samples/kmp/shared/build.gradle.kts +++ b/samples/kmp/shared/build.gradle.kts @@ -45,7 +45,7 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("com.trustwallet:wallet-core-kotlin:4.0.24") + implementation("com.trustwallet:wallet-core-kotlin:4.0.27") } } val commonTest by getting { diff --git a/samples/rust/Cargo.lock b/samples/rust/Cargo.lock index b77fefe671f..117be2dda3c 100644 --- a/samples/rust/Cargo.lock +++ b/samples/rust/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.19" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "autocfg" @@ -25,17 +25,18 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -46,9 +47,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "either" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "errno" @@ -57,17 +58,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "fastrand" -version = "1.8.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "hashbrown" @@ -75,12 +73,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - [[package]] name = "hex" version = "0.4.3" @@ -88,97 +80,83 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "indexmap" -version = "1.9.1" +name = "home" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "autocfg", - "hashbrown", + "windows-sys", ] [[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.9" +name = "indexmap" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.45.0", + "autocfg", + "hashbrown", ] [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.135" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "once_cell" -version = "1.15.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "protobuf" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e" +checksum = "58678a64de2fced2bdec6bca052a6716a0efe692d6e3f53d1bda6a1def64cfc0" dependencies = [ "once_cell", "protobuf-support", @@ -187,9 +165,9 @@ dependencies = [ [[package]] name = "protobuf-codegen" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901" +checksum = "32777b0b3f6538d9d2e012b3fad85c7e4b9244b5958d04a6415f4333782b7a77" dependencies = [ "anyhow", "once_cell", @@ -202,9 +180,9 @@ dependencies = [ [[package]] name = "protobuf-parse" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49" +checksum = "96cb37955261126624a25b5e6bda40ae34cf3989d52a783087ca6091b29b5642" dependencies = [ "anyhow", "indexmap", @@ -218,36 +196,39 @@ dependencies = [ [[package]] name = "protobuf-support" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372" +checksum = "e1ed294a835b0f30810e13616b1cd34943c6d1e84a8f3b0dcfe466d256c3e7e7" dependencies = [ "thiserror", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] -name = "redox_syscall" -version = "0.2.16" +name = "regex" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ - "bitflags", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", ] [[package]] -name = "regex" -version = "1.6.0" +name = "regex-automata" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -256,22 +237,21 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustix" -version = "0.36.17" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -288,9 +268,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.102" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -299,31 +279,30 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -332,43 +311,20 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "which" -version = "4.3.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", -] - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "rustix", ] [[package]] @@ -377,119 +333,62 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/tools/install-rust-dependencies b/tools/install-rust-dependencies index 32fe675512d..632c2290f1c 100755 --- a/tools/install-rust-dependencies +++ b/tools/install-rust-dependencies @@ -2,19 +2,16 @@ set -e -STABLE="stable-2023-06-01" -NIGHTLY="nightly-2023-06-27" +NIGHTLY="nightly-2024-02-09" -if [[ `uname` == "Darwin" || "$1" == "dev" ]]; then - rustup toolchain install $NIGHTLY - rustup default $NIGHTLY - rustup toolchain install $NIGHTLY-x86_64-apple-darwin --force-non-host - rustup toolchain install $NIGHTLY-aarch64-apple-darwin --force-non-host - rustup component add rust-src --toolchain $NIGHTLY-aarch64-apple-darwin - rustup component add rust-src --toolchain $NIGHTLY-x86_64-apple-darwin -else - rustup toolchain install $STABLE - rustup default $STABLE +rustup toolchain install $NIGHTLY +rustup default $NIGHTLY +rustup toolchain install $NIGHTLY-x86_64-apple-darwin --force-non-host +rustup toolchain install $NIGHTLY-aarch64-apple-darwin --force-non-host +rustup component add rust-src --toolchain $NIGHTLY-aarch64-apple-darwin +rustup component add rust-src --toolchain $NIGHTLY-x86_64-apple-darwin +if [[ `uname` == "Linux" ]]; then + rustup component add rust-src --toolchain $NIGHTLY-x86_64-unknown-linux-gnu fi # Android @@ -31,5 +28,4 @@ cargo install cbindgen --locked if [[ "$1" == "dev" ]]; then rustup component add llvm-tools-preview clippy rustfmt cargo install cargo-llvm-cov --locked - cargo install cargo-nextest --locked fi diff --git a/tools/install-sys-dependencies-mac b/tools/install-sys-dependencies-mac index 9ff7f1a41fd..c01bd2cde28 100755 --- a/tools/install-sys-dependencies-mac +++ b/tools/install-sys-dependencies-mac @@ -2,6 +2,8 @@ set -e +# A workaround for "The `brew link` step did not complete successfully" error. +brew install python@3 || brew link --overwrite python@3 brew install boost ninja xcodegen xcbeautify if command -v rustup &> /dev/null diff --git a/tools/release-size b/tools/release-size new file mode 100755 index 00000000000..bcd4076f9e8 --- /dev/null +++ b/tools/release-size @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import argparse +import json +import os + +RUST_TARGETS = [ + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "aarch64-linux-android", + "armv7-linux-androideabi", + "wasm32-unknown-emscripten", +] +LIB_NAME = "libwallet_core_rs.a" + + +def display_size(size_kb: int) -> str: + if size_kb >= 10000: + size_mb = float(size_kb) / 1024 + return f'{size_mb:+.2f} MB' + else: + return f'{size_kb} KB' + + +def measure_rust(_args): + result = {} + + for target in RUST_TARGETS: + path = f'rust/target/{target}/release/{LIB_NAME}' + file_stats = os.stat(path) + file_size_kb = file_stats.st_size / 1024 + result[target] = int(file_size_kb) + + print(json.dumps(result)) + + +def compare_sizes(args): + def display_target(target: str, before_kb: int, current_kb: int): + diff_kb = current_kb - before_kb + print(f'➡️ **{target}**') + print("```diff") + if before_kb == current_kb: + print(f' Size {display_size(before_kb)}') + else: + print(f'- Size {display_size(before_kb)}') + print(f'+ Size {display_size(current_kb)} \t {display_size(diff_kb)}') + print("```") + + current_json = json.load(open(args.current, 'r')) + before_json = {} + if os.path.isfile(args.before): + before_json = json.load(open(args.before, 'r')) + + print("## Binary size comparison") + print() + for target, current_kb in current_json.items(): + before_kb = before_json.get(target, 0) + display_target(target, before_kb, current_kb) + print() + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="GitHub CI helper functions") + subparsers = parser.add_subparsers() + + measure_parser = subparsers.add_parser('measure-rust', help="Measures Rust release binaries'") + measure_parser.set_defaults(func=measure_rust) + + compare_parser = subparsers.add_parser('compare', + help="Compares binary sizes. Takes 'before' and 'current' file names") + compare_parser.add_argument('--before', type=str) + compare_parser.add_argument('--current', type=str) + compare_parser.set_defaults(func=compare_sizes) + + args = parser.parse_args() + args.func(args) diff --git a/tools/rust-bindgen b/tools/rust-bindgen index 0c61c54f467..1b0afa3a6a5 100755 --- a/tools/rust-bindgen +++ b/tools/rust-bindgen @@ -52,9 +52,11 @@ if [[ "$NATIVE" == "true" ]]; then cargo build --release fi +export RUSTFLAGS="-Zlocation-detail=none" + if [[ "$WASM" == "true" ]]; then echo "Generating WASM target" - cargo build --target wasm32-unknown-emscripten --release + cargo build -Z build-std=std,panic_abort --target wasm32-unknown-emscripten --release fi if [[ "$ANDROID" == "true" ]]; then @@ -67,13 +69,12 @@ if [[ "$ANDROID" == "true" ]]; then export CC_armv7_linux_androideabi="$NDK_BIN_PATH/armv7a-linux-androideabi$NDK_API_LEVEL-clang" echo "Generating Android targets" - cargo build --target aarch64-linux-android --target armv7-linux-androideabi --target x86_64-linux-android --target i686-linux-android --release + cargo build -Z build-std=std,panic_abort --target aarch64-linux-android --target armv7-linux-androideabi --target x86_64-linux-android --target i686-linux-android --release fi if [[ "$IOS" == "true" ]]; then echo "Generating iOS targets" - cargo build --target aarch64-apple-ios --target aarch64-apple-ios-sim --target x86_64-apple-ios --target aarch64-apple-darwin --target x86_64-apple-darwin --release & - cargo build -Z build-std --target aarch64-apple-ios-macabi --target x86_64-apple-ios-macabi --release & + cargo build -Z build-std=std,panic_abort --target aarch64-apple-ios --target aarch64-apple-ios-sim --target x86_64-apple-ios --target aarch64-apple-darwin --target x86_64-apple-darwin --target aarch64-apple-ios-macabi --target x86_64-apple-ios-macabi --release & wait lipo $BUILD_FOLDER/x86_64-apple-ios/release/$TARGET_NAME $BUILD_FOLDER/aarch64-apple-ios-sim/release/$TARGET_NAME -create -output $BUILD_FOLDER/$TARGET_NAME mkdir -p $BUILD_FOLDER/darwin_universal