Files
pezkuwi-subquery/noter/test/prove.test.mjs
T
SatoshiQaziMuhammed c5be7f62f8 noter: prove a stake from the hub's own state once the People chain takes proofs (#39)
The People chain is gaining `prove_stake` (pezkuwi-DKS #132): a stake is proven from the Asset
Hub's own state through a relay-anchored storage proof, instead of a noter reporting it and
re-confirming it every three days -- which does not fit at forty million.

When the People chain's metadata has `stakingScore.proveStake`, the bot:
- builds the proof (`prove.js`): the relay parent of People's best block, which People kept in
  `RelayRoots`; the relay proof of `Paras::Heads(1000)` there; the hub proof of the account's
  `Staking::Bonded`/`Ledger`/`Nominators`, `NominationPools::PoolMembers`, and for a member the
  pool and its bonded account;
- submits it when the hub's figure differs from the People chain's, or when what People holds
  was never proven; never re-confirms an unchanged, proven stake;
- watches the Asset Hub's finalized blocks for staking and pool events and proves the tracked
  accounts they touch as they happen; the periodic scan stays as a safety net.

Before the upgrade nothing changes: the noter path is used as today. The bot's own reading only
decides when to prove; what lands is what the proof says. `prove.test.mjs` pins the pool account
derivation against Zagros pool 10.
2026-10-29 04:21:56 +04:00

16 lines
665 B
JavaScript

// node --test noter/test
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { stringToU8a } from '@pezkuwi/util';
import { poolBondedAccount } from '../prove.js';
// The People chain derives the same account (`hub_proof::pool_bonded_account`); pool 10 on
// Zagros, read off the live chain on 2026-10-28.
test('a pool bonded account is derived as the hub derives it', () => {
const zagrosPool10 = [
109, 111, 100, 108, 112, 121, 47, 110, 111, 112, 108, 115, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
];
assert.deepEqual(Array.from(poolBondedAccount(stringToU8a('py/nopls'), 10)), zagrosPool10);
});