diff --git a/.cargo/audit.toml b/.cargo/audit.toml deleted file mode 100644 index e23dbc3..0000000 --- a/.cargo/audit.toml +++ /dev/null @@ -1,4 +0,0 @@ -[advisories] -ignore = [ - "RUSTSEC-2021-0127" # serde_cbor dependency through the criterion dev-dependency -] diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 00aa8e5..70fa9d4 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -4,7 +4,6 @@ about: Please use the discussions tab for questions title: '' labels: '' assignees: '' - --- Please post your question as a discussion here: diff --git a/.github/scripts/release.py b/.github/scripts/release.py index 136f48f..029498a 100644 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -15,4 +15,3 @@ # * Git tag with version # * Git push branch and tag # * Cargo publish in all workspace members - diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml deleted file mode 100644 index 66479fc..0000000 --- a/.github/workflows/audit.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Security Audit -# See - -on: - push: - branches: [ main ] - paths: - - '**/Cargo.toml' - - '**/Cargo.lock' - schedule: - - cron: '0 2 * * *' # run at 2 AM UTC - -jobs: - security-audit: - name: Dependency Security Audit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b83db21..47b33a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,100 +1,86 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [main] + pull_request: env: CARGO_TERM_COLOR: always - # Skip incremental build and debug info generation in CI - CARGO_INCREMENTAL: 0 - CARGO_PROFILE_DEV_DEBUG: 0 jobs: accept: name: Accept runs-on: ubuntu-latest - needs: [lint, test] + needs: [test, feature-checks, clippy, docs, fmt] steps: - name: Accept - run: true - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Install rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - components: rustfmt, clippy - - name: Cache build - uses: Swatinem/rust-cache@v1 - with: - key: cache-v1 - - name: Check formatting - run: cargo fmt --all -- --check - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --locked --workspace --all-features --all-targets - - name: Check docs - run: cargo doc --locked --workspace --all-features --no-deps --document-private-items + run: "true" test: - name: Test + name: Test ${{ matrix.rust }} runs-on: ubuntu-latest + timeout-minutes: 30 strategy: + fail-fast: false matrix: - rust: - - stable - - nightly + rust: [stable, beta, nightly, 1.65] # MSRV steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Install rust - uses: dtolnay/rust-toolchain@master + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - - name: Cache build - uses: Swatinem/rust-cache@v1 - with: - key: cache-v1 + - name: exclude nightly features + if: ${{ matrix.rust }} != 'nightly' + run: | + sed -i 's/nightly = \[\]//g' Cargo.toml + sed -i 's/generic_const_exprs = \["nightly"\]//g' Cargo.toml + - uses: Swatinem/rust-cache@v2 # Cargo doc test is not included in `--all-targets` so we call it separately. # See # Cargo doc test also doesn't support `--no-run`, so we run it but # have it just print `--help`. - name: Build tests run: | - cargo test --locked --workspace --all-features --all-targets --no-run - cargo test --locked --workspace --all-features --doc -- --help + cargo test --workspace --all-features --all-targets --no-run + cargo test --workspace --all-features --doc -- --help - name: Run tests run: | - cargo test --locked --workspace --all-features --all-targets -- --nocapture - cargo test --locked --workspace --all-features --doc -- --nocapture + cargo test --workspace --all-features --all-targets -- --nocapture + cargo test --workspace --all-features --doc -- --nocapture + + feature-checks: + name: Feature checks + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + - name: cargo hack + run: | + cargo hack check \ + --feature-powerset --exclude-features nightly,generic_const_exprs \ + --depth 1 \ + --all-targets codecov: # See name: Coverage runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Install rust - uses: dtolnay/rust-toolchain@master + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly components: llvm-tools-preview - - name: Cache build - uses: Swatinem/rust-cache@v1 - with: - key: cache-v1 - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-llvm-cov - name: Build with code coverage run: | - cargo llvm-cov --no-report --locked --workspace --all-features --all-targets - cargo llvm-cov --no-report --locked --workspace --all-features --doc + cargo llvm-cov --no-report --workspace --all-features --all-targets + cargo llvm-cov --no-report --workspace --all-features --doc - name: Generate code coverage env: # Covered tests are slower, so reduce the test load. (We also shouldn't @@ -102,27 +88,58 @@ jobs: PROPTEST_CASES: 5 run: | # Generate profiles, but do not merge them - cargo llvm-cov --no-report --locked --workspace --all-features --all-targets -- --nocapture - cargo llvm-cov --no-report --locked --workspace --all-features --doc -- --nocapture + cargo llvm-cov --no-report --workspace --all-features --all-targets -- --nocapture + cargo llvm-cov --no-report --workspace --all-features --doc -- --nocapture - name: Merge profiles run: cargo llvm-cov --no-run --lcov --output-path lcov.info - name: Submit to codecov.io - uses: codecov/codecov-action@v3.1.1 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # Optional for public repos files: lcov.info fail_ci_if_error: true verbose: true - security_audit: - name: Dependency Security Audit + clippy: + name: Clippy runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - name: Set up Rust - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@clippy + - run: cargo clippy --workspace --all-features + env: + RUSTFLAGS: -Dwarnings + + docs: + name: Docs + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly - - uses: actions-rs/audit-check@v1 + components: rust-docs + - run: cargo doc --workspace --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: "--cfg doc_cfg -D warnings" + + fmt: + name: Fmt + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - run: cargo fmt --all --check + + cargo-deny: + name: Cargo deny check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: EmbarkStudios/cargo-deny-action@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} + command: check all diff --git a/.github/workflows/issue_tracker.yml b/.github/workflows/issue_tracker.yml index 46694be..af62b5a 100644 --- a/.github/workflows/issue_tracker.yml +++ b/.github/workflows/issue_tracker.yml @@ -2,7 +2,7 @@ name: Issue Tracker on: push: - branches: [ main ] + branches: [main] jobs: issue-tracker: diff --git a/Changelog.md b/CHANGELOG.md similarity index 92% rename from Changelog.md rename to CHANGELOG.md index 6dabf5a..f30d0bc 100644 --- a/Changelog.md +++ b/CHANGELOG.md @@ -9,12 +9,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Support for [`alloy-rlp`](https://github.com/alloy-rs/rlp) + ### Changed - Make `serde::Deserialize` impl more permissive - Use Ethereum `Quantity` encoding for serde serialization when human-readable - Fix error in `from_base_be` that allowed instantiation of overflowing `Uint`. -- Updated `ark` to `0.4`, `fastrlp` to `0.3` and `pyo3` to `0.18`. +- Updated `ark` to `0.4`, `fastrlp` to `0.3`, `pyo3` to `0.19`, and `sqlx-core` to `0.7`. +- Improved `fastrlp` perfomance +- Improved `proptest` performance +- Made `support` module and its modules public +- Made more `algorithm` functions public +- Constified `as_le_slice` and `as_le_bytes` + +### Removed + +- Automatic detection of nightly features. Enable them instead with the `nightly` cargo feature. +- Dependency on `derive_more` ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 0c8ccc8..d924ac5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,16 +3,20 @@ version = 3 [[package]] -name = "ahash" -version = "0.7.6" +name = "addr2line" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" dependencies = [ - "getrandom", - "once_cell", - "version_check", + "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.3" @@ -20,19 +24,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "alloy-rlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f54319708cdf93563fe45b1afd475901cecbd0edb992305dc91eadc52d7717e" +dependencies = [ + "arrayvec", + "bytes", + "smol_str", +] + [[package]] name = "anes" version = "0.1.6" @@ -179,15 +201,15 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", @@ -196,18 +218,18 @@ dependencies = [ [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] [[package]] name = "auto_impl" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8c1df849285fbacd587de7818cc7d13be6cd2cbcd47a04fb1801b0e2706e33" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", "proc-macro2", @@ -221,11 +243,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bincode" @@ -301,9 +338,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" @@ -343,9 +380,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -354,15 +391,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", @@ -393,28 +430,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - [[package]] name = "coverage-helper" version = "0.1.0" @@ -423,28 +438,13 @@ checksum = "a9db510e477cf3c14a6c56aa2ed28e499f1e27e01c17723b41ece793d11cf3fe" [[package]] name = "cpufeatures" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - [[package]] name = "criterion" version = "0.5.1" @@ -504,9 +504,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -561,24 +561,11 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -607,6 +594,12 @@ dependencies = [ "regex", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.1" @@ -615,7 +608,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -678,26 +671,11 @@ 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.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -726,15 +704,21 @@ checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.11.2", + "parking_lot", ] +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + [[package]] name = "futures-macro" version = "0.3.28" @@ -765,9 +749,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", + "futures-io", "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -785,9 +771,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -797,19 +783,16 @@ dependencies = [ ] [[package]] -name = "half" -version = "1.8.2" +name = "gimli" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] -name = "hashbrown" -version = "0.12.3" +name = "half" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.6", -] +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "hashbrown" @@ -817,32 +800,33 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash", ] [[package]] -name = "hashlink" -version = "0.8.1" +name = "hashbrown" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ - "hashbrown 0.12.3", + "ahash", + "allocator-api2", ] [[package]] -name = "hermit-abi" -version = "0.2.6" +name = "hashlink" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f" dependencies = [ - "libc", + "hashbrown 0.14.0", ] [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -867,9 +851,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -897,12 +881,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -922,13 +906,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -937,9 +921,9 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "rustix 0.38.4", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -953,15 +937,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -980,15 +964,15 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libm" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "linux-raw-sys" -version = "0.3.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f508063cc7bb32987c71511216bd5a32be15bccb6a80b52df8b9d7f01fc3aa2" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" @@ -998,9 +982,9 @@ checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -1008,12 +992,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "md-5" @@ -1032,9 +1013,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -1046,33 +1027,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "mio" -version = "0.8.6" +name = "miniz_oxide" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.45.0", + "adler", ] [[package]] -name = "native-tls" -version = "0.2.11" +name = "mio" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ - "lazy_static", "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", + "wasi", + "windows-sys", ] [[package]] @@ -1118,75 +1089,40 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - -[[package]] -name = "openssl" -version = "0.10.50" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30d8bc91859781f0a943411186324d580f2bbeb71b452fe91ae344806af3f1" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "foreign-types", + "hermit-abi", "libc", - "once_cell", - "openssl-macros", - "openssl-sys", ] [[package]] -name = "openssl-macros" -version = "0.1.1" +name = "object" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.26", + "memchr", ] [[package]] -name = "openssl-probe" -version = "0.1.5" +name = "once_cell" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] -name = "openssl-sys" -version = "0.9.85" +name = "oorandom" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" dependencies = [ "arrayvec", "bitvec", @@ -1198,9 +1134,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1208,17 +1144,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -1226,71 +1151,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", - "instant", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_shared", ] [[package]] name = "phf_shared" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", ] [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -1298,17 +1209,11 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - [[package]] name = "plotters" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", @@ -1319,15 +1224,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] @@ -1437,20 +1342,19 @@ dependencies = [ [[package]] name = "proptest" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f1b898011ce9595050a68e60f90bad083ff2987a695a42357134c8381fba70" +checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" dependencies = [ "bit-set", "bitflags 1.3.2", "byteorder", "lazy_static", "num-traits", - "quick-error 2.0.1", "rand", "rand_chacha", "rand_xorshift", - "regex-syntax", + "regex-syntax 0.6.29", "rusty-fork", "tempfile", "unarray", @@ -1458,15 +1362,15 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" +checksum = "ffb88ae05f306b4bfcde40ac4a51dc0b05936a9207a4b75b798c7729c4258a59" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot 0.12.1", + "parking_lot", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -1475,9 +1379,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" +checksum = "554db24f0b3c180a9c0b1268f91287ab3f17c162e15b54caaae5a6b3773396b0" dependencies = [ "once_cell", "target-lexicon", @@ -1485,9 +1389,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" +checksum = "922ede8759e8600ad4da3195ae41259654b9c55da4f7eec84a0ccc7d067a70a4" dependencies = [ "libc", "pyo3-build-config", @@ -1495,9 +1399,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" +checksum = "8a5caec6a1dd355964a841fcbeeb1b89fe4146c87295573f94228911af3cc5a2" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1507,9 +1411,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" +checksum = "e0b78ccbb160db1556cdb6fd96c50334c5d4ec44dc5e0a968d0a1208fa0efa8b" dependencies = [ "proc-macro2", "quote", @@ -1522,12 +1426,6 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quick-error" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" - [[package]] name = "quickcheck" version = "1.0.3" @@ -1617,31 +1515,34 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags 1.3.2", ] [[package]] -name = "redox_syscall" -version = "0.3.5" +name = "regex" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ - "bitflags 1.3.2", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax 0.7.4", ] [[package]] -name = "regex" -version = "1.7.3" +name = "regex-automata" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.4", ] [[package]] @@ -1650,6 +1551,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + [[package]] name = "rlp" version = "0.5.2" @@ -1662,8 +1569,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.8.0" +version = "1.9.0" dependencies = [ + "alloy-rlp", "approx", "arbitrary", "ark-bn254", @@ -1673,7 +1581,6 @@ dependencies = [ "bytes", "coverage-helper", "criterion", - "derive_more", "fastrlp", "hex", "hex-literal", @@ -1689,10 +1596,8 @@ dependencies = [ "rlp", "ruint", "ruint-macro", - "rustc_version", "serde", "serde_json", - "smallvec", "sqlx-core", "thiserror", "valuable", @@ -1701,11 +1606,17 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.0.2" +version = "1.1.0" dependencies = [ "ruint", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -1723,16 +1634,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.12" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722529a737f5a942fdbac3a46cee213053196737c5eaa3386d52e85b786f2659" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.2", - "windows-sys 0.48.0", + "linux-raw-sys 0.3.8", + "windows-sys", ] [[package]] @@ -1745,7 +1656,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.3", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1755,16 +1666,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" dependencies = [ "fnv", - "quick-error 1.2.3", + "quick-error", "tempfile", "wait-timeout", ] [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -1775,64 +1686,32 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys 0.42.0", -] - [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "security-framework" -version = "2.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", @@ -1841,9 +1720,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" dependencies = [ "itoa", "ryu", @@ -1852,9 +1731,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -1878,9 +1757,18 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "smol_str" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" +dependencies = [ + "serde", +] [[package]] name = "socket2" @@ -1894,12 +1782,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d283f86695ae989d1e18440a943880967156325ba025f05049946bff47bcc2b" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1915,16 +1803,14 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.6.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" dependencies = [ - "ahash 0.7.6", + "ahash", "atoi", - "bitflags 1.3.2", "byteorder", "bytes", - "crc", "crossbeam-queue", "dotenvy", "either", @@ -1932,39 +1818,23 @@ dependencies = [ "futures-channel", "futures-core", "futures-intrusive", + "futures-io", "futures-util", "hashlink", "hex", "indexmap", - "itoa", - "libc", "log", "memchr", "once_cell", "paste", "percent-encoding", - "sha2", "smallvec", "sqlformat", - "sqlx-rt", - "stringprep", "thiserror", - "tokio-stream", + "tracing", "url", ] -[[package]] -name = "sqlx-rt" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" -dependencies = [ - "native-tls", - "once_cell", - "tokio", - "tokio-native-tls", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -1973,9 +1843,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stringprep" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1983,9 +1853,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2017,37 +1887,38 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", - "redox_syscall 0.3.5", - "rustix 0.37.12", - "windows-sys 0.45.0", + "redox_syscall", + "rustix 0.37.23", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", @@ -2081,28 +1952,18 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2 0.4.9", - "windows-sys 0.45.0", -] - -[[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", + "windows-sys", ] [[package]] @@ -2118,33 +1979,22 @@ dependencies = [ "futures-channel", "futures-util", "log", - "parking_lot 0.12.1", + "parking_lot", "percent-encoding", "phf", "pin-project-lite", "postgres-protocol", "postgres-types", - "socket2 0.5.2", + "socket2 0.5.3", "tokio", "tokio-util", ] -[[package]] -name = "tokio-stream" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -2156,15 +2006,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ "indexmap", "toml_datetime", @@ -2178,15 +2028,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.26", +] + [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] @@ -2223,9 +2086,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -2250,9 +2113,9 @@ checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -2265,12 +2128,6 @@ 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" @@ -2304,9 +2161,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2314,24 +2171,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.26", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2339,28 +2196,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.26", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -2397,147 +2254,66 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[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", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" 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-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "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_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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[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.48.0" @@ -2546,9 +2322,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 3088f7f..0cae8ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,38 @@ [package] name = "ruint" -description = "Unsigned integer type with cont-generic bit length" -authors = ["Remco Bloemen "] -version = "1.8.0" -edition = "2021" -homepage = "https://github.com/recmo/uint" -repository = "https://github.com/recmo/uint" +description = "Unsigned integer type with const-generic bit length" +version = "1.9.0" keywords = ["uint"] categories = ["mathematics"] -readme = "Readme.md" -license = "MIT" +exclude = ["benches/", "proptest-regressions/", "tests/"] +readme = "README.md" + +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs", "--html-in-header", ".cargo/katex-header.html"] [workspace] -members = ["ruint-macro"] +members = [".", "ruint-macro"] +resolver = "2" -[features] -default = [] -dyn = ["dep:smallvec"] -generic_const_exprs = [] -postgres = ["dep:postgres-types", "dep:bytes"] -sqlx = ["dep:sqlx-core"] +[workspace.package] +edition = "2021" +rust-version = "1.65" +authors = ["Remco Bloemen "] +license = "MIT" +homepage = "https://github.com/recmo/uint" +repository = "https://github.com/recmo/uint" + +[workspace.dependencies] +ruint = { version = "1.9.0", path = "." } +ruint-macro = { version = "1.1.0", path = "ruint-macro" } [[bench]] name = "bench_uint" @@ -27,54 +40,73 @@ harness = false path = "benches/bench.rs" [dependencies] -arbitrary = { version = "1.1", optional = true } -ark-ff = { version = "0.4.0", optional = true } -bn-rs = { version = "0.2", optional = true } -bytes = { version = "1.1", optional = true } -derive_more = "0.99.17" -fastrlp = { version = "0.3.1", optional = true } -num-bigint = { version = "0.4.3", optional = true } -parity-scale-codec = { version = "3.2.1", optional = true, features = ["max-encoded-len"] } -postgres-types = { version = "0.2.3", optional = true } -primitive-types = { version = "<1", optional = true } -proptest = { version = "1.0", optional = true } -pyo3 = { version = "0.18.3", optional = true } -quickcheck = { version = "1.0", optional = true } -rand = { version = "0.8.5", optional = true } -rlp = { version = "0.5.1", optional = true } -ruint-macro = { version = "1.0.2", path = "./ruint-macro" } -serde = { version = "1.0", optional = true } -smallvec = { version = "1.8.0", optional = true, features = ["union"] } # for UintDyn -# HACK: (BLOCKED) sqlx requires a runtime to be specified. -# -sqlx-core = { version = "0.6", optional = true, features = ["runtime-tokio-native-tls"] } +ruint-macro = { version = "1.0.2", path = "ruint-macro" } + thiserror = "1.0" -valuable = { version = "0.1.0", optional = true } -zeroize = { version = "1.5", optional = true } -[build-dependencies] -# Rust currently has no way to conditionally compile based on compiler features. -# `autocfg` is a workaround, but doesn't support probing for `#[features(...)]` -# yet (there's a PR though, but crates.io doesn't allow us to use it). -# So instead, we do the dumb thing and just check for nightly. -rustc_version = "0.4.0" +# support +alloy-rlp = { version = "0.3", optional = true } +arbitrary = { version = "1", optional = true } +ark-ff = { version = "0.4", optional = true } +bn-rs = { version = "0.2", optional = true } +fastrlp = { version = "0.3", optional = true } +num-bigint = { version = "0.4", optional = true } +parity-scale-codec = { version = "3", optional = true, features = ["derive", "max-encoded-len"] } +primitive-types = { version = "0.12", optional = true } +proptest = { version = "1", optional = true } +pyo3 = { version = "0.19", optional = true } +quickcheck = { version = "1", optional = true } +rand = { version = "0.8", optional = true } +rlp = { version = "0.5", optional = true } +serde = { version = "1", optional = true } +valuable = { version = "0.1", optional = true } +zeroize = { version = "1.6", optional = true } + +# postgres +bytes = { version = "1.4", optional = true } +postgres-types = { version = "0.2", optional = true } + +# sqlx +sqlx-core = { version = "0.7", optional = true } [dev-dependencies] -ruint = { path = ".", features = ["arbitrary", "proptest"] } +ruint = { workspace = true, features = ["arbitrary", "proptest"] } criterion = "0.5" rand = "0.8" -approx = "0.5.1" -ark-bn254 = "0.4.0" +approx = "0.5" +ark-bn254 = "0.4" bincode = "1.3" coverage-helper = "0.1" -hex = "0.4.3" -hex-literal = "0.4.1" -postgres = "0.19.3" -proptest = { version = "1.0" } +hex = "0.4" +hex-literal = "0.4" +postgres = "0.19" +proptest = "1.2" serde_json = "1.0" -[package.metadata.docs.rs] -rustdoc-args = ["--cfg", "has_cfg_doc", "--html-in-header", ".cargo/katex-header.html"] -all-features = true +[features] +# nightly-only features +nightly = [] +generic_const_exprs = ["nightly"] + +# support +alloy-rlp = ["dep:alloy-rlp"] +arbitrary = ["dep:arbitrary"] +ark-ff = ["dep:ark-ff"] +bn-rs = ["dep:bn-rs"] +fastrlp = ["dep:fastrlp"] +num-bigint = ["dep:num-bigint"] +parity-scale-codec = ["dep:parity-scale-codec"] +primitive-types = ["dep:primitive-types"] +proptest = ["dep:proptest"] +pyo3 = ["dep:pyo3"] +quickcheck = ["dep:quickcheck"] +rand = ["dep:rand"] +rlp = ["dep:rlp"] +serde = ["dep:serde"] +valuable = ["dep:valuable"] +zeroize = ["dep:zeroize"] + +postgres = ["dep:postgres-types", "dep:bytes"] +sqlx = ["dep:sqlx-core"] diff --git a/Readme.md b/Readme.md index a976816..80b0b4a 100644 --- a/Readme.md +++ b/Readme.md @@ -57,7 +57,7 @@ without `generic_const_exprs` support (Rust issue [#76560][r76560]). [r76560]: https://github.com/rust-lang/rust/issues/76560 ```rust -# #[cfg(has_generic_const_exprs)] { +# #[cfg(feature = "generic_const_exprs")] { use ruint::nightly::Uint; let answer: Uint<256> = Uint::<256>::from(42); diff --git a/benches/bench.rs b/benches/bench.rs index a11ebdd..d5145e6 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,7 +1,7 @@ mod benches; mod prelude { - pub use criterion::{BatchSize, Criterion}; + pub use criterion::{black_box, BatchSize, Criterion}; pub use proptest::{ arbitrary::Arbitrary, strategy::{Strategy, ValueTree}, @@ -9,7 +9,6 @@ mod prelude { }; pub use rand::prelude::*; pub use ruint::{const_for, nlimbs, uint, Bits, Uint, UintTryFrom, UintTryTo}; - pub use std::hint::black_box; } fn main() { diff --git a/build.rs b/build.rs deleted file mode 100644 index 0b8d368..0000000 --- a/build.rs +++ /dev/null @@ -1,12 +0,0 @@ -use rustc_version::{version_meta, Channel}; - -fn main() { - // HACK: Ideally we would test for features instead of release channel. - let nightly = version_meta().unwrap().channel == Channel::Nightly; - if nightly { - println!("cargo:rustc-cfg=has_generic_const_exprs"); - println!("cargo:rustc-cfg=has_cfg_doc"); - println!("cargo:rustc-cfg=has_core_intrinsics"); - } - println!("cargo:rerun-if-changed=build.rs"); -} diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..2951ecc --- /dev/null +++ b/deny.toml @@ -0,0 +1,33 @@ +[advisories] +vulnerability = "deny" +unmaintained = "warn" +unsound = "warn" +yanked = "warn" +notice = "warn" + +[bans] +multiple-versions = "warn" +wildcards = "deny" +highlight = "all" + +[licenses] +unlicensed = "deny" +confidence-threshold = 0.9 +# copyleft = "deny" + +allow = [ + "MIT", + "MIT-0", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "ISC", + "Unicode-DFS-2016", + "Unlicense", + "MPL-2.0", +] + +[sources] +unknown-registry = "deny" +unknown-git = "deny" diff --git a/ruint-macro/Cargo.toml b/ruint-macro/Cargo.toml index c4923b8..1d3588a 100644 --- a/ruint-macro/Cargo.toml +++ b/ruint-macro/Cargo.toml @@ -1,21 +1,23 @@ [package] name = "ruint-macro" description = "The `uint!` macro for `Uint` literals" -authors = ["Remco Bloemen "] -version = "1.0.2" -edition = "2021" -homepage = "https://github.com/recmo/uint" -repository = "https://github.com/recmo/uint" +version = "1.1.0" keywords = ["uint", "macro"] categories = ["mathematics"] -readme = "Readme.md" -license-file = "../mit-license.md" +readme = "README.md" + +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true [lib] proc-macro = true -[dev-dependencies] -ruint = { path = ".." } - [package.metadata.release] tag = false + +[dev-dependencies] +ruint.workspace = true diff --git a/ruint-macro/Readme.md b/ruint-macro/README.md similarity index 100% rename from ruint-macro/Readme.md rename to ruint-macro/README.md diff --git a/ruint-macro/src/lib.rs b/ruint-macro/src/lib.rs index 1df3627..f061449 100644 --- a/ruint-macro/src/lib.rs +++ b/ruint-macro/src/lib.rs @@ -1,4 +1,4 @@ -#![doc = include_str!("../Readme.md")] +#![doc = include_str!("../README.md")] #![warn(clippy::all, clippy::pedantic, clippy::cargo, clippy::nursery)] use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; @@ -218,7 +218,7 @@ fn transform_stream(stream: TokenStream) -> TokenStream { } // Repeat the crate doc -#[doc = include_str!("../Readme.md")] +#[doc = include_str!("../README.md")] #[proc_macro] pub fn uint(stream: TokenStream) -> TokenStream { transform_stream(stream) diff --git a/src/algorithms/ops.rs b/src/algorithms/ops.rs index c22e53e..f9b1287 100644 --- a/src/algorithms/ops.rs +++ b/src/algorithms/ops.rs @@ -15,5 +15,3 @@ pub fn sbb(lhs: u64, rhs: u64, borrow: u64) -> (u64, u64) { .wrapping_sub(u128::from(borrow)); (result.low(), result.high().wrapping_neg()) } - -// diff --git a/src/bit_arr.rs b/src/bit_arr.rs index 8c31950..b4a5b85 100644 --- a/src/bit_arr.rs +++ b/src/bit_arr.rs @@ -3,14 +3,36 @@ use core::ops::{ BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Index, Not, Shl, ShlAssign, Shr, ShrAssign, }; -use derive_more::{From, FromStr, Into}; -use std::borrow::Cow; +use std::{borrow::Cow, str::FromStr}; /// A newtype wrapper around [`Uint`] that restricts operations to those /// relevant for bit arrays. -#[derive(Clone, Copy, Debug, Default, Eq, From, FromStr, Into, PartialEq, Hash)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)] pub struct Bits(Uint); +impl From> for Bits { + #[inline] + fn from(value: Uint) -> Self { + Self(value) + } +} + +impl From> for Uint { + #[inline] + fn from(value: Bits) -> Self { + value.0 + } +} + +impl FromStr for Bits { + type Err = as FromStr>::Err; + + #[inline] + fn from_str(src: &str) -> Result { + src.parse().map(Self) + } +} + impl Bits { /// The size of this integer type in 64-bit limbs. pub const LIMBS: usize = Uint::::LIMBS; diff --git a/src/bytes.rs b/src/bytes.rs index 1824078..0fa182e 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -6,14 +6,12 @@ use crate::{ Uint, }; use core::{ - mem::size_of_val, ptr::{addr_of, addr_of_mut}, slice, }; use std::borrow::Cow; // OPT: *_to_smallvec to avoid allocation. - impl Uint { /// The size of this integer type in bytes. Note that some bits may be /// forced zero if BITS is not cleanly divisible by eight. @@ -28,8 +26,7 @@ impl Uint { #[cfg(target_endian = "little")] #[must_use] #[inline(always)] - pub fn as_le_slice(&self) -> &[u8] { - debug_assert!(Self::BYTES <= size_of_val(&self.limbs)); + pub const fn as_le_slice(&self) -> &[u8] { let data = addr_of!(self.limbs).cast(); unsafe { slice::from_raw_parts(data, Self::BYTES) } } @@ -47,7 +44,6 @@ impl Uint { #[must_use] #[inline(always)] pub unsafe fn as_le_slice_mut(&mut self) -> &mut [u8] { - debug_assert!(Self::BYTES <= size_of_val(&self.limbs)); let data = addr_of_mut!(self.limbs).cast(); slice::from_raw_parts_mut(data, Self::BYTES) } @@ -57,7 +53,7 @@ impl Uint { /// Uses an optimized implementation on little-endian targets. #[must_use] #[inline(always)] - pub fn as_le_bytes(&self) -> Cow<'_, [u8]> { + pub const fn as_le_bytes(&self) -> Cow<'_, [u8]> { // On little endian platforms this is a no-op. #[cfg(target_endian = "little")] return Cow::Borrowed(self.as_le_slice()); @@ -101,7 +97,7 @@ impl Uint { bytes.copy_from_slice(self.as_le_slice()); #[cfg(not(target_endian = "little"))] - for (chunk, limb) in bytes.chunks_mut(8).zip(self.as_limbs().iter()) { + for (chunk, limb) in bytes.chunks_mut(8).zip(self.as_limbs()) { chunk.copy_from_slice(&limb.to_le_bytes()[..chunk.len()]); } diff --git a/src/from.rs b/src/from.rs index 216a8d3..fef9cb7 100644 --- a/src/from.rs +++ b/src/from.rs @@ -496,7 +496,6 @@ impl TryFrom for Uint { } // Convert Uint to integer types -// // Required because a generic rule violates the orphan rule macro_rules! to_value_to_ref { @@ -604,7 +603,6 @@ impl TryFrom<&Uint> for u128 } // Convert Uint to floating point -// impl From> for f32 { fn from(value: Uint) -> Self { diff --git a/src/lib.rs b/src/lib.rs index e65102f..8fb0c7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,10 @@ #![doc = include_str!("../Readme.md")] -#![doc(issue_tracker_base_url = "https://github.com/recmo/uint/issues/")] -#![warn(clippy::all, clippy::pedantic, clippy::nursery)] +#![warn(clippy::all, clippy::pedantic, clippy::nursery, unreachable_pub)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] #![allow( clippy::doc_markdown, // Unfortunately many false positives on Latex. clippy::inline_always, clippy::module_name_repetitions, - clippy::module_name_repetitions, clippy::redundant_pub_crate, clippy::unreadable_literal, clippy::let_unit_value, @@ -14,20 +13,11 @@ any(test, feature = "bench"), allow(clippy::wildcard_imports, clippy::cognitive_complexity) )] -#![cfg_attr( - all(has_generic_const_exprs, feature = "generic_const_exprs"), - allow(incomplete_features) -)] -#![cfg_attr( - all(has_generic_const_exprs, feature = "generic_const_exprs"), - feature(generic_const_exprs) -)] -// See -#![cfg_attr(coverage_nightly, feature(no_coverage))] -// See -#![cfg_attr(has_doc_cfg, feature(doc_cfg))] -// Nightly only feature flag to enable the `unlikely` compiler hint. -#![cfg_attr(has_core_intrinsics, feature(core_intrinsics))] +// Unstable features +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(feature = "nightly", feature(no_coverage, core_intrinsics))] +#![cfg_attr(feature = "generic_const_exprs", feature(generic_const_exprs))] +#![cfg_attr(feature = "generic_const_exprs", allow(incomplete_features))] // Workaround for proc-macro `uint!` in this crate. // See @@ -55,13 +45,9 @@ mod pow; mod root; mod special; mod string; -mod support; -mod uint_dyn; mod utils; -#[cfg(all(feature = "dyn", feature = "unstable"))] -#[doc(inline)] -pub use uint_dyn::UintDyn; +pub mod support; #[doc(inline)] pub use bit_arr::Bits; @@ -77,7 +63,7 @@ pub use self::{ #[doc(inline)] pub use ruint_macro::uint; -#[cfg(all(has_generic_const_exprs, feature = "generic_const_exprs"))] +#[cfg(feature = "generic_const_exprs")] pub mod nightly { //! Extra features that are nightly only. @@ -149,20 +135,25 @@ impl Uint { /// The size of this integer type in 64-bit limbs. pub const LIMBS: usize = nlimbs(BITS); + const ASSERT_LIMBS: () = assert!( + LIMBS == Self::LIMBS, + "Can not construct Uint with incorrect LIMBS" + ); + /// Bit mask for the last limb. pub const MASK: u64 = mask(BITS); /// The size of this integer type in bits. pub const BITS: usize = BITS; - /// The smallest value that can be represented by this integer type. - /// Synonym for [`Self::ZERO`]. - pub const MIN: Self = Self::ZERO; - /// The value zero. This is the only value that exists in all [`Uint`] /// types. pub const ZERO: Self = Self::from_limbs([0; LIMBS]); + /// The smallest value that can be represented by this integer type. + /// Synonym for [`Self::ZERO`]. + pub const MIN: Self = Self::ZERO; + /// The largest value that can be represented by this integer type, /// $2^{\mathtt{BITS}} − 1$. pub const MAX: Self = { @@ -212,8 +203,8 @@ impl Uint { #[track_caller] #[inline(always)] pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self { - Self::assert_valid(); - if BITS > 0 && Self::MASK < u64::MAX { + let () = Self::ASSERT_LIMBS; + if BITS > 0 && Self::MASK != u64::MAX { // FEATURE: (BLOCKED) Add `<{BITS}>` to the type when Display works in const fn. assert!( limbs[Self::LIMBS - 1] <= Self::MASK, @@ -257,7 +248,7 @@ impl Uint { /// was truncated. #[must_use] pub fn overflowing_from_limbs_slice(slice: &[u64]) -> (Self, bool) { - Self::assert_valid(); + let () = Self::ASSERT_LIMBS; if slice.len() < LIMBS { let mut limbs = [0; LIMBS]; limbs[..slice.len()].copy_from_slice(slice); @@ -282,19 +273,10 @@ impl Uint { (_, true) => Self::MAX, } } - - #[inline(always)] - const fn assert_valid() { - // REFACTOR: (BLOCKED) Replace with `assert_eq!` when it is made `const`. - // Blocked on Rust, not issue known. - #[allow(clippy::manual_assert)] - if LIMBS != Self::LIMBS { - panic!("Can not construct Uint with incorrect LIMBS"); - } - } } impl Default for Uint { + #[inline] fn default() -> Self { Self::ZERO } @@ -303,13 +285,15 @@ impl Default for Uint { /// Number of `u64` limbs required to represent the given number of bits. /// This needs to be public because it is used in the `Uint` type. #[must_use] +#[inline] pub const fn nlimbs(bits: usize) -> usize { (bits + 63) / 64 } /// Mask to apply to the highest limb to get the correct number of bits. #[must_use] -const fn mask(bits: usize) -> u64 { +#[inline] +pub const fn mask(bits: usize) -> u64 { if bits == 0 { return 0; } diff --git a/src/support/alloy_rlp.rs b/src/support/alloy_rlp.rs new file mode 100644 index 0000000..27b1047 --- /dev/null +++ b/src/support/alloy_rlp.rs @@ -0,0 +1,151 @@ +//! Support for the [`alloy-rlp`](https://crates.io/crates/alloy-rlp) crate. + +#![cfg(feature = "alloy-rlp")] +#![cfg_attr(docsrs, doc(cfg(feature = "alloy-rlp")))] + +use crate::Uint; +use alloy_rlp::{ + length_of_length, BufMut, Decodable, Encodable, Error, Header, MaxEncodedLen, + MaxEncodedLenAssoc, EMPTY_STRING_CODE, +}; + +const MAX_BITS: usize = 55 * 8; + +/// Allows a [`Uint`] to be serialized as RLP. +/// +/// See +impl Encodable for Uint { + #[inline] + fn length(&self) -> usize { + let bits = self.bit_len(); + if bits <= 7 { + 1 + } else { + let bytes = (bits + 7) / 8; + bytes + length_of_length(bytes) + } + } + + #[inline] + fn encode(&self, out: &mut dyn BufMut) { + // fast paths, avoiding allocation due to `to_be_bytes_vec` + match LIMBS { + 0 => return out.put_u8(EMPTY_STRING_CODE), + 1 => return self.limbs[0].encode(out), + #[allow(clippy::cast_lossless)] + 2 => return (self.limbs[0] as u128 | ((self.limbs[1] as u128) << 64)).encode(out), + _ => {} + } + + match self.bit_len() { + 0 => out.put_u8(EMPTY_STRING_CODE), + 1..=7 => { + #[allow(clippy::cast_possible_truncation)] // self < 128 + out.put_u8(self.limbs[0] as u8); + } + bits => { + // avoid heap allocation in `to_be_bytes_vec` + // SAFETY: we don't re-use `copy` + #[cfg(target_endian = "little")] + let mut copy = *self; + #[cfg(target_endian = "little")] + let bytes = unsafe { copy.as_le_slice_mut() }; + #[cfg(target_endian = "little")] + bytes.reverse(); + + #[cfg(target_endian = "big")] + let bytes = self.to_be_bytes_vec(); + + let leading_zero_bytes = Self::BYTES - (bits + 7) / 8; + let trimmed = &bytes[leading_zero_bytes..]; + if bits > MAX_BITS { + trimmed.encode(out); + } else { + #[allow(clippy::cast_possible_truncation)] // bytes.len() < 56 < 256 + out.put_u8(EMPTY_STRING_CODE + trimmed.len() as u8); + out.put_slice(trimmed); + } + } + } + } +} + +/// Allows a [`Uint`] to be deserialized from RLP. +/// +/// See +impl Decodable for Uint { + #[inline] + fn decode(buf: &mut &[u8]) -> Result { + let bytes = Header::decode_bytes(buf, false)?; + Self::try_from_be_slice(bytes).ok_or(Error::Overflow) + } +} + +#[cfg(feature = "generic_const_exprs")] +unsafe impl + MaxEncodedLen<{ Self::BYTES + length_of_length(Self::BYTES) }> for Uint +{ +} + +#[cfg(not(feature = "generic_const_exprs"))] +const _: () = { + crate::const_for!(BITS in [0, 1, 2, 8, 16, 32, 64, 128, 160, 192, 256, 384, 512, 4096] { + const LIMBS: usize = crate::nlimbs(BITS); + const BYTES: usize = Uint::::BYTES; + unsafe impl MaxEncodedLen<{ BYTES + length_of_length(BYTES) }> for Uint {} + }); +}; + +unsafe impl MaxEncodedLenAssoc for Uint { + const LEN: usize = Self::BYTES + length_of_length(Self::BYTES); +} + +#[cfg(test)] +mod test { + use super::*; + use crate::{ + aliases::{U0, U256}, + const_for, nlimbs, + }; + use hex_literal::hex; + use proptest::proptest; + + fn encode(value: T) -> Vec { + let mut buf = vec![]; + value.encode(&mut buf); + buf + } + + #[test] + fn test_rlp() { + // See + assert_eq!(encode(U0::from(0))[..], hex!("80")); + assert_eq!(encode(U256::from(0))[..], hex!("80")); + assert_eq!(encode(U256::from(15))[..], hex!("0f")); + assert_eq!(encode(U256::from(1024))[..], hex!("820400")); + assert_eq!(encode(U256::from(0x1234_5678))[..], hex!("8412345678")); + } + + #[test] + fn test_roundtrip() { + const_for!(BITS in SIZES { + const LIMBS: usize = nlimbs(BITS); + proptest!(|(value: Uint)| { + let serialized = encode(value); + + #[cfg(feature = "rlp")] + { + use rlp::Encodable as _; + let serialized_rlp = value.rlp_bytes(); + assert_eq!(serialized, serialized_rlp.freeze()[..]); + } + + assert_eq!(serialized.len(), value.length()); + let mut reader = &serialized[..]; + let deserialized = Uint::decode(&mut reader).unwrap(); + assert_eq!(reader.len(), 0); + assert_eq!(value, deserialized); + }); + }); + } +} diff --git a/src/support/arbitrary.rs b/src/support/arbitrary.rs index efc3a8b..dc52b82 100644 --- a/src/support/arbitrary.rs +++ b/src/support/arbitrary.rs @@ -1,6 +1,8 @@ //! Support for the [`arbitrary`](https://crates.io/crates/arbitrary) crate. + #![cfg(feature = "arbitrary")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "arbitrary")))] +#![cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] + use crate::Uint; use arbitrary::{Arbitrary, Result, Unstructured}; diff --git a/src/support/ark_ff.rs b/src/support/ark_ff.rs index eb37dd9..f218da9 100644 --- a/src/support/ark_ff.rs +++ b/src/support/ark_ff.rs @@ -1,6 +1,7 @@ //! Support for the [`ark-ff`](https://crates.io/crates/ark-ff) crate. + #![cfg(feature = "ark-ff")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "ark-ff")))] +#![cfg_attr(docsrs, doc(cfg(feature = "ark-ff")))] use crate::{ToFieldError, Uint}; use ark_ff::{ diff --git a/src/support/bn_rs.rs b/src/support/bn_rs.rs index 07b1ddf..e55543c 100644 --- a/src/support/bn_rs.rs +++ b/src/support/bn_rs.rs @@ -1,6 +1,7 @@ //! Support for the [`bn-rs`](https://crates.io/crates/bn-rs) crate. + #![cfg(feature = "bn-rs")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "bn-rs")))] +#![cfg_attr(docsrs, doc(cfg(feature = "bn-rs")))] use crate::{from::ToUintError, BaseConvertError, Bits, ParseError, Uint}; use bn_rs::{BigNumber, BN}; diff --git a/src/support/fastrlp.rs b/src/support/fastrlp.rs index abb89fa..c2ab8a3 100644 --- a/src/support/fastrlp.rs +++ b/src/support/fastrlp.rs @@ -1,51 +1,70 @@ //! Support for the [`fastrlp`](https://crates.io/crates/fastrlp) crate. + #![cfg(feature = "fastrlp")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "fastrlp")))] +#![cfg_attr(docsrs, doc(cfg(feature = "fastrlp")))] use crate::Uint; -use core::mem::size_of; -use fastrlp::{BufMut, Decodable, DecodeError, Encodable, Header}; +use fastrlp::{ + length_of_length, BufMut, Decodable, DecodeError, Encodable, Header, MaxEncodedLen, + MaxEncodedLenAssoc, EMPTY_STRING_CODE, +}; + +const MAX_BITS: usize = 55 * 8; /// Allows a [`Uint`] to be serialized as RLP. /// /// See impl Encodable for Uint { + #[inline] fn length(&self) -> usize { let bits = self.bit_len(); - match bits { - n if n <= 7 => 1, - n if n <= 55 * 8 => 1 + (n + 7) / 8, - n => { - let bytes = (n + 7) / 8; - let len_bytes = size_of::() - bytes.leading_zeros() as usize / 8; - 1 + len_bytes + bytes - } + if bits <= 7 { + 1 + } else { + let bytes = (bits + 7) / 8; + bytes + length_of_length(bytes) } } + #[inline] fn encode(&self, out: &mut dyn BufMut) { + // fast paths, avoiding allocation due to `to_be_bytes_vec` + match LIMBS { + 0 => return out.put_u8(EMPTY_STRING_CODE), + 1 => return self.limbs[0].encode(out), + #[allow(clippy::cast_lossless)] + 2 => return (self.limbs[0] as u128 | ((self.limbs[1] as u128) << 64)).encode(out), + _ => {} + } + match self.bit_len() { - 0 => out.put_u8(0x80), - n if n <= 7 => { + 0 => out.put_u8(EMPTY_STRING_CODE), + 1..=7 => { #[allow(clippy::cast_possible_truncation)] // self < 128 - out.put_u8(self.as_limbs()[0] as u8); - } - n if n <= 55 * 8 => { - let bytes = self.to_be_bytes_vec(); - let bytes = trim_leading_zeros(&bytes); - #[allow(clippy::cast_possible_truncation)] // bytes.len() < 56 < 256 - out.put_u8(0x80 + bytes.len() as u8); - out.put_slice(bytes); + out.put_u8(self.limbs[0] as u8); } - _ => { + bits => { + // avoid heap allocation in `to_be_bytes_vec` + // SAFETY: we don't re-use `copy` + #[cfg(target_endian = "little")] + let mut copy = *self; + #[cfg(target_endian = "little")] + let bytes = unsafe { copy.as_le_slice_mut() }; + #[cfg(target_endian = "little")] + bytes.reverse(); + + #[cfg(target_endian = "big")] let bytes = self.to_be_bytes_vec(); - let bytes = trim_leading_zeros(&bytes); - let length_bytes = bytes.len().to_be_bytes(); - let length_bytes = trim_leading_zeros(&length_bytes); - #[allow(clippy::cast_possible_truncation)] // length_bytes.len() <= 8 - out.put_u8(0xb7 + length_bytes.len() as u8); - out.put_slice(length_bytes); - out.put_slice(bytes); + + let leading_zero_bytes = Self::BYTES - (bits + 7) / 8; + let trimmed = &bytes[leading_zero_bytes..]; + if bits > MAX_BITS { + trimmed.encode(out); + } else { + #[allow(clippy::cast_possible_truncation)] // bytes.len() < 56 < 256 + out.put_u8(EMPTY_STRING_CODE + trimmed.len() as u8); + out.put_slice(trimmed); + } } } } @@ -55,6 +74,7 @@ impl Encodable for Uint { /// /// See impl Decodable for Uint { + #[inline] fn decode(buf: &mut &[u8]) -> Result { let header = Header::decode(buf)?; if header.list { @@ -66,9 +86,23 @@ impl Decodable for Uint { } } -fn trim_leading_zeros(bytes: &[u8]) -> &[u8] { - let zeros = bytes.iter().position(|&b| b != 0).unwrap_or(bytes.len()); - &bytes[zeros..] +#[cfg(feature = "generic_const_exprs")] +unsafe impl + MaxEncodedLen<{ Self::BYTES + length_of_length(Self::BYTES) }> for Uint +{ +} + +#[cfg(not(feature = "generic_const_exprs"))] +const _: () = { + crate::const_for!(BITS in [0, 1, 2, 8, 16, 32, 64, 128, 160, 192, 256, 384, 512, 4096] { + const LIMBS: usize = crate::nlimbs(BITS); + const BYTES: usize = Uint::::BYTES; + unsafe impl MaxEncodedLen<{ BYTES + length_of_length(BYTES) }> for Uint {} + }); +}; + +unsafe impl MaxEncodedLenAssoc for Uint { + const LEN: usize = Self::BYTES + length_of_length(Self::BYTES); } #[cfg(test)] @@ -103,6 +137,14 @@ mod test { const LIMBS: usize = nlimbs(BITS); proptest!(|(value: Uint)| { let serialized = encode(value); + + #[cfg(feature = "rlp")] + { + use rlp::Encodable as _; + let serialized_rlp = value.rlp_bytes(); + assert_eq!(serialized, serialized_rlp.freeze()[..]); + } + assert_eq!(serialized.len(), value.length()); let mut reader = &serialized[..]; let deserialized = Uint::decode(&mut reader).unwrap(); @@ -111,20 +153,4 @@ mod test { }); }); } - - #[test] - #[cfg(feature = "rlp")] - fn test_rlp_fastrlp_compat() { - use rlp::Encodable; - - const_for!(BITS in SIZES { - const LIMBS: usize = nlimbs(BITS); - proptest!(|(value: Uint)| { - let serialized = encode(value); - let serialized_rlp = value.rlp_bytes(); - assert_eq!(serialized, serialized_rlp); - // We already test that they can deserialize from this. - }); - }); - } } diff --git a/src/support/mod.rs b/src/support/mod.rs index 680d5c3..32a95de 100644 --- a/src/support/mod.rs +++ b/src/support/mod.rs @@ -1,18 +1,21 @@ +//! Support for external crates. + +mod alloy_rlp; mod arbitrary; mod ark_ff; mod bn_rs; mod fastrlp; mod num_bigint; -mod postgres; +pub mod postgres; mod primitive_types; mod proptest; mod pyo3; mod quickcheck; mod rand; mod rlp; -mod scale; +pub mod scale; mod serde; -mod sqlx; +pub mod sqlx; mod valuable; mod zeroize; diff --git a/src/support/num_bigint.rs b/src/support/num_bigint.rs index c6b3aa8..035aabb 100644 --- a/src/support/num_bigint.rs +++ b/src/support/num_bigint.rs @@ -1,6 +1,7 @@ //! Support for the [`num-bigint`](https://crates.io/crates/num-bigint) crate. + #![cfg(feature = "num-bigint")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "num-bigint")))] +#![cfg_attr(docsrs, doc(cfg(feature = "num-bigint")))] use crate::{from::ToUintError, Uint}; use num_bigint::{BigInt, BigUint, Sign}; diff --git a/src/support/postgres.rs b/src/support/postgres.rs index 373624f..f12cb00 100644 --- a/src/support/postgres.rs +++ b/src/support/postgres.rs @@ -1,6 +1,7 @@ //! Support for the [`postgres`](https://crates.io/crates/postgres) crate. + #![cfg(feature = "postgres")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "postgres")))] +#![cfg_attr(docsrs, doc(cfg(feature = "postgres")))] use crate::{ utils::{rem_up, trim_end_vec}, diff --git a/src/support/primitive_types.rs b/src/support/primitive_types.rs index 902688a..f4d20fe 100644 --- a/src/support/primitive_types.rs +++ b/src/support/primitive_types.rs @@ -1,6 +1,7 @@ //! Support for the [`primitive-types`](https://crates.io/crates/primitive-types) crate. + #![cfg(feature = "primitive-types")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "primitive-types")))] +#![cfg_attr(docsrs, doc(cfg(feature = "primitive-types")))] use crate::aliases as ours; use primitive_types::{H128, H160, H256, H512, U128, U256, U512}; diff --git a/src/support/proptest.rs b/src/support/proptest.rs index 24b41b1..5f79803 100644 --- a/src/support/proptest.rs +++ b/src/support/proptest.rs @@ -1,50 +1,45 @@ //! Support for the [`proptest`](https://crates.io/crates/proptest) crate. + #![cfg(feature = "proptest")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "proptest")))] +#![cfg_attr(docsrs, doc(cfg(feature = "proptest")))] -use crate::{nlimbs, Bits, Uint}; -use proptest::{ - arbitrary::Arbitrary, - collection::{vec, VecStrategy}, - num::u64::Any, - strategy::{BoxedStrategy, Strategy}, -}; +use crate::{Bits, Uint}; +use proptest::{arbitrary::Mapped, prelude::*}; impl Arbitrary for Uint { // FEATURE: Would be nice to have a value range as parameter // and/or a choice between uniform and 'exponential' distribution. type Parameters = (); - type Strategy = BoxedStrategy; - - fn arbitrary_with(_: Self::Parameters) -> BoxedStrategy { - // OPT: Copy [`UniformArrayStrategy`] to avoid heap allocations - let limbs: VecStrategy = vec(u64::arbitrary(), nlimbs(BITS)); - limbs - .prop_map(|mut limbs| { - if Self::LIMBS > 0 { - limbs[Self::LIMBS - 1] &= Self::MASK; - } - Self::from_limbs_slice(&limbs) - }) - .boxed() + type Strategy = Mapped<[u64; LIMBS], Self>; + + #[inline] + fn arbitrary() -> Self::Strategy { + Self::arbitrary_with(()) + } + + fn arbitrary_with((): Self::Parameters) -> Self::Strategy { + any::<[u64; LIMBS]>().prop_map(|mut limbs| { + if LIMBS > 0 { + limbs[LIMBS - 1] &= Self::MASK; + } + Self::from_limbs(limbs) + }) } } impl Arbitrary for Bits { type Parameters = as Arbitrary>::Parameters; - type Strategy = BoxedStrategy; + type Strategy = Mapped, Self>; fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { - Uint::::arbitrary_with(args) - .prop_map(Self::from) - .boxed() + Uint::::arbitrary_with(args).prop_map(Self::from) } } #[cfg(test)] mod tests { use super::*; - use crate::const_for; + use crate::{const_for, nlimbs}; use proptest::proptest; #[test] diff --git a/src/support/pyo3.rs b/src/support/pyo3.rs index a9befd1..42b22ac 100644 --- a/src/support/pyo3.rs +++ b/src/support/pyo3.rs @@ -19,8 +19,9 @@ //! //! [num]: https://github.com/PyO3/pyo3/blob/caaf7bbda74f873297d277733c157338f5492580/src/types/num.rs#L81 //! [bigint]: https://github.com/PyO3/pyo3/blob/4a68273b173ef86dac059106cc0b5b3c2c9830e2/src/conversions/num_bigint.rs#L80 + #![cfg(feature = "pyo3")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "pyo3")))] +#![cfg_attr(docsrs, doc(cfg(feature = "pyo3")))] use crate::Uint; use pyo3::{ diff --git a/src/support/quickcheck.rs b/src/support/quickcheck.rs index be1205f..0436902 100644 --- a/src/support/quickcheck.rs +++ b/src/support/quickcheck.rs @@ -1,6 +1,7 @@ //! Support for the [`quickcheck`](https://crates.io/crates/quickcheck) crate. + #![cfg(feature = "quickcheck")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "quickcheck")))] +#![cfg_attr(docsrs, doc(cfg(feature = "quickcheck")))] use crate::Uint; use quickcheck::{Arbitrary, Gen}; diff --git a/src/support/rand.rs b/src/support/rand.rs index 2267e9c..d79af0e 100644 --- a/src/support/rand.rs +++ b/src/support/rand.rs @@ -1,6 +1,7 @@ //! Support for the [`rand`](https://crates.io/crates/rand) crate. + #![cfg(feature = "rand")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "rand")))] +#![cfg_attr(docsrs, doc(cfg(feature = "rand")))] // FEATURE: Implement the Uniform distribution. diff --git a/src/support/rlp.rs b/src/support/rlp.rs index 2612c12..772bbba 100644 --- a/src/support/rlp.rs +++ b/src/support/rlp.rs @@ -1,6 +1,7 @@ //! Support for the [`rlp`](https://crates.io/crates/rlp) crate. + #![cfg(feature = "rlp")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "rlp")))] +#![cfg_attr(docsrs, doc(cfg(feature = "rlp")))] use crate::{Bits, Uint}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; @@ -33,6 +34,7 @@ impl Decodable for Uint { /// /// See impl Encodable for Bits { + #[allow(clippy::collection_is_never_read)] // have to use vec fn rlp_append(&self, s: &mut RlpStream) { #[allow(clippy::collection_is_never_read)] let bytes = self.to_be_bytes_vec(); diff --git a/src/support/scale.rs b/src/support/scale.rs index 87d137a..3ba9bab 100644 --- a/src/support/scale.rs +++ b/src/support/scale.rs @@ -1,6 +1,7 @@ //! Support for the [`parity-scale-codec`](https://crates.io/crates/parity-scale-codec) crate. + #![cfg(feature = "parity-scale-codec")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "parity-scale-codec")))] +#![cfg_attr(docsrs, doc(cfg(feature = "parity-scale-codec")))] use crate::Uint; use parity_scale_codec::{ @@ -266,13 +267,8 @@ fn assert_compact_supported() { #[cfg(test)] mod tests { - use crate::{ - aliases::U256, - const_for, nlimbs, - support::scale::{CompactRefUint, CompactUint}, - Uint, - }; - use parity_scale_codec::{Compact, Decode, Encode}; + use super::*; + use crate::{aliases::U256, const_for, nlimbs, Uint}; use proptest::proptest; #[test] diff --git a/src/support/serde.rs b/src/support/serde.rs index 675a65b..d9a2751 100644 --- a/src/support/serde.rs +++ b/src/support/serde.rs @@ -1,6 +1,7 @@ //! Support for the [`serde`](https://crates.io/crates/serde) crate. + #![cfg(feature = "serde")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "serde")))] +#![cfg_attr(docsrs, doc(cfg(feature = "serde")))] use crate::{nbytes, Bits, Uint}; use core::fmt::{Formatter, Result as FmtResult}; diff --git a/src/support/sqlx.rs b/src/support/sqlx.rs index fc33b62..c113f87 100644 --- a/src/support/sqlx.rs +++ b/src/support/sqlx.rs @@ -1,8 +1,9 @@ //! Support for the [`sqlx`](https://crates.io/crates/sqlx) crate. //! //! Currently only encodes to/from a big-endian byte array. + #![cfg(feature = "sqlx")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "sqlx")))] +#![cfg_attr(docsrs, doc(cfg(feature = "sqlx")))] use crate::Uint; use sqlx_core::{ @@ -15,7 +16,7 @@ use sqlx_core::{ use thiserror::Error; #[derive(Error, Debug)] -enum DecodeError { +pub enum DecodeError { #[error("Value too large for target type")] Overflow, } diff --git a/src/support/valuable.rs b/src/support/valuable.rs index d72abd2..db5520a 100644 --- a/src/support/valuable.rs +++ b/src/support/valuable.rs @@ -1,6 +1,7 @@ //! Support for the [`valuable`](https://crates.io/crates/valuable) crate. + #![cfg(feature = "valuable")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "valuable")))] +#![cfg_attr(docsrs, doc(cfg(feature = "valuable")))] use crate::Uint; use valuable::{Fields, NamedField, NamedValues, StructDef, Structable, Valuable, Value, Visit}; diff --git a/src/support/zeroize.rs b/src/support/zeroize.rs index 83ce144..8d06521 100644 --- a/src/support/zeroize.rs +++ b/src/support/zeroize.rs @@ -1,8 +1,9 @@ //! Support for the [`zeroize`](https://crates.io/crates/zeroize) crate. //! //! Currently only encodes to/from a big-endian byte array. + #![cfg(feature = "zeroize")] -#![cfg_attr(has_doc_cfg, doc(cfg(feature = "zeroize")))] +#![cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] use crate::{Bits, Uint}; use zeroize::Zeroize; diff --git a/src/uint_dyn/mod.rs b/src/uint_dyn/mod.rs deleted file mode 100644 index f06ba69..0000000 --- a/src/uint_dyn/mod.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![cfg(feature = "dyn")] -#![cfg(feature = "unstable")] -use smallvec::SmallVec; - -/// ⚠️ Dynamically sized unsigned integer type. -/// -/// **Warning.** This is not part of the stable API. -/// -/// *Warning* This type is unstable can break in semver-compatible minor -/// releases. -pub struct UintDyn { - _bit_len: usize, - // OPT: `bit_len` and the size in SmallVec are redundant. - _limbs: SmallVec<[u64; 2]>, -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::Uint; - - #[test] - fn test_sizes() { - // UintDyn has one word overhead, but two words free compared to plain Vec. - dbg!(std::mem::size_of::>()); - dbg!(std::mem::size_of::>()); - dbg!(std::mem::size_of::>()); - dbg!(std::mem::size_of::()); - } -} diff --git a/src/utils.rs b/src/utils.rs index 9af450f..91c66b0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -25,17 +25,31 @@ pub(crate) fn trim_end_vec(vec: &mut Vec, value: &T) { } } -#[cfg(has_core_intrinsics)] -pub use core::intrinsics::{likely, unlikely}; +// Branch prediction hints. +#[cfg(feature = "nightly")] +pub(crate) use core::intrinsics::{likely, unlikely}; -#[cfg(not(has_core_intrinsics))] +// On stable we can use #[cold] to get a equivalent effect: this attribute +// suggests that the function is unlikely to be called +#[cfg(not(feature = "nightly"))] #[inline(always)] -pub const fn unlikely(b: bool) -> bool { +#[cold] +const fn cold() {} + +#[cfg(not(feature = "nightly"))] +#[inline(always)] +pub(crate) const fn likely(b: bool) -> bool { + if !b { + cold(); + } b } -#[cfg(not(has_core_intrinsics))] +#[cfg(not(feature = "nightly"))] #[inline(always)] -pub const fn likely(b: bool) -> bool { +pub(crate) const fn unlikely(b: bool) -> bool { + if b { + cold(); + } b }