fix(safe): skip dead-nonce pending txs in alerting#235
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
executed=falseforever and will never run.ALL_SAFE_ADDRESSES), each of those stale txs previously triggered an AI explanation + Telegram alert, flooding the channel with months-old history.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: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
nonces-v3GH Actions cache and confirm the nextMonitor Safe Multisigsrun posts at most 1-2 alerts per safe, not a backlog🤖 Generated with Claude Code