-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Make extrinsics executed as sudo require 0 fees #6657
Comments
You should simply write your own Sudo pallet which has no fees. Should be very straight forward, probably just copy and paste the code and add the You will also need to add additional logic that verifies transactions to this pallet before they are propagated to the network. If an extrinsic has zero fees, that means that even "bad calls" to the extrinsic will have zero fees. Imagine I am not the sudo user, and I call the sudo function a million times, each time it tells me "sorry you dont have access", but I fill the block with these txs, I fill the network with propagating these tx, etc.. You need to create a signed extension that does the sudo account verification in the tx queue. Here is an example of such a check in Polkadot for claims, where we also allow a zero fee tx: https://github.com/paritytech/polkadot/blob/master/runtime/common/src/claims.rs#L541 Note you should still keep the Weight information the same. Weight information is used to determine how full your block is, which is important for chains that have a fixed block time. |
@shawntabrizi Thanks for the reply. So it doesn't help just to have
I had not realized that. Thanks for pointing out. |
@lovesh you need both |
@shawntabrizi Yes, as you saw, I raised the PR for sudo pallet supporting |
@shawntabrizi I understand your comment in the PR that the change could potentially cause spam. Assuming I don't take the |
Refunding the fees should work. Also shouldnt be that hard to calculate. The main different here is that a user must have at least enough fees to initially be able to pay the transaction, versus something truly feeless would allow any user, even one with zero balance, to submit the tx. I think though in general this behavior is strange from a philosophical standpoint. The Sudo user can call balances pallet and mint as much money as they like whenever they want. Giving them "zero fees" doesn't really accomplish much, and implies to me you might be looking to use sudo in ways it wasnt intended. I really think the solution here is to design your own pallet which builds the correct layers of functionality you need for your scenario, including access to Root dispatch, zero fees, etc... |
@lovesh Actually there might be a good solution we can implement in Substrate directly. Let me get back to you on this thread once I know more! Feel free to ping me on riot if you want to chat. |
That does work or me as sudo ends up with the same balance as before.
I agree, this seems a contrived use-case and in practice might not matter that much. The arbitrary minting has more manual effort (see how much I paid and then mint).
Lets see if I understand. Say I have an extrinsic Will ping you in Riot |
Can this be closed? |
I want to make some extrinsics require 0 fees, these are required to be sent by sudo. For non-sudo extrinsics, I can annotate the extrinsic with
#[weight = (0, Pays::No)]
and it works. But with sudo, I see the extrinsic call is wrapped with sudo pallet'ssudo
dispatchable which itself has non-zero weight and thus the extrinsic ends up having weight. I tried using the sudo pallet'ssudo_unchecked_weight
and pass 0 weight but still the extrinsic will have some fee due to the length, base fee, etcMy understanding of the weight annotations of the sudo pallet's extrinsics like
is that the
sudo
will inherit theDispatchClass
of the actual call (from my pallet) being made throughget_dispatch_info().class
. If it was inheriting thePays
enum as well like thisthen annotating my pallet's extrinsic with
Pays::No
will work. Is that correct?Is there another way of achieving my objective?
The text was updated successfully, but these errors were encountered: