Skip to content

Commit

Permalink
chore(sdk): Define MaybeSerde (#12577)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
emhane and mattsse authored Nov 18, 2024
1 parent cee11df commit ff22c8e
Show file tree
Hide file tree
Showing 28 changed files with 143 additions and 107 deletions.
73 changes: 34 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/evm/execution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ serde = [
"revm/serde",
"alloy-eips/serde",
"alloy-primitives/serde",
"rand/serde"
"rand/serde",
"reth-primitives-traits/serde",
]
serde-bincode-compat = [
"reth-primitives/serde-bincode-compat",
Expand Down
3 changes: 2 additions & 1 deletion crates/exex/exex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ serde = [
"alloy-primitives/serde",
"parking_lot/serde",
"rand/serde",
"secp256k1/serde"
"secp256k1/serde",
"reth-primitives-traits/serde",
]
1 change: 1 addition & 0 deletions crates/net/eth-wire-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ serde = [
"alloy-primitives/serde",
"bytes/serde",
"rand/serde",
"reth-primitives-traits/serde",
]
3 changes: 2 additions & 1 deletion crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ serde = [
"rand/serde",
"secp256k1/serde",
"reth-codecs/serde",
"alloy-chains/serde"
"alloy-chains/serde",
"reth-primitives-traits/serde",
]

[[test]]
Expand Down
1 change: 1 addition & 0 deletions crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ serde = [
"rand/serde",
"smallvec/serde",
"url/serde",
"reth-primitives-traits/serde",
]
test-utils = [
"dep:reth-provider",
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ serde = [
"alloy-primitives/serde",
"op-alloy-consensus?/serde",
"reth-execution-types/serde",
"reth-provider/serde"
"reth-provider/serde",
"reth-optimism-primitives/serde",
]
41 changes: 32 additions & 9 deletions crates/optimism/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,44 @@ description = "OP primitive types"
workspace = true

[dependencies]
# reth
reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }

# ethereum
alloy-primitives.workspace = true
alloy-consensus.workspace = true
op-alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-rlp.workspace = true
derive_more.workspace = true

# op
op-alloy-consensus.workspace = true

# codec
bytes.workspace = true
reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }
serde = { workspace = true, optional = true }

[features]
default = ["reth-codec"]
reth-codec = ["dep:reth-codecs", "dep:reth-primitives"]
# misc
derive_more.workspace = true

[dev-dependencies]
reth-codecs = { workspace = true, features = ["test-utils"] }
rstest.workspace = true
rstest.workspace = true

[features]
default = ["reth-codec"]
reth-codec = [
"dep:reth-codecs",
"dep:reth-primitives"
]
serde = [
"dep:serde",
"reth-primitives-traits/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"alloy-eips/serde",
"bytes/serde",
"reth-codecs/serde",
"op-alloy-consensus/serde",
]
10 changes: 4 additions & 6 deletions crates/optimism/primitives/src/tx_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//! This type is required because a `Compact` impl is needed on the deposit tx type.
use core::fmt::Debug;
use std::convert::TryFrom;

#[cfg(feature = "reth-codec")]
use alloy_consensus::constants::EIP7702_TX_TYPE_ID;
use alloy_primitives::{U64, U8};
use alloy_rlp::{Decodable, Encodable, Error};
use bytes::BufMut;
Expand All @@ -13,19 +14,16 @@ use derive_more::{
Display,
};
use op_alloy_consensus::OpTxType as AlloyOpTxType;
use reth_primitives_traits::{InMemorySize, TxType};

#[cfg(feature = "reth-codec")]
use alloy_consensus::constants::EIP7702_TX_TYPE_ID;
#[cfg(feature = "reth-codec")]
use op_alloy_consensus::DEPOSIT_TX_TYPE_ID;
#[cfg(feature = "reth-codec")]
use reth_primitives::transaction::{
COMPACT_EXTENDED_IDENTIFIER_FLAG, COMPACT_IDENTIFIER_EIP1559, COMPACT_IDENTIFIER_EIP2930,
COMPACT_IDENTIFIER_LEGACY,
};
use reth_primitives_traits::{InMemorySize, TxType};

/// Wrapper type for `AlloyOpTxType` to implement `TxType` trait.
/// Wrapper type for [`op_alloy_consensus::OpTxType`] to implement [`TxType`] trait.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Display, Ord, Hash, From, Into)]
#[into(u8)]
pub struct OpTxType(AlloyOpTxType);
Expand Down
19 changes: 16 additions & 3 deletions crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ description = "Common types in reth."
workspace = true

[dependencies]
# reth
reth-codecs.workspace = true

alloy-consensus = { workspace = true, features = ["serde"] }
# ethereum
alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-genesis.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true

revm-primitives = { workspace = true, features = ["serde"] }
revm-primitives.workspace = true

# misc
byteorder = "1"
Expand Down Expand Up @@ -76,7 +77,19 @@ arbitrary = [
"reth-codecs/arbitrary"
]
serde-bincode-compat = [
"serde",
"serde_with",
"alloy-consensus/serde-bincode-compat",
"alloy-eips/serde-bincode-compat"
]
serde = [
"alloy-consensus/serde",
"alloy-eips/serde",
"alloy-primitives/serde",
"bytes/serde",
"rand/serde",
"reth-codecs/serde",
"revm-primitives/serde",
"roaring/serde",
"revm-primitives/serde",
]
Loading

0 comments on commit ff22c8e

Please sign in to comment.