reth_node_core/cli/config.rs
1//! Config traits for various node components.
2
3use alloy_primitives::Bytes;
4use reth_network::{protocol::IntoRlpxSubProtocol, NetworkPrimitives};
5use reth_transaction_pool::PoolConfig;
6use std::{borrow::Cow, time::Duration};
7
8/// A trait that provides payload builder settings.
9///
10/// This provides all basic payload builder settings and is implemented by the
11/// [`PayloadBuilderArgs`](crate::args::PayloadBuilderArgs) type.
12pub trait PayloadBuilderConfig {
13 /// Block extra data set by the payload builder.
14 fn extra_data(&self) -> Cow<'_, str>;
15
16 /// Returns the extra data as bytes.
17 fn extra_data_bytes(&self) -> Bytes {
18 self.extra_data().as_bytes().to_vec().into()
19 }
20
21 /// The interval at which the job should build a new payload after the last.
22 fn interval(&self) -> Duration;
23
24 /// The deadline for when the payload builder job should resolve.
25 fn deadline(&self) -> Duration;
26
27 /// Target gas limit for built blocks.
28 fn gas_limit(&self) -> u64;
29
30 /// Maximum number of tasks to spawn for building a payload.
31 fn max_payload_tasks(&self) -> usize;
32}
33
34/// A trait that represents the configured network and can be used to apply additional configuration
35/// to the network.
36pub trait RethNetworkConfig {
37 /// Adds a new additional protocol to the `RLPx` sub-protocol list.
38 ///
39 /// These additional protocols are negotiated during the `RLPx` handshake.
40 /// If both peers share the same protocol, the corresponding handler will be included alongside
41 /// the `eth` protocol.
42 ///
43 /// See also [`ProtocolHandler`](reth_network::protocol::ProtocolHandler)
44 fn add_rlpx_sub_protocol(&mut self, protocol: impl IntoRlpxSubProtocol);
45
46 /// Returns the secret key used for authenticating sessions.
47 fn secret_key(&self) -> secp256k1::SecretKey;
48
49 // TODO add more network config methods here
50}
51
52impl<N: NetworkPrimitives> RethNetworkConfig for reth_network::NetworkManager<N> {
53 fn add_rlpx_sub_protocol(&mut self, protocol: impl IntoRlpxSubProtocol) {
54 Self::add_rlpx_sub_protocol(self, protocol);
55 }
56
57 fn secret_key(&self) -> secp256k1::SecretKey {
58 Self::secret_key(self)
59 }
60}
61
62/// A trait that provides all basic config values for the transaction pool and is implemented by the
63/// [`TxPoolArgs`](crate::args::TxPoolArgs) type.
64pub trait RethTransactionPoolConfig {
65 /// Returns transaction pool configuration.
66 fn pool_config(&self) -> PoolConfig;
67}