The evmRpcLatencyWatcher subscribes to RPC endpoints via WebSocket and measures when blocks arrive at the Portal versus when they appear at the RPC endpoints.
The measured values include client-side network latency. For RPC endpoints, only the arrival time of blocks is measured. This does not capture the node’s internal processing or response latency if queried directly. Results represent end-to-end delays as experienced by the client, not pure Portal or RPC processing performance.
Pass the watcher as the source output. You can chain a .pipe() transform to it, for example to expose the measurements as Prometheus metrics:
Each batch carries an array of samples: the ones that became decidable in that batch. A sample is decidable once both the Portal and the RPC endpoints have reported it, or once the wait window set by resolveTimeoutMs closes. It defaults to 60 seconds.
Each sample includes:
number / timestamp: the observed block and its timestamp
portal.receivedAt: when the block arrived from the Portal
rpc: one entry per configured RPC endpoint:
url: RPC endpoint URL
receivedAt: when the RPC endpoint received the block
hash: block hash as seen by the RPC
portalDelayMs: signed milliseconds between RPC arrival and Portal availability. A negative value means the Portal delivered the block first
unresolved: set when the endpoint did not report the block, in which case receivedAt and portalDelayMs are absent
An endpoint that did not report the block is rpc-behind when it had not reached the block before the window closed, and rpc-missing when it is already past the block but never reported it. Count these entries rather than charting them. A missing delay is not zero.
portalDelayMs can be negative. If you feed these values into a histogram, revisit the buckets and any max(0, ...) clamping, or every Portal lead folds back into the zero bucket.
The Prometheus gauge registered in the .pipe() transform above is served on the metricsServer() port, http://localhost:9090/metrics in this example. See the Metrics guide for details on custom metrics.