mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: optional serde features (#1214)
Co-authored-by: lambdaclass-user <github@lambdaclass.com>
This commit is contained in:
@ -11,7 +11,7 @@ readme = "README.md"
|
||||
bytes = { version = "1.1" }
|
||||
hex = "0.4"
|
||||
thiserror = "1"
|
||||
serde = "1"
|
||||
serde = { version = "1", optional = true }
|
||||
|
||||
# reth
|
||||
reth-codecs = { path = "../../storage/codecs" }
|
||||
@ -27,7 +27,7 @@ tokio-stream = "0.1.11"
|
||||
pin-project = "1.0"
|
||||
tracing = "0.1.37"
|
||||
snap = "1.0.5"
|
||||
smol_str = { version = "0.1", features = ["serde"] }
|
||||
smol_str = "0.1"
|
||||
metrics = "0.20.1"
|
||||
|
||||
# arbitrary utils
|
||||
@ -52,10 +52,11 @@ proptest = { version = "1.0" }
|
||||
proptest-derive = "0.3"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["serde"]
|
||||
serde = ["dep:serde", "smol_str/serde"]
|
||||
arbitrary = ["reth-primitives/arbitrary", "dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
|
||||
|
||||
[[test]]
|
||||
name = "fuzz_roundtrip"
|
||||
path = "tests/fuzz_roundtrip.rs"
|
||||
required-features = ["arbitrary"]
|
||||
required-features = ["arbitrary", "serde"]
|
||||
|
||||
@ -4,9 +4,11 @@ use crate::{version::ParseVersionError, EthMessage, EthVersion};
|
||||
use bytes::{BufMut, Bytes};
|
||||
use reth_codecs::add_arbitrary_tests;
|
||||
use reth_rlp::{Decodable, DecodeError, Encodable, RlpDecodable, RlpEncodable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smol_str::SmolStr;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
use proptest::{
|
||||
arbitrary::{any_with, ParamsFor},
|
||||
@ -14,7 +16,8 @@ use proptest::{
|
||||
};
|
||||
|
||||
/// A Capability message consisting of the message-id and the payload
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct RawCapabilityMessage {
|
||||
/// Identifier of the message.
|
||||
pub id: usize,
|
||||
@ -24,7 +27,8 @@ pub struct RawCapabilityMessage {
|
||||
|
||||
/// Various protocol related event types bubbled up from a session that need to be handled by the
|
||||
/// network.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum CapabilityMessage {
|
||||
/// Eth sub-protocol message.
|
||||
Eth(EthMessage),
|
||||
@ -34,9 +38,8 @@ pub enum CapabilityMessage {
|
||||
|
||||
/// A message indicating a supported capability and capability version.
|
||||
#[add_arbitrary_tests(rlp)]
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize, Default, Hash,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Default, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Capability {
|
||||
/// The name of the subprotocol
|
||||
pub name: SmolStr,
|
||||
|
||||
@ -3,13 +3,16 @@
|
||||
use bytes::Buf;
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_rlp::{Decodable, DecodeError, Encodable, Header};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// RLPx disconnect reason.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum DisconnectReason {
|
||||
/// Disconnect requested by the local node or remote peer.
|
||||
#[default]
|
||||
|
||||
@ -2,6 +2,8 @@ use crate::{capability::Capability, EthVersion, ProtocolVersion};
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::PeerId;
|
||||
use reth_rlp::{RlpDecodable, RlpEncodable};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The client version: `reth/v{major}.{minor}.{patch}`
|
||||
@ -11,7 +13,8 @@ pub(crate) const DEFAULT_CLIENT_VERSION: &str = concat!("reth/v", env!("CARGO_PK
|
||||
/// Message used in the `p2p` handshake, containing information about the supported RLPx protocol
|
||||
/// version and capabilities.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct HelloMessage {
|
||||
/// The version of the `p2p` protocol.
|
||||
pub protocol_version: ProtocolVersion,
|
||||
|
||||
@ -11,7 +11,6 @@ use metrics::counter;
|
||||
use pin_project::pin_project;
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_rlp::{Decodable, DecodeError, Encodable, EMPTY_LIST_CODE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{BTreeSet, HashMap, HashSet, VecDeque},
|
||||
io,
|
||||
@ -21,6 +20,9 @@ use std::{
|
||||
};
|
||||
use tokio_stream::Stream;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// [`MAX_PAYLOAD_SIZE`] is the maximum size of an uncompressed message payload.
|
||||
/// This is defined in [EIP-706](https://eips.ethereum.org/EIPS/eip-706).
|
||||
const MAX_PAYLOAD_SIZE: usize = 16 * 1024 * 1024;
|
||||
@ -615,7 +617,8 @@ pub fn set_capability_offsets(
|
||||
|
||||
/// This represents only the reserved `p2p` subprotocol messages.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum P2PMessage {
|
||||
/// The first packet sent over the connection, and sent once by both sides.
|
||||
Hello(HelloMessage),
|
||||
@ -747,7 +750,8 @@ impl TryFrom<u8> for P2PMessageID {
|
||||
|
||||
/// RLPx `p2p` protocol version
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum ProtocolVersion {
|
||||
/// `p2p` version 4
|
||||
V4 = 4,
|
||||
|
||||
@ -4,6 +4,8 @@ use super::RawBlockBody;
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{BlockHashOrNumber, Header, HeadersDirection, TransactionSigned, H256};
|
||||
use reth_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A request for a peer to return block headers starting at the requested block.
|
||||
@ -16,9 +18,8 @@ use serde::{Deserialize, Serialize};
|
||||
/// If the [`skip`](#structfield.skip) field is non-zero, the peer must skip that amount of headers
|
||||
/// in the direction specified by [`reverse`](#structfield.reverse).
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Copy, Clone, Debug, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable, Serialize, Deserialize,
|
||||
)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GetBlockHeaders {
|
||||
/// The block number or hash that the peer should start returning headers from.
|
||||
pub start_block: BlockHashOrNumber,
|
||||
@ -38,17 +39,8 @@ pub struct GetBlockHeaders {
|
||||
|
||||
/// The response to [`GetBlockHeaders`], containing headers if any headers were found.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct BlockHeaders(
|
||||
/// The requested headers.
|
||||
pub Vec<Header>,
|
||||
@ -62,17 +54,8 @@ impl From<Vec<Header>> for BlockHeaders {
|
||||
|
||||
/// A request for a peer to return block bodies for the given block hashes.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GetBlockBodies(
|
||||
/// The block hashes to request bodies for.
|
||||
pub Vec<H256>,
|
||||
@ -87,9 +70,8 @@ impl From<Vec<H256>> for GetBlockBodies {
|
||||
// TODO(onbjerg): We should have this type in primitives
|
||||
/// A response to [`GetBlockBodies`], containing bodies if any bodies were found.
|
||||
#[derive_arbitrary(rlp, 10)]
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize, Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct BlockBody {
|
||||
/// Transactions in the block
|
||||
pub transactions: Vec<TransactionSigned>,
|
||||
@ -111,17 +93,8 @@ impl BlockBody {
|
||||
/// The response to [`GetBlockBodies`], containing the block bodies that the peer knows about if
|
||||
/// any were found.
|
||||
#[derive_arbitrary(rlp, 1)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct BlockBodies(
|
||||
/// The requested block bodies, each of which should correspond to a hash in the request.
|
||||
pub Vec<BlockBody>,
|
||||
|
||||
@ -2,22 +2,15 @@
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{Header, TransactionSigned, H256, U128};
|
||||
use reth_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// This informs peers of new blocks that have appeared on the network.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct NewBlockHashes(
|
||||
/// New block hashes and the block number for each blockhash.
|
||||
/// Clients should request blocks using a [`GetBlockBodies`](crate::GetBlockBodies) message.
|
||||
@ -40,9 +33,8 @@ impl NewBlockHashes {
|
||||
|
||||
/// A block hash _and_ a block number.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize, Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct BlockHashNumber {
|
||||
/// The block hash
|
||||
pub hash: H256,
|
||||
@ -64,9 +56,8 @@ impl From<NewBlockHashes> for Vec<BlockHashNumber> {
|
||||
|
||||
/// A block body, including transactions and uncle headers.
|
||||
#[derive_arbitrary(rlp, 25)]
|
||||
#[derive(
|
||||
Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable, Serialize, Deserialize,
|
||||
)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct RawBlockBody {
|
||||
/// This block's header
|
||||
pub header: Header,
|
||||
@ -79,9 +70,8 @@ pub struct RawBlockBody {
|
||||
/// A new block with the current total difficulty, which includes the difficulty of the returned
|
||||
/// block.
|
||||
#[derive_arbitrary(rlp, 25)]
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize, Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct NewBlock {
|
||||
/// A new block.
|
||||
pub block: RawBlockBody,
|
||||
@ -92,17 +82,8 @@ pub struct NewBlock {
|
||||
/// This informs peers of transactions that have appeared on the network and are not yet included
|
||||
/// in a block.
|
||||
#[derive_arbitrary(rlp, 10)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Transactions(
|
||||
/// New transactions for the peer to include in its mempool.
|
||||
pub Vec<TransactionSigned>,
|
||||
@ -134,17 +115,8 @@ pub struct SharedTransactions(
|
||||
/// This informs peers of transaction hashes for transactions that have appeared on the network,
|
||||
/// but have not been included in a block.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct NewPooledTransactionHashes(
|
||||
/// Transaction hashes for new transactions that have appeared on the network.
|
||||
/// Clients should request the transactions with the given hashes using a
|
||||
|
||||
@ -7,11 +7,14 @@ use super::{
|
||||
use crate::SharedTransactions;
|
||||
use bytes::{Buf, BufMut};
|
||||
use reth_rlp::{length_of_length, Decodable, Encodable, Header};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An `eth` protocol message, containing a message ID and payload.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct ProtocolMessage {
|
||||
pub message_type: EthMessageID,
|
||||
pub message: EthMessage,
|
||||
@ -140,7 +143,8 @@ impl From<EthBroadcastMessage> for ProtocolBroadcastMessage {
|
||||
///
|
||||
/// The newer `eth/66` is an efficiency upgrade on top of `eth/65`, introducing a request id to
|
||||
/// correlate request-response message pairs. This allows for request multiplexing.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum EthMessage {
|
||||
/// Status is required for the protocol handshake
|
||||
Status(Status),
|
||||
@ -270,7 +274,8 @@ impl Encodable for EthBroadcastMessage {
|
||||
|
||||
/// Represents message IDs for eth protocol messages.
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum EthMessageID {
|
||||
Status = 0x00,
|
||||
NewBlockHashes = 0x01,
|
||||
@ -352,7 +357,8 @@ impl TryFrom<usize> for EthMessageID {
|
||||
/// This is used for all request-response style `eth` protocol messages.
|
||||
/// This can represent either a request or a response, since both include a message payload and
|
||||
/// request id.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct RequestPair<T> {
|
||||
/// id for the contained request or response message
|
||||
pub request_id: u64,
|
||||
|
||||
@ -2,21 +2,14 @@
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{Receipt, H256};
|
||||
use reth_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A request for transaction receipts from the given block hashes.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GetReceipts(
|
||||
/// The block hashes to request receipts for.
|
||||
pub Vec<H256>,
|
||||
@ -25,17 +18,8 @@ pub struct GetReceipts(
|
||||
/// The response to [`GetReceipts`], containing receipt lists that correspond to each block
|
||||
/// requested.
|
||||
#[derive_arbitrary(rlp, 1)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Receipts(
|
||||
/// Each receipt hash should correspond to a block hash in the request.
|
||||
pub Vec<Vec<Receipt>>,
|
||||
|
||||
@ -2,23 +2,16 @@
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{Bytes, H256};
|
||||
use reth_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A request for state tree nodes corresponding to the given hashes.
|
||||
/// This message was removed in `eth/67`, only clients running `eth/66` or earlier will respond to
|
||||
/// this message.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GetNodeData(pub Vec<H256>);
|
||||
|
||||
/// The response to [`GetNodeData`], containing the state tree nodes or contract bytecode
|
||||
@ -27,17 +20,8 @@ pub struct GetNodeData(pub Vec<H256>);
|
||||
/// Not all nodes are guaranteed to be returned by the peer.
|
||||
/// This message was removed in `eth/67`.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct NodeData(pub Vec<Bytes>);
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -4,16 +4,19 @@ use ethers_core::utils::Genesis;
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{Chain, ChainSpec, ForkId, Hardfork, Head, H256, MAINNET, U256};
|
||||
use reth_rlp::{RlpDecodable, RlpEncodable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The status message is used in the eth protocol handshake to ensure that peers are on the same
|
||||
/// network and are following the same fork.
|
||||
///
|
||||
/// When performing a handshake, the total difficulty is not guaranteed to correspond to the block
|
||||
/// hash. This information should be treated as untrusted.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Status {
|
||||
/// The current protocol version. For example, peers running `eth/66` would have a version of
|
||||
/// 66.
|
||||
|
||||
@ -2,21 +2,14 @@
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{TransactionSigned, H256};
|
||||
use reth_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A list of transaction hashes that the peer would like transaction bodies for.
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GetPooledTransactions(
|
||||
/// The transaction hashes to request transaction bodies for.
|
||||
pub Vec<H256>,
|
||||
@ -39,17 +32,8 @@ where
|
||||
/// corresponds to a requested hash. Hashes may need to be re-requested if the bodies are not
|
||||
/// included in the response.
|
||||
#[derive_arbitrary(rlp, 10)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RlpEncodableWrapper,
|
||||
RlpDecodableWrapper,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct PooledTransactions(
|
||||
/// The transaction bodies, each of which should correspond to a requested hash.
|
||||
pub Vec<TransactionSigned>,
|
||||
|
||||
Reference in New Issue
Block a user