diff --git a/INV4/pallet-inv4/Cargo.toml b/INV4/pallet-inv4/Cargo.toml index 7ca2b4b9..1be254b1 100644 --- a/INV4/pallet-inv4/Cargo.toml +++ b/INV4/pallet-inv4/Cargo.toml @@ -11,11 +11,11 @@ version = '0.1.0-dev' [dependencies] serde = { version = "1.0.132", optional = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } smallvec = "1.6.1" scale-info = { version = "2.0.0", features = ["derive"], default-features = false } @@ -25,21 +25,21 @@ log = { version = "0.4.14", default-features = false } # InvArch dependencies primitives = { package = "invarch-primitives", path = "../../primitives", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.36", default-features = false } +pallet-balances = { git = 'https://github.com/paritytech/substrate.git', default-features = false , branch = "polkadot-v0.9.43" } -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.36", default-features = false, optional = true } +frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true , branch = "polkadot-v0.9.43" } -orml-tokens2 = { package = "orml-tokens", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "4f5a3f34d8cbd98b7bc2e295219a3e7b99b9ecaf" } +orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } -orml-traits2 = { package = "orml-traits", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "4f5a3f34d8cbd98b7bc2e295219a3e7b99b9ecaf" } -orml-traits = { package = "orml-traits", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -orml-tokens = { package = "orml-tokens", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -orml-asset-registry = { package = "orml-asset-registry", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } [features] default = ["std"] diff --git a/INV4/pallet-inv4/src/benchmarking.rs b/INV4/pallet-inv4/src/benchmarking.rs index e30c7100..53da3019 100644 --- a/INV4/pallet-inv4/src/benchmarking.rs +++ b/INV4/pallet-inv4/src/benchmarking.rs @@ -13,15 +13,18 @@ use core::convert::TryFrom; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; use frame_support::{ dispatch::PostDispatchInfo, + pallet_prelude::DispatchResultWithPostInfo, traits::{Currency, Get}, - BoundedBTreeMap, + BoundedBTreeMap, BoundedVec, }; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::{ traits::{Bounded, Hash, Zero}, DispatchError, DispatchErrorWithPostInfo, Perbill, }; -use sp_std::{collections::btree_map::BTreeMap, iter::Sum, ops::Div, prelude::*, vec}; +use sp_std::{ + collections::btree_map::BTreeMap, convert::TryInto, iter::Sum, ops::Div, prelude::*, vec, +}; use crate::Pallet as INV4; @@ -39,7 +42,7 @@ fn derive_account(core_id: T::CoreId) -> T::AccountId { derive_core_account::(core_id) } -fn mock_core() -> Result<(), DispatchError> +fn mock_core() -> DispatchResultWithPostInfo where Result< INV4Origin::CoreId, ::AccountId>, @@ -55,7 +58,7 @@ where INV4::::create_core( SystemOrigin::Signed(whitelisted_caller()).into(), - vec![], + vec![].try_into().unwrap(), perbill_one(), perbill_one(), FeeAsset::TNKR, @@ -156,7 +159,7 @@ benchmarks! { create_core { let m in 0 .. T::MaxMetadata::get(); - let metadata = vec![u8::MAX; m as usize]; + let metadata: BoundedVec = vec![u8::MAX; m as usize].try_into().unwrap(); let caller = whitelisted_caller(); let minimum_support = perbill_one(); let required_approval = perbill_one(); @@ -168,7 +171,7 @@ benchmarks! { assert_last_event::(Event::CoreCreated { core_account: derive_account::(0u32.into()), core_id: 0u32.into(), - metadata, + metadata: metadata.to_vec(), minimum_support, required_approval }.into()); @@ -179,7 +182,7 @@ benchmarks! { mock_core().unwrap(); - let metadata = Some(vec![u8::MAX; m as usize]); + let metadata: Option> = Some(vec![u8::MAX; m as usize].try_into().unwrap()); let minimum_support = Some(perbill_one()); let required_approval = Some(perbill_one()); let frozen_tokens = Some(true); @@ -188,7 +191,7 @@ benchmarks! { verify { assert_last_event::(Event::ParametersSet { core_id: 0u32.into(), - metadata, + metadata: metadata.map(|m| m.to_vec()), minimum_support, required_approval, frozen_tokens @@ -237,7 +240,7 @@ benchmarks! { remark: vec![0; z as usize] }.into(); - let metadata = vec![u8::MAX; m as usize]; + let metadata: BoundedVec = vec![u8::MAX; m as usize].try_into().unwrap(); let caller: T::AccountId = whitelisted_caller(); let core_id: T::CoreId = 0u32.into(); let call_hash = <::Hashing as Hash>::hash_of(&call.clone()); @@ -251,7 +254,6 @@ benchmarks! { voter: caller, votes_added: Vote::Aye(T::CoreSeedBalance::get()), call_hash, - call, }.into()); } @@ -286,7 +288,6 @@ benchmarks! { ])).unwrap() ), call_hash, - call, }.into()); } @@ -312,7 +313,6 @@ benchmarks! { voter: caller, votes_removed: Vote::Aye(BalanceOf::::max_value().div(4u32.into())), call_hash, - call, }.into()); } diff --git a/INV4/pallet-inv4/src/fee_handling.rs b/INV4/pallet-inv4/src/fee_handling.rs index d7bd407d..79e6e45f 100644 --- a/INV4/pallet-inv4/src/fee_handling.rs +++ b/INV4/pallet-inv4/src/fee_handling.rs @@ -1,7 +1,7 @@ use crate::Config; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - traits::{fungibles::CreditOf, Currency}, + traits::{fungibles::Credit, Currency}, unsigned::TransactionValidityError, }; use scale_info::TypeInfo; @@ -44,7 +44,7 @@ pub trait MultisigFeeHandler { fn handle_creation_fee( imbalance: FeeAssetNegativeImbalance< >::NegativeImbalance, - CreditOf, + Credit, >, ); } diff --git a/INV4/pallet-inv4/src/inv4_core.rs b/INV4/pallet-inv4/src/inv4_core.rs index 3ac062d7..ee08d99e 100644 --- a/INV4/pallet-inv4/src/inv4_core.rs +++ b/INV4/pallet-inv4/src/inv4_core.rs @@ -8,6 +8,7 @@ use frame_support::{ pallet_prelude::*, traits::{ fungibles::{Balanced, Mutate}, + tokens::{Fortitude, Precision, Preservation}, Currency, ExistenceRequirement, WithdrawReasons, }, }; @@ -15,7 +16,6 @@ use frame_system::{ensure_signed, pallet_prelude::*}; use primitives::CoreInfo; use sp_arithmetic::traits::{CheckedAdd, One}; use sp_runtime::Perbill; -use sp_std::{convert::TryInto, vec::Vec}; pub type CoreIndexOf = ::CoreId; @@ -31,7 +31,7 @@ where /// Create IP Set pub(crate) fn inner_create_core( origin: OriginFor, - metadata: Vec, + metadata: BoundedVec, minimum_support: Perbill, required_approval: Perbill, creation_fee_asset: FeeAsset, @@ -39,11 +39,6 @@ where NextCoreId::::try_mutate(|next_id| -> DispatchResult { let creator = ensure_signed(origin)?; - let bounded_metadata: BoundedVec = metadata - .clone() - .try_into() - .map_err(|_| Error::::MaxMetadataExceeded)?; - // Increment counter let current_id = *next_id; *next_id = next_id @@ -63,7 +58,7 @@ where let info = CoreInfo { account: core_account.clone(), - metadata: bounded_metadata, + metadata: metadata.clone(), minimum_support, required_approval, frozen_tokens: true, @@ -83,6 +78,9 @@ where T::KSMAssetId::get(), &creator, T::KSMCoreCreationFee::get(), + Precision::Exact, + Preservation::Protect, + Fortitude::Force, )?), }); @@ -92,7 +90,7 @@ where Self::deposit_event(Event::CoreCreated { core_account, - metadata, + metadata: metadata.to_vec(), core_id: current_id, minimum_support, required_approval, @@ -104,7 +102,7 @@ where pub(crate) fn inner_set_parameters( origin: OriginFor, - metadata: Option>, + metadata: Option>, minimum_support: Option, required_approval: Option, frozen_tokens: Option, @@ -124,7 +122,7 @@ where } if let Some(m) = metadata.clone() { - c.metadata = m.try_into().map_err(|_| Error::::MaxMetadataExceeded)?; + c.metadata = m; } if let Some(f) = frozen_tokens { @@ -135,7 +133,7 @@ where Self::deposit_event(Event::ParametersSet { core_id, - metadata, + metadata: metadata.map(|m| m.to_vec()), minimum_support, required_approval, frozen_tokens, diff --git a/INV4/pallet-inv4/src/lib.rs b/INV4/pallet-inv4/src/lib.rs index 87c3ea29..f5073e09 100644 --- a/INV4/pallet-inv4/src/lib.rs +++ b/INV4/pallet-inv4/src/lib.rs @@ -29,11 +29,12 @@ mod benchmarking; #[cfg(test)] mod tests; +//pub mod migrations; + mod dispatch; pub mod fee_handling; pub mod inv4_core; mod lookup; -pub mod migrations; pub mod multisig; pub mod origin; pub mod util; @@ -142,8 +143,7 @@ pub mod pallet { type KSMAssetId: Get<<::Tokens as Inspect<::AccountId>>::AssetId>; type AssetsProvider: fungibles::Inspect, AssetId = Self::CoreId> - + fungibles::Mutate - + fungibles::Transfer; + + fungibles::Mutate; // + fungibles::Transfer; type Tokens: Balanced + Inspect; @@ -152,6 +152,9 @@ pub mod pallet { #[pallet::constant] type GenesisHash: Get<::Hash>; + #[pallet::constant] + type MaxCallSize: Get; + type WeightInfo: WeightInfo; } @@ -241,7 +244,6 @@ pub mod pallet { voter: T::AccountId, votes_added: VoteRecord, call_hash: T::Hash, - call: CallOf, }, /// Voting weight was added towards the vote threshold, but not enough to execute the `Call` /// @@ -253,7 +255,6 @@ pub mod pallet { votes_added: VoteRecord, current_votes: Tally, call_hash: T::Hash, - call: CallOf, }, MultisigVoteWithdrawn { core_id: T::CoreId, @@ -261,7 +262,6 @@ pub mod pallet { voter: T::AccountId, votes_removed: VoteRecord, call_hash: T::Hash, - call: CallOf, }, /// Multisig call was executed. /// @@ -329,7 +329,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::create_core(metadata.len() as u32))] pub fn create_core( owner: OriginFor, - metadata: Vec, + metadata: BoundedVec, minimum_support: Perbill, required_approval: Perbill, creation_fee_asset: FeeAsset, @@ -380,7 +380,7 @@ pub mod pallet { pub fn operate_multisig( caller: OriginFor, core_id: T::CoreId, - metadata: Option>, + metadata: Option>, fee_asset: FeeAsset, call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { @@ -423,7 +423,7 @@ pub mod pallet { ))] pub fn set_parameters( origin: OriginFor, - metadata: Option>, + metadata: Option>, minimum_support: Option, required_approval: Option, frozen_tokens: Option, diff --git a/INV4/pallet-inv4/src/lookup.rs b/INV4/pallet-inv4/src/lookup.rs index a8dabad8..37ab5cb8 100644 --- a/INV4/pallet-inv4/src/lookup.rs +++ b/INV4/pallet-inv4/src/lookup.rs @@ -28,10 +28,9 @@ impl StaticLookup for INV4Lookup { } fn unlookup(a: Self::Target) -> Self::Source { - if let Some(core_id) = CoreByAccount::::get(&a) { - MultiAddress::Index(core_id) - } else { - MultiAddress::Id(a) + match CoreByAccount::::get(&a) { + Some(core_id) => MultiAddress::Index(core_id), + None => MultiAddress::Id(a), } } } diff --git a/INV4/pallet-inv4/src/multisig.rs b/INV4/pallet-inv4/src/multisig.rs index e516945c..26a8f0d4 100644 --- a/INV4/pallet-inv4/src/multisig.rs +++ b/INV4/pallet-inv4/src/multisig.rs @@ -13,6 +13,7 @@ use frame_support::{ pallet_prelude::*, traits::{ fungibles::{Inspect, Mutate}, + tokens::{Fortitude, Precision}, Currency, VoteTally, }, BoundedBTreeMap, @@ -22,12 +23,12 @@ use sp_runtime::{ traits::{Hash, Zero}, Perbill, }; -use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec::Vec}; +use sp_std::{boxed::Box, collections::btree_map::BTreeMap}; -/// Maximum size of call we store is 4mb. -pub const MAX_SIZE: u32 = 4 * 1024 * 1024; +/// Maximum size of call we store is 50kb. +pub const MAX_SIZE: u32 = 50 * 1024; -pub type BoundedCallBytes = BoundedVec>; +pub type BoundedCallBytes = BoundedVec::MaxCallSize>; /// Details of a multisig operation #[derive(Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, PartialEq, Eq)] @@ -42,7 +43,7 @@ pub struct MultisigOperation { pub type MultisigOperationOf = MultisigOperation< ::AccountId, Tally, - BoundedCallBytes, + BoundedCallBytes, BoundedVec::MaxMetadata>, >; @@ -83,7 +84,13 @@ where let core_origin = ensure_multisig::>(origin)?; let core_id = core_origin.id; - T::AssetsProvider::burn_from(core_id, &target, amount)?; + T::AssetsProvider::burn_from( + core_id, + &target, + amount, + Precision::Exact, + Fortitude::Polite, + )?; Self::deposit_event(Event::Burned { core_id, @@ -98,7 +105,7 @@ where pub(crate) fn inner_operate_multisig( caller: OriginFor, core_id: T::CoreId, - metadata: Option>, + metadata: Option>, fee_asset: FeeAsset, call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { @@ -108,15 +115,6 @@ where ensure!(!owner_balance.is_zero(), Error::::NoPermission); - let bounded_metadata: Option> = if let Some(vec) = metadata { - Some( - vec.try_into() - .map_err(|_| Error::::MaxMetadataExceeded)?, - ) - } else { - None - }; - let (minimum_support, _) = Pallet::::minimum_support_and_required_approval(core_id) .ok_or(Error::::CoreNotFound)?; @@ -148,7 +146,7 @@ where result: dispatch_result.map(|_| ()).map_err(|e| e.error), }); } else { - let bounded_call: BoundedCallBytes = (*call) + let bounded_call: BoundedCallBytes = (*call) .encode() .try_into() .map_err(|_| Error::::MaxCallLengthExceeded)?; @@ -169,7 +167,7 @@ where ), original_caller: owner.clone(), actual_call: bounded_call, - metadata: bounded_metadata, + metadata, fee_asset, }, ); @@ -184,7 +182,6 @@ where voter: owner, votes_added: Vote::Aye(owner_balance), call_hash, - call: *call, }); } @@ -264,7 +261,6 @@ where votes_added: new_vote_record, current_votes: old_data.tally, call_hash, - call: decoded_call, }); } @@ -285,9 +281,6 @@ where let old_vote = old_data.tally.process_vote(owner.clone(), None)?; - let decoded_call = ::RuntimeCall::decode(&mut &old_data.actual_call[..]) - .map_err(|_| Error::::FailedDecodingCall)?; - *data = Some(old_data.clone()); Self::deposit_event(Event::MultisigVoteWithdrawn { @@ -300,7 +293,6 @@ where voter: owner, votes_removed: old_vote, call_hash, - call: decoded_call, }); Ok(().into()) diff --git a/INV4/pallet-inv4/src/tests/mock.rs b/INV4/pallet-inv4/src/tests/mock.rs index c33fbe03..ba0952e8 100644 --- a/INV4/pallet-inv4/src/tests/mock.rs +++ b/INV4/pallet-inv4/src/tests/mock.rs @@ -4,7 +4,7 @@ use core::convert::TryFrom; use frame_support::{ parameter_types, traits::{ - fungibles::CreditOf, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, + fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, EnsureOriginWithArg, GenesisBuild, }, }; @@ -90,6 +90,10 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type MaxHolds = ConstU32<1>; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = [u8; 8]; } const UNIT: u128 = 1000000000000; @@ -195,6 +199,7 @@ parameter_types! { pub const ExistentialDeposit: u128 = 100000000000; pub const MaxLocks: u32 = 1; pub const MaxReserves: u32 = 1; + pub const MaxCallSize: u32 = 50 * 1024; } pub struct AssetAuthority; @@ -299,7 +304,7 @@ impl MultisigFeeHandler for FeeCharger { fn handle_creation_fee( _imbalance: FeeAssetNegativeImbalance< >::NegativeImbalance, - CreditOf, + Credit, >, ) { } @@ -324,6 +329,8 @@ impl pallet::Config for Test { type Tokens = Tokens; type KSMAssetId = RelayAssetId; type KSMCoreCreationFee = KSMCoreCreationFee; + + type MaxCallSize = MaxCallSize; } pub struct ExtBuilder; diff --git a/INV4/pallet-inv4/src/tests/mod.rs b/INV4/pallet-inv4/src/tests/mod.rs index b2d97f54..e075c8ce 100644 --- a/INV4/pallet-inv4/src/tests/mod.rs +++ b/INV4/pallet-inv4/src/tests/mod.rs @@ -34,7 +34,7 @@ fn create_core_works() { assert_ok!(INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR @@ -66,7 +66,7 @@ fn create_core_works() { assert_ok!(INV4::create_core( RawOrigin::Signed(BOB).into(), - vec![1, 2, 3], + vec![1, 2, 3].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::KSM @@ -106,7 +106,7 @@ fn create_core_fails() { assert_err!( INV4::create_core( RawOrigin::Signed(DAVE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR @@ -124,28 +124,12 @@ fn create_core_fails() { assert_err!( INV4::create_core( RawOrigin::Signed(DAVE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::KSM ), - TokenError::NoFunds - ); - - assert_eq!(INV4::next_core_id(), 0u32); - assert_eq!(INV4::core_storage(0u32), None); - - // Max metadata exceeded - - assert_err!( - INV4::create_core( - RawOrigin::Signed(ALICE).into(), - vec![0u8; (MaxMetadata::get() + 1) as usize], - Perbill::from_percent(1), - Perbill::from_percent(1), - FeeAsset::TNKR - ), - Error::::MaxMetadataExceeded + TokenError::FundsUnavailable ); assert_eq!(INV4::next_core_id(), 0u32); @@ -158,7 +142,7 @@ fn set_parameters_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -167,7 +151,7 @@ fn set_parameters_works() { assert_ok!(INV4::set_parameters( Origin::Multisig(MultisigInternalOrigin::new(0u32)).into(), - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), Some(Perbill::from_percent(100)), Some(Perbill::from_percent(100)), Some(false) @@ -191,7 +175,7 @@ fn set_parameters_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -203,7 +187,7 @@ fn set_parameters_fails() { assert_err!( INV4::set_parameters( RawOrigin::Signed(ALICE).into(), - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), Some(Perbill::from_percent(100)), Some(Perbill::from_percent(100)), Some(false) @@ -216,26 +200,13 @@ fn set_parameters_fails() { assert_err!( INV4::set_parameters( Origin::Multisig(MultisigInternalOrigin::new(1u32)).into(), - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), Some(Perbill::from_percent(100)), Some(Perbill::from_percent(100)), Some(false) ), Error::::CoreNotFound ); - - // Max metadata exceeded. - - assert_err!( - INV4::set_parameters( - Origin::Multisig(MultisigInternalOrigin::new(0u32)).into(), - Some(vec![0u8; (MaxMetadata::get() + 1) as usize],), - None, - None, - None - ), - Error::::MaxMetadataExceeded - ); }); } @@ -244,7 +215,7 @@ fn token_mint_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -276,7 +247,7 @@ fn token_mint_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -306,7 +277,7 @@ fn token_burn_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -359,7 +330,7 @@ fn token_burn_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(1), Perbill::from_percent(1), FeeAsset::TNKR, @@ -411,7 +382,7 @@ fn token_burn_fails() { CoreSeedBalance::get() + 1, ALICE ), - TokenError::NoFunds + TokenError::FundsUnavailable ); }); } @@ -421,7 +392,7 @@ fn operate_multisig_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -441,7 +412,7 @@ fn operate_multisig_works() { assert_ok!(INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()) )); @@ -489,7 +460,7 @@ fn operate_multisig_works() { assert_ok!(INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()) )); @@ -500,7 +471,6 @@ fn operate_multisig_works() { executor_account: util::derive_core_account::(0u32), voter: ALICE, votes_added: Vote::Aye(CoreSeedBalance::get()), - call: call.clone(), call_hash: <::Hashing as Hash>::hash_of(&call), } .into(), @@ -512,7 +482,7 @@ fn operate_multisig_works() { <::Hashing as Hash>::hash_of(&call) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: Some(vec![1, 2, 3].try_into().unwrap()), @@ -535,7 +505,7 @@ fn operate_multisig_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -565,25 +535,13 @@ fn operate_multisig_fails() { INV4::operate_multisig( RawOrigin::Signed(CHARLIE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()) ), Error::::NoPermission ); - // MaxMetadataExceeded - assert_err!( - INV4::operate_multisig( - RawOrigin::Signed(ALICE).into(), - 0u32, - Some(vec![0u8; (MaxMetadata::get() + 1) as usize]), - FeeAsset::TNKR, - Box::new(call.clone()) - ), - Error::::MaxMetadataExceeded - ); - // Max call length exceeded. assert_err!( INV4::operate_multisig( @@ -628,7 +586,7 @@ fn cancel_multisig_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -646,7 +604,7 @@ fn cancel_multisig_works() { INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()), ) @@ -657,7 +615,7 @@ fn cancel_multisig_works() { INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()), ) @@ -669,7 +627,7 @@ fn cancel_multisig_works() { <::Hashing as Hash>::hash_of(&call) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: Some(vec![1, 2, 3].try_into().unwrap()), @@ -705,7 +663,7 @@ fn cancel_multisig_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -723,7 +681,7 @@ fn cancel_multisig_fails() { INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()), ) @@ -734,7 +692,7 @@ fn cancel_multisig_fails() { INV4::operate_multisig( RawOrigin::Signed(ALICE).into(), 0u32, - Some(vec![1, 2, 3]), + Some(vec![1, 2, 3].try_into().unwrap()), FeeAsset::TNKR, Box::new(call.clone()), ) @@ -755,7 +713,7 @@ fn cancel_multisig_fails() { <::Hashing as Hash>::hash_of(&call) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: Some(vec![1, 2, 3].try_into().unwrap()), @@ -778,7 +736,7 @@ fn vote_multisig_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -829,7 +787,7 @@ fn vote_multisig_works() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -869,7 +827,6 @@ fn vote_multisig_works() { ])) .unwrap(), ), - call: call2.clone(), call_hash: <::Hashing as Hash>::hash_of(&call2), } .into(), @@ -881,7 +838,7 @@ fn vote_multisig_works() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -933,7 +890,7 @@ fn vote_multisig_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -984,7 +941,7 @@ fn vote_multisig_fails() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -1029,7 +986,7 @@ fn withdraw_vote_multisig_works() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -1098,7 +1055,6 @@ fn withdraw_vote_multisig_works() { ])) .unwrap(), ), - call: call2.clone(), call_hash: <::Hashing as Hash>::hash_of(&call2), } .into(), @@ -1110,7 +1066,7 @@ fn withdraw_vote_multisig_works() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -1140,7 +1096,6 @@ fn withdraw_vote_multisig_works() { executor_account: util::derive_core_account::(0u32), voter: BOB, votes_removed: Vote::Nay(CoreSeedBalance::get()), - call: call2.clone(), call_hash: <::Hashing as Hash>::hash_of(&call2), } .into(), @@ -1152,7 +1107,7 @@ fn withdraw_vote_multisig_works() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -1182,7 +1137,6 @@ fn withdraw_vote_multisig_works() { executor_account: util::derive_core_account::(0u32), voter: ALICE, votes_removed: Vote::Aye(CoreSeedBalance::get()), - call: call2.clone(), call_hash: <::Hashing as Hash>::hash_of(&call2), } .into(), @@ -1194,7 +1148,7 @@ fn withdraw_vote_multisig_works() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, @@ -1209,7 +1163,7 @@ fn withdraw_vote_multisig_fails() { ExtBuilder::default().build().execute_with(|| { INV4::create_core( RawOrigin::Signed(ALICE).into(), - vec![], + vec![].try_into().unwrap(), Perbill::from_percent(100), Perbill::from_percent(100), FeeAsset::TNKR, @@ -1289,7 +1243,7 @@ fn withdraw_vote_multisig_fails() { <::Hashing as Hash>::hash_of(&call2) ), Some(MultisigOperation { - actual_call: BoundedCallBytes::try_from(call2.clone().encode()).unwrap(), + actual_call: BoundedCallBytes::::try_from(call2.clone().encode()).unwrap(), fee_asset: FeeAsset::TNKR, original_caller: ALICE, metadata: None, diff --git a/INV4/pallet-inv4/src/weights.rs b/INV4/pallet-inv4/src/weights.rs index 895852a8..62d170dd 100644 --- a/INV4/pallet-inv4/src/weights.rs +++ b/INV4/pallet-inv4/src/weights.rs @@ -1,9 +1,11 @@ -//! Autogenerated weights for pallet_inv4 + +//! Autogenerated weights for `pallet_inv4` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/release/invarch-collator @@ -24,11 +26,12 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; -/// Weight functions needed for pallet_inv4. +/// Weight functions needed for `pallet_inv4`. pub trait WeightInfo { fn create_core(m: u32, ) -> Weight; fn set_parameters(m: u32, ) -> Weight; @@ -40,177 +43,281 @@ pub trait WeightInfo { fn cancel_multisig_proposal() -> Weight; } - /// Weights for pallet_inv4 using the Substrate node and recommended hardware. + /// Weights for `pallet_inv4` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: INV4 NextCoreId (r:1 w:1) - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: INV4 CoreByAccount (r:0 w:1) - // Storage: INV4 CoreStorage (r:0 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: INV4 NextCoreId (r:1 w:1) + /// Proof: INV4 NextCoreId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreByAccount (r:0 w:1) + /// Proof: INV4 CoreByAccount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:0 w:1) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. fn create_core(m: u32, ) -> Weight { - // Minimum execution time: 78_000 nanoseconds. - Weight::from_ref_time(79_237_712) - // Standard Error: 11 - .saturating_add(Weight::from_ref_time(772).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(8)) + // Proof Size summary in bytes: + // Measured: `273` + // Estimated: `6196` + // Minimum execution time: 88_000_000 picoseconds. + Weight::from_parts(88_381_513, 6196) + // Standard Error: 8 + .saturating_add(Weight::from_parts(833, 0).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } - // Storage: INV4 CoreStorage (r:1 w:1) + /// Storage: INV4 CoreStorage (r:1 w:1) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. fn set_parameters(m: u32, ) -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(18_397_028) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(805).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `13528` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_738_408, 13528) + // Standard Error: 5 + .saturating_add(Weight::from_parts(727, 0).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn token_mint() -> Weight { - // Minimum execution time: 38_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `3593` + // Minimum execution time: 35_000_000 picoseconds. + Weight::from_parts(36_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn token_burn() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(40_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `438` + // Estimated: `3593` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(38_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: CoreAssets Accounts (r:1 w:0) - // Storage: INV4 CoreStorage (r:1 w:0) - // Storage: CoreAssets TotalIssuance (r:1 w:0) - // Storage: INV4 Multisig (r:1 w:1) + /// Storage: CoreAssets Accounts (r:1 w:0) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:1 w:0) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. - /// The range of component `z` is `[0, 4194294]`. - fn operate_multisig(_m: u32, z: u32, ) -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(35_000_000) - // Standard Error: 2 - .saturating_add(Weight::from_ref_time(2_288).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + /// The range of component `z` is `[0, 51190]`. + fn operate_multisig(m: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `554807` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(23_450_861, 554807) + // Standard Error: 32 + .saturating_add(Weight::from_parts(346, 0).saturating_mul(m.into())) + // Standard Error: 6 + .saturating_add(Weight::from_parts(1_826, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:1 w:1) - // Storage: CoreAssets Accounts (r:1 w:0) - // Storage: INV4 CoreStorage (r:1 w:0) - // Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) + /// Storage: CoreAssets Accounts (r:1 w:0) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:1 w:0) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn vote_multisig() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(32_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `749` + // Estimated: `554807` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 554807) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:1 w:1) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) fn withdraw_vote_multisig() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(23_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `445` + // Estimated: `554807` + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(16_000_000, 554807) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:0 w:1) + /// Storage: INV4 Multisig (r:0 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) fn cancel_multisig_proposal() -> Weight { - // Minimum execution time: 15_000 nanoseconds. - Weight::from_ref_time(16_000_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } - // For backwards compatibility and tests + // For backwards compatibility and tests. impl WeightInfo for () { - // Storage: INV4 NextCoreId (r:1 w:1) - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: INV4 CoreByAccount (r:0 w:1) - // Storage: INV4 CoreStorage (r:0 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: INV4 NextCoreId (r:1 w:1) + /// Proof: INV4 NextCoreId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreByAccount (r:0 w:1) + /// Proof: INV4 CoreByAccount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:0 w:1) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. fn create_core(m: u32, ) -> Weight { - // Minimum execution time: 78_000 nanoseconds. - Weight::from_ref_time(79_237_712) - // Standard Error: 11 - .saturating_add(Weight::from_ref_time(772).saturating_mul(m.into())) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(8)) + // Proof Size summary in bytes: + // Measured: `273` + // Estimated: `6196` + // Minimum execution time: 88_000_000 picoseconds. + Weight::from_parts(88_381_513, 6196) + // Standard Error: 8 + .saturating_add(Weight::from_parts(833, 0).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } - // Storage: INV4 CoreStorage (r:1 w:1) + /// Storage: INV4 CoreStorage (r:1 w:1) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. fn set_parameters(m: u32, ) -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(18_397_028) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(805).saturating_mul(m.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `13528` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_738_408, 13528) + // Standard Error: 5 + .saturating_add(Weight::from_parts(727, 0).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn token_mint() -> Weight { - // Minimum execution time: 38_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `3593` + // Minimum execution time: 35_000_000 picoseconds. + Weight::from_parts(36_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: CoreAssets Accounts (r:1 w:1) - // Storage: CoreAssets TotalIssuance (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: INV4 CoreMembers (r:0 w:1) + /// Storage: CoreAssets Accounts (r:1 w:1) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:1) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: INV4 CoreMembers (r:0 w:1) + /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn token_burn() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(40_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `438` + // Estimated: `3593` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(38_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: CoreAssets Accounts (r:1 w:0) - // Storage: INV4 CoreStorage (r:1 w:0) - // Storage: CoreAssets TotalIssuance (r:1 w:0) - // Storage: INV4 Multisig (r:1 w:1) + /// Storage: CoreAssets Accounts (r:1 w:0) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:1 w:0) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) /// The range of component `m` is `[0, 10000]`. - /// The range of component `z` is `[0, 4194294]`. - fn operate_multisig(_m: u32, z: u32, ) -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(35_000_000) - // Standard Error: 2 - .saturating_add(Weight::from_ref_time(2_288).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + /// The range of component `z` is `[0, 51190]`. + fn operate_multisig(m: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `554807` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(23_450_861, 554807) + // Standard Error: 32 + .saturating_add(Weight::from_parts(346, 0).saturating_mul(m.into())) + // Standard Error: 6 + .saturating_add(Weight::from_parts(1_826, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:1 w:1) - // Storage: CoreAssets Accounts (r:1 w:0) - // Storage: INV4 CoreStorage (r:1 w:0) - // Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) + /// Storage: CoreAssets Accounts (r:1 w:0) + /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: INV4 CoreStorage (r:1 w:0) + /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) + /// Storage: CoreAssets TotalIssuance (r:1 w:0) + /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn vote_multisig() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(32_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `749` + // Estimated: `554807` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 554807) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:1 w:1) + /// Storage: INV4 Multisig (r:1 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) fn withdraw_vote_multisig() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(23_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `445` + // Estimated: `554807` + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(16_000_000, 554807) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: INV4 Multisig (r:0 w:1) + /// Storage: INV4 Multisig (r:0 w:1) + /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) fn cancel_multisig_proposal() -> Weight { - // Minimum execution time: 15_000 nanoseconds. - Weight::from_ref_time(16_000_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/INV4/pallet-ipf/Cargo.toml b/INV4/pallet-ipf/Cargo.toml deleted file mode 100644 index 2a340a2d..00000000 --- a/INV4/pallet-ipf/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -authors = ['InvArchitects '] -description = 'IPF Pallet for tokenizing and managing intellectual property' -edition = '2018' -homepage = 'https://invarch.network' -license = 'GPLv3' -name = 'pallet-ipf' -repository = 'https://github.com/InvArch/InvArch-Pallet-Library/ipf' -version = '0.1.0-dev' - -[dependencies] -serde = { version = "1.0.132", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -primitives = { package = "invarch-primitives", path = "../../primitives", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -scale-info = { version = "2.0.0", features = ["derive"], default-features = false } - -[features] -default = ["std"] -std = [ - "serde", - "codec/std", - "sp-runtime/std", - "sp-std/std", - "frame-support/std", - "frame-system/std", - "primitives/std", - "sp-io/std", - "scale-info/std", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/INV4/pallet-ipf/README.md b/INV4/pallet-ipf/README.md deleted file mode 100644 index d046577a..00000000 --- a/INV4/pallet-ipf/README.md +++ /dev/null @@ -1,165 +0,0 @@ -[![Compatible with Substrate v3.0.0](https://img.shields.io/badge/Substrate-v3.0.0-E6007A)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) - -# IPF Pallet: IP Files for Substrate - -This is a [Pallet](https://substrate.dev/docs/en/knowledgebase/runtime/pallets) that defines basic functions -to create and manage [intellectual property (IP)](https://en.wikipedia.org/wiki/Intellectual_property) stored as [non-fungible tokens (NFTs)](https://en.wikipedia.org/wiki/Non-fungible_token) - -# IP Files : Immutable records of ownership [(CIDs)](https://wiki.crust.network/docs/en/buildIntegrationNFTDataStorage.html) over digital assets that can be interchangeably stored & organized in an various IP Sets. -Their IP Sets are embedded with with flexible on-chain licensing, copyright, and collaboration (IP License) structures that can conform to satisfy international & domain-specific compliance standards. - -The following **components** are defined: - -* `IP File` + Metadata - -The following **callable functions** are possible: - -* `mint` - Create a new IP File and add to an IP Set -* `burn` - Burn an IP File from an IP Set -* `send` - Send an IP File to other address - - -# IP File - -An IP File (IPF) is a part of a set, and can be thought of as a component of an idea. Either by itself or in combination with other IP Files, it serves to strengethen the foundation for an innovation. IP Files represent a unique digital asset. - -## IPF Standard - -```json -{ - "name": { - "type": "string", - "description": "Name of the IPT. E.g. IPT0, IPT1" - }, - "ipfId": { - "type": "u64", - "description": "The ID of an existing IPF owned by the current caller, can be found in events after minting or in storage" - }, - "metadata?": { - "type": "Vec", - "description": "Free to use any value as this won't affect logic and is intended to be used by dApp developers" - }, - "data?": { - "type": "H256", - "description": "An IPFS CID hash, intended to be the content identifier of the actual file, can be taken from CID here: https://cid.ipfs.io by copying the Digest (Hex) field" - } -} -``` - -When either metadata or [data](#data) is present, the other is optional. Data takes precedence -always. Note that because metadata contains description, attributes, third party URLs, etc. it is -still recommended to include it alongside `data`. - -### Computed fields - -Computed fields are fields that are used in interactions, but are not explicitly set on their -entities. Computed fields are the result of applying a standardized calculation or merger formula to -specific fields. The IPF entity has the following computed fields, to be provided by -implementations: - -```json -{ - "id": { - "type": "computed", - "description": "An IPF is uniquely identified by the combination of its minting block number, set ID, its instance ID, and its serial number, e.g. 4110010-0aff6865bed5g76b-HOVER-0000000000000123" - } -} -``` - -Example id: `4110010-0aff6865bed5g76b-HOVER-0000000000000123`. - -### Data - -The `data` object is composed of: - -- protocol (strict, see Protocols below) -- data -- type (mime type) - -#### Protocols - -| Protocol | Mime default | Description | -| --------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `ipfs` | image/png | Points to a directly interpretable resource, be it audio, video, code, or something else | -| `http(s)` | image/html | Points to a directly interpretable resource, be it audio, video, code, or something else (not recommended for use) | -| `p5` | application/javascript | Processing.js code | -| `js` | application/javascript | Plain JS code | -| `html` | text/html | HTML code, no need for `` and ``, can support dependencies but it's up to the author to prevent the dependencies from disappearing | -| `svg` | image/svg+xml | SVG image data | -| `bin` | n/a | binary, directly interpretable | - -#### Example - -#### A binary video - -```json -data: { - "protocol": "bin", - "data": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAQC0ttZGF0AQIUGRQmM...", - "type": "video/mp4" -} -``` - -## Metadata Standard - -```json -{ - "external_url": { - "type": "string", - "description": "HTTP or IPFS URL for finding out more about this file. If IPFS, MUST be in the format of ipfs://ipfs/HASH" - }, - "image": { - "type": "string", - "description": "HTTP or IPFS URL to project's main image, in the vein of og:image. If IPFS, MUST be in the format of ipfs://ipfs/HASH" - }, - "image_data": { - "type": "string?", - "description": "[OPTIONAL] Use only if you don't have the image field (they are mutually exclusive and image takes precedence). Raw base64 or SVG data for the image. If SVG, MUST start with (_); - - #[pallet::config] - pub trait Config: frame_system::Config { - /// The IPF Pallet Events - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// The IPF ID type - type IpfId: Parameter + Member + AtLeast32BitUnsigned + Default + Copy + MaxEncodedLen; - /// The maximum size of an IPF's metadata - type MaxIpfMetadata: Get; - } - - pub type IpfMetadataOf = BoundedVec::MaxIpfMetadata>; - pub type IpfInfoOf = IpfInfo< - ::AccountId, - ::Hash, // CID stored as just the hash - IpfMetadataOf, - >; - - pub type GenesisIpfData = ( - ::AccountId, // IPF owner - Vec, // IPF metadata - ::Hash, // CID stored as just the hash - ); - - /// Next available IPF ID - #[pallet::storage] - #[pallet::getter(fn next_ipf_id)] - pub type NextIpfId = StorageValue<_, T::IpfId, ValueQuery>; - - /// Store IPF info - /// - /// Returns `None` if IPF info not set of removed - #[pallet::storage] - #[pallet::getter(fn ipf_storage)] - pub type IpfStorage = StorageMap<_, Blake2_128Concat, T::IpfId, IpfInfoOf>; - - /// IPF existence check by owner and IPF ID - #[pallet::storage] - #[pallet::getter(fn ipf_by_owner)] - pub type IpfByOwner = StorageDoubleMap< - _, - Blake2_128Concat, - T::AccountId, // owner - Blake2_128Concat, - T::IpfId, - (), - >; - - /// Errors for IPF pallet - #[pallet::error] - pub enum Error { - /// No available IPF ID - NoAvailableIpfId, - /// IPF (IpsId, IpfId) not found - IpfNotFound, - /// The operator is not the owner of the IPF and has no permission - NoPermission, - /// Failed because the Maximum amount of metadata was exceeded - MaxMetadataExceeded, - } - - #[pallet::event] - #[pallet::generate_deposit(fn deposit_event)] - //#[pallet::metadata(T::AccountId = "AccountId", T::IpfId = "IpfId", T::Hash = "Hash")] - pub enum Event { - Minted(T::AccountId, T::IpfId, T::Hash), - Burned(T::AccountId, T::IpfId), - } - - /// Dispatch functions - #[pallet::call] - impl Pallet { - /// Mint IPF(Intellectual Property File) to `owner`. - /// i.e. create IP File - #[pallet::weight(300_000_000)] - pub fn mint( - owner: OriginFor, - metadata: Vec, - data: T::Hash, - ) -> DispatchResultWithPostInfo { - NextIpfId::::try_mutate(|id| -> DispatchResultWithPostInfo { - let owner = ensure_signed(owner)?; - let bounded_metadata: BoundedVec = metadata - .try_into() - .map_err(|_| Error::::MaxMetadataExceeded)?; - - let ipf_id = *id; - *id = id - .checked_add(&One::one()) - .ok_or(Error::::NoAvailableIpfId)?; - - let ipf_info = IpfInfo { - metadata: bounded_metadata, - owner: owner.clone(), - author: owner.clone(), - data, - }; - IpfStorage::::insert(ipf_id, ipf_info); - IpfByOwner::::insert(owner.clone(), ipf_id, ()); - - Self::deposit_event(Event::Minted(owner, ipf_id, data)); - - Ok(().into()) - }) - } - - /// Burn IPF(Intellectual Property File) from `owner`. - /// i.e. delete IP file - #[pallet::weight(300_000_000)] - pub fn burn(owner: OriginFor, ipf_id: T::IpfId) -> DispatchResult { - IpfStorage::::try_mutate(ipf_id, |ipf_info| -> DispatchResult { - let owner = ensure_signed(owner)?; - let t = ipf_info.take().ok_or(Error::::IpfNotFound)?; - ensure!(t.owner == owner, Error::::NoPermission); - - IpfByOwner::::remove(owner.clone(), ipf_id); - - Self::deposit_event(Event::Burned(owner, ipf_id)); - - Ok(()) - }) - } - } - - impl Pallet { - pub fn send(owner: T::AccountId, ipf_id: T::IpfId, target: T::AccountId) -> DispatchResult { - IpfStorage::::try_mutate(ipf_id, |ipf_info| -> DispatchResult { - let t = ipf_info.take().ok_or(Error::::IpfNotFound)?; - - ensure!(t.owner == owner, Error::::NoPermission); - - *ipf_info = Some(IpfInfo { - owner: target.clone(), - author: t.author, - metadata: t.metadata, - data: t.data, - }); - - IpfByOwner::::remove(owner, ipf_id); - IpfByOwner::::insert(target, ipf_id, ()); - - Ok(()) - }) - } - } - - #[pallet::hooks] - impl Hooks for Pallet {} -} diff --git a/INV4/pallet-ipf/src/mock.rs b/INV4/pallet-ipf/src/mock.rs deleted file mode 100644 index 8949a8c0..00000000 --- a/INV4/pallet-ipf/src/mock.rs +++ /dev/null @@ -1,128 +0,0 @@ -//! Mocks for the gradually-update module. - -use frame_support::{ - construct_runtime, parameter_types, - traits::{ConstU32, Contains}, -}; -use sp_core::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup}; -use sp_std::convert::TryFrom; - -use super::*; - -use crate as ipf; - -parameter_types! { - pub const BlockHashCount: u64 = 250; -} - -pub type AccountId = u128; -pub type BlockNumber = u64; - -impl frame_system::Config for Runtime { - type Origin = Origin; - type Index = u64; - type BlockNumber = BlockNumber; - type Call = Call; - type Hash = H256; - type Hashing = ::sp_runtime::traits::BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type BlockWeights = (); - type BlockLength = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type DbWeight = (); - type BaseCallFilter = BaseFilter; - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; -} - -parameter_types! { - pub const MaxIpfMetadata: u32 = 32; -} - -impl Config for Runtime { - type IpfId = u64; - type MaxIpfMetadata = MaxIpfMetadata; - type Event = Event; -} - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -use frame_system::Call as SystemCall; -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(c: &Call) -> bool { - match *c { - // Remark is used as a no-op call in the benchmarking - Call::System(SystemCall::remark { .. }) => true, - Call::System(_) => false, - } - } -} - -construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Ipf: ipf::{Pallet, Storage, Event}, - } -); - -pub const ALICE: AccountId = 1; -pub const BOB: AccountId = 2; -pub const IPF_ID: ::IpfId = 0; -pub const IPF_ID_DOESNT_EXIST: ::IpfId = 100; -pub const MOCK_DATA: [u8; 32] = [ - 12, 47, 182, 72, 140, 51, 139, 219, 171, 74, 247, 18, 123, 28, 200, 236, 221, 85, 25, 12, 218, - 0, 230, 247, 32, 73, 152, 66, 243, 27, 92, 95, -]; -pub const MOCK_METADATA: &'static [u8] = &[ - 12, 47, 182, 72, 140, 51, 139, 219, 171, 74, 247, 18, 123, 28, 200, 236, 221, 85, 25, 12, 218, - 0, 230, 247, 32, 73, 152, 66, 243, 27, 92, 95, -]; -pub const MOCK_DATA_SECONDARY: [u8; 32] = [ - 47, 182, 72, 140, 51, 139, 219, 171, 74, 247, 18, 123, 28, 200, 236, 221, 85, 25, 12, 218, 0, - 230, 247, 32, 73, 152, 66, 243, 27, 92, 95, 12, -]; -pub const MOCK_METADATA_SECONDARY: &'static [u8] = &[ - 47, 182, 72, 140, 51, 139, 219, 171, 74, 247, 18, 123, 28, 200, 236, 221, 85, 25, 12, 218, 0, - 230, 247, 32, 73, 152, 66, 243, 27, 92, 95, 12, -]; -pub const MOCK_METADATA_PAST_MAX: &'static [u8] = &[ - 12, 47, 182, 72, 140, 51, 139, 219, 171, 74, 247, 18, 123, 28, 200, 236, 221, 85, 25, 12, 218, - 0, 230, 247, 32, 73, 152, 66, 243, 27, 92, 95, 42, -]; - -pub struct ExtBuilder; - -impl Default for ExtBuilder { - fn default() -> Self { - ExtBuilder - } -} - -impl ExtBuilder { - pub fn build(self) -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default() - .build_storage::() - .unwrap(); - - let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} diff --git a/INV4/pallet-ipf/src/tests.rs b/INV4/pallet-ipf/src/tests.rs deleted file mode 100644 index c0ae018b..00000000 --- a/INV4/pallet-ipf/src/tests.rs +++ /dev/null @@ -1,256 +0,0 @@ -//! Unit tests for the IPF pallet. - -use super::*; -use frame_support::{assert_noop, assert_ok}; -use mock::*; -use sp_core::H256; -use sp_runtime::DispatchError; - -#[test] -fn mint_should_work() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(Ipf::next_ipf_id(), 0); - assert_ok!(Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - )); - assert_eq!(Ipf::next_ipf_id(), 1); - assert_ok!(Ipf::mint( - Origin::signed(ALICE), - MOCK_METADATA_SECONDARY.to_vec(), - H256::from(MOCK_DATA_SECONDARY) - )); - assert_eq!(Ipf::next_ipf_id(), 2); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: BOB, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - - assert_eq!( - IpfStorage::::get(1), - Some(IpfInfoOf:: { - author: ALICE, - owner: ALICE, - metadata: MOCK_METADATA_SECONDARY.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA_SECONDARY) - }) - ); - }); -} - -#[test] -fn mint_should_fail() { - ExtBuilder::default().build().execute_with(|| { - assert_noop!( - Ipf::mint( - Origin::none(), - MOCK_METADATA_PAST_MAX.to_vec(), - H256::from(MOCK_DATA) - ), - DispatchError::BadOrigin - ); - assert_noop!( - Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA_PAST_MAX.to_vec(), - H256::from(MOCK_DATA) - ), - Error::::MaxMetadataExceeded, - ); - - NextIpfId::::mutate(|id| *id = ::IpfId::max_value()); - assert_noop!( - Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - ), - Error::::NoAvailableIpfId - ); - - assert_eq!(IpfStorage::::get(0), None); - }); -} - -#[test] -fn burn_should_work() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - )); - - assert_ok!(Ipf::burn(Origin::signed(BOB), IPF_ID)); - - assert_eq!(IpfStorage::::get(0), None); - }); -} - -#[test] -fn burn_should_fail() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - )); - - assert_noop!(Ipf::burn(Origin::none(), IPF_ID), DispatchError::BadOrigin); - - assert_noop!( - Ipf::burn(Origin::signed(BOB), IPF_ID_DOESNT_EXIST), - Error::::IpfNotFound - ); - - assert_noop!( - Ipf::burn(Origin::signed(ALICE), IPF_ID), - Error::::NoPermission - ); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: BOB, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - }); -} - -#[test] -fn send_should_work() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(Ipf::next_ipf_id(), 0); - assert_ok!(Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - )); - assert_eq!(Ipf::next_ipf_id(), 1); - assert_ok!(Ipf::mint( - Origin::signed(ALICE), - MOCK_METADATA_SECONDARY.to_vec(), - H256::from(MOCK_DATA_SECONDARY) - )); - assert_eq!(Ipf::next_ipf_id(), 2); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: BOB, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - - assert_ok!(Ipf::send(BOB, 0, ALICE)); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: ALICE, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - - assert_eq!( - IpfStorage::::get(1), - Some(IpfInfoOf:: { - author: ALICE, - owner: ALICE, - metadata: MOCK_METADATA_SECONDARY.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA_SECONDARY) - }) - ); - - assert_ok!(Ipf::send(ALICE, 1, BOB)); - - assert_eq!( - IpfStorage::::get(1), - Some(IpfInfoOf:: { - author: ALICE, - owner: BOB, - metadata: MOCK_METADATA_SECONDARY.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA_SECONDARY) - }) - ); - }); -} - -#[test] -fn send_should_fail() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(Ipf::next_ipf_id(), 0); - assert_ok!(Ipf::mint( - Origin::signed(BOB), - MOCK_METADATA.to_vec(), - H256::from(MOCK_DATA) - )); - assert_eq!(Ipf::next_ipf_id(), 1); - assert_ok!(Ipf::mint( - Origin::signed(ALICE), - MOCK_METADATA_SECONDARY.to_vec(), - H256::from(MOCK_DATA_SECONDARY) - )); - assert_eq!(Ipf::next_ipf_id(), 2); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: BOB, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - - assert_eq!( - IpfStorage::::get(1), - Some(IpfInfoOf:: { - author: ALICE, - owner: ALICE, - metadata: MOCK_METADATA_SECONDARY.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA_SECONDARY) - }) - ); - - assert_noop!(Ipf::send(BOB, 2, ALICE), Error::::IpfNotFound); - - assert_noop!(Ipf::send(BOB, 1, ALICE), Error::::NoPermission); - - assert_noop!(Ipf::send(ALICE, 0, BOB), Error::::NoPermission); - - assert_eq!( - IpfStorage::::get(0), - Some(IpfInfoOf:: { - author: BOB, - owner: BOB, - metadata: MOCK_METADATA.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA) - }) - ); - - assert_eq!( - IpfStorage::::get(1), - Some(IpfInfoOf:: { - author: ALICE, - owner: ALICE, - metadata: MOCK_METADATA_SECONDARY.to_vec().try_into().unwrap(), - data: H256::from(MOCK_DATA_SECONDARY) - }) - ); - }); -} diff --git a/INV4/pallet-ipvm/Cargo.toml b/INV4/pallet-ipvm/Cargo.toml deleted file mode 100644 index 6baa1c0b..00000000 --- a/INV4/pallet-ipvm/Cargo.toml +++ /dev/null @@ -1,57 +0,0 @@ -[package] -authors = ['InvArchitects '] -description = 'IPS Pallet for creating and managing sets of tokenized IP' -edition = '2018' -homepage = 'https://invarch.io' -license = 'GPLv3' -name = 'pallet-smartip' -repository = 'https://github.com/InvArch/InvArch-Pallet-Library/smartip' -version = '0.1.0-dev' - -[dependencies] -serde = { version = "1.0.132", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } -pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } - -scale-info = { version = "2.0.0", features = ["derive"], default-features = false } - -# InvArch dependencies -primitives = { package = "invarch-primitives", path = "../../primitives", default-features = false } -ips = { package = "pallet-ips", path = "../pallet-ips", default-features = false } -ipf = { package = "pallet-ipf", path = "../pallet-ipf", default-features = false } -ipl = { package = "pallet-ipl", path = "../pallet-ipl", default-features = false } - - -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } - -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false } - -pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } - -[dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } - -[features] -default = ["std"] -std = [ - "serde", - "codec/std", - "sp-runtime/std", - "sp-std/std", - "frame-support/std", - "frame-system/std", - "sp-io/std", - "scale-info/std", - "pallet-contracts/std", - "pallet-balances/std", - "ips/std", - "ipf/std", - "pallet-contracts-primitives/std" -] -try-runtime = ["frame-support/try-runtime"] - diff --git a/INV4/pallet-ipvm/README.md b/INV4/pallet-ipvm/README.md deleted file mode 100644 index 07c40225..00000000 --- a/INV4/pallet-ipvm/README.md +++ /dev/null @@ -1,5 +0,0 @@ -[![Compatible with Substrate v3.0.0](https://img.shields.io/badge/Substrate-v3.0.0-E6007A)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) - -# IPVM Pallet: IP Virtual Machine for Substrate - -### WIP diff --git a/INV4/pallet-ipvm/src/lib.rs b/INV4/pallet-ipvm/src/lib.rs deleted file mode 100644 index 1f0e0c11..00000000 --- a/INV4/pallet-ipvm/src/lib.rs +++ /dev/null @@ -1,180 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] -#![allow(clippy::unused_unit)] -#![allow(clippy::too_many_arguments)] - -use frame_support::{pallet_prelude::*, traits::Currency as FSCurrency}; -use frame_system::pallet_prelude::*; -use sp_std::vec::Vec; - -//#[cfg(test)] -//mod mock; -//#[cfg(test)] -//mod tests; - -pub use pallet::*; - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use primitives::OneOrPercent; - use sp_core::crypto::UncheckedFrom; - use sp_runtime::traits::{CheckedAdd, Hash, StaticLookup}; - use sp_std::vec; - - #[pallet::config] - pub trait Config: - frame_system::Config - + ips::Config - + ipf::Config - + ipl::Config - + pallet_contracts::Config - + pallet_balances::Config - { - /// The IPS Pallet Events - type Event: From> + IsType<::Event>; - /// Currency - type Currency: FSCurrency; - - /// The minimum amount required to keep an account open. - #[pallet::constant] - type ExistentialDeposit: Get< - <::Currency as FSCurrency<::AccountId>>::Balance, - >; - } - - pub type BalanceOf = - <::Currency as FSCurrency<::AccountId>>::Balance; - - pub type ContractsBalanceOf = <::Currency as FSCurrency< - ::AccountId, - >>::Balance; - - pub type BalancesBalanceOf = <::Currency as FSCurrency< - ::AccountId, - >>::Balance; - - #[pallet::pallet] - pub struct Pallet(_); - - #[pallet::event] - #[pallet::generate_deposit(fn deposit_event)] - pub enum Event { - Created(T::AccountId, T::IpsId), - } - - /// Errors for SmartIP pallet - #[pallet::error] - pub enum Error { - BalanceOverflow, - } - - /// Dispatch functions - #[pallet::call] - impl Pallet - where - T::AccountId: UncheckedFrom, - T::AccountId: AsRef<[u8]>, - - ::Balance: From< - <::Currency as FSCurrency< - ::AccountId, - >>::Balance, - >, - <::Currency as FSCurrency< - ::AccountId, - >>::Balance: From< - <::Currency as FSCurrency< - ::AccountId, - >>::Balance, - >, - { - /// Create IP (Intellectual Property) Set (IPS) - #[pallet::weight(10000)] // TODO - pub fn create( - owner: OriginFor, - code: Vec, - data: Vec, - endowment: BalanceOf, - gas_limit: Weight, - allow_replica: bool, - ipl_license: ::Licenses, - ipl_execution_threshold: OneOrPercent, - ipl_default_asset_weight: OneOrPercent, - ipl_default_permission: bool, - ) -> DispatchResultWithPostInfo - where - ::Balance: From< - <::Currency as FSCurrency< - ::AccountId, - >>::Balance, - >, - <::Currency as FSCurrency< - ::AccountId, - >>::Balance: From< - <::Currency as FSCurrency< - ::AccountId, - >>::Balance, - >, - { - let ips_id: ::IpsId = ips::NextIpsId::::get(); - let ipf_id: ::IpfId = ipf::NextIpfId::::get(); - - ipf::Pallet::::mint(owner.clone(), vec![], T::Hashing::hash(&code))?; - - // TODO: WASM to WAT - // TODO: Mint WAT IPF - - let ips_account: ::AccountId = - primitives::utils::multi_account_id::::IpsId>(ips_id, None); - - ips::Pallet::::create_ips( - owner.clone(), - vec![], - vec![ipf_id], - allow_replica, - None, - ipl_license, - ipl_execution_threshold, - ipl_default_asset_weight, - ipl_default_permission, - )?; - - pallet_balances::Pallet::::transfer( - owner, - <::Lookup as StaticLookup>::unlookup( - ips_account.clone(), - ), - endowment - .checked_add(&::ExistentialDeposit::get()) - .ok_or(Error::::BalanceOverflow)? - .into(), - )?; - - pallet_contracts::Pallet::::bare_instantiate( - ips_account.clone(), - endowment.into(), - gas_limit, - Some(endowment.into()), - pallet_contracts_primitives::Code::Existing( - pallet_contracts::Pallet::::bare_upload_code( - ips_account.clone(), - code, - Some(endowment.into()), - )? - .code_hash, - ), - data, - vec![], - true, - ) - .result?; - - Self::deposit_event(Event::Created(ips_account, ips_id)); - - Ok(().into()) - } - } - - #[pallet::hooks] - impl Hooks for Pallet {} -} diff --git a/OCIF/ip-donations/README.md b/OCIF/ip-donations/README.md deleted file mode 100644 index 15f4f6d2..00000000 --- a/OCIF/ip-donations/README.md +++ /dev/null @@ -1,14 +0,0 @@ -[![Compatible with Substrate v3.0.0](https://img.shields.io/badge/Substrate-v3.0.0-E6007A)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) - -# IP Donations Pallet: IP Donations for Substrate - -This is a Substrate [Pallet](https://substrate.dev/docs/en/knowledgebase/runtime/pallets) that defines basic functions -to allocate staking rewards towards a network treasury to fund a grant, which will be donated to an Intellectual Property Set (IPS). - -# IP Donations - -The following **components** are defined: - -- `IP Donations` - -### WIP diff --git a/OCIF/ip-farming/README.md b/OCIF/ip-farming/README.md deleted file mode 100644 index 8cdb2f05..00000000 --- a/OCIF/ip-farming/README.md +++ /dev/null @@ -1,14 +0,0 @@ -[![Compatible with Substrate v3.0.0](https://img.shields.io/badge/Substrate-v3.0.0-E6007A)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) - -# IP Farming Pallet: IP Farming for Substrate - -This is a Substrate [Pallet](https://substrate.dev/docs/en/knowledgebase/runtime/pallets) that defines basic functions -to farm Intellectual Property Tokens (IPT) from an Intellectual Property Set (IPS) in exchange for network staking rewards. - -## IP Farming - -The following **components** are defined: - -- `IP Farming` - -### WIP diff --git a/OCIF/staking/Cargo.toml b/OCIF/staking/Cargo.toml index 049c040f..bcb94a70 100644 --- a/OCIF/staking/Cargo.toml +++ b/OCIF/staking/Cargo.toml @@ -16,26 +16,26 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } serde = { version = "1.0.140", features = ["derive"], optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } num-traits = { version = "0.2", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false, optional = true } -pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false, optional = true } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } pallet-inv4 = { path = "../../INV4/pallet-inv4", default-features = false } -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.36", default-features = false, optional = true } +frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true , branch = "polkadot-v0.9.43" } [dev-dependencies] -orml-traits = { package = "orml-traits", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -orml-tokens = { package = "orml-tokens", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } [features] default = ["std"] @@ -63,4 +63,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", ] -try-runtime = ["frame-support/try-runtime"] \ No newline at end of file +try-runtime = ["frame-support/try-runtime"] diff --git a/OCIF/staking/src/benchmarking.rs b/OCIF/staking/src/benchmarking.rs index c7fd2f5f..80d41c64 100644 --- a/OCIF/staking/src/benchmarking.rs +++ b/OCIF/staking/src/benchmarking.rs @@ -4,7 +4,10 @@ use super::*; use crate::Pallet as OcifStaking; use core::ops::Add; use frame_benchmarking::{benchmarks, whitelisted_caller}; -use frame_support::traits::{Get, OnFinalize, OnInitialize}; +use frame_support::{ + traits::{Get, OnFinalize, OnInitialize}, + BoundedVec, +}; use frame_system::{Pallet as System, RawOrigin}; use pallet_inv4::{ origin::{INV4Origin, MultisigInternalOrigin}, @@ -51,9 +54,9 @@ where OcifStaking::::register_core( INV4Origin::Multisig(MultisigInternalOrigin::new(0u32.into())).into(), - vec![], - vec![], - vec![], + vec![].try_into().unwrap(), + vec![].try_into().unwrap(), + vec![].try_into().unwrap(), ) } @@ -114,11 +117,11 @@ benchmarks! { let d in 0 .. T::MaxDescriptionLength::get(); let i in 0 .. T::MaxImageUrlLength::get(); - let name = vec![u8::MAX; n as usize]; - let description = vec![u8::MAX; d as usize]; - let image = vec![u8::MAX; i as usize]; + let name: BoundedVec = vec![u8::MAX; n as usize].try_into().unwrap(); + let description: BoundedVec = vec![u8::MAX; d as usize].try_into().unwrap(); + let image: BoundedVec = vec![u8::MAX; i as usize].try_into().unwrap(); - ::Currency::make_free_balance_be(&derive_account::(0u32.into()), T::RegisterDeposit::get()); + ::Currency::make_free_balance_be(&derive_account::(0u32.into()), T::RegisterDeposit::get() + T::RegisterDeposit::get()); }: _(INV4Origin::Multisig(MultisigInternalOrigin::new(0u32.into())), name, description, image) verify { assert_last_event::(Event::::CoreRegistered { @@ -131,9 +134,9 @@ benchmarks! { let d in 0 .. T::MaxDescriptionLength::get(); let i in 0 .. T::MaxImageUrlLength::get(); - let name = vec![u8::MAX; n as usize]; - let description = vec![u8::MAX; d as usize]; - let image = vec![u8::MAX; i as usize]; + let name: BoundedVec = vec![u8::MAX; n as usize].try_into().unwrap(); + let description: BoundedVec = vec![u8::MAX; d as usize].try_into().unwrap(); + let image: BoundedVec = vec![u8::MAX; i as usize].try_into().unwrap(); mock_register().unwrap(); @@ -147,9 +150,9 @@ benchmarks! { image: vec![] }, new_metadata: CoreMetadata { - name, - description, - image + name: name.to_vec(), + description: description.to_vec(), + image: image.to_vec() } }.into()); } diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index bb8bcacd..8bfc1f64 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -104,7 +104,6 @@ pub mod pallet { <::Currency as Currency<::AccountId>>::Balance; #[pallet::pallet] - #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(PhantomData); type NegativeImbalanceOf = <::Currency as Currency< @@ -364,9 +363,9 @@ pub mod pallet { )] pub fn register_core( origin: OriginFor, - name: Vec, - description: Vec, - image: Vec, + name: BoundedVec, + description: BoundedVec, + image: BoundedVec, ) -> DispatchResultWithPostInfo { Self::ensure_not_halted()?; @@ -379,25 +378,10 @@ pub mod pallet { Error::::CoreAlreadyRegistered, ); - let bounded_name: BoundedVec = name - .clone() - .try_into() - .map_err(|_| Error::::MaxNameExceeded)?; - - let bounded_description: BoundedVec = description - .clone() - .try_into() - .map_err(|_| Error::::MaxDescriptionExceeded)?; - - let bounded_image: BoundedVec = image - .clone() - .try_into() - .map_err(|_| Error::::MaxImageExceeded)?; - let metadata: CoreMetadataOf = CoreMetadata { - name: bounded_name, - description: bounded_description, - image: bounded_image, + name, + description, + image, }; ::Currency::reserve(&core_account, T::RegisterDeposit::get())?; @@ -508,9 +492,9 @@ pub mod pallet { )] pub fn change_core_metadata( origin: OriginFor, - name: Vec, - description: Vec, - image: Vec, + name: BoundedVec, + description: BoundedVec, + image: BoundedVec, ) -> DispatchResultWithPostInfo { Self::ensure_not_halted()?; @@ -520,25 +504,10 @@ pub mod pallet { RegisteredCore::::try_mutate(core_id, |core| { let mut new_core = core.take().ok_or(Error::::NotRegistered)?; - let bounded_name: BoundedVec = name - .clone() - .try_into() - .map_err(|_| Error::::MaxNameExceeded)?; - - let bounded_description: BoundedVec = description - .clone() - .try_into() - .map_err(|_| Error::::MaxDescriptionExceeded)?; - - let bounded_image: BoundedVec = image - .clone() - .try_into() - .map_err(|_| Error::::MaxImageExceeded)?; - let new_metadata: CoreMetadataOf = CoreMetadata { - name: bounded_name, - description: bounded_description, - image: bounded_image, + name: name.clone(), + description: description.clone(), + image: image.clone(), }; let old_metadata = new_core.metadata; @@ -555,9 +524,9 @@ pub mod pallet { image: old_metadata.image.into_inner(), }, new_metadata: CoreMetadata { - name, - description, - image, + name: name.to_vec(), + description: description.to_vec(), + image: image.to_vec(), }, }); diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index db97af56..9498e223 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -4,7 +4,7 @@ use core::convert::{TryFrom, TryInto}; use frame_support::{ construct_runtime, parameter_types, traits::{ - fungibles::CreditOf, ConstU128, ConstU32, Contains, Currency, OnFinalize, OnInitialize, + fungibles::Credit, ConstU128, ConstU32, Contains, Currency, OnFinalize, OnInitialize, }, weights::Weight, PalletId, @@ -54,7 +54,7 @@ construct_runtime!( parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024)); + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); } impl frame_system::Config for Test { @@ -99,6 +99,10 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type MaxHolds = ConstU32<1>; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = [u8; 8]; } parameter_types! { @@ -187,7 +191,7 @@ impl pallet_inv4::fee_handling::MultisigFeeHandler for FeeCharger { fn handle_creation_fee( _imbalance: pallet_inv4::fee_handling::FeeAssetNegativeImbalance< >::NegativeImbalance, - CreditOf, + Credit, >, ) { } @@ -241,6 +245,7 @@ impl pallet_inv4::Config for Test { type Tokens = CoreAssets; type KSMAssetId = KSMAssetId; type KSMCoreCreationFee = CoreCreationFee; + type MaxCallSize = ConstU32<51200>; } impl pallet_ocif_staking::Config for Test { diff --git a/OCIF/staking/src/testing/mod.rs b/OCIF/staking/src/testing/mod.rs index 7df9ad11..bbeff694 100644 --- a/OCIF/staking/src/testing/mod.rs +++ b/OCIF/staking/src/testing/mod.rs @@ -34,9 +34,9 @@ pub(crate) fn assert_register(core: mock::CoreId) { assert_ok!(OcifStaking::register_core( pallet_inv4::Origin::Multisig(pallet_inv4::origin::MultisigInternalOrigin::new(core)) .into(), - vec![], - vec![], - vec![] + vec![].try_into().unwrap(), + vec![].try_into().unwrap(), + vec![].try_into().unwrap() )); let core_info = RegisteredCore::::get(core).unwrap(); diff --git a/OCIF/staking/src/testing/test.rs b/OCIF/staking/src/testing/test.rs index 0c8b66b0..04dbb764 100644 --- a/OCIF/staking/src/testing/test.rs +++ b/OCIF/staking/src/testing/test.rs @@ -229,9 +229,9 @@ fn register_twice_with_same_account_fails() { OcifStaking::register_core( pallet_inv4::Origin::Multisig(pallet_inv4::origin::MultisigInternalOrigin::new(A)) .into(), - Vec::default(), - Vec::default(), - Vec::default() + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap() ), Error::::CoreAlreadyRegistered ); @@ -1974,9 +1974,9 @@ fn pallet_halt_is_ok() { core_id )) .into(), - Vec::default(), - Vec::default(), - Vec::default() + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap() ), Error::::Halted ); @@ -1997,9 +1997,9 @@ fn pallet_halt_is_ok() { core_id )) .into(), - Vec::default(), - Vec::default(), - Vec::default() + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap(), + Vec::default().try_into().unwrap() ), Error::::Halted ); diff --git a/OCIF/staking/src/weights.rs b/OCIF/staking/src/weights.rs index d65bc0d0..76f919ed 100644 --- a/OCIF/staking/src/weights.rs +++ b/OCIF/staking/src/weights.rs @@ -1,9 +1,11 @@ -//! Autogenerated weights for pallet_ocif_staking + +//! Autogenerated weights for `pallet_ocif_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/release/invarch-collator @@ -18,18 +20,18 @@ // 50 // --repeat // 20 - // --heap-pages=4096 // --output=../InvArch-Frames/OCIF/staking/src/weights.rs // --template=weights-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 sp_std::marker::PhantomData; +use core::marker::PhantomData; -/// Weight functions needed for pallet_ocif_staking. +/// Weight functions needed for `pallet_ocif_staking`. pub trait WeightInfo { fn register_core(n: u32, d: u32, i: u32, ) -> Weight; fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight; @@ -42,233 +44,377 @@ pub trait WeightInfo { fn halt_unhalt_pallet() -> Weight; } - /// Weights for pallet_ocif_staking using the Substrate node and recommended hardware. + /// Weights for `pallet_ocif_staking` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(27_973_075) - // Standard Error: 110 - .saturating_add(Weight::from_ref_time(308).saturating_mul(d.into())) - // Standard Error: 330 - .saturating_add(Weight::from_ref_time(587).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + fn register_core(_n: u32, _d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `3942` + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(29_525_844, 3942) + // Standard Error: 641 + .saturating_add(Weight::from_parts(2_603, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(17_755_825) - // Standard Error: 2_487 - .saturating_add(Weight::from_ref_time(16_749).saturating_mul(n.into())) - // Standard Error: 170 - .saturating_add(Weight::from_ref_time(1_909).saturating_mul(d.into())) - // Standard Error: 509 - .saturating_add(Weight::from_ref_time(1_146).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `3942` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(13_415_126, 3942) + // Standard Error: 2_128 + .saturating_add(Weight::from_parts(6_775, 0).saturating_mul(n.into())) + // Standard Error: 145 + .saturating_add(Weight::from_parts(1_501, 0).saturating_mul(d.into())) + // Standard Error: 436 + .saturating_add(Weight::from_parts(3_700, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:0) - // Storage: System Account (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:0) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unregister_core() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(33_000_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `268` + // Estimated: `3942` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(34_000_000, 3942) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:0) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:0) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn stake() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(43_000_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `4764` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(47_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:0) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:0) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn unstake() -> Weight { - // Minimum execution time: 44_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `397` + // Estimated: `4764` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn withdraw_unstaked() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `449` + // Estimated: `4764` + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(70_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:0) - // Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:0) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn staker_claim_rewards() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `374` + // Estimated: `3734` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(26_000_000, 3734) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn core_claim_rewards() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `308` + // Estimated: `3557` + // Minimum execution time: 21_000_000 picoseconds. + Weight::from_parts(22_000_000, 3557) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:1) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn halt_unhalt_pallet() -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `1486` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 1486) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } - // For backwards compatibility and tests + // For backwards compatibility and tests. impl WeightInfo for () { - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(27_973_075) - // Standard Error: 110 - .saturating_add(Weight::from_ref_time(308).saturating_mul(d.into())) - // Standard Error: 330 - .saturating_add(Weight::from_ref_time(587).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + fn register_core(_n: u32, _d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `3942` + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(29_525_844, 3942) + // Standard Error: 641 + .saturating_add(Weight::from_parts(2_603, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(17_755_825) - // Standard Error: 2_487 - .saturating_add(Weight::from_ref_time(16_749).saturating_mul(n.into())) - // Standard Error: 170 - .saturating_add(Weight::from_ref_time(1_909).saturating_mul(d.into())) - // Standard Error: 509 - .saturating_add(Weight::from_ref_time(1_146).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `3942` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(13_415_126, 3942) + // Standard Error: 2_128 + .saturating_add(Weight::from_parts(6_775, 0).saturating_mul(n.into())) + // Standard Error: 145 + .saturating_add(Weight::from_parts(1_501, 0).saturating_mul(d.into())) + // Standard Error: 436 + .saturating_add(Weight::from_parts(3_700, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:0) - // Storage: System Account (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:1) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:0) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unregister_core() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(33_000_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `268` + // Estimated: `3942` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(34_000_000, 3942) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:0) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:0) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn stake() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(43_000_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `4764` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(47_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking RegisteredCore (r:1 w:0) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking RegisteredCore (r:1 w:0) + /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn unstake() -> Weight { - // Minimum execution time: 44_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `397` + // Estimated: `4764` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking Ledger (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking Ledger (r:1 w:1) + /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:0) + /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn withdraw_unstaked() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `449` + // Estimated: `4764` + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(70_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:0) - // Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) + /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:0) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn staker_claim_rewards() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `374` + // Estimated: `3734` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(26_000_000, 3734) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:0) - // Storage: OcifStaking CurrentEra (r:1 w:0) - // Storage: OcifStaking CoreEraStake (r:1 w:1) - // Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Storage: OcifStaking Halted (r:1 w:0) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: OcifStaking CurrentEra (r:1 w:0) + /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: OcifStaking CoreEraStake (r:1 w:1) + /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) + /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) fn core_claim_rewards() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `308` + // Estimated: `3557` + // Minimum execution time: 21_000_000 picoseconds. + Weight::from_parts(22_000_000, 3557) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: OcifStaking Halted (r:1 w:1) + /// Storage: OcifStaking Halted (r:1 w:1) + /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn halt_unhalt_pallet() -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(14_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `1486` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 1486) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/XCA/README.md b/XCA/README.md deleted file mode 100644 index 6ce20476..00000000 --- a/XCA/README.md +++ /dev/null @@ -1,7 +0,0 @@ -[![Compatible with Substrate v3.0.0](https://img.shields.io/badge/Substrate-v3.0.0-E6007A)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) - -# Cross-Chain Authentication (XCA) Substrate FRAME Pallets - -## Features - -### WIP diff --git a/pallet-checked-inflation/Cargo.toml b/pallet-checked-inflation/Cargo.toml index cd06adef..75b6931d 100644 --- a/pallet-checked-inflation/Cargo.toml +++ b/pallet-checked-inflation/Cargo.toml @@ -16,19 +16,21 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } serde = { version = "1.0.140", features = ["derive"], optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } num-traits = { version = "0.2", default-features = false } -pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } + +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } [features] default = ["std"] @@ -48,4 +50,9 @@ std = [ "sp-staking/std", "pallet-balances/std", ] -try-runtime = ["frame-support/try-runtime"] \ No newline at end of file +try-runtime = ["frame-support/try-runtime"] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-system/runtime-benchmarks", +] diff --git a/pallet-checked-inflation/src/benchmarking.rs b/pallet-checked-inflation/src/benchmarking.rs new file mode 100644 index 00000000..e79853ce --- /dev/null +++ b/pallet-checked-inflation/src/benchmarking.rs @@ -0,0 +1,22 @@ +#![cfg(feature = "runtime-benchmarks")] + +use super::*; +use frame_benchmarking::benchmarks; +use frame_system::RawOrigin as SystemOrigin; + +fn assert_last_event(generic_event: ::RuntimeEvent) { + frame_system::Pallet::::assert_last_event(generic_event.into()); +} + +benchmarks! { + set_first_year_supply { + }: _(SystemOrigin::Root) + + halt_unhalt_pallet { + }: _(SystemOrigin::Root, true) + verify { + assert_last_event::(Event::::HaltChanged { + is_halted: true + }.into()); + } +} diff --git a/pallet-checked-inflation/src/lib.rs b/pallet-checked-inflation/src/lib.rs index 60245a57..db0d6222 100644 --- a/pallet-checked-inflation/src/lib.rs +++ b/pallet-checked-inflation/src/lib.rs @@ -6,6 +6,8 @@ use sp_std::convert::TryInto; mod inflation; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; #[cfg(test)] pub(crate) mod mock; @@ -15,6 +17,10 @@ mod test; pub use inflation::*; pub use pallet::*; +pub mod weights; + +pub use weights::WeightInfo; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -56,6 +62,8 @@ pub mod pallet { type Inflation: Get>>; type DealWithInflation: OnUnbalanced>; + + type WeightInfo: WeightInfo; } /// The current era. Starts from 1 and is reset every year. @@ -250,7 +258,9 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight(100_000_000)] + #[pallet::weight( + ::WeightInfo::set_first_year_supply() + )] pub fn set_first_year_supply(root: OriginFor) -> DispatchResult { ensure_root(root)?; @@ -262,7 +272,9 @@ pub mod pallet { } #[pallet::call_index(1)] - #[pallet::weight(100_000_000)] + #[pallet::weight( + ::WeightInfo::halt_unhalt_pallet() + )] pub fn halt_unhalt_pallet(root: OriginFor, halt: bool) -> DispatchResult { ensure_root(root)?; diff --git a/pallet-checked-inflation/src/mock.rs b/pallet-checked-inflation/src/mock.rs index 83d87408..84db2ebd 100644 --- a/pallet-checked-inflation/src/mock.rs +++ b/pallet-checked-inflation/src/mock.rs @@ -72,6 +72,11 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + + type MaxHolds = ConstU32<1>; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = [u8; 8]; } parameter_types! { @@ -95,6 +100,7 @@ impl pallet::Config for Test { type ErasPerYear = ConstU32; type Inflation = Inflation; type DealWithInflation = DealWithInflation; + type WeightInfo = weights::SubstrateWeight; } pub struct ExtBuilder; diff --git a/pallet-checked-inflation/src/weights.rs b/pallet-checked-inflation/src/weights.rs new file mode 100644 index 00000000..ea4b8d77 --- /dev/null +++ b/pallet-checked-inflation/src/weights.rs @@ -0,0 +1,89 @@ + +//! Autogenerated weights for `pallet_checked_inflation` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-08-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` +//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` + +// Executed Command: + // ./target/release/invarch-collator + // benchmark + // pallet + // --chain=dev + // --execution=wasm + // --wasm-execution=compiled + // --pallet=pallet_checked_inflation + // --extrinsic=* + // --steps + // 50 + // --repeat + // 20 + // --output=../InvArch-Frames/pallet-checked-inflation/src/weights.rs + // --template=weights-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_checked_inflation`. +pub trait WeightInfo { + fn set_first_year_supply() -> Weight; + fn halt_unhalt_pallet() -> Weight; + } + + /// Weights for `pallet_checked_inflation` using the Substrate node and recommended hardware. + pub struct SubstrateWeight(PhantomData); + impl WeightInfo for SubstrateWeight { + /// Storage: CheckedInflation YearStartIssuance (r:0 w:1) + /// Proof: CheckedInflation YearStartIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn set_first_year_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_000_000 picoseconds. + Weight::from_parts(4_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: CheckedInflation Halted (r:1 w:1) + /// Proof: CheckedInflation Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1486` + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(10_000_000, 1486) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + } + + // For backwards compatibility and tests. + impl WeightInfo for () { + /// Storage: CheckedInflation YearStartIssuance (r:0 w:1) + /// Proof: CheckedInflation YearStartIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn set_first_year_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_000_000 picoseconds. + Weight::from_parts(4_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: CheckedInflation Halted (r:1 w:1) + /// Proof: CheckedInflation Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1486` + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(10_000_000, 1486) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + } diff --git a/pallet-rings/Cargo.toml b/pallet-rings/Cargo.toml index e8b3e5ee..3896c2c2 100644 --- a/pallet-rings/Cargo.toml +++ b/pallet-rings/Cargo.toml @@ -17,34 +17,34 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } serde = { version = "1.0.140", features = ["derive"], optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } num-traits = { version = "0.2", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false, optional = true } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } pallet-inv4 = { path = "../INV4/pallet-inv4", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.36" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.36" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.36" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.36", default-features = false, optional = true } +frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true, branch = "polkadot-v0.9.43" } [dev-dependencies] -orml-traits2 = { package = "orml-traits", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "4f5a3f34d8cbd98b7bc2e295219a3e7b99b9ecaf" } -orml-traits = { package = "orml-traits", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -orml-tokens2 = { package = "orml-tokens", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "4f5a3f34d8cbd98b7bc2e295219a3e7b99b9ecaf" } -orml-tokens = { package = "orml-tokens", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -orml-asset-registry = { package = "orml-asset-registry", git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.36" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.36" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } [features] default = ["std"] @@ -79,4 +79,4 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", ] -try-runtime = ["frame-support/try-runtime"] \ No newline at end of file +try-runtime = ["frame-support/try-runtime"] diff --git a/pallet-rings/src/benchmarking.rs b/pallet-rings/src/benchmarking.rs index 43011069..3aed5000 100644 --- a/pallet-rings/src/benchmarking.rs +++ b/pallet-rings/src/benchmarking.rs @@ -2,7 +2,7 @@ use super::*; use frame_benchmarking::{benchmarks, whitelisted_caller}; -use frame_support::traits::Get; +use frame_support::{pallet_prelude::Weight, traits::Get, BoundedVec}; use frame_system::RawOrigin as SystemOrigin; use pallet_inv4::origin::{INV4Origin, MultisigInternalOrigin}; use sp_std::{ops::Div, prelude::*, vec}; @@ -43,11 +43,11 @@ benchmarks! { } send_call { - let c in 0 .. T::MaxWeightedLength::get(); + let c in 0 .. T::MaxXCMCallLength::get(); - let call = vec![u8::MAX; c as usize]; + let call: BoundedVec = vec![u8::MAX; c as usize].try_into().unwrap(); let destination = T::Chains::benchmark_mock(); - let weight = 100_000_000u64; + let weight = Weight::from_parts(100_000_000u64, 10_000u64); let fee_asset: <::Chains as ChainList>::ChainAssets = T::Chains::benchmark_mock().get_main_asset(); let fee: u128 = u128::MAX.div(4u128); @@ -56,7 +56,7 @@ benchmarks! { assert_last_event::(Event::CallSent { sender: 0u32.into(), destination, - call, + call: call.to_vec(), }.into()); } diff --git a/pallet-rings/src/lib.rs b/pallet-rings/src/lib.rs index d7462989..056f2486 100644 --- a/pallet-rings/src/lib.rs +++ b/pallet-rings/src/lib.rs @@ -20,11 +20,11 @@ pub use weights::WeightInfo; pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::{ensure_root, pallet_prelude::OriginFor}; + use frame_system::pallet_prelude::OriginFor; use pallet_inv4::origin::{ensure_multisig, INV4Origin}; use sp_std::{vec, vec::Vec}; use xcm::{ - latest::{prelude::*, MultiAsset, WildMultiAsset}, + latest::{prelude::*, MultiAsset, Weight, WildMultiAsset}, DoubleEncoded, }; @@ -41,10 +41,12 @@ pub mod pallet { type ParaId: Get; #[pallet::constant] - type MaxWeightedLength: Get; + type INV4PalletIndex: Get; #[pallet::constant] - type INV4PalletIndex: Get; + type MaxXCMCallLength: Get; + + type MaintenanceOrigin: EnsureOrigin<::RuntimeOrigin>; type WeightInfo: WeightInfo; } @@ -118,7 +120,7 @@ pub mod pallet { chain: ::Chains, under_maintenance: bool, ) -> DispatchResult { - ensure_root(origin)?; + T::MaintenanceOrigin::ensure_origin(origin)?; ChainsUnderMaintenance::::insert(chain.get_location(), under_maintenance); @@ -132,18 +134,15 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight( - ::WeightInfo::send_call( - (call.len() as u32) - .min(T::MaxWeightedLength::get()) - ) + ::WeightInfo::send_call(call.len() as u32) )] pub fn send_call( origin: OriginFor, destination: ::Chains, - weight: u64, + weight: Weight, fee_asset: <::Chains as ChainList>::ChainAssets, fee: u128, - call: Vec, + call: BoundedVec, ) -> DispatchResult { let core = ensure_multisig::>(origin)?; let core_id = core.id.into(); @@ -151,7 +150,7 @@ pub mod pallet { let dest = destination.get_location(); ensure!( - !Self::is_under_maintenance(dest.clone()).unwrap_or(false), + !Self::is_under_maintenance(dest).unwrap_or(false), Error::::ChainUnderMaintenance ); @@ -183,14 +182,13 @@ pub mod pallet { weight_limit: WeightLimit::Unlimited, }, Instruction::Transact { - origin_type: OriginKind::Native, + origin_kind: OriginKind::Native, require_weight_at_most: weight, - call: as From>>::from(call.clone()), + call: as From>>::from(call.clone().to_vec()), }, Instruction::RefundSurplus, Instruction::DepositAsset { assets: MultiAssetFilter::Wild(WildMultiAsset::All), - max_assets: 1, beneficiary, }, ]); @@ -201,7 +199,7 @@ pub mod pallet { Self::deposit_event(Event::CallSent { sender: core.id, destination, - call, + call: call.to_vec(), }); Ok(()) @@ -224,7 +222,7 @@ pub mod pallet { let dest = chain.get_location(); ensure!( - !Self::is_under_maintenance(dest.clone()).unwrap_or(false), + !Self::is_under_maintenance(dest).unwrap_or(false), Error::::ChainUnderMaintenance ); @@ -245,7 +243,7 @@ pub mod pallet { let beneficiary: MultiLocation = MultiLocation { parents: 0, interior: Junctions::X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: to.clone().into(), }), }; @@ -280,7 +278,6 @@ pub mod pallet { Instruction::RefundSurplus, Instruction::DepositAsset { assets: MultiAssetFilter::Wild(WildMultiAsset::All), - max_assets: 1, beneficiary: core_multilocation, }, ]); @@ -320,8 +317,8 @@ pub mod pallet { let dest = destination.get_location(); ensure!( - !(Self::is_under_maintenance(from_chain_location.clone()).unwrap_or(false) - || Self::is_under_maintenance(dest.clone()).unwrap_or(false)), + !(Self::is_under_maintenance(from_chain_location).unwrap_or(false) + || Self::is_under_maintenance(dest).unwrap_or(false)), Error::::ChainUnderMaintenance ); @@ -333,11 +330,9 @@ pub mod pallet { let asset_location = asset.get_asset_location(); let inverted_destination = dest - .inverted(&from_chain_location) + .reanchored(&from_chain_location, *from_chain_location.interior()) .map(|inverted| { - if let (ml, Some(Junction::OnlyChild) | None) = - inverted.clone().split_last_interior() - { + if let (ml, Some(Junction::OnlyChild) | None) = inverted.split_last_interior() { ml } else { inverted @@ -346,23 +341,21 @@ pub mod pallet { .map_err(|_| Error::::FailedToInvertLocation)?; let multiasset = MultiAsset { - id: AssetId::Concrete(asset_location.clone()), + id: AssetId::Concrete(asset_location), fun: Fungibility::Fungible(amount), }; let fee_multiasset = MultiAsset { - id: AssetId::Concrete(asset_location.clone()), + id: AssetId::Concrete(asset_location), fun: Fungibility::Fungible(fee), }; let reanchored_multiasset = multiasset .clone() - .reanchored(&dest, &from_chain_location) + .reanchored(&dest, *from_chain_location.interior()) .map(|mut reanchored| { if let AssetId::Concrete(ref mut m) = reanchored.id { - if let (ml, Some(Junction::OnlyChild) | None) = - m.clone().split_last_interior() - { + if let (ml, Some(Junction::OnlyChild) | None) = (*m).split_last_interior() { *m = ml; } } @@ -374,7 +367,7 @@ pub mod pallet { parents: 0, interior: if let Some(to_inner) = to.clone() { Junctions::X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: to_inner.into(), }) } else { @@ -412,13 +405,11 @@ pub mod pallet { }, Instruction::DepositAsset { assets: All.into(), - max_assets: 1, - beneficiary: beneficiary.clone(), + beneficiary, }, Instruction::RefundSurplus, Instruction::DepositAsset { assets: All.into(), - max_assets: 1, beneficiary, }, ]), @@ -426,7 +417,6 @@ pub mod pallet { Instruction::RefundSurplus, Instruction::DepositAsset { assets: All.into(), - max_assets: 1, beneficiary: core_multilocation, }, ]) @@ -449,7 +439,6 @@ pub mod pallet { }, Instruction::DepositAsset { assets: MultiAssetFilter::Wild(WildMultiAsset::All), - max_assets: 1, beneficiary, }, ]), @@ -458,7 +447,6 @@ pub mod pallet { Instruction::RefundSurplus, Instruction::DepositAsset { assets: MultiAssetFilter::Wild(WildMultiAsset::All), - max_assets: 1, beneficiary: core_multilocation, }, ]) diff --git a/pallet-rings/src/tests/mock.rs b/pallet-rings/src/tests/mock.rs index d6b8491e..fd05c809 100644 --- a/pallet-rings/src/tests/mock.rs +++ b/pallet-rings/src/tests/mock.rs @@ -7,8 +7,8 @@ use core::convert::TryFrom; use frame_support::{ parameter_types, traits::{ - fungibles::CreditOf, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, - EnsureOriginWithArg, Everything, GenesisBuild, + fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, + EnsureOriginWithArg, Everything, GenesisBuild, Nothing, }, }; use frame_system::EnsureRoot; @@ -24,8 +24,8 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::XcmExecutor; @@ -110,6 +110,10 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; + type MaxHolds = ConstU32<1>; + type FreezeIdentifier = (); + type MaxFreezes = (); + type HoldIdentifier = [u8; 8]; } thread_local! { @@ -119,15 +123,24 @@ thread_local! { /// Sender that never returns error, always sends pub struct TestSendXcm; impl SendXcm for TestSendXcm { - fn send_xcm(dest: impl Into, msg: Xcm<()>) -> SendResult { - SENT_XCM.with(|q| q.borrow_mut().push((dest.into(), msg))); - Ok(()) + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let pair = (dest.take().unwrap(), msg.take().unwrap()); + Ok((pair, MultiAssets::new())) + } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result { + let hash = pair.1.using_encoded(sp_io::hashing::blake2_256); + SENT_XCM.with(|q| q.borrow_mut().push(pair)); + Ok(hash) } } parameter_types! { - pub const RelayLocation: MultiLocation = Here.into(); - pub const AnyNetwork: NetworkId = NetworkId::Any; + pub const RelayLocation: MultiLocation = MultiLocation::parent(); + pub const AnyNetwork: Option = None; pub Ancestry: MultiLocation = Here.into(); pub UnitWeightCost: u64 = 1_000; } @@ -144,9 +157,11 @@ type LocalOriginConverter = ( parameter_types! { pub const BaseXcmWeight: u64 = 1_000; - pub CurrencyPerSecond: (xcm::latest::AssetId, u128) = (Concrete(RelayLocation::get()), 1); + pub CurrencyPerSecond: (xcm::latest::AssetId, u128, u128) = (Concrete(RelayLocation::get()), 1, 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; + pub UniversalLocation: InteriorMultiLocation = Here; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type Barrier = ( @@ -164,7 +179,6 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -172,6 +186,16 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type UniversalLocation = UniversalLocation; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; + type PalletInstancesInfo = AllPalletsWithSystem; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } pub type LocalOriginToLocation = SignedToAccountId32; @@ -186,11 +210,20 @@ impl pallet_xcm::Config for Test { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type UniversalLocation = UniversalLocation; + type MaxLockers = frame_support::traits::ConstU32<8>; + type MaxRemoteLockConsumers = frame_support::traits::ConstU32<0>; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type AdminOrigin = EnsureRoot; + type TrustedLockers = (); + type SovereignAccountOf = AccountId32Aliases<(), AccountId32>; + type RemoteLockConsumerIdentifier = (); + type WeightInfo = pallet_xcm::TestWeightInfo; } const UNIT: u128 = 1000000000000; @@ -403,7 +436,7 @@ impl MultisigFeeHandler for FeeCharger { fn handle_creation_fee( _imbalance: FeeAssetNegativeImbalance< >::NegativeImbalance, - CreditOf, + Credit, >, ) { } @@ -428,6 +461,7 @@ impl pallet_inv4::Config for Test { type Tokens = Tokens; type KSMAssetId = RelayAssetId; type KSMCoreCreationFee = KSMCoreCreationFee; + type MaxCallSize = ConstU32<51200>; } parameter_types! { @@ -440,9 +474,10 @@ impl pallet::Config for Test { type RuntimeEvent = RuntimeEvent; type ParaId = ParaId; type Chains = Chains; - type MaxWeightedLength = MaxWeightedLength; type INV4PalletIndex = INV4PalletIndex; type WeightInfo = weights::SubstrateWeight; + type MaxXCMCallLength = ConstU32<100_000>; + type MaintenanceOrigin = EnsureRoot; } #[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, Debug, TypeInfo)] diff --git a/pallet-rings/src/tests/mod.rs b/pallet-rings/src/tests/mod.rs index 9d685011..a15ec3a2 100644 --- a/pallet-rings/src/tests/mod.rs +++ b/pallet-rings/src/tests/mod.rs @@ -6,6 +6,7 @@ use frame_system::RawOrigin; use mock::*; use pallet_inv4::{origin::MultisigInternalOrigin, Origin}; use sp_std::vec; +use xcm::latest::Weight; #[test] fn set_maintenance_status() { @@ -55,10 +56,10 @@ fn send_call_works() { assert_ok!(Rings::send_call( Origin::Multisig(MultisigInternalOrigin::new(0u32)).into(), chain_a.clone(), - 5000000000, + Weight::from_parts(5000000000, 0), fee_asset, 10000000000000u128, - vec![1, 2, 3] + vec![1, 2, 3].try_into().unwrap() )); }) } @@ -74,10 +75,10 @@ fn send_call_fails() { Rings::send_call( RawOrigin::Signed(ALICE).into(), chain_a.clone(), - 5000000000, + Weight::from_parts(5000000000, 0), fee_asset.clone(), 10000000000000u128, - vec![1, 2, 3] + vec![1, 2, 3].try_into().unwrap() ), BadOrigin ); @@ -88,10 +89,10 @@ fn send_call_fails() { Rings::send_call( Origin::Multisig(MultisigInternalOrigin::new(0u32)).into(), chain_a, - 5000000000, + Weight::from_parts(5000000000, 0), fee_asset, 10000000000000u128, - vec![1, 2, 3] + vec![1, 2, 3].try_into().unwrap() ), Error::::ChainUnderMaintenance ); diff --git a/pallet-rings/src/weights.rs b/pallet-rings/src/weights.rs index a01f7b28..747e8534 100644 --- a/pallet-rings/src/weights.rs +++ b/pallet-rings/src/weights.rs @@ -1,9 +1,11 @@ -//! Autogenerated weights for pallet_rings + +//! Autogenerated weights for `pallet_rings` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/release/invarch-collator @@ -24,11 +26,12 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; -/// Weight functions needed for pallet_rings. +/// Weight functions needed for `pallet_rings`. pub trait WeightInfo { fn set_maintenance_status() -> Weight; fn send_call(c: u32, ) -> Weight; @@ -36,89 +39,175 @@ pub trait WeightInfo { fn bridge_assets() -> Weight; } - /// Weights for pallet_rings using the Substrate node and recommended hardware. + /// Weights for `pallet_rings` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Rings ChainsUnderMaintenance (r:0 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:0 w:1) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) fn set_maintenance_status() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[0, 100000]`. fn send_call(c: u32, ) -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_997_080) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_257_805, 4084) // Standard Error: 1 - .saturating_add(Weight::from_ref_time(712).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(2_102, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn transfer_assets() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(24_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4084) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn bridge_assets() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 4084) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } - // For backwards compatibility and tests + // For backwards compatibility and tests. impl WeightInfo for () { - // Storage: Rings ChainsUnderMaintenance (r:0 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:0 w:1) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) fn set_maintenance_status() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_ref_time(14_000_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[0, 100000]`. fn send_call(c: u32, ) -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_997_080) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_257_805, 4084) // Standard Error: 1 - .saturating_add(Weight::from_ref_time(712).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(2_102, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn transfer_assets() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(24_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4084) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Rings ChainsUnderMaintenance (r:1 w:0) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Storage: Rings ChainsUnderMaintenance (r:1 w:0) + /// Proof: Rings ChainsUnderMaintenance (max_values: None, max_size: Some(619), added: 3094, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn bridge_assets() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `4084` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 4084) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 5d2cef24..34ed2dc9 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -14,11 +14,11 @@ serde = { version = "1.0.132", optional = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } [features] @@ -31,4 +31,4 @@ std = [ "sp-std/std", "scale-info/std", "sp-io/std" -] \ No newline at end of file +]