Skip to content

RFC 0028: Nested Wire Envelope: Trait, Method, Version, and Direction - #557

Open
decrypto21 wants to merge 4 commits into
mainfrom
rfc/0028-nested-wire-envelope
Open

RFC 0028: Nested Wire Envelope: Trait, Method, Version, and Direction#557
decrypto21 wants to merge 4 commits into
mainfrom
rfc/0028-nested-wire-envelope

Conversation

@decrypto21

Copy link
Copy Markdown
Contributor

Adds the design proposal for folding wire direction (request/response, or a subscription's start/stop/interrupt/receive) and version into the payload itself, so each method costs one wire id instead of two or four. Registers it in docs/rfcs/_index.md.

Implemented directly in #357 rather than a separate PR: neither has merged, and the nested envelope isn't separable from that PR's own wire redesign, same unreleased codec 2 cutover.

@decrypto21
decrypto21 force-pushed the rfc/0028-nested-wire-envelope branch from 76ede58 to d4078ff Compare September 2, 2026 10:14
Start(Start),
Stop,
Interrupt(Option<Err>),
Receive(Item),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Receive should be after Start

pub enum Subscription<Start, Item, Err> {
    Start(Start),
    Receive(Item),
    Interrupt(Option<Err>),
    Stop,
}

So subscriptions can be partly backward compatible with request


## Summary

The codec 2 envelope (`[requestId][trait: u8][method: u8][payload]`) still spends its per-trait method-id budget on *direction*: a request/response method reserves two consecutive ids, a subscription reserves four. This RFC moves direction into the payload itself, one decode step past the `(trait, method)` routing pair: version selects a method's own `{Method}Version` enum, and that version wraps a `Request<Req, Res>` (or, for subscriptions, a `Subscription<Start, Item, Err>`) value whose own variant tag carries direction. The `(trait, method)` address stays exactly as flat as it is today (one `MethodIds` constant per method, unchanged as the dispatcher's routing key); only what a method's *payload* decodes into changes. Each method costs exactly one id, method ids run as a dense 0, 1, 2, ... sequence per trait, and a method's version history is the single place its shape (request/response today, subscription tomorrow) can change without touching its wire address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to read, for some reason we're not using normal vocabulary like "Enum", "Section/Pallet", etc.
Let's define wording first and then define what we want to do with it. Low level bytes position is part of SCALE spec itself, we need to reuse this abstraction and work with higher level primitives

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.

2 participants