Skip to content

fix(safe): skip dead-nonce pending txs in alerting#235

Merged
spalen0 merged 1 commit into
mainfrom
fix/safe-filter-dead-pending-nonces
May 23, 2026
Merged

fix(safe): skip dead-nonce pending txs in alerting#235
spalen0 merged 1 commit into
mainfrom
fix/safe-filter-dead-pending-nonces

Conversation

@spalen0
Copy link
Copy Markdown
Collaborator

@spalen0 spalen0 commented May 23, 2026

Summary

  • The Safe transaction service returns every proposal that never executed — including competing proposals whose nonce slot was already consumed by a different executed tx. These stay executed=false forever and will never run.
  • On a fresh cache (first run, GH Actions cache eviction, new safe added to ALL_SAFE_ADDRESSES), each of those stale txs previously triggered an AI explanation + Telegram alert, flooding the channel with months-old history.
  • The fix fetches the safe's current onchain nonce and filters pending where nonce > max(last_cached_nonce, current_nonce - 1). If the safe-info call fails we fall back to the existing cache-based filter so the monitor never breaks.

Live verification

Tested against brain.ychad.eth (0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7) with an empty cache:

Pending nonces returned by API After filter
Before 3251, 3250, 3191, 3191, 3183, 3173, 3152, 3120, 3114, 3084 (10 alerts)
After same 10 3251, 3250 (2 alerts)

Current safe nonce is 3250, so only those two are live; the other 8 are stale rejections / replacements from Feb–Apr 2026.

API note

The v2 endpoint /safes/{address}/ returns 404 — only v1 exposes safe metadata. The multisig-transactions endpoint stays on v2.

Test plan

  • Merge after fix(safe): escape Markdown in protocol and additional_info #234 (telegram markdown fix) so the YEARN_MS alert delivery is working
  • Manually evict the nonces-v3 GH Actions cache and confirm the next Monitor Safe Multisigs run posts at most 1-2 alerts per safe, not a backlog
  • Confirm subsequent runs continue to alert on genuinely new pending txs

🤖 Generated with Claude Code

The Safe transaction service returns every proposal that never executed —
including competing proposals whose nonce slot was already consumed by a
different tx that did execute. Those remain ``executed=false`` forever and
will never run. On a fresh cache (first run, GH Actions cache eviction, new
safe added to the watchlist) they previously triggered an AI explanation
and Telegram alert for each one, flooding the channel with stale history.

Now we fetch the safe's current onchain nonce from the v1 safe-info
endpoint and use ``max(last_cached_nonce, current_nonce - 1)`` as the
filter baseline. If the safe-info call fails we fall back to the existing
cache-based filter, so the monitor never breaks on transient API errors.

Smoke-tested against brain.ychad.eth (current nonce 3250): the API
returns 10 non-executed pending txs but only 2 (nonces 3250 and 3251) are
live and now pass the filter; the other 8 (nonces 3084-3191) are stale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@spalen0 spalen0 marked this pull request as ready for review May 23, 2026 12:36
@spalen0 spalen0 merged commit b2902d9 into main May 23, 2026
2 checks passed
@spalen0 spalen0 deleted the fix/safe-filter-dead-pending-nonces branch May 23, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant