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

require explicit pallet indexes #821

Merged
merged 53 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
13c7ada
add pallet index lint
sam0x17 Sep 16, 2024
3fd7696
WIP
sam0x17 Sep 17, 2024
b6c7165
silence warnings
sam0x17 Sep 17, 2024
5b24374
checkpoint
sam0x17 Sep 18, 2024
ca3c9f4
closer
sam0x17 Sep 18, 2024
d495812
still 2 test failures
sam0x17 Sep 18, 2024
11ca35f
close
sam0x17 Sep 18, 2024
57eb750
WIP
sam0x17 Sep 18, 2024
23b4a68
add procedural-fork stub
sam0x17 Sep 18, 2024
c23485f
add update.sh script
sam0x17 Sep 18, 2024
fdd33fb
add debugging
sam0x17 Sep 18, 2024
69410ac
update script
sam0x17 Sep 18, 2024
021ac06
local no-proc-macro fork of frame-support-procedural
sam0x17 Sep 18, 2024
dd5c84b
fix warnings
sam0x17 Sep 18, 2024
15fedec
publicly export everything
sam0x17 Sep 18, 2024
4723377
add docs
sam0x17 Sep 18, 2024
aa57e9c
tweak
sam0x17 Sep 18, 2024
6122efa
new lint using procedural-fork
sam0x17 Sep 18, 2024
523d469
passing :tada: :tada: :boom: !!!
sam0x17 Sep 18, 2024
160c7b2
more test examples
sam0x17 Sep 18, 2024
6b46371
refactor to use quote! directly
sam0x17 Sep 18, 2024
ff1cb0d
use explicit unwrap for testing purposes
sam0x17 Sep 18, 2024
ed529c7
handle implicit
sam0x17 Sep 18, 2024
edbaf38
fully handling all construct_runtime variants
sam0x17 Sep 18, 2024
b19854e
fully working, need to fix existing construct_runtime!s now
sam0x17 Sep 18, 2024
6dd376e
always use explicit pallet indexing :cool:
sam0x17 Sep 18, 2024
a1bd6eb
nearly
sam0x17 Sep 19, 2024
b39ef20
track original source text
sam0x17 Sep 19, 2024
d78c226
100% working
sam0x17 Sep 19, 2024
b98ef6e
fixed
sam0x17 Sep 19, 2024
5f457d8
intentionally fail CI to make sure this is caught automatically
sam0x17 Sep 19, 2024
a05aa81
fix procedural-fork tests
sam0x17 Sep 19, 2024
2c2247f
cargo fmt
sam0x17 Sep 19, 2024
b998f4b
suppress warnings in test mode
sam0x17 Sep 19, 2024
a1b057c
cargo clippy --fix --workspace --all-features
sam0x17 Sep 19, 2024
f8f2b95
supporess procedural-fork clippy warnings
sam0x17 Sep 19, 2024
4a194d3
allow more in procedural-fork
sam0x17 Sep 19, 2024
6985939
tweak
sam0x17 Sep 19, 2024
28b74fe
allow clippy::all in procedural-fork
sam0x17 Sep 19, 2024
2a35d78
successfully suppress clippy in procedural-fork
sam0x17 Sep 19, 2024
3ffcdec
cargo fmt --all
sam0x17 Sep 19, 2024
47db25a
allow unwrap in pallet index tests
sam0x17 Sep 19, 2024
22ba77c
fix lint check in CI
sam0x17 Sep 19, 2024
3ea6cf6
fix lint check again
sam0x17 Sep 19, 2024
bbab17a
lint check confirmed working in CI, fixing canary!
sam0x17 Sep 19, 2024
b4b7175
undo clippy changes to procedural-fork since we have silenced
sam0x17 Sep 19, 2024
f0d85ac
cargo fmt --all
sam0x17 Sep 19, 2024
060787a
cargo fmt
sam0x17 Sep 19, 2024
be0312c
fix newline
sam0x17 Sep 19, 2024
c368ce3
exclude procedural-fork tests
sam0x17 Sep 23, 2024
0564138
ignore procedural-fork tests via a cfg gate
sam0x17 Sep 23, 2024
4dd15c9
fix lint allow
sam0x17 Sep 23, 2024
c428641
revert lint change
sam0x17 Sep 23, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ jobs:

- name: check lints
run: |
set -o pipefail # Ensure the pipeline fails if any command in the pipeline fails
cargo check 2>&1 | sed -r "s/\x1B\[[0-9;]*[mK]//g" | tee /dev/tty | grep -q "^warning:" && \
(echo "Build emitted the following warnings:" >&2 && exit 1) || echo "No warnings found."
set -o pipefail
cargo check 2>&1 | sed -r "s/\x1B\[[0-9;]*[mK]//g" | grep "warning:" && exit 1
echo "No warnings found."

cargo-clippy-all-features:
name: cargo clippy --all-features
Expand Down
80 changes: 69 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ members = [
"runtime",
"support/tools",
"support/macros",
"support/linting",
"support/linting", "support/procedural-fork",
sam0x17 marked this conversation as resolved.
Show resolved Hide resolved
]
resolver = "2"

Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn main() {
};

track_lint(RequireFreezeStruct::lint(&parsed_file));
track_lint(RequireExplicitPalletIndex::lint(&parsed_file));
});

// Collect and print all errors after the parallel processing is done
Expand Down
10 changes: 5 additions & 5 deletions pallets/admin-utils/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
AdminUtils: pallet_admin_utils,
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>, Error<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
System: frame_system = 1,
Balances: pallet_balances = 2,
AdminUtils: pallet_admin_utils = 3,
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>, Error<T>} = 4,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 5,
}
);

Expand Down
10 changes: 5 additions & 5 deletions pallets/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, u64,
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system::{Pallet, Call, Event<T>},
Collective: pallet_collective::<Instance1>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
CollectiveMajority: pallet_collective::<Instance2>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
DefaultCollective: pallet_collective::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
Democracy: mock_democracy::{Pallet, Call, Event<T>},
System: frame_system::{Pallet, Call, Event<T>} = 1,
Collective: pallet_collective::<Instance1>::{Pallet, Call, Event<T>, Origin<T>, Config<T>} = 2,
CollectiveMajority: pallet_collective::<Instance2>::{Pallet, Call, Event<T>, Origin<T>, Config<T>} = 3,
DefaultCollective: pallet_collective::{Pallet, Call, Event<T>, Origin<T>, Config<T>} = 4,
Democracy: mock_democracy::{Pallet, Call, Event<T>} = 5,
}
);
mod mock_democracy {
Expand Down
4 changes: 2 additions & 2 deletions pallets/commitments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Commitments: pallet_commitments,
System: frame_system = 1,
Commitments: pallet_commitments = 2,
}
);

Expand Down
6 changes: 3 additions & 3 deletions pallets/commitments/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, u64,
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Commitments: pallet_commitments
System: frame_system = 1,
Balances: pallet_balances = 2,
Commitments: pallet_commitments = 3,
}
);

Expand Down
4 changes: 2 additions & 2 deletions pallets/registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
TemplateModule: pallet_template,
System: frame_system = 1,
TemplateModule: pallet_template = 2,
}
);

Expand Down
20 changes: 10 additions & 10 deletions pallets/subtensor/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Config<T>, Storage, Event<T>},
Triumvirate: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TriumvirateMembers: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
Senate: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
SenateMembers: pallet_membership::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>},
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>},
Utility: pallet_utility::{Pallet, Call, Storage, Event},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>} = 1,
Balances: pallet_balances::{Pallet, Call, Config<T>, Storage, Event<T>} = 2,
Triumvirate: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 3,
TriumvirateMembers: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 4,
Senate: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 5,
SenateMembers: pallet_membership::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>} = 6,
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>} = 7,
Utility: pallet_utility::{Pallet, Call, Storage, Event} = 8,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 9,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 10,
}
);

Expand Down
1 change: 1 addition & 0 deletions support/linting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
syn.workspace = true
quote.workspace = true
proc-macro2.workspace = true
procedural-fork = { version = "1.10.0-rc3", path = "../procedural-fork" }
sam0x17 marked this conversation as resolved.
Show resolved Hide resolved

[lints]
workspace = true
2 changes: 2 additions & 0 deletions support/linting/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod lint;
pub use lint::*;

mod pallet_index;
mod require_freeze_struct;

pub use pallet_index::RequireExplicitPalletIndex;
pub use require_freeze_struct::RequireFreezeStruct;
Loading
Loading