From c7152ee9fae763d6d4fb9a88d069d62a53ded548 Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Wed, 29 Jan 2025 01:50:26 -0800 Subject: [PATCH] feat(rpc/validation): Expose metric for validation disallow list size. (#14057) Co-authored-by: Matthias Seitz --- Cargo.lock | 1 + crates/rpc/rpc/Cargo.toml | 1 + crates/rpc/rpc/src/validation.rs | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index bef93960c..09ac2d8a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8748,6 +8748,7 @@ dependencies = [ "reth-errors", "reth-evm", "reth-evm-ethereum", + "reth-metrics", "reth-network-api", "reth-network-peers", "reth-network-types", diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 54ba3a1b9..255656a9c 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -20,6 +20,7 @@ reth-rpc-api.workspace = true reth-rpc-eth-api.workspace = true reth-engine-primitives.workspace = true reth-errors.workspace = true +reth-metrics.workspace = true reth-provider.workspace = true reth-transaction-pool.workspace = true reth-network-api.workspace = true diff --git a/crates/rpc/rpc/src/validation.rs b/crates/rpc/rpc/src/validation.rs index cbf240dd7..787ad53d9 100644 --- a/crates/rpc/rpc/src/validation.rs +++ b/crates/rpc/rpc/src/validation.rs @@ -17,6 +17,7 @@ use reth_consensus::{Consensus, FullConsensus, PostExecutionInput}; use reth_engine_primitives::PayloadValidator; use reth_errors::{BlockExecutionError, ConsensusError, ProviderError}; use reth_evm::execute::{BlockExecutorProvider, Executor}; +use reth_metrics::{metrics, metrics::Gauge, Metrics}; use reth_primitives::{GotExpected, NodePrimitives, RecoveredBlock, SealedHeader}; use reth_primitives_traits::{constants::GAS_LIMIT_BOUND_DIVISOR, BlockBody, SealedBlock}; use reth_provider::{BlockExecutionOutput, BlockReaderIdExt, StateProviderFactory}; @@ -62,8 +63,10 @@ where validation_window, cached_state: Default::default(), task_spawner, + metrics: Default::default(), }); + inner.metrics.disallow_size.set(inner.disallow.len() as f64); Self { inner } } @@ -478,6 +481,8 @@ pub struct ValidationApiInner { cached_state: RwLock<(B256, CachedReads)>, /// Task spawner for blocking operations task_spawner: Box, + /// Validation metrics + metrics: ValidationMetrics, } /// Configuration for validation API. @@ -537,3 +542,11 @@ pub enum ValidationApiError { #[error(transparent)] Payload(#[from] PayloadError), } + +/// Metrics for the validation endpoint. +#[derive(Metrics)] +#[metrics(scope = "builder.validation")] +pub(crate) struct ValidationMetrics { + /// The number of entries configured in the builder validation disallow list. + pub(crate) disallow_size: Gauge, +}