Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into alexey/pruner-batch-size
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Aug 21, 2023
2 parents 54a67f6 + 5c88193 commit a560441
Show file tree
Hide file tree
Showing 90 changed files with 2,964 additions and 1,081 deletions.
471 changes: 230 additions & 241 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ reth-net-nat = { path = "../../crates/net/nat" }
reth-payload-builder.workspace = true
reth-basic-payload-builder = { path = "../../crates/payload/basic" }
reth-discv4 = { path = "../../crates/net/discv4" }
reth-metrics.workspace = true
reth-prune = { path = "../../crates/prune" }
reth-trie = { path = "../../crates/trie" }

Expand All @@ -58,9 +57,11 @@ confy = "0.5"
toml = { version = "0.7", features = ["display"] }

# metrics
metrics-exporter-prometheus = "0.11.0"
metrics-util = "0.14.0"
metrics-exporter-prometheus = "0.12.1"
metrics-util = "0.15.0"
metrics-process = "1.0.9"
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# test vectors generation
proptest.workspace = true
Expand Down
9 changes: 7 additions & 2 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ use reth_stages::{
MetricEventsSender, MetricsListener,
};
use reth_tasks::TaskExecutor;
use reth_transaction_pool::{EthTransactionValidator, TransactionPool};
use reth_transaction_pool::{
blobstore::InMemoryBlobStore, TransactionPool, TransactionValidationTaskExecutor,
};
use secp256k1::SecretKey;
use std::{
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
Expand Down Expand Up @@ -262,13 +264,16 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
let factory = ProviderFactory::new(Arc::clone(&db), Arc::clone(&self.chain));
let blockchain_db = BlockchainProvider::new(factory, blockchain_tree.clone())?;

let blob_store = InMemoryBlobStore::default();
let transaction_pool = reth_transaction_pool::Pool::eth_pool(
EthTransactionValidator::with_additional_tasks(
TransactionValidationTaskExecutor::eth_with_additional_tasks(
blockchain_db.clone(),
Arc::clone(&self.chain),
blob_store.clone(),
ctx.task_executor.clone(),
1,
),
blob_store,
self.txpool.pool_config(),
);
info!(target: "reth::cli", "Transaction pool initialized");
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/prometheus_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use hyper::{
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use metrics_util::layers::{PrefixLayer, Stack};
use reth_db::{database::Database, tables, DatabaseEnv};
use reth_metrics::metrics::{self, absolute_counter, describe_counter, Unit};
use reth_metrics::metrics::{absolute_counter, describe_counter, Unit};
use std::{convert::Infallible, net::SocketAddr, sync::Arc};

pub(crate) trait Hook: Fn() + Send + Sync {}
Expand Down
7 changes: 5 additions & 2 deletions crates/blockchain-tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ normal = [
reth-primitives.workspace = true
reth-interfaces.workspace = true
reth-db = { path = "../storage/db" }
reth-metrics = { workspace = true, features = ["common"] }
reth-provider.workspace = true
reth-stages = { path = "../stages" }

Expand All @@ -27,7 +26,11 @@ parking_lot.workspace = true
lru = "0.10"
tracing.workspace = true

# mics
# metrics
reth-metrics = { workspace = true, features = ["common"] }
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# misc
aquamarine = "0.3.0"
linked_hash_set = "0.1.4"

Expand Down
2 changes: 1 addition & 1 deletion crates/blockchain-tree/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use reth_metrics::{
metrics::{self, Counter, Gauge},
metrics::{Counter, Gauge},
Metrics,
};

Expand Down
5 changes: 4 additions & 1 deletion crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ reth-provider.workspace = true
reth-rpc-types.workspace = true
reth-tasks.workspace = true
reth-payload-builder.workspace = true
reth-metrics.workspace = true
reth-prune = { path = "../../prune" }

# async
tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
futures.workspace = true

# metrics
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# misc
tracing.workspace = true
thiserror.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/invalid_headers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use reth_metrics::{
metrics::{self, Counter, Gauge},
metrics::{Counter, Gauge},
Metrics,
};
use reth_primitives::{Header, SealedHeader, H256};
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use reth_metrics::{
metrics::{self, Counter, Gauge, Histogram},
metrics::{Counter, Gauge, Histogram},
Metrics,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "reth metrics utilities"
reth-metrics-derive = { path = "./metrics-derive" }

# metrics
metrics = "0.20.1"
metrics = "0.21.1"

# async
tokio = { workspace = true, features = ["full"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/metrics/metrics-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ regex = "1.6.0"
once_cell = "1.17.0"

[dev-dependencies]
metrics = "0.20.1"
metrics = "0.21.1"
trybuild = "1.0"
serial_test = "0.10"
5 changes: 4 additions & 1 deletion crates/net/downloaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ reth-interfaces.workspace = true
reth-primitives.workspace = true
reth-db = { path = "../../storage/db" }
reth-tasks.workspace = true
reth-metrics.workspace = true

# async
futures.workspace = true
Expand All @@ -24,6 +23,10 @@ tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
tokio-util = { workspace = true, features = ["codec"] }

# metrics
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# misc
tracing.workspace = true
rayon.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/net/downloaders/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use reth_interfaces::p2p::error::DownloadError;
use reth_metrics::{
metrics::{self, Counter, Gauge},
metrics::{Counter, Gauge},
Metrics,
};

Expand Down
3 changes: 3 additions & 0 deletions crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ reth-rlp = { workspace = true, features = [
"ethereum-types",
"smol_str",
] }

# metrics
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# used for Chain and builders
ethers-core = { workspace = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire/src/p2pstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use futures::{Sink, SinkExt, StreamExt};
use pin_project::pin_project;
use reth_codecs::derive_arbitrary;
use reth_metrics::metrics::{self, counter};
use reth_metrics::metrics::counter;
use reth_primitives::{
bytes::{Buf, BufMut, Bytes, BytesMut},
hex,
Expand Down
5 changes: 4 additions & 1 deletion crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ reth-rlp-derive = { path = "../../rlp/rlp-derive" }
reth-tasks.workspace = true
reth-transaction-pool.workspace = true
reth-provider.workspace = true
reth-metrics = { workspace = true, features = ["common"] }
reth-rpc-types.workspace = true

# async/futures
Expand All @@ -46,6 +45,10 @@ serde = { workspace = true, optional = true }
humantime-serde = { version = "1.1", optional = true }
serde_json = { workspace = true, optional = true }

# metrics
reth-metrics = { workspace = true, features = ["common"] }
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

# misc
auto_impl = "1"
aquamarine = "0.3.0"
Expand Down
14 changes: 8 additions & 6 deletions crates/net/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ pub struct NetworkConfig<C> {

// === impl NetworkConfig ===

impl<C> NetworkConfig<C> {
/// Create a new instance with all mandatory fields set, rest is field with defaults.
pub fn new(client: C, secret_key: SecretKey) -> Self {
Self::builder(secret_key).build(client)
}

impl NetworkConfig<()> {
/// Convenience method for creating the corresponding builder type
pub fn builder(secret_key: SecretKey) -> NetworkConfigBuilder {
NetworkConfigBuilder::new(secret_key)
}
}

impl<C> NetworkConfig<C> {
/// Create a new instance with all mandatory fields set, rest is field with defaults.
pub fn new(client: C, secret_key: SecretKey) -> Self {
NetworkConfig::builder(secret_key).build(client)
}

/// Sets the config to use for the discovery v4 protocol.
pub fn set_discovery_v4(mut self, discovery_config: Discv4Config) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
//! // The key that's used for encrypting sessions and to identify our node.
//! let local_key = rng_secret_key();
//!
//! let config = NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(
//! let config = NetworkConfig::builder(local_key).boot_nodes(
//! mainnet_nodes()
//! ).build(client);
//!
Expand Down Expand Up @@ -101,7 +101,7 @@
//! let local_key = rng_secret_key();
//!
//! let config =
//! NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
//! NetworkConfig::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
//!
//! // create the network instance
//! let (handle, network, transactions, request_handler) = NetworkManager::builder(config)
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
/// let local_key = rng_secret_key();
///
/// let config =
/// NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
/// NetworkConfig::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
///
/// // create the network instance
/// let (handle, network, transactions, request_handler) = NetworkManager::builder(config)
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use reth_eth_wire::DisconnectReason;
use reth_metrics::{
metrics::{self, Counter, Gauge},
metrics::{Counter, Gauge},
Metrics,
};

Expand Down
12 changes: 11 additions & 1 deletion crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,17 @@ impl PeersInfo for NetworkHandle {

fn local_node_record(&self) -> NodeRecord {
let id = *self.peer_id();
let socket_addr = *self.inner.listener_address.lock();
let mut socket_addr = *self.inner.listener_address.lock();

if socket_addr.ip().is_unspecified() {
// zero address is invalid
if socket_addr.ip().is_ipv4() {
socket_addr.set_ip(std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST));
} else {
socket_addr.set_ip(std::net::IpAddr::V6(std::net::Ipv6Addr::LOCALHOST));
}
}

NodeRecord::new(socket_addr, id)
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/net/network/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ where
response: oneshot::Sender<RequestResult<PooledTransactions>>,
) {
if let Some(peer) = self.peers.get_mut(&peer_id) {
// TODO softResponseLimit 2 * 1024 * 1024
let transactions = self
.pool
.get_all(request.0)
Expand Down Expand Up @@ -237,6 +238,8 @@ where
///
/// The message for new pooled hashes depends on the negotiated version of the stream.
/// See [NewPooledTransactionHashes](NewPooledTransactionHashes)
///
/// TODO add note that this never broadcasts full 4844 transactions
fn propagate_transactions(
&mut self,
to_propagate: Vec<PropagateTransaction>,
Expand Down Expand Up @@ -803,7 +806,7 @@ impl Future for GetPooledTxRequestFut {
struct Peer {
/// Keeps track of transactions that we know the peer has seen.
transactions: LruCache<H256>,
/// A communication channel directly to the session task.
/// A communication channel directly to the peer's session task.
request_tx: PeerRequestSender,
/// negotiated version of the session.
version: EthVersion,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/net/network/tests/it/clique/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod clique;
pub mod clique_middleware;
mod geth;

pub use clique::CliqueGethInstance;
pub use clique_middleware::{CliqueError, CliqueMiddleware, CliqueMiddlewareError};
pub use geth::CliqueGethInstance;
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn can_peer_with_geth() {
"setting up reth networking stack in keepalive test"
);

let config = NetworkConfig::<Arc<NoopProvider>>::builder(secret_key)
let config = NetworkConfig::builder(secret_key)
.listener_addr(reth_p2p)
.discovery_addr(reth_disc)
.chain_spec(chainspec)
Expand Down
5 changes: 4 additions & 1 deletion crates/payload/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ reth-rlp.workspace = true
reth-provider.workspace = true
reth-payload-builder.workspace = true
reth-tasks.workspace = true
reth-metrics.workspace = true

## ethereum
revm.workspace = true
Expand All @@ -27,5 +26,9 @@ tokio = { workspace = true, features = ["sync", "time"] }
futures-core = "0.3"
futures-util.workspace = true

# metrics
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

## misc
tracing.workspace = true
5 changes: 1 addition & 4 deletions crates/payload/basic/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Metrics for the payload builder impl

use reth_metrics::{
metrics::{self, Counter},
Metrics,
};
use reth_metrics::{metrics::Counter, Metrics};

/// Transaction pool metrics
#[derive(Metrics)]
Expand Down
5 changes: 4 additions & 1 deletion crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ reth-rpc-types.workspace = true
reth-rlp.workspace = true
reth-interfaces.workspace = true
reth-revm-primitives = { path = "../../revm/revm-primitives" }
reth-metrics.workspace = true

## ethereum
revm-primitives.workspace = true
Expand All @@ -25,6 +24,10 @@ tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
futures-util.workspace = true

## metrics
reth-metrics.workspace = true
metrics = "0.21.1" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation

## misc
thiserror.workspace = true
sha2 = { version = "0.10", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/payload/builder/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Payload builder service metrics.

use reth_metrics::{
metrics::{self, Counter, Gauge},
metrics::{Counter, Gauge},
Metrics,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ pub use transaction::{
util::secp256k1::{public_key_to_address, recover_signer, sign_message},
AccessList, AccessListItem, AccessListWithGasUsed, BlobTransaction, BlobTransactionSidecar,
FromRecoveredTransaction, IntoRecoveredTransaction, InvalidTransactionError,
PooledTransactionsElement, Signature, Transaction, TransactionKind, TransactionMeta,
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930,
TxEip4844, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID,
LEGACY_TX_TYPE_ID,
PooledTransactionsElement, PooledTransactionsElementEcRecovered, Signature, Transaction,
TransactionKind, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered,
TransactionSignedNoHash, TxEip1559, TxEip2930, TxEip4844, TxLegacy, TxType, EIP1559_TX_TYPE_ID,
EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
};
pub use withdrawal::Withdrawal;

Expand Down
Loading

0 comments on commit a560441

Please sign in to comment.