Skip to content

feat: Emit Events for Monitoring State Resets#299

Merged
hman38705 merged 2 commits intosolutions-plug:mainfrom
Macnelson9:events
Mar 26, 2026
Merged

feat: Emit Events for Monitoring State Resets#299
hman38705 merged 2 commits intosolutions-plug:mainfrom
Macnelson9:events

Conversation

@Macnelson9
Copy link
Contributor

📋 Description

Adds on-chain transparency for monitoring resets by emitting a detailed reset event whenever monitoring counters are cleared. The event includes both historical counter values and the resetter identity for auditability.

🎯 Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test addition/update
  • CI/CD update

🔗 Related Issues

Closes #152

📝 Changes Made

  • Added emit_monitoring_state_reset event helper in events.rs.
  • Updated reset_monitoring to capture previous monitoring counters, clear state, and emit the new detailed event in monitoring.rs.
  • Updated track_error to persist LastObservation timestamp for accurate reset reporting in monitoring.rs.
  • Added monitoring unit tests for state reset correctness and event emission in monitoring.rs.

🧪 Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests passing locally
  • Test coverage maintained/improved

Manual Testing

  • Tested on testnet
  • Tested locally
  • Edge cases tested

Test Results:
Added tests verify:

  • Previous monitoring values are captured before reset.
  • ErrorCount and LastObservation are cleared after reset.
  • mon_reset event is emitted and contains historical counter values.

File-level diagnostics show no errors in modified files.

📸 Screenshots (if applicable)

Not applicable (no UI changes).

✅ Checklist

Code Quality

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex code
  • No unnecessary console.log or debug code
  • No commented-out code

Documentation

  • Documentation updated (if needed)
  • API documentation updated (if applicable)
  • CHANGELOG.md updated
  • README updated (if needed)

Testing & Quality

  • All tests pass (cargo test)
  • No linting errors (cargo clippy)
  • Code formatted (cargo fmt)
  • No new warnings introduced
  • Gas benchmarks run (if applicable)

Security

  • Security implications considered
  • No sensitive data exposed
  • Input validation added
  • Authorization checks in place

Git

  • Branch is up to date with main
  • Commits are atomic and well-described
  • Commit messages follow convention
  • No merge conflicts

🔍 Reviewer Notes

Please focus review on:

  • Event schema: topics/data for mon_reset and indexer compatibility.
  • Correctness of historical values captured before clearing.
  • Resetter identity source used in emitted event.

📊 Performance Impact

  • No performance impact
  • Performance improved
  • Performance impact acceptable (explain below)

Details:
Only lightweight storage reads/writes and one additional event emission were introduced on reset.

🚀 Deployment Notes

No migration or config changes required.
Safe to deploy as a backward-compatible observability enhancement.

📚 Additional Context

Primary files changed:

  • monitoring.rs
  • events.rs

Suggested commit message:
feat: emit on-chain events when monitoring counters are reset


By submitting this PR, I confirm that:

  • I have read and followed the CONTRIBUTING.md guidelines
  • My code follows the project's coding standards
  • I have tested my changes thoroughly
  • I am ready for code review

@drips-wave
Copy link

drips-wave bot commented Mar 26, 2026

@Macnelson9 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! 🚀

Learn more about application limits

@hman38705 hman38705 merged commit 9210150 into solutions-plug:main Mar 26, 2026
1 of 12 checks passed
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.

Emit Events for Monitoring State Resets

2 participants