-
Notifications
You must be signed in to change notification settings - Fork 74
causal sorting #2770
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
causal sorting #2770
Conversation
|
This PR is part of a stack of 11 bookmarks:
Created with jj-stack |
|
Claude finished @insipx's task —— View job PR Review - Causal Sorting ImplementationReviewed at 2025-11-13 21:38 UTC Todo List
Code Quality & ArchitectureStrong points:
Potential Issues1. Memory inefficiency in causal sort (xmtp_api_d14n/src/protocol/sort/causal.rs:24)missing.push(self.envelopes.remove(i));The 2. Clone overhead in depends_on extractor (xmtp_api_d14n/src/protocol/extractors/depends_on.rs:40)self.cursor = e.aad.as_ref().and_then(|a| a.depends_on.clone().map(Into::into));The 3. Inconsistent error handling in TopicCursor::get_or_default (xmtp_proto/src/types/topic_cursor.rs:16)pub fn get_or_default(&mut self, topic: &Topic) -> &GlobalCursor {
self.inner.entry(topic.clone()).or_default()
}This clones the 4. Missing documentation on TopicCursor::add (xmtp_proto/src/types/topic_cursor.rs:35)The Performance ConsiderationsVectorClock::dominates optimization (xmtp_api_d14n/src/protocol/impls/vector_clock.rs:8-10)fn dominates(&self, other: &Self) -> bool {
other.iter().all(|(&node, &seq)| self.get(&node) >= seq)
}This iterates over Test CoverageStrengths:
Gaps (per codecov):
Specific recommendations:
SecurityNo security concerns identified. The implementation correctly handles untrusted input through proper validation and doesn't expose sensitive data. Minor Issues
SummaryThe implementation is solid with good architecture and testing. Main concerns are performance optimizations (O(n²) removal, cloning overhead) and test coverage gaps in the new extractors. Consider addressing the clone issues referenced in #2691 before merging if this code will process large message batches. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2770 +/- ##
==========================================
- Coverage 77.28% 77.27% -0.02%
==========================================
Files 371 375 +4
Lines 53461 53692 +231
==========================================
+ Hits 41316 41488 +172
- Misses 12145 12204 +59 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4ff01fb to
56b9cb7
Compare
f347bed to
d11cf35
Compare
56b9cb7 to
9fc52ab
Compare
d11cf35 to
f98bdf4
Compare
9e14cc2 to
6db2e33
Compare
f98bdf4 to
3cdda8d
Compare
6db2e33 to
211ce1c
Compare
3cdda8d to
50739cb
Compare
211ce1c to
157a5d8
Compare
50739cb to
8d9c7b6
Compare
157a5d8 to
20f196a
Compare
d93572e to
0999e8f
Compare
7822659 to
3519e85
Compare
e00397f to
9385776
Compare
3519e85 to
7e857bd
Compare
9385776 to
96d5df8
Compare
96d5df8 to
de38fb0
Compare
Add causal sorting of envelopes and dependency extraction via
xmtp_api_d14n::protocol::sort::causalandEnvelope::depends_on()Introduce causal in-place sorting that removes envelopes with unmet dependencies and advances
TopicCursor; addDependsOnExtractorand extendEnvelopewithcursor()anddepends_on(); updateVectorClockandGlobalCursorto supportapply(&Cursor); exposeTopicCursorand reworkSortto returnResult<Option<Missing>, EnvelopeError>.📍Where to Start
Start with the causal sorter entrypoint
causal(...)in [file:xmtp_api_d14n/src/protocol/sort/causal.rs] and then review trait changes in [file:xmtp_api_d14n/src/protocol/traits/sort.rs] and [file:xmtp_api_d14n/src/protocol/traits/envelopes.rs].Macroscope summarized de38fb0.