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

Migrate pallet-nis benchmark to v2 #6293

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

aurexav
Copy link
Contributor

@aurexav aurexav commented Oct 30, 2024


Polkadot address: 156HGo9setPcU2qhFMVWLkcmtCEGySLwNqa3DaEiYSWtte4Y

@aurexav aurexav requested a review from a team as a code owner October 30, 2024 15:12
@re-gius re-gius added T2-pallets This PR/Issue is related to a particular pallet. T12-benchmarks This PR/Issue is related to benchmarking and weights. labels Nov 14, 2024
substrate/frame/nis/src/benchmarking.rs Outdated Show resolved Hide resolved
@re-gius
Copy link
Contributor

re-gius commented Nov 14, 2024

/cmd prdoc --bump patch --audience runtime_dev

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also migrate this pallet to the umbrella crate, as a part of this migration?

Here's an example PR: #5995

@@ -0,0 +1,10 @@
title: Migrate pallet-nis benchmark to v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should have the label silent and need not have a PRdoc.

Adding this label is something that only our contributors can do atm.

@kianenigma kianenigma added the R0-silent Changes should not be mentioned in any release notes label Nov 15, 2024
@aurexav
Copy link
Contributor Author

aurexav commented Nov 15, 2024

Can you also migrate this pallet to the umbrella crate, as a part of this migration?

Here's an example PR: #5995

Sure, will check that.

@aurexav
Copy link
Contributor Author

aurexav commented Dec 8, 2024

@kianenigma @re-gius, please review.

@aurexav
Copy link
Contributor Author

aurexav commented Dec 8, 2024

/cmd prdoc --bump patch --audience runtime_dev

I updated the PR description. Can I call this?

@re-gius
Copy link
Contributor

re-gius commented Dec 10, 2024

Please take a look at CI errors. Also comment in #6504 if you're migrating pallet-nis to the umbrella crate in this PR.

@re-gius
Copy link
Contributor

re-gius commented Dec 11, 2024

bot bench substrate-pallet --features=runtime-benchmarks --pallet=pallet_nis

@@ -909,7 +909,7 @@ pub mod pallet_prelude {
Task, TypedGet,
},
Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity,
PartialEqNoBound, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat,
PalletId, PartialEqNoBound, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not supposed to change this pallet in the context of migration to the umbrella crate

Copy link
Contributor Author

@aurexav aurexav Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, I have to depend on frame-support and use frame_support::PalletId. I think this is a part of migration to the umbrella crate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add frame_support::PalletId in a prelude in the umbrella crate (file mentioned in the other comment) and avoid changing this pallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

But after some thoughts, I think it's also good to place the PalletId here.

I added PalletId to frame-support's root 3 years ago paritytech/substrate#8477. At that time, there wasn't a really good place for it. I think it's a good time to move it into frame_support::pallet_prelude, it is being used frequently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, I completely agree with you. The problem here is many parachains depend on frame_support, so a major bump in frame_support could cause breaking changes for external teams. This is why we decided to never touch the frame_support prelude for umbrella crate migrations. If you still strongly feel that the frame support prelude needs an update, then it's probably better to group all the changes in a single PR and have a broad discussion about that.

pub use weights::WeightInfo;

use alloc::{vec, vec::Vec};
use frame::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this is Rust-correct, it does not follow the guidelines for migrations to the umbrella crate (see here). For instance, DefensiveSaturating is used across several pallets, so it should go into the main prelude. You should edit this and add new imports into the main preludes according to the guidelines. Ideally, we'd like to have just a use frame::prelude::* statement here. While this won't be probably the case because of ad-hoc imports for this pallet, having these many ad-hoc imports kind of defeats the whole purpose of having the umbrella crate.

Copy link
Contributor Author

@aurexav aurexav Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicts with your previous comment?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should proceed with this once "migrate to umbrella" is completed? I'm uncertain about which one is being utilized most often. Additionally, I've noticed many crates are still referencing use frame::traits::Currency. Isn't Currency a common used trait? Shouldn't it be included in the prelude? There are many aspects that remain quite unclear to me at this moment.

Copy link
Contributor

@re-gius re-gius Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're part of this migration process (if you want to), meaning that as we migrate new pallets to the umbrella crate, we notice that we need to add new imports to the preludes and we do that if those imports affect more than one pallet (see guidelines). The guidelines I mentioned also say why currency-related traits are kept out of this, please take a look.

Adding new imports to the umbrella crate is the main part of this task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well.. That currency guidelines has been collapsed. So I missed that one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, will resolve them today later.

Copy link
Contributor Author

@aurexav aurexav Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fungible, nonfungible and tokens should belong to currency? I didn't expose them to prelude.

There is still a problem. There are a lot of same name traits in those scope.

For example, fungible::Inspect, nofungible::Inspect.

There are 2 ways to resolve this.

  1. Only expose the mod. fungible, nofungible, ..
  2. Give them an alias, pub use fungible::Inspect as FunInspect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, right, then it's maybe better to revert the changes for conflicting names and keep it as it was before

Copy link
Contributor Author

@aurexav aurexav Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't continue the work if the conclusion is "maybe". 😿

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my advice, revert those changes, it's better at this point so that we can merge this

@aurexav
Copy link
Contributor Author

aurexav commented Feb 10, 2025

UP...

@@ -537,6 +544,11 @@ pub mod arithmetic {
pub use sp_arithmetic::{traits::*, *};
}

/// All token related types and traits.
pub mod token {
pub use frame_support::traits::{tokens::*, OnUnbalanced};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokens::* also adds several currency-related traits to the preludes, which should be avoided according to the guidelines. Moreover, you can see from CI that there is an ambiguous duplicate import of Balance for this reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T2-pallets This PR/Issue is related to a particular pallet. T12-benchmarks This PR/Issue is related to benchmarking and weights.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants