Optimize envelope visitors by Unpacked versions of envelopes#3340
Optimize envelope visitors by Unpacked versions of envelopes#3340
Unpacked versions of envelopes#3340Conversation
…ation - Update macros.rs, envelope_visitor.rs, and tuple impls to use Unpacked types - Update network_backoff.rs ResolvedEnvelope to UnpackedOriginatorEnvelope - Fix xmtp_query.rs in both combined and d14n to use UnpackedOriginatorEnvelope - Add AsUnpackedSubscribeResponse helper for packed SubscribeEnvelopesResponse compat - Fix group_message_metadata.rs to convert packed→unpacked before accept() - Fix test code in aggregate.rs to use UnpackedOriginatorEnvelope - Fix import ordering in d14n_compat.rs for rustfmt - Remove redundant Default derives (prost::Message provides them) - Fix rustfmt ordering in xmtp_proto/src/types.rs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @insipx's task —— View job Code Review — March 17, 2026, 20:57 UTCThis is a well-designed performance optimization that eliminates redundant deserialization. The wire-format compatibility approach is clever and the changes are thorough. I found a few potential issues worth addressing: 🐛 Potential Bug: Silent Conversion FailuresLocation: The let unpacked = self
.originator_envelope
.as_ref()
.map(UnpackedOriginatorEnvelope::try_from)
.transpose()
.map_err(ConversionError::from)?;
unpacked.as_ref().accept(visitor)?;If
|
ApprovabilityVerdict: Approved This is an internal optimization that introduces 'Unpacked' envelope types to avoid repeated protobuf decode calls when traversing nested envelopes. The wire format remains compatible, all changes are within the author's ownership domain, and the PR includes comprehensive tests demonstrating wire-format compatibility. You can customize Macroscope's approvability policy. Learn more. |
…lEnvelope impl Replace if/else with .map().transpose() chain — the Option<&T> blanket impl handles Some (delegates to T::accept) and None (calls visit_none) automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace SubscribeEnvelopesResponse with UnpackedSubscribeEnvelopesResponse in both xmtp_mls test helpers, eliminating manual encode/decode of nested bytes - Remove EnvelopeCollection impl and AsUnpackedSubscribeResponse helper for packed SubscribeEnvelopesResponse — no longer needed - Remove Paged impls for packed QueryEnvelopesResponse and SubscribeEnvelopesResponse - Drop unused prost::Message and SubscribeEnvelopesResponse imports Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3340 +/- ##
==========================================
- Coverage 82.51% 82.51% -0.01%
==========================================
Files 376 377 +1
Lines 51267 51292 +25
==========================================
+ Hits 42304 42322 +18
- Misses 8963 8970 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
this deserializes envelopes once, allowing visitors to return borrowed data from the network and should reduce cloning, esp in sort methods.
an experiment which uses hands-off claude to tackle a small tech debt issue
Note
Replace packed envelope types with
Unpackedvariants across envelope visitors and endpointsUnpacked*types (unpacked_envelopes.rs) that mirror the protobufOriginatorEnvelope,UnsignedOriginatorEnvelope, andPayerEnvelopestructs but decode nested messages inline rather than storing raw bytes.EnvelopeVisitortrait and all extractor implementations to acceptUnpackedOriginatorEnvelope,UnpackedUnsignedOriginatorEnvelope, andUnpackedPayerEnvelopeinstead of packed types, eliminating per-visitprost::Message::decodecalls.Outputtypes forQueryEnvelope,QueryEnvelopes, andSubscribeEnvelopesto returnUnpackedQueryEnvelopesResponse/UnpackedSubscribeEnvelopesResponseso callers receive already-decoded envelopes.d14n_compatsubscription decoder inxmtp_mls.SubscribeEnvelopesResponsetests are removed because nested messages are now held as structs.Macroscope summarized 11e9168.