-
Notifications
You must be signed in to change notification settings - Fork 754
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
salary pallet migration to umbrella crate #7025
base: master
Are you sure you want to change the base?
Conversation
use sp_core::Get; | ||
|
||
#[allow(deprecated)] | ||
use frame::benchmarking::v1::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use frame::benchmarking::v1::*; | |
use frame::benchmarking::prelude::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, notice that here we have the v2 benchmarking syntax, not the v1 (see here for more details)
substrate/frame/salary/src/lib.rs
Outdated
|
||
}; | ||
use frame::{ | ||
hashing::blake2_256, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hashing
module is already imported in the main prelude, so you don't need this
assert_noop, assert_ok, derive_impl, | ||
pallet_prelude::Weight, | ||
parameter_types, | ||
use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you need them all? Ideally, we would like to have only the testing prelude here because it's a test file and the testing prelude should already contain the other two
}; | ||
|
||
use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, | ||
traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConstU64
is already in the runtime::prelude::*
, which is in the testing_prelude::*
, so it's not needed. Try to double check the other traits and imports, they may already be imported through a prelude.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, to add to that - you might not need all these preludes. Try checking for each import and minimising the number of imports required.
substrate/frame/salary/Cargo.toml
Outdated
@@ -17,43 +17,29 @@ targets = ["x86_64-unknown-linux-gnu"] | |||
|
|||
[dependencies] | |||
codec = { features = ["derive"], workspace = true } | |||
frame-benchmarking = { optional = true, workspace = true } | |||
frame-support = { workspace = true } | |||
frame-system = { workspace = true } | |||
log = { workspace = true } | |||
pallet-ranked-collective = { optional = true, workspace = true } | |||
scale-info = { features = ["derive"], workspace = true } | |||
sp-arithmetic = { workspace = true } | |||
sp-core = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp-core
should be imported from the deps
module to further reduce dependencies outside the umbrella
.
sp-core = { workspace = true } |
substrate/frame/salary/Cargo.toml
Outdated
@@ -17,43 +17,29 @@ targets = ["x86_64-unknown-linux-gnu"] | |||
|
|||
[dependencies] | |||
codec = { features = ["derive"], workspace = true } | |||
frame-benchmarking = { optional = true, workspace = true } | |||
frame-support = { workspace = true } | |||
frame-system = { workspace = true } | |||
log = { workspace = true } | |||
pallet-ranked-collective = { optional = true, workspace = true } | |||
scale-info = { features = ["derive"], workspace = true } | |||
sp-arithmetic = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp-arithmetic
is present in the main prelude
and should be used directly from there instead of adding a dependency to this pallet.
sp-arithmetic = { workspace = true } |
@@ -22,10 +22,9 @@ | |||
use super::*; | |||
use crate::Pallet as Salary; | |||
|
|||
use frame_benchmarking::v2::*; | |||
use frame_system::{Pallet as System, RawOrigin}; | |||
use sp_core::Get; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sp_core::Get; | |
use frame::deps::sp_core::Get; |
substrate/frame/salary/Cargo.toml
Outdated
"frame-benchmarking?/std", | ||
"frame-support/experimental", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"log/std", | ||
"pallet-ranked-collective/std", | ||
"scale-info/std", | ||
"sp-arithmetic/std", | ||
"sp-core/std", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"sp-core/std", |
substrate/frame/salary/Cargo.toml
Outdated
"frame-benchmarking?/std", | ||
"frame-support/experimental", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"log/std", | ||
"pallet-ranked-collective/std", | ||
"scale-info/std", | ||
"sp-arithmetic/std", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"sp-arithmetic/std", |
}; | ||
|
||
use frame::{prelude::*, runtime::prelude::*, testing_prelude::*, | ||
traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, to add to that - you might not need all these preludes. Try checking for each import and minimising the number of imports required.
traits::{Convert, ReduceBy, ReplaceWithDefault}, | ||
BuildStorage, | ||
}; | ||
use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import was originally from frame_support
. Why not -
use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically; | |
use frame::deps::frame_support::hypothetically; |
or add it to one of the preludes where it makes sense?
frame_support::construct_runtime!( | ||
pub enum Test | ||
construct_runtime!( | ||
pub struct Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain a bit as to why did we have to change this from an enum
to a struct
?
@@ -145,9 +144,9 @@ impl pallet_ranked_collective::Config for Test { | |||
type BenchmarkSetup = Salary; | |||
} | |||
|
|||
pub fn new_test_ext() -> sp_io::TestExternalities { | |||
pub fn new_test_ext() -> TestState{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some explanation here as well?
@@ -194,7 +193,7 @@ fn swap_exhaustive_works() { | |||
|
|||
// The events mess up the storage root: | |||
System::reset_events(); | |||
sp_io::storage::root(sp_runtime::StateVersion::V1) | |||
sp_io::storage::root( frame::deps::sp_runtime::StateVersion::V1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the whole path here, let's import this at the top and then use it.
All GitHub workflows were cancelled due to failure one of the required jobs. |
β -----------------------------------------------------------------------------
Thank you for your Pull Request! π Please make sure it follows the contribution guidelines outlined in this
document and fill out the
sections below. Once you're ready to submit your PR for review, please delete this section and leave only the text under
the "Description" heading.
Description
Migrating salary pallet to use umbrella crates
Review Notes
This PR migrates pallet-salary to use the umbrella crate.
β -----------------------------------------------------------------------------