feat(wire): split the frame discriminant into trait and method bytes - #357
Draft
decrypto21 wants to merge 1 commit into
Draft
feat(wire): split the frame discriminant into trait and method bytes#357decrypto21 wants to merge 1 commit into
decrypto21 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
u8s instead of one: the API trait (namespace) and the method within that trait.[SCALE str requestId][u8 id][payload][SCALE str requestId][u8 trait][u8 method][payload]#[wire_trait(id = N)]attribute, carried through the macro, rustdoc extraction, and both emitters. Missing or duplicate trait ids are hard codegen errors; there is no fallback that derives an id from declaration or module order.n/n+1, a subscription takesn..n+3. Append-only becomes a per-trait rule.--codec-versiondefault,scripts/codegen.sh, the generated client constant, and the handshake's acceptance check).Why
u8is the whole address today, so new methods can only append at the global tail. Five traits already have non-contiguous id blocks as a result (accountspans 18-28, 110-112, and 164), and ids 70-75 are permanently burned by the retiredJsonRpctrait. 163 of 255 values are already assigned, and a single subscription costs four slots.Compatibility
UnsupportedProtocolVersionrather than a hang.message_idwith its own codec indices and has no reference to this envelope's discriminant.Verification
cargo test --workspace --all-features: 648 passed, 0 failed.cargo fmt --all -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings, and thewasm32-unknown-unknownbuild oftruapi-serverare all clean.js/packages/truapi:tscbuild clean,bun test206 passed, 0 failed.js/packages/truapi-host: 40 passed.yarn buildandyarn lintclean against a refreshed package snapshot.