Skip to content

Commit

Permalink
Merge pull request #821 from opentensor/sam-pallet-index
Browse files Browse the repository at this point in the history
require explicit pallet indexes
  • Loading branch information
unconst committed Sep 23, 2024
2 parents 2069a48 + c428641 commit cdbac35
Show file tree
Hide file tree
Showing 101 changed files with 21,037 additions and 41 deletions.
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: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ members = [
"support/tools",
"support/macros",
"support/linting",
"support/procedural-fork",
]
exclude = ["support/procedural-fork"]
resolver = "2"

[workspace.lints.clippy]
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" }

[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

0 comments on commit cdbac35

Please sign in to comment.