sudo_unchecked_weight

Call v101 → current #1

Dispatches a call with Root origin and custom weight specification.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

Sometimes you need to execute a call that would be rejected due to weight limits - especially runtime upgrades. sudo_unchecked_weight lets you specify the weight manually, bypassing the normal weight calculation. This is dangerous as it could overload blocks, but necessary for operations like deploying new code.

Why This Matters

Block weight limits protect the network from overload. But some legitimate operations (especially runtime upgrades) need to exceed these limits. This call provides an escape hatch for authorized administrators.

Example Scenario

You need to deploy a runtime upgrade that requires more weight than a single block allows. Call sudo_unchecked_weight(call=set_code(new_wasm), weight=Weight{ref_time: max, proof_size: max}). The upgrade executes regardless of normal weight limits.

Common Questions

Why would I use this instead of regular sudo?
Regular sudo still enforces weight limits. Use sudo_unchecked_weight when you need to exceed those limits, such as runtime upgrades or emergency heavy operations.
Is there a risk of blocking the network?
Yes, specifying excessive weight could produce blocks that validators struggle to process. Use sparingly and with accurate weight estimates.

Use Cases

  • Execute heavy operations that exceed normal block weight limits
  • Runtime upgrades that require maximum block weight
  • Emergency fixes when weight calculation is incorrect
  • Testing and benchmarking purposes

From Chain Metadata

Authenticates the sudo key and dispatches a function call with `Root` origin. This function does not check the weight of the call, and instead allows the Sudo user to specify the weight of the call. The dispatch origin for this call must be _Signed_. ## Complexity O(1).

Input Parameters

#NameTypeDescription
0
call
RuntimeCall call (RuntimeCall)
1
weight
Weight weight (Weight)

Permissions

Origin
Root
Required Role

Requirements

  • Signer must be the current sudo key
  • Call must be a valid runtime call
  • Weight must be specified as Weight struct

Effects

Events Emitted

Postconditions

  • The inner call is dispatched with Root origin
  • Transaction uses specified weight instead of computed weight
  • Sudid event emitted with call result

Side Effects

  • May allow execution of calls that would otherwise exceed block weight
  • Inner call effects apply as normal

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Build sudo_unchecked_weight call
const call = 0 as any /* RuntimeCall */;
const weight = 0 as any /* Weight */;

const call = api.tx[stringCamelCase("Sudo")][stringCamelCase("sudo_unchecked_weight")](
  call,
  weight
);

Runtime Info

Pallet Index
12
Call Index
1
First Version
v101
Current Version
v393