dn3-split-read: --tags names the two tags to look for (IGNH,IGNW by default; IGNS,IGNP for the Devnet 3 pair's hour on the earlier daemons)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
31cec57eb6
commit
c5983ce966
1 changed files with 7 additions and 4 deletions
|
|
@ -32,6 +32,9 @@ const TO_MS = opt('--to-ms', null) == null ? null : +opt('--to-ms');
|
|||
const inWindow = (b) => { const daa = Number(b.header.daaScore), ts = Number(b.header.timestamp); if (FROM_MS != null) return ts >= FROM_MS && (TO_MS == null || ts <= TO_MS); return daa >= FROM && daa <= toDaa; };
|
||||
const pastWindow = (b) => { const daa = Number(b.header.daaScore), ts = Number(b.header.timestamp); if (FROM_MS != null) return TO_MS != null && ts > TO_MS + 60_000; return daa > toDaa; };
|
||||
const OUT = opt('--out', null);
|
||||
// the two tags to look for: IGNH and IGNW since pool-tags-node 7455b8d5; `--tags IGNS,IGNP` reads a chain mined by the
|
||||
// earlier daemons (the Devnet 3 pair's hour of 7 October 2026, 19:33Z to 20:33Z, ran on the old tags)
|
||||
const [TAG_CHAIN, TAG_SPLIT] = opt('--tags', 'IGNH,IGNW').split(',');
|
||||
const log = (...a) => console.log(new Date().toISOString().slice(11, 23), ...a);
|
||||
|
||||
let rpcId = 0;
|
||||
|
|
@ -43,7 +46,7 @@ const hexToBytes = (h) => Buffer.from(h.replace(/^0x/, ''), 'hex');
|
|||
const hasTag = (payloadHex, tag) => hexToBytes(payloadHex).includes(Buffer.from(tag, 'ascii'));
|
||||
// the split's entries, from IGNW || 4 hex count || count x (40 hex address || 8 hex weight) (consensus/core/src/evm.rs)
|
||||
function splitOf(payloadHex) {
|
||||
const b = hexToBytes(payloadHex); const i = b.indexOf(Buffer.from('IGNW', 'ascii')); if (i < 0) return null;
|
||||
const b = hexToBytes(payloadHex); const i = b.indexOf(Buffer.from(TAG_SPLIT, 'ascii')); if (i < 0) return null;
|
||||
const body = b.subarray(i + 4).toString('latin1'); const n = parseInt(body.slice(0, 4), 16); if (!(n > 0)) return null;
|
||||
const out = []; for (let k = 0; k < n; k++) { const e = body.slice(4 + k * 48, 4 + k * 48 + 48); if (e.length < 48) return null; out.push({ address: '0x' + e.slice(0, 40), weight: parseInt(e.slice(40, 48), 16) }); }
|
||||
return out;
|
||||
|
|
@ -80,7 +83,7 @@ for (const cb of chainBlocks) {
|
|||
const cbTx = (b.transactions || [])[0];
|
||||
const payload = cbTx?.payload || '';
|
||||
const split = splitOf(payload);
|
||||
blocks.push({ hash: h, daa: Number(b.header.daaScore), ts: Number(b.header.timestamp), chain: b === cb, ignh: hasTag(payload, 'IGNH'), ignw: !!split, igna: hasTag(payload, 'IGNA'), split_entries: split ? split.length : 0, vote_key_hash: b.header.voteKeyHash || b.header.vote_key_hash });
|
||||
blocks.push({ hash: h, daa: Number(b.header.daaScore), ts: Number(b.header.timestamp), chain: b === cb, ignh: hasTag(payload, TAG_CHAIN), ignw: !!split, igna: hasTag(payload, 'IGNA'), split_entries: split ? split.length : 0, vote_key_hash: b.header.voteKeyHash || b.header.vote_key_hash });
|
||||
}
|
||||
}
|
||||
const first = chainBlocks[0], last = chainBlocks[chainBlocks.length - 1];
|
||||
|
|
@ -88,7 +91,7 @@ const iso = (ms) => new Date(Number(ms)).toISOString();
|
|||
const withBoth = blocks.filter(b => b.ignh && b.ignw);
|
||||
const onlyOne = blocks.filter(b => b.ignh !== b.ignw);
|
||||
log(`window: ${chainBlocks.length} chain blocks, ${blocks.length} blue blocks; first chain block DAA ${first.header.daaScore} ${String(first.verboseData?.hash || first.header.hash).slice(0, 16)} at ${iso(first.header.timestamp)}; last DAA ${last.header.daaScore} ${String(last.verboseData?.hash || last.header.hash).slice(0, 16)} at ${iso(last.header.timestamp)}`);
|
||||
log(`blocks carrying IGNH and IGNW: ${withBoth.length} (${withBoth.filter(b => b.chain).length} chain blocks); one tag without the other: ${onlyOne.length}; distinct vote keys among the split blocks: ${new Set(withBoth.map(b => b.vote_key_hash)).size}; split entries min/max: ${withBoth.length ? Math.min(...withBoth.map(b => b.split_entries)) : 0}/${withBoth.length ? Math.max(...withBoth.map(b => b.split_entries)) : 0}`);
|
||||
log(`blocks carrying ${TAG_CHAIN} and ${TAG_SPLIT}: ${withBoth.length} (${withBoth.filter(b => b.chain).length} chain blocks); one tag without the other: ${onlyOne.length}; distinct vote keys among the split blocks: ${new Set(withBoth.map(b => b.vote_key_hash)).size}; split entries min/max: ${withBoth.length ? Math.min(...withBoth.map(b => b.split_entries)) : 0}/${withBoth.length ? Math.max(...withBoth.map(b => b.split_entries)) : 0}`);
|
||||
// exec roots across the nodes at one executed height
|
||||
const nodes = [{ name: 'hub', ws: HUB, exec: HUB_EXEC }, ...NODES.map((n, i) => ({ name: `node${i + 1}`, ...n }))];
|
||||
const statuses = [];
|
||||
|
|
@ -102,7 +105,7 @@ for (const s of statuses) {
|
|||
const distinctRoots = new Set(roots.filter(r => r.stateRoot).map(r => r.stateRoot));
|
||||
log(`exec: ${statuses.map(s => `${s.name} tip ${s.tip ?? 'ERR'}`).join(', ')}; state root at executed block ${lowest} on ${roots.filter(r => r.stateRoot).length} nodes: ${distinctRoots.size === 1 ? 'AGREE ' + [...distinctRoots][0].slice(0, 18) : 'DISAGREE ' + roots.map(r => `${r.name}=${String(r.stateRoot).slice(0, 12)}`).join(' ')}`);
|
||||
const result = {
|
||||
read_at: new Date().toISOString(), hub: HUB, network: info.networkName || info.network, from_daa: FROM, to_daa: toDaa, from_ms: FROM_MS, to_ms: TO_MS,
|
||||
read_at: new Date().toISOString(), hub: HUB, network: info.networkName || info.network, tags: [TAG_CHAIN, TAG_SPLIT], from_daa: FROM, to_daa: toDaa, from_ms: FROM_MS, to_ms: TO_MS,
|
||||
first_chain_block: { number_daa: Number(first.header.daaScore), blue_score: Number(first.header.blueScore), hash: first.verboseData?.hash || first.header.hash, time: iso(first.header.timestamp) },
|
||||
last_chain_block: { number_daa: Number(last.header.daaScore), blue_score: Number(last.header.blueScore), hash: last.verboseData?.hash || last.header.hash, time: iso(last.header.timestamp) },
|
||||
activation_daa_if_set_now: Number(last.header.daaScore) + 7200,
|
||||
|
|
|
|||
Loading…
Reference in a new issue