Skip to content

feat(stellar): wire wraith_metrics into names, splitter, vault, and governance - #171

Merged
truthixify merged 2 commits into
wraith-protocol:developfrom
DSOTec:feat/metrics-wiring-four-contracts
Aug 26, 2026
Merged

feat(stellar): wire wraith_metrics into names, splitter, vault, and governance#171
truthixify merged 2 commits into
wraith-protocol:developfrom
DSOTec:feat/metrics-wiring-four-contracts

Conversation

@DSOTec

@DSOTec DSOTec commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Problem

wraith-metrics defines a v1 metric event schema, but only stealth-sender,
stealth-registry, and stealth-batch-sender emit through it. wraith-names,
stealth-splitter, stealth-vault, and the governance PoC emit nothing, so
METRICS.md has no per-contract tables for them and the Grafana dashboard
renders blank panels.

Solution

  • Added the natural counter/volume metrics to all four contracts, plus the
    matching contract_ids / metric_names / dimension_names constants.
  • Populated the four missing METRICS.md tables and added a symbol table
    mapping each 9-character wire Symbol to its canonical metric name.
  • Added 12 Grafana panels and extended the indexer to watch all seven
    contracts. The indexer previously could not run at all (Server is not
    exported by @stellar/stellar-sdk v12+) and its switch matched canonical
    names against abbreviated wire symbols, so it never matched an event —
    both fixed.
  • Added synthetic-stream.js, which replays a synthetic event stream through
    the parser/aggregator and fails if any dashboard panel would render blank.
  • Recorded optimized wasm size deltas in SIZE.md.

Testing

  • cargo test --workspace: 289 passed, 0 failed. Each of the four contracts
    has integration tests asserting on the emitted event's topics, value, and
    dimensions.
  • cargo fmt --all --check: clean.
  • npm run verify:dashboard: all 22 dashboard metrics have samples.
  • Optimized wasm: splitter +9.68%, vault +20.35%, governance +11.56%.
    wraith_names cannot be built for wasm32 on the pinned soroban-sdk (a
    pre-existing failure that reproduces on develop), so its delta is recorded
    as unmeasurable rather than guessed.

Note for reviewers — bench gate

Metric emission costs a flat +4,164 instructions, which pushes
wraith-names::resolve past the +5% per-op gate (hit +11.91%, miss +17.67%;
register lands at +4.96%). No other benched op moved. I rotated the committed
bench/baseline.json, but the PR gate prefers the weekly baseline artifact
from develop — that artifact needs rotating for this to go green. Happy to
drop the two resolve emissions instead if the read-path cost isn't worth it.

Closes #163

DSOTec added 2 commits August 25, 2026 14:58
…nance

Only stealth-sender, stealth-registry, and stealth-batch-sender emitted
WraithMetricEvents, so the Grafana dashboard had blank panels for the other
four contracts and METRICS.md had no per-contract table for them.

Contracts:
- wraith-names emits register_count, renew_count, release_count,
  resolve_hit_count, and resolve_miss_count. register_count fires from
  register_internal so register, register_on_behalf, bulk_register, and
  auction claim_name are all covered; bulk_renew emits a single renew_count
  carrying the batch size.
- stealth-splitter emits create_count, beneficiaries_per_split, fund_count,
  and fund_volume, dimensioned by asset_address.
- stealth-vault emits deposit_count, deposit_volume, claim_count, and
  refund_count, dimensioned by asset_address.
- governance emits proposal_count, vote_count, and execution_count,
  dimensioned by proposal_id (and support for votes).

wraith-metrics gains the matching contract_ids, metric_names, and
dimension_names constants.

Docs and tooling:
- METRICS.md gains the four missing per-contract tables plus a symbol table
  mapping each 9-character wire Symbol back to its canonical metric name.
- The indexer now watches all seven contracts, decodes the abbreviated wire
  symbols, and drives its Prometheus collectors from a declarative metric
  spec table instead of a hand-written switch. Counters increment by the
  event value so bulk_renew's batch count aggregates correctly.
- grafana-dashboard.json gains 12 panels for the new metrics.
- synthetic-stream.js replays a synthetic event stream through the parser and
  aggregator and fails if any dashboard panel would render blank.
- SIZE.md records the optimized wasm delta per contract.

Each of the four contracts has integration tests asserting on the emitted
WraithMetricEvent topics, value, and dimensions.
Wiring wraith_metrics into wraith-names adds one env.events().publish() to
register, resolve, release, and renew. Each emission costs a flat +4,164
instructions and +144 event bytes, which pushes wraith-names::resolve past the
+5% per-op PR gate (hit +11.91%, miss +17.67%; register lands at +4.96%).

Only those four ops moved — every other benched op is byte-identical to the
previous baseline, so this rotation absorbs no unrelated drift. METRICS.md now
records the measured per-emission cost so the trade-off is visible before
anyone instruments another read path.

Note that the PR gate prefers the weekly baseline artifact from develop over
this committed file; that artifact still needs a rotation for the gate to pass
on this branch.
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@DSOTec Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify
truthixify merged commit 233c055 into wraith-protocol:develop Aug 26, 2026
13 checks passed
@truthixify

Copy link
Copy Markdown
Contributor

Merged. Metrics wired across all four contracts with a snapshot test per emission, and the dashboard panels updated to match. Strong piece of work @DSOTec.

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.

wraith_metrics wiring into wraith-names, splitter, vault, governance

2 participants