igneum/tools/ci/override-json-check.sh

29 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# The duplicate-field class (6 October 2026): two merges each appended the proving v1 block to
# infra/fast-time/override-60x.json, so the file carried `proving_v1_activation_daa` twice; the node refuses such a file
# ("duplicate field") and the class-v3 and class-v4 fast-time gates could not start a node from it, while the fork's
# every-field test skips when the file is not beside it (it is not on the PCs). Rule: every override params file the
# harnesses and the node read parses as JSON with no duplicate key. This check fails CI when one does not.
set -euo pipefail
cd "$(dirname "$0")/../.."
fail=0
while IFS= read -r f; do
if ! python3 - "$f" <<'PY'
import json, sys, collections
def pairs(p):
c = collections.Counter(k for k, _ in p)
dups = sorted(k for k, n in c.items() if n > 1)
if dups:
raise SystemExit(f"duplicate key(s) {dups}")
return dict(p)
try:
json.load(open(sys.argv[1]), object_pairs_hook=pairs)
except SystemExit as e:
print(f"override-json: {sys.argv[1]}: {e}"); sys.exit(1)
except Exception as e:
print(f"override-json: {sys.argv[1]}: does not parse: {e}"); sys.exit(1)
PY
then fail=1; fi
done < <(git ls-files 'infra/fast-time/*.json' 'tools/finality-attacks/redteam/*.json' 'infra/**/override*.json' | sort -u)
[ "$fail" = 0 ] && echo "override-json: every override params file parses with no duplicate key"
exit $fail