Skip to content

fix(pubsub): enhance message validation and routing robustness #3223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pranavkonde
Copy link

Description

This PR improves the robustness and monitoring capabilities of PubSub message validation and routing. It addresses potential issues with message handling, adds rate limiting, and introduces comprehensive metrics for better observability.

Changes

Message Validation Improvements

  • Added basic message validation checks (topic and data presence)
  • Implemented message size limits (1MB max)
  • Enhanced signature validation with better error reporting
  • Added validation timing measurements
  • Added detailed validation metrics

Message Routing Enhancements

  • Implemented per-peer rate limiting (100 messages per minute)
  • Added automatic cleanup of rate limiting state
  • Improved error handling with detailed logging
  • Added processing timing measurements

New Metrics

Added comprehensive metrics for monitoring:

  • Message validation metrics
    • libp2p_pubsub_message_validation_total
    • libp2p_pubsub_message_validation_failed_signature
    • libp2p_pubsub_message_validation_failed_topic
    • libp2p_pubsub_message_validation_success
    • libp2p_pubsub_message_validation_time (histogram)
  • Message processing metrics
    • libp2p_pubsub_message_processed_total
    • libp2p_pubsub_rate_limit_exceeded
    • libp2p_pubsub_message_dropped_invalid
    • libp2p_pubsub_message_delivered
    • libp2p_pubsub_message_processing_time (histogram)
    • libp2p_pubsub_message_processing_failed

@pranavkonde pranavkonde requested a review from a team as a code owner July 13, 2025 14:53
@achingbrain
Copy link
Member

Thank you for opening this PR.

Is this in response to an issue you’ve seen in a deployed application or are you just trying to make general improvements to the codebase?

@pranavkonde
Copy link
Author

Thank you for opening this PR.

Is this in response to an issue you’ve seen in a deployed application or are you just trying to make general improvements to the codebase?

Thank you for the quick response!
This PR is based on general improvements to make the codebase more robust.

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.

2 participants