mirror of
https://github.com/pezkuwichain/pezkuwi-subquery.git
synced 2026-10-20 18:56:24 +00:00
Remove relay staking handlers after pallet removal (spec 1_020_006)
Staking pallet (index 9), FastUnstake (15), and VoterBagsList (100) were removed from the relay chain. The relay indexer now only tracks transfers and signed extrinsics. Added safety try-catch to staking queries in case handlers are accidentally re-enabled.
This commit is contained in:
1 parent
8a5681db33
commit
3cc7a7b245
3 files changed
+43
-62
No files matched your search
+1
-58
@@ -8,7 +8,7 @@ runner:
|
|||||||
query:
|
query:
|
||||||
name: "@subql/query"
|
name: "@subql/query"
|
||||||
version: "*"
|
version: "*"
|
||||||
description: Pezkuwi Staking SubQuery - Indexes staking rewards, slashes, era data for PezWallet
|
description: Pezkuwi Relay SubQuery - Indexes transfer history and governance-related data
|
||||||
repository: https://github.com/pezkuwichain/pezkuwi-subquery
|
repository: https://github.com/pezkuwichain/pezkuwi-subquery
|
||||||
schema:
|
schema:
|
||||||
file: ./schema.graphql
|
file: ./schema.graphql
|
||||||
@@ -26,71 +26,14 @@ dataSources:
|
|||||||
mapping:
|
mapping:
|
||||||
file: ./dist/index.js
|
file: ./dist/index.js
|
||||||
handlers:
|
handlers:
|
||||||
# Block handler: initialize active relay stakers from chain state
|
|
||||||
- handler: handleRelayBlock
|
|
||||||
kind: substrate/BlockHandler
|
|
||||||
# Signed extrinsics for history
|
# Signed extrinsics for history
|
||||||
- handler: handleHistoryElement
|
- handler: handleHistoryElement
|
||||||
kind: substrate/CallHandler
|
kind: substrate/CallHandler
|
||||||
filter:
|
filter:
|
||||||
isSigned: true
|
isSigned: true
|
||||||
# Staking rewards (old format)
|
|
||||||
- handler: handleReward
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: Reward
|
|
||||||
# Staking rewards (new format - Polkadot 2.0)
|
|
||||||
- handler: handleRewarded
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: Rewarded
|
|
||||||
# Nomination Pools rewards
|
|
||||||
- handler: handlePoolReward
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: nominationPools
|
|
||||||
method: PaidOut
|
|
||||||
# Slashing (old format)
|
|
||||||
- handler: handleSlash
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: Slash
|
|
||||||
# Slashing (new format)
|
|
||||||
- handler: handleSlashed
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: Slashed
|
|
||||||
# Pool bonded slash
|
|
||||||
- handler: handlePoolBondedSlash
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: nominationPools
|
|
||||||
method: PoolSlashed
|
|
||||||
# Pool unbonding slash
|
|
||||||
- handler: handlePoolUnbondingSlash
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: nominationPools
|
|
||||||
method: UnbondingPoolSlashed
|
|
||||||
# Transfers
|
# Transfers
|
||||||
- handler: handleTransfer
|
- handler: handleTransfer
|
||||||
kind: substrate/EventHandler
|
kind: substrate/EventHandler
|
||||||
filter:
|
filter:
|
||||||
module: balances
|
module: balances
|
||||||
method: Transfer
|
method: Transfer
|
||||||
# Era changes (old format)
|
|
||||||
- handler: handleNewEra
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: StakingElection
|
|
||||||
# Era changes (new format - Polkadot 2.0)
|
|
||||||
- handler: handleStakersElected
|
|
||||||
kind: substrate/EventHandler
|
|
||||||
filter:
|
|
||||||
module: staking
|
|
||||||
method: StakersElected
|
|
||||||
+28
-4
@@ -30,7 +30,19 @@ export async function handleRelayBlock(block: SubstrateBlock): Promise<void> {
|
|||||||
|
|
||||||
logger.info("Initializing active relay stakers from live chain state...");
|
logger.info("Initializing active relay stakers from live chain state...");
|
||||||
|
|
||||||
const activeEraOpt = (await api.query.staking.activeEra()) as Option<any>;
|
// Safety: staking pallet was removed from relay chain in spec 1_020_006
|
||||||
|
if (!api.query.staking || !api.query.staking.activeEra) {
|
||||||
|
logger.info("Staking pallet not available on relay chain - skipping relay staker init");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let activeEraOpt: Option<any>;
|
||||||
|
try {
|
||||||
|
activeEraOpt = (await api.query.staking.activeEra()) as Option<any>;
|
||||||
|
} catch (e) {
|
||||||
|
logger.warn(`Failed to query staking.activeEra on relay: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (activeEraOpt.isNone) {
|
if (activeEraOpt.isNone) {
|
||||||
logger.info("No active era found on relay chain");
|
logger.info("No active era found on relay chain");
|
||||||
return;
|
return;
|
||||||
@@ -121,9 +133,21 @@ export async function handleStakersElected(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function handleNewEra(event: SubstrateEvent): Promise<void> {
|
export async function handleNewEra(event: SubstrateEvent): Promise<void> {
|
||||||
const currentEra = ((await api.query.staking.currentEra()) as Option<any>)
|
// Safety: staking pallet was removed from relay chain in spec 1_020_006
|
||||||
.unwrap()
|
if (!api.query.staking || !api.query.staking.currentEra) {
|
||||||
.toNumber();
|
logger.warn("Staking pallet not available - skipping handleNewEra");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentEra: number;
|
||||||
|
try {
|
||||||
|
currentEra = ((await api.query.staking.currentEra()) as Option<any>)
|
||||||
|
.unwrap()
|
||||||
|
.toNumber();
|
||||||
|
} catch (e) {
|
||||||
|
logger.warn(`Failed to query staking.currentEra: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let validatorExposures: Array<{
|
let validatorExposures: Array<{
|
||||||
address: string;
|
address: string;
|
||||||
|
|||||||
@@ -170,6 +170,20 @@ function calculateYearlyInflation(stakedPortion: number): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function computeAndSaveAPY(): Promise<void> {
|
async function computeAndSaveAPY(): Promise<void> {
|
||||||
|
// Safety: check staking pallet availability before querying
|
||||||
|
if (!api.query.staking || !api.query.staking.activeEra) {
|
||||||
|
logger.warn("Staking pallet not available on this chain - skipping APY computation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await _computeAndSaveAPYInner();
|
||||||
|
} catch (e) {
|
||||||
|
logger.warn(`APY computation failed: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function _computeAndSaveAPYInner(): Promise<void> {
|
||||||
// Use AH's own totalIssuance. AH staking pallet mints inflation from AH supply.
|
// Use AH's own totalIssuance. AH staking pallet mints inflation from AH supply.
|
||||||
const TOTAL_SUPPLY = (
|
const TOTAL_SUPPLY = (
|
||||||
(await api.query.balances.totalIssuance()) as any
|
(await api.query.balances.totalIssuance()) as any
|
||||||
|
|||||||
Reference in new issue
Block a user