Skip to content

feat: add shared witness encoding helpers#137

Open
abelmega wants to merge 2 commits into
mainfrom
abel/feat/add-witness-encoding
Open

feat: add shared witness encoding helpers#137
abelmega wants to merge 2 commits into
mainfrom
abel/feat/add-witness-encoding

Conversation

@abelmega
Copy link
Copy Markdown
Collaborator

Summary

Add shared witness encoding helpers to stateless-common and switch RpcClient witness decoding to use the shared implementation.

What Changed

  • add stateless-common::witness_encoding for the shared witness RPC wire format
  • expose helpers for:
    • compressing witness payloads
    • decompressing witness payloads
    • encoding versioned witness RPC responses
    • decoding versioned witness RPC responses
  • migrate the fetch_witness_raw decode path in rpc_client.rs to call the shared decoder
  • replace the remaining hard-coded v0: test stub in rpc_client.rs with the shared version prefix constant
  • add round-trip and error-path tests for the new witness encoding module
  • tighten module comments to clearly distinguish response prefix vs payload

Notes

  • the witness RPC wire format remains unchanged: v0:base64(zstd(level=9, bincode-legacy((SaltWitness, MptWitness))))
  • rpc_client.rs request flow and retry behavior are unchanged
  • this PR does not yet migrate witness response encoding call sites outside the new helper module

Validation

  • cargo check -p stateless-common
  • cargo test -p stateless-common witness_encoding

@claude
Copy link
Copy Markdown

claude Bot commented May 27, 2026

The PR currently has no labels, but it appears the enhancement label is missing.

The title (feat: add shared witness encoding helpers) and the diff confirm this is a new feature: it introduces the witness_encoding module with shared helpers for compressing/decompressing/encoding/decoding witness RPC payloads, migrates rpc_client.rs to use the shared decoder, and adds round-trip tests. This matches the enhancement label description ("New feature or request").

Comment thread crates/stateless-common/src/witness_encoding.rs Outdated
Comment thread crates/stateless-common/src/witness_encoding.rs
@claude
Copy link
Copy Markdown

claude Bot commented May 27, 2026

Clean extraction. The layering is clear (compress/decompress for raw bytes, encode/decode for the full versioned string), error types are typed, and the rpc_client.rs migration is straightforward.

Two things before merge — see inline comments:

  1. Missing error-path tests for the Base64 and decompression branches in decode_witness_response.
  2. nit: WitnessEncodingError::Serialize uses #[source] while Compress uses #[from] — inconsistency without a clear reason.

@abelmega abelmega added compat:seamless enhancement New feature or request labels May 27, 2026
@claude
Copy link
Copy Markdown

claude Bot commented May 27, 2026

LGTM. Previous feedback addressed — #[from] added to WitnessEncodingError::Serialize and all three error-path tests added. The module is well-structured and the encoding contract is clearly documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compat:seamless enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants