-
Notifications
You must be signed in to change notification settings - Fork 133
[consensus/marshal] specific reporters type to send to multiple consumers #2202
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
[consensus/marshal] specific reporters type to send to multiple consumers #2202
Conversation
bdd6e13 to
2ee3517
Compare
2ee3517 to
92a7a18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Mind adding a short test for 2 & 3 reporters (the latter nesting the new struct: Reporters<A, Reporter, Reporters<A, Reporter, Reporter>>)?
Added some very simple tests checking receipt of acks and blocks. |
consensus/src/marshal/actor.rs
Outdated
| let (ack_tx, ack_rx) = oneshot::channel(); | ||
| application.report(Update::Block(block, ack_tx)).await; | ||
| self.pending_ack.replace(PendingAck { | ||
| let application = application.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note - We already have the assumption that application is a cheap clone (either a mailbox or a shallow struct for Marshaled.) This should be low-cost.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #2202 +/- ##
==========================================
- Coverage 92.22% 92.21% -0.01%
==========================================
Files 315 314 -1
Lines 86561 86557 -4
==========================================
- Hits 79827 79822 -5
- Misses 6734 6735 +1
... and 30 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
| /// | ||
| /// Use this type if to send marshal [`Update`] to more than one consumer. | ||
| /// | ||
| /// The reason this exists in addition [`crate::reporter::Reporters`], is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered making a new type for this to avoid a custom reporter but it becomes very difficult to actually know when it is safe to "listen" on this type (as one actor may finish before the "sender" is cloned).
It seems we need to be explicit in the number of recipients to ensure we properly wait for everything.
| } | ||
| } | ||
|
|
||
| #[test_async] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot about this lol...fml
consensus/src/marshal/actor.rs
Outdated
| receiver: ack_rx, | ||
| receiver: async move { | ||
| application | ||
| .clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second clone is unnecessary (pushed a fix)
| receiver: { | ||
| let mut application = application.clone(); | ||
| async move { | ||
| application.report(Update::Block(block, ack_tx)).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we call report in async here but not for tip. It implies a very specific function of report() that to me indicates of a deeper issue.
This patch provides a marshal-specific
Reporterstype to allow sending theUpdate<B>enum to more than one consumer.#2144 enshrined finalizer await by including a oneshot channel in the
marshal::Update<B>enum, which is a good change. However, it broke theconsensus::Reporter for Reporters<R1, R2>impl by requiring that theActivity: Clone.monorepo/consensus/src/reporter.rs
Lines 31 to 36 in fe0dcf4
This was likely not caught because no commonware example uses
consensus::Reportersin the marshal agent.