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

Auto-enforce code formatting #590

Merged
merged 38 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b8e7bbe
Bump version to 3.2.0
Dengjianping Jun 6, 2022
9542f40
Update weights and remove storage of pallet version from pallet-sudo
Dengjianping Jun 7, 2022
03d0a1b
Revert tx version
Dengjianping Jun 7, 2022
294d10b
Update weights for dolphin
Dengjianping Jun 8, 2022
238b161
Allow eAccountKey20 based location
Dengjianping Jun 9, 2022
8e28e34
Impl try-runtime for asset-manager
Dengjianping Jun 9, 2022
e1f289c
Merge branch 'manta' into release-v3.2.0
Dengjianping Jun 10, 2022
28a71f0
test
ghzlatarev Jun 10, 2022
defaba4
test
ghzlatarev Jun 10, 2022
e2b5899
test
ghzlatarev Jun 10, 2022
ecfd5d0
test
ghzlatarev Jun 10, 2022
9d11a01
check
ghzlatarev Jun 10, 2022
d2c2444
correct
ghzlatarev Jun 10, 2022
d53c8d2
rustfmt changes, rename file_header.txt
Jun 10, 2022
0c0a780
Autocorrects from `cargo +nightly fmt --all`
Jun 10, 2022
5a63bc7
Sync all license headers
Jun 10, 2022
64ca0ea
Add taplo rules and fix cargo.toml
Jun 10, 2022
74d16ce
Merge remote-tracking branch 'origin/ghzlatarev/check-linter' into ga…
Jun 10, 2022
44ba4d6
Add taplo to CI
Jun 10, 2022
87fea35
manual clippy fixes
Jun 10, 2022
97b65b5
clippy: autofixes
Jun 10, 2022
04f440b
Reorder BaseFilter in FORBIDDEN->ALLOWED fallthrough order
Jun 10, 2022
813dccc
fix edition for direct rustfmt invocation (needed by trunk)
Jun 11, 2022
e363edc
clippy: fix remaining autocorrected warnings
Jun 11, 2022
dea0e4a
fix taplo invocation for CI
Jun 11, 2022
0f976a1
speedup check&clippy in CI by adding SKIP_WASM_BUILD
Jun 11, 2022
060f172
save a cargo check run as clippy is a superset of check
Jun 11, 2022
026b7f2
Attempt to get an unformatted toml through CI
Jun 11, 2022
668a81d
Revert "Attempt to get an unformatted toml through CI"
Jun 11, 2022
00089d8
Remove stable rust from CI
Jun 11, 2022
e317b03
attempt to get an unformatted sourcefile through CI
Jun 11, 2022
01637f4
Revert "attempt to get an unformatted sourcefile through CI"
Jun 11, 2022
ceda9f8
tweak editorconfig
Jun 11, 2022
aab43d7
Merge branch 'manta' into garandor/reformat
Jun 14, 2022
3fbe64a
remove leftover comment
Jun 14, 2022
2f1bc8b
Merge branch 'manta' into garandor/reformat
Jun 15, 2022
8078a68
manually change every tab in a .rs file to 4 spaces
Jun 16, 2022
d218e0b
Adapt weight file generation template,thanks @Dengjianping
Jun 16, 2022
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
15 changes: 11 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ root = true
[*.rs]
charset=utf-8
end_of_line=lf
indent_size=space
indent_size=4
indent_style=space
insert_final_newline=true
max_line_length=100
tab_width=4
trim_trailing_whitespace=true

[*.toml]
end_of_line=lf
indent_size=2
indent_style=space
trim_trailing_whitespace=true

[*.md]
insert_final_newline=true
trim_trailing_whitespace=true

[*.yml]
end_of_line=lf
indent_size=2
indent_style=space
tab_width=8

[*.sh]
end_of_line=lf
indent_size=2
indent_style=space
tab_width=8
132 changes: 66 additions & 66 deletions .github/resources/frame-weight-template.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2020-2022 Manta Network.
// This file is part of Manta.

//
// Manta is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

//
// Manta is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

//
// You should have received a copy of the GNU General Public License
// along with Manta. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -34,76 +34,76 @@ use sp_std::marker::PhantomData;

/// Weight functions needed for {{pallet}}.
pub trait WeightInfo {
{{#each benchmarks as |benchmark|}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{c.name}}: u32, {{/each~}}
) -> Weight;
{{/each}}
{{#each benchmarks as |benchmark|}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{c.name}}: u32, {{/each~}}
) -> Weight;
{{/each}}
}

/// Weights for {{pallet}} using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> {{pallet}}::WeightInfo for SubstrateWeight<T> {
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
({{underscore benchmark.base_weight}} as Weight)
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
{{/each}}
}
{{/each}}
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
({{underscore benchmark.base_weight}} as Weight)
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
{{/each}}
}
{{/each}}
}

// For backwards compatibility and tests
impl WeightInfo for () {
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
({{underscore benchmark.base_weight}} as Weight)
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
{{/each}}
}
{{/each}}
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
({{underscore benchmark.base_weight}} as Weight)
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
{{/each}}
}
{{/each}}
}
15 changes: 8 additions & 7 deletions .github/workflows/check_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,26 @@ jobs:
run: |
curl -s https://sh.rustup.rs -sSf | sh -s -- -y
source ${HOME}/.cargo/env
rustup toolchain install stable
rustup toolchain install nightly
rustup default stable
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup default nightly
rustup update
cargo install taplo-cli
-
name: Run yamllint
uses: actionshub/yamllint@main
-
name: Check Clippy & Formatting
name: Check Formatting
env:
RUST_BACKTRACE: full
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: /home/runner/.cache/sccache
run: |
source ${HOME}/.cargo/env
SKIP_WASM_BUILD=1 cargo clippy
SKIP_WASM_BUILD=1 cargo fmt
cargo fmt --all -- --check
$HOME/.cargo/bin/taplo fmt --check
$HOME/.cargo/bin/taplo lint
-
name: Check Build
env:
Expand All @@ -111,8 +112,8 @@ jobs:
SCCACHE_DIR: /home/runner/.cache/sccache
run: |
source ${HOME}/.cargo/env
cargo check --no-default-features
cargo check --all-features
SKIP_WASM_BUILD=1 cargo check --no-default-features
SKIP_WASM_BUILD=1 cargo clippy --all-targets --all-features -- -D warnings
-
name: stop sccache server
run: sccache --stop-server || true
Expand Down
5 changes: 3 additions & 2 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
hard_tabs=true
imports_granularity="Crate"
edition = '2021' # Needed for direct invocation of rustfmt ourside of cargo fmt
imports_granularity = "Crate"
license_template_path = "FILE_TEMPLATE"
4 changes: 4 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[formatting]
array_auto_collapse = false
array_auto_expand = false
reorder_keys = true
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[workspace]
resolver = "2"
members = [
'node',
'pallets/*',
'runtime/manta',
'runtime/calamari',
'runtime/dolphin',
'runtime/common',
'primitives',
'node',
'pallets/*',
'runtime/manta',
'runtime/calamari',
'runtime/dolphin',
'runtime/common',
'primitives',
]
resolver = "2"

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

[profile.release]
Expand Down
File renamed without changes.
Loading