-
Notifications
You must be signed in to change notification settings - Fork 710
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: Consideration
trait generic over Footprint
and indicates zero cost
#4596
Conversation
fn new(who: &AccountId, new: Footprint) -> Result<Self, DispatchError>; | ||
/// be consumed through `update` or `drop` once the footprint changes or is removed. `None` | ||
/// implies no cost for a given footprint. | ||
fn new(who: &AccountId, new: Footprint) -> Result<Option<Self>, DispatchError>; |
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.
Self
can also say for itself that there is no cost (with 0 balance for example), but this wont let a pallet to have no storage entry for such case.
The CI pipeline was cancelled due to failure one of the required jobs. |
@@ -122,7 +122,9 @@ pub mod pallet { | |||
type ManagerOrigin: EnsureOrigin<Self::RuntimeOrigin>; | |||
|
|||
/// A means of providing some cost while data is stored on-chain. | |||
type Consideration: Consideration<Self::AccountId>; | |||
/// | |||
/// Should never return a `None`, implying no cost for a non-empty preimage. |
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.
Why should it not do that? The implementor of the Consideration
should be able to return as they see fit.
Otherwise it would probably need a Consideration
and MaybeConsideration
trait to disambiguate.
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.
Yes, I agree. But I did now want to change the behaviour of this pallet, and make only a patch. Otherwise we need a migration for the preimage pallet.
Maybe I should rephrase it, that we do expect some cost for any non zero footprint, so it should not return none.
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.
Okay i see. The maybe add a check to the integrity_test
of the pallet that a zero sized preimage still needs a deposit.
Consideration
trait generic over Footprint
and handles zero costConsideration
trait generic over Footprint
and indicates zero cost
…ero cost (paritytech#4596) `Consideration` trait generic over `Footprint` and indicates zero cost for a give footprint. `Consideration` trait is generic over `Footprint` (currently defined over the type with the same name). This makes it possible to setup a custom footprint (e.g. current number of proposals in the storage). `Consideration::new` and `Consideration::update` return an `Option<Self>` instead `Self`, this make it possible to indicate a no cost for a specific footprint (e.g. if current number of proposals in the storage < max_proposal_count / 2 then no cost). These cases need to be handled for paritytech#3151
…ation trait (#5359) Make ticket non-optional and add ensure_successful method to Consideration trait. Reverts the optional return ticket type for the new function introduced in [polkadot-sdk/4596](#4596) and adds a helper `ensure_successful` function for the runtime benchmarks. Since the existing FRAME pallet represents zero cost with a zero balance rather than `None` in an option, maintaining the ticket type as a non-optional balance is beneficial for backward compatibility and helps avoid unnecessary migrations.
Consideration
trait generic overFootprint
and indicates zero cost for a give footprint.Consideration
trait is generic overFootprint
(currently defined over the type with the same name). This makes it possible to setup a custom footprint (e.g. current number of proposals in the storage).Consideration::new
andConsideration::update
return anOption<Self>
insteadSelf
, this make it possible to indicate a no cost for a specific footprint (e.g. if current number of proposals in the storage < max_proposal_count / 2 then no cost).These cases need to be handled for #3151