mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Introduce BlockExecutionWeight and ExtrinsicBaseWeight (#5722)
* Introduce `BlockExectionWeight` and `ExtrinsicBaseWeight` * Add new traits everywhere * Missed one update * fix tests * Update `check_weight` logic * introduce `max_extrinsic_weight` function * fix + add tests * format nits * remove println * make test a bit more clear * Remove minimum weight * newlines left over from find/replace * Fix test, improve clarity * Fix executor tests * Extrinsic base weight same as old `MINIMUM_WEIGHT` * fix example test * Expose constants * Add test for full block with operational and normal * Initiate test environment with `BlockExecutionWeight` weight * format nit * Update frame/system/src/lib.rs Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Replace `TransactionBaseFee` with `ExtrinsicBaseWeight` (#5761) * Replace `TransactionBaseFee` with `ExtrinsicBaseFee` * Fix stuff * Fix and make tests better * Forgot to update this test * Fix priority number in test * Remove minimum weight from merge * Fix weight in contracts * remove `TransactionBaseFee` from contract tests * Let `register_extra_weight_unchecked` go past `MaximumBlockWeight` * address feedback Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -62,7 +62,6 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::MINIMUM_WEIGHT;
|
||||
//! # use pallet_timestamp as timestamp;
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//!
|
||||
@@ -70,7 +69,7 @@
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = MINIMUM_WEIGHT]
|
||||
//! #[weight = 0]
|
||||
//! pub fn get_time(origin) -> dispatch::DispatchResult {
|
||||
//! let _sender = ensure_signed(origin)?;
|
||||
//! let _now = <timestamp::Module<T>>::get();
|
||||
@@ -101,7 +100,7 @@ use frame_support::debug;
|
||||
use frame_support::{
|
||||
Parameter, decl_storage, decl_module,
|
||||
traits::{Time, UnixTime, Get},
|
||||
weights::{MINIMUM_WEIGHT, DispatchClass},
|
||||
weights::{DispatchClass},
|
||||
};
|
||||
use sp_runtime::{
|
||||
RuntimeString,
|
||||
@@ -148,13 +147,13 @@ decl_module! {
|
||||
/// `MinimumPeriod`.
|
||||
///
|
||||
/// The dispatch origin for this call must be `Inherent`.
|
||||
///
|
||||
///
|
||||
/// # <weight>
|
||||
/// - `O(T)` where `T` complexity of `on_timestamp_set`
|
||||
/// - 2 storage mutations (codec `O(1)`).
|
||||
/// - 1 event handler `on_timestamp_set` `O(T)`.
|
||||
/// # </weight>
|
||||
#[weight = (MINIMUM_WEIGHT, DispatchClass::Mandatory)]
|
||||
#[weight = (0, DispatchClass::Mandatory)]
|
||||
fn set(origin, #[compact] now: T::Moment) {
|
||||
ensure_none(origin)?;
|
||||
assert!(!<Self as Store>::DidUpdate::exists(), "Timestamp must be updated only once in the block");
|
||||
@@ -313,6 +312,8 @@ mod tests {
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type BlockExecutionWeight = ();
|
||||
type ExtrinsicBaseWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
Reference in New Issue
Block a user