feat(meta-tx): sponsored meta transactions for native Substrate accounts [ignore benchmarks] - #1505
Open
iamyxsh wants to merge 2 commits into
Open
feat(meta-tx): sponsored meta transactions for native Substrate accounts [ignore benchmarks]#1505iamyxsh wants to merge 2 commits into
iamyxsh wants to merge 2 commits into
Conversation
|
Crate versions that have not been updated:
New crates:
Crate versions that have been downgraded:
Runtime version has not been increased. |
|
Quick benchmark at commit 1c09b0e has been executed successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A POC of sponsored meta transactions for native Substrate accounts — a user signs an intent
off-chain, anyone submits it and pays the fee, and the call executes under the signer's origin.
This is the Substrate counterpart of the EVM call-permit path. Opening it for feedback on
direction before hardening.
Why only Substrate accounts
While scoping this I tested what already exists. The EVM side already does most of what was
asked for:
pays everything (measured: ~0.09 HDX).
So the remaining gap was native Substrate accounts only, and that is all this PR adds.
Why it is small
On the EVM side "the relayer pays" needed the whole
EvmFeePayeroverride, because EVM gas ischarged to
source. On the Substrate side the relayer signs and submits the extrinsic, soChargeTransactionPaymentalready charges them. Nothing to build.That leaves three jobs: verify a signature, dispatch under the signer's origin, bump a nonce.
What is in the payload
blake2_256over(tag, call, signer, nonce, deadline, genesis_hash, spec_version).Genesis hash and spec version are the Substrate analogue of EIP-712's domain separator — without
them an intent replays across forks, and across runtime upgrades that change call encoding.
Behaviour worth reviewing
replayable. The inner outcome is reported in the
Dispatchedevent rather than as anextrinsic error. This mirrors the EVM permit path.
CallFilterapplies — verified by an integration test that pausesCurrencies::transferand confirms a signed intent for it does not execute.utility.batch_allis just a valid inner call.The relayer
scripts/meta-tx-relayer/— an HTTP service that accepts intents, screens them against apallet allowlist, dry-runs, and submits. ERC-4337's bundler-plus-paymaster.
It is deliberately not in the node. The relayer holds a funded key and signs. RPC nodes are
public and replicated, so a spending key in one means every operator sponsors everyone. The
repo's own precedent agrees:
liquidation-worker-supportexposes an RPC that only serves data,and the actor that signs lives outside. A node RPC remains possible if sponsorship ever needs
to be consensus-adjacent; it does not.
npm run demogenerates a brand-new zero-balance account, signs an intent, and shows thebalance still zero afterwards.
Tests
22 total, all passing.
pallets/meta-tx/src/tests.rs): valid path and origin, wrong signer, call swappedafter signing, deadline swapped after signing, replay, nonce ahead, expired, on-deadline
boundary, nonce consumed on inner failure,
batch_allall-or-nothing both ways, unsignedorigin rejected, every payload field proven load-bearing, per-signer nonce independence.
integration-tests/src/meta_tx.rs), through the full fee pipeline so thesponsorship claim is real: zero-balance signer fully sponsored, batching, replay, expiry,
call filter respected, meta nonce independent of the system nonce.
Known gaps — deliberate for a POC
weights.rsis hand-set and needsscripts/benchmarking.shbefore this carries value on mainnet. The benchmark currently measures the reject path.
hash. Fine for a relayer-operated flow, not fine for arbitrary users. This may be the real
blocker for production and is worth discussing.
expiry and ordering questions. Not built pending confirmation it is wanted.
CallFilter. A signed call is a broad grant. AProxyType-style filter is the obvious next step if that is a concern.Questions