[Feature] Bincode support for alloy-consensus
and alloy-primitive
types
#1349
Labels
Milestone
alloy-consensus
and alloy-primitive
types
#1349
Component
consensus, eips, genesis, serde
Describe the feature you would like
Problem
Bincode does not support
#[serde(skip*)]
attributes. Additionally, there's a similar issue with rmp-serde.It means that we cannot use a lot of Alloy types for serialization/deserialization using these formats.
Solution
Introduce helper serde modules for those structs in
alloy-consensus
that have#[serde(skip*)]
attributes on fields and remove those attributes. Modules should be similar toalloy/crates/rpc-types-beacon/src/payload.rs
Lines 275 to 298 in 5c7470c
Then, these modules should be used in structs that have problematic types as fields. For example, for the
Block
type we will need to use a#[serde_as]
on theBlock
struct and#[serde_as(as = "HeaderBincode")]
on theheader
fieldalloy/crates/consensus/src/block.rs
Lines 15 to 18 in cf9a98f
Both of the attributes should be gated by the
serde-bincode
feature.The types that need special handling are:
Header
TxEip2930
TxEip1559
TxLegacy
As a test, we should be able to serialize and deserialize the
Block
struct usingbincode
.Additional context
No response
The text was updated successfully, but these errors were encountered: