Frame: Consideration trait generic over Footprint and indicates zero cost#4596
Frame: Consideration trait generic over Footprint and indicates zero cost#4596
Consideration trait generic over Footprint and indicates zero cost#4596Conversation
| 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.
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. |
| /// 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.
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.
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.
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.
…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
Considerationtrait generic overFootprintand indicates zero cost for a give footprint.Considerationtrait 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::newandConsideration::updatereturn 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