forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue paritytech#11090 Update
- Loading branch information
Showing
9 changed files
with
78 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "node-template-weights" | ||
name = "node-template-runtime-constants" | ||
version = "4.0.0-dev" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2021" | ||
|
@@ -16,30 +16,30 @@ serde = { version = "1.0.136", optional = true, features = ["derive"] } | |
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } | ||
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } | ||
frame-metadata = { version = "15.0.0", default-features = false, features = ["v14"] } | ||
sp-std = { version = "4.0.0", default-features = false, path = "../../../primitives/std" } | ||
sp-io = { version = "6.0.0", default-features = false, path = "../../../primitives/io" } | ||
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../primitives/runtime" } | ||
sp-tracing = { version = "5.0.0", default-features = false, path = "../../../primitives/tracing" } | ||
sp-core = { version = "6.0.0", default-features = false, path = "../../../primitives/core" } | ||
sp-arithmetic = { version = "5.0.0", default-features = false, path = "../../../primitives/arithmetic" } | ||
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/inherents" } | ||
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" } | ||
sp-std = { version = "4.0.0", default-features = false, path = "../../../../primitives/std" } | ||
sp-io = { version = "6.0.0", default-features = false, path = "../../../../primitives/io" } | ||
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../../primitives/runtime" } | ||
sp-tracing = { version = "5.0.0", default-features = false, path = "../../../../primitives/tracing" } | ||
sp-core = { version = "6.0.0", default-features = false, path = "../../../../primitives/core" } | ||
sp-arithmetic = { version = "5.0.0", default-features = false, path = "../../../../primitives/arithmetic" } | ||
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/inherents" } | ||
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/staking" } | ||
tt-call = "1.0.8" | ||
frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support/procedural" } | ||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support" } | ||
frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/support/procedural" } | ||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/support" } | ||
paste = "1.0" | ||
once_cell = { version = "1", default-features = false, optional = true } | ||
sp-state-machine = { version = "0.12.0", optional = true, path = "../../../primitives/state-machine" } | ||
sp-state-machine = { version = "0.12.0", optional = true, path = "../../../../primitives/state-machine" } | ||
bitflags = "1.3" | ||
impl-trait-for-tuples = "0.2.1" | ||
smallvec = "1.8.0" | ||
log = { version = "0.4.14", default-features = false } | ||
sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../../primitives/core/hashing/proc-macro" } | ||
sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../../../primitives/core/hashing/proc-macro" } | ||
|
||
[dev-dependencies] | ||
assert_matches = "1.3.0" | ||
pretty_assertions = "1.0.0" | ||
frame-system = { version = "4.0.0-dev", path = "../../../frame/system" } | ||
frame-system = { version = "4.0.0-dev", path = "../../../../frame/system" } | ||
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] } | ||
|
||
[features] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
mod block_weights; | ||
mod extrinsic_weights; | ||
mod paritydb_weights; | ||
mod rocksdb_weights; | ||
|
||
use codec::{Decode, Encode}; | ||
use scale_info::TypeInfo; | ||
use sp_runtime::RuntimeDebug; | ||
|
||
/// Numeric range of a transaction weight. | ||
pub type Weight = u64; | ||
|
||
/// The weight of database operations that the runtime can invoke. | ||
#[derive(Clone, Copy, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo)] | ||
pub struct RuntimeDbWeight { | ||
pub read: Weight, | ||
pub write: Weight, | ||
} | ||
|
||
impl RuntimeDbWeight { | ||
pub fn reads(self, r: Weight) -> Weight { | ||
self.read.saturating_mul(r) | ||
} | ||
|
||
pub fn writes(self, w: Weight) -> Weight { | ||
self.write.saturating_mul(w) | ||
} | ||
|
||
pub fn reads_writes(self, r: Weight, w: Weight) -> Weight { | ||
let read_weight = self.read.saturating_mul(r); | ||
let write_weight = self.write.saturating_mul(w); | ||
read_weight.saturating_add(write_weight) | ||
} | ||
} | ||
|
||
pub mod constants { | ||
use super::Weight; | ||
|
||
pub const WEIGHT_PER_SECOND: Weight = 1_000_000_000_000; | ||
pub const WEIGHT_PER_MILLIS: Weight = WEIGHT_PER_SECOND / 1000; | ||
// 1_000_000_000 | ||
pub const WEIGHT_PER_MICROS: Weight = WEIGHT_PER_MILLIS / 1000; | ||
// 1_000_000 | ||
pub const WEIGHT_PER_NANOS: Weight = WEIGHT_PER_MICROS / 1000; // 1_000 | ||
|
||
// Expose the Block and Extrinsic base weights. | ||
pub use super::{ | ||
block_weights::constants::BlockExecutionWeight, | ||
extrinsic_weights::constants::ExtrinsicBaseWeight, | ||
}; | ||
|
||
// Expose the DB weights. | ||
pub use super::{ | ||
paritydb_weights::constants::ParityDbWeight, rocksdb_weights::constants::RocksDbWeight, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters