pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
63 stars 33 forks source link

[IBC] Prevent Potential Overflow in Event Channel of Bus #878

Closed innocent-saeed36 closed 1 year ago

innocent-saeed36 commented 1 year ago

Problem:

In the current bus.go file, the PublishEventToBus() function pushes events into the channel without checking if the channel is already at capacity. If the rate of incoming events exceeds the channel's capacity to process them, it could potentially lead to deadlock or unhandled panic.

Solution:

The solution involves adding a check in the PublishEventToBus() function to ensure that the event channel isn't already at capacity before attempting to publish an event. If the channel is at capacity, a warning message is logged, and the event is dropped.

This change helps ensure the stability of the application by preventing potential channel overflow issues. It effectively guards against scenarios where a rapid influx of events could cause the application to lock up or crash.

bryanchriswhite commented 1 year ago

@innocent-saeed36 would you mind writing a test that fails on main but passes on this branch?