From 14e58b7073e32287022819719d6429d0866f17fd Mon Sep 17 00:00:00 2001 From: lemunozm Date: Wed, 29 Nov 2023 09:31:31 +0100 Subject: [PATCH] fixes and script changes --- Cargo.toml | 2 +- ci/run-check.sh | 14 ++++ pallets/bridge-mapping/Cargo.toml | 30 -------- pallets/liquidity-pools-gateway/Cargo.toml | 4 +- .../routers/Cargo.toml | 7 ++ pallets/nft-sales/Cargo.toml | 2 +- runtime/common/Cargo.toml | 7 ++ scripts/check_all_split.sh | 67 ++++++++++++++++ scripts/tests.sh | 76 ------------------- 9 files changed, 100 insertions(+), 109 deletions(-) delete mode 100644 pallets/bridge-mapping/Cargo.toml create mode 100755 scripts/check_all_split.sh delete mode 100755 scripts/tests.sh diff --git a/Cargo.toml b/Cargo.toml index aca17a7811..3a147fc114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [ + "node", "libs/mocks", "libs/primitives", "libs/proofs", @@ -8,7 +9,6 @@ members = [ "libs/traits", "libs/types", "libs/utils", - "node", "pallets/anchors", "pallets/bridge", "pallets/block-rewards", diff --git a/ci/run-check.sh b/ci/run-check.sh index 6e52c3c142..9bedc19510 100755 --- a/ci/run-check.sh +++ b/ci/run-check.sh @@ -37,4 +37,18 @@ case $TARGET in ;; docs-build) RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps + ;; + subalfred) + # Find all child directories containing Cargo.toml files + # TODO: Filter by crates found in the workspace + dirs=$(find . -name Cargo.toml -print0 | xargs -0 -n1 dirname | sort -u) + + # Execute the command "subalfred check" on each directory + for dir in $dirs; do + # Avoiding cargo workspace + if [[ "$dir" == "." ]]; then + continue + fi + subalfred check features $dir + done esac diff --git a/pallets/bridge-mapping/Cargo.toml b/pallets/bridge-mapping/Cargo.toml deleted file mode 100644 index 94a947fe56..0000000000 --- a/pallets/bridge-mapping/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -authors = ["buterajay@protonmail.com"] -description = "Access control list for bridge paths across chains" -edition = "2021" -license = "LGPL-3.0" -name = "pallet-bridge-mapping" -repository = "https://github.com/centrifuge/centrifuge-chain" -version = "2.0.0" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } - -[dev-dependencies] -cfg-primitives = { path = "../../libs/primitives" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } - -[features] -default = ["std"] -std = [ - "codec/std", - "scale-info/std", - "frame-support/std", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/liquidity-pools-gateway/Cargo.toml b/pallets/liquidity-pools-gateway/Cargo.toml index 2c72c9bffb..6a00d3e8d9 100644 --- a/pallets/liquidity-pools-gateway/Cargo.toml +++ b/pallets/liquidity-pools-gateway/Cargo.toml @@ -31,7 +31,7 @@ cfg-types = { path = "../../libs/types", default-features = false } cfg-utils = { path = "../../libs/utils", default-features = false } [dev-dependencies] -cfg-mocks = { path = "../../libs/mocks", features = ["runtime-benchmarks", "std"] } +cfg-mocks = { path = "../../libs/mocks", features = ["std"] } hex-literal = "0.4.1" sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } @@ -62,6 +62,7 @@ try-runtime = [ "frame-system/try-runtime", "sp-runtime/try-runtime", "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -71,4 +72,5 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "cfg-utils/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", ] diff --git a/pallets/liquidity-pools-gateway/routers/Cargo.toml b/pallets/liquidity-pools-gateway/routers/Cargo.toml index 172bbf6e1f..89a33f0a0e 100644 --- a/pallets/liquidity-pools-gateway/routers/Cargo.toml +++ b/pallets/liquidity-pools-gateway/routers/Cargo.toml @@ -67,6 +67,7 @@ std = [ "codec/std", "cfg-types/std", "cfg-traits/std", + "cfg-mocks/std", "hex/std", "frame-support/std", "frame-system/std", @@ -86,6 +87,8 @@ std = [ runtime-benchmarks = [ "cfg-traits/runtime-benchmarks", "cfg-types/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", + "cfg-primitives/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-liquidity-pools-gateway/runtime-benchmarks", @@ -94,17 +97,21 @@ runtime-benchmarks = [ "pallet-xcm-transactor/runtime-benchmarks", "xcm-primitives/runtime-benchmarks", "pallet-evm/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "cfg-traits/try-runtime", + "cfg-primitives/try-runtime", "cfg-types/try-runtime", + "cfg-mocks/try-runtime", "pallet-liquidity-pools-gateway/try-runtime", "pallet-ethereum/try-runtime", "pallet-ethereum-transaction/try-runtime", "pallet-xcm-transactor/try-runtime", "pallet-evm/try-runtime", + "pallet-balances/try-runtime", "sp-runtime/try-runtime", ] diff --git a/pallets/nft-sales/Cargo.toml b/pallets/nft-sales/Cargo.toml index 56f0c68222..700edbdc28 100644 --- a/pallets/nft-sales/Cargo.toml +++ b/pallets/nft-sales/Cargo.toml @@ -56,7 +56,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", ] std = [ "codec/std", @@ -71,6 +70,7 @@ std = [ "cfg-primitives/std", "frame-benchmarking/std", "scale-info/std", + "pallet-uniques?/std", ] try-runtime = [ "cfg-primitives/try-runtime", diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index d7d76cdc15..0269d5c646 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -143,6 +143,12 @@ std = [ "xcm-executor/std", "xcm-primitives/std", "xcm/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", # Locals "cfg-primitives/std", @@ -228,6 +234,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm-primitives/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", # Locals "cfg-primitives/runtime-benchmarks", diff --git a/scripts/check_all_split.sh b/scripts/check_all_split.sh new file mode 100755 index 0000000000..67508d8769 --- /dev/null +++ b/scripts/check_all_split.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Usage +# ./scripts/tests.sh <"-F=feature1,feature2,..."> + +all_crates=$( + cargo workspaces list +) + +cargo_action() { + action=$1 + package=$2 + features=$3 + norun=$4 + + echo -e "$testing_prompt cargo $action -p $package $features" + cargo $action -p $package $features $norun + + if [[ $? -ne 0 ]]; then + echo "Aborting!" + exit 1 + fi +} + +ESC="\033" +testing_prompt="$ESC[1;36m Testing$ESC[0m" + +cargo workspaces list > /dev/null +if [[ $? -ne 0 ]]; then + echo try: \'cargo install cargo-workspaces\' before using this crate +fi + +# Checking cargo check +for crate in $all_crates +do + if [[ $1 == *"runtime-benchmarks"* || $1 == *"try-runtime"* ]]; then + if [[ "$crate" == "proofs" ]]; then + echo "Skipping!" + continue + fi + + if [[ "$crate" == "runtime-integration-tests" ]]; then + echo "Skipping!" + continue + fi + fi + + cargo_action check $crate $1 +done + +# Checking cargo test +for crate in $all_crates +do + if [[ $1 == *"runtime-benchmarks"* || $1 == *"try-runtime"* ]]; then + if [[ "$crate" == "proofs" ]]; then + echo "Skipping!" + continue + fi + + if [[ "$crate" == "runtime-integration-tests" ]]; then + echo "Skipping!" + continue + fi + fi + + cargo_action test $crate $1 --no-run +done diff --git a/scripts/tests.sh b/scripts/tests.sh deleted file mode 100755 index cde366f4ea..0000000000 --- a/scripts/tests.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash - -# NOTE -# If some crate fails, you can continue the testing after fixing it as follows: -# ./scripts/tests.sh - -start_from=$1 - -all_crates=$( - cargo workspaces list -) - -cargo_action() { - action=$1 - package=$2 - features=$3 - - echo -e "$testing_prompt cargo $action -p $package $features" - cargo $action -p $package $features - - if [[ $1 -ne 0 ]]; then - echo "Aborting!" - exit 1 - fi -} - -ESC="\033" -testing_prompt="$ESC[1;36m Testing$ESC[0m" -go=0 - -if [[ -z "$start_from" ]]; then - go=1 -fi - -cargo workspaces list > /dev/null -if [[ $1 -ne 0 ]]; then - echo try: \'cargo install cargo-workspaces\' before using this crate -fi - - -for crate in $all_crates -do - if [[ "$start_from" == "$crate" ]]; then - go=1 - fi - - if [[ $go -eq 0 ]]; then - # Skipping until found a crate as starting point - continue - fi - - cargo_action check $crate - cargo_action test $crate --no-run - - if [[ "$crate" == "proofs" ]]; then - # proofs does not have either try-runtime or runtime-benchmarks features - continue - fi - - cargo_action check $crate "-F runtime-benchmarks" - cargo_action test $crate "-F runtime-benchmarks" --no-run - - if [[ "$crate" == "runtime-integration-tests" ]]; then - # runtime-integration-test does not have try-runtime feature - continue - fi - - cargo_action check $crate "-F try-runtime" - cargo_action test $crate "-F try-runtime" --no-run - - cargo_action check $crate "-F runtime-benchmarks,try-runtime" - cargo_action test $crate "-F runtime-benchmarks,try-runtime" --no-run -done - -# Run all tests all -cargo test --workspace -F runtime-benchmarks,try-runtime