mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: remove default receipts for network components (#13371)
This commit is contained in:
@ -223,7 +223,11 @@ pub enum EthMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
|
|||||||
/// Represents a `GetReceipts` request-response pair.
|
/// Represents a `GetReceipts` request-response pair.
|
||||||
GetReceipts(RequestPair<GetReceipts>),
|
GetReceipts(RequestPair<GetReceipts>),
|
||||||
/// Represents a Receipts request-response pair.
|
/// Represents a Receipts request-response pair.
|
||||||
Receipts(RequestPair<Receipts>),
|
#[cfg_attr(
|
||||||
|
feature = "serde",
|
||||||
|
serde(bound = "N::Receipt: serde::Serialize + serde::de::DeserializeOwned")
|
||||||
|
)]
|
||||||
|
Receipts(RequestPair<Receipts<N::Receipt>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: NetworkPrimitives> EthMessage<N> {
|
impl<N: NetworkPrimitives> EthMessage<N> {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
//! Abstraction over primitive types in network messages.
|
//! Abstraction over primitive types in network messages.
|
||||||
|
|
||||||
|
use alloy_consensus::{RlpDecodableReceipt, RlpEncodableReceipt, TxReceipt};
|
||||||
use alloy_rlp::{Decodable, Encodable};
|
use alloy_rlp::{Decodable, Encodable};
|
||||||
use reth_primitives_traits::{Block, BlockBody, BlockHeader, SignedTransaction};
|
use reth_primitives_traits::{Block, BlockBody, BlockHeader, SignedTransaction};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
@ -30,15 +31,12 @@ pub trait NetworkPrimitives:
|
|||||||
type PooledTransaction: SignedTransaction + TryFrom<Self::BroadcastedTransaction> + 'static;
|
type PooledTransaction: SignedTransaction + TryFrom<Self::BroadcastedTransaction> + 'static;
|
||||||
|
|
||||||
/// The transaction type which peers return in `GetReceipts` messages.
|
/// The transaction type which peers return in `GetReceipts` messages.
|
||||||
type Receipt: Encodable
|
type Receipt: TxReceipt
|
||||||
|
+ RlpEncodableReceipt
|
||||||
|
+ RlpDecodableReceipt
|
||||||
|
+ Encodable
|
||||||
+ Decodable
|
+ Decodable
|
||||||
+ Send
|
|
||||||
+ Sync
|
|
||||||
+ Unpin
|
+ Unpin
|
||||||
+ Clone
|
|
||||||
+ Debug
|
|
||||||
+ PartialEq
|
|
||||||
+ Eq
|
|
||||||
+ 'static;
|
+ 'static;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -225,7 +225,7 @@ pub enum PeerRequest<N: NetworkPrimitives = EthNetworkPrimitives> {
|
|||||||
/// The request for receipts.
|
/// The request for receipts.
|
||||||
request: GetReceipts,
|
request: GetReceipts,
|
||||||
/// The channel to send the response for receipts.
|
/// The channel to send the response for receipts.
|
||||||
response: oneshot::Sender<RequestResult<Receipts>>,
|
response: oneshot::Sender<RequestResult<Receipts<N::Receipt>>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,7 @@ where
|
|||||||
impl<C, N> NetworkConfig<C, N>
|
impl<C, N> NetworkConfig<C, N>
|
||||||
where
|
where
|
||||||
N: NetworkPrimitives,
|
N: NetworkPrimitives,
|
||||||
C: BlockReader<Block = N::Block, Receipt = reth_primitives::Receipt, Header = N::BlockHeader>
|
C: BlockReader<Block = N::Block, Receipt = N::Receipt, Header = N::BlockHeader>
|
||||||
+ HeaderProvider
|
+ HeaderProvider
|
||||||
+ Clone
|
+ Clone
|
||||||
+ Unpin
|
+ Unpin
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use crate::{
|
|||||||
budget::DEFAULT_BUDGET_TRY_DRAIN_DOWNLOADERS, metered_poll_nested_stream_with_budget,
|
budget::DEFAULT_BUDGET_TRY_DRAIN_DOWNLOADERS, metered_poll_nested_stream_with_budget,
|
||||||
metrics::EthRequestHandlerMetrics,
|
metrics::EthRequestHandlerMetrics,
|
||||||
};
|
};
|
||||||
use alloy_consensus::BlockHeader;
|
use alloy_consensus::{BlockHeader, ReceiptWithBloom, TxReceipt};
|
||||||
use alloy_eips::BlockHashOrNumber;
|
use alloy_eips::BlockHashOrNumber;
|
||||||
use alloy_rlp::Encodable;
|
use alloy_rlp::Encodable;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
@ -81,7 +81,7 @@ impl<C, N: NetworkPrimitives> EthRequestHandler<C, N> {
|
|||||||
impl<C, N> EthRequestHandler<C, N>
|
impl<C, N> EthRequestHandler<C, N>
|
||||||
where
|
where
|
||||||
N: NetworkPrimitives,
|
N: NetworkPrimitives,
|
||||||
C: BlockReader + HeaderProvider + ReceiptProvider<Receipt = reth_primitives::Receipt>,
|
C: BlockReader + HeaderProvider + ReceiptProvider<Receipt: Encodable + TxReceipt>,
|
||||||
{
|
{
|
||||||
/// Returns the list of requested headers
|
/// Returns the list of requested headers
|
||||||
fn get_headers_response(&self, request: GetBlockHeaders) -> Vec<C::Header> {
|
fn get_headers_response(&self, request: GetBlockHeaders) -> Vec<C::Header> {
|
||||||
@ -188,7 +188,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
_peer_id: PeerId,
|
_peer_id: PeerId,
|
||||||
request: GetReceipts,
|
request: GetReceipts,
|
||||||
response: oneshot::Sender<RequestResult<Receipts>>,
|
response: oneshot::Sender<RequestResult<Receipts<C::Receipt>>>,
|
||||||
) {
|
) {
|
||||||
self.metrics.eth_receipts_requests_received_total.increment(1);
|
self.metrics.eth_receipts_requests_received_total.increment(1);
|
||||||
|
|
||||||
@ -200,10 +200,8 @@ where
|
|||||||
if let Some(receipts_by_block) =
|
if let Some(receipts_by_block) =
|
||||||
self.client.receipts_by_block(BlockHashOrNumber::Hash(hash)).unwrap_or_default()
|
self.client.receipts_by_block(BlockHashOrNumber::Hash(hash)).unwrap_or_default()
|
||||||
{
|
{
|
||||||
let receipt = receipts_by_block
|
let receipt =
|
||||||
.into_iter()
|
receipts_by_block.into_iter().map(ReceiptWithBloom::from).collect::<Vec<_>>();
|
||||||
.map(|receipt| receipt.with_bloom())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
total_bytes += receipt.length();
|
total_bytes += receipt.length();
|
||||||
receipts.push(receipt);
|
receipts.push(receipt);
|
||||||
@ -226,7 +224,7 @@ where
|
|||||||
impl<C, N> Future for EthRequestHandler<C, N>
|
impl<C, N> Future for EthRequestHandler<C, N>
|
||||||
where
|
where
|
||||||
N: NetworkPrimitives,
|
N: NetworkPrimitives,
|
||||||
C: BlockReader<Block = N::Block, Receipt = reth_primitives::Receipt>
|
C: BlockReader<Block = N::Block, Receipt = N::Receipt>
|
||||||
+ HeaderProvider<Header = N::BlockHeader>
|
+ HeaderProvider<Header = N::BlockHeader>
|
||||||
+ Unpin,
|
+ Unpin,
|
||||||
{
|
{
|
||||||
@ -317,6 +315,6 @@ pub enum IncomingEthRequest<N: NetworkPrimitives = EthNetworkPrimitives> {
|
|||||||
/// The specific receipts requested.
|
/// The specific receipts requested.
|
||||||
request: GetReceipts,
|
request: GetReceipts,
|
||||||
/// The channel sender for the response containing receipts.
|
/// The channel sender for the response containing receipts.
|
||||||
response: oneshot::Sender<RequestResult<Receipts>>,
|
response: oneshot::Sender<RequestResult<Receipts<N::Receipt>>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ pub enum PeerResponse<N: NetworkPrimitives = EthNetworkPrimitives> {
|
|||||||
/// Represents a response to a request for receipts.
|
/// Represents a response to a request for receipts.
|
||||||
Receipts {
|
Receipts {
|
||||||
/// The receiver channel for the response to a receipts request.
|
/// The receiver channel for the response to a receipts request.
|
||||||
response: oneshot::Receiver<RequestResult<Receipts>>,
|
response: oneshot::Receiver<RequestResult<Receipts<N::Receipt>>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ pub enum PeerResponseResult<N: NetworkPrimitives = EthNetworkPrimitives> {
|
|||||||
/// Represents a result containing node data or an error.
|
/// Represents a result containing node data or an error.
|
||||||
NodeData(RequestResult<Vec<Bytes>>),
|
NodeData(RequestResult<Vec<Bytes>>),
|
||||||
/// Represents a result containing receipts or an error.
|
/// Represents a result containing receipts or an error.
|
||||||
Receipts(RequestResult<Vec<Vec<ReceiptWithBloom<reth_primitives::Receipt>>>>),
|
Receipts(RequestResult<Vec<Vec<ReceiptWithBloom<N::Receipt>>>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// === impl PeerResponseResult ===
|
// === impl PeerResponseResult ===
|
||||||
|
|||||||
@ -662,11 +662,8 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
|||||||
>,
|
>,
|
||||||
> + Unpin
|
> + Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
Node::Provider: BlockReader<
|
Node::Provider:
|
||||||
Receipt = reth_primitives::Receipt,
|
BlockReader<Receipt = N::Receipt, Block = N::Block, Header = N::BlockHeader>,
|
||||||
Block = N::Block,
|
|
||||||
Header = N::BlockHeader,
|
|
||||||
>,
|
|
||||||
{
|
{
|
||||||
self.start_network_with(builder, pool, Default::default())
|
self.start_network_with(builder, pool, Default::default())
|
||||||
}
|
}
|
||||||
@ -692,11 +689,8 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
|||||||
>,
|
>,
|
||||||
> + Unpin
|
> + Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
Node::Provider: BlockReader<
|
Node::Provider:
|
||||||
Receipt = reth_primitives::Receipt,
|
BlockReader<Receipt = N::Receipt, Block = N::Block, Header = N::BlockHeader>,
|
||||||
Block = N::Block,
|
|
||||||
Header = N::BlockHeader,
|
|
||||||
>,
|
|
||||||
{
|
{
|
||||||
let (handle, network, txpool, eth) = builder
|
let (handle, network, txpool, eth) = builder
|
||||||
.transactions(pool, tx_config)
|
.transactions(pool, tx_config)
|
||||||
|
|||||||
Reference in New Issue
Block a user