I am trying to reimplement one of the Substrate tutorials:


But I am stuck with an issue - where it says to do Scheduler -> Schedule -> sudo transaction to set code with the new runtime version when I try to sign this transaction (scheduled in 20+ blocks from the current block like it says in the tutorial) I am getting the following error:

Screenshot with error on the request page

When I go to Network -> explorer I see this:

A sudo just took place. [result] 
sudoResult: Result<Null, SpRuntimeDispatchError>

Full error backlog below: UP MID DOWN

Had anyone faced this before? And how do you solve it? It is a tutorial and based on demo pre-defined data, so "not enough moneyunits to pay for your gas" shouldn't be an issue, I would imagine.

UPD: The question is specifically about the second part of the Substrate tutorial - where they use Scheduler pallet and sudo query to schedule runtime upgrade. This part: Using Scheduler pallet instead of unchecked weights

2 Answers 2


There was a recent change to the scheduler pallet which makes it now precisely meter its own weight consumption. The tutorial was probably not updated yet.
This leads to a situation where a full block cannot be consumed by a scheduled task anymore, since the scheduler already deduced his own cost from the full block.
The proper solution is to benchmark it, which will happen here.

The current make-shift solution (which was also applied on Polkadot) is to use Utility::with_weight. This call can be used to wrap any other call and explicitly force it to use a specific weight. So instead of consuming a full block, you can force it to consume just 10% to make it work. So instead of sending System::set_code(… you send Utility::with_weight(System::set_code(….

On a relay and solo chain this is not of much concern, since the only bad thing would be longer block time for that one block. On a para-chain this could lead to problems if the para-chain misses its block production slot or goes overweight with the block.

  • Thanks, Oliver! How can I run Utility::with_weight in Polkadot.JS Substrate portal? (polkadot.js.org/apps/#/sudo interface connected to local node)
    – Gogosama
    Feb 1, 2023 at 3:49
  • Just select Utility and with_weight in the link that you posted. Or compose it manually in the Developer -> Extrinsics tab In the Developer::Extrinsic tab, which needs a running PolkadotJS browser extension. polkadot.js.org/apps/… Feb 1, 2023 at 17:06
  • @OliverTale-Yazdi, I'm going to test your workaround solution and update the tutorial. However, it isn't clear whether I should remove the scheduler portion altogether for now (replace with the utility pallet) or keep the scheduler but add the utility pallet as a wrapper around the System set_code call. Can you clarify?
    – Lisa Gunn
    Feb 3, 2023 at 18:37
  • The Utility does not replace the Scheduler here. It just wraps around the call to be scheduled. So it is an additive change. Thanks for updating :) Feb 3, 2023 at 20:32
  • 1
    @ImmanuelJohn i responded over here substrate.stackexchange.com/questions/10380 😊 Nov 2, 2023 at 12:12

See this error from the docs

Resources exhausted, e.g. attempt to read/write data which is too large to manipulate.

The FRAME System module sets boundaries on the block length and block weight that these transactions can use. However, the set_code function is intentionally designed to consume the maximum weight that can fit in a block. Forcing a runtime upgrade to consume an entire block prevents transactions in the same block from executing on different versions of a runtime.

Instead of sudo pick the extrinsic sudoUncheckedWeight from the pallet sudo and call from there the setCode extrinsic. This setting allows for a block to take an indefinite time to compute to ensure that the runtime upgrade does not fail.

From the docs:

The sudo_unchecked_weight function is the same as the sudo function except that it supports an additional parameter to specify the weight to use for the call. This parameter enables you to work around resource accounting safeguards to specify a weight of zero for the call that dispatches the set_code function.

  • Thanks, Alex. I've already done that before (sudoUncheckedWeight method) and it worked. I wasn't precise, the question was specifically about the second part of the tutorial where they use Scheduler pallet to schedule a runtime upgrade. That part involve sudo query and cause block exhaustion.
    – Gogosama
    Jan 27, 2023 at 19:23
  • If it is like you say, does it mean that runtime upgrade may need more than one block to be executed? How would I schedule that?
    – Gogosama
    Jan 27, 2023 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.