bookkeeper: don't flood logs if we have many channelmoves all at once.
What changed, and why it matters
This commit is a performance improvement, not a security fix. It changes the bookkeeper plugin so that when it processes a very large number of channel movements at once, it only writes detailed debug logs for the first and last one instead of every single one. This reduces log flooding and speeds up the first bookkeeper command after an upgrade. There is no indication this change addresses a vulnerability or security flaw.
No security action required. Treat as a normal performance improvement. If reviewing for release notes, note it as a user-facing performance improvement for large bookkeeper imports.
Security signals we found
No security-relevant signals present in commit message or diff
Performance optimization only: reduces debug log volume
No changes to authorization, validation, cryptography, or memory safety
No incident or vulnerability disclosure referenced
Evidence from the diff
The patch modifies plugins/bkpr/bookkeeper.c to add a bool log parameter to parse_and_log_channel_move(). In listchannelmoves_done(), when there are more than two channelmoves, it logs a single debug message with the count and then calls parse_and_log_channel_move() with log=true only for the first and last elements. The debug logging inside parse_and_log_channel_move() is now conditional. This is purely a logging volume/performance optimization.
Changed components
plugins/bkpr/bookkeeper.cbookkeeper plugin debug logginglistchannelmoves_done()parse_and_log_channel_move()Inspect captured patch +18 / −8
diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c
index e5e2e82f..bba69efb 100644
--- a/plugins/bkpr/bookkeeper.c
+++ b/plugins/bkpr/bookkeeper.c
@@ -87,7 +87,8 @@ static void
parse_and_log_channel_move(struct command *cmd,
const char *buf,
const jsmntok_t *channelmove,
- struct refresh_info *rinfo);
+ struct refresh_info *rinfo,
+ bool log);
static struct command_result *datastore_done(struct command *cmd,
const char *method,
@@ -120,8 +121,15 @@ static struct command_result *listchannelmoves_done(struct command *cmd,
be64 be_index;
moves = json_get_member(buf, result, "channelmoves");
+ if (moves->size > 2) {
+ plugin_log(cmd->plugin, LOG_DBG,
+ "%u channelmoves, only logging first and last",
+ moves->size);
+ }
+
json_for_each_arr(i, t, moves)
- parse_and_log_channel_move(cmd, buf, t, rinfo);
+ parse_and_log_channel_move(cmd, buf, t, rinfo,
+ i == 0 || i == moves->size - 1);
be_index = cpu_to_be64(bkpr->channelmoves_index);
jsonrpc_set_datastore_binary(cmd, "bookkeeper/channelmoves_index",
@@ -1277,7 +1285,8 @@ static void
parse_and_log_channel_move(struct command *cmd,
const char *buf,
const jsmntok_t *channelmove,
- struct refresh_info *rinfo)
+ struct refresh_info *rinfo,
+ bool log)
{
struct channel_event *e = tal(cmd, struct channel_event);
struct account *acct;
@@ -1324,11 +1333,12 @@ parse_and_log_channel_move(struct command *cmd,
err = tal_free(err);
}
- plugin_log(cmd->plugin, LOG_DBG, "coin_move 2 (%s) %s -%s %s %"PRIu64,
- e->tag,
- fmt_amount_msat(tmpctx, e->credit),
- fmt_amount_msat(tmpctx, e->debit),
- CHANNEL_MOVE, e->timestamp);
+ if (log)
+ plugin_log(cmd->plugin, LOG_DBG, "coin_move 2 (%s) %s -%s %s %"PRIu64,
+ e->tag,
+ fmt_amount_msat(tmpctx, e->credit),
+ fmt_amount_msat(tmpctx, e->debit),
+ CHANNEL_MOVE, e->timestamp);
/* Go find the account for this event */
acct = find_account(bkpr, acct_name);
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.