diff --git a/.github/workflows/cargo-tests.yml b/.github/workflows/cargo-tests.yml index f2ef7a9e..eca14860 100644 --- a/.github/workflows/cargo-tests.yml +++ b/.github/workflows/cargo-tests.yml @@ -57,6 +57,15 @@ jobs: - name: install rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install toml-sort + run: cargo install --git https://github.com/4meta5/toml_sort + - name: Add file permissions for toml-sort + run: chmod +x ./scripts/toml-sort.sh + - name: Add file permissions for check-toml-sorted + run: chmod +x ./scripts/check-toml-sorted.sh + - name: Check Cargo.toml files are formatted using toml_sort + run: ./scripts/check-toml-sorted.sh + - name: Check format run: cargo fmt --all -- --check diff --git a/Cargo.toml b/Cargo.toml index a8dfc553..7e068251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,43 +1,36 @@ [workspace] members = [ - "node", - "pallets/template", - "runtime", + "node", + "pallets/template", + "runtime", ] resolver = "2" [workspace.package] authors = [ "OpenZeppelin" ] -repository = "https://github.com/OpenZeppelin/polkadot-runtime-template" +description = "Runtime template(s) for Polkadot Para{chains, cores}" edition = "2021" license = "GPL-3.0-only" -description = "Runtime template(s) for Polkadot Para{chains, cores}" - -[workspace.lints.clippy] -type_complexity = "allow" -too_many_arguments = "allow" -large_enum_variant = "allow" +repository = "https://github.com/OpenZeppelin/polkadot-runtime-template" [workspace.dependencies] -clap = { version = "4.4.6", features = ["derive"] } +clap = { version = "4.4.6", features = [ "derive" ] } color-print = "0.3.4" -parity-scale-codec = { version = "3.0.0", default-features = false, features = [ - "derive", -] } futures = "0.3.28" hex-literal = "0.4.1" -jsonrpsee = { version = "0.16.2", features = ["server"] } +jsonrpsee = { version = "0.16.2", features = [ "server" ] } log = { version = "0.4.20", default-features = false } +parity-scale-codec = { version = "3.0.0", default-features = false, features = [ + "derive", +] } scale-info = { version = "2.10.0", default-features = false } -smallvec = "1.11.0" serde = { version = "1.0.188", default-features = false } +smallvec = "1.11.0" # Local pallet-template = { path = "pallets/template", default-features = false } # Substrate -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -50,23 +43,23 @@ pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "re pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -79,10 +72,10 @@ sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -90,16 +83,18 @@ sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } # Polkadot +pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", features = [ "rococo-native", ] } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -119,11 +114,16 @@ cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/pol cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-collator-selection = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } + +[workspace.lints.clippy] +large_enum_variant = "allow" +too_many_arguments = "allow" +type_complexity = "allow" [profile.production] codegen-units = 1 @@ -134,4 +134,3 @@ lto = true [profile.release] opt-level = 3 panic = "unwind" - diff --git a/node/Cargo.toml b/node/Cargo.toml index 71682658..4ce8045e 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,21 +1,21 @@ [package] name = "parachain-template-node" -version = "0.1.0" authors = { workspace = true } +build = "build.rs" description = "Node compatible with parachain runtime template." +edition = { workspace = true } license = { workspace = true } -repository = { workspace = true } -edition = "2021" -build = "build.rs" publish = false +repository = { workspace = true } +version = "0.1.0" [dependencies] clap = { workspace = true } +futures = { workspace = true } +jsonrpsee = { workspace = true, features = [ "server" ] } log = { workspace = true } parity-scale-codec = { workspace = true } -serde = { workspace = true, features = ["derive"] } -jsonrpsee = { workspace = true, features = [ "server" ] } -futures = { workspace = true } +serde = { workspace = true, features = [ "derive" ] } # Local parachain-template-runtime = { path = "../runtime" } @@ -28,11 +28,11 @@ sc-basic-authorship = { workspace = true } sc-chain-spec = { workspace = true } sc-cli = { workspace = true } sc-client-api = { workspace = true } -sc-offchain = { workspace = true } sc-consensus = { workspace = true } sc-executor = { workspace = true } sc-network = { workspace = true } sc-network-sync = { workspace = true } +sc-offchain = { workspace = true } sc-rpc = { workspace = true } sc-service = { workspace = true } sc-sysinfo = { workspace = true } @@ -45,8 +45,8 @@ sp-block-builder = { workspace = true } sp-blockchain = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } -sp-keystore = { workspace = true } sp-io = { workspace = true } +sp-keystore = { workspace = true } sp-runtime = { workspace = true } sp-timestamp = { workspace = true } substrate-frame-rpc-system = { workspace = true } @@ -60,6 +60,7 @@ polkadot-primitives = { workspace = true } xcm = { workspace = true } # Cumulus +color-print = { workspace = true } cumulus-client-cli = { workspace = true } cumulus-client-collator = { workspace = true } cumulus-client-consensus-aura = { workspace = true } @@ -69,7 +70,6 @@ cumulus-client-service = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-parachain-inherent = { workspace = true } cumulus-relay-chain-interface = { workspace = true } -color-print = { workspace = true } [build-dependencies] substrate-build-script-utils = { workspace = true } @@ -91,6 +91,5 @@ try-runtime = [ "sp-runtime/try-runtime", ] - [lints] workspace = true diff --git a/pallets/template/Cargo.toml b/pallets/template/Cargo.toml index 67ed436f..40ffcde7 100644 --- a/pallets/template/Cargo.toml +++ b/pallets/template/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "pallet-template" -description = "FRAME pallet template" -version = "0.1.0" authors = { workspace = true } +description = "FRAME pallet template" +edition = { workspace = true } license = { workspace = true } repository = { workspace = true } -edition = "2021" +version = "0.1.0" [package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] +targets = [ "x86_64-unknown-linux-gnu" ] [dependencies] parity-scale-codec = { workspace = true, features = [ "derive" ] } @@ -28,19 +28,19 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } [features] -default = ["std"] -runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", -] +default = [ "std" ] std = [ - "parity-scale-codec/std", "frame-benchmarking/std", "frame-support/std", "frame-system/std", + "parity-scale-codec/std", "scale-info/std", ] +runtime-benchmarks = [ + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", +] try-runtime = [ "frame-support/try-runtime", ] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index f95c7ca7..9eaffbaa 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,22 +1,19 @@ [package] name = "parachain-template-runtime" -version = "0.1.0" +authors = { workspace = true } description = "A generic parachain runtime template" +edition = { workspace = true } license = { workspace = true } -authors = { workspace = true } repository = { workspace = true } -edition = "2021" +version = "0.1.0" [package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[build-dependencies] -substrate-wasm-builder = { workspace = true } +targets = [ "x86_64-unknown-linux-gnu" ] [dependencies] -parity-scale-codec = { workspace = true, features = [ "derive" ] } hex-literal = { workspace = true, optional = true } log = { workspace = true } +parity-scale-codec = { workspace = true, features = [ "derive" ] } scale-info = { workspace = true, features = [ "derive" ] } smallvec = { workspace = true } @@ -35,13 +32,13 @@ pallet-aura = { workspace = true } pallet-authorship = { workspace = true } pallet-balances = { workspace = true } pallet-multisig = { workspace = true } -pallet-session = { workspace = true } pallet-proxy = { workspace = true } +pallet-session = { workspace = true } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } -pallet-utility = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } +pallet-utility = { workspace = true } sp-api = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } @@ -78,10 +75,12 @@ parachain-info = { workspace = true } [dev-dependencies] sp-io = { workspace = true } +[build-dependencies] +substrate-wasm-builder = { workspace = true } + [features] -default = ["std"] +default = [ "std" ] std = [ - "parity-scale-codec/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -102,17 +101,17 @@ std = [ "pallet-authorship/std", "pallet-balances/std", "pallet-collator-selection/std", - "pallet-template/std", "pallet-proxy/std", - "pallet-multisig/std", "pallet-session/std", "pallet-sudo/std", + "pallet-template/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-utility/std", "pallet-xcm/std", "parachain-info/std", + "parity-scale-codec/std", "polkadot-parachain-primitives/std", "polkadot-runtime-common/std", "scale-info/std", @@ -146,17 +145,16 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", - "pallet-template/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", + "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "polkadot-runtime-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", ] try-runtime = [ @@ -174,17 +172,18 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", "pallet-multisig/try-runtime", - "pallet-template/try-runtime", - "pallet-session/try-runtime", "pallet-proxy/try-runtime", + "pallet-session/try-runtime", + "pallet-session/try-runtime", "pallet-sudo/try-runtime", + "pallet-template/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", + "pallet-utility/try-runtime", "pallet-xcm/try-runtime", "parachain-info/try-runtime", "polkadot-runtime-common/try-runtime", "sp-runtime/try-runtime", - "pallet-utility/try-runtime", ] -experimental = ["pallet-aura/experimental"] +experimental = [ "pallet-aura/experimental" ] diff --git a/scripts/check-toml-sorted.sh b/scripts/check-toml-sorted.sh new file mode 100644 index 00000000..6b160d4d --- /dev/null +++ b/scripts/check-toml-sorted.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +find . -name "Cargo.toml" -not -path "*/target/*" -exec toml-sort {} \; + +CMD="git diff --name-only" + +stdbuf -oL $CMD | { + while IFS= read -r line; do + echo ║ $line + if [[ "$line" == *"Cargo.toml" ]]; then + echo "Check fails: $line" + echo "Please run './scripts/toml-sort.sh' to format Cargo.toml files properly." + exit 1 + fi + done +} diff --git a/scripts/toml-sort.sh b/scripts/toml-sort.sh new file mode 100755 index 00000000..8b40bcad --- /dev/null +++ b/scripts/toml-sort.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# From the workspace directory, run : +# ./scripts/toml-sort.sh +# to format all Cargo.toml files, and +# ./scripts/toml-sort.sh --check +# to only check the formatting. + +if ! type "toml-sort" > /dev/null; then + echo "Run 'cargo install --git https://github.com/4meta5/toml_sort'" +else + find . -name "Cargo.toml" -not -path "*/target/*" -exec toml-sort {} $@ \; +fi \ No newline at end of file diff --git a/toml-sort.toml b/toml-sort.toml new file mode 100644 index 00000000..fe030a7e --- /dev/null +++ b/toml-sort.toml @@ -0,0 +1,29 @@ +keys = [ + "workspace", + "name", + "package", + "bin", + "lib", + "test", + "dependencies", + "dev-dependencies", + "build-dependencies", + "features", + "default", + "std", +] + +inline_keys = [ + "package", + "workspace", + "path", + "git", + "branch", + "rev", + "version", + "default-features", + "optional", + "features", +] + +sort_string_arrays = true