Skip to content

feat: real-time Soroban log event parser and decoded alert pipeline#87

Merged
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:feat/soroban-ledger-event-decoder
Jun 28, 2026
Merged

feat: real-time Soroban log event parser and decoded alert pipeline#87
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:feat/soroban-ledger-event-decoder

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Real-Time Soroban Log Event Parser & Decoded Alert Pipeline

Closes: #8

Summary

Contract logs arrive from the Soroban RPC getTransaction response as raw hex XDR
topics + a base64 SCVal body, and were shown to operators verbatim — forcing 30–60s
of manual cross-referencing per alert. This decodes them client-side into typed,
human-readable alerts with severity color coding, well inside the <10ms/event budget.

What changed

Types — src/types/ledgerEvents.ts

  • LedgerEvent discriminated union over all seven known event types
    (approve_attestation, reject_attestation, slash_node, reward_distributed,
    node_registered, node_deregistered, parameter_changed) plus UnknownEvent.
  • Each event carries derived title, severity, and highSeverity metadata, plus the
    original rawTopics / rawBody.

Decode raw contract log events (hex XDR topics + base64 SCVal body) from
the Soroban RPC into typed, human-readable alerts instead of showing
operators raw cryptographic hex.

- types/ledgerEvents.ts: LedgerEvent discriminated union over the seven
  known event types plus UnknownEvent, with severity/title metadata
- utils/hexDecoder.ts: total decodeLedgerEvent() — parses the topic[0]
  signature via @stellar/stellar-sdk ScVal, matches a lookup table,
  decodes the subject topic + body map per the matched schema, and
  degrades any unrecognized/malformed input to UnknownEvent (never throws)
- hooks/useLedgerEvents: bounded newest-first raw event stream
- hooks/useDecodedLedgerEvents: wraps it and decodes each event at most
  once (memoized by raw-event identity via a WeakMap)
- components/alerts/AlertBanner: human-readable title, severity color
  coding, details deep-link, relative timestamp; UnknownEvent fallback
  with Copy Raw + Report (logs the shape to Sentry); optional Web Audio
  tone for high-severity (slash / reject) events, off by default
- utils/alertSound: in-memory synthesized alert tone (no network asset)
- services/sentry: captureUnknownLedgerEvent reporter
- move @stellar/stellar-sdk to runtime dependencies (decoder uses it)

Tested with vitest: encodes events with @stellar/stellar-sdk, asserts
each known type's decoded output, that unknown/garbage input yields an
UnknownEvent without throwing, and that 1,000 events decode in <100ms.
@JamesEjembi JamesEjembi merged commit 451fd40 into VeriNode-Labs:main Jun 28, 2026
2 checks passed
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