mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 16:07:57 +00:00
71aa0b0931
* test that successfully verify self-generated proof * verify proof result on all unpaused nodes * tighten interface: reuse connection * generate the proof on arbitrary node * s/stub-name/validator seems this doesn't pass some regex * rename script * add basic mmr-leaves test * documentation formatting * check lower bound on mmr leaves * test beefy rpc: finalized heads match * test mmr api: stateless proofs * set lower bound on number of leaves * change leaves in proof generation * remove TODOs * cleanup: consistently ignore zndsl name arg * refactor: simplify returns Co-authored-by: Serban Iorga <serban@parity.io> * lax finalized head test Co-authored-by: Adrian Catangiu <adrian@parity.io> * fixup! refactor: simplify returns * refactor out getApis Co-authored-by: Serban Iorga <serban@parity.io> * split out paused validator from group * refactor: don't ignore node arg don't randomize selection of proof generating / finalized head retrieving node, but use the node arg for this. * only check min block height, not relative Co-authored-by: Adrian Catangiu <adrian@parity.io> * verify finalized heads share same canonical chain picks the node with the highest finalized head, gets its blockchain headers since genesis, and verifies that all other nodes' finalized heads are in said blockchain. * fixup! split out paused validator from group Co-authored-by: Serban Iorga <serban@parity.io> --------- Co-authored-by: Serban Iorga <serban@parity.io> Co-authored-by: Adrian Catangiu <adrian@parity.io>
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
const common = require('./0003-common.js');
|
|
|
|
async function run(_, networkInfo, nodeNames) {
|
|
const apis = await common.getApis(networkInfo, nodeNames);
|
|
|
|
const finalizedHeads = await Promise.all(
|
|
Object.entries(apis).map(async ([nodeName, api]) => {
|
|
const finalizedHead = await api.rpc.beefy.getFinalizedHead();
|
|
return { nodeName, finalizedHead, finalizedHeight: await api.rpc.chain.getHeader(finalizedHead).then((header) => header.number) };
|
|
})
|
|
);
|
|
|
|
// select the node with the highest finalized height
|
|
const highestFinalizedHeight = finalizedHeads.reduce(
|
|
(acc, { nodeName, finalizedHeight }) =>
|
|
finalizedHeight >= acc.finalizedHeight
|
|
? { nodeName, finalizedHeight }
|
|
: acc,
|
|
{ nodeName: 'validator', finalizedHeight: 0 }
|
|
);
|
|
|
|
// get all block hashes up until the highest finalized height
|
|
const blockHashes = [];
|
|
for (let blockNumber = 0; blockNumber <= highestFinalizedHeight.finalizedHeight; blockNumber++) {
|
|
const blockHash = await apis[highestFinalizedHeight.nodeName].rpc.chain.getBlockHash(blockNumber);
|
|
blockHashes.push(blockHash);
|
|
}
|
|
|
|
// verify that height(finalized_head) is at least as high as the substrate_beefy_best_block test already verified
|
|
return finalizedHeads.every(({ finalizedHead, finalizedHeight }) =>
|
|
finalizedHeight >= 21 && finalizedHead.toHex() === blockHashes[finalizedHeight].toHex()
|
|
)
|
|
}
|
|
|
|
module.exports = { run };
|