mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 03:41:02 +00:00
Weight annotation. (#3157)
* Make extrinsics extensible. Also Remove old extrinsic types. * Rest of mockup. Add tips. * Fix some build issues * Runtiem builds :) * Substrate builds. * Fix a doc test * Compact encoding * Extract out the era logic into an extension * Weight Check signed extension. (#3115) * Weight signed extension. * Revert a bit + test for check era. * Update Cargo.toml * Update node/cli/src/factory_impl.rs * Update node/executor/src/lib.rs * Update node/executor/src/lib.rs * Don't use len for weight - use data. * Operational Transaction; second attempt (#3138) * working poc added. * some fixes. * Update doc. * Fix all tests + final logic. * more refactoring. * nits. * System block limit in bytes. * Silent the storage macro warnings. * More logic more tests. * Fix import. * Refactor names. * Fix build. * Update srml/balances/src/lib.rs * Final refactor. * Bump transaction version * Fix weight mult test. * Fix more tests and improve doc. * Bump. * Make some tests work again. * Fix subkey. * Remove todos + bump. * First draft of annotating weights. * Refactor weight to u64. * More refactoring and tests. * New convert for weight to fee * more tests. * remove merge redundancy. * Fix system test. * Bring back subkey stuff. * a few stress tests. * fix some of the grumbles. * Final nits. * Update srml/system/src/lib.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Scale weights by 1000. * Bump. * Fix decl_storage test.
This commit is contained in:
committed by
Bastian Köcher
parent
80472956f8
commit
002acb9373
@@ -182,11 +182,16 @@ impl Permill {
|
||||
/// Everything.
|
||||
pub fn one() -> Self { Self(1_000_000) }
|
||||
|
||||
/// create a new raw instance. This can be called at compile time.
|
||||
pub const fn from_const_parts(parts: u32) -> Self {
|
||||
Self([parts, 1_000_000][(parts > 1_000_000) as usize])
|
||||
}
|
||||
|
||||
/// From an explicitly defined number of parts per maximum of the type.
|
||||
pub fn from_parts(x: u32) -> Self { Self(x.min(1_000_000)) }
|
||||
pub fn from_parts(parts: u32) -> Self { Self::from_const_parts(parts) }
|
||||
|
||||
/// Converts from a percent. Equal to `x / 100`.
|
||||
pub fn from_percent(x: u32) -> Self { Self(x.min(100) * 10_000) }
|
||||
pub const fn from_percent(x: u32) -> Self { Self([x, 100][(x > 100) as usize] * 10_000) }
|
||||
|
||||
/// Converts a fraction into `Permill`.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -286,11 +291,16 @@ impl Perbill {
|
||||
/// Everything.
|
||||
pub fn one() -> Self { Self(1_000_000_000) }
|
||||
|
||||
/// create a new raw instance. This can be called at compile time.
|
||||
pub const fn from_const_parts(parts: u32) -> Self {
|
||||
Self([parts, 1_000_000_000][(parts > 1_000_000_000) as usize])
|
||||
}
|
||||
|
||||
/// From an explicitly defined number of parts per maximum of the type.
|
||||
pub fn from_parts(x: u32) -> Self { Self(x.min(1_000_000_000)) }
|
||||
pub fn from_parts(parts: u32) -> Self { Self::from_const_parts(parts) }
|
||||
|
||||
/// Converts from a percent. Equal to `x / 100`.
|
||||
pub fn from_percent(x: u32) -> Self { Self(x.min(100) * 10_000_000) }
|
||||
pub const fn from_percent(x: u32) -> Self { Self([x, 100][(x > 100) as usize] * 10_000_000) }
|
||||
|
||||
/// Construct new instance where `x` is in millionths. Value equivalent to `x / 1,000,000`.
|
||||
pub fn from_millionths(x: u32) -> Self { Self(x.min(1_000_000) * 1000) }
|
||||
@@ -411,11 +421,12 @@ impl Fixed64 {
|
||||
|
||||
/// Performs a saturated multiply and accumulate.
|
||||
///
|
||||
/// Returns `n + (self * n)`.
|
||||
/// Returns a saturated `n + (self * n)`.
|
||||
/// TODO: generalize this to any weight type. #3189
|
||||
pub fn saturated_multiply_accumulate(&self, int: u32) -> u32 {
|
||||
let parts = self.0;
|
||||
|
||||
let positive = parts > 0;
|
||||
|
||||
// natural parts might overflow.
|
||||
let natural_parts = self.clone().saturated_into::<u32>();
|
||||
// fractional parts can always fit into u32.
|
||||
@@ -459,8 +470,8 @@ impl Saturating for Fixed64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait for
|
||||
/// safe addition.
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait
|
||||
/// for safe addition.
|
||||
impl ops::Add for Fixed64 {
|
||||
type Output = Self;
|
||||
|
||||
@@ -469,8 +480,8 @@ impl ops::Add for Fixed64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait for
|
||||
/// safe subtraction.
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait
|
||||
/// for safe subtraction.
|
||||
impl ops::Sub for Fixed64 {
|
||||
type Output = Self;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user