Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-pls ignore- #445

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions benchmarked-extrinsics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// Polimec Blockchain – https://www.polimec.org/
// Copyright (C) Polimec 2022. All rights reserved.

// The Polimec Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The Polimec Blockchain is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// If you feel like getting in touch with us, you can do so at [email protected]


//! Autogenerated weights for `pallet_funding`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 39.0.0
//! DATE: 2025-02-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `Mac.home`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-paseo-local")`, DB CACHE: `1024`

// Executed Command:
// target/production/polimec-node
// benchmark
// pallet
// --chain=polimec-paseo-local
// --steps=50
// --repeat=20
// --pallet=pallet-funding
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=bid
// --wasm-execution=compiled
// --heap-pages=4096
// --output=benchmarked-extrinsics.rs
// --template=./.maintain/frame-weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;

/// Weight functions needed for `pallet_funding`.
pub trait WeightInfo {
fn bid(x: u32, ) -> Weight;
}

/// Weights for `pallet_funding` using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: `Timestamp::Now` (r:1 w:0)
/// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(437), added: 2912, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsDetails` (r:1 w:0)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`)
/// Storage: `Funding::Buckets` (r:1 w:1)
/// Proof: `Funding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`)
/// Storage: `Funding::NextBidId` (r:1 w:1)
/// Proof: `Funding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Funding::BidBucketBounds` (r:10 w:10)
/// Proof: `Funding::BidBucketBounds` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `Funding::AuctionBoughtUSD` (r:1 w:1)
/// Proof: `Funding::AuctionBoughtUSD` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`)
/// Storage: `Oracle::Values` (r:2 w:0)
/// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(634), added: 3109, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Metadata` (r:1 w:0)
/// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`)
/// Storage: `Funding::Evaluations` (r:1 w:0)
/// Proof: `Funding::Evaluations` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(175), added: 2650, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `Funding::CTAmountOversubscribed` (r:1 w:1)
/// Proof: `Funding::CTAmountOversubscribed` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:0 w:10)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(309), added: 2784, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 10]`.
fn bid(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `2890`
// Estimated: `7404 + x * (2535 ±0)`
// Minimum execution time: 184_000_000 picoseconds.
Weight::from_parts(139_444_380, 7404)
// Standard Error: 76_200
.saturating_add(Weight::from_parts(59_216_258, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(15_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(8_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2535).saturating_mul(x.into()))
}
}

// For backwards compatibility and tests.
impl WeightInfo for () {
/// Storage: `Timestamp::Now` (r:1 w:0)
/// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(437), added: 2912, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsDetails` (r:1 w:0)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`)
/// Storage: `Funding::Buckets` (r:1 w:1)
/// Proof: `Funding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`)
/// Storage: `Funding::NextBidId` (r:1 w:1)
/// Proof: `Funding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Funding::BidBucketBounds` (r:10 w:10)
/// Proof: `Funding::BidBucketBounds` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `Funding::AuctionBoughtUSD` (r:1 w:1)
/// Proof: `Funding::AuctionBoughtUSD` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`)
/// Storage: `Oracle::Values` (r:2 w:0)
/// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(634), added: 3109, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Metadata` (r:1 w:0)
/// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`)
/// Storage: `Funding::Evaluations` (r:1 w:0)
/// Proof: `Funding::Evaluations` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(175), added: 2650, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `Funding::CTAmountOversubscribed` (r:1 w:1)
/// Proof: `Funding::CTAmountOversubscribed` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:0 w:10)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(309), added: 2784, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 10]`.
fn bid(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `2890`
// Estimated: `7404 + x * (2535 ±0)`
// Minimum execution time: 184_000_000 picoseconds.
Weight::from_parts(139_444_380, 7404)
// Standard Error: 76_200
.saturating_add(Weight::from_parts(59_216_258, 0).saturating_mul(x.into()))
.saturating_add(RocksDbWeight::get().reads(15_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(RocksDbWeight::get().writes(8_u64))
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2535).saturating_mul(x.into()))
}
}
25 changes: 11 additions & 14 deletions integration-tests/src/tests/ct_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn get_migrations_for_participants(
for participant in participants {
let (status, migrations) =
pallet_funding::UserMigrations::<PolimecRuntime>::get((project_id, participant.clone())).unwrap();
user_migrations.insert(participant, (status, Migrations::from(migrations.into())));
user_migrations.insert(participant, (status, Migrations::from(migrations.to_vec())));
}
});
user_migrations
Expand Down Expand Up @@ -159,8 +159,8 @@ fn create_settled_project() -> (ProjectId, Vec<AccountId>) {
let mut inst = IntegrationInstantiator::new(None);

let project_metadata = default_project_metadata(ISSUER.into());
let evaluations = inst.generate_successful_evaluations(project_metadata.clone(), 5);
let bids = inst.generate_bids_from_total_ct_percent(project_metadata.clone(), 95, 8);
let evaluations = inst.generate_successful_evaluations(project_metadata.clone(), 10);
let bids = inst.generate_bids_from_total_ct_percent(project_metadata.clone(), 95, 30);
PolimecNet::execute_with(|| {
let project_id = inst.create_finished_project(project_metadata, ISSUER.into(), None, evaluations, bids);
assert_eq!(
Expand All @@ -171,10 +171,6 @@ fn create_settled_project() -> (ProjectId, Vec<AccountId>) {
pallet_funding::Evaluations::<PolimecRuntime>::iter_prefix_values((project_id,))
.map(|eval| eval.evaluator)
.chain(pallet_funding::Bids::<PolimecRuntime>::iter_prefix_values((project_id,)).map(|bid| bid.bidder))
.chain(
pallet_funding::Contributions::<PolimecRuntime>::iter_prefix_values((project_id,))
.map(|contribution| contribution.contributor),
)
.collect();
participants.sort();
participants.dedup();
Expand Down Expand Up @@ -211,8 +207,8 @@ fn create_project_with_unsettled_participation(participation_type: Participation
let mut inst = IntegrationInstantiator::new(None);
PolimecNet::execute_with(|| {
let project_metadata = default_project_metadata(ISSUER.into());
let evaluations = inst.generate_successful_evaluations(project_metadata.clone(), 5);
let bids = inst.generate_bids_from_total_ct_percent(project_metadata.clone(), 95, 8);
let evaluations = inst.generate_successful_evaluations(project_metadata.clone(), 10);
let bids = inst.generate_bids_from_total_ct_percent(project_metadata.clone(), 95, 30);
let project_id = inst.create_finished_project(project_metadata, ISSUER.into(), None, evaluations, bids);

assert_eq!(
Expand All @@ -221,12 +217,12 @@ fn create_project_with_unsettled_participation(participation_type: Participation
);
let evaluations_to_settle =
pallet_funding::Evaluations::<PolimecRuntime>::iter_prefix_values((project_id,)).collect_vec();
let bids_to_settle = pallet_funding::Bids::<PolimecRuntime>::iter_prefix_values((project_id,)).collect_vec();
let bids_to_settle = inst.get_bids(project_id);

let mut participants: Vec<AccountId> = evaluations_to_settle
.iter()
.map(|eval| eval.evaluator.clone())
.chain(bids_to_settle.iter().map(|bid| bid.bidder.clone()))
.chain(bids_to_settle.iter().map(|x| x.bidder.clone()))
.collect();
participants.sort();
participants.dedup();
Expand All @@ -242,9 +238,10 @@ fn create_project_with_unsettled_participation(participation_type: Participation
.unwrap()
}

let start = if participation_type == ParticipationType::Bid { 1 } else { 0 };
for bid in bids_to_settle[start..].iter() {
PolimecFunding::settle_bid(RuntimeOrigin::signed(alice()), project_id, bid.bidder.clone(), bid.id).unwrap()
let proposed_start = if participation_type == ParticipationType::Bid { 1 } else { 0 };
let end = if proposed_start == 1 { bids_to_settle.len() - 1 } else { bids_to_settle.len() };
for bid in bids_to_settle[..end].iter() {
PolimecFunding::settle_bid(RuntimeOrigin::signed(alice()), project_id, bid.id).unwrap()
}

let evaluations =
Expand Down
23 changes: 11 additions & 12 deletions integration-tests/src/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ fn participate_with_checks(
mut inst: IntegrationInstantiator,
project_id: ProjectId,
participation_type: ParticipationType,
participation_id: u32,
user: [u8; 32],
mode: ParticipationMode,
investor_type: InvestorType,
Expand Down Expand Up @@ -311,9 +310,6 @@ fn participate_with_checks(
if participation_type == ParticipationType::Bid {
PolimecFunding::bid(PolimecOrigin::signed(user.clone()), user_jwt, project_id, ct_amount, mode, funding_asset)
.unwrap();
let stored_bid = Bids::<PolimecRuntime>::get((project_id, user.clone(), participation_id));
// dbg!(&stored_bid);
assert!(stored_bid.is_some());
}

let post_participation_free_plmc = PolimecBalances::free_balance(user.clone());
Expand Down Expand Up @@ -399,7 +395,6 @@ fn e2e_test() {
inst,
project_id,
ParticipationType::Bid,
bid_id,
user,
mode,
investor_type,
Expand All @@ -425,13 +420,8 @@ fn e2e_test() {
let prev_treasury_usdt_balance = PolimecForeignAssets::balance(USDT.id(), otm_project_sub_account.clone());
let prev_escrow_usdt_balance = PolimecForeignAssets::balance(USDT.id(), funding_escrow_account.clone());

PolimecFunding::settle_bid(
PolimecOrigin::signed(rejected_bidder.clone()),
project_id,
rejected_bidder.clone(),
rejected_bid_id,
)
.unwrap();
PolimecFunding::settle_bid(PolimecOrigin::signed(rejected_bidder.clone()), project_id, rejected_bid_id)
.unwrap();

let post_bid_free_plmc = PolimecBalances::free_balance(rejected_bidder.clone());
let post_bid_reserved_plmc = PolimecBalances::reserved_balance(rejected_bidder.clone());
Expand Down Expand Up @@ -663,3 +653,12 @@ fn e2e_test() {
}
});
}

#[test]
fn sandbox() {
let bid_weight = <PolimecRuntime as pallet_funding::Config>::WeightInfo::bid(1);
let process_weight = <PolimecRuntime as pallet_funding::Config>::WeightInfo::process_next_oversubscribed_bid();

dbg!(bid_weight);
dbg!(process_weight);
}
Loading