Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Overly using serde(flatten) causes bitcode and bincode errors #1931

Closed
louisponet opened this issue Jan 21, 2025 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@louisponet
Copy link

Component

serde

What version of Alloy are you on?

├── alloy-primitives v0.8.15 () ├── alloy-consensus v0.8.3 () ├── alloy-network v0.8.3 () ├── alloy-primitives v0.8.15 () ├── alloy-provider v0.8.3 () ├── alloy-rpc-types v0.8.3 () ├── alloy-signer-local v0.8.3 () ├── alloy-transport-http v0.8.3 ()

Operating System

Linux

Describe the bug

Overly using the serde(flatten) attribute on different fields causes bitcode and bincode (tested with those) to panic with Sequence must have length. One clear example is Signed in alloy-consensus. Each of the fields is serializable, and if I create a Signed without serde(flatten) on the fields everything is fine.

Any reason to use serde(flatten) everywhere? If not, I can create a PR removing some.

Cheers

@louisponet louisponet added the bug Something isn't working label Jan 21, 2025
@klkvr
Copy link
Member

klkvr commented Jan 21, 2025

serde(flatten) is used to comply with RPC specification and we can't remove it for e.g TxEnvelope as this would result in transactions being serialized incorrectly

there's no bincode format specification, however we still provide bincode-compatible helpers for some of the types, e.g

/// Bincode-compatible [`TxEip1559`] serde implementation.
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {

feel free to add similar helpers for any other types you need such compatibiliy for

@louisponet
Copy link
Author

Ah nice, thank you! will have a look into that

@mattsse
Copy link
Member

mattsse commented Jan 31, 2025

closing because we have the bincode helpers for that

@mattsse mattsse closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants