Repository navigation
fix: include network cursor ID and rule identity in alert_id (#252) - #352
Merged
Merged
Conversation
|
@blizzj Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Fixes #252
Problem
alert_id()only hashedcontract_id,tx_hashandrule_triggered, contradicting the README/AlertPayload docs which say it derives from(network, contract_id, tx_hash, rule_type, rule_triggered). Two rules with identical labels on one contract (e.g. twoLargeTransfer(>=100XLM)rules routed to different webhooks) produced the same ID and one was silently deduplicated away by receivers.Changes
alert_id()now hashes the network cursor ID (Network::cursor_id, so custom networkscustom@https://…are distinguished),rule_type(previously omitted),rule_triggeredand the rule's index within the contract'sruleslist.EvalContextgains anetwork_id: Stringfield;check_no_activity()gains arule_index: usizeparameter soNoActivityincident/recovery alerts and cooldown summaries use the same scheme.README.md,docs/alert-rules.md,docs/configuration.md,AlertPayloaddoc comment) to describe the exact hash inputs.CHANGELOG.mdnotes the breaking ID change: receivers persistingalert_idfor dedup will see new values after upgrading.identical_rules_on_one_contract_do_not_collideasserts two identicalLargeTransferrules fire with distinct IDs, and that the same rule on a different network also differs. Existing determinism test extended to cover network and rule-index sensitivity.Notes
alert_iddedup entries will not match post-upgrade alerts (values change once).rule_indexis the position in the contract'sruleslist; reordering or inserting rules above an existing rule changes its alert IDs.Test plan
cargo test -p txwatch-rules(unit + collision tests)cargo test -p txwatch-poller(integration, updatedEvalContextliterals)cargo bench -p txwatch-rules --bench evaluatestill compilescloses #252
closes #257
closes #258
closes #261