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 Box<<T as Config>::RuntimeCall>call (RuntimeCall)
1
weight
Weight weight: Substrate dispatch weight (computational cost)

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

// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build sudo_unchecked_weight call (typed, named args)
const call = undefined as any /* RuntimeCall — replace with real value */;
const weight = undefined as any /* Weight — replace with real value */;

const tx = api.tx.Sudo.sudo_unchecked_weight({
  call,
  weight,
});

Runtime Info

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