mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Update System Weights (#5888)
* Update system weights * Use maximum block weight for scheduler * Update offences to use full block * Move weight inside if statement * Add one read to offences `on_initialize` * Delete factory test * Revert "Delete factory test" This reverts commit 8f95aacd63a028ef1b415185b45367b4140d86fd. * Revert "Add one read to offences `on_initialize`" This reverts commit 7df7ebc73625ed79b14086f13c247d4058ee87d6. * Revert "Move weight inside if statement" This reverts commit 87277d07913a7d1868eeee85ef4673f51ee4013b. * Revert "Update offences to use full block" This reverts commit 0bbe0ce18e9419b032157f7d37dea6481078cdc0. * Use scheduler in Sudo * Apply suggestions from code review Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Revert "Use scheduler in Sudo" This reverts commit 95bd2768dfea100bdf682cf4fe6c0f46e8e1f66e. * remove max extrinsic weight (it does nothing useful) * fix tests * introduce `sudo_unchecked_weight` * bump spec version * scheduler 80 percent of maximum * Update `set_changes_trie_config` weight * Update bin/node/runtime/src/lib.rs * Update frame/democracy/src/tests.rs * Update tests.rs * update based on feedback Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
@@ -92,7 +92,7 @@ use sp_runtime::{DispatchResult, traits::{StaticLookup, Dispatchable}};
|
||||
use frame_support::{
|
||||
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
|
||||
};
|
||||
use frame_support::weights::{GetDispatchInfo, FunctionOf, Pays};
|
||||
use frame_support::weights::{Weight, GetDispatchInfo, FunctionOf, Pays};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
pub trait Trait: frame_system::Trait {
|
||||
@@ -134,6 +134,30 @@ decl_module! {
|
||||
Self::deposit_event(RawEvent::Sudid(res.map(|_| ()).map_err(|e| e.error)));
|
||||
}
|
||||
|
||||
/// Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||
/// This function does not check the weight of the call, and instead allows the
|
||||
/// Sudo user to specify the weight of the call.
|
||||
///
|
||||
/// The dispatch origin for this call must be _Signed_.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - O(1).
|
||||
/// - The weight of this call is defined by the caller.
|
||||
/// # </weight>
|
||||
#[weight = FunctionOf(
|
||||
|(_, &weight): (&Box<<T as Trait>::Call>,&Weight,)| weight,
|
||||
|(call, _): (&Box<<T as Trait>::Call>,&Weight,)| call.get_dispatch_info().class,
|
||||
Pays::Yes,
|
||||
)]
|
||||
fn sudo_unchecked_weight(origin, call: Box<<T as Trait>::Call>, _weight: Weight) {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let sender = ensure_signed(origin)?;
|
||||
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
|
||||
|
||||
let res = call.dispatch(frame_system::RawOrigin::Root.into());
|
||||
Self::deposit_event(RawEvent::Sudid(res.map(|_| ()).map_err(|e| e.error)));
|
||||
}
|
||||
|
||||
/// Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
|
||||
///
|
||||
/// The dispatch origin for this call must be _Signed_.
|
||||
|
||||
Reference in New Issue
Block a user