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

CU-1tf7kpr - Picasso v0 runtime - part 1 #478

Merged
merged 8 commits into from
Jan 12, 2022
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integration-tests/simnode/src/chain/picasso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl substrate_simnode::ChainInfo for ChainInfo {
),
system::CheckWeight::<Self::Runtime>::new(),
transaction_payment::ChargeTransactionPayment::<Self::Runtime>::from(0),
crowdloan_rewards::PrevalidateAssociation::<Self::Runtime>::new(),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/dali/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ parameter_types! {
}

impl vesting::Config for Runtime {
type Currency = Tokens;
type Currency = Assets;
type Event = Event;
type MaxVestingSchedules = MaxVestingSchedule;
type MinVestedTransfer = MinVestedTransfer;
Expand All @@ -833,7 +833,7 @@ impl pallet_bonded_finance::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>;
type BondOfferId = u64;
type Convert = sp_runtime::traits::ConvertInto;
type Currency = Tokens;
type Currency = Assets;
type Event = Event;
type MinReward = MinReward;
type NativeCurrency = Balances;
Expand Down
6 changes: 6 additions & 0 deletions runtime/picasso/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ common = { path = "../common", default-features = false }
primitives = { path = "../primitives", default-features = false }
composable-traits = { path = "../../frame/composable-traits", default-features = false }
call-filter = { package = "pallet-call-filter", path = "../../frame/call-filter", default-features = false }
currency-factory = { package = "pallet-currency-factory", path = "../../frame/currency-factory", default-features = false }
governance-registry = { package = "pallet-governance-registry", path = "../../frame/governance-registry", default-features = false }
assets = { package = "pallet-assets", path = '../../frame/assets', default-features = false }
crowdloan-rewards = { package = "pallet-crowdloan-rewards", path = '../../frame/crowdloan-rewards', default-features = false }
vesting = { package = "pallet-vesting", path = "../../frame/vesting", default-features = false }
bonded-finance = { package = "pallet-bonded-finance", path = "../../frame/bonded-finance", default-features = false }
Comment on lines +75 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing std features as well as runtime-benchmark features


# Used for the node template's RPCs
system-rpc-runtime-api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false }
Expand Down
96 changes: 95 additions & 1 deletion runtime/picasso/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_version: 2000,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
transaction_version: 2,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down Expand Up @@ -385,6 +385,7 @@ where
system::CheckNonce::<Runtime>::from(nonce),
system::CheckWeight::<Runtime>::new(),
transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
crowdloan_rewards::PrevalidateAssociation::<Runtime>::new(),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|_e| {
Expand Down Expand Up @@ -673,6 +674,90 @@ impl democracy::Config for Runtime {
type WeightInfo = weights::democracy::WeightInfo<Runtime>;
}

parameter_types! {
pub const DynamicCurrencyIdInitial: CurrencyId = CurrencyId::LOCAL_LP_TOKEN_START;
}

impl currency_factory::Config for Runtime {
type Event = Event;
type DynamicCurrencyId = CurrencyId;
type DynamicCurrencyIdInitial = DynamicCurrencyIdInitial;
}

impl governance_registry::Config for Runtime {
type Event = Event;
type AssetId = CurrencyId;
type WeightInfo = ();
}

parameter_types! {
pub NativeAssetId: CurrencyId = CurrencyId::PICA;
}

impl assets::Config for Runtime {
type NativeAssetId = NativeAssetId;
type GenerateCurrencyId = Factory;
type AssetId = CurrencyId;
type Balance = Balance;
type NativeCurrency = Balances;
type MultiCurrency = Tokens;
type WeightInfo = ();
type AdminOrigin = EnsureRootOrHalfCouncil;
type GovernanceRegistry = GovernanceRegistry;
}

parameter_types! {
pub const InitialPayment: Perbill = Perbill::from_percent(25);
pub const VestingStep: BlockNumber = 7 * DAYS;
pub const Prefix: &'static [u8] = b"picasso-";
}

impl crowdloan_rewards::Config for Runtime {
type Event = Event;
type Balance = Balance;
type Currency = Assets;
type AdminOrigin = EnsureRootOrHalfCouncil;
type Convert = sp_runtime::traits::ConvertInto;
type RelayChainAccountId = [u8; 32];
type InitialPayment = InitialPayment;
type VestingStep = VestingStep;
type Prefix = Prefix;
type WeightInfo = weights::crowdloan_rewards::WeightInfo<Runtime>;
}

parameter_types! {
pub const MaxVestingSchedule: u32 = 128;
pub MinVestedTransfer: u64 = CurrencyId::PICA.milli::<u64>();
}

impl vesting::Config for Runtime {
type Currency = Assets;
type Event = Event;
type MaxVestingSchedules = MaxVestingSchedule;
type MinVestedTransfer = MinVestedTransfer;
type VestedTransferOrigin = system::EnsureSigned<AccountId>;
type WeightInfo = ();
}

parameter_types! {
pub const BondedFinanceId: PalletId = PalletId(*b"bondedfi");
pub MinReward: Balance = 10 * CurrencyId::PICA.unit::<Balance>();
pub Stake: Balance = 10 * CurrencyId::PICA.unit::<Balance>();
}

impl bonded_finance::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>;
type BondOfferId = u64;
type Convert = sp_runtime::traits::ConvertInto;
type Currency = Assets;
type Event = Event;
type MinReward = MinReward;
type NativeCurrency = Balances;
type PalletId = BondedFinanceId;
type Stake = Stake;
type Vesting = Vesting;
}

/// The calls we permit to be executed by extrinsics
pub struct BaseCallFilter;

Expand Down Expand Up @@ -728,6 +813,12 @@ construct_runtime!(
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 43,

Tokens: orml_tokens::{Pallet, Call, Storage, Event<T>} = 52,
Factory: currency_factory::{Pallet, Storage, Event<T>} = 53,
GovernanceRegistry: governance_registry::{Pallet, Call, Storage, Event<T>} = 54,
Assets: assets::{Pallet, Call, Storage} = 55,
CrowdloanRewards: crowdloan_rewards::{Pallet, Call, Storage, Event<T>} = 56,
Vesting: vesting::{Call, Event<T>, Pallet, Storage} = 57,
Comment on lines +816 to +820
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hussein-aitlahcen this pr doesn't add these pallets to the benchmark section

BondedFinance: bonded_finance::{Call, Event<T>, Pallet, Storage} = 58,
}
);

Expand All @@ -745,6 +836,7 @@ pub type SignedExtra = (
system::CheckNonce<Runtime>,
system::CheckWeight<Runtime>,
transaction_payment::ChargeTransactionPayment<Runtime>,
crowdloan_rewards::PrevalidateAssociation<Runtime>,
hussein-aitlahcen marked this conversation as resolved.
Show resolved Hide resolved
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down Expand Up @@ -885,6 +977,7 @@ impl_runtime_apis! {
list_benchmark!(list, extra, utility, Utility);
list_benchmark!(list, extra, identity, Identity);
list_benchmark!(list, extra, multisig, Multisig);
list_benchmark!(list, extra, crowdloan_rewards, CrowdloanRewards);

let storage_info = AllPalletsWithSystem::storage_info();

Expand Down Expand Up @@ -932,6 +1025,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, utility, Utility);
add_benchmark!(params, batches, identity, Identity);
add_benchmark!(params, batches, multisig, Multisig);
add_benchmark!(params, batches, crowdloan_rewards, CrowdloanRewards);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down
76 changes: 76 additions & 0 deletions runtime/picasso/src/weights/crowdloan_rewards.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

//! Autogenerated weights for `crowdloan_rewards`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-12-17, STEPS: `10`, REPEAT: 5, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("picasso-dev"), DB CACHE: 128

// Executed Command:
// ./target/release/composable
// benchmark
// --chain=picasso-dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=crowdloan-rewards
// --extrinsic=*
// --steps=10
// --repeat=5
// --raw
// --output=runtime/picasso/src/weights/crowdloan_rewards.rs

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

use support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `crowdloan_rewards`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> crowdloan_rewards::weights::WeightInfo for WeightInfo<T> {
// Storage: CrowdloanRewards VestingBlockStart (r:1 w:0)
// Storage: CrowdloanRewards Rewards (r:1001 w:1000)
// Storage: CrowdloanRewards TotalContributors (r:0 w:1)
// Storage: CrowdloanRewards TotalRewards (r:0 w:1)
fn populate(x: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 109_000
.saturating_add((6_792_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(x as Weight)))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(x as Weight)))
}
// Storage: CrowdloanRewards VestingBlockStart (r:1 w:1)
fn initialize(x: u32, ) -> Weight {
(33_355_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: CrowdloanRewards VestingBlockStart (r:1 w:0)
// Storage: CrowdloanRewards Rewards (r:1 w:1)
// Storage: System Account (r:1 w:1)
// Storage: CrowdloanRewards ClaimedRewards (r:1 w:1)
// Storage: CrowdloanRewards Associations (r:0 w:1)
fn associate(x: u32, ) -> Weight {
(169_323_000 as Weight)
// Standard Error: 1_000
.saturating_add((8_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: CrowdloanRewards Associations (r:1 w:0)
// Storage: CrowdloanRewards VestingBlockStart (r:1 w:0)
// Storage: CrowdloanRewards Rewards (r:1 w:1)
// Storage: System Account (r:1 w:1)
// Storage: CrowdloanRewards ClaimedRewards (r:1 w:1)
fn claim(x: u32, ) -> Weight {
(94_034_000 as Weight)
// Standard Error: 1_000
.saturating_add((31_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
}
1 change: 1 addition & 0 deletions runtime/picasso/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub mod balances;
pub mod collator_selection;
pub mod collective;
pub mod crowdloan_rewards;
pub mod democracy;
pub mod frame_system;
pub mod identity;
Expand Down