diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-03 18:31:32 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-03 18:31:32 +0000 |
| commit | e63fcfff1ae24dfff8aca6581badb51a06ddae28 (patch) | |
| tree | dad676d3d25661ff03c97ef5f11fb59c6d392d7c /scripts | |
| parent | b441687b5344454bea16384fe1280e470964faaa (diff) | |
payout: fail review when a money line lands on collapsing LogPrint
scripts/check-money-log-lines.sh flattens each LogPrint call in
src/rpc.cpp and fails if a money-moving phrase appears in a plain
LogPrint call. A new line that reports money moving needs
LogPrintAlways and one more phrase in the list.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-money-log-lines.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/check-money-log-lines.sh b/scripts/check-money-log-lines.sh new file mode 100755 index 0000000..c9f348b --- /dev/null +++ b/scripts/check-money-log-lines.sh | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # Money-moving payout lines must print every time they fire: they are the | ||
| 3 | # audit trail for obligations created, moved and destroyed, and LogPrint's | ||
| 4 | # burst collapse can stand one line in for any number of events inside one | ||
| 5 | # 3-second window (issue #3: 100 voids totalling 4,950 BTF read as one | ||
| 6 | # 49.49 BTF line). Every line carrying one of the phrases below must use | ||
| 7 | # LogPrintAlways, which keeps the category gate but skips the collapse. | ||
| 8 | # | ||
| 9 | # Adding a payout line that reports money moving? Use LogPrintAlways and | ||
| 10 | # add its phrase here. A phrase found in a plain LogPrint call fails this | ||
| 11 | # check; anything else passes, so a non-money line is never held up by it. | ||
| 12 | set -euo pipefail | ||
| 13 | cd "$(dirname "$0")/.." | ||
| 14 | |||
| 15 | phrases='was orphaned -- voiding|orphaned while queued|\[payout\] paid %s to %s|FAILED to pay|writing off|SKIPPED bad address' | ||
| 16 | |||
| 17 | # Call sites span several lines; flatten each call to a single line first so | ||
| 18 | # the phrase and the macro it belongs to are matched together. Only a line | ||
| 19 | # whose first token is the macro starts a call, so comments mentioning | ||
| 20 | # LogPrint are never mistaken for one. | ||
| 21 | bad=$(awk ' | ||
| 22 | /^[ \t]*LogPrint(Always)?[(]/ { | ||
| 23 | if (collecting) print buf | ||
| 24 | buf = $0; collecting = 1; next | ||
| 25 | } | ||
| 26 | collecting { | ||
| 27 | buf = buf $0 | ||
| 28 | if (/;[ \t]*$/) { print buf; collecting = 0 } | ||
| 29 | } | ||
| 30 | END { if (collecting) print buf } | ||
| 31 | ' src/rpc.cpp | grep -E '^[[:space:]]*LogPrint[(]' | grep -E "$phrases" || true) | ||
| 32 | |||
| 33 | if [ -n "$bad" ]; then | ||
| 34 | echo "error: money-moving payout line(s) on collapsing LogPrint:" >&2 | ||
| 35 | echo "$bad" >&2 | ||
| 36 | exit 1 | ||
| 37 | fi | ||
| 38 | echo "ok: every money-moving payout line in src/rpc.cpp uses LogPrintAlways" | ||