From f2c3a2a37fcf05ba977e8edac048bf7c8fabee2c Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 25 Oct 2023 14:48:27 -0700 Subject: [PATCH 01/14] schemas: PoV compatible changes --- Cargo.lock | 1 + common/primitives/src/schema.rs | 17 ++ e2e/package-lock.json | 2 +- pallets/messages/src/lib.rs | 4 +- pallets/messages/src/tests/mock.rs | 11 ++ pallets/messages/src/weights.rs | 106 ++++++------ pallets/schemas/Cargo.toml | 1 + pallets/schemas/src/benchmarking.rs | 6 +- pallets/schemas/src/lib.rs | 69 ++++++-- pallets/schemas/src/types.rs | 11 ++ pallets/schemas/src/weights.rs | 126 +++++++------- pallets/stateful-storage/src/lib.rs | 8 +- pallets/stateful-storage/src/tests/mock.rs | 16 +- pallets/stateful-storage/src/weights.rs | 182 ++++++++++----------- 14 files changed, 336 insertions(+), 224 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 050c69de53..3cf7a47e7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6910,6 +6910,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "numtoa", "pallet-collective", "parity-scale-codec", diff --git a/common/primitives/src/schema.rs b/common/primitives/src/schema.rs index 0dfbe0c2b7..1d729c79c7 100644 --- a/common/primitives/src/schema.rs +++ b/common/primitives/src/schema.rs @@ -73,10 +73,27 @@ pub struct SchemaResponse { pub settings: Vec, } +/// RPC Response form for a Schema Info +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq)] +pub struct SchemaInfoResponse { + /// The unique identifier for this Schema + pub schema_id: SchemaId, + /// The model format type for how the schema model is represented + pub model_type: ModelType, + /// The payload location + pub payload_location: PayloadLocation, + /// grants for the schema + pub settings: Vec, +} + /// This allows other pallets to resolve Schema information. With generic SchemaId pub trait SchemaProvider { /// Gets the Schema details associated with this `SchemaId` if any fn get_schema_by_id(schema_id: SchemaId) -> Option; + + /// Gets the Schema Info associated with this `SchemaId` if any + fn get_schema_info_by_id(schema_id: SchemaId) -> Option; } /// This allows other Pallets to check validity of schema ids. diff --git a/e2e/package-lock.json b/e2e/package-lock.json index c4a1611fdd..a858678f52 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -261,7 +261,7 @@ "node_modules/@frequency-chain/api-augment": { "version": "0.0.0", "resolved": "file:../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz", - "integrity": "sha512-aKaQC7Kzg34El/fP+yhPTnOEjxWk1lTMh6JiPuzMaludLfPEb+fiVFsx77KyMKiLGWWtIeB8luXRx/EWjaWrzw==", + "integrity": "sha512-QZ07GKhcVuIKzXh3ho8Tvlu3/VenNeyGZ9i+x7n2WFRxbvM9KqR0wF08YNFd/YOuoHbBXX8jw0LCH87Jz4lxzg==", "license": "Apache-2.0", "dependencies": { "@polkadot/api": "^10.9.1", diff --git a/pallets/messages/src/lib.rs b/pallets/messages/src/lib.rs index e89010827f..8a429f6008 100644 --- a/pallets/messages/src/lib.rs +++ b/pallets/messages/src/lib.rs @@ -230,7 +230,7 @@ pub mod pallet { .try_into() .map_err(|_| Error::::ExceedsMaxMessagePayloadSizeBytes)?; - if let Some(schema) = T::SchemaProvider::get_schema_by_id(schema_id) { + if let Some(schema) = T::SchemaProvider::get_schema_info_by_id(schema_id) { ensure!( schema.payload_location == PayloadLocation::IPFS, Error::::InvalidPayloadLocation @@ -283,7 +283,7 @@ pub mod pallet { let bounded_payload: BoundedVec = payload.try_into().map_err(|_| Error::::ExceedsMaxMessagePayloadSizeBytes)?; - if let Some(schema) = T::SchemaProvider::get_schema_by_id(schema_id) { + if let Some(schema) = T::SchemaProvider::get_schema_info_by_id(schema_id) { ensure!( schema.payload_location == PayloadLocation::OnChain, Error::::InvalidPayloadLocation diff --git a/pallets/messages/src/tests/mock.rs b/pallets/messages/src/tests/mock.rs index afcafdbde5..bd10fb314c 100644 --- a/pallets/messages/src/tests/mock.rs +++ b/pallets/messages/src/tests/mock.rs @@ -213,6 +213,17 @@ impl SchemaProvider for SchemaHandler { settings: Vec::new(), }) } + + fn get_schema_info_by_id(schema_id: u16) -> Option { + Self::get_schema_by_id(schema_id).and_then(|schema| { + Some(SchemaInfoResponse { + schema_id: schema.schema_id, + settings: schema.settings, + model_type: schema.model_type, + payload_location: schema.payload_location, + }) + }) + } } impl pallet_messages::Config for Test { diff --git a/pallets/messages/src/weights.rs b/pallets/messages/src/weights.rs index ae18564f25..992a65ea87 100644 --- a/pallets/messages/src/weights.rs +++ b/pallets/messages/src/weights.rs @@ -18,10 +18,10 @@ //! Autogenerated weights for pallet_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-07, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-qpqf8-fp5d5`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 +//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: // ./scripts/../target/bench-dev/frequency @@ -56,38 +56,38 @@ pub trait WeightInfo { /// Weights for pallet_messages using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Schemas Schemas (r:1 w:0) - /// Proof: Schemas Schemas (max_values: None, max_size: Some(65518), added: 67993, mode: Measured) - /// Storage: Msa PublicKeyToMsaId (r:1 w:0) - /// Proof: Msa PublicKeyToMsaId (max_values: None, max_size: Some(48), added: 2523, mode: Measured) - /// Storage: Msa DelegatorAndProviderToDelegation (r:1 w:0) - /// Proof: Msa DelegatorAndProviderToDelegation (max_values: None, max_size: Some(217), added: 2692, mode: Measured) - /// Storage: Messages Messages (r:1 w:1) - /// Proof: Messages Messages (max_values: None, max_size: Some(771174), added: 773649, mode: Measured) - /// The range of component `n` is `[0, 5119]`. + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) + /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `Measured`) + /// Storage: `Messages::Messages` (r:1 w:1) + /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `7339` - // Estimated: `19714` - // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(179_112_822, 19714) - // Standard Error: 35 - .saturating_add(Weight::from_parts(459, 0).saturating_mul(n.into())) + // Measured: `9623` + // Estimated: `21998` + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(48_931_384, 21998) + // Standard Error: 358 + .saturating_add(Weight::from_parts(560, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Schemas Schemas (r:1 w:0) - /// Proof: Schemas Schemas (max_values: None, max_size: Some(65518), added: 67993, mode: Measured) - /// Storage: Msa PublicKeyToMsaId (r:1 w:0) - /// Proof: Msa PublicKeyToMsaId (max_values: None, max_size: Some(48), added: 2523, mode: Measured) - /// Storage: Messages Messages (r:1 w:1) - /// Proof: Messages Messages (max_values: None, max_size: Some(771174), added: 773649, mode: Measured) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Storage: `Messages::Messages` (r:1 w:1) + /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `6183` - // Estimated: `18558` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(174_485_000, 18558) + // Measured: `7833` + // Estimated: `20208` + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(48_000_000, 20208) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -95,38 +95,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Schemas Schemas (r:1 w:0) - /// Proof: Schemas Schemas (max_values: None, max_size: Some(65518), added: 67993, mode: Measured) - /// Storage: Msa PublicKeyToMsaId (r:1 w:0) - /// Proof: Msa PublicKeyToMsaId (max_values: None, max_size: Some(48), added: 2523, mode: Measured) - /// Storage: Msa DelegatorAndProviderToDelegation (r:1 w:0) - /// Proof: Msa DelegatorAndProviderToDelegation (max_values: None, max_size: Some(217), added: 2692, mode: Measured) - /// Storage: Messages Messages (r:1 w:1) - /// Proof: Messages Messages (max_values: None, max_size: Some(771174), added: 773649, mode: Measured) - /// The range of component `n` is `[0, 5119]`. + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) + /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `Measured`) + /// Storage: `Messages::Messages` (r:1 w:1) + /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `7339` - // Estimated: `19714` - // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(179_112_822, 19714) - // Standard Error: 35 - .saturating_add(Weight::from_parts(459, 0).saturating_mul(n.into())) + // Measured: `9623` + // Estimated: `21998` + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(48_931_384, 21998) + // Standard Error: 358 + .saturating_add(Weight::from_parts(560, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Schemas Schemas (r:1 w:0) - /// Proof: Schemas Schemas (max_values: None, max_size: Some(65518), added: 67993, mode: Measured) - /// Storage: Msa PublicKeyToMsaId (r:1 w:0) - /// Proof: Msa PublicKeyToMsaId (max_values: None, max_size: Some(48), added: 2523, mode: Measured) - /// Storage: Messages Messages (r:1 w:1) - /// Proof: Messages Messages (max_values: None, max_size: Some(771174), added: 773649, mode: Measured) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Storage: `Messages::Messages` (r:1 w:1) + /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `6183` - // Estimated: `18558` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(174_485_000, 18558) + // Measured: `7833` + // Estimated: `20208` + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(48_000_000, 20208) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/pallets/schemas/Cargo.toml b/pallets/schemas/Cargo.toml index 2044460967..647d80dfdd 100644 --- a/pallets/schemas/Cargo.toml +++ b/pallets/schemas/Cargo.toml @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } +log = { version = "0.4.17", default-features = false } frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", optional = true, branch = "polkadot-v1.0.0" } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } diff --git a/pallets/schemas/src/benchmarking.rs b/pallets/schemas/src/benchmarking.rs index aebf8da2a7..b968ebee9a 100644 --- a/pallets/schemas/src/benchmarking.rs +++ b/pallets/schemas/src/benchmarking.rs @@ -42,7 +42,7 @@ benchmarks! { }: _(RawOrigin::Signed(sender), schema_input, model_type, payload_location) verify { ensure!(SchemasPallet::::get_current_schema_identifier_maximum() > 0, "Created schema count should be > 0"); - ensure!(SchemasPallet::::get_schema(1).is_some(), "Created schema should exist"); + ensure!(SchemasPallet::::get_schema_info(1).is_some(), "Created schema should exist"); } create_schema_via_governance { @@ -55,7 +55,7 @@ benchmarks! { }: _(RawOrigin::Root, sender.clone(), schema_input, model_type, payload_location, BoundedVec::default()) verify { ensure!(SchemasPallet::::get_current_schema_identifier_maximum() > 0, "Created schema count should be > 0"); - ensure!(SchemasPallet::::get_schema(1).is_some(), "Created schema should exist"); + ensure!(SchemasPallet::::get_schema_info(1).is_some(), "Created schema should exist"); } propose_to_create_schema { @@ -80,7 +80,7 @@ benchmarks! { }: _(RawOrigin::Signed(sender), schema_input, model_type, payload_location, BoundedVec::default()) verify { ensure!(SchemasPallet::::get_current_schema_identifier_maximum() > 0, "Created schema count should be > 0"); - ensure!(SchemasPallet::::get_schema(1).is_some(), "Created schema should exist"); + ensure!(SchemasPallet::::get_schema_info(1).is_some(), "Created schema should exist"); } set_max_schema_model_bytes { diff --git a/pallets/schemas/src/lib.rs b/pallets/schemas/src/lib.rs index 6a2d6c6575..c7e0c03ae8 100644 --- a/pallets/schemas/src/lib.rs +++ b/pallets/schemas/src/lib.rs @@ -75,6 +75,7 @@ mod tests; mod benchmarking; #[cfg(feature = "runtime-benchmarks")] use common_primitives::benchmarks::SchemaBenchmarkHelper; +use common_primitives::schema::SchemaInfoResponse; mod types; @@ -197,13 +198,34 @@ pub mod pallet { OptionQuery, >; + /// Storage for message schema info struct data + /// - Key: Schema Id + /// - Value: [`SchemaInfo`](SchemaInfo) + #[pallet::storage] + #[pallet::getter(fn get_schema_info)] + pub(super) type SchemaInfos = + StorageMap<_, Twox64Concat, SchemaId, SchemaInfo, OptionQuery>; + + /// Storage for message schema struct data + /// - Key: Schema Id + /// - Value: [`BoundedVec`](BoundedVec) + #[pallet::storage] + #[pallet::getter(fn get_schema_payload)] + pub(super) type SchemaPayloads = StorageMap< + _, + Twox64Concat, + SchemaId, + BoundedVec, + OptionQuery, + >; + #[pallet::genesis_config] pub struct GenesisConfig { /// Maximum schema size in bytes at genesis pub initial_max_schema_model_size: u32, /// Phantom type #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: PhantomData, } impl sp_std::default::Default for GenesisConfig { @@ -398,23 +420,46 @@ pub mod pallet { set_settings.set(i); } } - let schema = Schema { model_type, model, payload_location, settings: set_settings }; + let schema_info = SchemaInfo { model_type, payload_location, settings: set_settings }; >::set(schema_id); - >::insert(schema_id, schema); + >::insert(schema_id, schema_info); + >::insert(schema_id, model); Ok(schema_id) } /// Retrieve a schema by id pub fn get_schema_by_id(schema_id: SchemaId) -> Option { - if let Some(schema) = Self::get_schema(schema_id) { - let model_vec: Vec = schema.model.into_inner(); - let saved_settings = schema.settings; + match (Self::get_schema_info(schema_id), Self::get_schema_payload(schema_id)) { + (Some(schema_info), Some(payload)) => { + let model_vec: Vec = payload.into_inner(); + let saved_settings = schema_info.settings; + let settings = saved_settings.0.iter().collect::>(); + let response = SchemaResponse { + schema_id, + model: model_vec, + model_type: schema_info.model_type, + payload_location: schema_info.payload_location, + settings, + }; + Some(response) + }, + (None, Some(_)) | (Some(_), None) => { + log::error!("Corrupted state for schema {:?}, Should never happen!", schema_id); + None + }, + (None, None) => None, + } + } + + /// Retrieve a schema info by id + pub fn get_schema_info_by_id(schema_id: SchemaId) -> Option { + if let Some(schema_info) = Self::get_schema_info(schema_id) { + let saved_settings = schema_info.settings; let settings = saved_settings.0.iter().collect::>(); - let response = SchemaResponse { + let response = SchemaInfoResponse { schema_id, - model: model_vec, - model_type: schema.model_type, - payload_location: schema.payload_location, + model_type: schema_info.model_type, + payload_location: schema_info.payload_location, settings, }; return Some(response) @@ -532,4 +577,8 @@ impl SchemaProvider for Pallet { fn get_schema_by_id(schema_id: SchemaId) -> Option { Self::get_schema_by_id(schema_id) } + + fn get_schema_info_by_id(schema_id: SchemaId) -> Option { + Self::get_schema_info_by_id(schema_id) + } } diff --git a/pallets/schemas/src/types.rs b/pallets/schemas/src/types.rs index e0a99af945..13bbff7716 100644 --- a/pallets/schemas/src/types.rs +++ b/pallets/schemas/src/types.rs @@ -28,3 +28,14 @@ where /// additional control settings for the schema pub settings: SchemaSettings, } + +#[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)] +/// A structure defining a Schema information (excluding the payload) +pub struct SchemaInfo { + /// The type of model (AvroBinary, Parquet, etc.) + pub model_type: ModelType, + /// The payload location + pub payload_location: PayloadLocation, + /// additional control settings for the schema + pub settings: SchemaSettings, +} diff --git a/pallets/schemas/src/weights.rs b/pallets/schemas/src/weights.rs index faffb78dcd..2d113d9cbf 100644 --- a/pallets/schemas/src/weights.rs +++ b/pallets/schemas/src/weights.rs @@ -18,13 +18,13 @@ //! Autogenerated weights for pallet_schemas //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-23, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-wh5db`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: -// ./scripts/../target/release/frequency +// ./scripts/../target/bench-dev/frequency // benchmark // pallet // --pallet=pallet_schemas @@ -63,37 +63,41 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_247_000 picoseconds. - Weight::from_parts(70_723_144, 10399) - // Standard Error: 1_141 - .saturating_add(Weight::from_parts(36_724, 0).saturating_mul(m.into())) + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(19_699_735, 10399) + // Standard Error: 38 + .saturating_add(Weight::from_parts(33_567, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:1 w:0) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_via_governance(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 13_915_000 picoseconds. - Weight::from_parts(14_145_000, 10399) - // Standard Error: 107 - .saturating_add(Weight::from_parts(35_578, 0).saturating_mul(m.into())) + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(16_019_348, 10399) + // Standard Error: 40 + .saturating_add(Weight::from_parts(33_685, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Council::Members` (r:1 w:0) /// Proof: `Council::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -110,10 +114,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_821_000 picoseconds. - Weight::from_parts(9_711_070, 12605) - // Standard Error: 41 - .saturating_add(Weight::from_parts(3_289, 0).saturating_mul(m.into())) + // Minimum execution time: 20_000_000 picoseconds. + Weight::from_parts(19_576_769, 12605) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_662, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -121,19 +125,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_v2(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_318_000 picoseconds. - Weight::from_parts(14_442_000, 10399) - // Standard Error: 76 - .saturating_add(Weight::from_parts(35_708, 0).saturating_mul(m.into())) + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(22_363_353, 10399) + // Standard Error: 61 + .saturating_add(Weight::from_parts(33_609, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:0 w:1) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -141,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_742_000 picoseconds. - Weight::from_parts(7_240_000, 0) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(7_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -153,37 +159,41 @@ impl WeightInfo for () { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_247_000 picoseconds. - Weight::from_parts(70_723_144, 10399) - // Standard Error: 1_141 - .saturating_add(Weight::from_parts(36_724, 0).saturating_mul(m.into())) + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(19_699_735, 10399) + // Standard Error: 38 + .saturating_add(Weight::from_parts(33_567, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:1 w:0) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_via_governance(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 13_915_000 picoseconds. - Weight::from_parts(14_145_000, 10399) - // Standard Error: 107 - .saturating_add(Weight::from_parts(35_578, 0).saturating_mul(m.into())) + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(16_019_348, 10399) + // Standard Error: 40 + .saturating_add(Weight::from_parts(33_685, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Council::Members` (r:1 w:0) /// Proof: `Council::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -200,10 +210,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_821_000 picoseconds. - Weight::from_parts(9_711_070, 12605) - // Standard Error: 41 - .saturating_add(Weight::from_parts(3_289, 0).saturating_mul(m.into())) + // Minimum execution time: 20_000_000 picoseconds. + Weight::from_parts(19_576_769, 12605) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_662, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -211,19 +221,21 @@ impl WeightInfo for () { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_v2(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_318_000 picoseconds. - Weight::from_parts(14_442_000, 10399) - // Standard Error: 76 - .saturating_add(Weight::from_parts(35_708, 0).saturating_mul(m.into())) + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(22_363_353, 10399) + // Standard Error: 61 + .saturating_add(Weight::from_parts(33_609, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:0 w:1) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -231,8 +243,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_742_000 picoseconds. - Weight::from_parts(7_240_000, 0) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(7_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/stateful-storage/src/lib.rs b/pallets/stateful-storage/src/lib.rs index 31e02a9253..4c3dd6a513 100644 --- a/pallets/stateful-storage/src/lib.rs +++ b/pallets/stateful-storage/src/lib.rs @@ -73,7 +73,7 @@ use common_primitives::{ DelegatorId, MessageSourceId, MsaLookup, MsaValidator, ProviderId, SchemaGrantValidator, }, node::Verify, - schema::{PayloadLocation, SchemaId, SchemaProvider, SchemaResponse, SchemaSetting}, + schema::{PayloadLocation, SchemaId, SchemaInfoResponse, SchemaProvider, SchemaSetting}, stateful_storage::{ ItemizedStoragePageResponse, ItemizedStorageResponse, PageHash, PageId, PaginatedStorageResponse, @@ -697,9 +697,9 @@ impl Pallet { fn check_schema_for_read( schema_id: SchemaId, expected_payload_location: PayloadLocation, - ) -> Result { - let schema = - T::SchemaProvider::get_schema_by_id(schema_id).ok_or(Error::::InvalidSchemaId)?; + ) -> Result { + let schema = T::SchemaProvider::get_schema_info_by_id(schema_id) + .ok_or(Error::::InvalidSchemaId)?; // Ensure that the schema's payload location matches the expected location. ensure!( diff --git a/pallets/stateful-storage/src/tests/mock.rs b/pallets/stateful-storage/src/tests/mock.rs index abfce4f839..aff6be3370 100644 --- a/pallets/stateful-storage/src/tests/mock.rs +++ b/pallets/stateful-storage/src/tests/mock.rs @@ -11,7 +11,10 @@ use common_primitives::{ ProviderId, ProviderLookup, SchemaGrantValidator, }, node::AccountId, - schema::{ModelType, PayloadLocation, SchemaId, SchemaProvider, SchemaResponse, SchemaSetting}, + schema::{ + ModelType, PayloadLocation, SchemaId, SchemaInfoResponse, SchemaProvider, SchemaResponse, + SchemaSetting, + }, }; use frame_support::{ dispatch::DispatchResult, @@ -251,6 +254,17 @@ impl SchemaProvider for SchemaHandler { }), } } + + fn get_schema_info_by_id(schema_id: SchemaId) -> Option { + Self::get_schema_by_id(schema_id).and_then(|schema| { + Some(SchemaInfoResponse { + schema_id: schema.schema_id, + settings: schema.settings, + model_type: schema.model_type, + payload_location: schema.payload_location, + }) + }) + } } impl Clone for MaxPaginatedPageId { diff --git a/pallets/stateful-storage/src/weights.rs b/pallets/stateful-storage/src/weights.rs index 2454332792..b89511fb3c 100644 --- a/pallets/stateful-storage/src/weights.rs +++ b/pallets/stateful-storage/src/weights.rs @@ -18,13 +18,13 @@ //! Autogenerated weights for pallet_stateful_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-10, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-4nbbq`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: -// ./scripts/../target/release/frequency +// ./scripts/../target/bench-dev/frequency // benchmark // pallet // --pallet=pallet_stateful-storage @@ -60,8 +60,8 @@ pub trait WeightInfo { /// Weights for pallet_stateful_storage using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -71,17 +71,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 5121]`. fn apply_item_actions(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33370` - // Estimated: `45745` - // Minimum execution time: 96_061_000 picoseconds. - Weight::from_parts(94_653_993, 45745) - // Standard Error: 393 - .saturating_add(Weight::from_parts(7_470, 0).saturating_mul(s.into())) + // Measured: `33346` + // Estimated: `45721` + // Minimum execution time: 72_000_000 picoseconds. + Weight::from_parts(79_317_723, 45721) + // Standard Error: 495 + .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -91,17 +91,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 1024]`. fn upsert_page(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `416` - // Estimated: `12791` - // Minimum execution time: 30_016_000 picoseconds. - Weight::from_parts(31_656_787, 12791) - // Standard Error: 218 - .saturating_add(Weight::from_parts(12, 0).saturating_mul(s.into())) + // Measured: `392` + // Estimated: `12767` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_689_993, 12767) + // Standard Error: 240 + .saturating_add(Weight::from_parts(670, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -110,61 +110,59 @@ impl WeightInfo for SubstrateWeight { /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page() -> Weight { // Proof Size summary in bytes: - // Measured: `1575` - // Estimated: `13950` - // Minimum execution time: 37_076_000 picoseconds. - Weight::from_parts(38_198_000, 13950) + // Measured: `1551` + // Estimated: `13926` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 13926) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// Proof: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// The range of component `s` is `[1, 5121]`. fn apply_item_actions_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33377` - // Estimated: `45752` - // Minimum execution time: 157_055_000 picoseconds. - Weight::from_parts(158_666_683, 45752) - // Standard Error: 849 - .saturating_add(Weight::from_parts(13_079, 0).saturating_mul(s.into())) + // Measured: `33353` + // Estimated: `45728` + // Minimum execution time: 108_000_000 picoseconds. + Weight::from_parts(109_366_646, 45728) + // Standard Error: 645 + .saturating_add(Weight::from_parts(11_660, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. - fn upsert_page_with_signature(s: u32, ) -> Weight { + fn upsert_page_with_signature(_s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349` - // Estimated: `12724` - // Minimum execution time: 84_073_000 picoseconds. - Weight::from_parts(86_255_728, 12724) - // Standard Error: 566 - .saturating_add(Weight::from_parts(7_183, 0).saturating_mul(s.into())) + // Measured: `325` + // Estimated: `12700` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(73_626_300, 12700) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page_with_signature() -> Weight { // Proof Size summary in bytes: - // Measured: `1508` - // Estimated: `13883` - // Minimum execution time: 86_499_000 picoseconds. - Weight::from_parts(88_747_000, 13883) + // Measured: `1484` + // Estimated: `13859` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(67_000_000, 13859) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -172,8 +170,8 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -183,17 +181,17 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 5121]`. fn apply_item_actions(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33370` - // Estimated: `45745` - // Minimum execution time: 96_061_000 picoseconds. - Weight::from_parts(94_653_993, 45745) - // Standard Error: 393 - .saturating_add(Weight::from_parts(7_470, 0).saturating_mul(s.into())) + // Measured: `33346` + // Estimated: `45721` + // Minimum execution time: 72_000_000 picoseconds. + Weight::from_parts(79_317_723, 45721) + // Standard Error: 495 + .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -203,17 +201,17 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 1024]`. fn upsert_page(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `416` - // Estimated: `12791` - // Minimum execution time: 30_016_000 picoseconds. - Weight::from_parts(31_656_787, 12791) - // Standard Error: 218 - .saturating_add(Weight::from_parts(12, 0).saturating_mul(s.into())) + // Measured: `392` + // Estimated: `12767` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_689_993, 12767) + // Standard Error: 240 + .saturating_add(Weight::from_parts(670, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -222,61 +220,59 @@ impl WeightInfo for () { /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page() -> Weight { // Proof Size summary in bytes: - // Measured: `1575` - // Estimated: `13950` - // Minimum execution time: 37_076_000 picoseconds. - Weight::from_parts(38_198_000, 13950) + // Measured: `1551` + // Estimated: `13926` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 13926) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// Proof: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// The range of component `s` is `[1, 5121]`. fn apply_item_actions_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33377` - // Estimated: `45752` - // Minimum execution time: 157_055_000 picoseconds. - Weight::from_parts(158_666_683, 45752) - // Standard Error: 849 - .saturating_add(Weight::from_parts(13_079, 0).saturating_mul(s.into())) + // Measured: `33353` + // Estimated: `45728` + // Minimum execution time: 108_000_000 picoseconds. + Weight::from_parts(109_366_646, 45728) + // Standard Error: 645 + .saturating_add(Weight::from_parts(11_660, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. - fn upsert_page_with_signature(s: u32, ) -> Weight { + fn upsert_page_with_signature(_s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349` - // Estimated: `12724` - // Minimum execution time: 84_073_000 picoseconds. - Weight::from_parts(86_255_728, 12724) - // Standard Error: 566 - .saturating_add(Weight::from_parts(7_183, 0).saturating_mul(s.into())) + // Measured: `325` + // Estimated: `12700` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(73_626_300, 12700) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page_with_signature() -> Weight { // Proof Size summary in bytes: - // Measured: `1508` - // Estimated: `13883` - // Minimum execution time: 86_499_000 picoseconds. - Weight::from_parts(88_747_000, 13883) + // Measured: `1484` + // Estimated: `13859` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(67_000_000, 13859) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From 7c90126a92dbf39540e323d151cf53f9fad7226a Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 25 Oct 2023 15:07:34 -0700 Subject: [PATCH 02/14] Run benchmarks [run-benchmarks schemas,messages,stateful-storage] --- designdocs/schema_v2.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 designdocs/schema_v2.md diff --git a/designdocs/schema_v2.md b/designdocs/schema_v2.md new file mode 100644 index 0000000000..00fa9888b3 --- /dev/null +++ b/designdocs/schema_v2.md @@ -0,0 +1,41 @@ +# On Chain Message Storage + +## Context and Scope +The proposed feature consists of changes that is going to be one (or more) pallet(s) in runtime of a +Substrate based blockchain, and it will be used in all environments including production. + +## Problem Statement +After introduction of **Proof of Validity** or **PoV** in runtime weights, all pallets should be +re-evaluated and refactored if necessary to minimize the usage of **PoV**. This is to ensure all +important operations are scalable. +This document tries to propose some changes on **Schemas** pallet to optimize the **PoV** size. + +## Goals +- Minimizing Weights including **execution times** and **PoV** size. + +## Proposal +Split Schemas into `SchemaInfo` and `payload` would allow lower **PoV** when verifying schema existence +or compatibility. + +### Main Storage types +- **SchemaInfos** + - _Type_: `StorageMap` + - _Purpose_: Main structure To store related properties of any schema + index +- **SchemaPayloads** + - _Type_: `StorageMap>` + - _Purpose_: Stores the payload or model for each schema + + +### On Chain Structure +Following is a proposed data structure for storing schema information on chain. +```rust +pub struct SchemaInfo { + /// The type of model (AvroBinary, Parquet, etc.) + pub model_type: ModelType, + /// The payload location + pub payload_location: PayloadLocation, + /// additional control settings for the schema + pub settings: SchemaSettings, +} +``` From afe37117bcbd2ebacf3a59a581a4b0ee5b5c1edc Mon Sep 17 00:00:00 2001 From: "Frequency CI [bot]" Date: Wed, 25 Oct 2023 22:38:29 +0000 Subject: [PATCH 03/14] Update weights for PR #1743 --- pallets/messages/src/weights.rs | 28 ++++----- pallets/schemas/src/weights.rs | 76 +++++++++++----------- pallets/stateful-storage/src/weights.rs | 84 +++++++++++++------------ 3 files changed, 96 insertions(+), 92 deletions(-) diff --git a/pallets/messages/src/weights.rs b/pallets/messages/src/weights.rs index 992a65ea87..7892841048 100644 --- a/pallets/messages/src/weights.rs +++ b/pallets/messages/src/weights.rs @@ -20,11 +20,11 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` +//! HOSTNAME: `benchmark-runner-44wtw-6x7g7`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: -// ./scripts/../target/bench-dev/frequency +// ./scripts/../target/release/frequency // benchmark // pallet // --pallet=pallet_messages @@ -69,10 +69,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `9623` // Estimated: `21998` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(48_931_384, 21998) - // Standard Error: 358 - .saturating_add(Weight::from_parts(560, 0).saturating_mul(n.into())) + // Minimum execution time: 45_727_000 picoseconds. + Weight::from_parts(47_903_313, 21998) + // Standard Error: 127 + .saturating_add(Weight::from_parts(903, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -86,8 +86,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `7833` // Estimated: `20208` - // Minimum execution time: 44_000_000 picoseconds. - Weight::from_parts(48_000_000, 20208) + // Minimum execution time: 46_650_000 picoseconds. + Weight::from_parts(47_593_000, 20208) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -108,10 +108,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `9623` // Estimated: `21998` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(48_931_384, 21998) - // Standard Error: 358 - .saturating_add(Weight::from_parts(560, 0).saturating_mul(n.into())) + // Minimum execution time: 45_727_000 picoseconds. + Weight::from_parts(47_903_313, 21998) + // Standard Error: 127 + .saturating_add(Weight::from_parts(903, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -125,8 +125,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `7833` // Estimated: `20208` - // Minimum execution time: 44_000_000 picoseconds. - Weight::from_parts(48_000_000, 20208) + // Minimum execution time: 46_650_000 picoseconds. + Weight::from_parts(47_593_000, 20208) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/pallets/schemas/src/weights.rs b/pallets/schemas/src/weights.rs index 2d113d9cbf..bbab298390 100644 --- a/pallets/schemas/src/weights.rs +++ b/pallets/schemas/src/weights.rs @@ -20,11 +20,11 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` +//! HOSTNAME: `benchmark-runner-44wtw-6x7g7`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: -// ./scripts/../target/bench-dev/frequency +// ./scripts/../target/release/frequency // benchmark // pallet // --pallet=pallet_schemas @@ -72,10 +72,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(19_699_735, 10399) - // Standard Error: 38 - .saturating_add(Weight::from_parts(33_567, 0).saturating_mul(m.into())) + // Minimum execution time: 15_659_000 picoseconds. + Weight::from_parts(15_929_000, 10399) + // Standard Error: 52 + .saturating_add(Weight::from_parts(35_302, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -92,10 +92,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(16_019_348, 10399) - // Standard Error: 40 - .saturating_add(Weight::from_parts(33_685, 0).saturating_mul(m.into())) + // Minimum execution time: 15_764_000 picoseconds. + Weight::from_parts(15_918_000, 10399) + // Standard Error: 51 + .saturating_add(Weight::from_parts(35_247, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -114,10 +114,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(19_576_769, 12605) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_662, 0).saturating_mul(m.into())) + // Minimum execution time: 21_535_000 picoseconds. + Weight::from_parts(9_982_812, 12605) + // Standard Error: 33 + .saturating_add(Weight::from_parts(3_114, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -134,10 +134,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(22_363_353, 10399) - // Standard Error: 61 - .saturating_add(Weight::from_parts(33_609, 0).saturating_mul(m.into())) + // Minimum execution time: 15_582_000 picoseconds. + Weight::from_parts(15_805_000, 10399) + // Standard Error: 49 + .saturating_add(Weight::from_parts(35_254, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -147,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 0) + // Minimum execution time: 6_895_000 picoseconds. + Weight::from_parts(7_453_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -168,10 +168,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(19_699_735, 10399) - // Standard Error: 38 - .saturating_add(Weight::from_parts(33_567, 0).saturating_mul(m.into())) + // Minimum execution time: 15_659_000 picoseconds. + Weight::from_parts(15_929_000, 10399) + // Standard Error: 52 + .saturating_add(Weight::from_parts(35_302, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -188,10 +188,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(16_019_348, 10399) - // Standard Error: 40 - .saturating_add(Weight::from_parts(33_685, 0).saturating_mul(m.into())) + // Minimum execution time: 15_764_000 picoseconds. + Weight::from_parts(15_918_000, 10399) + // Standard Error: 51 + .saturating_add(Weight::from_parts(35_247, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -210,10 +210,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(19_576_769, 12605) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_662, 0).saturating_mul(m.into())) + // Minimum execution time: 21_535_000 picoseconds. + Weight::from_parts(9_982_812, 12605) + // Standard Error: 33 + .saturating_add(Weight::from_parts(3_114, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -230,10 +230,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(22_363_353, 10399) - // Standard Error: 61 - .saturating_add(Weight::from_parts(33_609, 0).saturating_mul(m.into())) + // Minimum execution time: 15_582_000 picoseconds. + Weight::from_parts(15_805_000, 10399) + // Standard Error: 49 + .saturating_add(Weight::from_parts(35_254, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -243,8 +243,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 0) + // Minimum execution time: 6_895_000 picoseconds. + Weight::from_parts(7_453_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/stateful-storage/src/weights.rs b/pallets/stateful-storage/src/weights.rs index b89511fb3c..c0e313eed6 100644 --- a/pallets/stateful-storage/src/weights.rs +++ b/pallets/stateful-storage/src/weights.rs @@ -20,11 +20,11 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `AramikMarkarianNewMacBookPro.local`, CPU: `` +//! HOSTNAME: `benchmark-runner-44wtw-6x7g7`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: -// ./scripts/../target/bench-dev/frequency +// ./scripts/../target/release/frequency // benchmark // pallet // --pallet=pallet_stateful-storage @@ -73,10 +73,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33346` // Estimated: `45721` - // Minimum execution time: 72_000_000 picoseconds. - Weight::from_parts(79_317_723, 45721) - // Standard Error: 495 - .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(s.into())) + // Minimum execution time: 95_988_000 picoseconds. + Weight::from_parts(94_921_845, 45721) + // Standard Error: 372 + .saturating_add(Weight::from_parts(6_232, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -93,10 +93,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `392` // Estimated: `12767` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(27_689_993, 12767) - // Standard Error: 240 - .saturating_add(Weight::from_parts(670, 0).saturating_mul(s.into())) + // Minimum execution time: 29_612_000 picoseconds. + Weight::from_parts(30_739_061, 12767) + // Standard Error: 281 + .saturating_add(Weight::from_parts(1_257, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -112,8 +112,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1551` // Estimated: `13926` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(30_000_000, 13926) + // Minimum execution time: 32_435_000 picoseconds. + Weight::from_parts(33_527_000, 13926) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -128,10 +128,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33353` // Estimated: `45728` - // Minimum execution time: 108_000_000 picoseconds. - Weight::from_parts(109_366_646, 45728) - // Standard Error: 645 - .saturating_add(Weight::from_parts(11_660, 0).saturating_mul(s.into())) + // Minimum execution time: 153_700_000 picoseconds. + Weight::from_parts(151_109_071, 45728) + // Standard Error: 483 + .saturating_add(Weight::from_parts(12_105, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -142,12 +142,14 @@ impl WeightInfo for SubstrateWeight { /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. - fn upsert_page_with_signature(_s: u32, ) -> Weight { + fn upsert_page_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `325` // Estimated: `12700` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(73_626_300, 12700) + // Minimum execution time: 83_746_000 picoseconds. + Weight::from_parts(85_519_619, 12700) + // Standard Error: 397 + .saturating_add(Weight::from_parts(6_075, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -161,8 +163,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1484` // Estimated: `13859` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(67_000_000, 13859) + // Minimum execution time: 86_729_000 picoseconds. + Weight::from_parts(88_574_000, 13859) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -183,10 +185,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33346` // Estimated: `45721` - // Minimum execution time: 72_000_000 picoseconds. - Weight::from_parts(79_317_723, 45721) - // Standard Error: 495 - .saturating_add(Weight::from_parts(3_179, 0).saturating_mul(s.into())) + // Minimum execution time: 95_988_000 picoseconds. + Weight::from_parts(94_921_845, 45721) + // Standard Error: 372 + .saturating_add(Weight::from_parts(6_232, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -203,10 +205,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `392` // Estimated: `12767` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(27_689_993, 12767) - // Standard Error: 240 - .saturating_add(Weight::from_parts(670, 0).saturating_mul(s.into())) + // Minimum execution time: 29_612_000 picoseconds. + Weight::from_parts(30_739_061, 12767) + // Standard Error: 281 + .saturating_add(Weight::from_parts(1_257, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -222,8 +224,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1551` // Estimated: `13926` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(30_000_000, 13926) + // Minimum execution time: 32_435_000 picoseconds. + Weight::from_parts(33_527_000, 13926) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -238,10 +240,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33353` // Estimated: `45728` - // Minimum execution time: 108_000_000 picoseconds. - Weight::from_parts(109_366_646, 45728) - // Standard Error: 645 - .saturating_add(Weight::from_parts(11_660, 0).saturating_mul(s.into())) + // Minimum execution time: 153_700_000 picoseconds. + Weight::from_parts(151_109_071, 45728) + // Standard Error: 483 + .saturating_add(Weight::from_parts(12_105, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -252,12 +254,14 @@ impl WeightInfo for () { /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. - fn upsert_page_with_signature(_s: u32, ) -> Weight { + fn upsert_page_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `325` // Estimated: `12700` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(73_626_300, 12700) + // Minimum execution time: 83_746_000 picoseconds. + Weight::from_parts(85_519_619, 12700) + // Standard Error: 397 + .saturating_add(Weight::from_parts(6_075, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -271,8 +275,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1484` // Estimated: `13859` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(67_000_000, 13859) + // Minimum execution time: 86_729_000 picoseconds. + Weight::from_parts(88_574_000, 13859) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From 460eadc0d012072c225c5f7a562edb80de77686c Mon Sep 17 00:00:00 2001 From: Aramik Date: Tue, 31 Oct 2023 18:00:22 -0700 Subject: [PATCH 04/14] added migration --- Cargo.lock | 1 + e2e/package-lock.json | 2 +- node/cli/Cargo.toml | 2 + node/cli/src/command.rs | 30 +++--- pallets/schemas/src/lib.rs | 18 +--- pallets/schemas/src/migration/mod.rs | 2 + pallets/schemas/src/migration/v2.rs | 118 +++++++++++++++++++++++ pallets/schemas/src/tests/other_tests.rs | 48 ++++++++- pallets/schemas/src/types.rs | 2 +- runtime/frequency/src/lib.rs | 7 +- 10 files changed, 193 insertions(+), 37 deletions(-) create mode 100644 pallets/schemas/src/migration/mod.rs create mode 100644 pallets/schemas/src/migration/v2.rs diff --git a/Cargo.lock b/Cargo.lock index 3cf7a47e7a..6623143af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3223,6 +3223,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "derive_more", + "frame-benchmarking", "frame-benchmarking-cli", "frame-support", "frame-system", diff --git a/e2e/package-lock.json b/e2e/package-lock.json index a858678f52..8ef4c64052 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -261,7 +261,7 @@ "node_modules/@frequency-chain/api-augment": { "version": "0.0.0", "resolved": "file:../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz", - "integrity": "sha512-QZ07GKhcVuIKzXh3ho8Tvlu3/VenNeyGZ9i+x7n2WFRxbvM9KqR0wF08YNFd/YOuoHbBXX8jw0LCH87Jz4lxzg==", + "integrity": "sha512-NrtVuB9KsYckEmDzWXylSxS2zYptbx3Lp4ToQ2FXSHizhKwUntBRMpvlg3EhKym4HAh+ACD713KADHq6DjpC3g==", "license": "Apache-2.0", "dependencies": { "@polkadot/api": "^10.9.1", diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 1814eaf89d..3f00fa7d3f 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -29,6 +29,7 @@ cli-opt = { default-features = false, path = "../cli-opt" } # Substrate frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", optional = true, branch = "polkadot-v1.0.0" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, branch = "polkadot-v1.0.0" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } @@ -70,6 +71,7 @@ cli = [ "sc-cli", "sc-service", "frame-benchmarking-cli", + "frame-benchmarking", "try-runtime-cli" ] default = ["std", "cli"] diff --git a/node/cli/src/command.rs b/node/cli/src/command.rs index 43e97e68b3..85153cf22a 100644 --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -371,22 +371,22 @@ pub fn run() -> Result<()> { #[cfg(feature = "try-runtime")] Some(Subcommand::TryRuntime(cmd)) => { - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; + use common_runtime::constants::MILLISECS_PER_BLOCK; + use try_runtime_cli::block_building_info::timestamp_with_aura_info; let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.tokio_handle.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - Ok(( - cmd.run::::ExtendHostFunctions, - >>(), - task_manager, - )) + type HostFunctions = + (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); + + // grab the task manager. + let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) + .map_err(|e| format!("Error: {:?}", e))?; + + let info_provider = timestamp_with_aura_info(MILLISECS_PER_BLOCK); + + runner.async_run(|_| { + Ok((cmd.run::(Some(info_provider)), task_manager)) }) }, Some(Subcommand::ExportRuntimeVersion(cmd)) => { diff --git a/pallets/schemas/src/lib.rs b/pallets/schemas/src/lib.rs index c7e0c03ae8..2f877845f1 100644 --- a/pallets/schemas/src/lib.rs +++ b/pallets/schemas/src/lib.rs @@ -76,7 +76,8 @@ mod benchmarking; #[cfg(feature = "runtime-benchmarks")] use common_primitives::benchmarks::SchemaBenchmarkHelper; use common_primitives::schema::SchemaInfoResponse; - +/// migration module +pub mod migration; mod types; pub use pallet::*; @@ -86,6 +87,8 @@ pub use weights::*; mod serde; +const LOG_TARGET: &str = "runtime::schemas"; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -185,19 +188,6 @@ pub mod pallet { pub(super) type CurrentSchemaIdentifierMaximum = StorageValue<_, SchemaId, ValueQuery>; - /// Storage for message schema struct data - /// - Key: Schema Id - /// - Value: [`Schema`](Schema) - #[pallet::storage] - #[pallet::getter(fn get_schema)] - pub(super) type Schemas = StorageMap< - _, - Twox64Concat, - SchemaId, - Schema, - OptionQuery, - >; - /// Storage for message schema info struct data /// - Key: Schema Id /// - Value: [`SchemaInfo`](SchemaInfo) diff --git a/pallets/schemas/src/migration/mod.rs b/pallets/schemas/src/migration/mod.rs new file mode 100644 index 0000000000..c34354a101 --- /dev/null +++ b/pallets/schemas/src/migration/mod.rs @@ -0,0 +1,2 @@ +/// migrations to v2 +pub mod v2; diff --git a/pallets/schemas/src/migration/v2.rs b/pallets/schemas/src/migration/v2.rs new file mode 100644 index 0000000000..877e663e02 --- /dev/null +++ b/pallets/schemas/src/migration/v2.rs @@ -0,0 +1,118 @@ +#[cfg(feature = "try-runtime")] +use crate::types::SCHEMA_STORAGE_VERSION; +use crate::{ + pallet::{SchemaInfos, SchemaPayloads}, + Config, Pallet, SchemaId, SchemaInfo, LOG_TARGET, +}; +use frame_support::{ + log, pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, weights::Weight, +}; +use sp_runtime::Saturating; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; +#[cfg(feature = "try-runtime")] +use sp_std::vec::Vec; + +/// old module storages +pub mod old { + use super::*; + use crate::Schema; + /// Storage for message schema struct data + /// - Key: Schema Id + /// - Value: [`Schema`](Schema) + #[storage_alias] + pub(crate) type Schemas = StorageMap< + Pallet, + Twox64Concat, + SchemaId, + Schema<::SchemaModelMaxBytesBoundedVecLimit>, + OptionQuery, + >; +} + +/// migration to v2 implementation +pub struct MigrateToV2(PhantomData); + +impl OnRuntimeUpgrade for MigrateToV2 { + fn on_runtime_upgrade() -> Weight { + migrate_to_v2::() + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + log::info!(target: LOG_TARGET, "Running pre_upgrade..."); + let count = old::Schemas::::iter().count() as u32; + log::info!(target: LOG_TARGET, "Finish pre_upgrade for {:?}", count); + Ok(count.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(state: Vec) -> Result<(), TryRuntimeError> { + log::info!(target: LOG_TARGET, "Running post_upgrade..."); + + let old_count: u32 = Decode::decode(&mut state.as_slice()) + .expect("the state parameter should be something that was generated by pre_upgrade"); + + let current_count = old::Schemas::::iter().count(); + let info_count = SchemaInfos::::iter().count(); + let payload_count = SchemaPayloads::::iter().count(); + + log::info!(target: LOG_TARGET, "Finish post_upgrade for {:?}", info_count); + let onchain_version = Pallet::::on_chain_storage_version(); + + assert_eq!(current_count, 0usize); + assert_eq!(info_count, old_count as usize); + assert_eq!(payload_count, old_count as usize); + assert_eq!(onchain_version, SCHEMA_STORAGE_VERSION); + Ok(()) + } +} + +/// migrating to v2 +pub fn migrate_to_v2() -> Weight { + log::info!(target: LOG_TARGET, "Running storage migration..."); + let onchain_version = Pallet::::on_chain_storage_version(); + let current_version = Pallet::::current_storage_version(); + log::info!(target: LOG_TARGET, "onchain_version= {:?}, current_version={:?}", onchain_version, current_version); + + if onchain_version < 2 { + let mut reads = 1u64; + let mut writes = 0u64; + let mut bytes = 0u64; + for (schema_id, schema) in old::Schemas::::drain() { + bytes = bytes.saturating_add(schema.encode().len() as u64); + + let info = SchemaInfo { + model_type: schema.model_type, + payload_location: schema.payload_location, + settings: schema.settings, + }; + + bytes = bytes.saturating_add(info.encode().len() as u64); + SchemaInfos::::insert(schema_id, info); + + bytes = bytes.saturating_add(schema.model.len() as u64); + SchemaPayloads::::insert(schema_id, schema.model); + + reads.saturating_inc(); + writes = writes.saturating_add(3); + } + + // Set storage version to `2`. + StorageVersion::new(2).put::>(); + writes.saturating_inc(); + + log::info!(target: LOG_TARGET, "Storage migrated to version 2 read={:?}, write={:?}, bytes={:?}", reads, writes, bytes); + let weights = T::DbWeight::get().reads_writes(reads, writes).add_proof_size(bytes); + log::info!(target: LOG_TARGET, "Migration Calculated weights={:?}",weights); + weights + } else { + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed onchain:{:?}, current:{:?}", + onchain_version, + current_version + ); + T::DbWeight::get().reads(1) + } +} diff --git a/pallets/schemas/src/tests/other_tests.rs b/pallets/schemas/src/tests/other_tests.rs index dcee3da83b..9255403047 100644 --- a/pallets/schemas/src/tests/other_tests.rs +++ b/pallets/schemas/src/tests/other_tests.rs @@ -1,7 +1,7 @@ use frame_support::{ assert_noop, assert_ok, - dispatch::{RawOrigin, Weight}, - traits::{ChangeMembers, Hash}, + dispatch::{GetStorageVersion, RawOrigin, Weight}, + traits::{ChangeMembers, Hash, StorageVersion}, BoundedVec, }; use serial_test::serial; @@ -20,7 +20,11 @@ use common_primitives::{ }; use sp_runtime::DispatchError::BadOrigin; -use crate::{Config, Error, Event as AnnouncementEvent}; +use crate::{ + migration::v2, + pallet::{SchemaInfos, SchemaPayloads}, + Config, Error, Event as AnnouncementEvent, +}; use super::mock::*; @@ -697,3 +701,41 @@ fn create_schema_with_append_only_setting_and_non_itemized_should_fail() { ); }) } + +#[test] +fn schemas_migration_to_v2_should_work_as_expected() { + new_test_ext().execute_with(|| { + // Arrange + sudo_set_max_schema_size(); + let sender: AccountId = test_public(5); + let schemas = vec![ + r#"{"Name": "Bond", "Code": "007"}"#, + r#"{"type": "num","minimum": -90,"maximum": 90}"#, + r#"{"latitude": 48.858093,"longitude": 2.294694}"#, + ]; + for fields in &schemas { + assert_ok!(SchemasPallet::create_schema_v2( + RuntimeOrigin::signed(sender.clone()), + create_bounded_schema_vec(fields), + ModelType::AvroBinary, + PayloadLocation::OnChain, + BoundedVec::default() + )); + } + + // Act + let _ = v2::migrate_to_v2::(); + + // Assert + let old_count = v2::old::Schemas::::iter().count(); + let new_info_count = SchemaInfos::::iter().count(); + let new_payload_count = SchemaPayloads::::iter().count(); + let current_version = SchemasPallet::current_storage_version(); + + + assert_eq!(old_count, 0); + assert_eq!(new_info_count, schemas.len()); + assert_eq!(new_payload_count, schemas.len()); + assert_eq!(current_version, StorageVersion::new(2)); + }); +} diff --git a/pallets/schemas/src/types.rs b/pallets/schemas/src/types.rs index 13bbff7716..1e071ce493 100644 --- a/pallets/schemas/src/types.rs +++ b/pallets/schemas/src/types.rs @@ -9,7 +9,7 @@ use scale_info::TypeInfo; use sp_std::fmt::Debug; /// Current storage version of the schemas pallet. -pub const SCHEMA_STORAGE_VERSION: StorageVersion = StorageVersion::new(1); +pub const SCHEMA_STORAGE_VERSION: StorageVersion = StorageVersion::new(2); #[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)] #[scale_info(skip_type_params(MaxModelSize))] diff --git a/runtime/frequency/src/lib.rs b/runtime/frequency/src/lib.rs index 7d7c86b981..af9698a4cc 100644 --- a/runtime/frequency/src/lib.rs +++ b/runtime/frequency/src/lib.rs @@ -79,7 +79,7 @@ pub use common_runtime::{ use frame_support::traits::Contains; #[cfg(feature = "try-runtime")] -use frame_support::traits::TryStateSelect; +use frame_support::traits::{TryStateSelect, UpgradeCheckSelect}; /// Interface to collective pallet to propose a proposal. pub struct CouncilProposalProvider; @@ -220,6 +220,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + (pallet_schemas::migration::v2::MigrateToV2,), >; /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know @@ -1280,9 +1281,9 @@ impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(_checks: bool) -> (Weight, Weight) { + fn on_runtime_upgrade(checks: UpgradeCheckSelect) -> (Weight, Weight) { log::info!("try-runtime::on_runtime_upgrade frequency."); - let weight = Executive::try_runtime_upgrade(true).unwrap(); + let weight = Executive::try_runtime_upgrade(checks).unwrap(); (weight, RuntimeBlockWeights::get().max_block) } From 5cfde10b455bf9e15fb47a6e163949adacc09697 Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 1 Nov 2023 16:21:32 -0700 Subject: [PATCH 05/14] better test --- pallets/schemas/src/tests/other_tests.rs | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pallets/schemas/src/tests/other_tests.rs b/pallets/schemas/src/tests/other_tests.rs index f29d876714..b95639ed3f 100644 --- a/pallets/schemas/src/tests/other_tests.rs +++ b/pallets/schemas/src/tests/other_tests.rs @@ -18,14 +18,14 @@ use common_primitives::{ types::ParquetType, ParquetModel, }, - schema::{ModelType, PayloadLocation, SchemaId, SchemaSetting}, + schema::{ModelType, PayloadLocation, SchemaId, SchemaSetting, SchemaSettings}, }; use sp_runtime::DispatchError::BadOrigin; use crate::{ migration::v2, pallet::{SchemaInfos, SchemaPayloads}, - Config, Error, Event as AnnouncementEvent, + Config, Error, Event as AnnouncementEvent, Schema, }; use super::mock::*; @@ -715,7 +715,7 @@ fn schemas_migration_to_v2_should_work_as_expected() { r#"{"type": "num","minimum": -90,"maximum": 90}"#, r#"{"latitude": 48.858093,"longitude": 2.294694}"#, ]; - for fields in &schemas { + for (idx, fields) in schemas.iter().enumerate() { assert_ok!(SchemasPallet::create_schema_v2( RuntimeOrigin::signed(sender.clone()), create_bounded_schema_vec(fields), @@ -723,7 +723,18 @@ fn schemas_migration_to_v2_should_work_as_expected() { PayloadLocation::OnChain, BoundedVec::default() )); + v2::old::Schemas::::insert( + idx as u16 + 1, + Schema { + model_type: ModelType::AvroBinary, + payload_location: PayloadLocation::OnChain, + settings: SchemaSettings::all_disabled(), + model: BoundedVec::try_from(fields.as_bytes().to_vec()) + .expect("should have value"), + }, + ); } + let old_schema_1 = v2::old::Schemas::::get(1u16).expect("should have value"); // Act let _ = v2::migrate_to_v2::(); @@ -734,9 +745,17 @@ fn schemas_migration_to_v2_should_work_as_expected() { let new_payload_count = SchemaPayloads::::iter().count(); let current_version = SchemasPallet::current_storage_version(); + let schema_info_1 = SchemaInfos::::get(1).expect("should have value"); + let schema_payload_1 = SchemaPayloads::::get(1u16).expect("should have value"); + assert_eq!(old_count, 0); assert_eq!(new_info_count, schemas.len()); assert_eq!(new_payload_count, schemas.len()); assert_eq!(current_version, StorageVersion::new(2)); + + assert_eq!(schema_info_1.model_type, old_schema_1.model_type); + assert_eq!(schema_info_1.payload_location, old_schema_1.payload_location); + assert_eq!(schema_info_1.settings, old_schema_1.settings); + assert_eq!(schema_payload_1.into_inner(), old_schema_1.model.into_inner()); }); } From 66fc6b79b840982d816bb9800862b5d03b03946f Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 1 Nov 2023 16:41:05 -0700 Subject: [PATCH 06/14] fixed docs --- pallets/schemas/src/lib.rs | 2 +- pallets/schemas/src/migration/v2.rs | 21 ++++++++++++++++++++- pallets/schemas/src/tests/other_tests.rs | 4 ++-- pallets/schemas/src/types.rs | 23 +---------------------- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/pallets/schemas/src/lib.rs b/pallets/schemas/src/lib.rs index 25fd3afa96..b3112d04b0 100644 --- a/pallets/schemas/src/lib.rs +++ b/pallets/schemas/src/lib.rs @@ -395,7 +395,7 @@ pub mod pallet { >::set(n); } - /// Build the [`Schema`] and insert it into storage + /// Build the [`SchemaInfo`] and insert it into storage /// Updates the `CurrentSchemaIdentifierMaximum` storage pub fn add_schema( model: BoundedVec, diff --git a/pallets/schemas/src/migration/v2.rs b/pallets/schemas/src/migration/v2.rs index e102486b6a..2b48a39302 100644 --- a/pallets/schemas/src/migration/v2.rs +++ b/pallets/schemas/src/migration/v2.rs @@ -15,7 +15,26 @@ use sp_std::vec::Vec; /// old module storages pub mod old { use super::*; - use crate::Schema; + use common_primitives::schema::{ModelType, PayloadLocation, SchemaSettings}; + + #[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)] + #[scale_info(skip_type_params(MaxModelSize))] + #[codec(mel_bound(MaxModelSize: MaxEncodedLen))] + /// A structure defining a Schema + pub struct Schema + where + MaxModelSize: Get, + { + /// The type of model (AvroBinary, Parquet, etc.) + pub model_type: ModelType, + /// Defines the structure of the message payload using model_type + pub model: BoundedVec, + /// The payload location + pub payload_location: PayloadLocation, + /// additional control settings for the schema + pub settings: SchemaSettings, + } + /// Storage for message schema struct data /// - Key: Schema Id /// - Value: [`Schema`](Schema) diff --git a/pallets/schemas/src/tests/other_tests.rs b/pallets/schemas/src/tests/other_tests.rs index b95639ed3f..613ebeedfb 100644 --- a/pallets/schemas/src/tests/other_tests.rs +++ b/pallets/schemas/src/tests/other_tests.rs @@ -25,7 +25,7 @@ use sp_runtime::DispatchError::BadOrigin; use crate::{ migration::v2, pallet::{SchemaInfos, SchemaPayloads}, - Config, Error, Event as AnnouncementEvent, Schema, + Config, Error, Event as AnnouncementEvent, }; use super::mock::*; @@ -725,7 +725,7 @@ fn schemas_migration_to_v2_should_work_as_expected() { )); v2::old::Schemas::::insert( idx as u16 + 1, - Schema { + v2::old::Schema { model_type: ModelType::AvroBinary, payload_location: PayloadLocation::OnChain, settings: SchemaSettings::all_disabled(), diff --git a/pallets/schemas/src/types.rs b/pallets/schemas/src/types.rs index 1e071ce493..c1573e43b7 100644 --- a/pallets/schemas/src/types.rs +++ b/pallets/schemas/src/types.rs @@ -1,34 +1,13 @@ //! Types for the Schema Pallet use codec::{Decode, Encode, MaxEncodedLen}; use common_primitives::schema::{ModelType, PayloadLocation, SchemaSettings}; -use frame_support::{ - traits::{Get, StorageVersion}, - BoundedVec, -}; +use frame_support::traits::StorageVersion; use scale_info::TypeInfo; use sp_std::fmt::Debug; /// Current storage version of the schemas pallet. pub const SCHEMA_STORAGE_VERSION: StorageVersion = StorageVersion::new(2); -#[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)] -#[scale_info(skip_type_params(MaxModelSize))] -#[codec(mel_bound(MaxModelSize: MaxEncodedLen))] -/// A structure defining a Schema -pub struct Schema -where - MaxModelSize: Get, -{ - /// The type of model (AvroBinary, Parquet, etc.) - pub model_type: ModelType, - /// Defines the structure of the message payload using model_type - pub model: BoundedVec, - /// The payload location - pub payload_location: PayloadLocation, - /// additional control settings for the schema - pub settings: SchemaSettings, -} - #[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)] /// A structure defining a Schema information (excluding the payload) pub struct SchemaInfo { From 4f91419c7571a236b341ff4a72a44feab4e8105c Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 1 Nov 2023 16:42:15 -0700 Subject: [PATCH 07/14] Run benchmarks [run-benchmarks schemas] From 1a10f6b6181d8d4af9f1f0e75b605ce690d82962 Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 1 Nov 2023 16:57:34 -0700 Subject: [PATCH 08/14] Run benchmarks [run-benchmarks schemas] --- e2e/package-lock.json | 2 +- runtime/frequency/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index 8ef4c64052..1f9b455da5 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -261,7 +261,7 @@ "node_modules/@frequency-chain/api-augment": { "version": "0.0.0", "resolved": "file:../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz", - "integrity": "sha512-NrtVuB9KsYckEmDzWXylSxS2zYptbx3Lp4ToQ2FXSHizhKwUntBRMpvlg3EhKym4HAh+ACD713KADHq6DjpC3g==", + "integrity": "sha512-j9kFmrh+utx0HfsooUZk9QVOsP7uOmSpxN7J6TKC1dOmaiMF7NnPGV4P85N3HrrlEVzY0/CLibJX3QmxbJ4k/Q==", "license": "Apache-2.0", "dependencies": { "@polkadot/api": "^10.9.1", diff --git a/runtime/frequency/src/lib.rs b/runtime/frequency/src/lib.rs index 22c83786b9..c738d685bb 100644 --- a/runtime/frequency/src/lib.rs +++ b/runtime/frequency/src/lib.rs @@ -258,7 +258,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("frequency"), impl_name: create_runtime_str!("frequency"), authoring_version: 1, - spec_version: 60, + spec_version: 61, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -272,7 +272,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("frequency-rococo"), impl_name: create_runtime_str!("frequency"), authoring_version: 1, - spec_version: 60, + spec_version: 61, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 965da26bfa19170a98acbf1d3e69211bee51f33f Mon Sep 17 00:00:00 2001 From: Aramik Date: Wed, 1 Nov 2023 18:03:43 -0700 Subject: [PATCH 09/14] Run benchmarks [run-benchmarks schemas,messages,stateful-storage] From a82b9cccee2eb476aa80e742cba45a0905bce05c Mon Sep 17 00:00:00 2001 From: "Frequency CI [bot]" Date: Thu, 2 Nov 2023 01:39:12 +0000 Subject: [PATCH 10/14] Update weights for PR #1743 --- pallets/messages/src/weights.rs | 60 ++++---- pallets/schemas/src/weights.rs | 124 ++++++++-------- pallets/stateful-storage/src/weights.rs | 180 ++++++++++++------------ 3 files changed, 188 insertions(+), 176 deletions(-) diff --git a/pallets/messages/src/weights.rs b/pallets/messages/src/weights.rs index afebb58b51..5e7553e7a4 100644 --- a/pallets/messages/src/weights.rs +++ b/pallets/messages/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -56,8 +56,8 @@ pub trait WeightInfo { /// Weights for pallet_messages using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -67,27 +67,27 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `9664` - // Estimated: `22039` - // Minimum execution time: 47_640_000 picoseconds. - Weight::from_parts(49_189_621, 22039) - // Standard Error: 82 - .saturating_add(Weight::from_parts(938, 0).saturating_mul(n.into())) + // Measured: `9623` + // Estimated: `21998` + // Minimum execution time: 46_448_000 picoseconds. + Weight::from_parts(47_830_962, 21998) + // Standard Error: 67 + .saturating_add(Weight::from_parts(957, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) /// Storage: `Messages::Messages` (r:1 w:1) /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `7958` - // Estimated: `20333` - // Minimum execution time: 43_681_000 picoseconds. - Weight::from_parts(45_218_000, 20333) + // Measured: `7833` + // Estimated: `20208` + // Minimum execution time: 45_816_000 picoseconds. + Weight::from_parts(47_622_000, 20208) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -95,8 +95,8 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -106,27 +106,27 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `9664` - // Estimated: `22039` - // Minimum execution time: 47_640_000 picoseconds. - Weight::from_parts(49_189_621, 22039) - // Standard Error: 82 - .saturating_add(Weight::from_parts(938, 0).saturating_mul(n.into())) + // Measured: `9623` + // Estimated: `21998` + // Minimum execution time: 46_448_000 picoseconds. + Weight::from_parts(47_830_962, 21998) + // Standard Error: 67 + .saturating_add(Weight::from_parts(957, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `Measured`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) /// Storage: `Messages::Messages` (r:1 w:1) /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `7958` - // Estimated: `20333` - // Minimum execution time: 43_681_000 picoseconds. - Weight::from_parts(45_218_000, 20333) + // Measured: `7833` + // Estimated: `20208` + // Minimum execution time: 45_816_000 picoseconds. + Weight::from_parts(47_622_000, 20208) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/pallets/schemas/src/weights.rs b/pallets/schemas/src/weights.rs index 599facf2bc..362a91fc74 100644 --- a/pallets/schemas/src/weights.rs +++ b/pallets/schemas/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_schemas //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -63,37 +63,41 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_031_000 picoseconds. - Weight::from_parts(14_415_000, 10399) - // Standard Error: 47 - .saturating_add(Weight::from_parts(35_161, 0).saturating_mul(m.into())) + // Minimum execution time: 15_624_000 picoseconds. + Weight::from_parts(15_710_000, 10399) + // Standard Error: 44 + .saturating_add(Weight::from_parts(33_970, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:1 w:0) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_via_governance(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_110_000 picoseconds. - Weight::from_parts(14_289_000, 10399) - // Standard Error: 47 - .saturating_add(Weight::from_parts(35_148, 0).saturating_mul(m.into())) + // Minimum execution time: 15_741_000 picoseconds. + Weight::from_parts(15_821_000, 10399) + // Standard Error: 45 + .saturating_add(Weight::from_parts(34_049, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Council::Members` (r:1 w:0) /// Proof: `Council::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -110,10 +114,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_148_000 picoseconds. - Weight::from_parts(9_634_788, 12605) - // Standard Error: 34 - .saturating_add(Weight::from_parts(3_135, 0).saturating_mul(m.into())) + // Minimum execution time: 21_689_000 picoseconds. + Weight::from_parts(10_698_818, 12605) + // Standard Error: 33 + .saturating_add(Weight::from_parts(3_122, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -121,19 +125,21 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_v2(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 13_941_000 picoseconds. - Weight::from_parts(14_046_000, 10399) - // Standard Error: 46 - .saturating_add(Weight::from_parts(35_198, 0).saturating_mul(m.into())) + // Minimum execution time: 15_629_000 picoseconds. + Weight::from_parts(15_771_000, 10399) + // Standard Error: 41 + .saturating_add(Weight::from_parts(34_326, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:0 w:1) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -141,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_747_000 picoseconds. - Weight::from_parts(6_980_000, 0) + // Minimum execution time: 7_005_000 picoseconds. + Weight::from_parts(7_235_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -153,37 +159,41 @@ impl WeightInfo for () { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_031_000 picoseconds. - Weight::from_parts(14_415_000, 10399) - // Standard Error: 47 - .saturating_add(Weight::from_parts(35_161, 0).saturating_mul(m.into())) + // Minimum execution time: 15_624_000 picoseconds. + Weight::from_parts(15_710_000, 10399) + // Standard Error: 44 + .saturating_add(Weight::from_parts(33_970, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:1 w:0) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_via_governance(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 14_110_000 picoseconds. - Weight::from_parts(14_289_000, 10399) - // Standard Error: 47 - .saturating_add(Weight::from_parts(35_148, 0).saturating_mul(m.into())) + // Minimum execution time: 15_741_000 picoseconds. + Weight::from_parts(15_821_000, 10399) + // Standard Error: 45 + .saturating_add(Weight::from_parts(34_049, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Council::Members` (r:1 w:0) /// Proof: `Council::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -200,10 +210,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_148_000 picoseconds. - Weight::from_parts(9_634_788, 12605) - // Standard Error: 34 - .saturating_add(Weight::from_parts(3_135, 0).saturating_mul(m.into())) + // Minimum execution time: 21_689_000 picoseconds. + Weight::from_parts(10_698_818, 12605) + // Standard Error: 33 + .saturating_add(Weight::from_parts(3_122, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -211,19 +221,21 @@ impl WeightInfo for () { /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Schemas::CurrentSchemaIdentifierMaximum` (r:1 w:1) /// Proof: `Schemas::CurrentSchemaIdentifierMaximum` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:0 w:1) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:0 w:1) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaPayloads` (r:0 w:1) + /// Proof: `Schemas::SchemaPayloads` (`max_values`: None, `max_size`: Some(65514), added: 67989, mode: `MaxEncodedLen`) /// The range of component `m` is `[16, 65499]`. fn create_schema_v2(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 13_941_000 picoseconds. - Weight::from_parts(14_046_000, 10399) - // Standard Error: 46 - .saturating_add(Weight::from_parts(35_198, 0).saturating_mul(m.into())) + // Minimum execution time: 15_629_000 picoseconds. + Weight::from_parts(15_771_000, 10399) + // Standard Error: 41 + .saturating_add(Weight::from_parts(34_326, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Schemas::GovernanceSchemaModelMaxBytes` (r:0 w:1) /// Proof: `Schemas::GovernanceSchemaModelMaxBytes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -231,8 +243,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_747_000 picoseconds. - Weight::from_parts(6_980_000, 0) + // Minimum execution time: 7_005_000 picoseconds. + Weight::from_parts(7_235_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/stateful-storage/src/weights.rs b/pallets/stateful-storage/src/weights.rs index 332d612ffc..619017e1dc 100644 --- a/pallets/stateful-storage/src/weights.rs +++ b/pallets/stateful-storage/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_stateful_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -60,8 +60,8 @@ pub trait WeightInfo { /// Weights for pallet_stateful_storage using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -71,17 +71,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 5121]`. fn apply_item_actions(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33370` - // Estimated: `77893` - // Minimum execution time: 99_564_000 picoseconds. - Weight::from_parts(97_543_524, 77893) - // Standard Error: 308 - .saturating_add(Weight::from_parts(7_013, 0).saturating_mul(s.into())) + // Measured: `33346` + // Estimated: `45721` + // Minimum execution time: 95_864_000 picoseconds. + Weight::from_parts(100_554_019, 45721) + // Standard Error: 615 + .saturating_add(Weight::from_parts(4_988, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -91,17 +91,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 1024]`. fn upsert_page(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `416` - // Estimated: `77893` - // Minimum execution time: 30_143_000 picoseconds. - Weight::from_parts(31_160_288, 77893) - // Standard Error: 198 - .saturating_add(Weight::from_parts(1_041, 0).saturating_mul(s.into())) + // Measured: `392` + // Estimated: `12767` + // Minimum execution time: 28_918_000 picoseconds. + Weight::from_parts(29_786_260, 12767) + // Standard Error: 179 + .saturating_add(Weight::from_parts(963, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -110,61 +110,61 @@ impl WeightInfo for SubstrateWeight { /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page() -> Weight { // Proof Size summary in bytes: - // Measured: `1575` - // Estimated: `77893` - // Minimum execution time: 35_161_000 picoseconds. - Weight::from_parts(36_319_000, 77893) + // Measured: `1551` + // Estimated: `13926` + // Minimum execution time: 32_286_000 picoseconds. + Weight::from_parts(33_306_000, 13926) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// Proof: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// The range of component `s` is `[1, 5121]`. fn apply_item_actions_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33377` - // Estimated: `77893` - // Minimum execution time: 157_264_000 picoseconds. - Weight::from_parts(150_585_335, 77893) - // Standard Error: 471 - .saturating_add(Weight::from_parts(14_094, 0).saturating_mul(s.into())) + // Measured: `33353` + // Estimated: `45728` + // Minimum execution time: 154_862_000 picoseconds. + Weight::from_parts(149_197_324, 45728) + // Standard Error: 483 + .saturating_add(Weight::from_parts(12_598, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. fn upsert_page_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349` - // Estimated: `77893` - // Minimum execution time: 84_281_000 picoseconds. - Weight::from_parts(86_715_032, 77893) - // Standard Error: 637 - .saturating_add(Weight::from_parts(6_519, 0).saturating_mul(s.into())) + // Measured: `325` + // Estimated: `12700` + // Minimum execution time: 82_069_000 picoseconds. + Weight::from_parts(83_641_051, 12700) + // Standard Error: 201 + .saturating_add(Weight::from_parts(6_617, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page_with_signature() -> Weight { // Proof Size summary in bytes: - // Measured: `1508` - // Estimated: `77893` - // Minimum execution time: 87_878_000 picoseconds. - Weight::from_parts(89_132_000, 77893) + // Measured: `1484` + // Estimated: `13859` + // Minimum execution time: 85_991_000 picoseconds. + Weight::from_parts(86_655_000, 13859) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -172,8 +172,8 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -183,17 +183,17 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 5121]`. fn apply_item_actions(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33370` - // Estimated: `77893` - // Minimum execution time: 99_564_000 picoseconds. - Weight::from_parts(97_543_524, 77893) - // Standard Error: 308 - .saturating_add(Weight::from_parts(7_013, 0).saturating_mul(s.into())) + // Measured: `33346` + // Estimated: `45721` + // Minimum execution time: 95_864_000 picoseconds. + Weight::from_parts(100_554_019, 45721) + // Standard Error: 615 + .saturating_add(Weight::from_parts(4_988, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -203,17 +203,17 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 1024]`. fn upsert_page(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `416` - // Estimated: `77893` - // Minimum execution time: 30_143_000 picoseconds. - Weight::from_parts(31_160_288, 77893) - // Standard Error: 198 - .saturating_add(Weight::from_parts(1_041, 0).saturating_mul(s.into())) + // Measured: `392` + // Estimated: `12767` + // Minimum execution time: 28_918_000 picoseconds. + Weight::from_parts(29_786_260, 12767) + // Standard Error: 179 + .saturating_add(Weight::from_parts(963, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) @@ -222,61 +222,61 @@ impl WeightInfo for () { /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page() -> Weight { // Proof Size summary in bytes: - // Measured: `1575` - // Estimated: `77893` - // Minimum execution time: 35_161_000 picoseconds. - Weight::from_parts(36_319_000, 77893) + // Measured: `1551` + // Estimated: `13926` + // Minimum execution time: 32_286_000 picoseconds. + Weight::from_parts(33_306_000, 13926) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// Proof: UNKNOWN KEY `0xbd1557c8db6bd8599a811a7175fbc2fc6400` (r:1 w:1) /// The range of component `s` is `[1, 5121]`. fn apply_item_actions_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `33377` - // Estimated: `77893` - // Minimum execution time: 157_264_000 picoseconds. - Weight::from_parts(150_585_335, 77893) - // Standard Error: 471 - .saturating_add(Weight::from_parts(14_094, 0).saturating_mul(s.into())) + // Measured: `33353` + // Estimated: `45728` + // Minimum execution time: 154_862_000 picoseconds. + Weight::from_parts(149_197_324, 45728) + // Standard Error: 483 + .saturating_add(Weight::from_parts(12_598, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// The range of component `s` is `[1, 1024]`. fn upsert_page_with_signature(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `349` - // Estimated: `77893` - // Minimum execution time: 84_281_000 picoseconds. - Weight::from_parts(86_715_032, 77893) - // Standard Error: 637 - .saturating_add(Weight::from_parts(6_519, 0).saturating_mul(s.into())) + // Measured: `325` + // Estimated: `12700` + // Minimum execution time: 82_069_000 picoseconds. + Weight::from_parts(83_641_051, 12700) + // Standard Error: 201 + .saturating_add(Weight::from_parts(6_617, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Schemas::Schemas` (r:1 w:0) - /// Proof: `Schemas::Schemas` (`max_values`: None, `max_size`: Some(65518), added: 67993, mode: `MaxEncodedLen`) + /// Storage: `Schemas::SchemaInfos` (r:1 w:0) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) /// Proof: UNKNOWN KEY `0x0763c98381dc89abe38627fe2f98cb7af1577fbf1d628fdddb4ebfc6e8d95fb1` (r:1 w:1) fn delete_page_with_signature() -> Weight { // Proof Size summary in bytes: - // Measured: `1508` - // Estimated: `77893` - // Minimum execution time: 87_878_000 picoseconds. - Weight::from_parts(89_132_000, 77893) + // Measured: `1484` + // Estimated: `13859` + // Minimum execution time: 85_991_000 picoseconds. + Weight::from_parts(86_655_000, 13859) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From 290c12840b2a89c2a6e38ecddeab2ff4096e44c9 Mon Sep 17 00:00:00 2001 From: Aramik Date: Fri, 10 Nov 2023 13:25:16 -0800 Subject: [PATCH 11/14] addressed pr comments --- designdocs/schema_v2.md | 5 +++++ pallets/schemas/src/lib.rs | 2 +- pallets/schemas/src/migration/v2.rs | 2 ++ pallets/schemas/src/tests/other_tests.rs | 21 ++++++++++++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/designdocs/schema_v2.md b/designdocs/schema_v2.md index 00fa9888b3..90bb772e51 100644 --- a/designdocs/schema_v2.md +++ b/designdocs/schema_v2.md @@ -39,3 +39,8 @@ pub struct SchemaInfo { pub settings: SchemaSettings, } ``` +### Expected PoV improvements +This PoV improvement would not extrinsic weights in this pallet, but it would directly affect any +pallet that is dependent on **Schemas** pallet. Some of these pallets are **Messages** and +**Stateful-Storage**. After these changes we are expecting see to see around 30-60KiB decrease in PoV +for `MaxEncodedLen` mode. diff --git a/pallets/schemas/src/lib.rs b/pallets/schemas/src/lib.rs index b3112d04b0..c0662f0112 100644 --- a/pallets/schemas/src/lib.rs +++ b/pallets/schemas/src/lib.rs @@ -395,7 +395,7 @@ pub mod pallet { >::set(n); } - /// Build the [`SchemaInfo`] and insert it into storage + /// Inserts both the [`SchemaInfo`] and Schema Payload into storage /// Updates the `CurrentSchemaIdentifierMaximum` storage pub fn add_schema( model: BoundedVec, diff --git a/pallets/schemas/src/migration/v2.rs b/pallets/schemas/src/migration/v2.rs index 2b48a39302..8a45c05364 100644 --- a/pallets/schemas/src/migration/v2.rs +++ b/pallets/schemas/src/migration/v2.rs @@ -92,6 +92,7 @@ pub fn migrate_to_v2() -> Weight { let onchain_version = Pallet::::on_chain_storage_version(); let current_version = Pallet::::current_storage_version(); log::info!(target: LOG_TARGET, "onchain_version= {:?}, current_version={:?}", onchain_version, current_version); + let each_layer_access: u64 = 33 * 16; if onchain_version < 2 { let mut reads = 1u64; @@ -99,6 +100,7 @@ pub fn migrate_to_v2() -> Weight { let mut bytes = 0u64; for (schema_id, schema) in old::Schemas::::drain() { bytes = bytes.saturating_add(schema.encode().len() as u64); + bytes = bytes.saturating_add(each_layer_access * 3); // three layers in merkle tree let info = SchemaInfo { model_type: schema.model_type, diff --git a/pallets/schemas/src/tests/other_tests.rs b/pallets/schemas/src/tests/other_tests.rs index 613ebeedfb..47c259eb13 100644 --- a/pallets/schemas/src/tests/other_tests.rs +++ b/pallets/schemas/src/tests/other_tests.rs @@ -735,6 +735,8 @@ fn schemas_migration_to_v2_should_work_as_expected() { ); } let old_schema_1 = v2::old::Schemas::::get(1u16).expect("should have value"); + let old_schema_2 = v2::old::Schemas::::get(2u16).expect("should have value"); + let old_schema_3 = v2::old::Schemas::::get(3u16).expect("should have value"); // Act let _ = v2::migrate_to_v2::(); @@ -745,17 +747,30 @@ fn schemas_migration_to_v2_should_work_as_expected() { let new_payload_count = SchemaPayloads::::iter().count(); let current_version = SchemasPallet::current_storage_version(); - let schema_info_1 = SchemaInfos::::get(1).expect("should have value"); - let schema_payload_1 = SchemaPayloads::::get(1u16).expect("should have value"); - assert_eq!(old_count, 0); assert_eq!(new_info_count, schemas.len()); assert_eq!(new_payload_count, schemas.len()); assert_eq!(current_version, StorageVersion::new(2)); + let schema_info_1 = SchemaInfos::::get(1).expect("should have value"); + let schema_payload_1 = SchemaPayloads::::get(1u16).expect("should have value"); assert_eq!(schema_info_1.model_type, old_schema_1.model_type); assert_eq!(schema_info_1.payload_location, old_schema_1.payload_location); assert_eq!(schema_info_1.settings, old_schema_1.settings); assert_eq!(schema_payload_1.into_inner(), old_schema_1.model.into_inner()); + + let schema_info_2 = SchemaInfos::::get(2).expect("should have value"); + let schema_payload_2 = SchemaPayloads::::get(2u16).expect("should have value"); + assert_eq!(schema_info_2.model_type, old_schema_2.model_type); + assert_eq!(schema_info_2.payload_location, old_schema_2.payload_location); + assert_eq!(schema_info_2.settings, old_schema_2.settings); + assert_eq!(schema_payload_2.into_inner(), old_schema_2.model.into_inner()); + + let schema_info_3 = SchemaInfos::::get(3).expect("should have value"); + let schema_payload_3 = SchemaPayloads::::get(3u16).expect("should have value"); + assert_eq!(schema_info_3.model_type, old_schema_3.model_type); + assert_eq!(schema_info_3.payload_location, old_schema_3.payload_location); + assert_eq!(schema_info_3.settings, old_schema_3.settings); + assert_eq!(schema_payload_3.into_inner(), old_schema_3.model.into_inner()); }); } From 7577903697132729f1198d55c3b9932b8efb5377 Mon Sep 17 00:00:00 2001 From: Aramik Date: Fri, 10 Nov 2023 13:26:23 -0800 Subject: [PATCH 12/14] Run benchmarks [run-benchmarks schemas,messages,stateful-storage] From 8df268508e8d0d68e718d166c7b976c54075727c Mon Sep 17 00:00:00 2001 From: "Frequency CI [bot]" Date: Fri, 10 Nov 2023 21:55:15 +0000 Subject: [PATCH 13/14] Update weights for PR #1743 --- pallets/messages/src/weights.rs | 88 ++++++++++++------------- pallets/schemas/src/weights.rs | 76 ++++++++++----------- pallets/stateful-storage/src/weights.rs | 84 +++++++++++------------ 3 files changed, 124 insertions(+), 124 deletions(-) diff --git a/pallets/messages/src/weights.rs b/pallets/messages/src/weights.rs index 5e7553e7a4..b20bf16e69 100644 --- a/pallets/messages/src/weights.rs +++ b/pallets/messages/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-10, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-d4nrm`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -57,38 +57,38 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// Storage: `Schemas::SchemaInfos` (r:1 w:0) - /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) - /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) - /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `Measured`) - /// Storage: `Messages::Messages` (r:1 w:1) - /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `MaxEncodedLen`) + /// Storage: `Messages::MessagesV2` (r:0 w:1) + /// Proof: `Messages::MessagesV2` (`max_values`: None, `max_size`: Some(3123), added: 5598, mode: `MaxEncodedLen`) /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `9623` - // Estimated: `21998` - // Minimum execution time: 46_448_000 picoseconds. - Weight::from_parts(47_830_962, 21998) - // Standard Error: 67 - .saturating_add(Weight::from_parts(957, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `402` + // Estimated: `12592` + // Minimum execution time: 32_164_000 picoseconds. + Weight::from_parts(33_345_645, 12592) + // Standard Error: 43 + .saturating_add(Weight::from_parts(848, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Schemas::SchemaInfos` (r:1 w:0) - /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) - /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) - /// Storage: `Messages::Messages` (r:1 w:1) - /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Messages::MessagesV2` (r:0 w:1) + /// Proof: `Messages::MessagesV2` (`max_values`: None, `max_size`: Some(3123), added: 5598, mode: `MaxEncodedLen`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `7833` - // Estimated: `20208` - // Minimum execution time: 45_816_000 picoseconds. - Weight::from_parts(47_622_000, 20208) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `790` + // Estimated: `12423` + // Minimum execution time: 31_839_000 picoseconds. + Weight::from_parts(32_576_000, 12423) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -96,38 +96,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { /// Storage: `Schemas::SchemaInfos` (r:1 w:0) - /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) - /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Msa::DelegatorAndProviderToDelegation` (r:1 w:0) - /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `Measured`) - /// Storage: `Messages::Messages` (r:1 w:1) - /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// Proof: `Msa::DelegatorAndProviderToDelegation` (`max_values`: None, `max_size`: Some(217), added: 2692, mode: `MaxEncodedLen`) + /// Storage: `Messages::MessagesV2` (r:0 w:1) + /// Proof: `Messages::MessagesV2` (`max_values`: None, `max_size`: Some(3123), added: 5598, mode: `MaxEncodedLen`) /// The range of component `n` is `[0, 3071]`. fn add_onchain_message(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `9623` - // Estimated: `21998` - // Minimum execution time: 46_448_000 picoseconds. - Weight::from_parts(47_830_962, 21998) - // Standard Error: 67 - .saturating_add(Weight::from_parts(957, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) + // Measured: `402` + // Estimated: `12592` + // Minimum execution time: 32_164_000 picoseconds. + Weight::from_parts(33_345_645, 12592) + // Standard Error: 43 + .saturating_add(Weight::from_parts(848, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Schemas::SchemaInfos` (r:1 w:0) - /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `Measured`) + /// Proof: `Schemas::SchemaInfos` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) /// Storage: `Msa::PublicKeyToMsaId` (r:1 w:0) - /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `Measured`) - /// Storage: `Messages::Messages` (r:1 w:1) - /// Proof: `Messages::Messages` (`max_values`: None, `max_size`: Some(618624), added: 621099, mode: `Measured`) + /// Proof: `Msa::PublicKeyToMsaId` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Messages::MessagesV2` (r:0 w:1) + /// Proof: `Messages::MessagesV2` (`max_values`: None, `max_size`: Some(3123), added: 5598, mode: `MaxEncodedLen`) fn add_ipfs_message() -> Weight { // Proof Size summary in bytes: - // Measured: `7833` - // Estimated: `20208` - // Minimum execution time: 45_816_000 picoseconds. - Weight::from_parts(47_622_000, 20208) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `790` + // Estimated: `12423` + // Minimum execution time: 31_839_000 picoseconds. + Weight::from_parts(32_576_000, 12423) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/schemas/src/weights.rs b/pallets/schemas/src/weights.rs index 362a91fc74..a64177a2bd 100644 --- a/pallets/schemas/src/weights.rs +++ b/pallets/schemas/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_schemas //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-10, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-d4nrm`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -72,10 +72,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_624_000 picoseconds. - Weight::from_parts(15_710_000, 10399) - // Standard Error: 44 - .saturating_add(Weight::from_parts(33_970, 0).saturating_mul(m.into())) + // Minimum execution time: 15_733_000 picoseconds. + Weight::from_parts(16_003_000, 10399) + // Standard Error: 43 + .saturating_add(Weight::from_parts(34_311, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -92,10 +92,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_741_000 picoseconds. - Weight::from_parts(15_821_000, 10399) - // Standard Error: 45 - .saturating_add(Weight::from_parts(34_049, 0).saturating_mul(m.into())) + // Minimum execution time: 15_842_000 picoseconds. + Weight::from_parts(16_036_000, 10399) + // Standard Error: 47 + .saturating_add(Weight::from_parts(34_330, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -114,10 +114,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_689_000 picoseconds. - Weight::from_parts(10_698_818, 12605) - // Standard Error: 33 - .saturating_add(Weight::from_parts(3_122, 0).saturating_mul(m.into())) + // Minimum execution time: 21_487_000 picoseconds. + Weight::from_parts(11_162_870, 12605) + // Standard Error: 31 + .saturating_add(Weight::from_parts(3_121, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -134,10 +134,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_629_000 picoseconds. - Weight::from_parts(15_771_000, 10399) - // Standard Error: 41 - .saturating_add(Weight::from_parts(34_326, 0).saturating_mul(m.into())) + // Minimum execution time: 15_775_000 picoseconds. + Weight::from_parts(15_884_000, 10399) + // Standard Error: 48 + .saturating_add(Weight::from_parts(34_322, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -147,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_005_000 picoseconds. - Weight::from_parts(7_235_000, 0) + // Minimum execution time: 6_505_000 picoseconds. + Weight::from_parts(6_843_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -168,10 +168,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_624_000 picoseconds. - Weight::from_parts(15_710_000, 10399) - // Standard Error: 44 - .saturating_add(Weight::from_parts(33_970, 0).saturating_mul(m.into())) + // Minimum execution time: 15_733_000 picoseconds. + Weight::from_parts(16_003_000, 10399) + // Standard Error: 43 + .saturating_add(Weight::from_parts(34_311, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -188,10 +188,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_741_000 picoseconds. - Weight::from_parts(15_821_000, 10399) - // Standard Error: 45 - .saturating_add(Weight::from_parts(34_049, 0).saturating_mul(m.into())) + // Minimum execution time: 15_842_000 picoseconds. + Weight::from_parts(16_036_000, 10399) + // Standard Error: 47 + .saturating_add(Weight::from_parts(34_330, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -210,10 +210,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `230` // Estimated: `12605` - // Minimum execution time: 21_689_000 picoseconds. - Weight::from_parts(10_698_818, 12605) - // Standard Error: 33 - .saturating_add(Weight::from_parts(3_122, 0).saturating_mul(m.into())) + // Minimum execution time: 21_487_000 picoseconds. + Weight::from_parts(11_162_870, 12605) + // Standard Error: 31 + .saturating_add(Weight::from_parts(3_121, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -230,10 +230,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `10399` - // Minimum execution time: 15_629_000 picoseconds. - Weight::from_parts(15_771_000, 10399) - // Standard Error: 41 - .saturating_add(Weight::from_parts(34_326, 0).saturating_mul(m.into())) + // Minimum execution time: 15_775_000 picoseconds. + Weight::from_parts(15_884_000, 10399) + // Standard Error: 48 + .saturating_add(Weight::from_parts(34_322, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -243,8 +243,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_005_000 picoseconds. - Weight::from_parts(7_235_000, 0) + // Minimum execution time: 6_505_000 picoseconds. + Weight::from_parts(6_843_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/stateful-storage/src/weights.rs b/pallets/stateful-storage/src/weights.rs index 619017e1dc..146c672dd5 100644 --- a/pallets/stateful-storage/src/weights.rs +++ b/pallets/stateful-storage/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_stateful_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-10, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `benchmark-runner-44wtw-n2ql6`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `benchmark-runner-44wtw-d4nrm`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024 // Executed Command: @@ -73,10 +73,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33346` // Estimated: `45721` - // Minimum execution time: 95_864_000 picoseconds. - Weight::from_parts(100_554_019, 45721) - // Standard Error: 615 - .saturating_add(Weight::from_parts(4_988, 0).saturating_mul(s.into())) + // Minimum execution time: 97_596_000 picoseconds. + Weight::from_parts(95_196_204, 45721) + // Standard Error: 469 + .saturating_add(Weight::from_parts(7_119, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -93,10 +93,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `392` // Estimated: `12767` - // Minimum execution time: 28_918_000 picoseconds. - Weight::from_parts(29_786_260, 12767) - // Standard Error: 179 - .saturating_add(Weight::from_parts(963, 0).saturating_mul(s.into())) + // Minimum execution time: 29_612_000 picoseconds. + Weight::from_parts(31_961_486, 12767) + // Standard Error: 972 + .saturating_add(Weight::from_parts(596, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -112,8 +112,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1551` // Estimated: `13926` - // Minimum execution time: 32_286_000 picoseconds. - Weight::from_parts(33_306_000, 13926) + // Minimum execution time: 32_983_000 picoseconds. + Weight::from_parts(33_821_000, 13926) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -128,10 +128,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33353` // Estimated: `45728` - // Minimum execution time: 154_862_000 picoseconds. - Weight::from_parts(149_197_324, 45728) - // Standard Error: 483 - .saturating_add(Weight::from_parts(12_598, 0).saturating_mul(s.into())) + // Minimum execution time: 155_737_000 picoseconds. + Weight::from_parts(153_426_516, 45728) + // Standard Error: 639 + .saturating_add(Weight::from_parts(12_619, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -146,10 +146,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `325` // Estimated: `12700` - // Minimum execution time: 82_069_000 picoseconds. - Weight::from_parts(83_641_051, 12700) - // Standard Error: 201 - .saturating_add(Weight::from_parts(6_617, 0).saturating_mul(s.into())) + // Minimum execution time: 83_880_000 picoseconds. + Weight::from_parts(85_475_027, 12700) + // Standard Error: 357 + .saturating_add(Weight::from_parts(5_950, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -163,8 +163,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1484` // Estimated: `13859` - // Minimum execution time: 85_991_000 picoseconds. - Weight::from_parts(86_655_000, 13859) + // Minimum execution time: 87_068_000 picoseconds. + Weight::from_parts(87_902_000, 13859) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -185,10 +185,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33346` // Estimated: `45721` - // Minimum execution time: 95_864_000 picoseconds. - Weight::from_parts(100_554_019, 45721) - // Standard Error: 615 - .saturating_add(Weight::from_parts(4_988, 0).saturating_mul(s.into())) + // Minimum execution time: 97_596_000 picoseconds. + Weight::from_parts(95_196_204, 45721) + // Standard Error: 469 + .saturating_add(Weight::from_parts(7_119, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -205,10 +205,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `392` // Estimated: `12767` - // Minimum execution time: 28_918_000 picoseconds. - Weight::from_parts(29_786_260, 12767) - // Standard Error: 179 - .saturating_add(Weight::from_parts(963, 0).saturating_mul(s.into())) + // Minimum execution time: 29_612_000 picoseconds. + Weight::from_parts(31_961_486, 12767) + // Standard Error: 972 + .saturating_add(Weight::from_parts(596, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -224,8 +224,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1551` // Estimated: `13926` - // Minimum execution time: 32_286_000 picoseconds. - Weight::from_parts(33_306_000, 13926) + // Minimum execution time: 32_983_000 picoseconds. + Weight::from_parts(33_821_000, 13926) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -240,10 +240,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33353` // Estimated: `45728` - // Minimum execution time: 154_862_000 picoseconds. - Weight::from_parts(149_197_324, 45728) - // Standard Error: 483 - .saturating_add(Weight::from_parts(12_598, 0).saturating_mul(s.into())) + // Minimum execution time: 155_737_000 picoseconds. + Weight::from_parts(153_426_516, 45728) + // Standard Error: 639 + .saturating_add(Weight::from_parts(12_619, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -258,10 +258,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `325` // Estimated: `12700` - // Minimum execution time: 82_069_000 picoseconds. - Weight::from_parts(83_641_051, 12700) - // Standard Error: 201 - .saturating_add(Weight::from_parts(6_617, 0).saturating_mul(s.into())) + // Minimum execution time: 83_880_000 picoseconds. + Weight::from_parts(85_475_027, 12700) + // Standard Error: 357 + .saturating_add(Weight::from_parts(5_950, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -275,8 +275,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1484` // Estimated: `13859` - // Minimum execution time: 85_991_000 picoseconds. - Weight::from_parts(86_655_000, 13859) + // Minimum execution time: 87_068_000 picoseconds. + Weight::from_parts(87_902_000, 13859) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From a96bc9babd8a33cc25a2da0094f838d93653cc56 Mon Sep 17 00:00:00 2001 From: Aramik Date: Fri, 10 Nov 2023 15:50:34 -0800 Subject: [PATCH 14/14] fixed design doc --- designdocs/schema_v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designdocs/schema_v2.md b/designdocs/schema_v2.md index 90bb772e51..aa114ca3b2 100644 --- a/designdocs/schema_v2.md +++ b/designdocs/schema_v2.md @@ -40,7 +40,7 @@ pub struct SchemaInfo { } ``` ### Expected PoV improvements -This PoV improvement would not extrinsic weights in this pallet, but it would directly affect any +This PoV improvement would not affect extrinsic weights in this pallet, but it would directly affect any pallet that is dependent on **Schemas** pallet. Some of these pallets are **Messages** and **Stateful-Storage**. After these changes we are expecting see to see around 30-60KiB decrease in PoV for `MaxEncodedLen` mode.