All pallets

Grandpa docs

Look up any call, event, or storage item with code examples. Runtime v472 · Block #9,197,056

Developer documentation for the Grandpa pallet of the Subtensor blockchain, part of the Bittensor decentralized AI network. This page is designed for developers integrating with the chain: look up any call, event, or storage item, copy code examples in TypeScript, Python, or Rust, and filter by your role. For in-depth explanations, version history, and relationships between items, see the Reference section.

Grandpa

See [`Pallet::report_equivocation`].

Index: 4 23 items

Calls 3

report_equivocation

call details

Reports GRANDPA voter equivocation (double voting) with ownership proof.

Parameters

NameTypeFormatDescription
equivocation_proofEquivocationProof—equivocation_proof (EquivocationProof)
key_owner_proofVoid—key_owner_proof (Void)
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// 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 report_equivocation call (typed, named args)
const equivocation_proof = undefined as any /* EquivocationProof — replace with real value */;

const tx = api.tx.Grandpa.report_equivocation({
  equivocation_proof,
});

report_equivocation_unsigned

call details

Reports GRANDPA equivocation without requiring a signed transaction.

Parameters

NameTypeFormatDescription
equivocation_proofEquivocationProof—equivocation_proof (EquivocationProof)
key_owner_proofVoid—key_owner_proof (Void)
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// 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 report_equivocation_unsigned call (typed, named args)
const equivocation_proof = undefined as any /* EquivocationProof — replace with real value */;

const tx = api.tx.Grandpa.report_equivocation_unsigned({
  equivocation_proof,
});

note_stalled

call details

Signals that GRANDPA finality has stalled and schedules a forced authority set change.

Parameters

NameTypeFormatDescription
delayu32Integerdelay: Block number
best_finalized_block_numberu32Integerbest_finalized_block_number: Block number
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 note_stalled call (typed, named args)
const delay = 0;
const best_finalized_block_number = 0;

const tx = api.tx.Grandpa.note_stalled({
  delay,
  best_finalized_block_number,
});

Events 3

NewAuthorities

event details

Emitted when a new GRANDPA authority set becomes active.

When it fires

  • Session change triggered authority set rotation
  • New validators have been selected for GRANDPA

Fields

NameTypeFormatDescription
authority_setVec<(Public, u64)>Array of (Public, u64)New set of GRANDPA authorities (public keys with voting weights)
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);

// Subscribe to NewAuthorities events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Grandpa.NewAuthorities.get(block.hash);
  for (const evt of events) {
    console.log("NewAuthorities:", evt.payload);
  }
});

Paused

event details

Emitted when GRANDPA finality is paused by governance.

When it fires

  • GRANDPA was previously live (not already paused)
  • Governance or root triggered the pause
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);

// Subscribe to Paused events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Grandpa.Paused.get(block.hash);
  for (const evt of events) {
    console.log("Paused:", evt.payload);
  }
});

Resumed

event details

Emitted when GRANDPA finality resumes after being paused.

When it fires

  • GRANDPA was previously paused
  • Governance or root triggered the resume
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);

// Subscribe to Resumed events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Grandpa.Resumed.get(block.hash);
  for (const evt of events) {
    console.log("Resumed:", evt.payload);
  }
});

Storage 7

Authorities

storage details

List of current GRANDPA authorities (public keys with voting weights).

Modifier: Default Keys: 0 Returns: WeakBoundedVec
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);

// Query Authorities storage (no keys - plain value)
const result = await api.query.Grandpa.Authorities.getValue();
console.log("Authorities:", result);

CurrentSetId

storage details

Monotonically increasing counter for GRANDPA authority set changes.

Modifier: Default Keys: 0 Returns: u64 (Integer)
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);

// Query CurrentSetId storage (no keys - plain value)
const result = await api.query.Grandpa.CurrentSetId.getValue();
console.log("CurrentSetId:", result);

NextForced

storage details

Next block number where a forced authority change can be signaled.

Modifier: Optional Keys: 0 Returns: u32 (Integer)
Modified by: note_stalled
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);

// Query NextForced storage (no keys - plain value)
const result = await api.query.Grandpa.NextForced.getValue();
console.log("NextForced:", result);

PendingChange

storage details

Scheduled authority set change waiting to be applied.

Modifier: Optional Keys: 0 Returns: StoredPendingChange
Modified by: note_stalled
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);

// Query PendingChange storage (no keys - plain value)
const result = await api.query.Grandpa.PendingChange.getValue();
console.log("PendingChange:", result);

SetIdSession

storage details

Maps GRANDPA set ID to the session index when that set was last responsible.

Modifier: Optional Keys: 1 Returns: u32 (Integer)

Keys

NameTypeFormatDescription
key1u64Integer—
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);

// Query SetIdSession storage
const key1 = 0n;

const result = await api.query.Grandpa.SetIdSession.getValue(key1);
console.log("SetIdSession:", result);

Stalled

storage details

Indicates GRANDPA has stalled with (delay, best_finalized_block).

Modifier: Optional Keys: 0 Returns: (u32, u32)
Modified by: note_stalled
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);

// Query Stalled storage (no keys - plain value)
const result = await api.query.Grandpa.Stalled.getValue();
console.log("Stalled:", result);

State

storage details

Current state of the GRANDPA authority set (Live, Paused, or PendingPause/Resume).

Modifier: Default Keys: 0 Returns: StoredState
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);

// Query State storage (no keys - plain value)
const result = await api.query.Grandpa.State.getValue();
console.log("State:", result);

Constants 3

MaxAuthorities

constant details

Maximum number of GRANDPA authorities allowed.

Type: u32
Value: 32
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);

// Query MaxAuthorities constant
const value = await api.constants.Grandpa.MaxAuthorities();
console.log("MaxAuthorities:", value);

MaxNominators

constant details

Maximum nominators per validator for GRANDPA key ownership proofs.

Type: u32
Value: 20
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);

// Query MaxNominators constant
const value = await api.constants.Grandpa.MaxNominators();
console.log("MaxNominators:", value);

MaxSetIdSessionEntries

constant details

Maximum entries kept in the SetIdSession mapping.

Type: u64
Value: "0"
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);

// Query MaxSetIdSessionEntries constant
const value = await api.constants.Grandpa.MaxSetIdSessionEntries();
console.log("MaxSetIdSessionEntries:", value);
// Balance: divide by 10^9 for TAO
const tao = value / 1_000_000_000n;

Errors 7

PauseFailed

error details #0

Cannot pause GRANDPA because it's already paused or pending.

Common Causes

  • Already paused
  • PendingPause scheduled

How to Fix

Check Grandpa.State,Wait for pending change

ResumeFailed

error details #1

Cannot resume GRANDPA because it's not paused.

Common Causes

  • Already Live
  • PendingResume scheduled

How to Fix

Check Grandpa.State,Wait for pending change

ChangePending

error details #2

An authority set change is already pending.

Common Causes

  • Session change scheduled
  • Previous forced change pending

How to Fix

Check Grandpa.PendingChange,Wait for current change

TooSoon

error details #3

Cannot signal forced change; minimum delay not met.

Common Causes

  • Recent forced change
  • NextForced not reached

How to Fix

Check Grandpa.NextForced,Wait for delay

InvalidKeyOwnershipProof

error details #4

Key ownership proof in equivocation report is invalid.

Common Causes

  • Wrong session
  • Proof corrupted
  • Session data pruned

How to Fix

Verify session matches,Check SetIdSession,Report promptly

InvalidEquivocationProof

error details #5

Equivocation proof doesn't demonstrate double voting.

Common Causes

  • Bad signatures
  • Same block
  • Wrong round

How to Fix

Verify signatures,Ensure different blocks,Check round

DuplicateOffenceReport

error details #6

This equivocation was already reported.

Common Causes

  • Another reporter was faster
  • Resubmitting

How to Fix

No action needed - offender will be slashed