From 0010079f0da3d70df3eb7ae5a1a8b8bc0eafde33 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Fri, 7 Jul 2023 16:18:28 +0200 Subject: [PATCH] HB SBP Milestone review #2 --- pallets/hyperdrive/src/lib.rs | 17 +++++++++++ pallets/marketplace/src/lib.rs | 42 ++++++++++++++++++++++++++++ pallets/marketplace/src/migration.rs | 6 ++++ pallets/marketplace/src/types.rs | 20 +++++++++++++ pallets/marketplace/src/weights.rs | 5 ++++ 5 files changed, 90 insertions(+) diff --git a/pallets/hyperdrive/src/lib.rs b/pallets/hyperdrive/src/lib.rs index 5c50491a..e1ef5426 100644 --- a/pallets/hyperdrive/src/lib.rs +++ b/pallets/hyperdrive/src/lib.rs @@ -334,6 +334,13 @@ pub mod pallet { /// We fail with a [`DispatchError`] if the given `proof` is invalid. /// Any error happening afterwards, while decoding the payload and triggering actions, emits an event informing about the error but does not fail the extrinsic. /// This is necessary to make [`MessageSequenceId`] update in any case. + + /// #[pallet::call_index(2)] #[pallet::weight(< T as Config>::WeightInfo::submit_message())] pub fn submit_message( @@ -368,6 +375,11 @@ pub mod pallet { /// Updates the target chain owner (contract address) in storage. Can only be called by a privileged/root account. #[pallet::call_index(3)] + /// #[pallet::weight(Weight::from_parts(10_000, 0).saturating_add(T::DbWeight::get().reads_writes(1, 0)))] pub fn update_target_chain_owner( origin: OriginFor, @@ -430,6 +442,11 @@ pub mod pallet { Self::process_action(payload_bytes) } + /// #[transactional] fn process_action(message_bytes: &Vec) -> Result<(), ProcessMessageResult> { let action = T::MessageParser::parse_value(message_bytes) diff --git a/pallets/marketplace/src/lib.rs b/pallets/marketplace/src/lib.rs index 5503d76b..d84400fa 100644 --- a/pallets/marketplace/src/lib.rs +++ b/pallets/marketplace/src/lib.rs @@ -96,6 +96,13 @@ pub mod pallet { pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + /// #[pallet::pallet] #[pallet::without_storage_info] #[pallet::storage_version(STORAGE_VERSION)] @@ -360,6 +367,11 @@ pub mod pallet { } } + /// #[pallet::hooks] impl Hooks> for Pallet { fn on_runtime_upgrade() -> frame_support::weights::Weight { @@ -413,6 +425,12 @@ pub mod pallet { /// Proposes processors to match with a job. The match fails if it conflicts with the processor's schedule. #[pallet::call_index(2)] + /// #[pallet::weight(< T as Config >::WeightInfo::propose_matching())] pub fn propose_matching( origin: OriginFor, @@ -486,6 +504,12 @@ pub mod pallet { /// the report is accepted if `[now, now + tolerance]` overlaps with an execution of the schedule agreed on. /// `tolerance` is a pallet config value. #[pallet::call_index(4)] + /// #[pallet::weight(< T as Config >::WeightInfo::report())] pub fn report( origin: OriginFor, @@ -573,6 +597,12 @@ pub mod pallet { /// Called by processors when the assigned job can be finalized. #[pallet::call_index(5)] + /// #[pallet::weight(::WeightInfo::finalize_job())] pub fn finalize_job( origin: OriginFor, @@ -654,6 +684,12 @@ pub mod pallet { /// /// For details see [`Pallet::finalize_jobs_for`]. #[pallet::call_index(6)] + /// #[pallet::weight(::WeightInfo::finalize_jobs())] pub fn finalize_jobs( origin: OriginFor, @@ -675,6 +711,12 @@ pub mod pallet { } } + /// impl JobHooks for Pallet { /// Registers a job in the marketplace by providing a [JobRegistration]. /// If a job for the same `(accountId, script)` was previously registered, it will be overwritten. diff --git a/pallets/marketplace/src/migration.rs b/pallets/marketplace/src/migration.rs index a21a6ad1..34c1785d 100644 --- a/pallets/marketplace/src/migration.rs +++ b/pallets/marketplace/src/migration.rs @@ -64,6 +64,12 @@ fn migrate_to_v2() -> Weight { T::DbWeight::get().reads_writes(count + 1, count + 1) } +/// fn migrate_to_v3() -> Weight { let mut count = 0u32; count += StoredJobStatus::::clear(10_000, None).loops; diff --git a/pallets/marketplace/src/types.rs b/pallets/marketplace/src/types.rs index d49293b7..b2c71e20 100644 --- a/pallets/marketplace/src/types.rs +++ b/pallets/marketplace/src/types.rs @@ -70,6 +70,11 @@ pub struct AdvertisementRestriction { /// Storage capacity in bytes not to be exceeded in matching. The associated fee is listed in [pricing]. pub storage_capacity: u32, /// An optional array of the [AccountId]s of consumers whose jobs should get accepted. If the array is [None], then jobs from all consumers are accepted. + /// pub allowed_consumers: Option>>, /// The modules available to the job on processor. pub available_modules: JobModules, @@ -185,6 +190,11 @@ pub struct JobRequirements { pub min_reputation: Option, /// Optional match provided with the job requirements. If provided, it gets processed instantaneously during /// registration call and validation errors lead to abortion of the call. + /// pub instant_match: Option>>, } @@ -194,6 +204,11 @@ pub struct Match { /// The job to match. pub job_id: JobId, /// The sources to match each of the job's slots with. + /// pub sources: Vec>, } @@ -205,6 +220,11 @@ pub struct Match { #[derive(RuntimeDebug, Encode, Decode, TypeInfo, Clone, PartialEq)] pub struct PartialJobRegistration { /// An optional array of the [AccountId]s allowed to fulfill the job. If the array is [None], then all sources are allowed. + /// pub allowed_sources: Option>, /// A boolean indicating if only verified sources can fulfill the job. A verified source is one that has provided a valid key attestation. pub allow_only_verified_sources: bool, diff --git a/pallets/marketplace/src/weights.rs b/pallets/marketplace/src/weights.rs index 13bc7154..9bb43ca8 100644 --- a/pallets/marketplace/src/weights.rs +++ b/pallets/marketplace/src/weights.rs @@ -59,6 +59,11 @@ impl WeightInfo for Weights { .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } + /// fn propose_matching() -> Weight { // Minimum execution time: nanoseconds. Weight::from_parts(129_864_000, 0)