Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Returning PermanentlyOverweight error on scheduled runtime upgrade when using set_code() #13288

Closed
2 tasks done
dnjscksdn98 opened this issue Feb 1, 2023 · 3 comments
Closed
2 tasks done
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@dnjscksdn98
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

I have tested some runtime upgrade actions while using the node-template of the current master branch. But when trying the instant runtime upgrade by the sudoUncheckedWeight() extrinsic, it worked fine as expected.

Instead, when trying to schedule a runtime upgrade at a certain future block, it always returns a PermanentlyOverweight error from pallet_scheduler. (Both sudo and governance proposals)

So I've tried to check out where the exact error point was and found out it was in the execute_dispatch() method. https://github.com/paritytech/substrate/blob/master/frame/scheduler/src/lib.rs#L1119

Inside the method it measures the weight for the scheduled call (max_weight). But in the case of set_code(), the weight is set as the maximum block weight of the system. So the actual measured weight for the scheduled set_code() call will be max_block_weight + execute_dispatch_unsigned_weight, that will always exceed the limit of the maximum block weight. So due to this kind of situation it will always fall into an Overweight error.
https://github.com/paritytech/substrate/blob/master/frame/scheduler/src/lib.rs#L1132

So I'm leaving an issue for any help to figure it out. And please let me know if I've done the right way to upgrade a runtime. (Just followed the official documentations)

My runtime impl for pallet_scheduler and pallet_preimage. Except implementing the pallets, no other changes have been made.

parameter_types! {
	pub MaximumSchedulerWeight: Weight = NORMAL_DISPATCH_RATIO * BlockWeights::get().max_block;
	pub const MaxScheduledPerBlock: u32 = 50;
}

impl pallet_scheduler::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type RuntimeOrigin = RuntimeOrigin;
	type PalletsOrigin = OriginCaller;
	type RuntimeCall = RuntimeCall;
	type MaximumWeight = MaximumSchedulerWeight;
	type ScheduleOrigin = EnsureRoot<AccountId>;
	type MaxScheduledPerBlock = MaxScheduledPerBlock;
	type OriginPrivilegeCmp = EqualPrivilegeOnly;
	type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
	type Preimages = Preimage;
}

parameter_types! {
	pub const PreimageBaseDeposit: Balance = 1 * DOLLARS;
	pub const PreimageByteDeposit: Balance = 1 * CENTS;
}

impl pallet_preimage::Config for Runtime {
	type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
	type RuntimeEvent = RuntimeEvent;
	type Currency = Balances;
	type ManagerOrigin = EnsureRoot<AccountId>;
	type BaseDeposit = PreimageBaseDeposit;
	type ByteDeposit = PreimageByteDeposit;
}
  • I also suggest to update the official runtime upgrade tutorial, because the type Preimages = (); for pallet_scheduler is not set to pallet_preimage. This will always lead to an Exhausted error.

Steps to reproduce

  1. Add pallet_scheduler and pallet_preimage to the node-template runtime.
  2. Build and launch the node. (./target/release/node-template --dev)
  3. Increase the spec_version and rebuild the project in a second terminal.
  4. Access polkadot.js apps page.
  5. Access the sudo tab and execute a set_code() call by schedule()
  6. Wait until it reaches the scheduled block.
@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Feb 1, 2023
@hirschenberger
Copy link
Contributor

This may be resolved when we don't use max_weight anymore when #13192 lands

@ggwpez
Copy link
Member

ggwpez commented Feb 2, 2023

Yes someone also asked this on SE https://substrate.stackexchange.com/questions/6919 and it should indeed be fixed by the aforementioned MR.

The work-around is to wrap it in Utility::with_weight to override the weight to something small.

Closing in favour of #13192

@ggwpez ggwpez closed this as completed Feb 2, 2023
@dnjscksdn98
Copy link
Author

Thanks for your support 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

3 participants