Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Relocate weight to paint + decouple from extensions #4124

Merged
merged 16 commits into from
Nov 22, 2019

Conversation

kianenigma
Copy link
Contributor

  • Makes SignedExtension independent of the type of the weight data, allowing a potential user to actually not have any sort of weight or class by setting type Info = ().

  • Moves the weight related stuff to support, since they are part of our opinionated runtime.

Looks like we need a follow up PR to move all the extrinsic stuff to paint, but I'll do that in a follow up, since this has a bit of logic change in signed extension.

@kianenigma kianenigma added the A0-please_review Pull request needs code review. label Nov 18, 2019
@@ -8,7 +8,7 @@ edition = "2018"
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
sr-primitives = { path = "../../primitives/sr-primitives", default-features = false }
phragmen = { package = "substrate-phragmen", path = "../../primitives/phragmen", default-features = false }
paint-support = { path = "../support", default-features = false }
support = { package = "paint-support", path = "../support", default-features = false }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as soon as names are settled, one should make a PR and unify all of such imports.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we no longer want to do renames?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, but see my note:

as soon as names are settled, one should make a PR and unify all of such imports.

at least now that almost everywhere we use paint-support as support, having consistency is better IMO + makes sed-ing much easier. As mentioned, I'm more than happy to kill all of these as soon as we are done with paint -> palette.

@kianenigma kianenigma changed the title Fisr migrated version of weight to paint Relocate weight to paint + decouple from extensions Nov 18, 2019
@@ -8,7 +8,7 @@ edition = "2018"
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
sr-primitives = { path = "../../primitives/sr-primitives", default-features = false }
phragmen = { package = "substrate-phragmen", path = "../../primitives/phragmen", default-features = false }
paint-support = { path = "../support", default-features = false }
support = { package = "paint-support", path = "../support", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we no longer want to do renames?

paint/contracts/src/lib.rs Outdated Show resolved Hide resolved
paint/support/src/weights.rs Outdated Show resolved Hide resolved
@@ -23,11 +23,11 @@ pub use paint_metadata::{
FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata,
ModuleConstantMetadata, DefaultByte, DefaultByteGetter, ModuleErrorMetadata, ErrorMetadata
};
pub use crate::weights::{
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really worth to re-export? This stuff is in the same crate, I don't see a point - it will just introduce ambiguity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK: This stuff, similar to other re-exports of the module are needed to be accessed from within the macro. I learned this by example. @bkchr can probably either explain more or correct me.

@@ -56,7 +56,7 @@ type NegativeImbalanceOf<T> =

pub trait Trait: system::Trait {
/// The currency type in which fees will be paid.
type Currency: Currency<Self::AccountId>;
type Currency: Currency<Self::AccountId> + Send + Sync;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate why is Send + Sync required? I wouldn't expect to see that in any part of runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I didn't really care much since I have seen these two in all SignedExtension type. For instance:

impl<T: Trait + Send + Sync> SignedExtension for CheckWeight<T> {

So I assumed it is okay. But I will look it up.

although, we use Send + Sync in Member which is used around the runtime, so just by observation, I would not assume that we ban them in runtime. Although it does makes sense that a single threaded runtime should not really need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed due to AccountId being Member.

primitives/sr-primitives/src/traits.rs Outdated Show resolved Hide resolved
@@ -713,6 +712,9 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq
/// The type that encodes information that can be passed from pre_dispatch to post-dispatch.
type Pre: Default;

/// An opaque set of information attached to the transaction.
type Info: Copy;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy is a pretty strict, why not just Clone?

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 did face the dilemma and at the time the rational was: while we are making Type Info be generic but we currently know that we'll use it with a type that has Copy and this makes the syntax much much easier for now. If we see Copy as merely a marker that clone is cheap, I think it is fair to say that this bundled information will always be cheap to copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

naah made it clone, was easier than what I thought to refactor.

@kianenigma kianenigma requested a review from tomusdrw November 20, 2019 14:14
@kianenigma
Copy link
Contributor Author

will need some minor refactoring in polkadot

palette/executive/src/lib.rs Outdated Show resolved Hide resolved
palette/membership/src/lib.rs Outdated Show resolved Hide resolved
kianenigma and others added 2 commits November 22, 2019 10:26
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
@kianenigma kianenigma merged commit f718dd0 into master Nov 22, 2019
@kianenigma kianenigma deleted the kiz-relocate-weight-stuff branch November 22, 2019 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants