mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-11-17 16:16:09 +00:00
FRAME: Create TransactionExtension as a replacement for SignedExtension (#2280)
Closes #2160 First part of [Extrinsic Horizon](https://github.com/paritytech/polkadot-sdk/issues/2415) Introduces a new trait `TransactionExtension` to replace `SignedExtension`. Introduce the idea of transactions which obey the runtime's extensions and have according Extension data (né Extra data) yet do not have hard-coded signatures. Deprecate the terminology of "Unsigned" when used for transactions/extrinsics owing to there now being "proper" unsigned transactions which obey the extension framework and "old-style" unsigned which do not. Instead we have __*General*__ for the former and __*Bare*__ for the latter. (Ultimately, the latter will be phased out as a type of transaction, and Bare will only be used for Inherents.) Types of extrinsic are now therefore: - Bare (no hardcoded signature, no Extra data; used to be known as "Unsigned") - Bare transactions (deprecated): Gossiped, validated with `ValidateUnsigned` (deprecated) and the `_bare_compat` bits of `TransactionExtension` (deprecated). - Inherents: Not gossiped, validated with `ProvideInherent`. - Extended (Extra data): Gossiped, validated via `TransactionExtension`. - Signed transactions (with a hardcoded signature). - General transactions (without a hardcoded signature). `TransactionExtension` differs from `SignedExtension` because: - A signature on the underlying transaction may validly not be present. - It may alter the origin during validation. - `pre_dispatch` is renamed to `prepare` and need not contain the checks present in `validate`. - `validate` and `prepare` is passed an `Origin` rather than a `AccountId`. - `validate` may pass arbitrary information into `prepare` via a new user-specifiable type `Val`. - `AdditionalSigned`/`additional_signed` is renamed to `Implicit`/`implicit`. It is encoded *for the entire transaction* and passed in to each extension as a new argument to `validate`. This facilitates the ability of extensions to acts as underlying crypto. There is a new `DispatchTransaction` trait which contains only default function impls and is impl'ed for any `TransactionExtension` impler. It provides several utility functions which reduce some of the tedium from using `TransactionExtension` (indeed, none of its regular functions should now need to be called directly). Three transaction version discriminator ("versions") are now permissible: - 0b000000100: Bare (used to be called "Unsigned"): contains Signature or Extra (extension data). After bare transactions are no longer supported, this will strictly identify an Inherents only. - 0b100000100: Old-school "Signed" Transaction: contains Signature and Extra (extension data). - 0b010000100: New-school "General" Transaction: contains Extra (extension data), but no Signature. For the New-school General Transaction, it becomes trivial for authors to publish extensions to the mechanism for authorizing an Origin, e.g. through new kinds of key-signing schemes, ZK proofs, pallet state, mutations over pre-authenticated origins or any combination of the above. ## Code Migration ### NOW: Getting it to build Wrap your `SignedExtension`s in `AsTransactionExtension`. This should be accompanied by renaming your aggregate type in line with the new terminology. E.g. Before: ```rust /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( /* snip */ MySpecialSignedExtension, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>; ``` After: ```rust /// The extension to the basic transaction logic. pub type TxExtension = ( /* snip */ AsTransactionExtension<MySpecialSignedExtension>, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>; ``` You'll also need to alter any transaction building logic to add a `.into()` to make the conversion happen. E.g. Before: ```rust fn construct_extrinsic( /* snip */ ) -> UncheckedExtrinsic { let extra: SignedExtra = ( /* snip */ MySpecialSignedExtension::new(/* snip */), ); let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap(); let signature = payload.using_encoded(|e| sender.sign(e)); UncheckedExtrinsic::new_signed( /* snip */ Signature::Sr25519(signature), extra, ) } ``` After: ```rust fn construct_extrinsic( /* snip */ ) -> UncheckedExtrinsic { let tx_ext: TxExtension = ( /* snip */ MySpecialSignedExtension::new(/* snip */).into(), ); let payload = SignedPayload::new(call.clone(), tx_ext.clone()).unwrap(); let signature = payload.using_encoded(|e| sender.sign(e)); UncheckedExtrinsic::new_signed( /* snip */ Signature::Sr25519(signature), tx_ext, ) } ``` ### SOON: Migrating to `TransactionExtension` Most `SignedExtension`s can be trivially converted to become a `TransactionExtension`. There are a few things to know. - Instead of a single trait like `SignedExtension`, you should now implement two traits individually: `TransactionExtensionBase` and `TransactionExtension`. - Weights are now a thing and must be provided via the new function `fn weight`. #### `TransactionExtensionBase` This trait takes care of anything which is not dependent on types specific to your runtime, most notably `Call`. - `AdditionalSigned`/`additional_signed` is renamed to `Implicit`/`implicit`. - Weight must be returned by implementing the `weight` function. If your extension is associated with a pallet, you'll probably want to do this via the pallet's existing benchmarking infrastructure. #### `TransactionExtension` Generally: - `pre_dispatch` is now `prepare` and you *should not reexecute the `validate` functionality in there*! - You don't get an account ID any more; you get an origin instead. If you need to presume an account ID, then you can use the trait function `AsSystemOriginSigner::as_system_origin_signer`. - You get an additional ticket, similar to `Pre`, called `Val`. This defines data which is passed from `validate` into `prepare`. This is important since you should not be duplicating logic from `validate` to `prepare`, you need a way of passing your working from the former into the latter. This is it. - This trait takes two type parameters: `Call` and `Context`. `Call` is the runtime call type which used to be an associated type; you can just move it to become a type parameter for your trait impl. `Context` is not currently used and you can safely implement over it as an unbounded type. - There's no `AccountId` associated type any more. Just remove it. Regarding `validate`: - You get three new parameters in `validate`; all can be ignored when migrating from `SignedExtension`. - `validate` returns a tuple on success; the second item in the tuple is the new ticket type `Self::Val` which gets passed in to `prepare`. If you use any information extracted during `validate` (off-chain and on-chain, non-mutating) in `prepare` (on-chain, mutating) then you can pass it through with this. For the tuple's last item, just return the `origin` argument. Regarding `prepare`: - This is renamed from `pre_dispatch`, but there is one change: - FUNCTIONALITY TO VALIDATE THE TRANSACTION NEED NOT BE DUPLICATED FROM `validate`!! - (This is different to `SignedExtension` which was required to run the same checks in `pre_dispatch` as in `validate`.) Regarding `post_dispatch`: - Since there are no unsigned transactions handled by `TransactionExtension`, `Pre` is always defined, so the first parameter is `Self::Pre` rather than `Option<Self::Pre>`. If you make use of `SignedExtension::validate_unsigned` or `SignedExtension::pre_dispatch_unsigned`, then: - Just use the regular versions of these functions instead. - Have your logic execute in the case that the `origin` is `None`. - Ensure your transaction creation logic creates a General Transaction rather than a Bare Transaction; this means having to include all `TransactionExtension`s' data. - `ValidateUnsigned` can still be used (for now) if you need to be able to construct transactions which contain none of the extension data, however these will be phased out in stage 2 of the Transactions Horizon, so you should consider moving to an extension-centric design. ## TODO - [x] Introduce `CheckSignature` impl of `TransactionExtension` to ensure it's possible to have crypto be done wholly in a `TransactionExtension`. - [x] Deprecate `SignedExtension` and move all uses in codebase to `TransactionExtension`. - [x] `ChargeTransactionPayment` - [x] `DummyExtension` - [x] `ChargeAssetTxPayment` (asset-tx-payment) - [x] `ChargeAssetTxPayment` (asset-conversion-tx-payment) - [x] `CheckWeight` - [x] `CheckTxVersion` - [x] `CheckSpecVersion` - [x] `CheckNonce` - [x] `CheckNonZeroSender` - [x] `CheckMortality` - [x] `CheckGenesis` - [x] `CheckOnlySudoAccount` - [x] `WatchDummy` - [x] `PrevalidateAttests` - [x] `GenericSignedExtension` - [x] `SignedExtension` (chain-polkadot-bulletin) - [x] `RefundSignedExtensionAdapter` - [x] Implement `fn weight` across the board. - [ ] Go through all pre-existing extensions which assume an account signer and explicitly handle the possibility of another kind of origin. - [x] `CheckNonce` should probably succeed in the case of a non-account origin. - [x] `CheckNonZeroSender` should succeed in the case of a non-account origin. - [x] `ChargeTransactionPayment` and family should fail in the case of a non-account origin. - [ ] - [x] Fix any broken tests. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io> Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Co-authored-by: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com> Co-authored-by: Chevdor <chevdor@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Maciej <maciej.zyszkiewicz@parity.io> Co-authored-by: Javier Viola <javier@parity.io> Co-authored-by: Marcin S. <marcin@realemail.net> Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> Co-authored-by: Javier Bullrich <javier@bullrich.dev> Co-authored-by: Koute <koute@users.noreply.github.com> Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Vladimir Istyufeev <vladimir@parity.io> Co-authored-by: Ross Bulat <ross@parity.io> Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com> Co-authored-by: ordian <write@reusable.software> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Julian Eager <eagr@tutanota.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Dónal Murray <donal.murray@parity.io> Co-authored-by: yjh <yjh465402634@gmail.com> Co-authored-by: Tom Mi <tommi@niemi.lol> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will | Paradox | ParaNodes.io <79228812+paradox-tt@users.noreply.github.com> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com> Co-authored-by: Joshy Orndorff <git-user-email.h0ly5@simplelogin.com> Co-authored-by: PG Herveou <pgherveou@gmail.com> Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Juan Girini <juangirini@gmail.com> Co-authored-by: bader y <ibnbassem@gmail.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: asynchronous rob <rphmeier@gmail.com> Co-authored-by: Parth <desaiparth08@gmail.com> Co-authored-by: Andrew Jones <ascjones@gmail.com> Co-authored-by: Jonathan Udd <jonathan@dwellir.com> Co-authored-by: Serban Iorga <serban@parity.io> Co-authored-by: Egor_P <egor@parity.io> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Evgeny Snitko <evgeny@parity.io> Co-authored-by: Just van Stam <vstam1@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: gupnik <nikhilgupta.iitk@gmail.com> Co-authored-by: dzmitry-lahoda <dzmitry@lahoda.pro> Co-authored-by: zhiqiangxu <652732310@qq.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Anwesh <anweshknayak@gmail.com> Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Sam Johnson <sam@durosoft.com> Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Co-authored-by: Muharem <ismailov.m.h@gmail.com> Co-authored-by: joepetrowski <joe@parity.io> Co-authored-by: Alexandru Gheorghe <49718502+alexggh@users.noreply.github.com> Co-authored-by: Gabriel Facco de Arruda <arrudagates@gmail.com> Co-authored-by: Squirrel <gilescope@gmail.com> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Co-authored-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: command-bot <>
This commit is contained in:
+61









Gavin Wood
Nikhil Gupta
georgepisaltu
Chevdor
Bastian Köcher
Maciej
Javier Viola
Marcin S.
Tsvetomir Dimitrov
Javier Bullrich
Koute
Adrian Catangiu
Vladimir Istyufeev
Ross Bulat
Gonçalo Pestana
Liam Aharon
Svyatoslav Nikolsky
André Silva
Oliver Tale-Yazdi
s0me0ne-unkn0wn
ordian
Sebastian Kunert
Aaro Altonen
Dmitry Markin
Alexandru Vasile
Alexander Samusev
Julian Eager
Michal Kucharczyk
Davide Galassi
Dónal Murray
yjh
Tom Mi
dependabot[bot]
Will | Paradox | ParaNodes.io
Bastian Köcher
Joshy Orndorff
Joshy Orndorff
PG Herveou
Alexander Theißen
Kian Paimani
Juan Girini
bader y
James Wilson
joe petrowski
asynchronous rob
Parth
Andrew Jones
Jonathan Udd
Serban Iorga
Egor_P
Branislav Kontur
Evgeny Snitko
Just van Stam
Francisco Aguirre
gupnik
dzmitry-lahoda
zhiqiangxu
Nazar Mokrynskyi
Anwesh
cheme
Sam Johnson
kianenigma
Jegor Sidorenko
Muharem
joepetrowski
Alexandru Gheorghe
Gabriel Facco de Arruda
Squirrel
Andrei Sandu
georgepisaltu
command-bot authored and
GitHub committed 2024-03-04 19:12:43 +00:00
1 parent
b0741d4f78
commit
fd5f9292f5
349 files changed
+25580
-17081
No files matched your search
@@ -0,0 +1,213 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Benchmarks for System Extensions
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use frame_benchmarking::{account, impl_benchmark_test_suite, v2::*, BenchmarkError};
|
||||
use frame_support::{
|
||||
dispatch::{DispatchClass, DispatchInfo, PostDispatchInfo},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::{
|
||||
pallet_prelude::*, CheckGenesis, CheckMortality, CheckNonZeroSender, CheckNonce,
|
||||
CheckSpecVersion, CheckTxVersion, CheckWeight, Config, Pallet as System, RawOrigin,
|
||||
};
|
||||
use sp_runtime::{
|
||||
generic::Era,
|
||||
traits::{AsSystemOriginSigner, DispatchTransaction, Dispatchable, Get},
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub struct Pallet<T: Config>(System<T>);
|
||||
|
||||
#[benchmarks(where
|
||||
T: Send + Sync,
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
<T::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + Clone)
|
||||
]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn check_genesis() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckGenesis::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_mortality() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let ext = CheckMortality::<T>::from(Era::mortal(16, 256));
|
||||
let block_number: BlockNumberFor<T> = 17u32.into();
|
||||
System::<T>::set_block_number(block_number);
|
||||
let prev_block: BlockNumberFor<T> = 16u32.into();
|
||||
let default_hash: T::Hash = Default::default();
|
||||
frame_system::BlockHash::<T>::insert(prev_block, default_hash);
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo {
|
||||
weight: Weight::from_parts(100, 0),
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_non_zero_sender() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let ext = CheckNonZeroSender::<T>::new();
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_nonce() -> Result<(), BenchmarkError> {
|
||||
let caller: T::AccountId = account("caller", 0, 0);
|
||||
let mut info = frame_system::AccountInfo::default();
|
||||
info.nonce = 1u32.into();
|
||||
info.providers = 1;
|
||||
let expected_nonce = info.nonce + 1u32.into();
|
||||
frame_system::Account::<T>::insert(caller.clone(), info);
|
||||
let len = 0_usize;
|
||||
let ext = CheckNonce::<T>::from(1u32.into());
|
||||
let info = DispatchInfo { weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller.clone()).into(), &call, &info, len, |_| {
|
||||
Ok(().into())
|
||||
})
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let updated_info = frame_system::Account::<T>::get(caller.clone());
|
||||
assert_eq!(updated_info.nonce, expected_nonce);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_spec_version() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckSpecVersion::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_tx_version() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckTxVersion::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_weight() -> Result<(), BenchmarkError> {
|
||||
let caller = account("caller", 0, 0);
|
||||
let base_extrinsic = <T as frame_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
let info = DispatchInfo {
|
||||
weight: Weight::from_parts(base_extrinsic.ref_time() * 5, 0),
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
|
||||
let post_info = PostDispatchInfo {
|
||||
actual_weight: Some(Weight::from_parts(base_extrinsic.ref_time() * 2, 0)),
|
||||
pays_fee: Default::default(),
|
||||
};
|
||||
let len = 0_usize;
|
||||
let base_extrinsic = <T as frame_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
|
||||
let ext = CheckWeight::<T>::new();
|
||||
|
||||
let initial_block_weight = Weight::from_parts(base_extrinsic.ref_time() * 2, 0);
|
||||
frame_system::BlockWeight::<T>::mutate(|current_weight| {
|
||||
current_weight.set(Weight::zero(), DispatchClass::Mandatory);
|
||||
current_weight.set(initial_block_weight, DispatchClass::Normal);
|
||||
});
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, |_| Ok(post_info))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
System::<T>::block_weight().total(),
|
||||
initial_block_weight + base_extrinsic + post_info.actual_weight.unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test,);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ use sp_core::storage::well_known_keys;
|
||||
use sp_runtime::traits::Hash;
|
||||
use sp_std::{prelude::*, vec};
|
||||
|
||||
pub mod extensions;
|
||||
mod mock;
|
||||
|
||||
pub struct Pallet<T: Config>(System<T>);
|
||||
|
||||
@@ -57,6 +57,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type ExtensionsWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||
|
||||
@@ -19,7 +19,8 @@ use crate::{pallet_prelude::BlockNumberFor, Config, Pallet};
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, SignedExtension, Zero},
|
||||
impl_tx_ext_default,
|
||||
traits::{TransactionExtension, TransactionExtensionBase, Zero},
|
||||
transaction_validity::TransactionValidityError,
|
||||
};
|
||||
|
||||
@@ -46,30 +47,26 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckGenesis<T> {
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> CheckGenesis<T> {
|
||||
/// Creates new `SignedExtension` to check genesis hash.
|
||||
/// Creates new `TransactionExtension` to check genesis hash.
|
||||
pub fn new() -> Self {
|
||||
Self(sp_std::marker::PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckGenesis<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type Call = <T as Config>::RuntimeCall;
|
||||
type AdditionalSigned = T::Hash;
|
||||
type Pre = ();
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckGenesis<T> {
|
||||
const IDENTIFIER: &'static str = "CheckGenesis";
|
||||
|
||||
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||
type Implicit = T::Hash;
|
||||
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
|
||||
Ok(<Pallet<T>>::block_hash(BlockNumberFor::<T>::zero()))
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_genesis()
|
||||
}
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<T::RuntimeCall, Context>
|
||||
for CheckGenesis<T>
|
||||
{
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
impl_tx_ext_default!(T::RuntimeCall; Context; validate prepare);
|
||||
}
|
||||
@@ -20,10 +20,12 @@ use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
generic::Era,
|
||||
traits::{DispatchInfoOf, SaturatedConversion, SignedExtension},
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
|
||||
impl_tx_ext_default,
|
||||
traits::{
|
||||
DispatchInfoOf, SaturatedConversion, TransactionExtension, TransactionExtensionBase,
|
||||
ValidateResult,
|
||||
},
|
||||
transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction},
|
||||
};
|
||||
|
||||
/// Check for transaction mortality.
|
||||
@@ -54,29 +56,11 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckMortality<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckMortality<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type Call = T::RuntimeCall;
|
||||
type AdditionalSigned = T::Hash;
|
||||
type Pre = ();
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckMortality<T> {
|
||||
const IDENTIFIER: &'static str = "CheckMortality";
|
||||
type Implicit = T::Hash;
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
_who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
_info: &DispatchInfoOf<Self::Call>,
|
||||
_len: usize,
|
||||
) -> TransactionValidity {
|
||||
let current_u64 = <Pallet<T>>::block_number().saturated_into::<u64>();
|
||||
let valid_till = self.0.death(current_u64);
|
||||
Ok(ValidTransaction {
|
||||
longevity: valid_till.saturating_sub(current_u64),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
|
||||
let current_u64 = <Pallet<T>>::block_number().saturated_into::<u64>();
|
||||
let n = self.0.birth(current_u64).saturated_into::<BlockNumberFor<T>>();
|
||||
if !<BlockHash<T>>::contains_key(n) {
|
||||
@@ -85,17 +69,39 @@ impl<T: Config + Send + Sync> SignedExtension for CheckMortality<T> {
|
||||
Ok(<Pallet<T>>::block_hash(n))
|
||||
}
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_mortality()
|
||||
}
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<T::RuntimeCall, Context>
|
||||
for CheckMortality<T>
|
||||
{
|
||||
type Pre = ();
|
||||
type Val = ();
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
origin: <T as Config>::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
_context: &mut Context,
|
||||
_self_implicit: Self::Implicit,
|
||||
_inherited_implication: &impl Encode,
|
||||
) -> ValidateResult<Self::Val, T::RuntimeCall> {
|
||||
let current_u64 = <Pallet<T>>::block_number().saturated_into::<u64>();
|
||||
let valid_till = self.0.death(current_u64);
|
||||
Ok((
|
||||
ValidTransaction {
|
||||
longevity: valid_till.saturating_sub(current_u64),
|
||||
..Default::default()
|
||||
},
|
||||
(),
|
||||
origin,
|
||||
))
|
||||
}
|
||||
impl_tx_ext_default!(T::RuntimeCall; Context; prepare);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -106,23 +112,21 @@ mod tests {
|
||||
weights::Weight,
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::DispatchTransaction;
|
||||
|
||||
#[test]
|
||||
fn signed_ext_check_era_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// future
|
||||
assert_eq!(
|
||||
CheckMortality::<Test>::from(Era::mortal(4, 2))
|
||||
.additional_signed()
|
||||
.err()
|
||||
.unwrap(),
|
||||
CheckMortality::<Test>::from(Era::mortal(4, 2)).implicit().err().unwrap(),
|
||||
InvalidTransaction::AncientBirthBlock.into(),
|
||||
);
|
||||
|
||||
// correct
|
||||
System::set_block_number(13);
|
||||
<BlockHash<Test>>::insert(12, H256::repeat_byte(1));
|
||||
assert!(CheckMortality::<Test>::from(Era::mortal(4, 12)).additional_signed().is_ok());
|
||||
assert!(CheckMortality::<Test>::from(Era::mortal(4, 12)).implicit().is_ok());
|
||||
})
|
||||
}
|
||||
|
||||
@@ -142,7 +146,10 @@ mod tests {
|
||||
System::set_block_number(17);
|
||||
<BlockHash<Test>>::insert(16, H256::repeat_byte(1));
|
||||
|
||||
assert_eq!(ext.validate(&1, CALL, &normal, len).unwrap().longevity, 15);
|
||||
assert_eq!(
|
||||
ext.validate_only(Some(1).into(), CALL, &normal, len).unwrap().0.longevity,
|
||||
15
|
||||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,14 @@
|
||||
|
||||
use crate::Config;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{dispatch::DispatchInfo, DefaultNoBound};
|
||||
use frame_support::{traits::OriginTrait, DefaultNoBound};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, Dispatchable, SignedExtension},
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
|
||||
impl_tx_ext_default,
|
||||
traits::{
|
||||
transaction_extension::TransactionExtensionBase, DispatchInfoOf, TransactionExtension,
|
||||
},
|
||||
transaction_validity::InvalidTransaction,
|
||||
};
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
|
||||
@@ -45,66 +46,82 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckNonZeroSender<T> {
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> CheckNonZeroSender<T> {
|
||||
/// Create new `SignedExtension` to check runtime version.
|
||||
/// Create new `TransactionExtension` to check runtime version.
|
||||
pub fn new() -> Self {
|
||||
Self(sp_std::marker::PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckNonZeroSender<T>
|
||||
where
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
|
||||
{
|
||||
type AccountId = T::AccountId;
|
||||
type Call = T::RuntimeCall;
|
||||
type AdditionalSigned = ();
|
||||
type Pre = ();
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckNonZeroSender<T> {
|
||||
const IDENTIFIER: &'static str = "CheckNonZeroSender";
|
||||
|
||||
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
|
||||
Ok(())
|
||||
type Implicit = ();
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_non_zero_sender()
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
}
|
||||
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<T::RuntimeCall, Context>
|
||||
for CheckNonZeroSender<T>
|
||||
{
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
fn validate(
|
||||
&self,
|
||||
who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
_info: &DispatchInfoOf<Self::Call>,
|
||||
origin: <T as Config>::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
) -> TransactionValidity {
|
||||
if who.using_encoded(|d| d.iter().all(|x| *x == 0)) {
|
||||
return Err(TransactionValidityError::Invalid(InvalidTransaction::BadSigner))
|
||||
_context: &mut Context,
|
||||
_self_implicit: Self::Implicit,
|
||||
_inherited_implication: &impl Encode,
|
||||
) -> sp_runtime::traits::ValidateResult<Self::Val, T::RuntimeCall> {
|
||||
if let Some(who) = origin.as_system_signer() {
|
||||
if who.using_encoded(|d| d.iter().all(|x| *x == 0)) {
|
||||
return Err(InvalidTransaction::BadSigner.into())
|
||||
}
|
||||
}
|
||||
Ok(ValidTransaction::default())
|
||||
Ok((Default::default(), (), origin))
|
||||
}
|
||||
impl_tx_ext_default!(T::RuntimeCall; Context; prepare);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{new_test_ext, Test, CALL};
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
use frame_support::{assert_ok, dispatch::DispatchInfo};
|
||||
use sp_runtime::{traits::DispatchTransaction, TransactionValidityError};
|
||||
|
||||
#[test]
|
||||
fn zero_account_ban_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
assert_noop!(
|
||||
CheckNonZeroSender::<Test>::new().validate(&0, CALL, &info, len),
|
||||
InvalidTransaction::BadSigner
|
||||
assert_eq!(
|
||||
CheckNonZeroSender::<Test>::new()
|
||||
.validate_only(Some(0).into(), CALL, &info, len)
|
||||
.unwrap_err(),
|
||||
TransactionValidityError::from(InvalidTransaction::BadSigner)
|
||||
);
|
||||
assert_ok!(CheckNonZeroSender::<Test>::new().validate(&1, CALL, &info, len));
|
||||
assert_ok!(CheckNonZeroSender::<Test>::new().validate_only(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
&info,
|
||||
len
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsigned_origin_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
assert_ok!(CheckNonZeroSender::<Test>::new().validate_only(
|
||||
None.into(),
|
||||
CALL,
|
||||
&info,
|
||||
len
|
||||
));
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::Config;
|
||||
use crate::{AccountInfo, Config};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::dispatch::DispatchInfo;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, Dispatchable, One, SignedExtension, Zero},
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionLongevity, TransactionValidity, TransactionValidityError,
|
||||
ValidTransaction,
|
||||
traits::{
|
||||
AsSystemOriginSigner, DispatchInfoOf, Dispatchable, One, TransactionExtension,
|
||||
TransactionExtensionBase, ValidateResult, Zero,
|
||||
},
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionLongevity, TransactionValidityError, ValidTransaction,
|
||||
},
|
||||
Saturating,
|
||||
};
|
||||
use sp_std::vec;
|
||||
|
||||
@@ -58,75 +61,78 @@ impl<T: Config> sp_std::fmt::Debug for CheckNonce<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> SignedExtension for CheckNonce<T>
|
||||
impl<T: Config> TransactionExtensionBase for CheckNonce<T> {
|
||||
const IDENTIFIER: &'static str = "CheckNonce";
|
||||
type Implicit = ();
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_nonce()
|
||||
}
|
||||
}
|
||||
impl<T: Config, Context> TransactionExtension<T::RuntimeCall, Context> for CheckNonce<T>
|
||||
where
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
|
||||
<T::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + Clone,
|
||||
{
|
||||
type AccountId = T::AccountId;
|
||||
type Call = T::RuntimeCall;
|
||||
type AdditionalSigned = ();
|
||||
type Val = Option<(T::AccountId, AccountInfo<T::Nonce, T::AccountData>)>;
|
||||
type Pre = ();
|
||||
const IDENTIFIER: &'static str = "CheckNonce";
|
||||
|
||||
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
_info: &DispatchInfoOf<Self::Call>,
|
||||
fn validate(
|
||||
&self,
|
||||
origin: <T as Config>::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
let mut account = crate::Account::<T>::get(who);
|
||||
_context: &mut Context,
|
||||
_self_implicit: Self::Implicit,
|
||||
_inherited_implication: &impl Encode,
|
||||
) -> ValidateResult<Self::Val, T::RuntimeCall> {
|
||||
let Some(who) = origin.as_system_origin_signer() else {
|
||||
return Ok((Default::default(), None, origin))
|
||||
};
|
||||
let account = crate::Account::<T>::get(who);
|
||||
if account.providers.is_zero() && account.sufficients.is_zero() {
|
||||
// Nonce storage not paid for
|
||||
return Err(InvalidTransaction::Payment.into())
|
||||
}
|
||||
if self.0 != account.nonce {
|
||||
return Err(if self.0 < account.nonce {
|
||||
InvalidTransaction::Stale
|
||||
} else {
|
||||
InvalidTransaction::Future
|
||||
}
|
||||
.into())
|
||||
}
|
||||
account.nonce += T::Nonce::one();
|
||||
crate::Account::<T>::insert(who, account);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
_info: &DispatchInfoOf<Self::Call>,
|
||||
_len: usize,
|
||||
) -> TransactionValidity {
|
||||
let account = crate::Account::<T>::get(who);
|
||||
if account.providers.is_zero() && account.sufficients.is_zero() {
|
||||
// Nonce storage not paid for
|
||||
return InvalidTransaction::Payment.into()
|
||||
}
|
||||
if self.0 < account.nonce {
|
||||
return InvalidTransaction::Stale.into()
|
||||
return Err(InvalidTransaction::Stale.into())
|
||||
}
|
||||
|
||||
let provides = vec![Encode::encode(&(who, self.0))];
|
||||
let provides = vec![Encode::encode(&(who.clone(), self.0))];
|
||||
let requires = if account.nonce < self.0 {
|
||||
vec![Encode::encode(&(who, self.0 - One::one()))]
|
||||
vec![Encode::encode(&(who.clone(), self.0.saturating_sub(One::one())))]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
Ok(ValidTransaction {
|
||||
let validity = ValidTransaction {
|
||||
priority: 0,
|
||||
requires,
|
||||
provides,
|
||||
longevity: TransactionLongevity::max_value(),
|
||||
propagate: true,
|
||||
})
|
||||
};
|
||||
|
||||
Ok((validity, Some((who.clone(), account)), origin))
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
self,
|
||||
val: Self::Val,
|
||||
_origin: &T::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
_context: &Context,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
let Some((who, mut account)) = val else { return Ok(()) };
|
||||
// `self.0 < account.nonce` already checked in `validate`.
|
||||
if self.0 > account.nonce {
|
||||
return Err(InvalidTransaction::Future.into())
|
||||
}
|
||||
account.nonce.saturating_inc();
|
||||
crate::Account::<T>::insert(who, account);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +140,8 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{new_test_ext, Test, CALL};
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
use frame_support::assert_ok;
|
||||
use sp_runtime::traits::DispatchTransaction;
|
||||
|
||||
#[test]
|
||||
fn signed_ext_check_nonce_works() {
|
||||
@@ -152,22 +159,33 @@ mod tests {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
// stale
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(0).validate(&1, CALL, &info, len),
|
||||
InvalidTransaction::Stale
|
||||
assert_eq!(
|
||||
CheckNonce::<Test>(0)
|
||||
.validate_only(Some(1).into(), CALL, &info, len,)
|
||||
.unwrap_err(),
|
||||
TransactionValidityError::Invalid(InvalidTransaction::Stale)
|
||||
);
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(0).pre_dispatch(&1, CALL, &info, len),
|
||||
InvalidTransaction::Stale
|
||||
assert_eq!(
|
||||
CheckNonce::<Test>(0)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &info, len)
|
||||
.unwrap_err(),
|
||||
InvalidTransaction::Stale.into()
|
||||
);
|
||||
// correct
|
||||
assert_ok!(CheckNonce::<Test>(1).validate(&1, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).pre_dispatch(&1, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_only(Some(1).into(), CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
&info,
|
||||
len
|
||||
));
|
||||
// future
|
||||
assert_ok!(CheckNonce::<Test>(5).validate(&1, CALL, &info, len));
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(5).pre_dispatch(&1, CALL, &info, len),
|
||||
InvalidTransaction::Future
|
||||
assert_ok!(CheckNonce::<Test>(5).validate_only(Some(1).into(), CALL, &info, len));
|
||||
assert_eq!(
|
||||
CheckNonce::<Test>(5)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &info, len)
|
||||
.unwrap_err(),
|
||||
InvalidTransaction::Future.into()
|
||||
);
|
||||
})
|
||||
}
|
||||
@@ -198,20 +216,44 @@ mod tests {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
// Both providers and sufficients zero
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(1).validate(&1, CALL, &info, len),
|
||||
InvalidTransaction::Payment
|
||||
assert_eq!(
|
||||
CheckNonce::<Test>(1)
|
||||
.validate_only(Some(1).into(), CALL, &info, len)
|
||||
.unwrap_err(),
|
||||
TransactionValidityError::Invalid(InvalidTransaction::Payment)
|
||||
);
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(1).pre_dispatch(&1, CALL, &info, len),
|
||||
InvalidTransaction::Payment
|
||||
assert_eq!(
|
||||
CheckNonce::<Test>(1)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &info, len)
|
||||
.unwrap_err(),
|
||||
TransactionValidityError::Invalid(InvalidTransaction::Payment)
|
||||
);
|
||||
// Non-zero providers
|
||||
assert_ok!(CheckNonce::<Test>(1).validate(&2, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).pre_dispatch(&2, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_only(Some(2).into(), CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_and_prepare(
|
||||
Some(2).into(),
|
||||
CALL,
|
||||
&info,
|
||||
len
|
||||
));
|
||||
// Non-zero sufficients
|
||||
assert_ok!(CheckNonce::<Test>(1).validate(&3, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).pre_dispatch(&3, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_only(Some(3).into(), CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_and_prepare(
|
||||
Some(3).into(),
|
||||
CALL,
|
||||
&info,
|
||||
len
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsigned_check_nonce_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_only(None.into(), CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).validate_and_prepare(None.into(), CALL, &info, len));
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@ use crate::{Config, Pallet};
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, SignedExtension},
|
||||
impl_tx_ext_default,
|
||||
traits::{transaction_extension::TransactionExtensionBase, TransactionExtension},
|
||||
transaction_validity::TransactionValidityError,
|
||||
};
|
||||
|
||||
@@ -46,30 +47,26 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckSpecVersion<T> {
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> CheckSpecVersion<T> {
|
||||
/// Create new `SignedExtension` to check runtime version.
|
||||
/// Create new `TransactionExtension` to check runtime version.
|
||||
pub fn new() -> Self {
|
||||
Self(sp_std::marker::PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckSpecVersion<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type Call = <T as Config>::RuntimeCall;
|
||||
type AdditionalSigned = u32;
|
||||
type Pre = ();
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckSpecVersion<T> {
|
||||
const IDENTIFIER: &'static str = "CheckSpecVersion";
|
||||
|
||||
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||
type Implicit = u32;
|
||||
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
|
||||
Ok(<Pallet<T>>::runtime_version().spec_version)
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_spec_version()
|
||||
}
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<<T as Config>::RuntimeCall, Context>
|
||||
for CheckSpecVersion<T>
|
||||
{
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
impl_tx_ext_default!(<T as Config>::RuntimeCall; Context; validate prepare);
|
||||
}
|
||||
@@ -19,7 +19,8 @@ use crate::{Config, Pallet};
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, SignedExtension},
|
||||
impl_tx_ext_default,
|
||||
traits::{transaction_extension::TransactionExtensionBase, TransactionExtension},
|
||||
transaction_validity::TransactionValidityError,
|
||||
};
|
||||
|
||||
@@ -46,29 +47,26 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckTxVersion<T> {
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> CheckTxVersion<T> {
|
||||
/// Create new `SignedExtension` to check transaction version.
|
||||
/// Create new `TransactionExtension` to check transaction version.
|
||||
pub fn new() -> Self {
|
||||
Self(sp_std::marker::PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckTxVersion<T> {
|
||||
type AccountId = T::AccountId;
|
||||
type Call = <T as Config>::RuntimeCall;
|
||||
type AdditionalSigned = u32;
|
||||
type Pre = ();
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckTxVersion<T> {
|
||||
const IDENTIFIER: &'static str = "CheckTxVersion";
|
||||
|
||||
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||
type Implicit = u32;
|
||||
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
|
||||
Ok(<Pallet<T>>::runtime_version().transaction_version)
|
||||
}
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
fn weight(&self) -> sp_weights::Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_tx_version()
|
||||
}
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<<T as Config>::RuntimeCall, Context>
|
||||
for CheckTxVersion<T>
|
||||
{
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
impl_tx_ext_default!(<T as Config>::RuntimeCall; Context; validate prepare);
|
||||
}
|
||||
@@ -23,9 +23,12 @@ use frame_support::{
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf, SignedExtension},
|
||||
transaction_validity::{InvalidTransaction, TransactionValidity, TransactionValidityError},
|
||||
DispatchResult,
|
||||
traits::{
|
||||
DispatchInfoOf, Dispatchable, PostDispatchInfoOf, TransactionExtension,
|
||||
TransactionExtensionBase, ValidateResult,
|
||||
},
|
||||
transaction_validity::{InvalidTransaction, TransactionValidityError},
|
||||
DispatchResult, ValidTransaction,
|
||||
};
|
||||
use sp_weights::Weight;
|
||||
|
||||
@@ -100,39 +103,43 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates new `SignedExtension` to check weight of the extrinsic.
|
||||
/// Creates new `TransactionExtension` to check weight of the extrinsic.
|
||||
pub fn new() -> Self {
|
||||
Self(Default::default())
|
||||
}
|
||||
|
||||
/// Do the pre-dispatch checks. This can be applied to both signed and unsigned.
|
||||
///
|
||||
/// It checks and notes the new weight and length.
|
||||
pub fn do_pre_dispatch(
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
let next_len = Self::check_block_length(info, len)?;
|
||||
let next_weight = Self::check_block_weight(info)?;
|
||||
Self::check_extrinsic_weight(info)?;
|
||||
|
||||
crate::AllExtrinsicsLen::<T>::put(next_len);
|
||||
crate::BlockWeight::<T>::put(next_weight);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Do the validate checks. This can be applied to both signed and unsigned.
|
||||
///
|
||||
/// It only checks that the block weight and length limit will not exceed.
|
||||
pub fn do_validate(info: &DispatchInfoOf<T::RuntimeCall>, len: usize) -> TransactionValidity {
|
||||
///
|
||||
/// Returns the transaction validity and the next block length, to be used in `prepare`.
|
||||
pub fn do_validate(
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
) -> Result<(ValidTransaction, u32), TransactionValidityError> {
|
||||
// ignore the next length. If they return `Ok`, then it is below the limit.
|
||||
let _ = Self::check_block_length(info, len)?;
|
||||
let next_len = Self::check_block_length(info, len)?;
|
||||
// during validation we skip block limit check. Since the `validate_transaction`
|
||||
// call runs on an empty block anyway, by this we prevent `on_initialize` weight
|
||||
// consumption from causing false negatives.
|
||||
Self::check_extrinsic_weight(info)?;
|
||||
|
||||
Ok(Default::default())
|
||||
Ok((Default::default(), next_len))
|
||||
}
|
||||
|
||||
/// Do the pre-dispatch checks. This can be applied to both signed and unsigned.
|
||||
///
|
||||
/// It checks and notes the new weight and length.
|
||||
pub fn do_prepare(
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
next_len: u32,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
let next_weight = Self::check_block_weight(info)?;
|
||||
// Extrinsic weight already checked in `validate`.
|
||||
|
||||
crate::AllExtrinsicsLen::<T>::put(next_len);
|
||||
crate::BlockWeight::<T>::put(next_weight);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,62 +208,55 @@ where
|
||||
Ok(all_weight)
|
||||
}
|
||||
|
||||
impl<T: Config + Send + Sync> SignedExtension for CheckWeight<T>
|
||||
impl<T: Config + Send + Sync> TransactionExtensionBase for CheckWeight<T> {
|
||||
const IDENTIFIER: &'static str = "CheckWeight";
|
||||
type Implicit = ();
|
||||
|
||||
fn weight(&self) -> Weight {
|
||||
<T::ExtensionsWeightInfo as super::WeightInfo>::check_weight()
|
||||
}
|
||||
}
|
||||
impl<T: Config + Send + Sync, Context> TransactionExtension<T::RuntimeCall, Context>
|
||||
for CheckWeight<T>
|
||||
where
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
{
|
||||
type AccountId = T::AccountId;
|
||||
type Call = T::RuntimeCall;
|
||||
type AdditionalSigned = ();
|
||||
type Pre = ();
|
||||
const IDENTIFIER: &'static str = "CheckWeight";
|
||||
|
||||
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
_who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
Self::do_pre_dispatch(info, len)
|
||||
}
|
||||
type Val = u32; /* next block length */
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
_who: &Self::AccountId,
|
||||
_call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
origin: T::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
) -> TransactionValidity {
|
||||
Self::do_validate(info, len)
|
||||
_context: &mut Context,
|
||||
_self_implicit: Self::Implicit,
|
||||
_inherited_implication: &impl Encode,
|
||||
) -> ValidateResult<Self::Val, T::RuntimeCall> {
|
||||
let (validity, next_len) = Self::do_validate(info, len)?;
|
||||
Ok((validity, next_len, origin))
|
||||
}
|
||||
|
||||
fn pre_dispatch_unsigned(
|
||||
_call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
Self::do_pre_dispatch(info, len)
|
||||
}
|
||||
|
||||
fn validate_unsigned(
|
||||
_call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> TransactionValidity {
|
||||
Self::do_validate(info, len)
|
||||
fn prepare(
|
||||
self,
|
||||
val: Self::Val,
|
||||
_origin: &T::RuntimeOrigin,
|
||||
_call: &T::RuntimeCall,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
_context: &Context,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Self::do_prepare(info, val)
|
||||
}
|
||||
|
||||
fn post_dispatch(
|
||||
_pre: Option<Self::Pre>,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
post_info: &PostDispatchInfoOf<Self::Call>,
|
||||
_pre: Self::Pre,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
|
||||
_len: usize,
|
||||
_result: &DispatchResult,
|
||||
_context: &Context,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
let unspent = post_info.calc_unspent(info);
|
||||
if unspent.any_gt(Weight::zero()) {
|
||||
@@ -301,6 +301,7 @@ mod tests {
|
||||
AllExtrinsicsLen, BlockWeight, DispatchClass,
|
||||
};
|
||||
use frame_support::{assert_err, assert_ok, dispatch::Pays, weights::Weight};
|
||||
use sp_runtime::traits::DispatchTransaction;
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
fn block_weights() -> crate::limits::BlockWeights {
|
||||
@@ -338,7 +339,8 @@ mod tests {
|
||||
}
|
||||
|
||||
check(|max, len| {
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(max, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(max, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(max, next_len));
|
||||
assert_eq!(System::block_weight().total(), Weight::MAX);
|
||||
assert!(System::block_weight().total().ref_time() > block_weight_limit().ref_time());
|
||||
});
|
||||
@@ -419,9 +421,11 @@ mod tests {
|
||||
|
||||
let len = 0_usize;
|
||||
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&max_normal, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&max_normal, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&max_normal, next_len));
|
||||
assert_eq!(System::block_weight().total(), Weight::from_parts(768, 0));
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&rest_operational, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&rest_operational, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&rest_operational, next_len));
|
||||
assert_eq!(block_weight_limit(), Weight::from_parts(1024, u64::MAX));
|
||||
assert_eq!(System::block_weight().total(), block_weight_limit().set_proof_size(0));
|
||||
// Checking single extrinsic should not take current block weight into account.
|
||||
@@ -443,10 +447,12 @@ mod tests {
|
||||
|
||||
let len = 0_usize;
|
||||
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&rest_operational, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&rest_operational, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&rest_operational, next_len));
|
||||
// Extra 20 here from block execution + base extrinsic weight
|
||||
assert_eq!(System::block_weight().total(), Weight::from_parts(266, 0));
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&max_normal, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&max_normal, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&max_normal, next_len));
|
||||
assert_eq!(block_weight_limit(), Weight::from_parts(1024, u64::MAX));
|
||||
assert_eq!(System::block_weight().total(), block_weight_limit().set_proof_size(0));
|
||||
});
|
||||
@@ -469,16 +475,19 @@ mod tests {
|
||||
};
|
||||
let len = 0_usize;
|
||||
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&dispatch_normal, len).unwrap();
|
||||
assert_err!(
|
||||
CheckWeight::<Test>::do_pre_dispatch(&dispatch_normal, len),
|
||||
CheckWeight::<Test>::do_prepare(&dispatch_normal, next_len),
|
||||
InvalidTransaction::ExhaustsResources
|
||||
);
|
||||
let next_len =
|
||||
CheckWeight::<Test>::check_block_length(&dispatch_operational, len).unwrap();
|
||||
// Thank goodness we can still do an operational transaction to possibly save the
|
||||
// blockchain.
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&dispatch_operational, len));
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&dispatch_operational, next_len));
|
||||
// Not too much though
|
||||
assert_err!(
|
||||
CheckWeight::<Test>::do_pre_dispatch(&dispatch_operational, len),
|
||||
CheckWeight::<Test>::do_prepare(&dispatch_operational, next_len),
|
||||
InvalidTransaction::ExhaustsResources
|
||||
);
|
||||
// Even with full block, validity of single transaction should be correct.
|
||||
@@ -503,21 +512,35 @@ mod tests {
|
||||
current_weight.set(normal_limit, DispatchClass::Normal)
|
||||
});
|
||||
// will not fit.
|
||||
assert_err!(
|
||||
CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &normal, len),
|
||||
InvalidTransaction::ExhaustsResources
|
||||
assert_eq!(
|
||||
CheckWeight::<Test>(PhantomData)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &normal, len)
|
||||
.unwrap_err(),
|
||||
InvalidTransaction::ExhaustsResources.into()
|
||||
);
|
||||
// will fit.
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &op, len));
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
&op,
|
||||
len
|
||||
));
|
||||
|
||||
// likewise for length limit.
|
||||
let len = 100_usize;
|
||||
AllExtrinsicsLen::<Test>::put(normal_length_limit());
|
||||
assert_err!(
|
||||
CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &normal, len),
|
||||
InvalidTransaction::ExhaustsResources
|
||||
assert_eq!(
|
||||
CheckWeight::<Test>(PhantomData)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &normal, len)
|
||||
.unwrap_err(),
|
||||
InvalidTransaction::ExhaustsResources.into()
|
||||
);
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &op, len));
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
&op,
|
||||
len
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -528,7 +551,12 @@ mod tests {
|
||||
let normal_limit = normal_weight_limit().ref_time() as usize;
|
||||
let reset_check_weight = |tx, s, f| {
|
||||
AllExtrinsicsLen::<Test>::put(0);
|
||||
let r = CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, tx, s);
|
||||
let r = CheckWeight::<Test>(PhantomData).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
tx,
|
||||
s,
|
||||
);
|
||||
if f {
|
||||
assert!(r.is_err())
|
||||
} else {
|
||||
@@ -571,7 +599,12 @@ mod tests {
|
||||
BlockWeight::<Test>::mutate(|current_weight| {
|
||||
current_weight.set(s, DispatchClass::Normal)
|
||||
});
|
||||
let r = CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, i, len);
|
||||
let r = CheckWeight::<Test>(PhantomData).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
i,
|
||||
len,
|
||||
);
|
||||
if f {
|
||||
assert!(r.is_err())
|
||||
} else {
|
||||
@@ -604,18 +637,22 @@ mod tests {
|
||||
.set(Weight::from_parts(256, 0) - base_extrinsic, DispatchClass::Normal);
|
||||
});
|
||||
|
||||
let pre = CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &info, len).unwrap();
|
||||
let pre = CheckWeight::<Test>(PhantomData)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &info, len)
|
||||
.unwrap()
|
||||
.0;
|
||||
assert_eq!(
|
||||
BlockWeight::<Test>::get().total(),
|
||||
info.weight + Weight::from_parts(256, 0)
|
||||
);
|
||||
|
||||
assert_ok!(CheckWeight::<Test>::post_dispatch(
|
||||
Some(pre),
|
||||
pre,
|
||||
&info,
|
||||
&post_info,
|
||||
len,
|
||||
&Ok(())
|
||||
&Ok(()),
|
||||
&()
|
||||
));
|
||||
assert_eq!(
|
||||
BlockWeight::<Test>::get().total(),
|
||||
@@ -639,7 +676,10 @@ mod tests {
|
||||
current_weight.set(Weight::from_parts(128, 0), DispatchClass::Normal);
|
||||
});
|
||||
|
||||
let pre = CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &info, len).unwrap();
|
||||
let pre = CheckWeight::<Test>(PhantomData)
|
||||
.validate_and_prepare(Some(1).into(), CALL, &info, len)
|
||||
.unwrap()
|
||||
.0;
|
||||
assert_eq!(
|
||||
BlockWeight::<Test>::get().total(),
|
||||
info.weight +
|
||||
@@ -648,11 +688,12 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_ok!(CheckWeight::<Test>::post_dispatch(
|
||||
Some(pre),
|
||||
pre,
|
||||
&info,
|
||||
&post_info,
|
||||
len,
|
||||
&Ok(())
|
||||
&Ok(()),
|
||||
&()
|
||||
));
|
||||
assert_eq!(
|
||||
BlockWeight::<Test>::get().total(),
|
||||
@@ -672,7 +713,12 @@ mod tests {
|
||||
|
||||
// Initial weight from `weights.base_block`
|
||||
assert_eq!(System::block_weight().total(), weights.base_block);
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &free, len));
|
||||
assert_ok!(CheckWeight::<Test>(PhantomData).validate_and_prepare(
|
||||
Some(1).into(),
|
||||
CALL,
|
||||
&free,
|
||||
len
|
||||
));
|
||||
assert_eq!(
|
||||
System::block_weight().total(),
|
||||
weights.get(DispatchClass::Normal).base_extrinsic + weights.base_block
|
||||
@@ -696,9 +742,11 @@ mod tests {
|
||||
|
||||
let len = 0_usize;
|
||||
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&max_normal, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&max_normal, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&max_normal, next_len));
|
||||
assert_eq!(System::block_weight().total(), Weight::from_parts(768, 0));
|
||||
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&mandatory, len));
|
||||
let next_len = CheckWeight::<Test>::check_block_length(&mandatory, len).unwrap();
|
||||
assert_ok!(CheckWeight::<Test>::do_prepare(&mandatory, next_len));
|
||||
assert_eq!(block_weight_limit(), Weight::from_parts(1024, u64::MAX));
|
||||
assert_eq!(System::block_weight().total(), Weight::from_parts(1024 + 768, 0));
|
||||
assert_eq!(CheckWeight::<Test>::check_extrinsic_weight(&mandatory), Ok(()));
|
||||
|
||||
@@ -22,3 +22,6 @@ pub mod check_nonce;
|
||||
pub mod check_spec_version;
|
||||
pub mod check_tx_version;
|
||||
pub mod check_weight;
|
||||
pub mod weights;
|
||||
|
||||
pub use weights::WeightInfo;
|
||||
@@ -0,0 +1,196 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Autogenerated weights for `frame_system_extensions`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate-node
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=frame_system_extensions
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./substrate/frame/system/src/extensions/weights.rs
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --template=./substrate/.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `frame_system_extensions`.
|
||||
pub trait WeightInfo {
|
||||
fn check_genesis() -> Weight;
|
||||
fn check_mortality() -> Weight;
|
||||
fn check_non_zero_sender() -> Weight;
|
||||
fn check_nonce() -> Weight;
|
||||
fn check_spec_version() -> Weight;
|
||||
fn check_tx_version() -> Weight;
|
||||
fn check_weight() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `frame_system_extensions` using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: `System::BlockHash` (r:1 w:0)
|
||||
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
|
||||
fn check_genesis() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `3509`
|
||||
// Minimum execution time: 3_876_000 picoseconds.
|
||||
Weight::from_parts(4_160_000, 3509)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
}
|
||||
/// Storage: `System::BlockHash` (r:1 w:0)
|
||||
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
|
||||
fn check_mortality() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `92`
|
||||
// Estimated: `3509`
|
||||
// Minimum execution time: 6_296_000 picoseconds.
|
||||
Weight::from_parts(6_523_000, 3509)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
}
|
||||
fn check_non_zero_sender() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 449_000 picoseconds.
|
||||
Weight::from_parts(527_000, 0)
|
||||
}
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
fn check_nonce() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `101`
|
||||
// Estimated: `3593`
|
||||
// Minimum execution time: 5_689_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 3593)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn check_spec_version() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 399_000 picoseconds.
|
||||
Weight::from_parts(461_000, 0)
|
||||
}
|
||||
fn check_tx_version() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 390_000 picoseconds.
|
||||
Weight::from_parts(439_000, 0)
|
||||
}
|
||||
/// Storage: `System::AllExtrinsicsLen` (r:1 w:1)
|
||||
/// Proof: `System::AllExtrinsicsLen` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn check_weight() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `24`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 4_375_000 picoseconds.
|
||||
Weight::from_parts(4_747_000, 1489)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `System::BlockHash` (r:1 w:0)
|
||||
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
|
||||
fn check_genesis() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `3509`
|
||||
// Minimum execution time: 3_876_000 picoseconds.
|
||||
Weight::from_parts(4_160_000, 3509)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
}
|
||||
/// Storage: `System::BlockHash` (r:1 w:0)
|
||||
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
|
||||
fn check_mortality() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `92`
|
||||
// Estimated: `3509`
|
||||
// Minimum execution time: 6_296_000 picoseconds.
|
||||
Weight::from_parts(6_523_000, 3509)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
}
|
||||
fn check_non_zero_sender() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 449_000 picoseconds.
|
||||
Weight::from_parts(527_000, 0)
|
||||
}
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
fn check_nonce() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `101`
|
||||
// Estimated: `3593`
|
||||
// Minimum execution time: 5_689_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 3593)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn check_spec_version() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 399_000 picoseconds.
|
||||
Weight::from_parts(461_000, 0)
|
||||
}
|
||||
fn check_tx_version() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 390_000 picoseconds.
|
||||
Weight::from_parts(439_000, 0)
|
||||
}
|
||||
/// Storage: `System::AllExtrinsicsLen` (r:1 w:1)
|
||||
/// Proof: `System::AllExtrinsicsLen` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn check_weight() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `24`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 4_375_000 picoseconds.
|
||||
Weight::from_parts(4_747_000, 1489)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ pub use extensions::{
|
||||
check_genesis::CheckGenesis, check_mortality::CheckMortality,
|
||||
check_non_zero_sender::CheckNonZeroSender, check_nonce::CheckNonce,
|
||||
check_spec_version::CheckSpecVersion, check_tx_version::CheckTxVersion,
|
||||
check_weight::CheckWeight,
|
||||
check_weight::CheckWeight, WeightInfo as ExtensionsWeightInfo,
|
||||
};
|
||||
// Backward compatible re-export.
|
||||
pub use extensions::check_mortality::CheckMortality as CheckEra;
|
||||
@@ -284,6 +284,7 @@ pub mod pallet {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type ExtensionsWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
type Version = ();
|
||||
type BlockWeights = ();
|
||||
@@ -356,6 +357,9 @@ pub mod pallet {
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo = ();
|
||||
|
||||
/// Weight information for the extensions of this pallet.
|
||||
type ExtensionsWeightInfo = ();
|
||||
|
||||
/// This is used as an identifier of the chain.
|
||||
type SS58Prefix = ();
|
||||
|
||||
@@ -563,8 +567,12 @@ pub mod pallet {
|
||||
/// All resources should be cleaned up associated with the given account.
|
||||
type OnKilledAccount: OnKilledAccount<Self::AccountId>;
|
||||
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo: WeightInfo;
|
||||
|
||||
/// Weight information for the transaction extensions of this pallet.
|
||||
type ExtensionsWeightInfo: extensions::WeightInfo;
|
||||
|
||||
/// The designated SS58 prefix of this chain.
|
||||
///
|
||||
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
|
||||
|
||||
@@ -79,6 +79,9 @@ pub struct SubmitTransaction<T: SendTransactionTypes<OverarchingCall>, Overarchi
|
||||
_phantom: sp_std::marker::PhantomData<(T, OverarchingCall)>,
|
||||
}
|
||||
|
||||
// TODO [#2415]: Avoid splitting call and the totally opaque `signature`; `CreateTransaction` trait
|
||||
// should provide something which impls `Encode`, which can be sent onwards to
|
||||
// `sp_io::offchain::submit_transaction`. There's no great need to split things up as in here.
|
||||
impl<T, LocalCall> SubmitTransaction<T, LocalCall>
|
||||
where
|
||||
T: SendTransactionTypes<LocalCall>,
|
||||
@@ -88,6 +91,8 @@ where
|
||||
call: <T as SendTransactionTypes<LocalCall>>::OverarchingCall,
|
||||
signature: Option<<T::Extrinsic as ExtrinsicT>::SignaturePayload>,
|
||||
) -> Result<(), ()> {
|
||||
// TODO: Use regular transaction API instead.
|
||||
#[allow(deprecated)]
|
||||
let xt = T::Extrinsic::new(call, signature).ok_or(())?;
|
||||
sp_io::offchain::submit_transaction(xt.encode())
|
||||
}
|
||||
@@ -471,7 +476,7 @@ pub trait SendTransactionTypes<LocalCall> {
|
||||
///
|
||||
/// This trait is meant to be implemented by the runtime and is responsible for constructing
|
||||
/// a payload to be signed and contained within the extrinsic.
|
||||
/// This will most likely include creation of `SignedExtra` (a set of `SignedExtensions`).
|
||||
/// This will most likely include creation of `TxExtension` (a tuple of `TransactionExtension`s).
|
||||
/// Note that the result can be altered by inspecting the `Call` (for instance adjusting
|
||||
/// fees, or mortality depending on the `pallet` being called).
|
||||
pub trait CreateSignedTransaction<LocalCall>:
|
||||
@@ -621,14 +626,17 @@ mod tests {
|
||||
use crate::mock::{RuntimeCall, Test as TestRuntime, CALL};
|
||||
use codec::Decode;
|
||||
use sp_core::offchain::{testing, TransactionPoolExt};
|
||||
use sp_runtime::testing::{TestSignature, TestXt, UintAuthorityId};
|
||||
use sp_runtime::{
|
||||
generic::UncheckedExtrinsic,
|
||||
testing::{TestSignature, UintAuthorityId},
|
||||
};
|
||||
|
||||
impl SigningTypes for TestRuntime {
|
||||
type Public = UintAuthorityId;
|
||||
type Signature = TestSignature;
|
||||
}
|
||||
|
||||
type Extrinsic = TestXt<RuntimeCall, ()>;
|
||||
type Extrinsic = UncheckedExtrinsic<u64, RuntimeCall, (), ()>;
|
||||
|
||||
impl SendTransactionTypes<RuntimeCall> for TestRuntime {
|
||||
type Extrinsic = Extrinsic;
|
||||
@@ -693,7 +701,7 @@ mod tests {
|
||||
let _tx3 = pool_state.write().transactions.pop().unwrap();
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx1 = Extrinsic::decode(&mut &*tx1).unwrap();
|
||||
assert_eq!(tx1.signature, None);
|
||||
assert!(tx1.is_inherent());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -724,7 +732,7 @@ mod tests {
|
||||
let tx1 = pool_state.write().transactions.pop().unwrap();
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx1 = Extrinsic::decode(&mut &*tx1).unwrap();
|
||||
assert_eq!(tx1.signature, None);
|
||||
assert!(tx1.is_inherent());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -758,7 +766,7 @@ mod tests {
|
||||
let _tx2 = pool_state.write().transactions.pop().unwrap();
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx1 = Extrinsic::decode(&mut &*tx1).unwrap();
|
||||
assert_eq!(tx1.signature, None);
|
||||
assert!(tx1.is_inherent());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -790,7 +798,7 @@ mod tests {
|
||||
let tx1 = pool_state.write().transactions.pop().unwrap();
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx1 = Extrinsic::decode(&mut &*tx1).unwrap();
|
||||
assert_eq!(tx1.signature, None);
|
||||
assert!(tx1.is_inherent());
|
||||
});
|
||||
}
|
||||
}
|
||||
Generated
+127
-122
@@ -15,30 +15,31 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Autogenerated weights for frame_system
|
||||
//! Autogenerated weights for `frame_system`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-06-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-s7kdgajz-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// target/production/substrate
|
||||
// ./target/production/substrate-node
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=frame_system
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json
|
||||
// --pallet=frame-system
|
||||
// --chain=dev
|
||||
// --header=./HEADER-APACHE2
|
||||
// --output=./frame/system/src/weights.rs
|
||||
// --template=./.maintain/frame-weight-template.hbs
|
||||
// --output=./substrate/frame/system/src/weights.rs
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --template=./substrate/.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -48,7 +49,7 @@
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for frame_system.
|
||||
/// Weight functions needed for `frame_system`.
|
||||
pub trait WeightInfo {
|
||||
fn remark(b: u32, ) -> Weight;
|
||||
fn remark_with_event(b: u32, ) -> Weight;
|
||||
@@ -61,7 +62,7 @@ pub trait WeightInfo {
|
||||
fn apply_authorized_upgrade() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for frame_system using the Substrate node and recommended hardware.
|
||||
/// Weights for `frame_system` using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// The range of component `b` is `[0, 3932160]`.
|
||||
@@ -69,84 +70,86 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_004_000 picoseconds.
|
||||
Weight::from_parts(2_119_000, 0)
|
||||
// Minimum execution time: 2_130_000 picoseconds.
|
||||
Weight::from_parts(2_976_430, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(390, 0).saturating_mul(b.into()))
|
||||
.saturating_add(Weight::from_parts(386, 0).saturating_mul(b.into()))
|
||||
}
|
||||
/// The range of component `b` is `[0, 3932160]`.
|
||||
fn remark_with_event(b: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_032_000 picoseconds.
|
||||
Weight::from_parts(8_097_000, 0)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_455, 0).saturating_mul(b.into()))
|
||||
// Minimum execution time: 5_690_000 picoseconds.
|
||||
Weight::from_parts(15_071_416, 0)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_387, 0).saturating_mul(b.into()))
|
||||
}
|
||||
/// Storage: System Digest (r:1 w:1)
|
||||
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
|
||||
/// Storage: unknown `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
|
||||
fn set_heap_pages() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `1485`
|
||||
// Minimum execution time: 4_446_000 picoseconds.
|
||||
Weight::from_parts(4_782_000, 1485)
|
||||
// Minimum execution time: 3_822_000 picoseconds.
|
||||
Weight::from_parts(4_099_000, 1485)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: System Digest (r:1 w:1)
|
||||
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
|
||||
/// Storage: unknown `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof Skipped: unknown `0x3a636f6465` (r:0 w:1)
|
||||
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
|
||||
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
fn set_code() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `1485`
|
||||
// Minimum execution time: 84_000_503_000 picoseconds.
|
||||
Weight::from_parts(87_586_619_000, 1485)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Measured: `142`
|
||||
// Estimated: `67035`
|
||||
// Minimum execution time: 81_512_045_000 picoseconds.
|
||||
Weight::from_parts(82_321_281_000, 67035)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `i` is `[0, 1000]`.
|
||||
fn set_storage(i: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_086_000 picoseconds.
|
||||
Weight::from_parts(2_175_000, 0)
|
||||
// Standard Error: 1_056
|
||||
.saturating_add(Weight::from_parts(841_511, 0).saturating_mul(i.into()))
|
||||
// Minimum execution time: 2_074_000 picoseconds.
|
||||
Weight::from_parts(2_137_000, 0)
|
||||
// Standard Error: 879
|
||||
.saturating_add(Weight::from_parts(797_224, 0).saturating_mul(i.into()))
|
||||
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `i` is `[0, 1000]`.
|
||||
fn kill_storage(i: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_000_000 picoseconds.
|
||||
Weight::from_parts(2_255_000, 0)
|
||||
// Standard Error: 1_425
|
||||
.saturating_add(Weight::from_parts(662_473, 0).saturating_mul(i.into()))
|
||||
// Minimum execution time: 2_122_000 picoseconds.
|
||||
Weight::from_parts(2_208_000, 0)
|
||||
// Standard Error: 855
|
||||
.saturating_add(Weight::from_parts(594_034, 0).saturating_mul(i.into()))
|
||||
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `p` is `[0, 1000]`.
|
||||
fn kill_prefix(p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `115 + p * (69 ±0)`
|
||||
// Estimated: `128 + p * (70 ±0)`
|
||||
// Minimum execution time: 4_189_000 picoseconds.
|
||||
Weight::from_parts(4_270_000, 128)
|
||||
// Standard Error: 2_296
|
||||
.saturating_add(Weight::from_parts(1_389_650, 0).saturating_mul(p.into()))
|
||||
// Measured: `129 + p * (69 ±0)`
|
||||
// Estimated: `135 + p * (70 ±0)`
|
||||
// Minimum execution time: 3_992_000 picoseconds.
|
||||
Weight::from_parts(4_170_000, 135)
|
||||
// Standard Error: 1_377
|
||||
.saturating_add(Weight::from_parts(1_267_892, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
|
||||
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
|
||||
.saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into()))
|
||||
@@ -157,114 +160,116 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 33_027_000 picoseconds.
|
||||
Weight::from_parts(33_027_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
// Minimum execution time: 8_872_000 picoseconds.
|
||||
Weight::from_parts(9_513_000, 0)
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `System::AuthorizedUpgrade` (r:1 w:1)
|
||||
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
|
||||
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
|
||||
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
fn apply_authorized_upgrade() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `22`
|
||||
// Estimated: `1518`
|
||||
// Minimum execution time: 118_101_992_000 picoseconds.
|
||||
Weight::from_parts(118_101_992_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1518))
|
||||
.saturating_add(T::DbWeight::get().reads(2))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
// Measured: `164`
|
||||
// Estimated: `67035`
|
||||
// Minimum execution time: 85_037_546_000 picoseconds.
|
||||
Weight::from_parts(85_819_414_000, 67035)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// The range of component `b` is `[0, 3932160]`.
|
||||
fn remark(b: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_004_000 picoseconds.
|
||||
Weight::from_parts(2_119_000, 0)
|
||||
// Minimum execution time: 2_130_000 picoseconds.
|
||||
Weight::from_parts(2_976_430, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(390, 0).saturating_mul(b.into()))
|
||||
.saturating_add(Weight::from_parts(386, 0).saturating_mul(b.into()))
|
||||
}
|
||||
/// The range of component `b` is `[0, 3932160]`.
|
||||
fn remark_with_event(b: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_032_000 picoseconds.
|
||||
Weight::from_parts(8_097_000, 0)
|
||||
// Standard Error: 2
|
||||
.saturating_add(Weight::from_parts(1_455, 0).saturating_mul(b.into()))
|
||||
// Minimum execution time: 5_690_000 picoseconds.
|
||||
Weight::from_parts(15_071_416, 0)
|
||||
// Standard Error: 1
|
||||
.saturating_add(Weight::from_parts(1_387, 0).saturating_mul(b.into()))
|
||||
}
|
||||
/// Storage: System Digest (r:1 w:1)
|
||||
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
|
||||
/// Storage: unknown `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
|
||||
fn set_heap_pages() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `1485`
|
||||
// Minimum execution time: 4_446_000 picoseconds.
|
||||
Weight::from_parts(4_782_000, 1485)
|
||||
// Minimum execution time: 3_822_000 picoseconds.
|
||||
Weight::from_parts(4_099_000, 1485)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: System Digest (r:1 w:1)
|
||||
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
|
||||
/// Storage: unknown `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof Skipped: unknown `0x3a636f6465` (r:0 w:1)
|
||||
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
|
||||
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
fn set_code() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `1485`
|
||||
// Minimum execution time: 84_000_503_000 picoseconds.
|
||||
Weight::from_parts(87_586_619_000, 1485)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Measured: `142`
|
||||
// Estimated: `67035`
|
||||
// Minimum execution time: 81_512_045_000 picoseconds.
|
||||
Weight::from_parts(82_321_281_000, 67035)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `i` is `[0, 1000]`.
|
||||
fn set_storage(i: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_086_000 picoseconds.
|
||||
Weight::from_parts(2_175_000, 0)
|
||||
// Standard Error: 1_056
|
||||
.saturating_add(Weight::from_parts(841_511, 0).saturating_mul(i.into()))
|
||||
// Minimum execution time: 2_074_000 picoseconds.
|
||||
Weight::from_parts(2_137_000, 0)
|
||||
// Standard Error: 879
|
||||
.saturating_add(Weight::from_parts(797_224, 0).saturating_mul(i.into()))
|
||||
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into())))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `i` is `[0, 1000]`.
|
||||
fn kill_storage(i: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_000_000 picoseconds.
|
||||
Weight::from_parts(2_255_000, 0)
|
||||
// Standard Error: 1_425
|
||||
.saturating_add(Weight::from_parts(662_473, 0).saturating_mul(i.into()))
|
||||
// Minimum execution time: 2_122_000 picoseconds.
|
||||
Weight::from_parts(2_208_000, 0)
|
||||
// Standard Error: 855
|
||||
.saturating_add(Weight::from_parts(594_034, 0).saturating_mul(i.into()))
|
||||
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into())))
|
||||
}
|
||||
/// Storage: Skipped Metadata (r:0 w:0)
|
||||
/// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured)
|
||||
/// Storage: `Skipped::Metadata` (r:0 w:0)
|
||||
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `p` is `[0, 1000]`.
|
||||
fn kill_prefix(p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `115 + p * (69 ±0)`
|
||||
// Estimated: `128 + p * (70 ±0)`
|
||||
// Minimum execution time: 4_189_000 picoseconds.
|
||||
Weight::from_parts(4_270_000, 128)
|
||||
// Standard Error: 2_296
|
||||
.saturating_add(Weight::from_parts(1_389_650, 0).saturating_mul(p.into()))
|
||||
// Measured: `129 + p * (69 ±0)`
|
||||
// Estimated: `135 + p * (70 ±0)`
|
||||
// Minimum execution time: 3_992_000 picoseconds.
|
||||
Weight::from_parts(4_170_000, 135)
|
||||
// Standard Error: 1_377
|
||||
.saturating_add(Weight::from_parts(1_267_892, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into())))
|
||||
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into())))
|
||||
.saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into()))
|
||||
@@ -275,25 +280,25 @@ impl WeightInfo for () {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 33_027_000 picoseconds.
|
||||
Weight::from_parts(33_027_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
// Minimum execution time: 8_872_000 picoseconds.
|
||||
Weight::from_parts(9_513_000, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `System::AuthorizedUpgrade` (r:1 w:1)
|
||||
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
|
||||
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
|
||||
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Digest` (r:1 w:1)
|
||||
/// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
|
||||
fn apply_authorized_upgrade() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `22`
|
||||
// Estimated: `1518`
|
||||
// Minimum execution time: 118_101_992_000 picoseconds.
|
||||
Weight::from_parts(118_101_992_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1518))
|
||||
.saturating_add(RocksDbWeight::get().reads(2))
|
||||
.saturating_add(RocksDbWeight::get().writes(3))
|
||||
// Measured: `164`
|
||||
// Estimated: `67035`
|
||||
// Minimum execution time: 85_037_546_000 picoseconds.
|
||||
Weight::from_parts(85_819_414_000, 67035)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user