diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0b92af0f..21f480f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: Install rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: 1.79.0 components: rustfmt, clippy - name: Install dprint @@ -66,7 +66,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - run: sudo add-apt-repository ppa:ethereum/ethereum + # - run: sudo add-apt-repository ppa:ethereum/ethereum - run: sudo apt-get update -y - name: Install deps run: sudo apt-get install -y musl-dev musl-tools solc @@ -74,7 +74,7 @@ jobs: - name: Install rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: 1.79.0 components: clippy target: x86_64-unknown-linux-musl override: true @@ -118,12 +118,14 @@ jobs: test: needs: [rustfmt] runs-on: self-hosted + env: + CLIPPY_FLAGS: -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions name: cargo test --workspace --all-features steps: - name: Checkout sources uses: actions/checkout@v4 - - run: sudo add-apt-repository ppa:ethereum/ethereum + # - run: sudo add-apt-repository ppa:ethereum/ethereum - run: sudo apt-get update -y - name: Install deps run: sudo apt-get install -y musl-dev musl-tools solc @@ -131,7 +133,7 @@ jobs: - name: Install rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: 1.79.0 components: clippy target: wasm32-unknown-unknown override: true @@ -146,15 +148,18 @@ jobs: --exclude rosetta-server-polkadot \ --exclude rosetta-client \ -- \ - -Dwarnings \ - -Dclippy::unwrap_used \ - -Dclippy::expect_used \ - -Dclippy::nursery \ - -Dclippy::pedantic \ - -Aclippy::module_name_repetitions + ${CLIPPY_FLAGS} + + - name: check.sh --fmt + run: ./scripts/check.sh --fmt - - name: ethereum-types no-std - run: cargo build --locked -p rosetta-ethereum-types --no-default-features --target wasm32-unknown-unknown + # Test crates with different feature flags, including wasm32-unknown-unknown + # This is done to ensure that those libraries can be used inside the substrate runtime + - name: check.sh --eth-types + run: ./scripts/check.sh --eth-types + + - name: check.sh --eth-backend + run: ./scripts/check.sh --eth-backend - name: Pull nodes run: ./scripts/pull_nodes.sh diff --git a/Cargo.lock b/Cargo.lock index 155c374b..d94661e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,19 +23,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ - "gimli 0.29.0", + "gimli 0.31.0", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -156,17 +150,29 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alloy-json-abi" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9996daf962fd0a90d3c93b388033228865953b92de7bb1959b891d78750a4091" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + [[package]] name = "alloy-primitives" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" dependencies = [ "alloy-rlp", "bytes", "cfg-if", "const-hex", - "derive_more", + "derive_more 1.0.0", "hex-literal", "itoa", "k256", @@ -190,13 +196,13 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" +checksum = "0458ccb02a564228fcd76efb8eb5a520521a8347becde37b402afec9a1b83859" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", "syn 2.0.77", @@ -204,15 +210,15 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" +checksum = "2bc65475025fc1e84bf86fc840f04f63fcccdcf3cf12053c99918e4054dfbc69" dependencies = [ "alloy-sol-macro-input", "const-hex", "heck 0.5.0", "indexmap 2.5.0", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", "syn 2.0.77", @@ -222,9 +228,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" +checksum = "6ed10f0715a0b69fde3236ff3b9ae5f6f7c97db5a387747100070d3016b9266b" dependencies = [ "const-hex", "dunce", @@ -235,12 +241,23 @@ dependencies = [ "syn-solidity", ] +[[package]] +name = "alloy-sol-type-parser" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3edae8ea1de519ccba896b6834dec874230f72fe695ff3c9c118e90ec7cff783" +dependencies = [ + "serde", + "winnow 0.6.18", +] + [[package]] name = "alloy-sol-types" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" +checksum = "1eb88e4da0a1b697ed6a9f811fdba223cf4d5c21410804fd1707836af73a462b" dependencies = [ + "alloy-json-abi", "alloy-primitives", "alloy-sol-macro", "const-hex", @@ -273,9 +290,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "ark-bls12-377" @@ -543,9 +560,9 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" +checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ "async-task", "concurrent-queue", @@ -630,7 +647,7 @@ dependencies = [ "futures-lite 2.3.0", "parking", "polling 3.7.3", - "rustix 0.38.35", + "rustix 0.38.36", "slab", "tracing", "windows-sys 0.59.0", @@ -682,7 +699,7 @@ dependencies = [ "cfg-if", "event-listener 5.3.1", "futures-lite 2.3.0", - "rustix 0.38.35", + "rustix 0.38.36", "tracing", "windows-sys 0.59.0", ] @@ -699,7 +716,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.35", + "rustix 0.38.36", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -707,20 +724,20 @@ dependencies = [ [[package]] name = "async-std" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615" dependencies = [ "async-channel 1.9.0", "async-global-executor", - "async-io 1.13.0", - "async-lock 2.8.0", + "async-io 2.3.4", + "async-lock 3.4.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite 1.13.0", - "gloo-timers", + "futures-lite 2.3.0", + "gloo-timers 0.3.0", "kv-log-macro", "log", "memchr", @@ -803,17 +820,17 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ - "addr2line 0.22.0", - "cc", + "addr2line 0.24.1", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object 0.36.4", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -1117,9 +1134,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "jobserver", "libc", @@ -1394,9 +1411,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1736,6 +1753,27 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "unicode-xid", +] + [[package]] name = "digest" version = "0.9.0" @@ -2564,7 +2602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -2789,7 +2827,7 @@ version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" dependencies = [ - "gloo-timers", + "gloo-timers 0.2.6", "send_wrapper 0.4.0", ] @@ -2897,9 +2935,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "glob" @@ -2919,6 +2957,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "group" version = "0.13.0" @@ -3294,16 +3344,16 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.4.1", "hyper-util", "log", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -3312,9 +3362,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -3510,9 +3560,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "itertools" @@ -3653,7 +3703,7 @@ dependencies = [ "http 1.1.0", "jsonrpsee-core 0.23.2", "pin-project", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "rustls-platform-verifier", "soketto 0.8.0", @@ -3676,7 +3726,7 @@ dependencies = [ "http 1.1.0", "jsonrpsee-core 0.24.3", "pin-project", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "rustls-platform-verifier", "soketto 0.8.0", @@ -3787,11 +3837,11 @@ dependencies = [ "base64 0.22.1", "http-body 1.0.1", "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper-rustls 0.27.3", "hyper-util", "jsonrpsee-core 0.24.3", "jsonrpsee-types 0.24.3", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-platform-verifier", "serde", "serde_json", @@ -3906,9 +3956,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -4129,7 +4179,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.35", + "rustix 0.38.36", ] [[package]] @@ -4184,15 +4234,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -4584,9 +4625,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -4694,9 +4735,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" dependencies = [ "memchr", "thiserror", @@ -4933,7 +4974,7 @@ dependencies = [ "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.35", + "rustix 0.38.36", "tracing", "windows-sys 0.59.0", ] @@ -5058,6 +5099,28 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -5441,7 +5504,7 @@ version = "0.6.0" dependencies = [ "anyhow", "async-trait", - "derive_more", + "derive_more 0.99.18", "dirs-next", "fraction", "futures", @@ -5605,7 +5668,7 @@ dependencies = [ "rlp", "rlp-derive", "scale-info", - "secp256k1", + "secp256k1 0.29.1", "serde", "serde_json", "sha3", @@ -5949,9 +6012,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", @@ -5981,22 +6044,22 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "log", "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -6062,10 +6125,10 @@ dependencies = [ "jni", "log", "once_cell", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-native-certs 0.7.3", "rustls-platform-verifier-android", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "security-framework", "security-framework-sys", "webpki-roots 0.26.5", @@ -6090,9 +6153,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -6124,7 +6187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" dependencies = [ "byteorder", - "derive_more", + "derive_more 0.99.18", "twox-hash", ] @@ -6170,7 +6233,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" dependencies = [ - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "primitive-types", "scale-bits", @@ -6197,7 +6260,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ba0b9c48dc0eb20c60b083c29447c0c4617cb7c4a4c9fef72aa5c5bc539e15e" dependencies = [ - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "primitive-types", "scale-bits", @@ -6227,7 +6290,7 @@ checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "bitvec", "cfg-if", - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "scale-info-derive", "serde", @@ -6276,7 +6339,7 @@ checksum = "ba4d772cfb7569e03868400344a1695d16560bf62b86b918604773607d39ec84" dependencies = [ "base58", "blake2", - "derive_more", + "derive_more 0.99.18", "either", "frame-metadata 15.1.0", "parity-scale-codec", @@ -6291,11 +6354,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6377,7 +6440,16 @@ version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.9.2", +] + +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "secp256k1-sys 0.10.0", ] [[package]] @@ -6389,6 +6461,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +dependencies = [ + "cc", +] + [[package]] name = "secrecy" version = "0.8.0" @@ -6478,9 +6559,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -6496,9 +6577,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -6507,9 +6588,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -6662,9 +6743,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" dependencies = [ "cc", "cfg-if", @@ -6751,9 +6832,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smol" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aad24f41392790e6ac67f4f4cd871da61f7d758e07b5622431e491e897d9c8a7" +checksum = "a33bd3e260892199c3ccfc487c88b2da2265080acb316cd920da72fdfd7c599f" dependencies = [ "async-channel 2.3.1", "async-executor", @@ -6781,7 +6862,7 @@ dependencies = [ "bs58", "chacha20", "crossbeam-queue", - "derive_more", + "derive_more 0.99.18", "ed25519-zebra 4.0.3", "either", "event-listener 4.0.3", @@ -6831,7 +6912,7 @@ dependencies = [ "async-lock 3.4.0", "base64 0.21.7", "blake2-rfc", - "derive_more", + "derive_more 0.99.18", "either", "event-listener 4.0.3", "fnv", @@ -6980,7 +7061,7 @@ dependencies = [ "rand 0.8.5", "scale-info", "schnorrkel", - "secp256k1", + "secp256k1 0.28.2", "secrecy", "serde", "sp-crypto-hashing", @@ -7047,7 +7128,7 @@ dependencies = [ "parity-scale-codec", "polkavm-derive 0.9.1", "rustversion", - "secp256k1", + "secp256k1 0.28.2", "sp-core", "sp-crypto-hashing", "sp-externalities", @@ -7668,9 +7749,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" +checksum = "4b95156f8b577cb59dc0b1df15c6f29a10afc5f8a7ac9786b0b5c68c19149278" dependencies = [ "paste", "proc-macro2", @@ -7737,7 +7818,7 @@ dependencies = [ "cfg-if", "fastrand 2.1.1", "once_cell", - "rustix 0.38.35", + "rustix 0.38.36", "windows-sys 0.59.0", ] @@ -7961,16 +8042,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -8002,7 +8083,7 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", "tokio-native-tls", @@ -8013,9 +8094,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -8271,7 +8352,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "sha1 0.10.6", "thiserror", @@ -9120,7 +9201,7 @@ checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", "linux-raw-sys 0.4.14", - "rustix 0.38.35", + "rustix 0.38.36", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ca9a9ca0..bb605535 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ rosetta-utils = { path = "rosetta-utils", default-features = false } ## Crates we want all members to use the same version jsonrpsee = { version = "0.24", default-features = false } parity-scale-codec = { version = "3.6" } -tokio = { version = "1.37" } +tokio = { version = "1.40" } subxt = { version = "0.37", default-features = false } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } diff --git a/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml b/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml index 462cc50c..c530f03f 100644 --- a/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml +++ b/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/analog-labs/chain-connectors" description = "Arbitrum unit test." [dev-dependencies] -alloy-sol-types = { version = "0.7" } +alloy-sol-types = { version = "0.8" } anyhow = "1.0" ethers = { version = "2.0", default-features = true, features = ["abigen", "rustls", "ws"] } ethers-solc = "2.0" diff --git a/chains/astar/server/Cargo.toml b/chains/astar/server/Cargo.toml index 460e663b..9ef9257b 100644 --- a/chains/astar/server/Cargo.toml +++ b/chains/astar/server/Cargo.toml @@ -17,7 +17,7 @@ parity-scale-codec = { workspace = true, features = ["derive"] } rosetta-config-astar = { workspace = true, features = ["astar-metadata"] } rosetta-config-ethereum.workspace = true rosetta-core.workspace = true -rosetta-server = { workspace = true, features = ["ws", "webpki-tls"] } +rosetta-server = { workspace = true, features = ["webpki-tls"] } rosetta-server-ethereum.workspace = true serde.workspace = true serde_json.workspace = true @@ -26,8 +26,8 @@ subxt = { workspace = true, features = ["substrate-compat"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } [dev-dependencies] -alloy-primitives = { version = "0.7" } -alloy-sol-types = { version = "0.7" } +alloy-primitives = { version = "0.8" } +alloy-sol-types = { version = "0.8" } ethers-solc = "2.0" rosetta-client.workspace = true rosetta-docker = { workspace = true, features = ["tests"] } diff --git a/chains/binance/Cargo.toml b/chains/binance/Cargo.toml index 6e59d2b6..f8a34ded 100644 --- a/chains/binance/Cargo.toml +++ b/chains/binance/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/analog-labs/chain-connectors" description = "binance rosetta test." [dependencies] -alloy-sol-types = { version = "0.7" } +alloy-sol-types = { version = "0.8" } anyhow = "1.0" ethers = { version = "2.0", default-features = true, features = ["abigen", "rustls", "ws"] } ethers-solc = "2.0" diff --git a/chains/ethereum/backend/Cargo.toml b/chains/ethereum/backend/Cargo.toml index 6dcc609e..60d6c34e 100644 --- a/chains/ethereum/backend/Cargo.toml +++ b/chains/ethereum/backend/Cargo.toml @@ -15,11 +15,11 @@ parity-scale-codec = { workspace = true, features = ["derive"], optional = true rosetta-ethereum-types = { workspace = true, features = ["with-rlp", "with-crypto"] } scale-info = { version = "2.9", default-features = false, features = ["derive"], optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } -serde_json = { version = "1.0", default-features = false, optional = true } +serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true } [dev-dependencies] hex-literal = "0.4" -serde_json = { version = "1.0", default-features = false } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } [features] default = ["std", "jsonrpsee"] diff --git a/chains/ethereum/backend/src/block_range.rs b/chains/ethereum/backend/src/block_range.rs index f7066b59..16953a41 100644 --- a/chains/ethereum/backend/src/block_range.rs +++ b/chains/ethereum/backend/src/block_range.rs @@ -1,3 +1,4 @@ +use crate::rstd::vec::Vec; use rosetta_ethereum_types::{Address, AtBlock, BlockIdentifier, H256}; /// Represents the target range of blocks for the filter diff --git a/chains/ethereum/backend/src/lib.rs b/chains/ethereum/backend/src/lib.rs index 22c8d018..ff9dffe2 100644 --- a/chains/ethereum/backend/src/lib.rs +++ b/chains/ethereum/backend/src/lib.rs @@ -36,22 +36,30 @@ pub mod ext { #[cfg(feature = "std")] pub(crate) mod rstd { #[cfg(feature = "jsonrpsee")] - pub use std::{ops, str, string, vec}; + pub use std::{ops, string}; + + pub mod vec { + pub use std::vec::*; + } pub mod sync { pub use std::sync::Arc; } - pub use std::{borrow, boxed, fmt, marker}; + pub use std::{borrow, boxed, fmt, marker, str}; } #[cfg(not(feature = "std"))] pub(crate) mod rstd { #[cfg(feature = "jsonrpsee")] - pub use alloc::{string, vec}; + pub use alloc::string; #[cfg(feature = "jsonrpsee")] pub use core::ops; + pub mod vec { + pub use alloc::vec::*; + } + pub mod sync { pub use alloc::sync::Arc; } @@ -66,6 +74,7 @@ use rstd::{ marker::Sized, str, sync::Arc, + vec::Vec, }; /// Exit reason diff --git a/chains/ethereum/backend/src/serde_util.rs b/chains/ethereum/backend/src/serde_util.rs index f9c9c145..09987135 100644 --- a/chains/ethereum/backend/src/serde_util.rs +++ b/chains/ethereum/backend/src/serde_util.rs @@ -1,3 +1,4 @@ +use crate::rstd::vec::Vec; use serde::Deserialize; /// Helper type for deserialize a single value or a vector of values @@ -12,7 +13,7 @@ pub(crate) enum ValueOrArray { /// Helper for parse/serialize `Vec` to `Vec`, `T` or `None` depending on the number of /// elements. Must be used with `#[serde(with = "opt_value_or_array")]` pub mod opt_value_or_array { - use super::ValueOrArray; + use super::{ValueOrArray, Vec}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// # Errors diff --git a/chains/ethereum/config/src/util.rs b/chains/ethereum/config/src/util.rs index 34e9ac3f..84084262 100644 --- a/chains/ethereum/config/src/util.rs +++ b/chains/ethereum/config/src/util.rs @@ -72,7 +72,7 @@ macro_rules! impl_wrapper { fn decode_into(input: &mut I, dst: &mut core::mem::MaybeUninit) -> crate::rstd::result::Result { // Safety: Self is repr(transparent) over the inner type, so have the same ABI and memory layout, we can safely cast it let dst = unsafe { - &mut *(dst as *mut core::mem::MaybeUninit<$name>).cast::>() + &mut *core::ptr::from_mut::>(dst).cast::>() }; <$original as parity_scale_codec::Decode>::decode_into(input, dst) } @@ -97,7 +97,7 @@ macro_rules! impl_wrapper { unsafe { // Safety: $name is repr(transparent) over the $original type, so have the same ABI as the original // so can safely cast it - &*(value as *const $original).cast::<$name>() + &*core::ptr::from_ref::<$original>(value).cast::<$name>() } } } @@ -107,7 +107,7 @@ macro_rules! impl_wrapper { unsafe { // Safety: $name is repr(transparent) over the $original type, so have the same ABI as the original // so can safely cast it - &mut *(value as *mut $original).cast::<$name>() + &mut *core::ptr::from_mut::<$original>(value).cast::<$name>() } } } @@ -123,7 +123,7 @@ macro_rules! impl_wrapper { unsafe { // Safety: $name is repr(transparent) over the $original type, so have the same ABI as the original // so can safely cast it - &*(value as *const $name).cast::<$original>() + &*core::ptr::from_ref::<$name>(value).cast::<$original>() } } } @@ -133,7 +133,7 @@ macro_rules! impl_wrapper { unsafe { // Safety: $name is repr(transparent) over the $original type, so have the same ABI as the original // so can safely cast it - &mut *(value as *mut $name).cast::<$original>() + &mut *core::ptr::from_mut::<$name>(value).cast::<$original>() } } } diff --git a/chains/ethereum/server/Cargo.toml b/chains/ethereum/server/Cargo.toml index 14abe039..7bb46f2d 100644 --- a/chains/ethereum/server/Cargo.toml +++ b/chains/ethereum/server/Cargo.toml @@ -20,7 +20,7 @@ pin-project = { version = "1.1" } rosetta-config-ethereum.workspace = true rosetta-core.workspace = true rosetta-ethereum-backend = { workspace = true, features = ["jsonrpsee"] } -rosetta-server = { workspace = true, features = ["ws", "webpki-tls"] } +rosetta-server = { workspace = true, features = ["webpki-tls"] } rosetta-utils = { workspace = true, features = ["std", "jsonrpsee"] } serde.workspace = true serde_json.workspace = true @@ -31,8 +31,8 @@ tracing = "0.1" url = "2.4" [dev-dependencies] -alloy-primitives = { version = "0.7" } -alloy-sol-types = { version = "0.7" } +alloy-primitives = { version = "0.8" } +alloy-sol-types = { version = "0.8" } ethers-solc = "2.0" rosetta-client.workspace = true rosetta-docker = { workspace = true, features = ["tests"] } diff --git a/chains/ethereum/types/Cargo.toml b/chains/ethereum/types/Cargo.toml index 4e127b79..873bf877 100644 --- a/chains/ethereum/types/Cargo.toml +++ b/chains/ethereum/types/Cargo.toml @@ -30,7 +30,7 @@ libsecp256k1 = { version = "0.7", default-features = false, features = ["static- parity-scale-codec = { workspace = true, features = ["derive", "bytes"], optional = true } rlp = { version = "0.5", default-features = false, optional = true } scale-info = { version = "2.9", default-features = false, features = ["derive"], optional = true } -secp256k1 = { version = "0.28", default-features = false, features = ["alloc", "recovery"], optional = true } +secp256k1 = { version = "0.29", default-features = false, features = ["alloc", "recovery"], optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } sha3 = { version = "0.10", default-features = false, optional = true } diff --git a/chains/ethereum/types/src/i256.rs b/chains/ethereum/types/src/i256.rs index 9ce2660d..20bcb661 100644 --- a/chains/ethereum/types/src/i256.rs +++ b/chains/ethereum/types/src/i256.rs @@ -140,20 +140,6 @@ impl I256 { Self(U256::MAX) } - /// The maximum value which can be inhabited by this type. - #[inline(always)] - #[must_use] - pub const fn max_value() -> Self { - Self::MAX - } - - /// The minimum value which can be inhabited by this type. - #[inline(always)] - #[must_use] - pub const fn min_value() -> Self { - Self::MIN - } - /// Creates an I256 from a sign and an absolute value. Returns the value and a bool that is true /// if the conversion caused an overflow. #[inline(always)] @@ -712,7 +698,7 @@ impl I256 { #[inline(always)] #[must_use] pub fn checked_div(self, rhs: Self) -> Option { - if rhs.is_zero() || (self == Self::min_value() && rhs == Self::minus_one()) { + if rhs.is_zero() || (self == Self::MIN && rhs == Self::minus_one()) { None } else { Some(self.overflowing_div(rhs).0) @@ -844,7 +830,7 @@ impl I256 { #[track_caller] #[must_use] pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { - if self == Self::min_value() && rhs == Self::minus_one() { + if self == Self::MIN && rhs == Self::minus_one() { (self, true) } else { (self.div_euclid(rhs), false) @@ -856,7 +842,7 @@ impl I256 { #[inline(always)] #[must_use] pub fn checked_div_euclid(self, rhs: Self) -> Option { - if rhs.is_zero() || (self == Self::min_value() && rhs == Self::minus_one()) { + if rhs.is_zero() || (self == Self::MIN && rhs == Self::minus_one()) { None } else { Some(self.div_euclid(rhs)) @@ -916,7 +902,7 @@ impl I256 { #[track_caller] #[must_use] pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { - if self == Self::min_value() && rhs == Self::minus_one() { + if self == Self::MIN && rhs == Self::minus_one() { (Self::zero(), true) } else { (self.rem_euclid(rhs), false) @@ -944,7 +930,7 @@ impl I256 { #[inline(always)] #[must_use] pub fn checked_rem_euclid(self, rhs: Self) -> Option { - if rhs.is_zero() || (self == Self::min_value() && rhs == Self::minus_one()) { + if rhs.is_zero() || (self == Self::MIN && rhs == Self::minus_one()) { None } else { Some(self.rem_euclid(rhs)) @@ -1049,7 +1035,7 @@ impl I256 { /// shift value was larger than or equal to the number of bits. #[inline(always)] #[must_use] - pub fn overflowing_shl(self, rhs: usize) -> (Self, bool) { + pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) { if rhs >= 256 { (Self::zero(), true) } else { @@ -1061,7 +1047,7 @@ impl I256 { /// equal to the number of bits in `self`. #[inline(always)] #[must_use] - pub fn checked_shl(self, rhs: usize) -> Option { + pub fn checked_shl(self, rhs: u32) -> Option { match self.overflowing_shl(rhs) { (value, false) => Some(value), _ => None, @@ -1072,8 +1058,8 @@ impl I256 { /// number of bits in `self`. #[inline(always)] #[must_use] - pub fn wrapping_shl(self, rhs: usize) -> Self { - self.overflowing_shl(rhs).0 + pub fn wrapping_shl(self, lhs: u32) -> Self { + self.overflowing_shl(lhs).0 } /// Shifts self right by `rhs` bits. @@ -1082,7 +1068,7 @@ impl I256 { /// shift value was larger than or equal to the number of bits. #[inline(always)] #[must_use] - pub fn overflowing_shr(self, rhs: usize) -> (Self, bool) { + pub fn overflowing_shr(self, rhs: u32) -> (Self, bool) { if rhs >= 256 { (Self::zero(), true) } else { @@ -1094,7 +1080,7 @@ impl I256 { /// equal to the number of bits in `self`. #[inline(always)] #[must_use] - pub fn checked_shr(self, rhs: usize) -> Option { + pub fn checked_shr(self, rhs: u32) -> Option { match self.overflowing_shr(rhs) { (value, false) => Some(value), _ => None, @@ -1105,7 +1091,7 @@ impl I256 { /// number of bits in `self`. #[inline(always)] #[must_use] - pub fn wrapping_shr(self, rhs: usize) -> Self { + pub fn wrapping_shr(self, rhs: u32) -> Self { self.overflowing_shr(rhs).0 } @@ -1113,7 +1099,7 @@ impl I256 { /// the number is positive this is the same as logic shift right. #[inline(always)] #[must_use] - pub fn asr(self, rhs: usize) -> Self { + pub fn asr(self, rhs: u32) -> Self { // Avoid shifting if we are going to know the result regardless of the value. match (rhs, self.sign()) { (0, _) => self, @@ -1148,7 +1134,7 @@ impl I256 { /// Returns `None` if the operation overflowed (most significant bit changes). #[inline(always)] #[must_use] - pub fn asl(self, rhs: usize) -> Option { + pub fn asl(self, rhs: u32) -> Option { if rhs == 0 { Some(self) } else { @@ -1198,6 +1184,7 @@ macro_rules! impl_conversions { } impl From<$i> for I256 { + #[allow(clippy::cast_sign_loss)] #[inline(always)] fn from(value: $i) -> Self { let uint: $u = value as $u; @@ -1213,6 +1200,7 @@ macro_rules! impl_conversions { impl TryFrom for $u { type Error = TryFromBigIntError; + #[allow(clippy::cast_possible_truncation)] #[inline(always)] fn try_from(value: I256) -> Result<$u, Self::Error> { if value.is_negative() || value > I256::from(<$u>::MAX) { @@ -1226,6 +1214,7 @@ macro_rules! impl_conversions { impl TryFrom for $i { type Error = TryFromBigIntError; + #[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)] #[inline(always)] fn try_from(value: I256) -> Result<$i, Self::Error> { if value < I256::from(<$i>::MIN) || value > I256::from(<$i>::MAX) { @@ -1240,6 +1229,7 @@ macro_rules! impl_conversions { (@impl_fns $t:ty, $actual_low:ident $low:ident $as:ident) => { /// Low word. + #[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)] #[inline(always)] #[must_use] pub const fn $low(&self) -> $t { @@ -1549,9 +1539,10 @@ macro_rules! impl_shift { impl ops::Shl<$t> for I256 { type Output = Self; + #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation, clippy::cast_lossless)] #[inline(always)] fn shl(self, rhs: $t) -> Self::Output { - self.wrapping_shl(rhs as usize) + self.wrapping_shl(rhs as u32) } } @@ -1565,9 +1556,10 @@ macro_rules! impl_shift { impl ops::Shr<$t> for I256 { type Output = Self; + #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation, clippy::cast_lossless)] #[inline(always)] fn shr(self, rhs: $t) -> Self::Output { - self.wrapping_shr(rhs as usize) + self.wrapping_shr(rhs as u32) } } @@ -1624,11 +1616,234 @@ fn handle_overflow((result, overflow): (I256, bool)) -> I256 { result } +// num-traits +impl num_traits::Zero for I256 { + #[inline(always)] + fn zero() -> Self { + Self(U256::zero()) + } + + #[inline(always)] + fn is_zero(&self) -> bool { + self.0.is_zero() + } +} + +impl num_traits::One for I256 { + #[inline(always)] + fn one() -> Self { + Self(U256::one()) + } + + #[inline(always)] + fn set_one(&mut self) { + self.0.set_one(); + } + + #[inline] + fn is_one(&self) -> bool + where + Self: PartialEq, + { + self.0.is_one() + } +} + +impl num_traits::Bounded for I256 { + #[inline(always)] + fn min_value() -> Self { + Self::MIN + } + + #[inline(always)] + fn max_value() -> Self { + Self::MAX + } +} + +impl num_traits::Pow for I256 { + type Output = Self; + + #[inline(always)] + fn pow(self, rhs: u32) -> Self { + Self::pow(self, rhs) + } +} + +impl num_traits::Pow for &I256 { + type Output = I256; + + #[inline(always)] + fn pow(self, rhs: u32) -> Self::Output { + I256::pow(*self, rhs) + } +} + +impl num_traits::WrappingAdd for I256 { + #[inline(always)] + fn wrapping_add(&self, v: &Self) -> Self { + Self::wrapping_add(*self, *v) + } +} + +impl num_traits::WrappingSub for I256 { + #[inline(always)] + fn wrapping_sub(&self, v: &Self) -> Self { + Self::wrapping_sub(*self, *v) + } +} + +impl num_traits::WrappingMul for I256 { + #[inline(always)] + fn wrapping_mul(&self, v: &Self) -> Self { + Self::wrapping_mul(*self, *v) + } +} + +impl num_traits::WrappingNeg for I256 { + #[inline(always)] + fn wrapping_neg(&self) -> Self { + Self::wrapping_neg(*self) + } +} + +impl num_traits::WrappingShr for I256 { + #[inline(always)] + fn wrapping_shr(&self, rhs: u32) -> Self { + Self::wrapping_shr(*self, rhs) + } +} + +impl num_traits::WrappingShl for I256 { + #[inline(always)] + fn wrapping_shl(&self, rhs: u32) -> Self { + Self::wrapping_shl(*self, rhs) + } +} + +impl num_traits::CheckedAdd for I256 { + #[inline(always)] + fn checked_add(&self, v: &Self) -> Option { + Self::checked_add(*self, *v) + } +} + +impl num_traits::CheckedSub for I256 { + #[inline(always)] + fn checked_sub(&self, v: &Self) -> Option { + Self::checked_sub(*self, *v) + } +} + +impl num_traits::CheckedMul for I256 { + #[inline(always)] + fn checked_mul(&self, v: &Self) -> Option { + Self::checked_mul(*self, *v) + } +} + +impl num_traits::CheckedDiv for I256 { + #[inline(always)] + fn checked_div(&self, v: &Self) -> Option { + Self::checked_div(*self, *v) + } +} + +impl num_traits::CheckedRem for I256 { + #[inline(always)] + fn checked_rem(&self, v: &Self) -> Option { + Self::checked_rem(*self, *v) + } +} + +impl num_traits::CheckedNeg for I256 { + #[inline(always)] + fn checked_neg(&self) -> Option { + Self::checked_neg(*self) + } +} + +impl num_traits::Euclid for I256 { + #[inline(always)] + fn div_euclid(&self, v: &Self) -> Self { + Self::div_euclid(*self, *v) + } + + #[inline(always)] + fn rem_euclid(&self, v: &Self) -> Self { + Self::rem_euclid(*self, *v) + } +} + +impl num_traits::CheckedEuclid for I256 { + #[inline(always)] + fn checked_div_euclid(&self, v: &Self) -> Option { + Self::checked_div_euclid(*self, *v) + } + + #[inline(always)] + fn checked_rem_euclid(&self, v: &Self) -> Option { + Self::checked_rem_euclid(*self, *v) + } +} + +impl num_traits::SaturatingAdd for I256 { + #[inline(always)] + fn saturating_add(&self, v: &Self) -> Self { + Self::saturating_add(*self, *v) + } +} + +impl num_traits::SaturatingSub for I256 { + #[inline(always)] + fn saturating_sub(&self, v: &Self) -> Self { + Self::saturating_sub(*self, *v) + } +} + +impl num_traits::SaturatingMul for I256 { + #[inline(always)] + fn saturating_mul(&self, v: &Self) -> Self { + Self::saturating_mul(*self, *v) + } +} + +impl num_traits::FromBytes for I256 { + type Bytes = [u8; 32]; + + fn from_be_bytes(bytes: &Self::Bytes) -> Self { + Self(U256::from_big_endian(bytes)) + } + + fn from_le_bytes(bytes: &Self::Bytes) -> Self { + Self(U256::from_little_endian(bytes)) + } +} + +impl num_traits::ToBytes for I256 { + type Bytes = [u8; 32]; + + fn to_be_bytes(&self) -> Self::Bytes { + let mut bytes = [0u8; 32]; + self.0.to_big_endian(&mut bytes); + bytes + } + + fn to_le_bytes(&self) -> Self::Bytes { + let mut bytes = [0u8; 32]; + self.0.to_little_endian(&mut bytes); + bytes + } +} + #[cfg(test)] mod tests { use super::*; use core::ops::Neg; + #[cfg(not(feature = "std"))] + use alloc::{format, string::ToString}; + #[inline] fn min_abs() -> U256 { U256::from(1) << 255 @@ -1643,11 +1858,11 @@ mod tests { assert_eq!(I256::one().to_string(), "1"); assert_eq!(I256::minus_one().to_string(), "-1"); assert_eq!( - I256::max_value().to_string(), + I256::MAX.to_string(), "57896044618658097711785492504343953926634992332820282019728792003956564819967" ); assert_eq!( - I256::min_value().to_string(), + I256::MIN.to_string(), "-57896044618658097711785492504343953926634992332820282019728792003956564819968" ); } @@ -1668,20 +1883,11 @@ mod tests { ($signed:ty, $unsigned:ty) => { assert_eq!(I256::from(-42 as $signed).to_string(), "-42"); assert_eq!(I256::from(42 as $signed).to_string(), "42"); - assert_eq!( - I256::from(<$signed>::max_value()).to_string(), - <$signed>::max_value().to_string(), - ); - assert_eq!( - I256::from(<$signed>::min_value()).to_string(), - <$signed>::min_value().to_string(), - ); + assert_eq!(I256::from(<$signed>::MAX).to_string(), <$signed>::MAX.to_string(),); + assert_eq!(I256::from(<$signed>::MIN).to_string(), <$signed>::MIN.to_string(),); assert_eq!(I256::from(42 as $unsigned).to_string(), "42"); - assert_eq!( - I256::from(<$unsigned>::max_value()).to_string(), - <$unsigned>::max_value().to_string(), - ); + assert_eq!(I256::from(<$unsigned>::MAX).to_string(), <$unsigned>::MAX.to_string(),); assert!(matches!(<$signed>::try_from(small_positive), Ok(42))); assert!(matches!(<$signed>::try_from(small_negative), Ok(-42))); @@ -2065,19 +2271,16 @@ mod tests { // Overflowing assert_eq!(a.overflowing_rem_euclid(b), (I256::from(3), false)); - assert_eq!( - I256::min_value().overflowing_rem_euclid(I256::minus_one()), - (I256::zero(), true) - ); + assert_eq!(I256::MIN.overflowing_rem_euclid(I256::minus_one()), (I256::zero(), true)); // Wrapping assert_eq!(I256::from(100).wrapping_rem_euclid(I256::from(10)), I256::zero()); - assert_eq!(I256::min_value().wrapping_rem_euclid(I256::minus_one()), I256::zero()); + assert_eq!(I256::MIN.wrapping_rem_euclid(I256::minus_one()), I256::zero()); // Checked assert_eq!(a.checked_rem_euclid(b), Some(I256::from(3))); assert_eq!(a.checked_rem_euclid(I256::zero()), None); - assert_eq!(I256::min_value().checked_rem_euclid(I256::minus_one()), None); + assert_eq!(I256::MIN.checked_rem_euclid(I256::minus_one()), None); } #[test] diff --git a/chains/ethereum/types/src/serde_utils.rs b/chains/ethereum/types/src/serde_utils.rs index da8f9f8f..c431833b 100644 --- a/chains/ethereum/types/src/serde_utils.rs +++ b/chains/ethereum/types/src/serde_utils.rs @@ -646,7 +646,7 @@ impl SerializableRational for Vec { { // Safety: `Vec` and `Vec` have the same memory layout #[allow(clippy::transmute_undefined_repr)] - let value = unsafe { &*std::ptr::from_ref::(self).cast::>() }; + let value = unsafe { &*core::ptr::from_ref::(self).cast::>() }; as Serialize>::serialize(value, serializer) } } @@ -728,6 +728,9 @@ mod tests { use super::*; use num_traits::ToPrimitive; + #[cfg(not(feature = "std"))] + use alloc::string::ToString; + const TEST_CASES: [f64; 5] = [ 0.529_074_766_666_666_6, 0.492_404_533_333_333_34, diff --git a/chains/ethereum/types/src/transactions/eip1559.rs b/chains/ethereum/types/src/transactions/eip1559.rs index 0d863cc5..068c5f34 100644 --- a/chains/ethereum/types/src/transactions/eip1559.rs +++ b/chains/ethereum/types/src/transactions/eip1559.rs @@ -267,8 +267,11 @@ impl super::TransactionT for Eip1559Transaction { #[cfg(all(test, any(feature = "serde", feature = "with-rlp")))] pub(crate) mod tests { use super::Eip1559Transaction; + + #[cfg(feature = "with-rlp")] + use crate::bytes::Bytes; + use crate::{ - bytes::Bytes, eth_hash::{Address, H256}, transactions::{ access_list::{AccessList, AccessListItem}, diff --git a/chains/ethereum/types/src/transactions/typed_transaction.rs b/chains/ethereum/types/src/transactions/typed_transaction.rs index 77a15706..16cbda18 100644 --- a/chains/ethereum/types/src/transactions/typed_transaction.rs +++ b/chains/ethereum/types/src/transactions/typed_transaction.rs @@ -257,6 +257,9 @@ mod tests { signature::Signature, }; + #[cfg(not(feature = "std"))] + use alloc::string::ToString; + #[allow(clippy::unwrap_used)] fn build_typed_transaction>( builder: fn() -> (T, Signature, serde_json::Value), diff --git a/chains/polkadot/server/Cargo.toml b/chains/polkadot/server/Cargo.toml index 7f937d9b..33e02aef 100644 --- a/chains/polkadot/server/Cargo.toml +++ b/chains/polkadot/server/Cargo.toml @@ -13,7 +13,7 @@ hex = "0.4" parity-scale-codec = { workspace = true, features = ["derive"] } rosetta-config-polkadot = { workspace = true, features = ["polkadot-metadata", "westend-metadata"] } rosetta-core.workspace = true -rosetta-server = { workspace = true, default-features = false, features = ["ws", "webpki-tls"] } +rosetta-server = { workspace = true, default-features = false, features = ["webpki-tls"] } scale-info.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/chains/polygon/rosetta-testing-polygon/Cargo.toml b/chains/polygon/rosetta-testing-polygon/Cargo.toml index afb840a4..69bd46d2 100644 --- a/chains/polygon/rosetta-testing-polygon/Cargo.toml +++ b/chains/polygon/rosetta-testing-polygon/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/analog-labs/chain-connectors" description = "Polygon rosetta test." [dependencies] -alloy-sol-types = { version = "0.7" } +alloy-sol-types = { version = "0.8" } anyhow = "1.0" ethers = { version = "2.0", default-features = true, features = ["abigen", "rustls", "ws"] } ethers-solc = "2.0" diff --git a/deny.toml b/deny.toml index 6bcefd73..a023e845 100644 --- a/deny.toml +++ b/deny.toml @@ -98,6 +98,9 @@ ignore = [ # Timing variabilit on curve25519-dalek, which can potentially leak private keys { id = 'RUSTSEC-2024-0344', reason = "Waiting for third-part libraries to update to the fixed version" }, + + # Subxt 0.37 depends deprecated libraries: https://github.com/paritytech/subxt/issues/1608 + { id = 'RUSTSEC-2024-0370', reason = "Waiting for subxt to update their deprecated dependencies" }, ] # This section is considered when running `cargo deny check sources`. diff --git a/rosetta-server/Cargo.toml b/rosetta-server/Cargo.toml index 699e8529..dd2ada40 100644 --- a/rosetta-server/Cargo.toml +++ b/rosetta-server/Cargo.toml @@ -8,31 +8,21 @@ description = "Generic rosetta server implementation." [features] default = [] -native-tls = ["tokio-tungstenite/native-tls", "jsonrpsee/client-ws-transport-tls"] -webpki-tls = ["tokio-tungstenite/rustls-tls-webpki-roots", "jsonrpsee/client-ws-transport-tls"] -ws = [ - "dep:async-trait", - "dep:futures", - "dep:futures-util", - "dep:futures-timer", - "dep:jsonrpsee", - "dep:subxt", - "dep:pin-project", - "futures/std", -] +native-tls = ["tokio-tungstenite/native-tls"] +webpki-tls = ["tokio-tungstenite/rustls-tls-webpki-roots"] [dependencies] anyhow = "1.0" -async-trait = { version = "0.1", optional = true } -futures = { version = "0.3", optional = true } -futures-timer = { version = "3.0", optional = true } -futures-util = { version = "0.3", optional = true } +async-trait = { version = "0.1" } +futures = { version = "0.3", features = ["std"] } +futures-timer = { version = "3.0" } +futures-util = { version = "0.3" } hex = "0.4" -jsonrpsee = { workspace = true, features = ["ws-client", "http-client"], optional = true } -pin-project = { version = "1.1", optional = true } +jsonrpsee = { workspace = true, features = ["ws-client", "http-client", "client-ws-transport-tls"] } +pin-project = { version = "1.1" } serde.workspace = true serde_json.workspace = true -subxt = { workspace = true, features = ["native", "substrate-compat"], optional = true } +subxt = { workspace = true, features = ["native", "substrate-compat"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tokio-retry = "0.3" tokio-tungstenite = { version = "0.23", default-features = false, features = ["handshake", "connect"] } diff --git a/rosetta-server/src/lib.rs b/rosetta-server/src/lib.rs index 15956812..6757c996 100644 --- a/rosetta-server/src/lib.rs +++ b/rosetta-server/src/lib.rs @@ -1,2 +1 @@ -#[cfg(feature = "ws")] pub mod ws; diff --git a/rosetta-server/src/ws.rs b/rosetta-server/src/ws.rs index eb805ca9..6fe8897f 100644 --- a/rosetta-server/src/ws.rs +++ b/rosetta-server/src/ws.rs @@ -1,4 +1,3 @@ -#![cfg(feature = "ws")] mod config; mod error; mod jsonrpsee_client; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ead08f07..aac2d0c8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.78.0" +channel = "1.79.0" components = ["rust-src", "rust-analyzer", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/check.sh b/scripts/check.sh index f06be207..cd84936b 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,28 +1,47 @@ #!/bin/bash set -e +shopt -s inherit_errexit SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd "${SCRIPT_DIR}/../" +CHECK_FORMAT=0 RUN_FIX=0 RUN_TESTS=0 TEST_ETH_BACKEND=0 +TEST_ETH_TYPES=0 # process arguments while [[ $# -gt 0 ]] do case "$1" in + --all) + CHECK_FORMAT=1 + RUN_FIX=1 + RUN_TESTS=1 + TEST_ETH_BACKEND=1 + TEST_ETH_TYPES=1 + shift 1 + ;; + --fmt|--format) + CHECK_FORMAT=1 + shift 1 + ;; --test|--tests) RUN_TESTS=1 shift 1 ;; --fix) - RUN_FIX=1 - shift 1 + RUN_FIX=1 + shift 1 ;; --eth-backend) - TEST_ETH_BACKEND=1 - shift 1 + TEST_ETH_BACKEND=1 + shift 1 + ;; + --eth-types) + TEST_ETH_TYPES=1 + shift 1 ;; *) warn "Unknown argument: $1" @@ -34,11 +53,20 @@ done # Check for 'docker' and abort if it is not running. docker info > /dev/null 2>&1 || { echo >&2 "ERROR - requires 'docker', please start docker and try again."; exit 1; } -# Check for 'cargo' and abort if it is not available. -cargo -V > /dev/null 2>&1 || { echo >&2 "ERROR - requires 'cargo' for compile the binaries"; exit 1; } +# Check for 'cargo deny' and abort if it is not available. +cargo deny -V > /dev/null 2>&1 || { echo >&2 "ERROR - 'cargo deny' not found, install using 'cargo install --locked cargo-deny'"; exit 1; } + +# Check for 'awk' command and abort if it is not available. +command -v awk > /dev/null 2>&1 || { echo >&2 "ERROR - requires 'awk' for verify semantic versioning"; exit 1; } + +# Check for 'grep' command and abort if it is not available. +command -v grep > /dev/null 2>&1 || { echo >&2 "ERROR - this script requires 'grep' internally"; exit 1; } + +# Check for 'head' command and abort if it is not available. +command -v head > /dev/null 2>&1 || { echo >&2 "ERROR - this script requires 'head' internally"; exit 1; } # Check for 'solc' and abort if it is not available. -solc --version > /dev/null 2>&1 || { echo >&2 "ERROR - requires 'solc >= 0.8.20' for compile the contracts"; exit 1; } +solc --version > /dev/null 2>&1 || { echo >&2 "ERROR - requires 'solc >= 0.8.25' for compile the contracts"; exit 1; } # Check for 'cargo deny' and abort if it is not available. cargo deny -V > /dev/null 2>&1 || { echo >&2 "ERROR - 'cargo deny' not found, install using 'cargo install --locked cargo-deny'"; exit 1; } @@ -64,6 +92,119 @@ if test -t 1 && command -v tput >/dev/null 2>&1; then fi : "${ncols:=72}" +# shellcheck disable=SC2001 +function semver2int() { + local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' + local major; + local minor; + local patch; + major="$(echo "$1" | sed -e "s#${RE}#\1#")" + minor="$(echo "$1" | sed -e "s#${RE}#\2#")" + patch="$(echo "$1" | sed -e "s#${RE}#\3#")" + # Convert semver to decimal + major=$((major * 1000000000)) + minor=$((minor * 1000000)) + patch=$((patch * 1)) + echo $((major + minor + patch)) +} + +# shellcheck disable=SC2001 +function parse_semver() { + local version="$1" + if [[ "${version}" =~ ^[0-9]+\.[0-9]+$ ]]; then + version="${version}.0" + fi + local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' + local major; + local minor; + local patch; + major="$(echo "${version}" | sed -e "s#${RE}#\1#")" + minor="$(echo "${version}" | sed -e "s#${RE}#\2#")" + patch="$(echo "${version}" | sed -e "s#${RE}#\3#")" + echo "${major}.${minor}.${patch}" +} + +# Check sematic version +function checkSemver() { + local name='' + local actual + local expect + local lhs + local rhs + if [[ "$#" -gt 2 ]]; then + name="${bold_color}${1}${reset_color}${bold_color}:${reset_color} " + shift 1 + fi + actual="$(parse_semver "${1}")" + expect="$(parse_semver "${2}")" + lhs="$(semver2int "${actual}")" + rhs="$(semver2int "${expect}")" + if [[ "${lhs}" -lt "${rhs}" ]]; then + printf "%s${error_color}%s < %s ${reset_color}\n" "${name}" "${actual}" "${expect}" + # print suggestion if provided + if [[ -n "${3}" ]]; then + printf "%s\n" "${3}" + fi + exit 1 + fi +} + +# Check `solc` version +solc_version="$(solc --version)" +solc_version="$(tr '\n' ' ' <<< "${solc_version}")" +solc_version="$(awk -FVersion: '{ print $NF }' <<< "${solc_version}")" +solc_version="$(awk -F. '{print $1 "." $2 "." $3 }' <<< "${solc_version}")" +# shellcheck disable=SC2001 +solc_version="$(sed 's/[^0-9\.]*//g' <<< "${solc_version}")" +checkSemver 'solc' \ + "${solc_version}" \ + '0.8.25' \ + "install svm following this instructions: ${bold_color}https://github.com/alloy-rs/svm-rs${reset_color}" + +# Check `rustc` version +rustc_version="$(rustc --version)" +rustc_version="$(awk '{print $2}' <<< "${rustc_version}")" +checkSemver 'rustc' \ + "${rustc_version}" \ + '1.79.0' \ + "upgrade rustc with command: ${warn_color}rustup update stable${reset_color}" + +# Check `cargo-deny` version +cargo_deny_version="$(cargo deny --version)" +cargo_deny_version="$(awk '{print $2}' <<< "${cargo_deny_version}")" +checkSemver 'cargo deny' \ + "${cargo_deny_version}" \ + '0.14.24' \ + "upgrade ${bold_color}cargo-deny${reset_color} with command: ${warn_color}cargo install cargo-deny${reset_color}" + +# Check `dprint` version +dprint_version="$(dprint --version)" +dprint_version="$(awk '{print $2}' <<< "${dprint_version}")" +checkSemver 'dprint' \ + "${dprint_version}" \ + '0.47.1' \ + "upgrade ${bold_color}dprint${reset_color} with command: ${warn_color}cargo install dprint${reset_color}" + +# Check `shellcheck` version +shellcheck_version="$(shellcheck --version)" +shellcheck_version="$(grep 'version:' <<< "${shellcheck_version}")" +shellcheck_version="$(awk '{print $2}' <<< "${shellcheck_version}")" +# "$(shellcheck --version | grep 'version:' | awk '{print $2}')" +checkSemver 'shellcheck' \ + "${shellcheck_version}" \ + '0.8.0' \ + "upgrade ${bold_color}shellcheck${reset_color} following the instructions at: ${warn_color}https://github.com/koalaman/shellcheck${reset_color}" + +# Check `docker api` version +docker_version="$(docker version)" +docker_version="$(grep 'API version:' <<< "${docker_version}")" +docker_version="$(head -1 <<< "${docker_version}")" +docker_version="$(awk '{ print $3 }' <<< "${docker_version}")" +checkSemver 'docker api' \ + "${docker_version}" \ + '1.42.0' \ + "the minimal docker api version supported by ${bold_color}rosetta-docker${reset_color} is ${warn_color}1.42${reset_color}" + # Print the command in yellow, and the output in red print_failed_command() { printf >&2 "${bold_color}${warn_color}%s${reset_color}\n${error_color}%s${reset_color}\n" "$1" "$2" @@ -89,41 +230,66 @@ if [[ "${RUN_FIX}" == "1" ]]; then exec_cmd 'format' 'cargo +nightly fmt --all && dprint fmt' # exec_cmd 'clippy --fix' "cargo clippy --fix --allow-dirty --workspace --examples --tests --all-features -- ${CLIPPY_FLAGS}" fi -exec_cmd 'shellcheck' 'shellcheck --enable=all --severity=style ./scripts/*.sh' -exec_cmd 'cargo fmt' 'cargo +nightly fmt --all -- --check' -exec_cmd 'dprint check' 'dprint check' -exec_cmd 'cargo deny' 'cargo deny check' - -# Run clippy on all packages with different feature flags -# LINT_FLAGS='-- -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions' - -# exec_cmd 'ethereum build all-features' 'cargo build -p rosetta-config-ethereum --all-features' -# exec_cmd 'ethereum test all-features' 'cargo test -p rosetta-config-ethereum --all-features' -# exec_cmd 'ethereum clippy all-features' "cargo clippy -p rosetta-config-ethereum --all-features ${LINT_FLAGS}" -# ethereumFeatures=('std' 'std,serde' 'std,scale-info' 'std,scale-codec') -# for features in "${ethereumFeatures[@]}"; -# do -# exec_cmd "ethereum build ${features}" "cargo build -p rosetta-config-ethereum --no-default-features --features=${features}" -# exec_cmd "ethereum test ${features}" "cargo test -p rosetta-config-ethereum --no-default-features --features=${features}" -# exec_cmd "ethereum clippy ${features}" "cargo clippy -p rosetta-config-ethereum --no-default-features --features=${features} ${LINT_FLAGS}" -# done - - -# exec_cmd 'clippy rosetta-server-astar' 'cargo clippy --locked -p rosetta-server-astar --examples --tests -- -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions' -# exec_cmd 'clippy rosetta-server-ethereum' 'cargo clippy --locked -p rosetta-server-ethereum --examples --tests -- -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions' -# exec_cmd 'clippy rosetta-server-polkadot' 'cargo clippy --locked -p rosetta-server-polkadot --examples --tests -- -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions' -# exec_cmd 'clippy rosetta-client' 'cargo clippy --locked -p rosetta-client --examples --tests -- -Dwarnings -Dclippy::unwrap_used -Dclippy::expect_used -Dclippy::nursery -Dclippy::pedantic -Aclippy::module_name_repetitions' -exec_cmd 'clippy' "cargo clippy --locked --workspace --examples --tests --all-features -- ${CLIPPY_FLAGS}" + +if [[ "${CHECK_FORMAT}" == "1" ]]; then + exec_cmd 'shellcheck' 'shellcheck --enable=all --severity=style ./scripts/*.sh' + exec_cmd 'cargo fmt' 'cargo +nightly fmt --all -- --check' + exec_cmd 'dprint check' 'dprint check' + exec_cmd 'cargo deny' 'cargo deny check' + exec_cmd 'clippy' "cargo clippy --locked --workspace --examples --tests --all-features -- ${CLIPPY_FLAGS}" +fi if [[ "${TEST_ETH_BACKEND}" == "1" ]]; then NAME='rosetta-ethereum-backend' - exec_cmd 'clippy all-features' "cargo clippy -p ${NAME} --tests --all-features -- ${CLIPPY_FLAGS}" - exec_cmd 'clippy no-default-features' "cargo clippy -p ${NAME} --tests --no-default-features -- ${CLIPPY_FLAGS}" - exec_cmd 'clippy std' "cargo clippy -p ${NAME} --tests --no-default-features --features=std -- ${CLIPPY_FLAGS}" - exec_cmd 'clippy serde' "cargo clippy -p ${NAME} --tests --no-default-features --features=serde -- ${CLIPPY_FLAGS}" - exec_cmd 'clippy jsonrpsee' "cargo clippy -p ${NAME} --tests --no-default-features --features=jsonrpsee -- ${CLIPPY_FLAGS}" - exec_cmd 'clippy with-codec' "cargo clippy -p ${NAME} --tests --no-default-features --features=with-codec -- ${CLIPPY_FLAGS}" - exec_cmd 'build wasm32-unknown-unknown' "cargo build -p ${NAME} --target wasm32-unknown-unknown --no-default-features --features=with-codec,jsonrpsee,serde" + exec_cmd 'clippy all-features' "cargo --locked clippy -p ${NAME} --tests --all-features -- ${CLIPPY_FLAGS}" + exec_cmd 'clippy no-default-features' "cargo --locked clippy -p ${NAME} --tests --no-default-features -- ${CLIPPY_FLAGS}" + exec_cmd 'clippy std' "cargo clippy --locked -p ${NAME} --tests --no-default-features --features=std -- ${CLIPPY_FLAGS}" + exec_cmd 'clippy serde' "cargo clippy --locked -p ${NAME} --tests --no-default-features --features=serde -- ${CLIPPY_FLAGS}" + exec_cmd 'clippy jsonrpsee' "cargo clippy --locked -p ${NAME} --tests --no-default-features --features=jsonrpsee -- ${CLIPPY_FLAGS}" + exec_cmd 'clippy with-codec' "cargo clippy --locked -p ${NAME} --tests --no-default-features --features=with-codec -- ${CLIPPY_FLAGS}" + exec_cmd 'build wasm32-unknown-unknown' "cargo build --locked -p ${NAME} --target wasm32-unknown-unknown --no-default-features --features=with-codec,jsonrpsee,serde" +fi + +if [[ "${TEST_ETH_TYPES}" == "1" ]]; then + NAME='rosetta-ethereum-types' + # Combine all features, to make sure any combination of features works. + # The following features must work on wasm32-unknown-unknown targets, once they must be used in substrate runtime. + FEATURES=( + '--features=serde' + '--features=with-rlp' + '--features=with-codec' + '--features=with-crypto' + '--features=serde,with-rlp' + '--features=serde,with-codec' + '--features=serde,with-crypto' + '--features=with-rlp,with-codec' + '--features=with-rlp,with-crypto' + '--features=with-rlp,with-codec,with-crypto,serde' + ) + + # all features + extraflags='--all-features' + exec_cmd "clippy ${extraflags}" "cargo --locked clippy -p ${NAME} ${extraflags} --tests -- ${CLIPPY_FLAGS}" + exec_cmd "build ${extraflags}" "cargo --locked build -p ${NAME} ${extraflags}" + + # no features + extraflags='--no-default-features' + exec_cmd "clippy ${extraflags}" "cargo --locked clippy -p ${NAME} ${extraflags} --tests -- ${CLIPPY_FLAGS}" + exec_cmd "build ${extraflags}" "cargo --locked build -p ${NAME} ${extraflags}" + exec_cmd "build --target wasm32-unknown-unknown ${extraflags}" "cargo build --locked -p ${NAME} --target wasm32-unknown-unknown ${extraflags}" + + # only std feature + extraflags='--no-default-features --features=std' + exec_cmd "clippy ${extraflags}" "cargo clippy --locked -p ${NAME} ${extraflags} --tests -- ${CLIPPY_FLAGS}" + exec_cmd "build ${extraflags}" "cargo build --locked -p ${NAME} ${extraflags}" + + # iterate over all features + for index in "${!FEATURES[@]}"; + do + extraflags="${FEATURES[${index}]}" + exec_cmd "clippy ${extraflags}" "cargo clippy --locked -p ${NAME} --no-default-features ${extraflags} --tests -- ${CLIPPY_FLAGS}" + exec_cmd "build --target wasm32-unknown-unknown ${extraflags}" "cargo build --locked -p ${NAME} --target wasm32-unknown-unknown --no-default-features ${extraflags}" + done fi if [[ "${RUN_TESTS}" == "1" ]]; then @@ -139,16 +305,6 @@ if [[ "${RUN_TESTS}" == "1" ]]; then --exclude rosetta-client \ --exclude rosetta-testing-arbitrum \ --exclude rosetta-testing-binance - # cargo test --locked --all-features --workspace + #exec_cmd 'cargo test' 'cargo test --locked --all-features --workspace' exec_cmd 'cleanup docker' "${SCRIPT_DIR}/reset_docker.sh" fi -#exec_cmd 'reset docker' "${SCRIPT_DIR}/reset_docker.sh" -#cargo test --locked --all-features --workspace - - -#exec_cmd 'cargo test' 'cargo test --locked --all-features --workspace' - -#echo "Running ${SCRIPT_DIR}/build_connectors.sh" -#"${SCRIPT_DIR}/build_connectors.sh" -# -#cargo test --locked --all-features --workspace