diff --git a/Cargo.lock b/Cargo.lock index 361ea9375a..1a7ef86a5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7430,6 +7430,7 @@ version = "3.3.1" dependencies = [ "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hex-literal", "hydradx-traits", @@ -7678,6 +7679,7 @@ name = "pallet-broadcast" version = "1.0.1" dependencies = [ "frame-support", + "frame-support-procedural", "frame-system", "hydradx-traits", "log", @@ -7890,6 +7892,7 @@ dependencies = [ "cumulus-primitives-core", "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hydra-dx-math", "hydradx-adapters", @@ -8122,6 +8125,7 @@ version = "1.3.5" dependencies = [ "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hydra-dx-math", "hydradx-traits", @@ -8699,6 +8703,7 @@ dependencies = [ "bitflags 1.3.2", "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hydra-dx-math", "hydradx-traits", @@ -8757,6 +8762,7 @@ version = "2.1.1" dependencies = [ "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hydradx-traits", "orml-tokens", @@ -8960,6 +8966,7 @@ version = "2.7.1" dependencies = [ "frame-benchmarking", "frame-support", + "frame-support-procedural", "frame-system", "hydra-dx-math", "hydradx-adapters", diff --git a/Cargo.toml b/Cargo.toml index 1e6c6270df..9f172f48ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,6 +165,7 @@ frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sd frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false, features = ["tuples-96"] } +frame-support-procedural = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "stable2409-patch", default-features = false } diff --git a/pallets/asset-registry/Cargo.toml b/pallets/asset-registry/Cargo.toml index d79776743f..f297a00dee 100644 --- a/pallets/asset-registry/Cargo.toml +++ b/pallets/asset-registry/Cargo.toml @@ -25,6 +25,7 @@ orml-traits = { workspace = true } # Substrate dependencies frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } sp-core = { workspace = true } sp-arithmetic = { workspace = true } @@ -57,6 +58,7 @@ std = [ "serde/std", "codec/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "sp-runtime/std", "sp-core/std", diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 8e2ee29478..b932abf73e 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -59,6 +59,8 @@ use polkadot_xcm::v3::Junctions::X1; use polkadot_xcm::v3::MultiLocation; use sp_runtime::TransactionOutcome; +pub use frame_support_procedural::whitelist_storage; + /// Default value of existential deposit. This value is used if existential deposit wasn't /// provided. pub const DEFAULT_ED: Balance = 1; @@ -225,6 +227,7 @@ pub mod pallet { StorageMap<_, Blake2_128Concat, T::AssetNativeLocation, T::AssetId, OptionQuery>; #[pallet::storage] + #[pallet::whitelist_storage] /// Number of accounts that paid existential deposits for insufficient assets. /// This storage is used by `SufficiencyCheck`. pub type ExistentialDepositCounter = StorageValue<_, u128, ValueQuery>; diff --git a/pallets/broadcast/Cargo.toml b/pallets/broadcast/Cargo.toml index 0329667de7..880e2c1624 100644 --- a/pallets/broadcast/Cargo.toml +++ b/pallets/broadcast/Cargo.toml @@ -26,6 +26,7 @@ sp-api = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } [features] @@ -34,6 +35,7 @@ std = [ "codec/std", "scale-info/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "sp-std/std", "sp-api/std", diff --git a/pallets/broadcast/src/lib.rs b/pallets/broadcast/src/lib.rs index a6abf3adf4..8265dab0fc 100644 --- a/pallets/broadcast/src/lib.rs +++ b/pallets/broadcast/src/lib.rs @@ -39,6 +39,8 @@ const LOG_TARGET: &str = "runtime::amm-support"; type ExecutionIdStack = BoundedVec>; +pub use frame_support_procedural::whitelist_storage; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -57,11 +59,13 @@ pub mod pallet { } #[pallet::storage] + #[pallet::whitelist_storage] /// Next available incremental ID #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; #[pallet::storage] + #[pallet::whitelist_storage] /// Execution context to figure out where the trade is originated from #[pallet::getter(fn execution_context)] pub(super) type ExecutionContext = StorageValue<_, ExecutionIdStack, ValueQuery>; @@ -70,6 +74,7 @@ pub mod pallet { /// After the stack is full, we start to increase the overflow count, /// so we how many times we can ignore the removal from the context. #[pallet::storage] + #[pallet::whitelist_storage] pub(super) type OverflowCount = StorageValue<_, u32, ValueQuery>; #[pallet::error] diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 4c9b69d0cd..0937f26754 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -22,6 +22,7 @@ sp-std = { workspace = true } # FRAME frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } #cumumlus @@ -68,6 +69,7 @@ default = ["std"] std = [ "codec/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "sp-runtime/std", "sp-std/std", diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 3ee813c17e..bf6f678c63 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -126,6 +126,8 @@ pub mod pallet { use hydradx_traits::fee::SwappablePaymentAssetTrader; use hydradx_traits::{NativePriceOracle, PriceOracle}; + pub use frame_support_procedural::whitelist_storage; + use super::*; #[pallet::pallet] @@ -405,6 +407,7 @@ pub mod pallet { /// Id sequencer for schedules #[pallet::storage] + #[pallet::whitelist_storage] #[pallet::getter(fn next_schedule_id)] pub type ScheduleIdSequencer = StorageValue<_, ScheduleId, ValueQuery>; diff --git a/pallets/ema-oracle/Cargo.toml b/pallets/ema-oracle/Cargo.toml index 47fa147117..a853a104e2 100644 --- a/pallets/ema-oracle/Cargo.toml +++ b/pallets/ema-oracle/Cargo.toml @@ -22,6 +22,7 @@ hydra-dx-math = { workspace = true } # Substrate dependencies frame-benchmarking = { workspace = true, optional = true } frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } sp-arithmetic = { workspace = true } sp-core = { workspace = true } @@ -48,6 +49,7 @@ std = [ "serde", "codec/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "frame-benchmarking/std", "log/std", diff --git a/pallets/ema-oracle/src/lib.rs b/pallets/ema-oracle/src/lib.rs index 3e6371009f..116fec7786 100644 --- a/pallets/ema-oracle/src/lib.rs +++ b/pallets/ema-oracle/src/lib.rs @@ -110,6 +110,8 @@ impl BenchmarkHelper for () { } } +pub use frame_support_procedural::whitelist_storage; + #[allow(clippy::type_complexity)] #[frame_support::pallet] pub mod pallet { @@ -165,6 +167,7 @@ pub mod pallet { /// Accumulator for oracle data in current block that will be recorded at the end of the block. #[pallet::storage] + #[pallet::whitelist_storage] #[pallet::getter(fn accumulator)] pub type Accumulator = StorageValue< _, @@ -190,6 +193,7 @@ pub mod pallet { /// Assets that are whitelisted and tracked by the pallet. #[pallet::storage] + #[pallet::whitelist_storage] pub type WhitelistedAssets = StorageValue<_, BoundedBTreeSet<(Source, (AssetId, AssetId)), T::MaxUniqueEntries>, ValueQuery>; diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index c10fc0ef75..5faf9e66e7 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -28,6 +28,7 @@ sp-std = { workspace = true } # FRAME frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } # ORML @@ -63,6 +64,7 @@ std = [ "sp-runtime/std", "sp-std/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "scale-info/std", "sp-core/std", diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 79392a16da..b82dfc2df4 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -124,6 +124,8 @@ pub use weights::WeightInfo; pub type NFTCollectionIdOf = <::NFTHandler as Inspect<::AccountId>>::CollectionId; +pub use frame_support_procedural::whitelist_storage; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -241,6 +243,7 @@ pub mod pallet { pub(super) type Assets = StorageMap<_, Blake2_128Concat, T::AssetId, AssetState>; #[pallet::storage] + #[pallet::whitelist_storage] /// Imbalance of hub asset #[pallet::getter(fn current_imbalance)] pub(super) type HubAssetImbalance = StorageValue<_, SimpleImbalance, ValueQuery>; @@ -252,6 +255,7 @@ pub mod pallet { } #[pallet::storage] + #[pallet::whitelist_storage] /// Tradable state of hub asset. pub(super) type HubAssetTradability = StorageValue<_, Tradability, ValueQuery, DefaultHubAssetTradability>; @@ -263,6 +267,7 @@ pub mod pallet { StorageMap<_, Blake2_128Concat, T::PositionItemId, Position>; #[pallet::storage] + #[pallet::whitelist_storage] #[pallet::getter(fn next_position_id)] /// Position ids sequencer pub(super) type NextPositionId = StorageValue<_, T::PositionItemId, ValueQuery>; diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index d55c226948..96da50f741 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -23,6 +23,7 @@ sp-core = { workspace = true } # FRAME frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } # ORML dependencies @@ -44,6 +45,7 @@ default = ["std"] std = [ "codec/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "sp-runtime/std", "sp-core/std", diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index f62c6e4c09..71073ceb4a 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -66,6 +66,8 @@ pub type NamedReserveIdentifier = [u8; 8]; pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; +pub use frame_support_procedural::whitelist_storage; + #[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen)] pub struct Order { pub owner: AccountId, @@ -180,6 +182,7 @@ pub mod pallet { /// ID sequencer for Orders #[pallet::storage] + #[pallet::whitelist_storage] #[pallet::getter(fn next_order_id)] pub type NextOrderId = StorageValue<_, OrderId, ValueQuery>; diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index 2a6e8269f3..1d180162b7 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -24,6 +24,7 @@ orml-traits = { workspace = true } # Substrate dependencies frame-benchmarking = { workspace = true, optional = true } frame-support = { workspace = true } +frame-support-procedural = { workspace = true } frame-system = { workspace = true } sp-std = { workspace = true } sp-core = { workspace = true } @@ -51,6 +52,7 @@ std = [ "scale-info/std", "sp-std/std", "frame-support/std", + "frame-support-procedural/std", "frame-system/std", "orml-tokens/std", "orml-traits/std", diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index eb8f313c06..a03b60f105 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -60,6 +60,8 @@ pub use pallet::*; pub const MAX_NUMBER_OF_TRADES: u32 = 5; +pub use frame_support_procedural::whitelist_storage; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -175,6 +177,7 @@ pub mod pallet { ///Flag to indicate when to skip ED handling #[pallet::storage] + #[pallet::whitelist_storage] #[pallet::getter(fn last_trade_position)] pub type SkipEd = StorageValue<_, types::SkipEd, OptionQuery>; diff --git a/runtime/hydradx/src/benchmarking/omnipool.rs b/runtime/hydradx/src/benchmarking/omnipool.rs index de26b072c5..08a18c0952 100644 --- a/runtime/hydradx/src/benchmarking/omnipool.rs +++ b/runtime/hydradx/src/benchmarking/omnipool.rs @@ -87,6 +87,8 @@ runtime_benchmarks! { // Register new asset in asset registry let token_id = register_asset(b"FCK".to_vec(), Balance::one()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + log::info!(target: "benchmark", "Token ID: {}", token_id); + // Create account for token provider and set balance let owner: AccountId = account("owner", 0, 1); @@ -188,6 +190,8 @@ runtime_benchmarks! { // Create account for token provider and set balance let owner: AccountId = account("owner", 0, 1); + log::info!(target: "benchmark", "Token ID: {}", token_id); + let token_price = FixedU128::from((1,5)); let token_amount = 200_000_000_000_000_u128; diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index c40b3c1dec..0786d9511c 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -1047,7 +1047,6 @@ impl_runtime_apis! { use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark; let mut list = Vec::::new(); - list_benchmarks!(list, extra); orml_list_benchmark!(list, extra, pallet_currencies, benchmarking::currencies); @@ -1170,7 +1169,10 @@ impl_runtime_apis! { } } - let whitelist: Vec = vec![ + use frame_support::traits::WhitelistedStorageKeys; + let mut whitelisted_storage = AllPalletsWithSystem::whitelisted_storage_keys(); + let mut whitelist: Vec = vec![ + // --- Might wanna delete as it should be part of whitelisted storage already --- // // Block Number hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), // Total Issuance @@ -1181,7 +1183,15 @@ impl_runtime_apis! { hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), // System Events hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), + // --- Speed --- // + // Omnipool assets 0 + hex!("97bd8c21bba825270fe6b1b8b3961ac3682a59d51ab9e48a8c8cc418ff9708d211d2df4e979aa105cf552e9544ebd2b500000000").to_vec().into(), + // Omnipool assets 2 + hex!("97bd8c21bba825270fe6b1b8b3961ac3682a59d51ab9e48a8c8cc418ff9708d2754faa9acf0378f8c3543d9f132d85bc02000000").to_vec().into(), + // Omnipool 100001 (benchmarking) + hex!("97bd8c21bba825270fe6b1b8b3961ac3682a59d51ab9e48a8c8cc418ff9708d266bc47c64821db8bf16ce3409f3b26cd41420f00").to_vec().into(), ]; + whitelist.append(&mut whitelisted_storage); let mut batches = Vec::::new(); let params = (&config, &whitelist); @@ -1202,6 +1212,7 @@ impl_runtime_apis! { orml_add_benchmark!(params, batches, pallet_omnipool_liquidity_mining, benchmarking::omnipool_liquidity_mining); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) } }