mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(sdk): Define MaybeSerde (#12577)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
73
Cargo.lock
generated
73
Cargo.lock
generated
@ -182,9 +182,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "alloy-eip7702"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69fb9fd842fdf10a524bbf2c4de6942ad869c1c8c3d128a1b09e67ed5f7cedbd"
|
||||
checksum = "5f6cee6a35793f3db8a5ffe60e86c695f321d081a567211245f503e8c498fce8"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rlp",
|
||||
@ -776,9 +776,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "alloy-trie"
|
||||
version = "0.7.3"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40d8e28db02c006f7abb20f345ffb3cc99c465e36f676ba262534e654ae76042"
|
||||
checksum = "b6b2e366c0debf0af77766c23694a3f863b02633050e71e096e257ffbd395e50"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rlp",
|
||||
@ -1525,9 +1525,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.10.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c"
|
||||
checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"regex-automata 0.4.9",
|
||||
@ -1651,9 +1651,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
|
||||
checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
@ -1752,9 +1752,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.20"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
||||
checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@ -1762,9 +1762,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.20"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
||||
checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@ -1786,9 +1786,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
|
||||
|
||||
[[package]]
|
||||
name = "coins-bip32"
|
||||
@ -1859,14 +1859,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "comfy-table"
|
||||
version = "7.1.1"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7"
|
||||
checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9"
|
||||
dependencies = [
|
||||
"crossterm 0.27.0",
|
||||
"crossterm",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"unicode-width",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2107,19 +2107,6 @@ version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"crossterm_winapi",
|
||||
"libc",
|
||||
"parking_lot",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.28.1"
|
||||
@ -3198,9 +3185,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.34"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
|
||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
@ -6165,7 +6152,7 @@ dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm 0.28.1",
|
||||
"crossterm",
|
||||
"instability",
|
||||
"itertools 0.13.0",
|
||||
"lru",
|
||||
@ -6174,7 +6161,7 @@ dependencies = [
|
||||
"strum_macros",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -6665,7 +6652,7 @@ dependencies = [
|
||||
"backon",
|
||||
"clap",
|
||||
"comfy-table",
|
||||
"crossterm 0.28.1",
|
||||
"crossterm",
|
||||
"eyre",
|
||||
"fdlimit",
|
||||
"futures",
|
||||
@ -8397,6 +8384,7 @@ dependencies = [
|
||||
"reth-primitives",
|
||||
"reth-primitives-traits",
|
||||
"rstest",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -9629,6 +9617,7 @@ checksum = "8f4b84ba6e838ceb47b41de5194a60244fac43d9fe03b71dbe8c5a201081d6d1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -9903,9 +9892,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "scc"
|
||||
version = "2.2.4"
|
||||
version = "2.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8"
|
||||
checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed"
|
||||
dependencies = [
|
||||
"sdd",
|
||||
]
|
||||
@ -11349,7 +11338,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
||||
dependencies = [
|
||||
"itertools 0.13.0",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -11358,6 +11347,12 @@ version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -78,5 +78,6 @@ serde = [
|
||||
"alloy-primitives/serde",
|
||||
"parking_lot/serde",
|
||||
"rand/serde",
|
||||
"secp256k1/serde"
|
||||
"secp256k1/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
|
||||
@ -65,4 +65,5 @@ serde = [
|
||||
"alloy-primitives/serde",
|
||||
"bytes/serde",
|
||||
"rand/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
|
||||
@ -87,7 +87,8 @@ serde = [
|
||||
"rand/serde",
|
||||
"secp256k1/serde",
|
||||
"reth-codecs/serde",
|
||||
"alloy-chains/serde"
|
||||
"alloy-chains/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
|
||||
[[test]]
|
||||
|
||||
@ -121,6 +121,7 @@ serde = [
|
||||
"rand/serde",
|
||||
"smallvec/serde",
|
||||
"url/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
test-utils = [
|
||||
"dep:reth-provider",
|
||||
|
||||
@ -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",
|
||||
]
|
||||
|
||||
@ -12,21 +12,44 @@ description = "OP primitive types"
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
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
|
||||
bytes.workspace = true
|
||||
# reth
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-codecs = { workspace = true, optional = true }
|
||||
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }
|
||||
|
||||
[features]
|
||||
default = ["reth-codec"]
|
||||
reth-codec = ["dep:reth-codecs", "dep:reth-primitives"]
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
alloy-rlp.workspace = true
|
||||
|
||||
# op
|
||||
op-alloy-consensus.workspace = true
|
||||
|
||||
# codec
|
||||
bytes.workspace = true
|
||||
serde = { workspace = true, optional = true }
|
||||
|
||||
# misc
|
||||
derive_more.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
reth-codecs = { workspace = true, features = ["test-utils"] }
|
||||
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",
|
||||
]
|
||||
|
||||
@ -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;
|
||||
@ -13,10 +14,6 @@ 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")]
|
||||
@ -24,8 +21,9 @@ 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);
|
||||
|
||||
@ -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"
|
||||
@ -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",
|
||||
]
|
||||
@ -6,7 +6,6 @@ use bytes::Buf;
|
||||
use derive_more::Deref;
|
||||
use reth_codecs::{add_arbitrary_tests, Compact};
|
||||
use revm_primitives::{AccountInfo, Bytecode as RevmBytecode, BytecodeDecodeError, JumpTable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Identifier for [`LegacyRaw`](RevmBytecode::LegacyRaw).
|
||||
const LEGACY_RAW_BYTECODE_ID: u8 = 0;
|
||||
@ -24,7 +23,8 @@ const EOF_BYTECODE_ID: u8 = 3;
|
||||
const EIP7702_BYTECODE_ID: u8 = 4;
|
||||
|
||||
/// An Ethereum account.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize, Compact)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Compact)]
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
|
||||
#[add_arbitrary_tests(compact)]
|
||||
pub struct Account {
|
||||
@ -60,7 +60,8 @@ impl Account {
|
||||
/// Bytecode for an account.
|
||||
///
|
||||
/// A wrapper around [`revm::primitives::Bytecode`][RevmBytecode] with encoding/decoding support.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, Deref)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Deref)]
|
||||
pub struct Bytecode(pub RevmBytecode);
|
||||
|
||||
impl Bytecode {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Block body abstraction.
|
||||
|
||||
use crate::InMemorySize;
|
||||
use crate::{InMemorySize, MaybeSerde};
|
||||
use alloc::fmt;
|
||||
use alloy_consensus::Transaction;
|
||||
|
||||
@ -15,11 +15,10 @@ pub trait BlockBody:
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ serde::Serialize
|
||||
+ for<'de> serde::Deserialize<'de>
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
{
|
||||
/// Ordered list of signed transactions as committed in block.
|
||||
// todo: requires trait for signed transaction
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
//! Block header data primitive.
|
||||
|
||||
use crate::InMemorySize;
|
||||
use alloy_primitives::Sealable;
|
||||
use core::fmt;
|
||||
|
||||
use alloy_primitives::Sealable;
|
||||
use reth_codecs::Compact;
|
||||
|
||||
use crate::{InMemorySize, MaybeSerde};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block header to support full node
|
||||
/// operations.
|
||||
pub trait FullBlockHeader: BlockHeader + Compact {}
|
||||
@ -26,6 +28,7 @@ pub trait BlockHeader:
|
||||
+ alloy_consensus::BlockHeader
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,12 +41,11 @@ impl<T> BlockHeader for T where
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ serde::Serialize
|
||||
+ for<'de> serde::Deserialize<'de>
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ alloy_consensus::BlockHeader
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
{
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ use alloc::fmt;
|
||||
|
||||
use reth_codecs::Compact;
|
||||
|
||||
use crate::{BlockHeader, FullBlockHeader, InMemorySize};
|
||||
use crate::{BlockHeader, FullBlockHeader, InMemorySize, MaybeSerde};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block to support full node operations.
|
||||
pub trait FullBlock: Block<Header: Compact> + Compact {}
|
||||
@ -20,17 +20,7 @@ impl<T> FullBlock for T where T: Block<Header: FullBlockHeader> + Compact {}
|
||||
// senders
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait Block:
|
||||
Send
|
||||
+ Sync
|
||||
+ Unpin
|
||||
+ Clone
|
||||
+ Default
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ serde::Serialize
|
||||
+ for<'a> serde::Deserialize<'a>
|
||||
+ InMemorySize
|
||||
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + InMemorySize + MaybeSerde
|
||||
{
|
||||
/// Header part of the block.
|
||||
type Header: BlockHeader + 'static;
|
||||
|
||||
@ -92,3 +92,16 @@ pub trait MaybeArbitrary {}
|
||||
impl<T> MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {}
|
||||
#[cfg(not(any(feature = "test-utils", feature = "arbitrary")))]
|
||||
impl<T> MaybeArbitrary for T {}
|
||||
|
||||
/// Helper trait that requires de-/serialize implementation since `serde` feature is enabled.
|
||||
#[cfg(feature = "serde")]
|
||||
pub trait MaybeSerde: serde::Serialize + for<'de> serde::Deserialize<'de> {}
|
||||
/// Noop. Helper trait that would require de-/serialize implementation if `serde` feature were
|
||||
/// enabled.
|
||||
#[cfg(not(feature = "serde"))]
|
||||
pub trait MaybeSerde {}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<T> MaybeSerde for T where T: serde::Serialize + for<'de> serde::Deserialize<'de> {}
|
||||
#[cfg(not(feature = "serde"))]
|
||||
impl<T> MaybeSerde for T {}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
use core::fmt;
|
||||
|
||||
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType};
|
||||
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType, MaybeSerde};
|
||||
|
||||
/// Configures all the primitive types of the node.
|
||||
pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static {
|
||||
/// Block primitive.
|
||||
type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
|
||||
/// Signed version of the transaction type.
|
||||
type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
|
||||
/// Transaction envelope type ID.
|
||||
type TxType: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
/// A receipt.
|
||||
type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
|
||||
}
|
||||
|
||||
impl NodePrimitives for () {
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
//! Receipt abstraction
|
||||
|
||||
use crate::{InMemorySize, MaybeSerde};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::TxReceipt;
|
||||
use alloy_primitives::B256;
|
||||
use core::fmt;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::InMemorySize;
|
||||
|
||||
/// Helper trait that unifies all behaviour required by receipt to support full node operations.
|
||||
pub trait FullReceipt: Receipt + Compact {}
|
||||
@ -26,9 +24,8 @@ pub trait Receipt:
|
||||
+ TxReceipt
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ Serialize
|
||||
+ MaybeSerde
|
||||
+ InMemorySize
|
||||
+ for<'de> Deserialize<'de>
|
||||
{
|
||||
/// Returns transaction type.
|
||||
fn tx_type(&self) -> u8;
|
||||
|
||||
@ -6,9 +6,8 @@ use core::{fmt, hash::Hash};
|
||||
|
||||
use alloy_primitives::B256;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{FullTxType, InMemorySize, MaybeArbitrary, TxType};
|
||||
use crate::{FullTxType, InMemorySize, MaybeArbitrary, MaybeSerde, TxType};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
|
||||
pub trait FullTransaction: Transaction<Type: FullTxType> + Compact {}
|
||||
@ -26,10 +25,9 @@ pub trait Transaction:
|
||||
+ Eq
|
||||
+ PartialEq
|
||||
+ Hash
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>
|
||||
+ TransactionExt
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
}
|
||||
@ -44,10 +42,9 @@ impl<T> Transaction for T where
|
||||
+ Eq
|
||||
+ PartialEq
|
||||
+ Hash
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>
|
||||
+ TransactionExt
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256};
|
||||
use reth_codecs::Compact;
|
||||
use revm_primitives::TxEnv;
|
||||
|
||||
use crate::{FullTransaction, InMemorySize, MaybeArbitrary, Transaction};
|
||||
use crate::{FullTransaction, InMemorySize, MaybeArbitrary, MaybeSerde, Transaction};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block to support full node operations.
|
||||
pub trait FullSignedTx: SignedTransaction<Transaction: FullTransaction> + Compact {}
|
||||
@ -27,13 +27,12 @@ pub trait SignedTransaction:
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ Hash
|
||||
+ serde::Serialize
|
||||
+ for<'a> serde::Deserialize<'a>
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ Encodable2718
|
||||
+ Decodable2718
|
||||
+ alloy_consensus::Transaction
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
+ InMemorySize
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
reth-ethereum-forks.workspace = true
|
||||
reth-static-file-types.workspace = true
|
||||
revm-primitives = { workspace = true, features = ["serde"] }
|
||||
|
||||
@ -59,4 +59,5 @@ serde = [
|
||||
"alloy-eips/serde",
|
||||
"alloy-primitives/serde",
|
||||
"alloy-consensus/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
|
||||
@ -81,7 +81,7 @@ serde = [
|
||||
"alloy-primitives/serde",
|
||||
"alloy-trie?/serde",
|
||||
"bytes/serde",
|
||||
"op-alloy-consensus?/serde"
|
||||
"op-alloy-consensus?/serde",
|
||||
]
|
||||
arbitrary = [
|
||||
"alloy-consensus?/arbitrary",
|
||||
|
||||
@ -16,7 +16,7 @@ workspace = true
|
||||
reth-codecs.workspace = true
|
||||
reth-db-models.workspace = true
|
||||
reth-primitives = { workspace = true, features = ["reth-codec"] }
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
reth-prune-types.workspace = true
|
||||
reth-stages-types.workspace = true
|
||||
reth-storage-errors.workspace = true
|
||||
|
||||
@ -14,7 +14,7 @@ workspace = true
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-codecs.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
|
||||
@ -15,7 +15,7 @@ workspace = true
|
||||
# reth
|
||||
reth-db-api.workspace = true
|
||||
reth-primitives = { workspace = true, features = ["reth-codec"] }
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
reth-fs-util.workspace = true
|
||||
reth-storage-errors.workspace = true
|
||||
reth-nippy-jar.workspace = true
|
||||
|
||||
@ -110,6 +110,7 @@ serde = [
|
||||
"rand/serde",
|
||||
"revm/serde",
|
||||
"reth-codecs/serde",
|
||||
"reth-optimism-primitives?/serde",
|
||||
]
|
||||
test-utils = [
|
||||
"reth-db/test-utils",
|
||||
|
||||
@ -88,6 +88,7 @@ serde = [
|
||||
"rand?/serde",
|
||||
"revm/serde",
|
||||
"smallvec/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
]
|
||||
test-utils = [
|
||||
"rand",
|
||||
|
||||
@ -12,7 +12,7 @@ description = "Commonly used types for trie usage in reth."
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
reth-codecs.workspace = true
|
||||
|
||||
alloy-primitives.workspace = true
|
||||
|
||||
Reference in New Issue
Block a user