Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
[package]
|
||||
name = "pezpallet-presale"
|
||||
version = "1.0.0"
|
||||
description = "PEZ token presale pallet - accepts wUSDT, distributes PEZ"
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
repository.workspace = true
|
||||
documentation = "https://docs.rs/pezpallet-presale"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
|
||||
"derive",
|
||||
"max-encoded-len",
|
||||
] }
|
||||
log = { default-features = false, workspace = true }
|
||||
scale-info = { default-features = false, features = [
|
||||
"derive",
|
||||
], workspace = true }
|
||||
serde = { features = ["alloc", "derive"], workspace = true }
|
||||
|
||||
pezframe-benchmarking = { optional = true, workspace = true }
|
||||
pezframe-support = { default-features = false, workspace = true }
|
||||
pezframe-system = { default-features = false, workspace = true }
|
||||
pezsp-runtime = { default-features = false, workspace = true }
|
||||
pezsp-std = { default-features = false, workspace = true }
|
||||
|
||||
pezpallet-assets = { default-features = false, workspace = true }
|
||||
pezpallet-balances = { default-features = false, workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pezpallet-balances = { workspace = true }
|
||||
pezsp-core = { workspace = true }
|
||||
pezsp-io = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"pezpallet-assets/std",
|
||||
"pezpallet-balances?/std",
|
||||
"scale-info/std",
|
||||
"serde/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-std/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-assets/runtime-benchmarks",
|
||||
"pezpallet-balances",
|
||||
"pezpallet-balances?/runtime-benchmarks",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezpallet-assets/try-runtime",
|
||||
"pezpallet-balances?/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,459 @@
|
||||
//! Benchmarking setup for pezpallet-presale
|
||||
//!
|
||||
//! Complete benchmarks for all presale operations including:
|
||||
//! - create_presale, cancel_presale, add_to_whitelist
|
||||
//! - contribute, refund, claim_vested
|
||||
//! - finalize_presale (with O(N) contributor loop)
|
||||
//! - refund_cancelled_presale, batch_refund_failed_presale
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Presale;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::fungibles::{Create, Mutate};
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
/// Helper trait for benchmark asset setup
|
||||
pub trait BenchmarkHelper<AssetId, AccountId> {
|
||||
/// Create an asset ID from seed
|
||||
fn create_asset_id(seed: u32) -> AssetId;
|
||||
/// Setup assets for benchmarking (create and mint)
|
||||
fn setup_assets(
|
||||
payment_asset: AssetId,
|
||||
reward_asset: AssetId,
|
||||
admin: &AccountId,
|
||||
accounts: &[AccountId],
|
||||
payment_amount: u128,
|
||||
reward_amount: u128,
|
||||
);
|
||||
}
|
||||
|
||||
impl<AssetId: From<u32>, AccountId> BenchmarkHelper<AssetId, AccountId> for () {
|
||||
fn create_asset_id(seed: u32) -> AssetId {
|
||||
seed.into()
|
||||
}
|
||||
fn setup_assets(
|
||||
_payment_asset: AssetId,
|
||||
_reward_asset: AssetId,
|
||||
_admin: &AccountId,
|
||||
_accounts: &[AccountId],
|
||||
_payment_amount: u128,
|
||||
_reward_amount: u128,
|
||||
) {
|
||||
// Default implementation does nothing
|
||||
// Runtime should provide actual implementation
|
||||
}
|
||||
}
|
||||
|
||||
#[benchmarks(
|
||||
where
|
||||
T::AssetId: From<u32>,
|
||||
T::Assets: Create<T::AccountId> + Mutate<T::AccountId>,
|
||||
)]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
use pezframe_support::traits::{fungibles::Create, Get};
|
||||
|
||||
fn get_asset_id<T: Config>(seed: u32) -> T::AssetId
|
||||
where
|
||||
T::AssetId: From<u32>,
|
||||
{
|
||||
seed.into()
|
||||
}
|
||||
|
||||
/// Setup assets for presale benchmarking
|
||||
/// Creates payment and reward assets, mints to necessary accounts
|
||||
fn setup_benchmark_assets<T: Config>(
|
||||
caller: &T::AccountId,
|
||||
presale_treasury: &T::AccountId,
|
||||
) -> (T::AssetId, T::AssetId)
|
||||
where
|
||||
T::AssetId: From<u32>,
|
||||
T::Assets: Create<T::AccountId> + Mutate<T::AccountId>,
|
||||
{
|
||||
let payment_asset = get_asset_id::<T>(1);
|
||||
let reward_asset = get_asset_id::<T>(2);
|
||||
|
||||
// Create assets if they don't exist (ignore errors if already created)
|
||||
let min_balance: T::Balance = 1u128.into();
|
||||
let _ = T::Assets::create(payment_asset.clone(), caller.clone(), true, min_balance);
|
||||
let _ = T::Assets::create(reward_asset.clone(), caller.clone(), true, min_balance);
|
||||
|
||||
// Mint payment tokens to caller for contributions
|
||||
let payment_amount: T::Balance = 100_000_000u128.into();
|
||||
let _ = T::Assets::mint_into(payment_asset.clone(), caller, payment_amount);
|
||||
|
||||
// Mint payment tokens to platform accounts for fee distribution
|
||||
let _ = T::Assets::mint_into(
|
||||
payment_asset.clone(),
|
||||
&T::PlatformTreasury::get(),
|
||||
payment_amount,
|
||||
);
|
||||
let _ = T::Assets::mint_into(
|
||||
payment_asset.clone(),
|
||||
&T::StakingRewardPool::get(),
|
||||
payment_amount,
|
||||
);
|
||||
|
||||
// Mint reward tokens to presale treasury for distribution
|
||||
let reward_amount: T::Balance = 10_000_000_000u128.into();
|
||||
let _ = T::Assets::mint_into(reward_asset.clone(), presale_treasury, reward_amount);
|
||||
|
||||
(payment_asset, reward_asset)
|
||||
}
|
||||
|
||||
/// Create a presale with standard parameters
|
||||
fn create_test_presale<T: Config>(
|
||||
caller: &T::AccountId,
|
||||
payment_asset: T::AssetId,
|
||||
reward_asset: T::AssetId,
|
||||
is_whitelist: bool,
|
||||
enable_vesting: bool,
|
||||
) -> PresaleId
|
||||
where
|
||||
T::AssetId: From<u32>,
|
||||
{
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
|
||||
let _ = Presale::<T>::create_presale(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
payment_asset,
|
||||
reward_asset,
|
||||
10_000_000_000u128, // tokens_for_sale (10M)
|
||||
1000u32.into(), // duration (long enough for tests)
|
||||
is_whitelist,
|
||||
100u128, // min_contribution
|
||||
10_000_000u128, // max_contribution
|
||||
1_000_000u128, // soft_cap
|
||||
100_000_000u128, // hard_cap
|
||||
enable_vesting,
|
||||
if enable_vesting { 20u8 } else { 0u8 }, // 20% immediate if vesting
|
||||
if enable_vesting { 100u32.into() } else { 0u32.into() }, // vesting_duration
|
||||
if enable_vesting { 10u32.into() } else { 0u32.into() }, // cliff
|
||||
10u32.into(), // grace_period_blocks
|
||||
5u8, // refund_fee_percent
|
||||
2u8, // grace_refund_fee_percent
|
||||
);
|
||||
|
||||
presale_id
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn create_presale() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let payment_asset = get_asset_id::<T>(1);
|
||||
let reward_asset = get_asset_id::<T>(2);
|
||||
|
||||
#[extrinsic_call]
|
||||
create_presale(
|
||||
RawOrigin::Signed(caller),
|
||||
payment_asset,
|
||||
reward_asset,
|
||||
1_000_000u128, // tokens_for_sale
|
||||
100u32.into(), // duration
|
||||
false, // is_whitelist
|
||||
100u128, // min_contribution
|
||||
10_000u128, // max_contribution
|
||||
500_000u128, // soft_cap
|
||||
1_000_000u128, // hard_cap
|
||||
false, // enable_vesting
|
||||
0u8, // vesting_immediate_percent
|
||||
0u32.into(), // vesting_duration_blocks
|
||||
0u32.into(), // vesting_cliff_blocks
|
||||
10u32.into(), // grace_period_blocks
|
||||
5u8, // refund_fee_percent
|
||||
10u8, // grace_refund_fee_percent
|
||||
);
|
||||
|
||||
// Verify presale was created
|
||||
assert!(crate::Presales::<T>::contains_key(0));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cancel_presale() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let payment_asset = get_asset_id::<T>(1);
|
||||
let reward_asset = get_asset_id::<T>(2);
|
||||
|
||||
// Create a presale first
|
||||
let presale_id =
|
||||
create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
|
||||
#[extrinsic_call]
|
||||
cancel_presale(RawOrigin::Root, presale_id);
|
||||
|
||||
// Verify presale was cancelled
|
||||
let presale = crate::Presales::<T>::get(presale_id).unwrap();
|
||||
assert_eq!(presale.status, PresaleStatus::Cancelled);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn add_to_whitelist() {
|
||||
let owner: T::AccountId = whitelisted_caller();
|
||||
let user: T::AccountId = account("user", 0, 0);
|
||||
let payment_asset = get_asset_id::<T>(1);
|
||||
let reward_asset = get_asset_id::<T>(2);
|
||||
|
||||
// Create a whitelist presale
|
||||
let presale_id = create_test_presale::<T>(&owner, payment_asset, reward_asset, true, false);
|
||||
|
||||
#[extrinsic_call]
|
||||
add_to_whitelist(RawOrigin::Signed(owner), presale_id, user.clone());
|
||||
|
||||
// Verify user was whitelisted
|
||||
assert!(crate::WhitelistedAccounts::<T>::get(presale_id, &user));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn contribute() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
|
||||
let amount: u128 = 10_000u128;
|
||||
|
||||
#[extrinsic_call]
|
||||
contribute(RawOrigin::Signed(caller.clone()), presale_id, amount);
|
||||
|
||||
// Verify contribution was recorded
|
||||
assert!(crate::Contributions::<T>::get(presale_id, &caller).is_some());
|
||||
assert!(crate::TotalRaised::<T>::get(presale_id) > 0);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn refund() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
|
||||
// Make a contribution first
|
||||
let amount: u128 = 10_000u128;
|
||||
let _ =
|
||||
Presale::<T>::contribute(RawOrigin::Signed(caller.clone()).into(), presale_id, amount);
|
||||
|
||||
// Verify contribution exists
|
||||
assert!(crate::Contributions::<T>::get(presale_id, &caller).is_some());
|
||||
|
||||
#[extrinsic_call]
|
||||
refund(RawOrigin::Signed(caller.clone()), presale_id);
|
||||
|
||||
// Verify refund was processed
|
||||
let contribution = crate::Contributions::<T>::get(presale_id, &caller).unwrap();
|
||||
assert!(contribution.refunded);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn claim_vested() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Mint EXTRA reward tokens to presale treasury to prevent account death
|
||||
let extra_reward: T::Balance = 100_000_000_000u128.into();
|
||||
let _ = T::Assets::mint_into(reward_asset.clone(), &presale_treasury, extra_reward);
|
||||
|
||||
// Create presale WITH vesting (will get the presale_id we calculated)
|
||||
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, true);
|
||||
|
||||
// Make a contribution
|
||||
let amount: u128 = 1_000_000u128; // Large enough to reach soft cap
|
||||
let _ =
|
||||
Presale::<T>::contribute(RawOrigin::Signed(caller.clone()).into(), presale_id, amount);
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
// Finalize presale (requires root)
|
||||
let _ = Presale::<T>::finalize_presale(RawOrigin::Root.into(), presale_id);
|
||||
|
||||
// Advance past cliff period
|
||||
pezframe_system::Pallet::<T>::set_block_number(3000u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
claim_vested(RawOrigin::Signed(caller.clone()), presale_id);
|
||||
|
||||
// Verify claim was recorded
|
||||
let claimed = crate::VestingClaimed::<T>::get(presale_id, &caller);
|
||||
assert!(claimed > 0);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn refund_cancelled_presale() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ =
|
||||
create_test_presale::<T>(&caller, payment_asset.clone(), reward_asset, false, false);
|
||||
|
||||
// Make a contribution
|
||||
let amount: u128 = 10_000u128;
|
||||
let _ =
|
||||
Presale::<T>::contribute(RawOrigin::Signed(caller.clone()).into(), presale_id, amount);
|
||||
|
||||
// Mint payment tokens to presale treasury for refund
|
||||
let refund_amount: T::Balance = 100_000u128.into();
|
||||
let _ = T::Assets::mint_into(payment_asset, &presale_treasury, refund_amount);
|
||||
|
||||
// Cancel the presale
|
||||
let _ = Presale::<T>::cancel_presale(RawOrigin::Root.into(), presale_id);
|
||||
|
||||
#[extrinsic_call]
|
||||
refund_cancelled_presale(RawOrigin::Signed(caller.clone()), presale_id);
|
||||
|
||||
// Verify refund was processed
|
||||
let contribution = crate::Contributions::<T>::get(presale_id, &caller).unwrap();
|
||||
assert!(contribution.refunded);
|
||||
}
|
||||
|
||||
/// Benchmark finalize_presale with variable number of contributors
|
||||
/// This is O(N) complexity - critical for proper weight calculation
|
||||
#[benchmark]
|
||||
fn finalize_presale(n: Linear<1, 100>) {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets with enough for many contributors
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ = create_test_presale::<T>(
|
||||
&caller,
|
||||
payment_asset.clone(),
|
||||
reward_asset.clone(),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
// Add n contributors
|
||||
for i in 0..n {
|
||||
let contributor: T::AccountId = account("contributor", i, 0);
|
||||
|
||||
// Mint payment tokens to contributor
|
||||
let contribution_amount: T::Balance = 50_000u128.into();
|
||||
let _ = T::Assets::mint_into(payment_asset.clone(), &contributor, contribution_amount);
|
||||
|
||||
// Make contribution
|
||||
let _ = Presale::<T>::contribute(
|
||||
RawOrigin::Signed(contributor).into(),
|
||||
presale_id,
|
||||
10_000u128,
|
||||
);
|
||||
}
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
finalize_presale(RawOrigin::Root, presale_id);
|
||||
|
||||
// Verify presale was finalized
|
||||
let presale = crate::Presales::<T>::get(presale_id).unwrap();
|
||||
assert!(
|
||||
presale.status == PresaleStatus::Finalized || presale.status == PresaleStatus::Failed
|
||||
);
|
||||
}
|
||||
|
||||
/// Benchmark batch_refund_failed_presale with variable batch size
|
||||
/// This is also O(N) complexity
|
||||
#[benchmark]
|
||||
fn batch_refund_failed_presale(n: Linear<1, 100>) {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
// Get next presale ID before creating
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let presale_treasury = Presale::<T>::presale_account_id(presale_id);
|
||||
|
||||
// Setup assets
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale with HIGH soft cap (will fail)
|
||||
let _ = Presale::<T>::create_presale(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
payment_asset.clone(),
|
||||
reward_asset,
|
||||
10_000_000_000u128, // tokens_for_sale
|
||||
1000u32.into(), // duration
|
||||
false,
|
||||
100u128, // min_contribution
|
||||
10_000_000u128, // max_contribution
|
||||
1_000_000_000_000u128, // soft_cap (very high - will fail)
|
||||
2_000_000_000_000u128, // hard_cap
|
||||
false,
|
||||
0u8,
|
||||
0u32.into(),
|
||||
0u32.into(),
|
||||
10u32.into(),
|
||||
5u8,
|
||||
2u8,
|
||||
);
|
||||
|
||||
// Add n contributors (small amounts that won't reach soft cap)
|
||||
for i in 0..n {
|
||||
let contributor: T::AccountId = account("contributor", i, 0);
|
||||
|
||||
// Mint payment tokens to contributor
|
||||
let contribution_amount: T::Balance = 50_000u128.into();
|
||||
let _ = T::Assets::mint_into(payment_asset.clone(), &contributor, contribution_amount);
|
||||
|
||||
// Make small contribution
|
||||
let _ = Presale::<T>::contribute(
|
||||
RawOrigin::Signed(contributor).into(),
|
||||
presale_id,
|
||||
1_000u128,
|
||||
);
|
||||
}
|
||||
|
||||
// Mint payment tokens to presale treasury for refunds
|
||||
let refund_pool: T::Balance = (n as u128 * 10_000u128).into();
|
||||
let _ = T::Assets::mint_into(payment_asset.clone(), &presale_treasury, refund_pool);
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
// Finalize presale (will mark as Failed due to soft cap not reached)
|
||||
let _ = Presale::<T>::finalize_presale(RawOrigin::Root.into(), presale_id);
|
||||
|
||||
// Verify presale failed
|
||||
let presale = crate::Presales::<T>::get(presale_id).unwrap();
|
||||
assert_eq!(presale.status, PresaleStatus::Failed);
|
||||
|
||||
#[extrinsic_call]
|
||||
batch_refund_failed_presale(RawOrigin::Signed(caller), presale_id, 0, n);
|
||||
|
||||
// Verify refunds were processed
|
||||
let first_contributor: T::AccountId = account("contributor", 0, 0);
|
||||
let contribution = crate::Contributions::<T>::get(presale_id, &first_contributor);
|
||||
if let Some(c) = contribution {
|
||||
assert!(c.refunded);
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Presale, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,195 @@
|
||||
use crate as pezpallet_presale;
|
||||
use pezframe_support::{
|
||||
parameter_types,
|
||||
traits::{ConstU128, ConstU16, ConstU32, ConstU64},
|
||||
PalletId,
|
||||
};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
Balances: pezpallet_balances,
|
||||
Assets: pezpallet_assets,
|
||||
Presale: pezpallet_presale,
|
||||
}
|
||||
);
|
||||
|
||||
impl pezframe_system::Config for Test {
|
||||
type BaseCallFilter = pezframe_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Nonce = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = pezpallet_balances::AccountData<u128>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ConstU16<42>;
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = ConstU32<16>;
|
||||
type RuntimeTask = ();
|
||||
type ExtensionsWeightInfo = ();
|
||||
type SingleBlockMigrations = ();
|
||||
type MultiBlockMigrator = ();
|
||||
type PreInherents = ();
|
||||
type PostInherents = ();
|
||||
type PostTransactions = ();
|
||||
}
|
||||
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type MaxLocks = ();
|
||||
type MaxReserves = ();
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
type Balance = u128;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ConstU128<1>;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
type FreezeIdentifier = ();
|
||||
type MaxFreezes = ();
|
||||
type RuntimeHoldReason = ();
|
||||
type RuntimeFreezeReason = ();
|
||||
type DoneSlashHandler = ();
|
||||
}
|
||||
|
||||
impl pezpallet_assets::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = u128;
|
||||
type AssetId = u32;
|
||||
type AssetIdParameter = u32;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin =
|
||||
pezframe_support::traits::AsEnsureOriginWithArg<pezframe_system::EnsureSigned<u64>>;
|
||||
type ForceOrigin = pezframe_system::EnsureRoot<u64>;
|
||||
type AssetDeposit = ConstU128<1>;
|
||||
type AssetAccountDeposit = ConstU128<0>; // No deposit required for test environment
|
||||
type MetadataDepositBase = ConstU128<1>;
|
||||
type MetadataDepositPerByte = ConstU128<1>;
|
||||
type ApprovalDeposit = ConstU128<1>;
|
||||
type StringLimit = ConstU32<50>;
|
||||
type Freezer = ();
|
||||
type Extra = ();
|
||||
type WeightInfo = ();
|
||||
type RemoveItemsLimit = ConstU32<1000>;
|
||||
type CallbackHandle = ();
|
||||
type Holder = ();
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const PresalePalletId: PalletId = PalletId(*b"py/prsal");
|
||||
pub const PlatformFeePercent: u8 = 2;
|
||||
pub const MaxContributors: u32 = 10000;
|
||||
pub const MaxBonusTiers: u32 = 5;
|
||||
pub const MaxWhitelistedAccounts: u32 = 10000;
|
||||
pub PlatformTreasuryAccount: u64 = 999;
|
||||
pub StakingRewardPoolAccount: u64 = 998;
|
||||
}
|
||||
|
||||
impl pezpallet_presale::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AssetId = u32;
|
||||
type Balance = u128;
|
||||
type Assets = Assets;
|
||||
type PalletId = PresalePalletId;
|
||||
type PlatformTreasury = PlatformTreasuryAccount;
|
||||
type StakingRewardPool = StakingRewardPoolAccount;
|
||||
type PlatformFeePercent = PlatformFeePercent;
|
||||
type MaxContributors = MaxContributors;
|
||||
type MaxBonusTiers = MaxBonusTiers;
|
||||
type MaxWhitelistedAccounts = MaxWhitelistedAccounts;
|
||||
type CreatePresaleOrigin = pezframe_system::EnsureSigned<u64>;
|
||||
type EmergencyOrigin = pezframe_system::EnsureRoot<u64>;
|
||||
type PresaleWeightInfo = crate::weights::BizinikiwiWeight<Test>;
|
||||
}
|
||||
|
||||
// Build genesis storage according to the mock runtime.
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
|
||||
pezpallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![
|
||||
(1, 1_000_000_000_000_000), // Alice
|
||||
(2, 1_000_000_000_000_000), // Bob
|
||||
(3, 1_000_000_000_000_000), // Charlie
|
||||
(999, 1_000_000_000_000_000), // Platform Treasury
|
||||
(998, 1_000_000_000_000_000), // Staking Pool
|
||||
],
|
||||
dev_accounts: None,
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
let mut ext = pezsp_io::TestExternalities::new(t);
|
||||
ext.execute_with(|| System::set_block_number(1));
|
||||
ext
|
||||
}
|
||||
|
||||
// Helper to create assets
|
||||
pub fn create_assets() {
|
||||
use pezframe_support::assert_ok;
|
||||
|
||||
// Create PEZ asset (ID: 1)
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
1u32,
|
||||
1, // Alice as admin
|
||||
true,
|
||||
1
|
||||
));
|
||||
|
||||
// Create wUSDT asset (ID: 2)
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
2u32,
|
||||
1, // Alice as admin
|
||||
true,
|
||||
1
|
||||
));
|
||||
}
|
||||
|
||||
// Helper to mint assets to accounts
|
||||
pub fn mint_assets(asset_id: u32, account: u64, amount: u128) {
|
||||
use pezframe_support::assert_ok;
|
||||
|
||||
assert_ok!(Assets::mint(RuntimeOrigin::signed(1), asset_id.into(), account, amount));
|
||||
}
|
||||
|
||||
// Helper to get presale sub-account treasury for a specific presale ID
|
||||
pub fn presale_treasury(presale_id: u32) -> u64 {
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
|
||||
// Create a unique account ID for each presale by hashing pezpallet_id + presale_id
|
||||
// This matches the logic in pezpallet_presale::Pallet::presale_account_id
|
||||
let pezpallet_id = PresalePalletId::get();
|
||||
let mut buf = Vec::new();
|
||||
buf.extend_from_slice(&pezpallet_id.0[..]);
|
||||
buf.extend_from_slice(&presale_id.to_le_bytes());
|
||||
let hash = blake2_256(&buf);
|
||||
|
||||
// Convert hash to u64 (since Test uses u64 as AccountId)
|
||||
// Take first 8 bytes and convert to u64
|
||||
u64::from_le_bytes([hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7]])
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,466 @@
|
||||
// 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_presale`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2025-12-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `MamostePC`, CPU: `11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// --runtime
|
||||
// target/release/wbuild/asset-hub-pezkuwichain-runtime/asset_hub_pezkuwichain_runtime.compact.compressed.wasm
|
||||
// --pallets
|
||||
// pezpallet_presale
|
||||
// -e
|
||||
// all
|
||||
// --steps
|
||||
// 50
|
||||
// --repeat
|
||||
// 20
|
||||
// --output
|
||||
// pezcumulus/teyrchains/pezpallets/presale/src/weights.rs
|
||||
// --template
|
||||
// bizinikiwi/.maintain/frame-weight-template.hbs
|
||||
|
||||
#![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_presale`.
|
||||
pub trait WeightInfo {
|
||||
fn create_presale() -> Weight;
|
||||
fn cancel_presale() -> Weight;
|
||||
fn add_to_whitelist() -> Weight;
|
||||
fn contribute() -> Weight;
|
||||
fn refund() -> Weight;
|
||||
fn claim_vested() -> Weight;
|
||||
fn refund_cancelled_presale() -> Weight;
|
||||
fn finalize_presale(n: u32, ) -> Weight;
|
||||
fn batch_refund_failed_presale(n: u32, ) -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_presale` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `Presale::NextPresaleId` (r:1 w:1)
|
||||
/// Proof: `Presale::NextPresaleId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Presales` (r:0 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
fn create_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `147`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 9_638_000 picoseconds.
|
||||
Weight::from_parts(10_003_000, 1489)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
fn cancel_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `356`
|
||||
// Estimated: `3717`
|
||||
// Minimum execution time: 12_202_000 picoseconds.
|
||||
Weight::from_parts(12_492_000, 3717)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::WhitelistedAccounts` (r:0 w:1)
|
||||
/// Proof: `Presale::WhitelistedAccounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
|
||||
fn add_to_whitelist() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `356`
|
||||
// Estimated: `3717`
|
||||
// Minimum execution time: 12_973_000 picoseconds.
|
||||
Weight::from_parts(14_077_000, 3717)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:4 w:4)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalPlatformVolume` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalPlatformVolume` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalPlatformFees` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalPlatformFees` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
|
||||
fn contribute() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1169`
|
||||
// Estimated: `323487`
|
||||
// Minimum execution time: 160_665_000 picoseconds.
|
||||
Weight::from_parts(165_629_000, 323487)
|
||||
.saturating_add(T::DbWeight::get().reads(13_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(11_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:4 w:4)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::Freezes` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::Freezes` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
fn refund() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1531`
|
||||
// Estimated: `11426`
|
||||
// Minimum execution time: 169_420_000 picoseconds.
|
||||
Weight::from_parts(173_774_000, 11426)
|
||||
.saturating_add(T::DbWeight::get().reads(11_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(10_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:0)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::VestingClaimed` (r:1 w:1)
|
||||
/// Proof: `Presale::VestingClaimed` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:2 w:2)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
fn claim_vested() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1392`
|
||||
// Estimated: `6208`
|
||||
// Minimum execution time: 72_526_000 picoseconds.
|
||||
Weight::from_parts(74_529_000, 6208)
|
||||
.saturating_add(T::DbWeight::get().reads(8_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:2 w:2)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
fn refund_cancelled_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1370`
|
||||
// Estimated: `323487`
|
||||
// Minimum execution time: 66_454_000 picoseconds.
|
||||
Weight::from_parts(69_615_000, 323487)
|
||||
.saturating_add(T::DbWeight::get().reads(7_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:0)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:100 w:0)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:101 w:101)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:101 w:101)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::Freezes` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::Freezes` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::SuccessfulPresales` (r:1 w:1)
|
||||
/// Proof: `Presale::SuccessfulPresales` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 100]`.
|
||||
fn finalize_presale(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `525`
|
||||
// Estimated: `3717 + n * (3235 ±0)`
|
||||
// Minimum execution time: 17_663_000 picoseconds.
|
||||
Weight::from_parts(18_454_000, 3717)
|
||||
// Standard Error: 463_975
|
||||
.saturating_add(Weight::from_parts(2_728_899, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
.saturating_add(Weight::from_parts(0, 3235).saturating_mul(n.into()))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:100 w:100)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:101 w:101)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 100]`.
|
||||
fn batch_refund_failed_presale(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1244 + n * (198 ±0)`
|
||||
// Estimated: `323487 + n * (2609 ±0)`
|
||||
// Minimum execution time: 70_612_000 picoseconds.
|
||||
Weight::from_parts(17_304_947, 323487)
|
||||
// Standard Error: 88_572
|
||||
.saturating_add(Weight::from_parts(42_218_217, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2609).saturating_mul(n.into()))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `Presale::NextPresaleId` (r:1 w:1)
|
||||
/// Proof: `Presale::NextPresaleId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Presales` (r:0 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
fn create_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `147`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 9_638_000 picoseconds.
|
||||
Weight::from_parts(10_003_000, 1489)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
fn cancel_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `356`
|
||||
// Estimated: `3717`
|
||||
// Minimum execution time: 12_202_000 picoseconds.
|
||||
Weight::from_parts(12_492_000, 3717)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::WhitelistedAccounts` (r:0 w:1)
|
||||
/// Proof: `Presale::WhitelistedAccounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
|
||||
fn add_to_whitelist() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `356`
|
||||
// Estimated: `3717`
|
||||
// Minimum execution time: 12_973_000 picoseconds.
|
||||
Weight::from_parts(14_077_000, 3717)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:4 w:4)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalPlatformVolume` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalPlatformVolume` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalPlatformFees` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalPlatformFees` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
|
||||
fn contribute() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1169`
|
||||
// Estimated: `323487`
|
||||
// Minimum execution time: 160_665_000 picoseconds.
|
||||
Weight::from_parts(165_629_000, 323487)
|
||||
.saturating_add(RocksDbWeight::get().reads(13_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(11_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:4 w:4)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::Freezes` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::Freezes` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:1)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
fn refund() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1531`
|
||||
// Estimated: `11426`
|
||||
// Minimum execution time: 169_420_000 picoseconds.
|
||||
Weight::from_parts(173_774_000, 11426)
|
||||
.saturating_add(RocksDbWeight::get().reads(11_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(10_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:0)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::VestingClaimed` (r:1 w:1)
|
||||
/// Proof: `Presale::VestingClaimed` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:2 w:2)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
fn claim_vested() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1392`
|
||||
// Estimated: `6208`
|
||||
// Minimum execution time: 72_526_000 picoseconds.
|
||||
Weight::from_parts(74_529_000, 6208)
|
||||
.saturating_add(RocksDbWeight::get().reads(8_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:1 w:1)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:2 w:2)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
fn refund_cancelled_presale() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1370`
|
||||
// Estimated: `323487`
|
||||
// Minimum execution time: 66_454_000 picoseconds.
|
||||
Weight::from_parts(69_615_000, 323487)
|
||||
.saturating_add(RocksDbWeight::get().reads(7_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:1)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::TotalRaised` (r:1 w:0)
|
||||
/// Proof: `Presale::TotalRaised` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:100 w:0)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:101 w:101)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:101 w:101)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::Freezes` (r:1 w:1)
|
||||
/// Proof: `AssetsFreezer::Freezes` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::SuccessfulPresales` (r:1 w:1)
|
||||
/// Proof: `Presale::SuccessfulPresales` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 100]`.
|
||||
fn finalize_presale(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `525`
|
||||
// Estimated: `3717 + n * (3235 ±0)`
|
||||
// Minimum execution time: 17_663_000 picoseconds.
|
||||
Weight::from_parts(18_454_000, 3717)
|
||||
// Standard Error: 463_975
|
||||
.saturating_add(Weight::from_parts(2_728_899, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
.saturating_add(Weight::from_parts(0, 3235).saturating_mul(n.into()))
|
||||
}
|
||||
/// Storage: `Presale::Presales` (r:1 w:0)
|
||||
/// Proof: `Presale::Presales` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributors` (r:1 w:0)
|
||||
/// Proof: `Presale::Contributors` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Presale::Contributions` (r:100 w:100)
|
||||
/// Proof: `Presale::Contributions` (`max_values`: None, `max_size`: Some(110), added: 2585, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Asset` (r:1 w:1)
|
||||
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Assets::Account` (r:101 w:101)
|
||||
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0)
|
||||
/// Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 100]`.
|
||||
fn batch_refund_failed_presale(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1244 + n * (198 ±0)`
|
||||
// Estimated: `323487 + n * (2609 ±0)`
|
||||
// Minimum execution time: 70_612_000 picoseconds.
|
||||
Weight::from_parts(17_304_947, 323487)
|
||||
// Standard Error: 88_572
|
||||
.saturating_add(Weight::from_parts(42_218_217, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2609).saturating_mul(n.into()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user