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

feat(exex): derive serde ser/deser for ExExNotification #8963

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/ethereum-forks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ proptest-derive.workspace = true

[features]
default = ["std", "serde"]
std = ["thiserror-no-std/std"]
serde = ["dep:serde"]
arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
optimism = []
serde = ["dep:serde"]
std = ["thiserror-no-std/std"]
5 changes: 4 additions & 1 deletion crates/evm/execution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ reth-trie.workspace = true

revm.workspace = true

serde = { workspace = true, optional = true }

[dev-dependencies]
reth-primitives = { workspace = true, features = ["test-utils"] }
alloy-primitives.workspace = true
alloy-eips.workspace = true

[features]
optimism = ["dep:reth-chainspec"]
optimism = ["dep:reth-chainspec"]
serde = ["dep:serde", "reth-trie/serde", "revm/serde"]
1 change: 1 addition & 0 deletions crates/evm/execution-types/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::{borrow::Cow, collections::BTreeMap, fmt, ops::RangeInclusive};
///
/// A chain of blocks should not be empty.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Chain {
/// All blocks in this chain.
blocks: BTreeMap<BlockNumber, SealedBlockWithSenders>,
Expand Down
1 change: 1 addition & 0 deletions crates/evm/execution-types/src/execution_outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::collections::HashMap;
/// The `ExecutionOutcome` structure aggregates the state changes over an arbitrary number of
/// blocks, capturing the resulting state, receipts, and requests following the execution.
#[derive(Default, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExecutionOutcome {
/// Bundle state with reverts.
pub bundle: BundleState,
Expand Down
5 changes: 5 additions & 0 deletions crates/exex/exex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ tokio-util.workspace = true
## misc
eyre.workspace = true
metrics.workspace = true
serde = { workspace = true, optional = true }

[features]
default = []
serde = ["dep:serde", "reth-provider/serde"]
1 change: 1 addition & 0 deletions crates/exex/exex/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use reth_provider::{CanonStateNotification, Chain};

/// Notifications sent to an `ExEx`.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ExExNotification {
/// Chain got committed without a reorg, and only the new chain is returned.
ChainCommitted {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/discv4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ reth-tracing.workspace = true

[features]
default = ["serde"]
test-utils = ["dep:rand"]
serde = ["dep:serde"]
test-utils = ["dep:rand"]
3 changes: 2 additions & 1 deletion crates/net/eth-wire-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ async-stream.workspace = true

[features]
default = ["serde"]
serde = ["dep:serde"]
arbitrary = [
"reth-primitives/arbitrary",
"dep:arbitrary",
"dep:proptest",
"dep:proptest-derive",
]
serde = ["dep:serde"]

2 changes: 1 addition & 1 deletion crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ async-stream.workspace = true

[features]
default = ["serde"]
serde = ["dep:serde"]
arbitrary = [
"reth-primitives/arbitrary",
"dep:arbitrary",
"dep:proptest",
"dep:proptest-derive",
]
optimism = ["reth-primitives/optimism"]
serde = ["dep:serde"]

[[test]]
name = "fuzz_roundtrip"
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ criterion = { workspace = true, features = ["async_tokio", "html_reports"] }

[features]
default = ["serde"]
geth-tests = []
serde = ["dep:serde", "dep:humantime-serde", "secp256k1/serde", "enr/serde", "dep:serde_json"]
test-utils = ["reth-provider/test-utils", "dep:tempfile", "reth-transaction-pool/test-utils"]
geth-tests = []

[[bench]]
name = "bench"
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod error;
pub use error::{GotExpected, GotExpectedBoxed};

mod log;
pub use log::{logs_bloom, Log};
pub use log::{logs_bloom, Log, LogData};

mod storage;
pub use storage::StorageEntry;
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives-traits/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::Bloom;
pub use alloy_primitives::Log;
pub use alloy_primitives::{Log, LogData};

/// Calculate receipt logs bloom.
pub fn logs_bloom<'a>(logs: impl IntoIterator<Item = &'a Log>) -> Bloom {
Expand Down
15 changes: 14 additions & 1 deletion crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use proptest::strategy::Strategy;
#[cfg(feature = "zstd-codec")]
use reth_codecs::CompactZstd;
use reth_codecs::{add_arbitrary_tests, main_codec, Compact};
use serde::{Deserialize, Serialize};

#[cfg(not(feature = "std"))]
use alloc::{vec, vec::Vec};
Expand Down Expand Up @@ -66,7 +67,19 @@ impl Receipt {
}

/// A collection of receipts organized as a two-dimensional vector.
#[derive(Clone, Debug, PartialEq, Eq, Default, From, Deref, DerefMut, IntoIterator)]
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Default,
Serialize,
Deserialize,
From,
Deref,
DerefMut,
IntoIterator,
)]
pub struct Receipts {
/// A two-dimensional vector of optional `Receipt` instances.
pub receipt_vec: Vec<Vec<Option<Receipt>>>,
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ assert_matches.workspace = true
rand.workspace = true

[features]
test-utils = ["alloy-rlp", "reth-db/test-utils", "reth-nippy-jar/test-utils"]
optimism = ["reth-primitives/optimism", "reth-execution-types/optimism"]
serde = ["reth-execution-types/serde"]
test-utils = ["alloy-rlp", "reth-db/test-utils", "reth-nippy-jar/test-utils"]
2 changes: 1 addition & 1 deletion crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ serde_json.workspace = true

[features]
default = ["serde"]
arbitrary = ["proptest", "reth-primitives/arbitrary"]
serde = ["dep:serde"]
test-utils = ["rand", "paste", "serde"]
arbitrary = ["proptest", "reth-primitives/arbitrary"]

[[bench]]
name = "truncate"
Expand Down
4 changes: 4 additions & 0 deletions crates/trie/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ metrics = { workspace = true, optional = true }
# `test-utils` feature
triehash = { version = "0.8", optional = true }

# `serde` feature
serde = { workspace = true, optional = true }

[dev-dependencies]
# reth
reth-chainspec.workspace = true
Expand Down Expand Up @@ -67,6 +70,7 @@ criterion.workspace = true

[features]
metrics = ["reth-metrics", "dep:metrics"]
serde = ["dep:serde"]
test-utils = ["triehash", "reth-trie-common/test-utils"]

[[bench]]
Expand Down
3 changes: 3 additions & 0 deletions crates/trie/trie/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::collections::{hash_map::IntoIter, HashMap, HashSet};

/// The key of a trie node.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TrieKey {
/// A node in the account trie.
AccountNode(StoredNibbles),
Expand All @@ -24,6 +25,7 @@ pub enum TrieKey {

/// The operation to perform on the trie.
#[derive(PartialEq, Eq, Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TrieOp {
/// Delete the node entry.
Delete,
Expand All @@ -40,6 +42,7 @@ impl TrieOp {

/// The aggregation of trie updates.
#[derive(Debug, Default, Clone, PartialEq, Eq, Deref)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TrieUpdates {
trie_operations: HashMap<TrieKey, TrieOp>,
}
Expand Down
Loading