Skip to content

FRAME: Syntax for marking calls "feeless" #1725

@liamaharon

Description

@liamaharon

Moving an internal FRAME team discussion to a Github issue.

Motivation

@gavofyork suggested a new syntax which can be used before a call and have it mean that it can skip all normal transaction fee and account existence requirements.

#[pallet::feeless_if(|origin: &OriginFor<T>, ticket: &Ticket| -> bool {
	let account = ensure_signed(origin.clone())?;
	some_conditions_here(&account, &ticket)
})]

@gupnik volunteered to work on it.

Solution

@gupnik suggested a solution and requested feedback:

  1. Pallet Call enum can optionally have a feeless conditional.
  2. Construct Runtime creates a RuntimeSignedExtension that takes OnChargeTransaction.
  3. In post_dispatch, we check if the current call has a feeless conditional. If so, the fee is never charged (bypassing the requirement the caller has any balance).

A couple of questions

  1. How can RuntimeSignedExtension know the amount that was charged originally?
  2. Is there a way to test the entire flow using a unit test? Any references that I could use?

Other questions

  • @KiChjang suggested rather than an attribute macro this could be implemented in a way more 'rustic'.
  • @liamaharon considered rather than the method returning a bool, it returning a Balance which could be used to modify the fee in more than a single way way.

Metadata

Metadata

Assignees

Labels

T1-FRAMEThis PR/Issue is related to core FRAME, the framework.

Type

No type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions