Skip to content

Conversation

@SuperFluffy
Copy link
Contributor

This patch provides a marshal-specific Reporters type to allow sending the Update<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 the consensus::Reporter for Reporters<R1, R2> impl by requiring that the Activity: Clone.

impl<A, R1, R2> Reporter for Reporters<A, R1, R2>
where
A: Clone + Send + 'static,
R1: Reporter<Activity = A>,
R2: Reporter<Activity = A>,
{
.

This was likely not caught because no commonware example uses consensus::Reporters in the marshal agent.

@SuperFluffy SuperFluffy force-pushed the janis/clone-marshal-reporter branch from bdd6e13 to 2ee3517 Compare November 11, 2025 14:07
@SuperFluffy SuperFluffy force-pushed the janis/clone-marshal-reporter branch from 2ee3517 to 92a7a18 Compare November 11, 2025 14:11
@SuperFluffy SuperFluffy changed the title [consensus/marshal] define marshal-specific reporters type [consensus/marshal] specific reporters type to send to multiple consumers Nov 11, 2025
Copy link
Collaborator

@clabby clabby left a 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>>)?

@SuperFluffy
Copy link
Contributor Author

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.

let (ack_tx, ack_rx) = oneshot::channel();
application.report(Update::Block(block, ack_tx)).await;
self.pending_ack.replace(PendingAck {
let application = application.clone();
Copy link
Collaborator

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
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 93.29897% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.21%. Comparing base (fe0dcf4) to head (bd925c9).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
consensus/src/marshal/mod.rs 91.72% 12 Missing ⚠️
consensus/src/marshal/actor.rs 97.95% 1 Missing ⚠️
@@            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     
Files with missing lines Coverage Δ
consensus/src/marshal/actor.rs 87.98% <97.95%> (+0.46%) ⬆️
consensus/src/marshal/mod.rs 97.82% <91.72%> (-1.39%) ⬇️

... and 30 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe0dcf4...bd925c9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

///
/// Use this type if to send marshal [`Update`] to more than one consumer.
///
/// The reason this exists in addition [`crate::reporter::Reporters`], is that
Copy link
Contributor

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]
Copy link
Contributor

@patrick-ogrady patrick-ogrady Nov 13, 2025

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

receiver: ack_rx,
receiver: async move {
application
.clone()
Copy link
Contributor

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;
Copy link
Contributor

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.

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.

3 participants