mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
FRAME: Revamp Preimage pallet to use Consideration (#1363)
Make Preimage pallet use Consideration instead of handling deposits directly. Other half of paritytech/substrate#13666. Depends/based on #1361. Script for the lazy migration that should be run manually once: [migrate-preimage-lazy.py](https://github.com/ggwpez/substrate-scripts/blob/master/migrate-preimage-lazy.py). ## TODO - [x] Migration code. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
//! Preimage pallet benchmarking.
|
||||
|
||||
use super::*;
|
||||
use frame_benchmarking::v1::{account, benchmarks, whitelist_account, BenchmarkError};
|
||||
use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError};
|
||||
use frame_support::assert_ok;
|
||||
use frame_system::RawOrigin;
|
||||
use sp_runtime::traits::Bounded;
|
||||
@@ -26,11 +26,9 @@ use sp_std::{prelude::*, vec};
|
||||
|
||||
use crate::Pallet as Preimage;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
fn funded_account<T: Config>(name: &'static str, index: u32) -> T::AccountId {
|
||||
let caller: T::AccountId = account(name, index, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
fn funded_account<T: Config>() -> T::AccountId {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
caller
|
||||
}
|
||||
|
||||
@@ -49,8 +47,7 @@ benchmarks! {
|
||||
// Expensive note - will reserve.
|
||||
note_preimage {
|
||||
let s in 0 .. MAX_SIZE;
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
whitelist_account!(caller);
|
||||
let caller = funded_account::<T>();
|
||||
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
|
||||
}: _(RawOrigin::Signed(caller), preimage)
|
||||
verify {
|
||||
@@ -59,8 +56,7 @@ benchmarks! {
|
||||
// Cheap note - will not reserve since it was requested.
|
||||
note_requested_preimage {
|
||||
let s in 0 .. MAX_SIZE;
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
whitelist_account!(caller);
|
||||
let caller = funded_account::<T>();
|
||||
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
|
||||
assert_ok!(Preimage::<T>::request_preimage(
|
||||
T::ManagerOrigin::try_successful_origin()
|
||||
@@ -89,8 +85,7 @@ benchmarks! {
|
||||
|
||||
// Expensive unnote - will unreserve.
|
||||
unnote_preimage {
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
whitelist_account!(caller);
|
||||
let caller = funded_account::<T>();
|
||||
let (preimage, hash) = preimage_and_hash::<T>();
|
||||
assert_ok!(Preimage::<T>::note_preimage(RawOrigin::Signed(caller.clone()).into(), preimage));
|
||||
}: _(RawOrigin::Signed(caller), hash)
|
||||
@@ -115,16 +110,15 @@ benchmarks! {
|
||||
// Expensive request - will unreserve the noter's deposit.
|
||||
request_preimage {
|
||||
let (preimage, hash) = preimage_and_hash::<T>();
|
||||
let noter = funded_account::<T>("noter", 0);
|
||||
whitelist_account!(noter);
|
||||
let noter = funded_account::<T>();
|
||||
assert_ok!(Preimage::<T>::note_preimage(RawOrigin::Signed(noter.clone()).into(), preimage));
|
||||
}: _<T::RuntimeOrigin>(
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
let deposit = T::BaseDeposit::get() + T::ByteDeposit::get() * MAX_SIZE.into();
|
||||
let s = RequestStatus::Requested { deposit: Some((noter, deposit)), count: 1, len: Some(MAX_SIZE) };
|
||||
assert_eq!(StatusFor::<T>::get(&hash), Some(s));
|
||||
let ticket = TicketOf::<T>::new(¬er, Footprint { count: 1, size: MAX_SIZE as u64 }).unwrap();
|
||||
let s = RequestStatus::Requested { maybe_ticket: Some((noter, ticket)), count: 1, maybe_len: Some(MAX_SIZE) };
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
|
||||
}
|
||||
// Cheap request - would unreserve the deposit but none was held.
|
||||
request_no_deposit_preimage {
|
||||
@@ -138,8 +132,8 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
let s = RequestStatus::Requested { deposit: None, count: 2, len: Some(MAX_SIZE) };
|
||||
assert_eq!(StatusFor::<T>::get(&hash), Some(s));
|
||||
let s = RequestStatus::Requested { maybe_ticket: None, count: 2, maybe_len: Some(MAX_SIZE) };
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
|
||||
}
|
||||
// Cheap request - the preimage is not yet noted, so deposit to unreserve.
|
||||
request_unnoted_preimage {
|
||||
@@ -148,8 +142,8 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
let s = RequestStatus::Requested { deposit: None, count: 1, len: None };
|
||||
assert_eq!(StatusFor::<T>::get(&hash), Some(s));
|
||||
let s = RequestStatus::Requested { maybe_ticket: None, count: 1, maybe_len: None };
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
|
||||
}
|
||||
// Cheap request - the preimage is already requested, so just a counter bump.
|
||||
request_requested_preimage {
|
||||
@@ -163,8 +157,8 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
let s = RequestStatus::Requested { deposit: None, count: 2, len: None };
|
||||
assert_eq!(StatusFor::<T>::get(&hash), Some(s));
|
||||
let s = RequestStatus::Requested { maybe_ticket: None, count: 2, maybe_len: None };
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
|
||||
}
|
||||
|
||||
// Expensive unrequest - last reference and it's noted, so will destroy the preimage.
|
||||
@@ -184,7 +178,7 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
assert_eq!(StatusFor::<T>::get(&hash), None);
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), None);
|
||||
}
|
||||
// Cheap unrequest - last reference, but it's not noted.
|
||||
unrequest_unnoted_preimage {
|
||||
@@ -198,7 +192,7 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
assert_eq!(StatusFor::<T>::get(&hash), None);
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), None);
|
||||
}
|
||||
// Cheap unrequest - not the last reference.
|
||||
unrequest_multi_referenced_preimage {
|
||||
@@ -217,9 +211,38 @@ benchmarks! {
|
||||
T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?,
|
||||
hash
|
||||
) verify {
|
||||
let s = RequestStatus::Requested { deposit: None, count: 1, len: None };
|
||||
assert_eq!(StatusFor::<T>::get(&hash), Some(s));
|
||||
let s = RequestStatus::Requested { maybe_ticket: None, count: 1, maybe_len: None };
|
||||
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
|
||||
}
|
||||
|
||||
ensure_updated {
|
||||
let n in 0..MAX_HASH_UPGRADE_BULK_COUNT;
|
||||
|
||||
let caller = funded_account::<T>();
|
||||
let hashes = (0..n).map(|i| insert_old_unrequested::<T>(i)).collect::<Vec<_>>();
|
||||
}: _(RawOrigin::Signed(caller), hashes)
|
||||
verify {
|
||||
assert_eq!(RequestStatusFor::<T>::iter_keys().count(), n as usize);
|
||||
#[allow(deprecated)]
|
||||
let c = StatusFor::<T>::iter_keys().count();
|
||||
assert_eq!(c, 0);
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Preimage, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
|
||||
fn insert_old_unrequested<T: Config>(s: u32) -> <T as frame_system::Config>::Hash {
|
||||
let acc = account("old", s, 0);
|
||||
T::Currency::make_free_balance_be(&acc, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
|
||||
// The preimage size does not matter here as it is not touched.
|
||||
let preimage = s.to_le_bytes();
|
||||
let hash = <T as frame_system::Config>::Hashing::hash(&preimage[..]);
|
||||
|
||||
#[allow(deprecated)]
|
||||
StatusFor::<T>::insert(
|
||||
&hash,
|
||||
OldRequestStatus::Unrequested { deposit: (acc, 123u32.into()), len: preimage.len() as u32 },
|
||||
);
|
||||
hash
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ mod mock;
|
||||
mod tests;
|
||||
pub mod weights;
|
||||
|
||||
use sp_runtime::traits::{BadOrigin, Hash, Saturating};
|
||||
use sp_runtime::{
|
||||
traits::{BadOrigin, Hash, Saturating},
|
||||
Perbill,
|
||||
};
|
||||
use sp_std::{borrow::Cow, prelude::*};
|
||||
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
@@ -46,8 +49,8 @@ use frame_support::{
|
||||
ensure,
|
||||
pallet_prelude::Get,
|
||||
traits::{
|
||||
Currency, Defensive, FetchResult, Hash as PreimageHash, PreimageProvider,
|
||||
PreimageRecipient, QueryPreimage, ReservableCurrency, StorePreimage,
|
||||
Consideration, Currency, Defensive, FetchResult, Footprint, Hash as PreimageHash,
|
||||
PreimageProvider, PreimageRecipient, QueryPreimage, ReservableCurrency, StorePreimage,
|
||||
},
|
||||
BoundedSlice, BoundedVec,
|
||||
};
|
||||
@@ -61,7 +64,7 @@ pub use pallet::*;
|
||||
|
||||
/// A type to note whether a preimage is owned by a user or the system.
|
||||
#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen, RuntimeDebug)]
|
||||
pub enum RequestStatus<AccountId, Balance> {
|
||||
pub enum OldRequestStatus<AccountId, Balance> {
|
||||
/// The associated preimage has not yet been requested by the system. The given deposit (if
|
||||
/// some) is being held until either it becomes requested or the user retracts the preimage.
|
||||
Unrequested { deposit: (AccountId, Balance), len: u32 },
|
||||
@@ -71,13 +74,31 @@ pub enum RequestStatus<AccountId, Balance> {
|
||||
Requested { deposit: Option<(AccountId, Balance)>, count: u32, len: Option<u32> },
|
||||
}
|
||||
|
||||
/// A type to note whether a preimage is owned by a user or the system.
|
||||
#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen, RuntimeDebug)]
|
||||
pub enum RequestStatus<AccountId, Ticket> {
|
||||
/// The associated preimage has not yet been requested by the system. The given deposit (if
|
||||
/// some) is being held until either it becomes requested or the user retracts the preimage.
|
||||
Unrequested { ticket: (AccountId, Ticket), len: u32 },
|
||||
/// There are a non-zero number of outstanding requests for this hash by this chain. If there
|
||||
/// is a preimage registered, then `len` is `Some` and it may be removed iff this counter
|
||||
/// becomes zero.
|
||||
Requested { maybe_ticket: Option<(AccountId, Ticket)>, count: u32, maybe_len: Option<u32> },
|
||||
}
|
||||
|
||||
type BalanceOf<T> =
|
||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
type TicketOf<T> = <T as Config>::Consideration;
|
||||
|
||||
/// Maximum size of preimage we can store is 4mb.
|
||||
const MAX_SIZE: u32 = 4 * 1024 * 1024;
|
||||
/// Hard-limit on the number of hashes that can be passed to `ensure_updated`.
|
||||
///
|
||||
/// Exists only for benchmarking purposes.
|
||||
pub const MAX_HASH_UPGRADE_BULK_COUNT: u32 = 1024;
|
||||
|
||||
#[frame_support::pallet]
|
||||
#[allow(deprecated)]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
|
||||
@@ -93,17 +114,15 @@ pub mod pallet {
|
||||
type WeightInfo: weights::WeightInfo;
|
||||
|
||||
/// Currency type for this pallet.
|
||||
// TODO#1569: Remove.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
|
||||
/// An origin that can request a preimage be placed on-chain without a deposit or fee, or
|
||||
/// manage existing preimages.
|
||||
type ManagerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The base deposit for placing a preimage on chain.
|
||||
type BaseDeposit: Get<BalanceOf<Self>>;
|
||||
|
||||
/// The per-byte deposit for placing a preimage on chain.
|
||||
type ByteDeposit: Get<BalanceOf<Self>>;
|
||||
/// A means of providing some cost while data is stored on-chain.
|
||||
type Consideration: Consideration<Self::AccountId>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -135,18 +154,33 @@ pub mod pallet {
|
||||
Requested,
|
||||
/// The preimage request cannot be removed since no outstanding requests exist.
|
||||
NotRequested,
|
||||
/// More than `MAX_HASH_UPGRADE_BULK_COUNT` hashes were requested to be upgraded at once.
|
||||
TooMany,
|
||||
}
|
||||
|
||||
/// A reason for this pallet placing a hold on funds.
|
||||
#[pallet::composite_enum]
|
||||
pub enum HoldReason {
|
||||
/// The funds are held as storage deposit for a preimage.
|
||||
Preimage,
|
||||
}
|
||||
|
||||
/// The request status of a given hash.
|
||||
#[deprecated = "RequestStatusFor"]
|
||||
#[pallet::storage]
|
||||
pub(super) type StatusFor<T: Config> =
|
||||
StorageMap<_, Identity, T::Hash, RequestStatus<T::AccountId, BalanceOf<T>>>;
|
||||
StorageMap<_, Identity, T::Hash, OldRequestStatus<T::AccountId, BalanceOf<T>>>;
|
||||
|
||||
/// The request status of a given hash.
|
||||
#[pallet::storage]
|
||||
pub(super) type RequestStatusFor<T: Config> =
|
||||
StorageMap<_, Identity, T::Hash, RequestStatus<T::AccountId, TicketOf<T>>>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub(super) type PreimageFor<T: Config> =
|
||||
StorageMap<_, Identity, (T::Hash, u32), BoundedVec<u8, ConstU32<MAX_SIZE>>>;
|
||||
|
||||
#[pallet::call]
|
||||
#[pallet::call(weight = T::WeightInfo)]
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Register a preimage on-chain.
|
||||
///
|
||||
@@ -173,7 +207,6 @@ pub mod pallet {
|
||||
/// - `hash`: The hash of the preimage to be removed from the store.
|
||||
/// - `len`: The length of the preimage of `hash`.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::unnote_preimage())]
|
||||
pub fn unnote_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
|
||||
let maybe_sender = Self::ensure_signed_or_manager(origin)?;
|
||||
Self::do_unnote_preimage(&hash, maybe_sender)
|
||||
@@ -184,7 +217,6 @@ pub mod pallet {
|
||||
/// If the preimage requests has already been provided on-chain, we unreserve any deposit
|
||||
/// a user may have paid, and take the control of the preimage out of their hands.
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::request_preimage())]
|
||||
pub fn request_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
|
||||
T::ManagerOrigin::ensure_origin(origin)?;
|
||||
Self::do_request_preimage(&hash);
|
||||
@@ -195,15 +227,80 @@ pub mod pallet {
|
||||
///
|
||||
/// NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`.
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(T::WeightInfo::unrequest_preimage())]
|
||||
pub fn unrequest_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
|
||||
T::ManagerOrigin::ensure_origin(origin)?;
|
||||
Self::do_unrequest_preimage(&hash)
|
||||
}
|
||||
|
||||
/// Ensure that the a bulk of pre-images is upgraded.
|
||||
///
|
||||
/// The caller pays no fee if at least 90% of pre-images were successfully updated.
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(T::WeightInfo::ensure_updated(hashes.len() as u32))]
|
||||
pub fn ensure_updated(
|
||||
origin: OriginFor<T>,
|
||||
hashes: Vec<T::Hash>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_signed(origin)?;
|
||||
ensure!(hashes.len() <= MAX_HASH_UPGRADE_BULK_COUNT as usize, Error::<T>::TooMany);
|
||||
|
||||
let updated = hashes.iter().map(Self::do_ensure_updated).filter(|b| *b).count() as u32;
|
||||
let ratio = Perbill::from_rational(updated, hashes.len() as u32);
|
||||
|
||||
let pays: Pays = (ratio < Perbill::from_percent(90)).into();
|
||||
Ok(pays.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
fn do_ensure_updated(h: &T::Hash) -> bool {
|
||||
#[allow(deprecated)]
|
||||
let r = match StatusFor::<T>::take(h) {
|
||||
Some(r) => r,
|
||||
None => return false,
|
||||
};
|
||||
let n = match r {
|
||||
OldRequestStatus::Unrequested { deposit: (who, amount), len } => {
|
||||
// unreserve deposit
|
||||
T::Currency::unreserve(&who, amount);
|
||||
// take consideration
|
||||
let Ok(ticket) =
|
||||
T::Consideration::new(&who, Footprint::from_parts(1, len as usize))
|
||||
.defensive_proof("Unexpected inability to take deposit after unreserved")
|
||||
else {
|
||||
return true
|
||||
};
|
||||
RequestStatus::Unrequested { ticket: (who, ticket), len }
|
||||
},
|
||||
OldRequestStatus::Requested { deposit: maybe_deposit, count, len: maybe_len } => {
|
||||
let maybe_ticket = if let Some((who, deposit)) = maybe_deposit {
|
||||
// unreserve deposit
|
||||
T::Currency::unreserve(&who, deposit);
|
||||
// take consideration
|
||||
if let Some(len) = maybe_len {
|
||||
let Ok(ticket) =
|
||||
T::Consideration::new(&who, Footprint::from_parts(1, len as usize))
|
||||
.defensive_proof(
|
||||
"Unexpected inability to take deposit after unreserved",
|
||||
)
|
||||
else {
|
||||
return true
|
||||
};
|
||||
Some((who, ticket))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
RequestStatus::Requested { maybe_ticket, count, maybe_len }
|
||||
},
|
||||
};
|
||||
RequestStatusFor::<T>::insert(h, n);
|
||||
true
|
||||
}
|
||||
|
||||
/// Ensure that the origin is either the `ManagerOrigin` or a signed origin.
|
||||
fn ensure_signed_or_manager(
|
||||
origin: T::RuntimeOrigin,
|
||||
@@ -230,26 +327,29 @@ impl<T: Config> Pallet<T> {
|
||||
let len = preimage.len() as u32;
|
||||
ensure!(len <= MAX_SIZE, Error::<T>::TooBig);
|
||||
|
||||
Self::do_ensure_updated(&hash);
|
||||
// We take a deposit only if there is a provided depositor and the preimage was not
|
||||
// previously requested. This also allows the tx to pay no fee.
|
||||
let status = match (StatusFor::<T>::get(hash), maybe_depositor) {
|
||||
(Some(RequestStatus::Requested { count, deposit, .. }), _) =>
|
||||
RequestStatus::Requested { count, deposit, len: Some(len) },
|
||||
let status = match (RequestStatusFor::<T>::get(hash), maybe_depositor) {
|
||||
(Some(RequestStatus::Requested { maybe_ticket, count, .. }), _) =>
|
||||
RequestStatus::Requested { maybe_ticket, count, maybe_len: Some(len) },
|
||||
(Some(RequestStatus::Unrequested { .. }), Some(_)) =>
|
||||
return Err(Error::<T>::AlreadyNoted.into()),
|
||||
(Some(RequestStatus::Unrequested { len, deposit }), None) =>
|
||||
RequestStatus::Requested { deposit: Some(deposit), count: 1, len: Some(len) },
|
||||
(None, None) => RequestStatus::Requested { count: 1, len: Some(len), deposit: None },
|
||||
(Some(RequestStatus::Unrequested { ticket, len }), None) => RequestStatus::Requested {
|
||||
maybe_ticket: Some(ticket),
|
||||
count: 1,
|
||||
maybe_len: Some(len),
|
||||
},
|
||||
(None, None) =>
|
||||
RequestStatus::Requested { maybe_ticket: None, count: 1, maybe_len: Some(len) },
|
||||
(None, Some(depositor)) => {
|
||||
let length = preimage.len() as u32;
|
||||
let deposit = T::BaseDeposit::get()
|
||||
.saturating_add(T::ByteDeposit::get().saturating_mul(length.into()));
|
||||
T::Currency::reserve(depositor, deposit)?;
|
||||
RequestStatus::Unrequested { deposit: (depositor.clone(), deposit), len }
|
||||
let ticket =
|
||||
T::Consideration::new(depositor, Footprint::from_parts(1, len as usize))?;
|
||||
RequestStatus::Unrequested { ticket: (depositor.clone(), ticket), len }
|
||||
},
|
||||
};
|
||||
let was_requested = matches!(status, RequestStatus::Requested { .. });
|
||||
StatusFor::<T>::insert(hash, status);
|
||||
RequestStatusFor::<T>::insert(hash, status);
|
||||
|
||||
let _ = Self::insert(&hash, preimage)
|
||||
.defensive_proof("Unable to insert. Logic error in `note_bytes`?");
|
||||
@@ -264,15 +364,19 @@ impl<T: Config> Pallet<T> {
|
||||
// If the preimage already exists before the request is made, the deposit for the preimage is
|
||||
// returned to the user, and removed from their management.
|
||||
fn do_request_preimage(hash: &T::Hash) {
|
||||
let (count, len, deposit) =
|
||||
StatusFor::<T>::get(hash).map_or((1, None, None), |x| match x {
|
||||
RequestStatus::Requested { mut count, len, deposit } => {
|
||||
Self::do_ensure_updated(&hash);
|
||||
let (count, maybe_len, maybe_ticket) =
|
||||
RequestStatusFor::<T>::get(hash).map_or((1, None, None), |x| match x {
|
||||
RequestStatus::Requested { maybe_ticket, mut count, maybe_len } => {
|
||||
count.saturating_inc();
|
||||
(count, len, deposit)
|
||||
(count, maybe_len, maybe_ticket)
|
||||
},
|
||||
RequestStatus::Unrequested { deposit, len } => (1, Some(len), Some(deposit)),
|
||||
RequestStatus::Unrequested { ticket, len } => (1, Some(len), Some(ticket)),
|
||||
});
|
||||
StatusFor::<T>::insert(hash, RequestStatus::Requested { count, len, deposit });
|
||||
RequestStatusFor::<T>::insert(
|
||||
hash,
|
||||
RequestStatus::Requested { maybe_ticket, count, maybe_len },
|
||||
);
|
||||
if count == 1 {
|
||||
Self::deposit_event(Event::Requested { hash: *hash });
|
||||
}
|
||||
@@ -288,24 +392,25 @@ impl<T: Config> Pallet<T> {
|
||||
hash: &T::Hash,
|
||||
maybe_check_owner: Option<T::AccountId>,
|
||||
) -> DispatchResult {
|
||||
match StatusFor::<T>::get(hash).ok_or(Error::<T>::NotNoted)? {
|
||||
RequestStatus::Requested { deposit: Some((owner, deposit)), count, len } => {
|
||||
Self::do_ensure_updated(&hash);
|
||||
match RequestStatusFor::<T>::get(hash).ok_or(Error::<T>::NotNoted)? {
|
||||
RequestStatus::Requested { maybe_ticket: Some((owner, ticket)), count, maybe_len } => {
|
||||
ensure!(maybe_check_owner.map_or(true, |c| c == owner), Error::<T>::NotAuthorized);
|
||||
T::Currency::unreserve(&owner, deposit);
|
||||
StatusFor::<T>::insert(
|
||||
let _ = ticket.drop(&owner);
|
||||
RequestStatusFor::<T>::insert(
|
||||
hash,
|
||||
RequestStatus::Requested { deposit: None, count, len },
|
||||
RequestStatus::Requested { maybe_ticket: None, count, maybe_len },
|
||||
);
|
||||
Ok(())
|
||||
},
|
||||
RequestStatus::Requested { deposit: None, .. } => {
|
||||
RequestStatus::Requested { maybe_ticket: None, .. } => {
|
||||
ensure!(maybe_check_owner.is_none(), Error::<T>::NotAuthorized);
|
||||
Self::do_unrequest_preimage(hash)
|
||||
},
|
||||
RequestStatus::Unrequested { deposit: (owner, deposit), len } => {
|
||||
RequestStatus::Unrequested { ticket: (owner, ticket), len } => {
|
||||
ensure!(maybe_check_owner.map_or(true, |c| c == owner), Error::<T>::NotAuthorized);
|
||||
T::Currency::unreserve(&owner, deposit);
|
||||
StatusFor::<T>::remove(hash);
|
||||
let _ = ticket.drop(&owner);
|
||||
RequestStatusFor::<T>::remove(hash);
|
||||
|
||||
Self::remove(hash, len);
|
||||
Self::deposit_event(Event::Cleared { hash: *hash });
|
||||
@@ -316,25 +421,32 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// Clear a preimage request.
|
||||
fn do_unrequest_preimage(hash: &T::Hash) -> DispatchResult {
|
||||
match StatusFor::<T>::get(hash).ok_or(Error::<T>::NotRequested)? {
|
||||
RequestStatus::Requested { mut count, len, deposit } if count > 1 => {
|
||||
Self::do_ensure_updated(&hash);
|
||||
match RequestStatusFor::<T>::get(hash).ok_or(Error::<T>::NotRequested)? {
|
||||
RequestStatus::Requested { mut count, maybe_len, maybe_ticket } if count > 1 => {
|
||||
count.saturating_dec();
|
||||
StatusFor::<T>::insert(hash, RequestStatus::Requested { count, len, deposit });
|
||||
RequestStatusFor::<T>::insert(
|
||||
hash,
|
||||
RequestStatus::Requested { maybe_ticket, count, maybe_len },
|
||||
);
|
||||
},
|
||||
RequestStatus::Requested { count, len, deposit } => {
|
||||
RequestStatus::Requested { count, maybe_len, maybe_ticket } => {
|
||||
debug_assert!(count == 1, "preimage request counter at zero?");
|
||||
match (len, deposit) {
|
||||
match (maybe_len, maybe_ticket) {
|
||||
// Preimage was never noted.
|
||||
(None, _) => StatusFor::<T>::remove(hash),
|
||||
(None, _) => RequestStatusFor::<T>::remove(hash),
|
||||
// Preimage was noted without owner - just remove it.
|
||||
(Some(len), None) => {
|
||||
Self::remove(hash, len);
|
||||
StatusFor::<T>::remove(hash);
|
||||
RequestStatusFor::<T>::remove(hash);
|
||||
Self::deposit_event(Event::Cleared { hash: *hash });
|
||||
},
|
||||
// Preimage was noted with owner - move to unrequested so they can get refund.
|
||||
(Some(len), Some(deposit)) => {
|
||||
StatusFor::<T>::insert(hash, RequestStatus::Unrequested { deposit, len });
|
||||
(Some(len), Some(ticket)) => {
|
||||
RequestStatusFor::<T>::insert(
|
||||
hash,
|
||||
RequestStatus::Unrequested { ticket, len },
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -359,8 +471,10 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
fn len(hash: &T::Hash) -> Option<u32> {
|
||||
use RequestStatus::*;
|
||||
match StatusFor::<T>::get(hash) {
|
||||
Some(Requested { len: Some(len), .. }) | Some(Unrequested { len, .. }) => Some(len),
|
||||
Self::do_ensure_updated(&hash);
|
||||
match RequestStatusFor::<T>::get(hash) {
|
||||
Some(Requested { maybe_len: Some(len), .. }) | Some(Unrequested { len, .. }) =>
|
||||
Some(len),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -380,7 +494,8 @@ impl<T: Config> PreimageProvider<T::Hash> for Pallet<T> {
|
||||
}
|
||||
|
||||
fn preimage_requested(hash: &T::Hash) -> bool {
|
||||
matches!(StatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
|
||||
Self::do_ensure_updated(hash);
|
||||
matches!(RequestStatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
|
||||
}
|
||||
|
||||
fn get_preimage(hash: &T::Hash) -> Option<Vec<u8>> {
|
||||
@@ -423,7 +538,8 @@ impl<T: Config<Hash = PreimageHash>> QueryPreimage for Pallet<T> {
|
||||
}
|
||||
|
||||
fn is_requested(hash: &T::Hash) -> bool {
|
||||
matches!(StatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
|
||||
Self::do_ensure_updated(&hash);
|
||||
matches!(RequestStatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
|
||||
}
|
||||
|
||||
fn request(hash: &T::Hash) {
|
||||
|
||||
@@ -37,7 +37,7 @@ mod v0 {
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen, RuntimeDebug)]
|
||||
pub enum RequestStatus<AccountId, Balance> {
|
||||
pub enum OldRequestStatus<AccountId, Balance> {
|
||||
Unrequested(Option<(AccountId, Balance)>),
|
||||
Requested(u32),
|
||||
}
|
||||
@@ -55,7 +55,7 @@ mod v0 {
|
||||
Pallet<T>,
|
||||
Identity,
|
||||
<T as frame_system::Config>::Hash,
|
||||
RequestStatus<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
|
||||
OldRequestStatus<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
|
||||
>;
|
||||
|
||||
/// Returns the number of images or `None` if the storage is corrupted.
|
||||
@@ -127,21 +127,22 @@ pub mod v1 {
|
||||
}
|
||||
|
||||
let status = match status {
|
||||
v0::RequestStatus::Unrequested(deposit) => match deposit {
|
||||
Some(deposit) => RequestStatus::Unrequested { deposit, len },
|
||||
v0::OldRequestStatus::Unrequested(deposit) => match deposit {
|
||||
Some(deposit) => OldRequestStatus::Unrequested { deposit, len },
|
||||
// `None` depositor becomes system-requested.
|
||||
None =>
|
||||
RequestStatus::Requested { deposit: None, count: 1, len: Some(len) },
|
||||
OldRequestStatus::Requested { deposit: None, count: 1, len: Some(len) },
|
||||
},
|
||||
v0::RequestStatus::Requested(count) if count == 0 => {
|
||||
v0::OldRequestStatus::Requested(count) if count == 0 => {
|
||||
log::error!(target: TARGET, "preimage has counter of zero: {:?}", hash);
|
||||
continue
|
||||
},
|
||||
v0::RequestStatus::Requested(count) =>
|
||||
RequestStatus::Requested { deposit: None, count, len: Some(len) },
|
||||
v0::OldRequestStatus::Requested(count) =>
|
||||
OldRequestStatus::Requested { deposit: None, count, len: Some(len) },
|
||||
};
|
||||
log::trace!(target: TARGET, "Moving preimage {:?} with len {}", hash, len);
|
||||
|
||||
#[allow(deprecated)]
|
||||
crate::StatusFor::<T>::insert(hash, status);
|
||||
crate::PreimageFor::<T>::insert(&(hash, len), preimage);
|
||||
|
||||
@@ -176,6 +177,7 @@ pub mod v1 {
|
||||
pub fn image_count<T: Config>() -> Option<u32> {
|
||||
// Use iter_values() to ensure that the values are decodable.
|
||||
let images = crate::PreimageFor::<T>::iter_values().count() as u32;
|
||||
#[allow(deprecated)]
|
||||
let status = crate::StatusFor::<T>::iter_values().count() as u32;
|
||||
|
||||
if images == status {
|
||||
@@ -189,6 +191,7 @@ pub mod v1 {
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "try-runtime")]
|
||||
mod test {
|
||||
#![allow(deprecated)]
|
||||
use super::*;
|
||||
use crate::mock::{Test as T, *};
|
||||
|
||||
@@ -203,19 +206,19 @@ mod test {
|
||||
// Case 1: Unrequested without deposit
|
||||
let (p, h) = preimage::<T>(128);
|
||||
v0::PreimageFor::<T>::insert(h, p);
|
||||
v0::StatusFor::<T>::insert(h, v0::RequestStatus::Unrequested(None));
|
||||
v0::StatusFor::<T>::insert(h, v0::OldRequestStatus::Unrequested(None));
|
||||
// Case 2: Unrequested with deposit
|
||||
let (p, h) = preimage::<T>(1024);
|
||||
v0::PreimageFor::<T>::insert(h, p);
|
||||
v0::StatusFor::<T>::insert(h, v0::RequestStatus::Unrequested(Some((1, 1))));
|
||||
v0::StatusFor::<T>::insert(h, v0::OldRequestStatus::Unrequested(Some((1, 1))));
|
||||
// Case 3: Requested by 0 (invalid)
|
||||
let (p, h) = preimage::<T>(8192);
|
||||
v0::PreimageFor::<T>::insert(h, p);
|
||||
v0::StatusFor::<T>::insert(h, v0::RequestStatus::Requested(0));
|
||||
v0::StatusFor::<T>::insert(h, v0::OldRequestStatus::Requested(0));
|
||||
// Case 4: Requested by 10
|
||||
let (p, h) = preimage::<T>(65536);
|
||||
v0::PreimageFor::<T>::insert(h, p);
|
||||
v0::StatusFor::<T>::insert(h, v0::RequestStatus::Requested(10));
|
||||
v0::StatusFor::<T>::insert(h, v0::OldRequestStatus::Requested(10));
|
||||
|
||||
assert_eq!(v0::image_count::<T>(), Some(4));
|
||||
assert_eq!(v1::image_count::<T>(), None, "V1 storage should be corrupted");
|
||||
@@ -234,14 +237,14 @@ mod test {
|
||||
assert_eq!(crate::PreimageFor::<T>::get(&(h, 128)), Some(p));
|
||||
assert_eq!(
|
||||
crate::StatusFor::<T>::get(h),
|
||||
Some(RequestStatus::Requested { deposit: None, count: 1, len: Some(128) })
|
||||
Some(OldRequestStatus::Requested { deposit: None, count: 1, len: Some(128) })
|
||||
);
|
||||
// Case 2: Unrequested with deposit becomes unrequested
|
||||
let (p, h) = preimage::<T>(1024);
|
||||
assert_eq!(crate::PreimageFor::<T>::get(&(h, 1024)), Some(p));
|
||||
assert_eq!(
|
||||
crate::StatusFor::<T>::get(h),
|
||||
Some(RequestStatus::Unrequested { deposit: (1, 1), len: 1024 })
|
||||
Some(OldRequestStatus::Unrequested { deposit: (1, 1), len: 1024 })
|
||||
);
|
||||
// Case 3: Requested by 0 should be skipped
|
||||
let (_, h) = preimage::<T>(8192);
|
||||
@@ -252,7 +255,7 @@ mod test {
|
||||
assert_eq!(crate::PreimageFor::<T>::get(&(h, 65536)), Some(p));
|
||||
assert_eq!(
|
||||
crate::StatusFor::<T>::get(h),
|
||||
Some(RequestStatus::Requested { deposit: None, count: 10, len: Some(65536) })
|
||||
Some(OldRequestStatus::Requested { deposit: None, count: 10, len: Some(65536) })
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ use super::*;
|
||||
use crate as pallet_preimage;
|
||||
use frame_support::{
|
||||
ord_parameter_types,
|
||||
traits::{ConstU32, ConstU64, Everything},
|
||||
traits::{fungible::HoldConsideration, ConstU32, ConstU64, Everything},
|
||||
weights::constants::RocksDbWeight,
|
||||
};
|
||||
use frame_system::EnsureSignedBy;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
traits::{BlakeTwo256, Convert, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
@@ -80,22 +80,28 @@ impl pallet_balances::Config for Test {
|
||||
type MaxReserves = ConstU32<50>;
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
type FreezeIdentifier = ();
|
||||
type MaxFreezes = ();
|
||||
type MaxFreezes = ConstU32<1>;
|
||||
type RuntimeHoldReason = ();
|
||||
type MaxHolds = ();
|
||||
type MaxHolds = ConstU32<2>;
|
||||
}
|
||||
|
||||
ord_parameter_types! {
|
||||
pub const One: u64 = 1;
|
||||
}
|
||||
|
||||
pub struct ConvertDeposit;
|
||||
impl Convert<Footprint, u64> for ConvertDeposit {
|
||||
fn convert(a: Footprint) -> u64 {
|
||||
a.count * 2 + a.size
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type WeightInfo = ();
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type ManagerOrigin = EnsureSignedBy<One, u64>;
|
||||
type BaseDeposit = ConstU64<2>;
|
||||
type ByteDeposit = ConstU64<1>;
|
||||
type Consideration = HoldConsideration<u64, Balances, (), ConvertDeposit>;
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
@@ -110,3 +116,20 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
pub fn hashed(data: impl AsRef<[u8]>) -> H256 {
|
||||
BlakeTwo256::hash(data.as_ref())
|
||||
}
|
||||
|
||||
/// Insert an un-migrated preimage.
|
||||
pub fn insert_old_unrequested<T: Config>(
|
||||
s: u32,
|
||||
acc: T::AccountId,
|
||||
) -> <T as frame_system::Config>::Hash {
|
||||
// The preimage size does not matter here as it is not touched.
|
||||
let preimage = s.to_le_bytes();
|
||||
let hash = <T as frame_system::Config>::Hashing::hash(&preimage[..]);
|
||||
|
||||
#[allow(deprecated)]
|
||||
StatusFor::<T>::insert(
|
||||
&hash,
|
||||
OldRequestStatus::Unrequested { deposit: (acc, 123u32.into()), len: preimage.len() as u32 },
|
||||
);
|
||||
hash
|
||||
}
|
||||
|
||||
@@ -24,12 +24,11 @@ use crate::mock::*;
|
||||
|
||||
use frame_support::{
|
||||
assert_err, assert_noop, assert_ok, assert_storage_noop,
|
||||
traits::{Bounded, BoundedInline, Hash as PreimageHash},
|
||||
traits::{fungible::InspectHold, Bounded, BoundedInline, Hash as PreimageHash},
|
||||
StorageNoopGuard,
|
||||
};
|
||||
use pallet_balances::Error as BalancesError;
|
||||
use sp_core::{blake2_256, H256};
|
||||
use sp_runtime::bounded_vec;
|
||||
use sp_runtime::{bounded_vec, TokenError};
|
||||
|
||||
/// Returns one `Inline`, `Lookup` and `Legacy` item each with different data and hash.
|
||||
pub fn make_bounded_values() -> (Bounded<Vec<u8>>, Bounded<Vec<u8>>, Bounded<Vec<u8>>) {
|
||||
@@ -52,7 +51,7 @@ pub fn make_bounded_values() -> (Bounded<Vec<u8>>, Bounded<Vec<u8>>, Bounded<Vec
|
||||
fn user_note_preimage_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
|
||||
assert_eq!(Balances::reserved_balance(2), 3);
|
||||
assert_eq!(Balances::balance_on_hold(&(), &2), 3);
|
||||
assert_eq!(Balances::free_balance(2), 97);
|
||||
|
||||
let h = hashed([1]);
|
||||
@@ -61,11 +60,11 @@ fn user_note_preimage_works() {
|
||||
|
||||
assert_noop!(
|
||||
Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]),
|
||||
Error::<Test>::AlreadyNoted
|
||||
Error::<Test>::AlreadyNoted,
|
||||
);
|
||||
assert_noop!(
|
||||
Preimage::note_preimage(RuntimeOrigin::signed(0), vec![2]),
|
||||
BalancesError::<Test>::InsufficientBalance
|
||||
TokenError::FundsUnavailable,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -171,7 +170,7 @@ fn request_note_order_makes_no_difference() {
|
||||
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
|
||||
(
|
||||
StatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
)
|
||||
});
|
||||
@@ -180,7 +179,7 @@ fn request_note_order_makes_no_difference() {
|
||||
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
|
||||
let other_way = (
|
||||
StatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
);
|
||||
assert_eq!(one_way, other_way);
|
||||
@@ -207,7 +206,7 @@ fn request_user_note_order_makes_no_difference() {
|
||||
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
|
||||
(
|
||||
StatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
)
|
||||
});
|
||||
@@ -216,7 +215,7 @@ fn request_user_note_order_makes_no_difference() {
|
||||
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
|
||||
let other_way = (
|
||||
StatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
|
||||
);
|
||||
assert_eq!(one_way, other_way);
|
||||
@@ -249,13 +248,14 @@ fn unrequest_preimage_works() {
|
||||
fn user_noted_then_requested_preimage_is_refunded_once_only() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1; 3]));
|
||||
assert_eq!(Balances::balance_on_hold(&(), &2), 5);
|
||||
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
|
||||
assert_eq!(Balances::balance_on_hold(&(), &2), 8);
|
||||
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([1])));
|
||||
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
|
||||
// Still have reserve from `vec[1; 3]`.
|
||||
assert_eq!(Balances::reserved_balance(2), 5);
|
||||
assert_eq!(Balances::free_balance(2), 95);
|
||||
// Still have hold from `vec[1; 3]`.
|
||||
assert_eq!(Balances::balance_on_hold(&(), &2), 5);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ fn noted_preimage_use_correct_map() {
|
||||
assert_eq!(PreimageFor::<Test>::iter().count(), 8);
|
||||
|
||||
// All are present
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 8);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 8);
|
||||
|
||||
// Now start removing them again...
|
||||
for i in 0..7 {
|
||||
@@ -287,7 +287,7 @@ fn noted_preimage_use_correct_map() {
|
||||
assert_eq!(PreimageFor::<Test>::iter().count(), 0);
|
||||
|
||||
// All are gone
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 0);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -327,20 +327,20 @@ fn query_and_store_preimage_workflow() {
|
||||
Preimage::request(&hash);
|
||||
// It is requested thrice.
|
||||
assert!(matches!(
|
||||
StatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatus::Requested { count: 3, .. }
|
||||
));
|
||||
|
||||
// It can be realized and decoded correctly.
|
||||
assert_eq!(Preimage::realize::<Vec<u8>>(&bound).unwrap(), (data.clone(), Some(len)));
|
||||
assert!(matches!(
|
||||
StatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatus::Requested { count: 2, .. }
|
||||
));
|
||||
// Dropping should unrequest.
|
||||
Preimage::drop(&bound);
|
||||
assert!(matches!(
|
||||
StatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatusFor::<Test>::get(&hash).unwrap(),
|
||||
RequestStatus::Requested { count: 1, .. }
|
||||
));
|
||||
|
||||
@@ -381,7 +381,7 @@ fn query_preimage_request_works() {
|
||||
assert!(<Preimage as QueryPreimage>::len(&hash).is_none());
|
||||
assert_noop!(<Preimage as QueryPreimage>::fetch(&hash, None), DispatchError::Unavailable);
|
||||
// But there is only one entry in the map.
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 1);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 1);
|
||||
|
||||
// Un-request the preimage.
|
||||
<Preimage as QueryPreimage>::unrequest(&hash);
|
||||
@@ -392,7 +392,7 @@ fn query_preimage_request_works() {
|
||||
// It is not requested anymore.
|
||||
assert!(!<Preimage as QueryPreimage>::is_requested(&hash));
|
||||
// And there is no entry in the map.
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 0);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ fn query_preimage_hold_and_drop_work() {
|
||||
assert!(<Preimage as QueryPreimage>::is_requested(&legacy.hash()));
|
||||
|
||||
// There are two values requested in total.
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 2);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 2);
|
||||
|
||||
// Cleanup by dropping both.
|
||||
<Preimage as QueryPreimage>::drop(&lookup);
|
||||
@@ -422,7 +422,7 @@ fn query_preimage_hold_and_drop_work() {
|
||||
assert!(!<Preimage as QueryPreimage>::is_requested(&legacy.hash()));
|
||||
|
||||
// There are no values requested anymore.
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 0);
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -489,3 +489,27 @@ fn store_preimage_bound_too_large_errors() {
|
||||
assert_ok!(<Preimage as StorePreimage>::bound(data.clone()));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ensure_updated_works() {
|
||||
#![allow(deprecated)]
|
||||
new_test_ext().execute_with(|| {
|
||||
let alice = 2;
|
||||
|
||||
for i in 0..100 {
|
||||
let hashes =
|
||||
(0..100).map(|j| insert_old_unrequested::<Test>(j, alice)).collect::<Vec<_>>();
|
||||
let old = hashes.iter().take(i).cloned().collect::<Vec<_>>();
|
||||
let bad = vec![hashed([0; 32]); 100 - i];
|
||||
|
||||
let hashes = [old.as_slice(), bad.as_slice()].concat();
|
||||
let res = Preimage::ensure_updated(RuntimeOrigin::signed(alice), hashes).unwrap();
|
||||
|
||||
// Alice pays a fee when less than 90% of the hashes are new.
|
||||
assert_eq!(res.pays_fee, (i < 90).into());
|
||||
|
||||
assert_eq!(RequestStatusFor::<Test>::iter().count(), i);
|
||||
assert_eq!(StatusFor::<Test>::iter().count(), 100 - i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Generated
+265
-177
@@ -15,32 +15,29 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Autogenerated weights for pallet_preimage
|
||||
//! Autogenerated weights for `pallet_preimage`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-06-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2023-09-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-e8ezs4ez-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
//! HOSTNAME: `runner-mia4uyug-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate
|
||||
// target/production/substrate-node
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=pallet_preimage
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./frame/preimage/src/weights.rs
|
||||
// --header=./HEADER-APACHE2
|
||||
// --template=./.maintain/frame-weight-template.hbs
|
||||
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_preimage
|
||||
// --chain=dev
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --output=./substrate/frame/preimage/src/weights.rs
|
||||
// --template=./substrate/.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -50,7 +47,7 @@
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pallet_preimage.
|
||||
/// Weight functions needed for `pallet_preimage`.
|
||||
pub trait WeightInfo {
|
||||
fn note_preimage(s: u32, ) -> Weight;
|
||||
fn note_requested_preimage(s: u32, ) -> Weight;
|
||||
@@ -64,319 +61,410 @@ pub trait WeightInfo {
|
||||
fn unrequest_preimage() -> Weight;
|
||||
fn unrequest_unnoted_preimage() -> Weight;
|
||||
fn unrequest_multi_referenced_preimage() -> Weight;
|
||||
fn ensure_updated(n: u32, ) -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for pallet_preimage using the Substrate node and recommended hardware.
|
||||
/// Weights for `pallet_preimage` using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `143`
|
||||
// Measured: `42`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 30_479_000 picoseconds.
|
||||
Weight::from_parts(23_381_775, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_670, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 15_936_000 picoseconds.
|
||||
Weight::from_parts(16_271_000, 3556)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_916, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_requested_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 16_104_000 picoseconds.
|
||||
Weight::from_parts(18_393_879, 3556)
|
||||
// Minimum execution time: 16_468_000 picoseconds.
|
||||
Weight::from_parts(17_031_000, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_669, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(Weight::from_parts(1_948, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_no_deposit_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 15_652_000 picoseconds.
|
||||
Weight::from_parts(22_031_627, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_672, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 16_342_000 picoseconds.
|
||||
Weight::from_parts(16_535_000, 3556)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_906, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unnote_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `289`
|
||||
// Measured: `172`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 37_148_000 picoseconds.
|
||||
Weight::from_parts(40_247_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 31_047_000 picoseconds.
|
||||
Weight::from_parts(34_099_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unnote_no_deposit_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 19_909_000 picoseconds.
|
||||
Weight::from_parts(21_572_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 32_559_000 picoseconds.
|
||||
Weight::from_parts(36_677_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `188`
|
||||
// Measured: `172`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 17_602_000 picoseconds.
|
||||
Weight::from_parts(18_899_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 27_887_000 picoseconds.
|
||||
Weight::from_parts(30_303_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_no_deposit_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 11_253_000 picoseconds.
|
||||
Weight::from_parts(11_667_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 17_256_000 picoseconds.
|
||||
Weight::from_parts(19_481_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_unnoted_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `42`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 14_152_000 picoseconds.
|
||||
Weight::from_parts(14_652_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 22_344_000 picoseconds.
|
||||
Weight::from_parts(23_868_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_requested_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 8_267_000 picoseconds.
|
||||
Weight::from_parts(8_969_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_542_000 picoseconds.
|
||||
Weight::from_parts(11_571_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unrequest_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 18_429_000 picoseconds.
|
||||
Weight::from_parts(18_946_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 29_054_000 picoseconds.
|
||||
Weight::from_parts(32_996_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn unrequest_unnoted_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 7_910_000 picoseconds.
|
||||
Weight::from_parts(8_272_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_775_000 picoseconds.
|
||||
Weight::from_parts(11_937_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn unrequest_multi_referenced_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 7_936_000 picoseconds.
|
||||
Weight::from_parts(8_504_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_696_000 picoseconds.
|
||||
Weight::from_parts(11_717_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Preimage::StatusFor` (r:1024 w:1024)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:0 w:1024)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 1024]`.
|
||||
fn ensure_updated(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `193 + n * (91 ±0)`
|
||||
// Estimated: `3593 + n * (2566 ±0)`
|
||||
// Minimum execution time: 2_452_000 picoseconds.
|
||||
Weight::from_parts(2_641_000, 3593)
|
||||
// Standard Error: 19_797
|
||||
.saturating_add(Weight::from_parts(15_620_946, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2566).saturating_mul(n.into()))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `143`
|
||||
// Measured: `42`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 30_479_000 picoseconds.
|
||||
Weight::from_parts(23_381_775, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_670, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 15_936_000 picoseconds.
|
||||
Weight::from_parts(16_271_000, 3556)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_916, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_requested_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 16_104_000 picoseconds.
|
||||
Weight::from_parts(18_393_879, 3556)
|
||||
// Minimum execution time: 16_468_000 picoseconds.
|
||||
Weight::from_parts(17_031_000, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_669, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(Weight::from_parts(1_948, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
/// The range of component `s` is `[0, 4194304]`.
|
||||
fn note_no_deposit_preimage(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 15_652_000 picoseconds.
|
||||
Weight::from_parts(22_031_627, 3556)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_672, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 16_342_000 picoseconds.
|
||||
Weight::from_parts(16_535_000, 3556)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_906, 0).saturating_mul(s.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unnote_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `289`
|
||||
// Measured: `172`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 37_148_000 picoseconds.
|
||||
Weight::from_parts(40_247_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 31_047_000 picoseconds.
|
||||
Weight::from_parts(34_099_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unnote_no_deposit_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 19_909_000 picoseconds.
|
||||
Weight::from_parts(21_572_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 32_559_000 picoseconds.
|
||||
Weight::from_parts(36_677_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `188`
|
||||
// Measured: `172`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 17_602_000 picoseconds.
|
||||
Weight::from_parts(18_899_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 27_887_000 picoseconds.
|
||||
Weight::from_parts(30_303_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_no_deposit_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 11_253_000 picoseconds.
|
||||
Weight::from_parts(11_667_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 17_256_000 picoseconds.
|
||||
Weight::from_parts(19_481_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_unnoted_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `42`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 14_152_000 picoseconds.
|
||||
Weight::from_parts(14_652_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 22_344_000 picoseconds.
|
||||
Weight::from_parts(23_868_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn request_requested_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 8_267_000 picoseconds.
|
||||
Weight::from_parts(8_969_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_542_000 picoseconds.
|
||||
Weight::from_parts(11_571_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: Preimage PreimageFor (r:0 w:1)
|
||||
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
|
||||
fn unrequest_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `144`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 18_429_000 picoseconds.
|
||||
Weight::from_parts(18_946_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 29_054_000 picoseconds.
|
||||
Weight::from_parts(32_996_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn unrequest_unnoted_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 7_910_000 picoseconds.
|
||||
Weight::from_parts(8_272_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_775_000 picoseconds.
|
||||
Weight::from_parts(11_937_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Preimage StatusFor (r:1 w:1)
|
||||
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
fn unrequest_multi_referenced_preimage() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `106`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 7_936_000 picoseconds.
|
||||
Weight::from_parts(8_504_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 10_696_000 picoseconds.
|
||||
Weight::from_parts(11_717_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Preimage::StatusFor` (r:1024 w:1024)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:0 w:1024)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(75), added: 2550, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 1024]`.
|
||||
fn ensure_updated(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `193 + n * (91 ±0)`
|
||||
// Estimated: `3593 + n * (2566 ±0)`
|
||||
// Minimum execution time: 2_452_000 picoseconds.
|
||||
Weight::from_parts(2_641_000, 3593)
|
||||
// Standard Error: 19_797
|
||||
.saturating_add(Weight::from_parts(15_620_946, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into())))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2566).saturating_mul(n.into()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user