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

[FRAME] Storage derive macro #[frame_support::stored] #4079

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Apr 11, 2024

WIP DNM

Some examples:

/// Ignore T and require S to be MEL.
#[frame_support::stored(skip(T), mel(S))]
struct A<S, T>(::core::marker::PhantomData<(S, T)>);

/// Only create a custom bound for MEL:
#[frame_support::stored(skip(S, T), mel_bound(S: MaxEncodedLen + Encode, T: MaxEncodedLen + Encode))]
struct A<S, T>(::core::marker::PhantomData<(S, T)>);

/// Overwrite the standard MEL bound with a custom one.
#[frame_support::stored(mel_bound(S: MaxEncodedLen + Encode, T: MaxEncodedLen + Encode))]
struct A<S, T>(::core::marker::PhantomData<(S, T)>);

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
#[scale_info(skip_type_params(Total))]
#[codec(mel_bound(Votes: MaxEncodedLen))]
#[derive(CloneNoBound, PartialEqNoBound, EqNoBound, RuntimeDebugNoBound)]
#[frame_support::stored(skip(Total), mel(Votes))]
pub struct Tally<Votes: Clone + PartialEq + Eq + Debug + TypeInfo + Codec, Total> {
Copy link
Member Author

@ggwpez ggwpez Apr 11, 2024

Choose a reason for hiding this comment

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

The difficult part about this was to re-add the Clone etc. bounds for all parameters that are not skipped.
And that requires some changes to all of our *NoBound derives. Writing all these bounds like in this case is not so nice... ideally it would do it automatically.

Copy link
Contributor

Choose a reason for hiding this comment

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

if I read it right, mel(Votes) here means do not generate anything for Votes and use whatever is set for it below? wonder why MaxEncodedLen is not needed then?

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6116337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants