-
Notifications
You must be signed in to change notification settings - Fork 134
[utils] Introduce Acknowledgement
#2216
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
Conversation
Deploying monorepo with
|
| Latest commit: |
3897706
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://464645fc.monorepo-eu0.pages.dev |
| Branch Preview URL: | https://acknowledgement.monorepo-eu0.pages.dev |
| last_processed_height: u64, | ||
| // Pending application acknowledgement, if any | ||
| pending_ack: OptionFuture<PendingAck<B>>, | ||
| pending_ack: OptionFuture<PendingAck<B, A>>, |
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 originally considered migrating to channels::tracked (so we could enqueue multiple blocks at once) but opted to take a simpler approach at first to unblock.
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.
Pull Request Overview
This PR introduces a new Acknowledgement trait as a first-party abstraction for handling asynchronous task completion acknowledgements. The implementation replaces the previous oneshot::channel() approach with a more flexible and maintainable acknowledgement system.
Key changes:
- Added a new
Acknowledgementtrait with anExact<N>implementation that supports waiting for exactly N acknowledgements - Replaced
oneshot::Sender<()>with the newAcknowledgementtrait throughout the marshal module - Made
Updateclonable to support multiple consumers acknowledging the same block
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| utils/src/lib.rs | Exports the new acknowledgement module and Acknowledgement trait |
| utils/src/acknowledgement.rs | Defines the Acknowledgement trait and Exact<N> implementation with atomic state management |
| examples/reshare/src/dkg/ingress.rs | Updates DKG message types to use Acknowledgement instead of oneshot::Sender<()> |
| examples/reshare/src/dkg/actor.rs | Changes block finalization to call acknowledge() instead of send(()) |
| consensus/src/marshal/mod.rs | Updates Update enum to use Acknowledgement and makes it clonable |
| consensus/src/marshal/mocks/application.rs | Updates mock application to use acknowledge() method |
| consensus/src/marshal/actor.rs | Refactors marshal actor to use Acknowledgement trait and its associated types |
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.
Bit worried about the usability of putting the number of required acks into the type signature instead of handling it inline.
EDIT: I also think this might run into troubles with the Reporters forking two one or more optional reporters.
Correct. You need to know exactly how many participants you want to acknowledge delivery a prioi (see race condition point above). We could alternatively accept some sort of arg into |
That's right, thanks for pointing that out. I have pushed a possible solution to #2218: Instead of requiring trait Splittable: Send {
fn split(self) -> (Self, Self);
}Modulo me overlooking some other race conditions, I think this might be an elegant way of a) hiding the cardinality of how many drops are expected from the consumer (some mailbox should not need to know how many other mailboxes need to ack the update), b) it solves the problem with the |
Figured out a way to avoid the race condition (and we can just use |
clabby
left a comment
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.
Neat :)
| // Because acknowledge consumes self, we know that there is no way for there | ||
| // to remain 0 references before the last acknowledgement has been cloned (i.e. | ||
| // the acknowledgement won't resolve while we are still creating new clones). | ||
| self.state.increment(); |
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.
👍
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #2216 +/- ##
==========================================
+ Coverage 92.21% 92.26% +0.04%
==========================================
Files 314 317 +3
Lines 86380 86951 +571
==========================================
+ Hits 79657 80222 +565
- Misses 6723 6729 +6
... and 12 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Replaces: #2202
Replaces: #2212
Instead of adding a custom
Reporterimpl, I think the most maintainable approach is to treatAcknowledgementas a first-party action.