Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

[MOON-1460] change eligibility ratio to be a number #38

Merged
merged 24 commits into from
Mar 29, 2022

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Mar 18, 2022

Updates eligibility ratio to be a number to handle cases of more than 100 authors

pallets/author-slot-filter/src/lib.rs Outdated Show resolved Hide resolved
pallets/author-slot-filter/src/lib.rs Outdated Show resolved Hide resolved
pallets/author-slot-filter/src/lib.rs Outdated Show resolved Hide resolved
@nbaztec nbaztec requested a review from librelois March 22, 2022 16:56
#[pallet::getter(fn eligible_ratio)]
pub type EligibleRatio<T: Config> = StorageValue<_, Percent, ValueQuery, Half<T>>;
#[pallet::getter(fn eligible_count)]
pub type EligibleCount<T: Config> = StorageValue<_, EligibilityValue, ValueQuery, Half<T>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This implies that a migration is necessary, it must also be decided how the percentage is translated into number during the migration, @alan do you have an idea on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this might affect block production I suggest we keep the previous storage, and add the new EligibleCount in a new storage. We can in the future remove EligibleRatio

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we want to keep the previous storage? How is it helping ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general I am hesitant of migrating a storage prefix involved in block production without keeping the previous storage. I think that has been our approach so far with every data migration we have performed if we suspected it could affect block production

Copy link
Collaborator

@crystalin crystalin Mar 23, 2022

Choose a reason for hiding this comment

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

Ok, we could mark it as deprecated. But I don't think it makes anything safer in terms of block production

@girazoki
Copy link
Collaborator

I am having trouble figuring out why this brings and advantage over what was before. I dont understand why the previous approach could not handle more than 100 authors, would you mind explaining?

@nbaztec
Copy link
Contributor Author

nbaztec commented Mar 23, 2022

I think it was mentioned that if the total author count was > 100 say 150 a value of 50% = 75 would be erroneous since our max slots are always 100 (at least that's my understanding)

@girazoki
Copy link
Collaborator

Ok got it thanks to @librelois, it is a precision issue right?

Origin::root(),
value.clone()
));
assert_eq!(AuthorSlotFilter::eligible_count(), value)
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add one more test which tests the migration? You can take https:/PureStake/moonbeam/blob/c582e2f34a2271a22e60a73dbc6d4ffde90de837/pallets/xcm-transactor/src/tests.rs#L319 as a reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added, please review.

@nbaztec nbaztec requested a review from girazoki March 28, 2022 12:51
Copy link
Collaborator

@girazoki girazoki left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@librelois librelois left a comment

Choose a reason for hiding this comment

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

I just have 2 blocking comments, overall it's good :)

@nbaztec nbaztec requested a review from librelois March 29, 2022 13:01
@nbaztec nbaztec requested a review from librelois March 29, 2022 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants