Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: formatting #184

Merged
merged 18 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Git Hooks

A pre-push hook which checks formatting of Rust files. Additional checks may be added in the future.

# Prerequisites

The following prerequisites are required:

## Rust Nightly

The nightly version of Rust provides additional formatting benefits over the stable version.

```shell
rustup toolchain install nightly --profile minimal --component rustfmt
```

# Installation

Use the following command in the root directory of the local repository to configure Git to use the hooks:

```shell
git config core.hooksPath .githooks
```

14 changes: 14 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -eu

# Check Rust formatting
if ! cargo +nightly fmt --all -- --check
then
echo "There are some code style issues."
# shellcheck disable=SC2006
echo "Run 'cargo +nightly fmt --all' first."
exit 1
fi

exit 0
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Check formatting
run: cargo +stable fmt --all -- --check
run: |
rustup toolchain install nightly --profile minimal --component rustfmt
cargo +nightly fmt --all -- --check

- name: Check manifests
run: |
cargo install taplo-cli --locked
taplo format --check

- name: Check features
run: |
cargo install zepter --locked
zepter lint propagate-feature --feature try-runtime --left-side-feature-missing=ignore --workspace --feature-enables-dep="try-runtime:frame-try-runtime" --locked
zepter lint propagate-feature --feature runtime-benchmarks --left-side-feature-missing=ignore --workspace --feature-enables-dep="runtime-benchmarks:frame-benchmarking" --locked
zepter lint propagate-feature --feature std --left-side-feature-missing=ignore --workspace --locked
zepter format features

check:
needs: lint
Expand All @@ -33,6 +50,7 @@ jobs:
permissions:
checks: write
env:
RUSTFLAGS: "-Wmissing_docs"
SKIP_WASM_BUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down
32 changes: 16 additions & 16 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Basic
# Non-default formatting configuration options: use with `cargo +nightly fmt --all`
binop_separator = "Back"
chain_width = 80
combine_control_expr = false
comment_width = 100
condense_wildcard_suffixes = true
edition = "2021"
format_code_in_doc_comments = true
format_strings = true
group_imports = "StdExternalCrate"
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
# Consistency
newline_style = "Unix"
# Misc
chain_width = 80
spaces_around_ranges = false
binop_separator = "Back"
reorder_impl_items = false
match_arm_leading_pipes = "Preserve"
match_arm_blocks = false
match_block_trailing_comma = true
trailing_comma = "Vertical"
newline_style = "Unix"
normalize_comments = true
reorder_impl_items = true
trailing_semicolon = false
unstable_features = true
use_field_init_shorthand = true
# Format comments
comment_width = 100
# Uses max_width or its default value (100) if not specified.
use_small_heuristics = "Max"
use_try_shorthand = true
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
wrap_comments = true
17 changes: 17 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# all options https://taplo.tamasfe.dev/configuration/formatter-options.html

exclude = [ "networks/**", "target/**" ]

# global rules
[formatting]
array_auto_collapse = false
array_auto_expand = true
compact_arrays = false # zepter compatibility
indent_string = " " # tab
inline_table_expand = false
reorder_arrays = true
reorder_keys = true

[[rule]]
include = [ "Cargo.toml" ]
keys = [ "workspace.dependencies" ]
106 changes: 53 additions & 53 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,73 @@
panic = "unwind"

[profile.production]
codegen-units = 1
inherits = "release"
lto = true
codegen-units = 1

[workspace.package]
authors = ["R0GUE <go@r0gue.io>"]
authors = [ "R0GUE <go@r0gue.io>" ]
description = "Pop Network makes it easy for smart contract developers to use the Power of Polkadot."
edition = "2021"
homepage = "https://r0gue.io"
license = "Unlicense"
repository = "https://github.com/r0gue-io/pop-node/"
description = "Pop Network makes it easy for smart contract developers to use the Power of Polkadot."

[workspace]
exclude = [ "pop-api", "tests/contracts" ]
members = [
"node",
"runtime/devnet",
"runtime/testnet",
"integration-tests",
"primitives",
"integration-tests",
"node",
"primitives",
"runtime/devnet",
"runtime/testnet",
]
exclude = ["pop-api", "tests/contracts"]

resolver = "2"

[workspace.dependencies]
clap = { version = "4.4.18", features = [ "derive" ] }
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
"derive",
"derive",
] }
futures = "0.3.28"
hex-literal = "0.4.1"
jsonrpsee = { version = "0.23.2", features = [ "server" ] }
log = { version = "0.4.21", default-features = false }
scale-info = { version = "2.11.1", default-features = false, features = [
"derive",
"derive",
] }
smallvec = "1.11.2"
serde = "1.0.197"
clap = { version = "4.4.18", features = ["derive"] }
jsonrpsee = { version = "0.23.2", features = ["server"] }
futures = "0.3.28"
serde_json = "1.0.114"
tracing-subscriber = { version = "0.3", default-features = false }
smallvec = "1.11.2"
subxt = "0.34.0"
subxt-signer = "0.34.0"
tokio = { version = "1.36", features = ["macros", "time", "rt-multi-thread"] }
tokio = { version = "1.36", features = [ "macros", "rt-multi-thread", "time" ] }
tracing-subscriber = { version = "0.3", default-features = false }

# Build
substrate-build-script-utils = "11.0.0"
substrate-wasm-builder = "23.0.0"

# Local
pop-primitives = { path = "./primitives", default-features = false }
pop-runtime-common = { path = "runtime/common", default-features = false }
pop-runtime-devnet = { path = "runtime/devnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-testnet = { path = "runtime/testnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-common = { path = "runtime/common", default-features = false }
pop-primitives = { path = "./primitives", default-features = false }

# Substrate
sc-basic-authorship = "0.42.0"
sc-chain-spec = "35.0.0"
sc-cli = "0.44.0"
sc-client-api = "35.1.0"
sc-offchain = "37.0.0"
sc-consensus = "0.41.0"
sc-executor = "0.39.0"
sc-network = "0.42.0"
sc-network-sync = "0.41.0"
sc-rpc = "37.0.0"
sc-service = "0.43.0"
sc-sysinfo = "35.0.0"
sc-telemetry = "22.0.0"
sc-tracing = "35.0.0"
sc-transaction-pool = "35.0.0"
sc-transaction-pool-api = "35.0.0"
frame-benchmarking = { version = "36.0.0", default-features = false }
frame-benchmarking-cli = "40.0.0"
frame-executive = { version = "36.0.0", default-features = false }
frame-metadata-hash-extension = { version = "0.4.0", default-features = false }
frame-support = { version = "36.0.0", default-features = false }
frame-system = { version = "36.1.0", default-features = false }
frame-system-benchmarking = { version = "36.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "33.0.0", default-features = false }
frame-try-runtime = { version = "0.42.0", default-features = false }
frame-metadata-hash-extension = { version = "0.4.0", default-features = false }
pallet-assets = { version = "37.0.0", default-features = false }
pallet-aura = { version = "35.0.0", default-features = false }
pallet-authorship = { version = "36.0.0", default-features = false }
pallet-assets = { version = "37.0.0", default-features = false }
pallet-balances = { version = "37.0.0", default-features = false }
pallet-contracts = { version = "35.0.0", default-features = false }
pallet-message-queue = { version = "39.0.0", default-features = false }
Expand All @@ -103,6 +87,22 @@ pallet-transaction-payment-rpc = "38.0.0"
pallet-transaction-payment-rpc-runtime-api = { version = "36.0.0", default-features = false }
pallet-utility = { version = "36.0.0", default-features = false }
prometheus-endpoint = { version = "0.17.0", default-features = false, package = "substrate-prometheus-endpoint" }
sc-basic-authorship = "0.42.0"
sc-chain-spec = "35.0.0"
sc-cli = "0.44.0"
sc-client-api = "35.1.0"
sc-consensus = "0.41.0"
sc-executor = "0.39.0"
sc-network = "0.42.0"
sc-network-sync = "0.41.0"
sc-offchain = "37.0.0"
sc-rpc = "37.0.0"
sc-service = "0.43.0"
sc-sysinfo = "35.0.0"
sc-telemetry = "22.0.0"
sc-tracing = "35.0.0"
sc-transaction-pool = "35.0.0"
sc-transaction-pool-api = "35.0.0"
sp-api = { version = "33.0.0", default-features = false }
sp-authority-discovery = { version = "33.0.0", default-features = false }
sp-block-builder = { version = "33.0.0", default-features = false }
Expand All @@ -112,57 +112,57 @@ sp-consensus-babe = { version = "0.39.0", default-features = false }
sp-consensus-beefy = { version = "20.0.0", default-features = false }
sp-consensus-grandpa = { version = "20.0.0", default-features = false }
sp-core = { version = "34.0.0", default-features = false }
sp-keystore = "0.40.0"
sp-io = { version = "37.0.0", default-features = false }
sp-genesis-builder = { version = "0.14.0", default-features = false }
sp-inherents = { version = "33.0.0", default-features = false }
sp-io = { version = "37.0.0", default-features = false }
sp-keystore = "0.40.0"
sp-offchain = { version = "33.0.0", default-features = false }
sp-runtime = { version = "38.0.0", default-features = false }
sp-timestamp = "33.0.0"
substrate-frame-rpc-system = "36.0.0"
sp-session = { version = "34.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-timestamp = "33.0.0"
sp-transaction-pool = { version = "33.0.0", default-features = false }
sp-version = { version = "36.0.0", default-features = false }
substrate-frame-rpc-system = "36.0.0"

# Polkadot
pallet-xcm = { version = "15.0.0", default-features = false }
polkadot-cli = "15.0.0"
polkadot-parachain-primitives = { version = "13.0.0", default-features = false }
polkadot-runtime-parachains = { version = "15.0.3", default-features = false }
polkadot-primitives = { version = "14.0.0", default-features = false }
polkadot-runtime-common = { version = "15.0.0", default-features = false }
rococo-runtime-constants = { version = "15.0.0", default-features = false }
polkadot-runtime-parachains = { version = "15.0.3", default-features = false }
rococo-runtime = { version = "15.0.0", default-features = false }
rococo-runtime-constants = { version = "15.0.0", default-features = false }
xcm = { version = "14.0.3", package = "staging-xcm", default-features = false }
xcm-builder = { version = "15.0.0", package = "staging-xcm-builder", default-features = false }
xcm-executor = { version = "15.0.0", package = "staging-xcm-executor", default-features = false }

# Cumulus
asset-hub-rococo-runtime = { version = "0.19.0", default-features = false }
asset-test-utils = { version = "15.0.0", default-features = false }
color-print = "0.3.4"
cumulus-client-cli = "0.15.0"
cumulus-client-collator = "0.15.0"
cumulus-client-consensus-aura = "0.15.0"
cumulus-client-consensus-common = "0.15.0"
cumulus-client-consensus-proposer = "0.14.0"
cumulus-client-service = "0.15.0"
cumulus-pallet-aura-ext = { version = "0.15.0", default-features = false }
cumulus-pallet-parachain-system = { version = "0.15.0", default-features = false }
cumulus-pallet-session-benchmarking = { version = "17.0.0", default-features = false }
cumulus-pallet-xcm = { version = "0.15.0", default-features = false }
cumulus-pallet-xcmp-queue = { version = "0.15.0", default-features = false }
cumulus-primitives-aura = { version = "0.14.0", default-features = false }
cumulus-primitives-core = { version = "0.14.0", default-features = false }
cumulus-primitives-parachain-inherent = "0.14.0"
cumulus-primitives-storage-weight-reclaim = { version = "6.0.2", default-features = false }
cumulus-primitives-utility = { version = "0.15.0", default-features = false }
cumulus-relay-chain-interface = "0.15.0"
emulated-integration-tests-common = { version = "11.0.0", default-features = false }
pallet-collator-selection = { version = "17.0.0", default-features = false }
parachains-common = { version = "15.0.0", default-features = false }
parachain-info = { version = "0.15.0", package = "staging-parachain-info", default-features = false }
cumulus-primitives-parachain-inherent = "0.14.0"
cumulus-relay-chain-interface = "0.15.0"
color-print = "0.3.4"
cumulus-client-cli = "0.15.0"
cumulus-client-collator = "0.15.0"
cumulus-client-consensus-aura = "0.15.0"
cumulus-client-consensus-common = "0.15.0"
cumulus-client-consensus-proposer = "0.14.0"
cumulus-client-service = "0.15.0"
parachains-common = { version = "15.0.0", default-features = false }

# TODO: Paseo (note: using polkadot as stopgap until paseo updated to polkadot sdk v1.14.0)
asset-hub-paseo-runtime = { git = "https://github.com/polkadot-fellows/runtimes", default-features = false, package = "asset-hub-polkadot-runtime" }
Expand Down
Loading
Loading