Description
Summary
In the constructor functions such as new_relay_context_with_batch
, a batch message worker is spawned for each relay context created. However this means that messages from two relay context couple in a bi-relay context cannot be batched together by the same batch worker.
The spawning of batch message worker should instead be done in the constructor for a bi-relay context, so that they can be shared between the two relay contexts.
Details
For the case of FullCosmosRelay
, the sharing can be done by creating one sender/receiver pair for the batch worker, then set it as the source channel for one relay context, and the destination channel for the other relay context.
A better way to manage the construction and spawning of the batch message worker can be done in informalsystems/hermes#3083, to define a bi-relay builder component that manage the sharing and spawning of the batch message workers.