From e63fcfff1ae24dfff8aca6581badb51a06ddae28 Mon Sep 17 00:00:00 2001 From: bitflash-maintainer Date: Thu, 3 Sep 2026 18:31:32 +0000 Subject: 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. --- scripts/check-money-log-lines.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/check-money-log-lines.sh (limited to 'scripts') 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 @@ +#!/usr/bin/env bash +# Money-moving payout lines must print every time they fire: they are the +# audit trail for obligations created, moved and destroyed, and LogPrint's +# burst collapse can stand one line in for any number of events inside one +# 3-second window (issue #3: 100 voids totalling 4,950 BTF read as one +# 49.49 BTF line). Every line carrying one of the phrases below must use +# LogPrintAlways, which keeps the category gate but skips the collapse. +# +# Adding a payout line that reports money moving? Use LogPrintAlways and +# add its phrase here. A phrase found in a plain LogPrint call fails this +# check; anything else passes, so a non-money line is never held up by it. +set -euo pipefail +cd "$(dirname "$0")/.." + +phrases='was orphaned -- voiding|orphaned while queued|\[payout\] paid %s to %s|FAILED to pay|writing off|SKIPPED bad address' + +# Call sites span several lines; flatten each call to a single line first so +# the phrase and the macro it belongs to are matched together. Only a line +# whose first token is the macro starts a call, so comments mentioning +# LogPrint are never mistaken for one. +bad=$(awk ' + /^[ \t]*LogPrint(Always)?[(]/ { + if (collecting) print buf + buf = $0; collecting = 1; next + } + collecting { + buf = buf $0 + if (/;[ \t]*$/) { print buf; collecting = 0 } + } + END { if (collecting) print buf } +' src/rpc.cpp | grep -E '^[[:space:]]*LogPrint[(]' | grep -E "$phrases" || true) + +if [ -n "$bad" ]; then + echo "error: money-moving payout line(s) on collapsing LogPrint:" >&2 + echo "$bad" >&2 + exit 1 +fi +echo "ok: every money-moving payout line in src/rpc.cpp uses LogPrintAlways" -- cgit v1.2.3