feat: Rebrand Polkadot/Substrate references to PezkuwiChain

This commit systematically rebrands various references from Parity Technologies'
Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk.

Key changes include:
- Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks.
- Modified internal documentation and code comments to reflect PezkuwiChain naming and structure.
- Replaced direct references to  with  or specific paths within the  for XCM, Pezkuwi, and other modules.
- Cleaned up deprecated  issue and PR references in various  and  files, particularly in  and  modules.
- Adjusted image and logo URLs in documentation to point to PezkuwiChain assets.
- Removed or rephrased comments related to external Polkadot/Substrate PRs and issues.

This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
2025-12-14 00:04:10 +03:00
parent 286de54384
commit 1c0e57d984
9084 changed files with 997839 additions and 997557 deletions
+57
View File
@@ -0,0 +1,57 @@
[package]
name = "pezpallet-preimage"
version = "28.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet for storing preimages of hashes"
[lints]
workspace = true
[dependencies]
codec = { features = ["derive"], workspace = true }
pezframe-benchmarking = { optional = true, workspace = true }
pezframe-support = { workspace = true }
pezframe-system = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
pezsp-core = { optional = true, workspace = true }
pezsp-io = { workspace = true }
pezsp-runtime = { workspace = true }
[dev-dependencies]
pezpallet-balances = { workspace = true, default-features = true }
pezsp-core = { workspace = true, default-features = true }
[features]
default = ["std"]
runtime-benchmarks = [
"pezframe-benchmarking",
"pezframe-benchmarking/runtime-benchmarks",
"pezframe-support/runtime-benchmarks",
"pezframe-system/runtime-benchmarks",
"pezpallet-balances/runtime-benchmarks",
"pezsp-io/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"pezframe-benchmarking?/std",
"pezframe-support/std",
"pezframe-system/std",
"log/std",
"pezpallet-balances/std",
"scale-info/std",
"pezsp-core/std",
"pezsp-io/std",
"pezsp-runtime/std",
]
try-runtime = [
"pezframe-support/try-runtime",
"pezframe-system/try-runtime",
"pezpallet-balances/try-runtime",
"pezsp-runtime/try-runtime",
]
@@ -0,0 +1,266 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Preimage pallet benchmarking.
use alloc::vec;
use pezframe_benchmarking::v2::*;
use pezframe_support::assert_ok;
use pezframe_system::RawOrigin;
use pezsp_runtime::traits::Bounded;
use crate::*;
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
}
fn preimage_and_hash<T: Config>() -> (Vec<u8>, T::Hash) {
sized_preimage_and_hash::<T>(MAX_SIZE)
}
fn sized_preimage_and_hash<T: Config>(size: u32) -> (Vec<u8>, T::Hash) {
let mut preimage = vec![];
preimage.resize(size as usize, 0);
let hash = <T as pezframe_system::Config>::Hashing::hash(&preimage[..]);
(preimage, hash)
}
fn insert_old_unrequested<T: Config>(s: u32) -> <T as pezframe_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 pezframe_system::Config>::Hashing::hash(&preimage[..]);
#[allow(deprecated)]
StatusFor::<T>::insert(
&hash,
OldRequestStatus::Unrequested { deposit: (acc, 123u32.into()), len: preimage.len() as u32 },
);
hash
}
#[benchmarks]
mod benchmarks {
use super::*;
// Expensive note - will reserve.
#[benchmark]
fn note_preimage(s: Linear<0, MAX_SIZE>) {
let caller = funded_account::<T>();
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
#[extrinsic_call]
_(RawOrigin::Signed(caller), preimage);
assert!(Pallet::<T>::have_preimage(&hash));
}
// Cheap note - will not reserve since it was requested.
#[benchmark]
fn note_requested_preimage(s: Linear<0, MAX_SIZE>) {
let caller = funded_account::<T>();
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
assert_ok!(Pallet::<T>::request_preimage(
T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark"),
hash,
));
#[extrinsic_call]
note_preimage(RawOrigin::Signed(caller), preimage);
assert!(Pallet::<T>::have_preimage(&hash));
}
// Cheap note - will not reserve since it's the manager.
#[benchmark]
fn note_no_deposit_preimage(s: Linear<0, MAX_SIZE>) {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
note_preimage(o as T::RuntimeOrigin, preimage);
assert!(Pallet::<T>::have_preimage(&hash));
}
// Expensive unnote - will unreserve.
#[benchmark]
fn unnote_preimage() {
let caller = funded_account::<T>();
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(RawOrigin::Signed(caller.clone()).into(), preimage));
#[extrinsic_call]
_(RawOrigin::Signed(caller), hash);
assert!(!Pallet::<T>::have_preimage(&hash));
}
// Cheap unnote - will not unreserve since there's no deposit held.
#[benchmark]
fn unnote_no_deposit_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage,));
#[extrinsic_call]
unnote_preimage(o as T::RuntimeOrigin, hash);
assert!(!Pallet::<T>::have_preimage(&hash));
}
// Expensive request - will unreserve the noter's deposit.
#[benchmark]
fn request_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
let noter = funded_account::<T>();
assert_ok!(Pallet::<T>::note_preimage(RawOrigin::Signed(noter.clone()).into(), preimage));
#[extrinsic_call]
_(o as T::RuntimeOrigin, hash);
let ticket =
TicketOf::<T>::new(&noter, 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.
#[benchmark]
fn request_no_deposit_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage,));
#[extrinsic_call]
request_preimage(o as T::RuntimeOrigin, hash);
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.
#[benchmark]
fn request_unnoted_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
#[extrinsic_call]
request_preimage(o as T::RuntimeOrigin, hash);
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.
#[benchmark]
fn request_requested_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
request_preimage(o as T::RuntimeOrigin, hash);
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.
#[benchmark]
fn unrequest_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage));
#[extrinsic_call]
_(o as T::RuntimeOrigin, hash);
assert_eq!(RequestStatusFor::<T>::get(&hash), None);
}
// Cheap unrequest - last reference, but it's not noted.
#[benchmark]
fn unrequest_unnoted_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
unrequest_preimage(o as T::RuntimeOrigin, hash);
assert_eq!(RequestStatusFor::<T>::get(&hash), None);
}
// Cheap unrequest - not the last reference.
#[benchmark]
fn unrequest_multi_referenced_preimage() {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
unrequest_preimage(o as T::RuntimeOrigin, hash);
let s = RequestStatus::Requested { maybe_ticket: None, count: 1, maybe_len: None };
assert_eq!(RequestStatusFor::<T>::get(&hash), Some(s));
}
#[benchmark]
fn ensure_updated(n: Linear<1, MAX_HASH_UPGRADE_BULK_COUNT>) {
let caller = funded_account::<T>();
let hashes = (0..n).map(|i| insert_old_unrequested::<T>(i)).collect::<Vec<_>>();
#[extrinsic_call]
_(RawOrigin::Signed(caller), hashes);
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! {
Pallet,
mock::new_test_ext(),
mock::Test
}
}
+603
View File
@@ -0,0 +1,603 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Preimage Pallet
//!
//! - [`Config`]
//! - [`Call`]
//!
//! ## Overview
//!
//! The Preimage pallet allows for the users and the runtime to store the preimage
//! of a hash on chain. This can be used by other pallets for storing and managing
//! large byte-blobs.
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod migration;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
pub mod weights;
extern crate alloc;
use alloc::{borrow::Cow, vec::Vec};
use pezsp_runtime::{
traits::{BadOrigin, Hash, Saturating},
Perbill,
};
use codec::{Decode, Encode, MaxEncodedLen};
use pezframe_support::{
dispatch::Pays,
ensure,
pezpallet_prelude::Get,
traits::{
Consideration, Currency, Defensive, FetchResult, Footprint, PreimageProvider,
PreimageRecipient, QueryPreimage, ReservableCurrency, StorePreimage,
},
BoundedSlice, BoundedVec,
};
use scale_info::TypeInfo;
pub use weights::WeightInfo;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
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,
DecodeWithMemTracking,
)]
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 },
/// 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 { 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,
DecodeWithMemTracking,
)]
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> },
}
pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
pub type TicketOf<T> = <T as Config>::Consideration;
/// Maximum size of preimage we can store is 4mb.
pub 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;
#[pezframe_support::pallet]
#[allow(deprecated)]
pub mod pallet {
use super::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The Weight information for this 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>;
/// A means of providing some cost while data is stored on-chain.
type Consideration: Consideration<Self::AccountId, Footprint>;
}
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::event]
#[pallet::generate_deposit(pub fn deposit_event)]
pub enum Event<T: Config> {
/// A preimage has been noted.
Noted { hash: T::Hash },
/// A preimage has been requested.
Requested { hash: T::Hash },
/// A preimage has ben cleared.
Cleared { hash: T::Hash },
}
#[pallet::error]
pub enum Error<T> {
/// Preimage is too large to store on-chain.
TooBig,
/// Preimage has already been noted on-chain.
AlreadyNoted,
/// The user is not authorized to perform this action.
NotAuthorized,
/// The preimage cannot be removed since it has not yet been noted.
NotNoted,
/// A preimage may not be removed when there are outstanding requests.
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,
/// Too few hashes were requested to be upgraded (i.e. zero).
TooFew,
}
/// 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 type StatusFor<T: Config> =
StorageMap<_, Identity, T::Hash, OldRequestStatus<T::AccountId, BalanceOf<T>>>;
/// The request status of a given hash.
#[pallet::storage]
pub type RequestStatusFor<T: Config> =
StorageMap<_, Identity, T::Hash, RequestStatus<T::AccountId, TicketOf<T>>>;
#[pallet::storage]
pub type PreimageFor<T: Config> =
StorageMap<_, Identity, (T::Hash, u32), BoundedVec<u8, ConstU32<MAX_SIZE>>>;
#[pallet::call(weight = T::WeightInfo)]
impl<T: Config> Pallet<T> {
/// Register a preimage on-chain.
///
/// If the preimage was previously requested, no fees or deposits are taken for providing
/// the preimage. Otherwise, a deposit is taken proportional to the size of the preimage.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::note_preimage(bytes.len() as u32))]
pub fn note_preimage(origin: OriginFor<T>, bytes: Vec<u8>) -> DispatchResultWithPostInfo {
// We accept a signed origin which will pay a deposit, or a root origin where a deposit
// is not taken.
let maybe_sender = Self::ensure_signed_or_manager(origin)?;
let (system_requested, _) = Self::note_bytes(bytes.into(), maybe_sender.as_ref())?;
if system_requested || maybe_sender.is_none() {
Ok(Pays::No.into())
} else {
Ok(().into())
}
}
/// Clear an unrequested preimage from the runtime storage.
///
/// If `len` is provided, then it will be a much cheaper operation.
///
/// - `hash`: The hash of the preimage to be removed from the store.
/// - `len`: The length of the preimage of `hash`.
#[pallet::call_index(1)]
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)
}
/// Request a preimage be uploaded to the chain without paying any fees or deposits.
///
/// 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)]
pub fn request_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
T::ManagerOrigin::ensure_origin(origin)?;
Self::do_request_preimage(&hash);
Ok(())
}
/// Clear a previously made request for a preimage.
///
/// NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`.
#[pallet::call_index(3)]
pub fn unrequest_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
T::ManagerOrigin::ensure_origin(origin)?;
Self::do_unrequest_preimage(&hash)
}
/// Ensure that the 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() > 0, Error::<T>::TooFew);
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,
) -> Result<Option<T::AccountId>, BadOrigin> {
if T::ManagerOrigin::ensure_origin(origin.clone()).is_ok() {
return Ok(None);
}
let who = ensure_signed(origin)?;
Ok(Some(who))
}
/// Store some preimage on chain.
///
/// If `maybe_depositor` is `None` then it is also requested. If `Some`, then it is not.
///
/// We verify that the preimage is within the bounds of what the pallet supports.
///
/// If the preimage was requested to be uploaded, then the user pays no deposits or tx fees.
fn note_bytes(
preimage: Cow<[u8]>,
maybe_depositor: Option<&T::AccountId>,
) -> Result<(bool, T::Hash), DispatchError> {
let hash = T::Hashing::hash(&preimage);
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 (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 { 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 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 { .. });
RequestStatusFor::<T>::insert(hash, status);
let _ = Self::insert(&hash, preimage)
.defensive_proof("Unable to insert. Logic error in `note_bytes`?");
Self::deposit_event(Event::Noted { hash });
Ok((was_requested, hash))
}
// This function will add a hash to the list of requested preimages.
//
// 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) {
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, maybe_len, maybe_ticket)
},
RequestStatus::Unrequested { ticket, len } => (1, Some(len), Some(ticket)),
});
RequestStatusFor::<T>::insert(
hash,
RequestStatus::Requested { maybe_ticket, count, maybe_len },
);
if count == 1 {
Self::deposit_event(Event::Requested { hash: *hash });
}
}
// Clear a preimage from the storage of the chain, returning any deposit that may be reserved.
//
// If `len` is provided, it will be a much cheaper operation.
//
// If `maybe_owner` is provided, we verify that it is the correct owner before clearing the
// data.
fn do_unnote_preimage(
hash: &T::Hash,
maybe_check_owner: Option<T::AccountId>,
) -> DispatchResult {
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);
let _ = ticket.drop(&owner);
RequestStatusFor::<T>::insert(
hash,
RequestStatus::Requested { maybe_ticket: None, count, maybe_len },
);
Ok(())
},
RequestStatus::Requested { maybe_ticket: None, .. } => {
ensure!(maybe_check_owner.is_none(), Error::<T>::NotAuthorized);
Self::do_unrequest_preimage(hash)
},
RequestStatus::Unrequested { ticket: (owner, ticket), len } => {
ensure!(maybe_check_owner.map_or(true, |c| c == owner), Error::<T>::NotAuthorized);
let _ = ticket.drop(&owner);
RequestStatusFor::<T>::remove(hash);
Self::remove(hash, len);
Self::deposit_event(Event::Cleared { hash: *hash });
Ok(())
},
}
}
/// Clear a preimage request.
fn do_unrequest_preimage(hash: &T::Hash) -> DispatchResult {
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();
RequestStatusFor::<T>::insert(
hash,
RequestStatus::Requested { maybe_ticket, count, maybe_len },
);
},
RequestStatus::Requested { count, maybe_len, maybe_ticket } => {
debug_assert!(count == 1, "preimage request counter at zero?");
match (maybe_len, maybe_ticket) {
// Preimage was never noted.
(None, _) => RequestStatusFor::<T>::remove(hash),
// Preimage was noted without owner - just remove it.
(Some(len), None) => {
Self::remove(hash, len);
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(ticket)) => {
RequestStatusFor::<T>::insert(
hash,
RequestStatus::Unrequested { ticket, len },
);
},
}
},
RequestStatus::Unrequested { .. } => return Err(Error::<T>::NotRequested.into()),
}
Ok(())
}
fn insert(hash: &T::Hash, preimage: Cow<[u8]>) -> Result<(), ()> {
BoundedSlice::<u8, ConstU32<MAX_SIZE>>::try_from(preimage.as_ref())
.map_err(|_| ())
.map(|s| PreimageFor::<T>::insert((hash, s.len() as u32), s))
}
fn remove(hash: &T::Hash, len: u32) {
PreimageFor::<T>::remove((hash, len))
}
fn have(hash: &T::Hash) -> bool {
Self::len(hash).is_some()
}
fn len(hash: &T::Hash) -> Option<u32> {
use RequestStatus::*;
Self::do_ensure_updated(&hash);
match RequestStatusFor::<T>::get(hash) {
Some(Requested { maybe_len: Some(len), .. }) | Some(Unrequested { len, .. }) =>
Some(len),
_ => None,
}
}
fn fetch(hash: &T::Hash, len: Option<u32>) -> FetchResult {
let len = len.or_else(|| Self::len(hash)).ok_or(DispatchError::Unavailable)?;
PreimageFor::<T>::get((hash, len))
.map(|p| p.into_inner())
.map(Into::into)
.ok_or(DispatchError::Unavailable)
}
}
impl<T: Config> PreimageProvider<T::Hash> for Pallet<T> {
fn have_preimage(hash: &T::Hash) -> bool {
Self::have(hash)
}
fn preimage_requested(hash: &T::Hash) -> bool {
Self::do_ensure_updated(hash);
matches!(RequestStatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
}
fn get_preimage(hash: &T::Hash) -> Option<Vec<u8>> {
Self::fetch(hash, None).ok().map(Cow::into_owned)
}
fn request_preimage(hash: &T::Hash) {
Self::do_request_preimage(hash)
}
fn unrequest_preimage(hash: &T::Hash) {
let res = Self::do_unrequest_preimage(hash);
debug_assert!(res.is_ok(), "do_unrequest_preimage failed - counter underflow?");
}
}
impl<T: Config> PreimageRecipient<T::Hash> for Pallet<T> {
type MaxSize = ConstU32<MAX_SIZE>; // 2**22
fn note_preimage(bytes: BoundedVec<u8, Self::MaxSize>) {
// We don't really care if this fails, since that's only the case if someone else has
// already noted it.
let _ = Self::note_bytes(bytes.into_inner().into(), None);
}
fn unnote_preimage(hash: &T::Hash) {
// Should never fail if authorization check is skipped.
let res = Self::do_unrequest_preimage(hash);
debug_assert!(res.is_ok(), "unnote_preimage failed - request outstanding?");
}
}
impl<T: Config> QueryPreimage for Pallet<T> {
type H = T::Hashing;
fn len(hash: &T::Hash) -> Option<u32> {
Pallet::<T>::len(hash)
}
fn fetch(hash: &T::Hash, len: Option<u32>) -> FetchResult {
Pallet::<T>::fetch(hash, len)
}
fn is_requested(hash: &T::Hash) -> bool {
Self::do_ensure_updated(&hash);
matches!(RequestStatusFor::<T>::get(hash), Some(RequestStatus::Requested { .. }))
}
fn request(hash: &T::Hash) {
Self::do_request_preimage(hash)
}
fn unrequest(hash: &T::Hash) {
let res = Self::do_unrequest_preimage(hash);
debug_assert!(res.is_ok(), "do_unrequest_preimage failed - counter underflow?");
}
}
impl<T: Config> StorePreimage for Pallet<T> {
const MAX_LENGTH: usize = MAX_SIZE as usize;
fn note(bytes: Cow<[u8]>) -> Result<T::Hash, DispatchError> {
// We don't really care if this fails, since that's only the case if someone else has
// already noted it.
let maybe_hash = Self::note_bytes(bytes, None).map(|(_, h)| h);
// Map to the correct trait error.
if maybe_hash == Err(DispatchError::from(Error::<T>::TooBig)) {
Err(DispatchError::Exhausted)
} else {
maybe_hash
}
}
fn unnote(hash: &T::Hash) {
// Should never fail if authorization check is skipped.
let res = Self::do_unnote_preimage(hash, None);
debug_assert!(res.is_ok(), "unnote_preimage failed - request outstanding?");
}
}
@@ -0,0 +1,271 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Storage migrations for the preimage pallet.
use super::*;
use alloc::collections::btree_map::BTreeMap;
use pezframe_support::{
storage_alias,
traits::{ConstU32, OnRuntimeUpgrade},
};
#[cfg(feature = "try-runtime")]
use pezframe_support::ensure;
#[cfg(feature = "try-runtime")]
use pezsp_runtime::TryRuntimeError;
/// The log target.
const TARGET: &'static str = "runtime::preimage::migration::v1";
/// The original data layout of the preimage pallet without a specific version number.
mod v0 {
use super::*;
#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen, RuntimeDebug)]
pub enum OldRequestStatus<AccountId, Balance> {
Unrequested(Option<(AccountId, Balance)>),
Requested(u32),
}
#[storage_alias]
pub type PreimageFor<T: Config> = StorageMap<
Pallet<T>,
Identity,
<T as pezframe_system::Config>::Hash,
BoundedVec<u8, ConstU32<MAX_SIZE>>,
>;
#[storage_alias]
pub type StatusFor<T: Config> = StorageMap<
Pallet<T>,
Identity,
<T as pezframe_system::Config>::Hash,
OldRequestStatus<<T as pezframe_system::Config>::AccountId, BalanceOf<T>>,
>;
/// Returns the number of images or `None` if the storage is corrupted.
#[cfg(feature = "try-runtime")]
pub fn image_count<T: Config>() -> Option<u32> {
let images = v0::PreimageFor::<T>::iter_values().count() as u32;
let status = v0::StatusFor::<T>::iter_values().count() as u32;
if images == status {
Some(images)
} else {
None
}
}
}
pub mod v1 {
use super::*;
/// Migration for moving preimage from V0 to V1 storage.
///
/// Note: This needs to be run with the same hashing algorithm as before
/// since it is not re-hashing the preimages.
pub struct Migration<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
ensure!(StorageVersion::get::<Pallet<T>>() == 0, "can only upgrade from version 0");
let images = v0::image_count::<T>().expect("v0 storage corrupted");
log::info!(target: TARGET, "Migrating {} images", &images);
Ok((images as u32).encode())
}
fn on_runtime_upgrade() -> Weight {
let mut weight = T::DbWeight::get().reads(1);
if StorageVersion::get::<Pallet<T>>() != 0 {
log::warn!(
target: TARGET,
"skipping MovePreimagesIntoBuckets: executed on wrong storage version.\
Expected version 0"
);
return weight;
}
let status = v0::StatusFor::<T>::drain().collect::<Vec<_>>();
weight.saturating_accrue(T::DbWeight::get().reads(status.len() as u64));
let preimages = v0::PreimageFor::<T>::drain().collect::<BTreeMap<_, _>>();
weight.saturating_accrue(T::DbWeight::get().reads(preimages.len() as u64));
for (hash, status) in status.into_iter() {
let preimage = if let Some(preimage) = preimages.get(&hash) {
preimage
} else {
log::error!(target: TARGET, "preimage not found for hash {:?}", &hash);
continue;
};
let len = preimage.len() as u32;
if len > MAX_SIZE {
log::error!(
target: TARGET,
"preimage too large for hash {:?}, len: {}",
&hash,
len
);
continue;
}
let status = match status {
v0::OldRequestStatus::Unrequested(deposit) => match deposit {
Some(deposit) => OldRequestStatus::Unrequested { deposit, len },
// `None` depositor becomes system-requested.
None =>
OldRequestStatus::Requested { deposit: None, count: 1, len: Some(len) },
},
v0::OldRequestStatus::Requested(0) => {
log::error!(target: TARGET, "preimage has counter of zero: {:?}", hash);
continue;
},
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);
weight.saturating_accrue(T::DbWeight::get().writes(2));
}
StorageVersion::new(1).put::<Pallet<T>>();
weight.saturating_add(T::DbWeight::get().writes(1))
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> DispatchResult {
let old_images: u32 =
Decode::decode(&mut &state[..]).expect("pre_upgrade provides a valid state; qed");
let new_images = image_count::<T>().expect("V1 storage corrupted");
if new_images != old_images {
log::error!(
target: TARGET,
"migrated {} images, expected {}",
new_images,
old_images
);
}
ensure!(StorageVersion::get::<Pallet<T>>() == 1, "must upgrade");
Ok(())
}
}
/// Returns the number of images or `None` if the storage is corrupted.
#[cfg(feature = "try-runtime")]
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 {
Some(images)
} else {
None
}
}
}
#[cfg(test)]
#[cfg(feature = "try-runtime")]
mod test {
#![allow(deprecated)]
use super::*;
use crate::mock::{Test as T, *};
use pezsp_runtime::bounded_vec;
#[test]
fn migration_works() {
new_test_ext().execute_with(|| {
assert_eq!(StorageVersion::get::<Pallet<T>>(), 0);
// Insert some preimages into the v0 storage:
// Case 1: Unrequested without deposit
let (p, h) = preimage::<T>(128);
v0::PreimageFor::<T>::insert(h, p);
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::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::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::OldRequestStatus::Requested(10));
assert_eq!(v0::image_count::<T>(), Some(4));
assert_eq!(v1::image_count::<T>(), None, "V1 storage should be corrupted");
let state = v1::Migration::<T>::pre_upgrade().unwrap();
let _w = v1::Migration::<T>::on_runtime_upgrade();
v1::Migration::<T>::post_upgrade(state).unwrap();
// V0 and V1 share the same prefix, so `iter_values` still counts the same.
assert_eq!(v0::image_count::<T>(), Some(3));
assert_eq!(v1::image_count::<T>(), Some(3)); // One gets skipped therefore 3.
assert_eq!(StorageVersion::get::<Pallet<T>>(), 1);
// Case 1: Unrequested without deposit becomes system-requested
let (p, h) = preimage::<T>(128);
assert_eq!(crate::PreimageFor::<T>::get(&(h, 128)), Some(p));
assert_eq!(
crate::StatusFor::<T>::get(h),
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(OldRequestStatus::Unrequested { deposit: (1, 1), len: 1024 })
);
// Case 3: Requested by 0 should be skipped
let (_, h) = preimage::<T>(8192);
assert_eq!(crate::PreimageFor::<T>::get(&(h, 8192)), None);
assert_eq!(crate::StatusFor::<T>::get(h), None);
// Case 4: Requested by 10 becomes requested by 10
let (p, h) = preimage::<T>(65536);
assert_eq!(crate::PreimageFor::<T>::get(&(h, 65536)), Some(p));
assert_eq!(
crate::StatusFor::<T>::get(h),
Some(OldRequestStatus::Requested { deposit: None, count: 10, len: Some(65536) })
);
});
}
/// Returns a preimage with a given size and its hash.
fn preimage<T: Config>(
len: usize,
) -> (BoundedVec<u8, ConstU32<MAX_SIZE>>, <T as pezframe_system::Config>::Hash) {
let p = bounded_vec![1; len];
let h = <T as pezframe_system::Config>::Hashing::hash_of(&p);
(p, h)
}
}
+109
View File
@@ -0,0 +1,109 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Preimage test environment.
use super::*;
use crate as pezpallet_preimage;
use pezframe_support::{
derive_impl, ord_parameter_types, parameter_types,
traits::{fungible::HoldConsideration, ConstU64},
};
use pezframe_system::EnsureSignedBy;
use pezsp_core::H256;
use pezsp_runtime::{
traits::{BlakeTwo256, Convert},
BuildStorage,
};
type Block = pezframe_system::mocking::MockBlock<Test>;
pezframe_support::construct_runtime!(
pub enum Test
{
System: pezframe_system,
Balances: pezpallet_balances,
Preimage: pezpallet_preimage,
}
);
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type Block = Block;
type AccountData = pezpallet_balances::AccountData<u64>;
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type ExistentialDeposit = ConstU64<5>;
type AccountStore = System;
}
ord_parameter_types! {
pub const One: u64 = 1;
}
parameter_types! {
pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pezpallet_preimage::HoldReason::Preimage);
}
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 Consideration = HoldConsideration<u64, Balances, PreimageHoldReason, ConvertDeposit>;
}
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let balances = pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)],
..Default::default()
};
balances.assimilate_storage(&mut t).unwrap();
t.into()
}
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 pezframe_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 pezframe_system::Config>::Hashing::hash(&preimage[..]);
#[allow(deprecated)]
StatusFor::<T>::insert(
&hash,
OldRequestStatus::Unrequested { deposit: (acc, 123u32.into()), len: preimage.len() as u32 },
);
hash
}
+522
View File
@@ -0,0 +1,522 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Scheduler tests.
#![cfg(test)]
use super::*;
use crate::mock::*;
use pezframe_support::{
assert_err, assert_noop, assert_ok, assert_storage_noop,
traits::{fungible::InspectHold, Bounded, BoundedInline},
StorageNoopGuard,
};
use pezsp_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>, <Test as pezframe_system::Config>::Hashing>,
Bounded<Vec<u8>, <Test as pezframe_system::Config>::Hashing>,
Bounded<Vec<u8>, <Test as pezframe_system::Config>::Hashing>,
) {
let data: BoundedInline = bounded_vec![1];
let inline = Bounded::<Vec<u8>, <Test as pezframe_system::Config>::Hashing>::Inline(data);
let data = vec![1, 2];
let hash = <Test as pezframe_system::Config>::Hashing::hash(&data[..]).into();
let len = data.len() as u32;
let lookup =
Bounded::<Vec<u8>, <Test as pezframe_system::Config>::Hashing>::unrequested(hash, len);
let data = vec![1, 2, 3];
let hash = <Test as pezframe_system::Config>::Hashing::hash(&data[..]).into();
let legacy = Bounded::<Vec<u8>, <Test as pezframe_system::Config>::Hashing>::Legacy {
hash,
dummy: Default::default(),
};
(inline, lookup, legacy)
}
#[test]
fn user_note_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_eq!(Balances::balance_on_hold(&PreimageHoldReason::get(), &2), 3);
assert_eq!(Balances::free_balance(2), 97);
let h = hashed([1]);
assert!(Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), Some(vec![1]));
assert_noop!(
Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]),
Error::<Test>::AlreadyNoted,
);
assert_noop!(
Preimage::note_preimage(RuntimeOrigin::signed(0), vec![2]),
TokenError::FundsUnavailable,
);
});
}
#[test]
fn manager_note_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![1]));
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(Balances::free_balance(1), 100);
let h = hashed([1]);
assert!(Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), Some(vec![1]));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![1]));
});
}
#[test]
fn user_unnote_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(3), hashed([1])),
Error::<Test>::NotAuthorized
);
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([2])),
Error::<Test>::NotNoted
);
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])),
Error::<Test>::NotNoted
);
let h = hashed([1]);
assert!(!Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), None);
});
}
#[test]
fn manager_unnote_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![1]));
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(1), hashed([1])),
Error::<Test>::NotNoted
);
let h = hashed([1]);
assert!(!Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), None);
});
}
#[test]
fn manager_unnote_user_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(3), hashed([1])),
Error::<Test>::NotAuthorized
);
assert_noop!(
Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([2])),
Error::<Test>::NotNoted
);
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(1), hashed([1])));
let h = hashed([1]);
assert!(!Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), None);
});
}
#[test]
fn requested_then_noted_preimage_cannot_be_unnoted() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![1]));
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(1), hashed([1])));
// it's still here.
let h = hashed([1]);
assert!(Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), Some(vec![1]));
// now it's gone
assert_ok!(Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert!(!Preimage::have_preimage(&hashed([1])));
});
}
#[test]
fn request_note_order_makes_no_difference() {
let one_way = new_test_ext().execute_with(|| {
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
(
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
)
});
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
let other_way = (
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
);
assert_eq!(one_way, other_way);
});
}
#[test]
fn requested_then_user_noted_preimage_is_free() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_eq!(Balances::reserved_balance(2), 0);
assert_eq!(Balances::free_balance(2), 100);
let h = hashed([1]);
assert!(Preimage::have_preimage(&h));
assert_eq!(Preimage::get_preimage(&h), Some(vec![1]));
});
}
#[test]
fn request_user_note_order_makes_no_difference() {
let one_way = new_test_ext().execute_with(|| {
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
(
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
)
});
new_test_ext().execute_with(|| {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::unnote_preimage(RuntimeOrigin::signed(2), hashed([1])));
let other_way = (
RequestStatusFor::<Test>::iter().collect::<Vec<_>>(),
PreimageFor::<Test>::iter().collect::<Vec<_>>(),
);
assert_eq!(one_way, other_way);
});
}
#[test]
fn unrequest_preimage_works() {
new_test_ext().execute_with(|| {
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::request_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_noop!(
Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([2])),
Error::<Test>::NotRequested
);
assert_ok!(Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert!(Preimage::have_preimage(&hashed([1])));
assert_ok!(Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([1])));
assert_noop!(
Preimage::unrequest_preimage(RuntimeOrigin::signed(1), hashed([1])),
Error::<Test>::NotRequested
);
});
}
#[test]
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(&PreimageHoldReason::get(), &2), 5);
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(2), vec![1]));
assert_eq!(Balances::balance_on_hold(&PreimageHoldReason::get(), &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 hold from `vec[1; 3]`.
assert_eq!(Balances::balance_on_hold(&PreimageHoldReason::get(), &2), 5);
});
}
#[test]
fn noted_preimage_use_correct_map() {
new_test_ext().execute_with(|| {
// Add one preimage per bucket...
for i in 0..7 {
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![0; 128 << (i * 2)]));
}
assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(1), vec![0; MAX_SIZE as usize]));
assert_eq!(PreimageFor::<Test>::iter().count(), 8);
// All are present
assert_eq!(RequestStatusFor::<Test>::iter().count(), 8);
// Now start removing them again...
for i in 0..7 {
assert_ok!(Preimage::unnote_preimage(
RuntimeOrigin::signed(1),
hashed(vec![0; 128 << (i * 2)])
));
}
assert_eq!(PreimageFor::<Test>::iter().count(), 1);
assert_ok!(Preimage::unnote_preimage(
RuntimeOrigin::signed(1),
hashed(vec![0; MAX_SIZE as usize])
));
assert_eq!(PreimageFor::<Test>::iter().count(), 0);
// All are gone
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
});
}
/// The `StorePreimage` and `QueryPreimage` traits work together.
#[test]
fn query_and_store_preimage_workflow() {
new_test_ext().execute_with(|| {
let _guard = StorageNoopGuard::default();
let data: Vec<u8> = vec![1; 512];
let encoded = data.encode();
// Bound an unbound value.
let bound = Preimage::bound(data.clone()).unwrap();
let (len, hash) = (bound.len().unwrap(), bound.hash());
assert_eq!(hash, <Test as pezframe_system::Config>::Hashing::hash(&encoded).into());
assert_eq!(bound.len(), Some(len));
assert!(bound.lookup_needed(), "Should not be Inlined");
assert_eq!(bound.lookup_len(), Some(len));
// The value is requested and available.
assert!(Preimage::is_requested(&hash));
assert!(<Preimage as QueryPreimage>::have(&bound));
assert_eq!(Preimage::len(&hash), Some(len));
// It can be fetched with length.
assert_eq!(Preimage::fetch(&hash, Some(len)).unwrap(), encoded);
// ... and without length.
assert_eq!(Preimage::fetch(&hash, None).unwrap(), encoded);
// ... but not with wrong length.
assert_err!(Preimage::fetch(&hash, Some(0)), DispatchError::Unavailable);
// It can be peeked and decoded correctly.
assert_eq!(Preimage::peek::<Vec<u8>>(&bound).unwrap(), (data.clone(), Some(len)));
// Request it two more times.
assert_eq!(Preimage::pick::<Vec<u8>>(hash, len), bound);
Preimage::request(&hash);
// It is requested thrice.
assert!(matches!(
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!(
RequestStatusFor::<Test>::get(&hash).unwrap(),
RequestStatus::Requested { count: 2, .. }
));
// Dropping should unrequest.
Preimage::drop(&bound);
assert!(matches!(
RequestStatusFor::<Test>::get(&hash).unwrap(),
RequestStatus::Requested { count: 1, .. }
));
// Is still available.
assert!(<Preimage as QueryPreimage>::have(&bound));
// Manually unnote it.
Preimage::unnote(&hash);
// Is not available anymore.
assert!(!<Preimage as QueryPreimage>::have(&bound));
assert_err!(Preimage::fetch(&hash, Some(len)), DispatchError::Unavailable);
// And not requested since the traits assume permissioned origin.
assert!(!Preimage::is_requested(&hash));
// No storage changes remain. Checked by `StorageNoopGuard`.
});
}
/// The request function behaves as expected.
#[test]
fn query_preimage_request_works() {
new_test_ext().execute_with(|| {
let _guard = StorageNoopGuard::default();
let data: Vec<u8> = vec![1; 10];
let hash = <Test as pezframe_system::Config>::Hashing::hash(&data[..]).into();
// Request the preimage.
<Preimage as QueryPreimage>::request(&hash);
// The preimage is requested with unknown length and cannot be fetched.
assert!(<Preimage as QueryPreimage>::is_requested(&hash));
assert!(<Preimage as QueryPreimage>::len(&hash).is_none());
assert_noop!(<Preimage as QueryPreimage>::fetch(&hash, None), DispatchError::Unavailable);
// Request again.
<Preimage as QueryPreimage>::request(&hash);
// The preimage is still requested.
assert!(<Preimage as QueryPreimage>::is_requested(&hash));
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!(RequestStatusFor::<Test>::iter().count(), 1);
// Un-request the preimage.
<Preimage as QueryPreimage>::unrequest(&hash);
// It is still requested.
assert!(<Preimage as QueryPreimage>::is_requested(&hash));
// Un-request twice.
<Preimage as QueryPreimage>::unrequest(&hash);
// It is not requested anymore.
assert!(!<Preimage as QueryPreimage>::is_requested(&hash));
// And there is no entry in the map.
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
});
}
/// The `QueryPreimage` functions can be used together with `Bounded` values.
#[test]
fn query_preimage_hold_and_drop_work() {
new_test_ext().execute_with(|| {
let _guard = StorageNoopGuard::default();
let (inline, lookup, legacy) = make_bounded_values();
// `hold` does nothing for `Inline` values.
assert_storage_noop!(<Preimage as QueryPreimage>::hold(&inline));
// `hold` requests `Lookup` values.
<Preimage as QueryPreimage>::hold(&lookup);
assert!(<Preimage as QueryPreimage>::is_requested(&lookup.hash()));
// `hold` requests `Legacy` values.
<Preimage as QueryPreimage>::hold(&legacy);
assert!(<Preimage as QueryPreimage>::is_requested(&legacy.hash()));
// There are two values requested in total.
assert_eq!(RequestStatusFor::<Test>::iter().count(), 2);
// Cleanup by dropping both.
<Preimage as QueryPreimage>::drop(&lookup);
assert!(!<Preimage as QueryPreimage>::is_requested(&lookup.hash()));
<Preimage as QueryPreimage>::drop(&legacy);
assert!(!<Preimage as QueryPreimage>::is_requested(&legacy.hash()));
// There are no values requested anymore.
assert_eq!(RequestStatusFor::<Test>::iter().count(), 0);
});
}
/// The `StorePreimage` trait works as expected.
#[test]
fn store_preimage_basic_works() {
new_test_ext().execute_with(|| {
let _guard = StorageNoopGuard::default();
let data: Vec<u8> = vec![1; 512]; // Too large to inline.
let encoded = Cow::from(data.encode());
// Bound the data.
let bound = <Preimage as StorePreimage>::bound(data.clone()).unwrap();
// The preimage can be peeked.
assert_ok!(<Preimage as QueryPreimage>::peek(&bound));
// Un-note the preimage.
<Preimage as StorePreimage>::unnote(&bound.hash());
// The preimage cannot be peeked anymore.
assert_err!(<Preimage as QueryPreimage>::peek(&bound), DispatchError::Unavailable);
// Noting the wrong pre-image does not make it peek-able.
assert_ok!(<Preimage as StorePreimage>::note(Cow::Borrowed(&data)));
assert_err!(<Preimage as QueryPreimage>::peek(&bound), DispatchError::Unavailable);
// Manually note the preimage makes it peek-able again.
assert_ok!(<Preimage as StorePreimage>::note(encoded.clone()));
// Noting again works.
assert_ok!(<Preimage as StorePreimage>::note(encoded));
assert_ok!(<Preimage as QueryPreimage>::peek(&bound));
// Cleanup.
<Preimage as StorePreimage>::unnote(&bound.hash());
let data_hash = <Test as pezframe_system::Config>::Hashing::hash(&data);
<Preimage as StorePreimage>::unnote(&data_hash.into());
// No storage changes remain. Checked by `StorageNoopGuard`.
});
}
#[test]
fn store_preimage_note_too_large_errors() {
new_test_ext().execute_with(|| {
// Works with `MAX_LENGTH`.
let len = <Preimage as StorePreimage>::MAX_LENGTH;
let data = vec![0u8; len];
assert_ok!(<Preimage as StorePreimage>::note(data.into()));
// Errors with `MAX_LENGTH+1`.
let data = vec![0u8; len + 1];
assert_err!(<Preimage as StorePreimage>::note(data.into()), DispatchError::Exhausted);
});
}
#[test]
fn store_preimage_bound_too_large_errors() {
new_test_ext().execute_with(|| {
// Using `MAX_LENGTH` number of bytes in a vector does not work
// since SCALE prepends the length.
let len = <Preimage as StorePreimage>::MAX_LENGTH;
let data: Vec<u8> = vec![0; len];
assert_err!(<Preimage as StorePreimage>::bound(data.clone()), DispatchError::Exhausted);
// Works with `MAX_LENGTH-4`.
let data: Vec<u8> = vec![0; len - 4];
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);
}
});
}
+511
View File
@@ -0,0 +1,511 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_preimage`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `4563561839a5`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// frame-omni-bencher
// v1
// benchmark
// pallet
// --extrinsic=*
// --runtime=target/production/wbuild/kitchensink-runtime/kitchensink_runtime.wasm
// --pallet=pezpallet_preimage
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/preimage/src/weights.rs
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --template=bizinikiwi/.maintain/frame-weight-template.hbs
// --no-storage-info
// --no-min-squares
// --no-median-slopes
// --genesis-builder-policy=none
// --exclude-pallets=pezpallet_xcm,pezpallet_xcm_benchmarks::fungible,pezpallet_xcm_benchmarks::generic,pezpallet_nomination_pools,pezpallet_remark,pezpallet_transaction_storage,pezpallet_election_provider_multi_block,pezpallet_election_provider_multi_block::signed,pezpallet_election_provider_multi_block::unsigned,pezpallet_election_provider_multi_block::verifier
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weight functions needed for `pezpallet_preimage`.
pub trait WeightInfo {
fn note_preimage(s: u32, ) -> Weight;
fn note_requested_preimage(s: u32, ) -> Weight;
fn note_no_deposit_preimage(s: u32, ) -> Weight;
fn unnote_preimage() -> Weight;
fn unnote_no_deposit_preimage() -> Weight;
fn request_preimage() -> Weight;
fn request_no_deposit_preimage() -> Weight;
fn request_unnoted_preimage() -> Weight;
fn request_requested_preimage() -> Weight;
fn unrequest_preimage() -> Weight;
fn unrequest_unnoted_preimage() -> Weight;
fn unrequest_multi_referenced_preimage() -> Weight;
fn ensure_updated(n: u32, ) -> Weight;
}
/// Weights for `pezpallet_preimage` using the Bizinikiwi node and recommended hardware.
pub struct BizinikiwiWeight<T>(PhantomData<T>);
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(11322), added: 13797, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, 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: `0`
// Estimated: `28584`
// Minimum execution time: 49_419_000 picoseconds.
Weight::from_parts(50_499_000, 28584)
// Standard Error: 135
.saturating_add(Weight::from_parts(13_491, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// 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(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`)
/// The range of component `s` is `[0, 4194304]`.
fn note_requested_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 11_867_000 picoseconds.
Weight::from_parts(12_175_000, 3556)
// Standard Error: 133
.saturating_add(Weight::from_parts(13_488, 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: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(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`)
/// The range of component `s` is `[0, 4194304]`.
fn note_no_deposit_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 10_925_000 picoseconds.
Weight::from_parts(11_052_000, 3556)
// Standard Error: 133
.saturating_add(Weight::from_parts(13_491, 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: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(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, 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: `130`
// Estimated: `3892`
// Minimum execution time: 48_912_000 picoseconds.
Weight::from_parts(50_830_000, 3892)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// 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(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`)
fn unnote_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 21_655_000 picoseconds.
Weight::from_parts(24_435_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `74`
// Estimated: `3556`
// Minimum execution time: 18_283_000 picoseconds.
Weight::from_parts(19_292_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 12_317_000 picoseconds.
Weight::from_parts(13_510_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 12_145_000 picoseconds.
Weight::from_parts(12_538_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_requested_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_853_000 picoseconds.
Weight::from_parts(7_180_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// 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(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`)
fn unrequest_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 19_099_000 picoseconds.
Weight::from_parts(20_209_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn unrequest_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_847_000 picoseconds.
Weight::from_parts(7_034_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn unrequest_multi_referenced_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_767_000 picoseconds.
Weight::from_parts(7_056_000, 3556)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `Preimage::StatusFor` (r:1023 w:1023)
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1023 w:1023)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(11322), added: 13797, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1023 w:1023)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `MaxEncodedLen`)
/// Storage: `Preimage::RequestStatusFor` (r:0 w:1023)
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// The range of component `n` is `[1, 1024]`.
fn ensure_updated(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + n * (227 ±0)`
// Estimated: `28584 + n * (2902 ±0)`
// Minimum execution time: 54_553_000 picoseconds.
Weight::from_parts(56_817_000, 28584)
// Standard Error: 37_902
.saturating_add(Weight::from_parts(59_397_441, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2902).saturating_mul(n.into()))
}
}
// For backwards compatibility and tests.
impl WeightInfo for () {
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(11322), added: 13797, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, 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: `0`
// Estimated: `28584`
// Minimum execution time: 49_419_000 picoseconds.
Weight::from_parts(50_499_000, 28584)
// Standard Error: 135
.saturating_add(Weight::from_parts(13_491, 0).saturating_mul(s.into()))
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
/// 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(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`)
/// The range of component `s` is `[0, 4194304]`.
fn note_requested_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 11_867_000 picoseconds.
Weight::from_parts(12_175_000, 3556)
// Standard Error: 133
.saturating_add(Weight::from_parts(13_488, 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: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(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`)
/// The range of component `s` is `[0, 4194304]`.
fn note_no_deposit_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 10_925_000 picoseconds.
Weight::from_parts(11_052_000, 3556)
// Standard Error: 133
.saturating_add(Weight::from_parts(13_491, 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: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(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, 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: `130`
// Estimated: `3892`
// Minimum execution time: 48_912_000 picoseconds.
Weight::from_parts(50_830_000, 3892)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
/// 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(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`)
fn unnote_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 21_655_000 picoseconds.
Weight::from_parts(24_435_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `74`
// Estimated: `3556`
// Minimum execution time: 18_283_000 picoseconds.
Weight::from_parts(19_292_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 12_317_000 picoseconds.
Weight::from_parts(13_510_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 12_145_000 picoseconds.
Weight::from_parts(12_538_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn request_requested_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_853_000 picoseconds.
Weight::from_parts(7_180_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// 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(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`)
fn unrequest_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `3556`
// Minimum execution time: 19_099_000 picoseconds.
Weight::from_parts(20_209_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn unrequest_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_847_000 picoseconds.
Weight::from_parts(7_034_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// 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(91), added: 2566, mode: `MaxEncodedLen`)
fn unrequest_multi_referenced_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3556`
// Minimum execution time: 6_767_000 picoseconds.
Weight::from_parts(7_056_000, 3556)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `Preimage::StatusFor` (r:1023 w:1023)
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1023 w:1023)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(11322), added: 13797, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1023 w:1023)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `MaxEncodedLen`)
/// Storage: `Preimage::RequestStatusFor` (r:0 w:1023)
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// The range of component `n` is `[1, 1024]`.
fn ensure_updated(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + n * (227 ±0)`
// Estimated: `28584 + n * (2902 ±0)`
// Minimum execution time: 54_553_000 picoseconds.
Weight::from_parts(56_817_000, 28584)
// Standard Error: 37_902
.saturating_add(Weight::from_parts(59_397_441, 0).saturating_mul(n.into()))
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into())))
.saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2902).saturating_mul(n.into()))
}
}