Skip to content

fix: emit the binary encoding in one call - #18

Merged
sveitser merged 4 commits into
mainfrom
fix/serialize-bytes-in-one-call
Sep 1, 2026
Merged

fix: emit the binary encoding in one call#18
sveitser merged 4 commits into
mainfrom
fix/serialize-bytes-in-one-call

Conversation

@sveitser

@sveitser sveitser commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

The non-human-readable branch went through `<[u8]>::serialize`, which is a
`serialize_seq` plus one `serialize_element` per byte. Formats still write
length-then-bytes, so the wire is unaffected, but they are asked to do it a
byte at a time: a 1 MiB blob is 1,048,576 calls where one would do.

`serialize_bytes` states the whole blob at once. Measured on bincode with a
1 MiB field, 974 us -> 19 us. The gap widens to 6.3 ms -> 19 us when the value
is serialized through a `&mut dyn erased_serde::Serializer`, because there each
of those million calls is also a virtual call; that is what led us here.

`binary_encoding_is_unchanged_since_0_1_0` pins the 0.1.0 encodings as literals
rather than deriving them from the current code, and checks both directions:
that this version still writes them, and still reads them. Verified against
downstream too -- the 32 reference-vector tests in espresso-network, covering
every protocol version's headers, payloads, transactions and VID data, pass
unchanged with this patched in.
Behaviour-only; the API and the encoding are unchanged, so a patch bump.
Publishing is tag-triggered, so this only prepares the version.
GitHub auto-fails the pinned v4.0.1 as a deprecated release. Track the major
tag, as every other action here already does.
@sveitser
sveitser merged commit ca0a273 into main Sep 1, 2026
9 checks passed
@sveitser
sveitser deleted the fix/serialize-bytes-in-one-call branch September 1, 2026 15:22
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