Skip to content

feat(maintainer): record SPV proof-submission metrics - #4190

Open
piotr-roslaniec wants to merge 3 commits into
chore/code-quality-followupsfrom
feat/maintainer-spv-metrics
Open

feat(maintainer): record SPV proof-submission metrics#4190
piotr-roslaniec wants to merge 3 commits into
chore/code-quality-followupsfrom
feat/maintainer-spv-metrics

Conversation

@piotr-roslaniec

@piotr-roslaniec piotr-roslaniec commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

What

Wires a clientinfo metrics registry + PerformanceMetrics into the maintainer command and threads a real metrics recorder through maintainer.Initialize into the SPV maintainer, so deposit-sweep and redemption proof-submission counters are actually recorded in production.

Why

The SPV proof submitters accept an optional metrics recorder, but the maintainer boot path never built one, so the recorder was always nil and the counters were dead in production. maintainer is the only command that runs the SPV maintainer, so these metrics were never observable.

Changes

  • cmd/maintainer.go: build the client-info registry + PerformanceMetrics (new initializeMaintainerMetrics helper), register baseline client-info + Ethereum sources, and pass the recorder to maintainer.Initialize. The recorder is derived from the client-info registry: when clientInfo.port=0, clientinfo.Initialize reports not-configured and the recorder stays a genuine nil interface (no typed-nil trap), disabling metrics recording.
  • config/category.go: add ClientInfo to MaintainerCategories so the client-info port is parsed for the maintainer command. Because clientInfo.port defaults to 9601 (the same shared flag the node start command uses), the maintainer now serves the client-info metrics/diagnostics endpoint on :9601 by default, consistent with start. Operators who do not want the endpoint can set clientInfo.port=0. See the operator impact note below.
  • pkg/maintainer/maintainer.go: thread spv.MetricsRecorder through Initialize into spv.Initialize.
  • pkg/maintainer/spv: add an exported MetricsRecorder interface; store it on spvMaintainer; extend the transactionProofSubmitter type; forward the recorder (instead of hardcoded nil) at the deposit-sweep and redemption submitters. Moving-funds and moved-funds-sweep submitters accept the recorder to satisfy the type but are not yet instrumented (no counters defined for them).
  • cmd/maintainercli.go: the two manual one-off proof-submit subcommands pass nil (no registry in that path).
  • docs/performance-metrics.adoc: document the six SPV proof-submission counters that this change makes observable in production.

Release note / operator impact

The maintainer command now exposes the client-info metrics/diagnostics HTTP endpoint on port 9601 (all interfaces) by default, matching the behavior of the node start command. The endpoint serves system/process metrics, client version, Ethereum connectivity/latest-block info, and the SPV proof-submission counters. It does not expose the Ethereum operator key or peer/operator identity. Operators who do not want the maintainer to open this endpoint should set clientInfo.port=0 in the ClientInfo config section (or via --clientInfo.port=0).

Tests

  • TestSubmitDepositSweepProof and TestSubmitRedemptionProof thread a real recorder and assert the attempt/success/failure counters fire on the success path.
  • TestSubmitDepositSweepProofRecordsFailureMetrics / TestSubmitRedemptionProofRecordsFailureMetrics cover the attempt+failure counters on the early zero-confirmations reject path.
  • TestSubmitDepositSweepProofRecordsAssembleFailureMetrics / TestSubmitRedemptionProofRecordsAssembleFailureMetrics cover the failed-counter increment on the SPV-proof-assembly error branch.
  • TestInitializeMaintainerMetricsDisabledWhenPortUnset guards the metrics on/off gate: a 0 client-info port yields a nil recorder.

Base / stacking

Based on chore/code-quality-followups (#4187), not main: the param-based recorder seam this PR fills only exists after that PR removed the global metrics singleton. Once #4187 merges, this branch should be rebased --onto main and becomes a standalone change.

The SPV proof submitters accept an optional metrics recorder, but the
maintainer command never built one, so proof-submission counters were
never recorded in production (the recorder was always passed as nil).

Wire a clientinfo registry and PerformanceMetrics into the maintainer
boot path and thread the recorder through maintainer.Initialize into the
SPV maintainer, replacing the hardcoded nil at the deposit sweep and
redemption submitters. Add ClientInfo to the maintainer config
categories so the metrics endpoint port is parsed.

Moving funds and moved funds sweep submitters accept the recorder to
satisfy the submitter type but are not yet instrumented, as those proof
submissions have no metrics counters defined.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f33d298-4a2f-46c8-a9d7-5c5134dff16b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/maintainer-spv-metrics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ilure

Close review gaps on the SPV proof-submission metrics change:

- assert the redemption success-path counters; the success test
  previously passed a nil recorder and asserted nothing, so a
  removed/misplaced success increment would go undetected.
- cover the assemble-error failed-counter branch for both the deposit
  sweep and redemption provers (a realistic production failure mode);
  only the early zero-confirmations reject was asserted before. The
  on-chain-submit branch shares the same guard idiom but the local chain
  double cannot be forced to fail that call.
- add a cmd test for initializeMaintainerMetrics: a 0 client-info port
  yields a nil recorder, guarding the sole production metrics on/off gate
  against an inverted condition.
…ntract

- list the six SPV proof-submission counters in performance-metrics.adoc;
  this change is what makes them observable in production.
- reframe the MetricsRecorder doc as an API contract (callers must treat
  nil as "metrics off" and guard every call) instead of the rot-prone
  "all call sites guard against it" status claim.

@lionakhnazarov lionakhnazarov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants