Skip to content

Commit

Permalink
Use db reads/writes as weights
Browse files Browse the repository at this point in the history
  • Loading branch information
elfedy committed Mar 22, 2024
1 parent b2e77f4 commit 33fd351
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions pallets/emergency-para-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ cumulus-pallet-parachain-system = { workspace = true }
# Polkadot
polkadot-parachain-primitives = { workspace = true }

# Benchmarks
frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
sp-core = { workspace = true, features = [ "std" ] }
sp-io = { workspace = true, features = [ "std" ] }
Expand All @@ -37,6 +40,7 @@ substrate-test-runtime-client = { workspace = true }
[features]
default = [ "std" ]
std = [
"frame-benchmarking/std",
"cumulus-primitives-core/std",
"cumulus-pallet-parachain-system/std",
"frame-support/std",
Expand All @@ -48,4 +52,9 @@ std = [
"sp-runtime/std",
"sp-std/std",
]

runtime-benchmarks = [
"frame-benchmarking",
]

try-runtime = [ "frame-support/try-runtime" ]
4 changes: 2 additions & 2 deletions pallets/emergency-para-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight((0, DispatchClass::Operational))]
#[pallet::weight((T::DbWeight::get().reads_writes(1, 2), DispatchClass::Operational))]
pub fn paused_to_normal(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
T::PausedToNormalOrigin::ensure_origin(origin)?;

Expand All @@ -131,7 +131,7 @@ pub mod pallet {
}

#[pallet::call_index(1)]
#[pallet::weight((1_000_000, DispatchClass::Operational))]
#[pallet::weight((T::DbWeight::get().read, DispatchClass::Operational))]
pub fn fast_authorize_upgrade(origin: OriginFor<T>, code_hash: T::Hash) -> DispatchResult {
T::FastAuthorizeUpgradeOrigin::ensure_origin(origin)?;
ensure!(
Expand Down

0 comments on commit 33fd351

Please sign in to comment.