mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 08:51:04 +00:00
This PR reverts #2280 which introduced `TransactionExtension` to replace `SignedExtension`. As a result of the discussion [here](https://github.com/paritytech/polkadot-sdk/pull/3623#issuecomment-1986789700), the changes will be reverted for now with plans to reintroduce the concept in the future. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -25,7 +25,7 @@ use scale_info::TypeInfo;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_runtime::{
|
||||
generic::{CheckedExtrinsic, UncheckedExtrinsic},
|
||||
traits::Dispatchable,
|
||||
traits::SignedExtension,
|
||||
DispatchError, RuntimeDebug,
|
||||
};
|
||||
use sp_std::fmt;
|
||||
@@ -268,8 +268,7 @@ pub fn extract_actual_weight(result: &DispatchResultWithPostInfo, info: &Dispatc
|
||||
.calc_actual_weight(info)
|
||||
}
|
||||
|
||||
/// Extract the actual pays_fee from a dispatch result if any or fall back to the default
|
||||
/// weight.
|
||||
/// Extract the actual pays_fee from a dispatch result if any or fall back to the default weight.
|
||||
pub fn extract_actual_pays_fee(result: &DispatchResultWithPostInfo, info: &DispatchInfo) -> Pays {
|
||||
match result {
|
||||
Ok(post_info) => post_info,
|
||||
@@ -369,10 +368,11 @@ where
|
||||
}
|
||||
|
||||
/// Implementation for unchecked extrinsic.
|
||||
impl<Address, Call, Signature, Extension> GetDispatchInfo
|
||||
for UncheckedExtrinsic<Address, Call, Signature, Extension>
|
||||
impl<Address, Call, Signature, Extra> GetDispatchInfo
|
||||
for UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||
where
|
||||
Call: GetDispatchInfo + Dispatchable,
|
||||
Call: GetDispatchInfo,
|
||||
Extra: SignedExtension,
|
||||
{
|
||||
fn get_dispatch_info(&self) -> DispatchInfo {
|
||||
self.function.get_dispatch_info()
|
||||
@@ -380,7 +380,7 @@ where
|
||||
}
|
||||
|
||||
/// Implementation for checked extrinsic.
|
||||
impl<AccountId, Call, Extension> GetDispatchInfo for CheckedExtrinsic<AccountId, Call, Extension>
|
||||
impl<AccountId, Call, Extra> GetDispatchInfo for CheckedExtrinsic<AccountId, Call, Extra>
|
||||
where
|
||||
Call: GetDispatchInfo,
|
||||
{
|
||||
@@ -389,6 +389,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation for test extrinsic.
|
||||
#[cfg(feature = "std")]
|
||||
impl<Call: Encode + GetDispatchInfo, Extra: Encode> GetDispatchInfo
|
||||
for sp_runtime::testing::TestXt<Call, Extra>
|
||||
{
|
||||
fn get_dispatch_info(&self) -> DispatchInfo {
|
||||
// for testing: weight == size.
|
||||
DispatchInfo {
|
||||
weight: Weight::from_parts(self.encode().len() as _, 0),
|
||||
pays_fee: Pays::Yes,
|
||||
class: self.call.get_dispatch_info().class,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct holding value for each `DispatchClass`.
|
||||
#[derive(Clone, Eq, PartialEq, Default, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
pub struct PerDispatchClass<T> {
|
||||
|
||||
@@ -54,8 +54,7 @@ pub mod __private {
|
||||
#[cfg(feature = "std")]
|
||||
pub use sp_runtime::{bounded_btree_map, bounded_vec};
|
||||
pub use sp_runtime::{
|
||||
traits::{AsSystemOriginSigner, Dispatchable},
|
||||
DispatchError, RuntimeDebug, StateVersion, TransactionOutcome,
|
||||
traits::Dispatchable, DispatchError, RuntimeDebug, StateVersion, TransactionOutcome,
|
||||
};
|
||||
#[cfg(feature = "std")]
|
||||
pub use sp_state_machine::BasicExternalities;
|
||||
@@ -76,7 +75,6 @@ pub mod storage;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
pub mod traits;
|
||||
pub mod transaction_extensions;
|
||||
pub mod weights;
|
||||
#[doc(hidden)]
|
||||
pub mod unsigned {
|
||||
@@ -1586,8 +1584,8 @@ pub mod pallet_macros {
|
||||
/// [`ValidateUnsigned`](frame_support::pallet_prelude::ValidateUnsigned) for
|
||||
/// type `Pallet<T>`, and some optional where clause.
|
||||
///
|
||||
/// NOTE: There is also the [`sp_runtime::traits::TransactionExtension`] trait that can be
|
||||
/// used to add some specific logic for transaction validation.
|
||||
/// NOTE: There is also the [`sp_runtime::traits::SignedExtension`] trait that can be used
|
||||
/// to add some specific logic for transaction validation.
|
||||
///
|
||||
/// ## Macro expansion
|
||||
///
|
||||
|
||||
@@ -482,7 +482,7 @@ pub trait OriginTrait: Sized {
|
||||
type Call;
|
||||
|
||||
/// The caller origin, overarching type of all pallets origins.
|
||||
type PalletsOrigin: Send + Sync + Into<Self> + CallerTrait<Self::AccountId> + MaxEncodedLen;
|
||||
type PalletsOrigin: Into<Self> + CallerTrait<Self::AccountId> + MaxEncodedLen;
|
||||
|
||||
/// The AccountId used across the system.
|
||||
type AccountId;
|
||||
@@ -496,14 +496,6 @@ pub trait OriginTrait: Sized {
|
||||
/// Replace the caller with caller from the other origin
|
||||
fn set_caller_from(&mut self, other: impl Into<Self>);
|
||||
|
||||
/// Replace the caller with caller from the other origin
|
||||
fn set_caller(&mut self, caller: Self::PalletsOrigin);
|
||||
|
||||
/// Replace the caller with caller from the other origin
|
||||
fn set_caller_from_signed(&mut self, caller_account: Self::AccountId) {
|
||||
self.set_caller(Self::PalletsOrigin::from(RawOrigin::Signed(caller_account)))
|
||||
}
|
||||
|
||||
/// Filter the call if caller is not root, if false is returned then the call must be filtered
|
||||
/// out.
|
||||
///
|
||||
@@ -552,17 +544,6 @@ pub trait OriginTrait: Sized {
|
||||
fn as_system_ref(&self) -> Option<&RawOrigin<Self::AccountId>> {
|
||||
self.caller().as_system_ref()
|
||||
}
|
||||
|
||||
/// Extract a reference to the sytsem signer, if that's what the caller is.
|
||||
fn as_system_signer(&self) -> Option<&Self::AccountId> {
|
||||
self.caller().as_system_ref().and_then(|s| {
|
||||
if let RawOrigin::Signed(ref who) = s {
|
||||
Some(who)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -919,13 +919,24 @@ pub trait ExtrinsicCall: sp_runtime::traits::Extrinsic {
|
||||
fn call(&self) -> &Self::Call;
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<Call, Extra> ExtrinsicCall for sp_runtime::testing::TestXt<Call, Extra>
|
||||
where
|
||||
Call: codec::Codec + Sync + Send + TypeInfo,
|
||||
Extra: TypeInfo,
|
||||
{
|
||||
fn call(&self) -> &Self::Call {
|
||||
&self.call
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, Call, Signature, Extra> ExtrinsicCall
|
||||
for sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||
where
|
||||
Address: TypeInfo,
|
||||
Call: TypeInfo,
|
||||
Signature: TypeInfo,
|
||||
Extra: TypeInfo,
|
||||
Extra: sp_runtime::traits::SignedExtension + TypeInfo,
|
||||
{
|
||||
fn call(&self) -> &Self::Call {
|
||||
&self.function
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// 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.
|
||||
|
||||
//! Transaction extensions.
|
||||
|
||||
use crate::{CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound};
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_runtime::{
|
||||
impl_tx_ext_default,
|
||||
traits::{
|
||||
transaction_extension::{TransactionExtensionBase, TransactionExtensionInterior},
|
||||
DispatchInfoOf, Dispatchable, IdentifyAccount, TransactionExtension, Verify,
|
||||
},
|
||||
transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction},
|
||||
};
|
||||
|
||||
#[derive(
|
||||
CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, RuntimeDebugNoBound, TypeInfo,
|
||||
)]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
pub struct VerifyMultiSignature<V: Verify>
|
||||
where
|
||||
V: TransactionExtensionInterior,
|
||||
<V::Signer as IdentifyAccount>::AccountId: TransactionExtensionInterior,
|
||||
{
|
||||
signature: V,
|
||||
account: <V::Signer as IdentifyAccount>::AccountId,
|
||||
}
|
||||
|
||||
impl<V: Verify> TransactionExtensionBase for VerifyMultiSignature<V>
|
||||
where
|
||||
V: TransactionExtensionInterior,
|
||||
<V::Signer as IdentifyAccount>::AccountId: TransactionExtensionInterior,
|
||||
{
|
||||
const IDENTIFIER: &'static str = "VerifyMultiSignature";
|
||||
type Implicit = ();
|
||||
}
|
||||
|
||||
impl<V: Verify, Call: Dispatchable + Encode, Context> TransactionExtension<Call, Context>
|
||||
for VerifyMultiSignature<V>
|
||||
where
|
||||
V: TransactionExtensionInterior,
|
||||
<V::Signer as IdentifyAccount>::AccountId: TransactionExtensionInterior,
|
||||
<Call as Dispatchable>::RuntimeOrigin: From<Option<<V::Signer as IdentifyAccount>::AccountId>>,
|
||||
{
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
impl_tx_ext_default!(Call; Context; prepare);
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
_origin: <Call as Dispatchable>::RuntimeOrigin,
|
||||
_call: &Call,
|
||||
_info: &DispatchInfoOf<Call>,
|
||||
_len: usize,
|
||||
_: &mut Context,
|
||||
_: (),
|
||||
inherited_implication: &impl Encode,
|
||||
) -> Result<
|
||||
(ValidTransaction, Self::Val, <Call as Dispatchable>::RuntimeOrigin),
|
||||
TransactionValidityError,
|
||||
> {
|
||||
let msg = inherited_implication.using_encoded(blake2_256);
|
||||
|
||||
if !self.signature.verify(&msg[..], &self.account) {
|
||||
Err(InvalidTransaction::BadProof)?
|
||||
}
|
||||
// We clobber the original origin. Maybe we shuld check that it's none?
|
||||
let origin = Some(self.account.clone()).into();
|
||||
Ok((ValidTransaction::default(), (), origin))
|
||||
}
|
||||
}
|
||||
@@ -15,23 +15,24 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-03-01 (Y/M/D)
|
||||
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-06-16 (Y/M/D)
|
||||
//! HOSTNAME: `runner-e8ezs4ez-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//!
|
||||
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development`
|
||||
//! WARMUPS: `10`, REPEAT: `100`
|
||||
//! WEIGHT-PATH: `./substrate/frame/support/src/weights/`
|
||||
//! WEIGHT-PATH: `./frame/support/src/weights/`
|
||||
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate-node
|
||||
// ./target/production/substrate
|
||||
// benchmark
|
||||
// overhead
|
||||
// --chain=dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --weight-path=./substrate/frame/support/src/weights/
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --weight-path=./frame/support/src/weights/
|
||||
// --header=./HEADER-APACHE2
|
||||
// --warmup=10
|
||||
// --repeat=100
|
||||
|
||||
@@ -43,17 +44,17 @@ parameter_types! {
|
||||
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
|
||||
///
|
||||
/// Stats nanoseconds:
|
||||
/// Min, Max: 424_332, 493_017
|
||||
/// Average: 437_118
|
||||
/// Median: 434_920
|
||||
/// Std-Dev: 8798.01
|
||||
/// Min, Max: 376_949, 622_462
|
||||
/// Average: 390_584
|
||||
/// Median: 386_322
|
||||
/// Std-Dev: 24792.0
|
||||
///
|
||||
/// Percentiles nanoseconds:
|
||||
/// 99th: 460_074
|
||||
/// 95th: 451_580
|
||||
/// 75th: 440_307
|
||||
/// 99th: 433_299
|
||||
/// 95th: 402_688
|
||||
/// 75th: 391_645
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(437_118), 0);
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(390_584), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -15,23 +15,24 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-03-01 (Y/M/D)
|
||||
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-06-16 (Y/M/D)
|
||||
//! HOSTNAME: `runner-e8ezs4ez-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//!
|
||||
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development`
|
||||
//! WARMUPS: `10`, REPEAT: `100`
|
||||
//! WEIGHT-PATH: `./substrate/frame/support/src/weights/`
|
||||
//! WEIGHT-PATH: `./frame/support/src/weights/`
|
||||
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate-node
|
||||
// ./target/production/substrate
|
||||
// benchmark
|
||||
// overhead
|
||||
// --chain=dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --weight-path=./substrate/frame/support/src/weights/
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --weight-path=./frame/support/src/weights/
|
||||
// --header=./HEADER-APACHE2
|
||||
// --warmup=10
|
||||
// --repeat=100
|
||||
|
||||
@@ -43,17 +44,17 @@ parameter_types! {
|
||||
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
|
||||
///
|
||||
/// Stats nanoseconds:
|
||||
/// Min, Max: 106_053, 107_403
|
||||
/// Average: 106_446
|
||||
/// Median: 106_415
|
||||
/// Std-Dev: 216.17
|
||||
/// Min, Max: 123_875, 128_419
|
||||
/// Average: 124_414
|
||||
/// Median: 124_332
|
||||
/// Std-Dev: 497.74
|
||||
///
|
||||
/// Percentiles nanoseconds:
|
||||
/// 99th: 107_042
|
||||
/// 95th: 106_841
|
||||
/// 75th: 106_544
|
||||
/// 99th: 125_245
|
||||
/// 95th: 124_989
|
||||
/// 75th: 124_498
|
||||
pub const ExtrinsicBaseWeight: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(106_446), 0);
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(124_414), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user