From 7c6ab07193e60a06de14f90fd3f618ac72ff17b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 27 Jun 2024 12:49:55 +0200 Subject: [PATCH] Mention the signed extensions in the reference docs (#4887) Co-authored-by: gupnik --- Cargo.lock | 3 ++ docs/sdk/Cargo.toml | 3 ++ .../src/reference_docs/signed_extensions.rs | 54 ++++++++++++++++++- .../system/src/extensions/check_mortality.rs | 3 ++ .../skip-feeless-payment/src/lib.rs | 9 ++-- 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15b5ea3431c5..753857e9ba82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14612,6 +14612,8 @@ dependencies = [ "frame-system", "kitchensink-runtime", "minimal-template-runtime", + "pallet-asset-conversion-tx-payment", + "pallet-asset-tx-payment", "pallet-assets", "pallet-aura", "pallet-authorship", @@ -14630,6 +14632,7 @@ dependencies = [ "pallet-proxy", "pallet-referenda", "pallet-scheduler", + "pallet-skip-feeless-payment", "pallet-timestamp", "pallet-transaction-payment", "pallet-uniques", diff --git a/docs/sdk/Cargo.toml b/docs/sdk/Cargo.toml index 7d3d2da51ab3..d3e48de5d181 100644 --- a/docs/sdk/Cargo.toml +++ b/docs/sdk/Cargo.toml @@ -74,6 +74,9 @@ pallet-balances = { workspace = true, default-features = true } pallet-assets = { workspace = true, default-features = true } pallet-preimage = { workspace = true, default-features = true } pallet-transaction-payment = { workspace = true, default-features = true } +pallet-asset-tx-payment = { workspace = true, default-features = true } +pallet-skip-feeless-payment = { workspace = true, default-features = true } +pallet-asset-conversion-tx-payment = { workspace = true, default-features = true } pallet-utility = { workspace = true, default-features = true } pallet-multisig = { workspace = true, default-features = true } pallet-proxy = { workspace = true, default-features = true } diff --git a/docs/sdk/src/reference_docs/signed_extensions.rs b/docs/sdk/src/reference_docs/signed_extensions.rs index 43a6bcc14c5d..c644aeaa4165 100644 --- a/docs/sdk/src/reference_docs/signed_extensions.rs +++ b/docs/sdk/src/reference_docs/signed_extensions.rs @@ -1,7 +1,59 @@ //! Signed extensions are, briefly, a means for different chains to extend the "basic" extrinsic //! format with custom data that can be checked by the runtime. //! -//! # Example +//! # FRAME provided signed extensions +//! +//! FRAME by default already provides the following signed extensions: +//! +//! - [`CheckGenesis`](frame_system::CheckGenesis): Ensures that a transaction was sent for the same +//! network. Determined based on genesis. +//! +//! - [`CheckMortality`](frame_system::CheckMortality): Extends a transaction with a configurable +//! mortality. +//! +//! - [`CheckNonZeroSender`](frame_system::CheckNonZeroSender): Ensures that the sender of a +//! transaction is not the *all zero account* (all bytes of the accountid are zero). +//! +//! - [`CheckNonce`](frame_system::CheckNonce): Extends a transaction with a nonce to prevent replay +//! of transactions and to provide ordering of transactions. +//! +//! - [`CheckSpecVersion`](frame_system::CheckSpecVersion): Ensures that a transaction was built for +//! the currently active runtime. +//! +//! - [`CheckTxVersion`](frame_system::CheckTxVersion): Ensures that the transaction signer used the +//! correct encoding of the call. +//! +//! - [`CheckWeight`](frame_system::CheckWeight): Ensures that the transaction fits into the block +//! before dispatching it. +//! +//! - [`ChargeTransactionPayment`](pallet_transaction_payment::ChargeTransactionPayment): Charges +//! transaction fees from the signer based on the weight of the call using the native token. +//! +//! - [`ChargeAssetTxPayment`](pallet_asset_tx_payment::ChargeAssetTxPayment): Charges transaction +//! fees from the signer based on the weight of the call using any supported asset (including the +//! native token). +//! +//! - [`ChargeAssetTxPayment`(using +//! conversion)](pallet_asset_conversion_tx_payment::ChargeAssetTxPayment): Charges transaction +//! fees from the signer based on the weight of the call using any supported asset (including the +//! native token). The asset is converted to the native token using a pool. +//! +//! - [`SkipCheckIfFeeless`](pallet_skip_feeless_payment::SkipCheckIfFeeless): Allows transactions +//! to be processed without paying any fee. This requires that the `call` that should be +//! dispatched is augmented with the [`feeless_if`](frame_support::pallet_macros::feeless_if) +//! attribute. +//! +//! - [`CheckMetadataHash`](frame_metadata_hash_extension::CheckMetadataHash): Extends transactions +//! to include the so-called metadata hash. This is required by chains to support the generic +//! Ledger application and other similar offline wallets. +//! +//! - [`StorageWeightReclaim`](cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim): A +//! signed extension for parachains that reclaims unused storage weight after executing a +//! transaction. +//! +//! For more information about these extensions, follow the link to the type documentation. +//! +//! # Building a custom signed extension //! //! Defining a couple of very simple signed extensions looks like the following: #![doc = docify::embed!("./src/reference_docs/signed_extensions.rs", signed_extensions_example)] diff --git a/substrate/frame/system/src/extensions/check_mortality.rs b/substrate/frame/system/src/extensions/check_mortality.rs index 148dfd4aad47..31fdbba5950e 100644 --- a/substrate/frame/system/src/extensions/check_mortality.rs +++ b/substrate/frame/system/src/extensions/check_mortality.rs @@ -28,6 +28,9 @@ use sp_runtime::{ /// Check for transaction mortality. /// +/// The extension adds [`Era`] to every signed extrinsic. It also contributes to the signed data, by +/// including the hash of the block at [`Era::birth`]. +/// /// # Transaction Validity /// /// The extension affects `longevity` of the transaction according to the [`Era`] definition. diff --git a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs index 00391d79478c..682fb3203561 100644 --- a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs @@ -16,8 +16,8 @@ //! # Skip Feeless Payment Pallet //! //! This pallet allows runtimes that include it to skip payment of transaction fees for -//! dispatchables marked by [`#[pallet::feeless_if]`](`macro@ -//! frame_support::pallet_prelude::feeless_if`). +//! dispatchables marked by +//! [`#[pallet::feeless_if]`](frame_support::pallet_prelude::feeless_if). //! //! ## Overview //! @@ -30,8 +30,9 @@ //! ## Integration //! //! This pallet wraps an existing transaction payment pallet. This means you should both pallets -//! in your `construct_runtime` macro and include this pallet's -//! [`SignedExtension`] ([`SkipCheckIfFeeless`]) that would accept the existing one as an argument. +//! in your [`construct_runtime`](frame_support::construct_runtime) macro and +//! include this pallet's [`SignedExtension`] ([`SkipCheckIfFeeless`]) that would accept the +//! existing one as an argument. #![cfg_attr(not(feature = "std"), no_std)]