From 022b3ac29c239404a664d4e16044fdce4362c1c6 Mon Sep 17 00:00:00 2001 From: Mihir Wadekar Date: Wed, 21 Jan 2026 16:33:12 -0800 Subject: [PATCH] feat: Collects flashbot metrics during execution We now collect aggregated (by block) flashblock metrics --- runner/clients/baserethnode/metrics.go | 40 ++++++++++++++++++++------ runner/clients/reth/metrics.go | 40 ++++++++++++++++++++------ runner/network/types/types.go | 29 +++++++++++++------ 3 files changed, 84 insertions(+), 25 deletions(-) diff --git a/runner/clients/baserethnode/metrics.go b/runner/clients/baserethnode/metrics.go index 6b13a65..872a2d1 100644 --- a/runner/clients/baserethnode/metrics.go +++ b/runner/clients/baserethnode/metrics.go @@ -40,14 +40,38 @@ func (r *metricsCollector) GetMetrics() []metrics.BlockMetrics { func (r *metricsCollector) GetMetricTypes() map[string]bool { return map[string]bool{ - "reth_sync_execution_execution_duration": true, - "reth_sync_block_validation_state_root_duration": true, - "reth_sync_state_provider_storage_fetch_latency": true, - "reth_sync_state_provider_account_fetch_latency": true, - "reth_sync_state_provider_code_fetch_latency": true, - "reth_sync_state_provider_total_storage_fetch_latency": true, - "reth_sync_state_provider_total_account_fetch_latency": true, - "reth_sync_state_provider_total_code_fetch_latency": true, + "reth_sync_execution_execution_duration": true, + "reth_sync_block_validation_state_root_duration": true, + "reth_sync_state_provider_storage_fetch_latency": true, + "reth_sync_state_provider_account_fetch_latency": true, + "reth_sync_state_provider_code_fetch_latency": true, + "reth_sync_state_provider_total_storage_fetch_latency": true, + "reth_sync_state_provider_total_account_fetch_latency": true, + "reth_sync_state_provider_total_code_fetch_latency": true, + "reth_flashblocks_upstream_errors": true, + "reth_flashblocks_upstream_messages": true, + "reth_flashblocks_block_processing_duration": true, + "reth_flashblocks_sender_recovery_duration": true, + "reth_flashblocks_unexpected_block_order": true, + "reth_flashblocks_flashblocks_in_block": true, + "reth_flashblocks_block_processing_error": true, + "reth_flashblocks_pending_clear_catchup": true, + "reth_flashblocks_pending_clear_reorg": true, + "reth_flashblocks_pending_snapshot_fb_index": true, + "reth_flashblocks_pending_snapshot_height": true, + "reth_flashblocks_reconnect_attempts": true, + "reth_flashblocks_rpc_get_transaction_count": true, + "reth_flashblocks_rpc_get_transaction_receipt": true, + "reth_flashblocks_rpc_get_transaction_by_hash": true, + "reth_flashblocks_rpc_get_balance": true, + "reth_flashblocks_rpc_get_block_by_number": true, + "reth_flashblocks_rpc_call": true, + "reth_flashblocks_rpc_estimate_gas": true, + "reth_flashblocks_rpc_simulate_v1": true, + "reth_flashblocks_rpc_get_logs": true, + "reth_flashblocks_rpc_get_block_transaction_count_by_number": true, + "reth_flashblocks_bundle_state_clone_duration": true, + "reth_flashblocks_bundle_state_clone_size": true, } } diff --git a/runner/clients/reth/metrics.go b/runner/clients/reth/metrics.go index 4cf17d2..d64d5e1 100644 --- a/runner/clients/reth/metrics.go +++ b/runner/clients/reth/metrics.go @@ -40,14 +40,38 @@ func (r *metricsCollector) GetMetrics() []metrics.BlockMetrics { func (r *metricsCollector) GetMetricTypes() map[string]bool { return map[string]bool{ - "reth_sync_execution_execution_duration": true, - "reth_sync_block_validation_state_root_duration": true, - "reth_sync_state_provider_storage_fetch_latency": true, - "reth_sync_state_provider_account_fetch_latency": true, - "reth_sync_state_provider_code_fetch_latency": true, - "reth_sync_state_provider_total_storage_fetch_latency": true, - "reth_sync_state_provider_total_account_fetch_latency": true, - "reth_sync_state_provider_total_code_fetch_latency": true, + "reth_sync_execution_execution_duration": true, + "reth_sync_block_validation_state_root_duration": true, + "reth_sync_state_provider_storage_fetch_latency": true, + "reth_sync_state_provider_account_fetch_latency": true, + "reth_sync_state_provider_code_fetch_latency": true, + "reth_sync_state_provider_total_storage_fetch_latency": true, + "reth_sync_state_provider_total_account_fetch_latency": true, + "reth_sync_state_provider_total_code_fetch_latency": true, + "reth_flashblocks_upstream_errors": true, + "reth_flashblocks_upstream_messages": true, + "reth_flashblocks_block_processing_duration": true, + "reth_flashblocks_sender_recovery_duration": true, + "reth_flashblocks_unexpected_block_order": true, + "reth_flashblocks_flashblocks_in_block": true, + "reth_flashblocks_block_processing_error": true, + "reth_flashblocks_pending_clear_catchup": true, + "reth_flashblocks_pending_clear_reorg": true, + "reth_flashblocks_pending_snapshot_fb_index": true, + "reth_flashblocks_pending_snapshot_height": true, + "reth_flashblocks_reconnect_attempts": true, + "reth_flashblocks_rpc_get_transaction_count": true, + "reth_flashblocks_rpc_get_transaction_receipt": true, + "reth_flashblocks_rpc_get_transaction_by_hash": true, + "reth_flashblocks_rpc_get_balance": true, + "reth_flashblocks_rpc_get_block_by_number": true, + "reth_flashblocks_rpc_call": true, + "reth_flashblocks_rpc_estimate_gas": true, + "reth_flashblocks_rpc_simulate_v1": true, + "reth_flashblocks_rpc_get_logs": true, + "reth_flashblocks_rpc_get_block_transaction_count_by_number": true, + "reth_flashblocks_bundle_state_clone_duration": true, + "reth_flashblocks_bundle_state_clone_size": true, } } diff --git a/runner/network/types/types.go b/runner/network/types/types.go index b9f45bd..63f8241 100644 --- a/runner/network/types/types.go +++ b/runner/network/types/types.go @@ -134,13 +134,18 @@ func getAverage(metrics []metrics.BlockMetrics, metricName string) float64 { } const ( - UpdateForkChoiceLatencyMetric = "latency/update_fork_choice" - NewPayloadLatencyMetric = "latency/new_payload" - GetPayloadLatencyMetric = "latency/get_payload" - SendTxsLatencyMetric = "latency/send_txs" - GasPerBlockMetric = "gas/per_block" - GasPerSecondMetric = "gas/per_second" - TransactionsPerBlockMetric = "transactions/per_block" + UpdateForkChoiceLatencyMetric = "latency/update_fork_choice" + NewPayloadLatencyMetric = "latency/new_payload" + GetPayloadLatencyMetric = "latency/get_payload" + SendTxsLatencyMetric = "latency/send_txs" + GasPerBlockMetric = "gas/per_block" + GasPerSecondMetric = "gas/per_second" + TransactionsPerBlockMetric = "transactions/per_block" + FlashblockProcessingDurationMetric = "reth_flashblocks_block_processing_duration" + FlashblockSenderRecoveryMetric = "reth_flashblocks_sender_recovery_duration" + FlashblocksInBlockMetric = "reth_flashblocks_flashblocks_in_block" + FlashblockUpstreamMessagesMetric = "reth_flashblocks_upstream_messages" + FlashblockBundleStateCloneDuration = "reth_flashblocks_bundle_state_clone_duration" ) type SequencerKeyMetrics struct { @@ -152,7 +157,9 @@ type SequencerKeyMetrics struct { type ValidatorKeyMetrics struct { CommonKeyMetrics - AverageNewPayloadLatency float64 `json:"newPayload"` + AverageNewPayloadLatency float64 `json:"newPayload"` + AverageFlashblockProcessingDuration float64 `json:"flashblockProcessingDuration,omitempty"` + AverageFlashblocksInBlock float64 `json:"flashblocksInBlock,omitempty"` } type CommonKeyMetrics struct { @@ -163,9 +170,13 @@ type CommonKeyMetrics struct { func BlockMetricsToValidatorSummary(metrics []metrics.BlockMetrics) *ValidatorKeyMetrics { averageNewPayloadLatency := getAverage(metrics, NewPayloadLatencyMetric) averageGasPerSecond := getAverage(metrics, GasPerSecondMetric) + averageFlashblockProcessingDuration := getAverage(metrics, FlashblockProcessingDurationMetric) + averageFlashblocksInBlock := getAverage(metrics, FlashblocksInBlockMetric) return &ValidatorKeyMetrics{ - AverageNewPayloadLatency: averageNewPayloadLatency, + AverageNewPayloadLatency: averageNewPayloadLatency, + AverageFlashblockProcessingDuration: averageFlashblockProcessingDuration, + AverageFlashblocksInBlock: averageFlashblocksInBlock, CommonKeyMetrics: CommonKeyMetrics{ AverageGasPerSecond: averageGasPerSecond, },