Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ tmp/

# Output directory
out/
data/
logs/
storage/
36 changes: 36 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"context"
"fmt"
"time"

"github.com/keep-network/keep-core/pkg/tbtcpg"

"github.com/keep-network/keep-common/pkg/persistence"
Expand Down Expand Up @@ -87,6 +89,23 @@ func start(cmd *cobra.Command) error {
blockCounter,
)

// Wire performance metrics into network provider if available
var perfMetrics *clientinfo.PerformanceMetrics
if clientInfoRegistry != nil {
perfMetrics = clientinfo.NewPerformanceMetrics(clientInfoRegistry)
// Type assert to libp2p provider to set metrics recorder
// The provider struct is not exported, so we use interface assertion
if setter, ok := netProvider.(interface {
SetMetricsRecorder(recorder interface {
IncrementCounter(name string, value float64)
SetGauge(name string, value float64)
RecordDuration(name string, duration time.Duration)
})
}); ok {
setter.SetMetricsRecorder(perfMetrics)
}
}

// Initialize beacon and tbtc only for non-bootstrap nodes.
// Skip initialization for bootstrap nodes as they are only used for network
// discovery.
Expand All @@ -106,13 +125,28 @@ func start(cmd *cobra.Command) error {

scheduler := generator.StartScheduler()

// Observe Bitcoin connectivity (for backward compatibility)
// Note: RPC health checker also tracks this with more comprehensive checks
clientInfoRegistry.ObserveBtcConnectivity(
btcChain,
clientConfig.ClientInfo.BitcoinMetricsTick,
)

clientInfoRegistry.RegisterBtcChainInfoSource(btcChain)

// Start RPC health checker for Ethereum and Bitcoin RPC endpoints
// This makes actual RPC calls (not just ICMP ping) to verify services are working
if clientInfoRegistry != nil {
rpcHealthChecker := clientinfo.NewRPCHealthChecker(
clientInfoRegistry,
blockCounter,
btcChain,
clientConfig.ClientInfo.RPCHealthCheckInterval,
clientConfig.ClientInfo.RPCHealthCheckTimeout,
)
rpcHealthChecker.Start(ctx)
}

err = beacon.Initialize(
ctx,
beaconChain,
Expand Down Expand Up @@ -220,6 +254,8 @@ func initializeClientInfo(
config.ClientInfo.NetworkMetricsTick,
)

// Observe Ethereum connectivity (for backward compatibility)
// Note: RPC health checker also tracks this with more comprehensive checks
registry.ObserveEthConnectivity(
blockCounter,
config.ClientInfo.EthereumMetricsTick,
Expand Down
Loading
Loading