Skip to content

feat(consensus): bincode compatibility for header and transaction types#1397

Merged
mattsse merged 13 commits intoalloy-rs:mainfrom
shekhirin:alexey/bincode-compat
Sep 30, 2024
Merged

feat(consensus): bincode compatibility for header and transaction types#1397
mattsse merged 13 commits intoalloy-rs:mainfrom
shekhirin:alexey/bincode-compat

Conversation

@shekhirin
Copy link
Copy Markdown
Contributor

@shekhirin shekhirin commented Sep 28, 2024

Closes #1349

Introduces the serde-bincode-compat feature that provides bincode-compatible implementations of serde serialization/deserialization to use with serde_as macro.

Example usage

/// ```rust
/// use alloy_consensus::{serde_bincode_compat, Header};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
/// #[serde_as]
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
/// struct Data {
/// #[serde_as(as = "serde_bincode_compat::Header")]
/// header: Header,
/// }
/// ```

@shekhirin shekhirin added the enhancement New feature or request label Sep 28, 2024
@shekhirin shekhirin force-pushed the alexey/bincode-compat branch from 8f47037 to af593d2 Compare September 29, 2024 10:23
"dep:alloy-serde",
"alloy-eips/serde",
]
serde-bincode-compat = ["serde_with"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

open to renaming this feature to something more generic than bincode, because it also unlocks messagepack via https://github.com/3Hren/msgpack-rust

@shekhirin shekhirin marked this pull request as ready for review September 29, 2024 10:24
@shekhirin shekhirin force-pushed the alexey/bincode-compat branch from 484416c to 84956fe Compare September 29, 2024 11:47
Copy link
Copy Markdown
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

why is this required for all the tx types?

@shekhirin
Copy link
Copy Markdown
Contributor Author

why is this required for all the tx types?

they have a skip_serializing_if attribute, and we use tx types in the block body in Reth

github-merge-queue bot pushed a commit to alloy-rs/op-alloy that referenced this pull request Sep 30, 2024
## Motivation

alloy-rs/alloy#1349

## Solution

Same as alloy-rs/alloy#1397

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes
lwedge99 pushed a commit to sentioxyz/alloy that referenced this pull request Oct 8, 2024
…es (alloy-rs#1397)

* fix(serde): encode optional quantity as Some

* use serialize_some

* fix in other types too

* feat(consensus): bincode compatibility for header and transaction types

* add docs

* reorganize modules

* add legacy bincode compat impl, remove comments

* less cows

* fix doctest for legacy tx

* rename feature

* more info about limitation

* remove special treatment for quantity fields
docker-dragonmj9ol added a commit to docker-dragonmj9ol/op-alloy that referenced this pull request Nov 6, 2025
## Motivation

alloy-rs/alloy#1349

## Solution

Same as alloy-rs/alloy#1397

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 21, 2026
## Motivation

alloy-rs/alloy#1349

## Solution

Same as alloy-rs/alloy#1397

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes
refcell pushed a commit to base/base that referenced this pull request Feb 18, 2026
## Motivation

alloy-rs/alloy#1349

## Solution

Same as alloy-rs/alloy#1397

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes
refcell pushed a commit to base/base that referenced this pull request Feb 18, 2026
## Motivation

alloy-rs/alloy#1349

## Solution

Same as alloy-rs/alloy#1397

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature] Bincode support for alloy-consensus and alloy-primitive types

2 participants