Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRAME: Meta Transaction #6428

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e0f8b55
init impl
muharem Oct 24, 2024
fee605e
preamble
muharem Oct 24, 2024
75fd3ee
benchmarks
muharem Oct 25, 2024
1c7b1b4
fox cargo features
muharem Oct 29, 2024
3d9a9e2
integrate meta-tx pallet into runtimes
muharem Nov 7, 2024
2a95be7
remove preamble
muharem Nov 7, 2024
dd2afa6
update doc
muharem Nov 7, 2024
a44b9cc
runtime origin config
muharem Nov 7, 2024
4e65e60
tests
muharem Nov 8, 2024
4f8b3cf
weights
muharem Nov 8, 2024
89698ea
fixes
muharem Nov 11, 2024
1543cec
Merge remote-tracking branch 'origin/master' into muharem-meta-tx
muharem Nov 11, 2024
08f3928
prdoc
muharem Nov 11, 2024
44eff95
weightinfo
muharem Nov 11, 2024
867cbcb
propogate features
muharem Nov 11, 2024
d7dc7ae
Merge branch 'master' into muharem-meta-tx
shawntabrizi Nov 12, 2024
1249eed
Merge remote-tracking branch 'origin/master' into muharem-meta-tx
muharem Nov 25, 2024
b9ae6fa
use verify signature pallet, add ext version, update docs
muharem Nov 25, 2024
21744f6
undo fmt
muharem Nov 25, 2024
27acefb
update prdoc
muharem Nov 25, 2024
d25b7a3
toml fmt fix
muharem Nov 25, 2024
4c53277
fixe
muharem Nov 25, 2024
1f839f1
fix
muharem Nov 25, 2024
532edd2
remove unstable
muharem Nov 25, 2024
d4e7911
remove unstable
muharem Nov 25, 2024
f91835f
fix
muharem Nov 25, 2024
17db627
fix docs
muharem Nov 25, 2024
51e4046
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Nov 25, 2024
1cc1ec9
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Nov 25, 2024
0ea2924
Merge branch 'master' into muharem-meta-tx
muharem Nov 26, 2024
488440b
Merge branch 'master' into muharem-meta-tx
muharem Dec 9, 2024
4c6f5ef
Apply suggestions from code review
muharem Dec 22, 2024
9591d57
fmt
muharem Dec 22, 2024
b093542
Merge remote-tracking branch 'origin/master' into muharem-meta-tx
muharem Dec 22, 2024
85c1512
taplo fmt
muharem Dec 22, 2024
eae9d94
fix
muharem Dec 22, 2024
b54e16f
drop associate types, use bounds
muharem Dec 22, 2024
7bb2175
Merge remote-tracking branch 'origin/master' into muharem-meta-tx
muharem Jan 14, 2025
295165a
meta tx marker
muharem Jan 14, 2025
57c55c1
include verify signature pallet into westend
muharem Jan 14, 2025
8106b06
include features
muharem Jan 14, 2025
e0462d7
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Jan 14, 2025
5f7bcb5
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jan 14, 2025
010ba1f
weights
muharem Jan 15, 2025
246710a
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Jan 15, 2025
4b3bcba
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jan 15, 2025
84c2533
Merge branch 'master' into muharem-meta-tx
muharem Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ members = [
"substrate/frame/membership",
"substrate/frame/merkle-mountain-range",
"substrate/frame/message-queue",
"substrate/frame/meta-tx",
"substrate/frame/metadata-hash-extension",
"substrate/frame/migrations",
"substrate/frame/mixnet",
Expand Down Expand Up @@ -948,6 +949,7 @@ pallet-insecure-randomness-collective-flip = { path = "substrate/frame/insecure-
pallet-lottery = { default-features = false, path = "substrate/frame/lottery" }
pallet-membership = { path = "substrate/frame/membership", default-features = false }
pallet-message-queue = { path = "substrate/frame/message-queue", default-features = false }
pallet-meta-tx = { path = "substrate/frame/meta-tx", default-features = false }
pallet-migrations = { path = "substrate/frame/migrations", default-features = false }
pallet-minimal-template = { path = "templates/minimal/pallets/template", default-features = false }
pallet-mixnet = { default-features = false, path = "substrate/frame/mixnet" }
Expand Down
4 changes: 4 additions & 0 deletions polkadot/runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pallet-identity = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-meta-tx = { workspace = true }
pallet-migrations = { workspace = true }
pallet-mmr = { workspace = true }
pallet-multisig = { workspace = true }
Expand Down Expand Up @@ -170,6 +171,7 @@ std = [
"pallet-indices/std",
"pallet-membership/std",
"pallet-message-queue/std",
"pallet-meta-tx/std",
"pallet-migrations/std",
"pallet-mmr/std",
"pallet-multisig/std",
Expand Down Expand Up @@ -261,6 +263,7 @@ runtime-benchmarks = [
"pallet-indices/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-meta-tx/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-mmr/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
Expand Down Expand Up @@ -324,6 +327,7 @@ try-runtime = [
"pallet-indices/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-meta-tx/try-runtime",
"pallet-migrations/try-runtime",
"pallet-mmr/try-runtime",
"pallet-multisig/try-runtime",
Expand Down
29 changes: 29 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,31 @@ impl OnSwap for SwapLeases {
}
}

pub type MetaTxExtension = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
muharem marked this conversation as resolved.
Show resolved Hide resolved
frame_system::CheckNonce<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

impl pallet_meta_tx::Config for Runtime {
type WeightInfo = weights::pallet_meta_tx::WeightInfo<Runtime>;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Signature = Signature;
type PublicKey = <Signature as sp_runtime::traits::Verify>::Signer;
#[cfg(not(feature = "runtime-benchmarks"))]
type Extension = MetaTxExtension;
#[cfg(feature = "runtime-benchmarks")]
type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = pallet_meta_tx::BenchmarkHelperFor<Runtime>;
}

#[frame_support::runtime(legacy_ordering)]
mod runtime {
#[runtime::runtime]
Expand Down Expand Up @@ -1773,6 +1798,9 @@ mod runtime {
#[runtime::pallet_index(102)]
pub type RootTesting = pallet_root_testing;

#[runtime::pallet_index(103)]
pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;

// BEEFY Bridges support.
#[runtime::pallet_index(200)]
pub type Beefy = pallet_beefy;
Expand Down Expand Up @@ -1916,6 +1944,7 @@ mod benches {
[pallet_vesting, Vesting]
[pallet_whitelist, Whitelist]
[pallet_asset_rate, AssetRate]
[pallet_meta_tx, MetaTx]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/westend/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod pallet_fast_unstake;
pub mod pallet_identity;
pub mod pallet_indices;
pub mod pallet_message_queue;
pub mod pallet_meta_tx;
pub mod pallet_migrations;
pub mod pallet_mmr;
pub mod pallet_multisig;
Expand Down
57 changes: 57 additions & 0 deletions polkadot/runtime/westend/src/weights/pallet_meta_tx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for `pallet_meta_tx`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-11-08, STEPS: `50`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024

// Executed Command:
// ./target/debug/polkadot
// benchmark
// pallet
// --chain=westend-dev
// --steps=50
// --repeat=2
// --pallet=pallet-meta-tx
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./polkadot/runtime/westend/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]

use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;

/// Weight functions for `pallet_meta_tx`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_meta_tx::WeightInfo for WeightInfo<T> {
fn bare_dispatch() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 138_000_000 picoseconds.
Weight::from_parts(140_000_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
27 changes: 27 additions & 0 deletions prdoc/pr_6428.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "FRAME: Meta Transaction"

doc:
- audience: Runtime Dev
description: |
Introduces the meta-tx pallet that implements Meta Transactions.

The meta transaction follows a layout similar to that of a regular transaction and can
leverage the same extensions that implement the `TransactionExtension` trait. Once signed and
shared by the signer, it can be relayed by a relayer. The relayer then submits a regular
transaction with the `meta-tx::dispatch` call, passing the signed meta transaction as an
argument.

To see an example, refer to the `sign_and_execute_meta_tx` test case within the pallet.

crates:
- name: pallet-meta-tx
bump: major
- name: westend-runtime
bump: major
- name: kitchensink-runtime
bump: major
- name: polkadot-sdk
bump: major
29 changes: 29 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,31 @@ impl pallet_parameters::Config for Runtime {
type WeightInfo = ();
}

pub type MetaTxExtension = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

impl pallet_meta_tx::Config for Runtime {
type WeightInfo = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Signature = Signature;
type PublicKey = <Signature as sp_runtime::traits::Verify>::Signer;
#[cfg(not(feature = "runtime-benchmarks"))]
type Extension = MetaTxExtension;
#[cfg(feature = "runtime-benchmarks")]
type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = pallet_meta_tx::BenchmarkHelperFor<Runtime>;
}

#[frame_support::runtime]
mod runtime {
use super::*;
Expand Down Expand Up @@ -2629,6 +2654,9 @@ mod runtime {

#[runtime::pallet_index(81)]
pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;

#[runtime::pallet_index(82)]
pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
}

impl TryFrom<RuntimeCall> for pallet_revive::Call<Runtime> {
Expand Down Expand Up @@ -2889,6 +2917,7 @@ mod benches {
[pallet_example_mbm, PalletExampleMbms]
[pallet_asset_conversion_ops, AssetConversionMigration]
[pallet_verify_signature, VerifySignature]
[pallet_meta_tx, MetaTx]
);
}

Expand Down
60 changes: 60 additions & 0 deletions substrate/frame/meta-tx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
name = "pallet-meta-tx"
description = "Dispatch Meta Transaction"
license = "Apache-2.0"
version = "0.1.0"
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true

[lints]
workspace = true

[dependencies]
codec = { workspace = true, features = ["max-encoded-len"] }
docify = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
serde = { features = ["derive"], optional = true, workspace = true }

frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
sp-io = { workspace = true}

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
pallet-transaction-payment = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
sp-keystore ={ workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"pallet-balances/try-runtime",
"pallet-transaction-payment/try-runtime",
]
Loading
Loading