tools/verify-proof.mjs: the chain comes from --chain, else from the chain the envelope's notarization declares (when known), else 2800. An envelope notarized on the testnet 28001 and checked without --chain used to be looked up on 2800 and reported INVALID. The notary stays the known contract of that chain (or --notary); an address written in the envelope is never trusted as the notary.

This commit is contained in:
Aere Network 2026-09-27 20:48:58 +03:00
parent 93f9d5839b
commit c239cbd750

View File

@ -219,9 +219,13 @@ const args = process.argv.slice(2);
const opt = (n) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : null; }; const opt = (n) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : null; };
const file = args.find((a, i) => !a.startsWith('--') && !(i > 0 && args[i - 1].startsWith('--') && args[i - 1] !== '--json')); const file = args.find((a, i) => !a.startsWith('--') && !(i > 0 && args[i - 1].startsWith('--') && args[i - 1] !== '--json'));
if (!file) { console.error('usage: node verify-proof.mjs <envelope.json> [--rpc <url>] [--chain 2800|28001] [--notary <address>] [--manifests <url|dir>] [--json]'); stop(2); } if (!file) { console.error('usage: node verify-proof.mjs <envelope.json> [--rpc <url>] [--chain 2800|28001] [--notary <address>] [--manifests <url|dir>] [--json]'); stop(2); }
const chain = Number(opt('--chain') || 2800);
if (!NOTARY[chain]) { console.error('unknown chain ' + chain + ' (2800 or 28001)'); stop(2); }
let env; try { env = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (e) { console.error('the envelope cannot be read: ' + e.message); stop(2); } let env; try { env = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (e) { console.error('the envelope cannot be read: ' + e.message); stop(2); }
// The chain: --chain if given; otherwise the chain the envelope's notarization declares, when it is a known chain; otherwise 2800.
// (Before 2026-09-27 an envelope notarized on 28001, checked without --chain, was looked up on 2800 and reported INVALID.) The
// notary stays the known contract of that chain (or --notary): an address written in the envelope is never trusted as the notary.
const declared = env && env.notarization && Number(env.notarization.chainId);
const chain = Number(opt('--chain') || (declared && NOTARY[declared] ? declared : 2800));
if (!NOTARY[chain]) { console.error('unknown chain ' + chain + ' (2800 or 28001)'); stop(2); }
const o = { chain, rpcGiven: !!opt('--rpc'), rpc: opt('--rpc') || RPC_DEFAULT[chain], notary: (opt('--notary') || NOTARY[chain]).toLowerCase(), const o = { chain, rpcGiven: !!opt('--rpc'), rpc: opt('--rpc') || RPC_DEFAULT[chain], notary: (opt('--notary') || NOTARY[chain]).toLowerCase(),
manifests: opt('--manifests') || MANIFESTS_DEFAULT[chain] }; manifests: opt('--manifests') || MANIFESTS_DEFAULT[chain] };
const l = local(env); const l = local(env);