Skip to content

fix(blockchain): resolve issues #917 #933 #934 #937 — reliability har…#1068

Merged
hman38705 merged 1 commit into
solutions-plug:mainfrom
knytcomics-ui:fix/issues-917-933-934-937-blockchain-reliability
Jun 30, 2026
Merged

fix(blockchain): resolve issues #917 #933 #934 #937 — reliability har…#1068
hman38705 merged 1 commit into
solutions-plug:mainfrom
knytcomics-ui:fix/issues-917-933-934-937-blockchain-reliability

Conversation

@knytcomics-ui

@knytcomics-ui knytcomics-ui commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

…dening

closes #933 — WATCHED_TX_TTL now configurable (WATCHED_TX_TTL_SECS)

  • Remove hardcoded 30-min Duration const; replace with config-driven value
  • Add Config::watched_tx_ttl_secs (default 1800) read from WATCHED_TX_TTL_SECS
  • Thread the value into BlockchainClient::watched_tx_ttl field
  • Migration 019 creates watched_transactions table with expires_at column driven by the same TTL, satisfying the DB persistence requirement

closes #934 — WATCHED_TX_MAX_SIZE cap now rejects (503) instead of silently evicting

  • Cap behaviour changed from evict-oldest to reject-with-503; callers receive a clear error rather than silently losing monitor coverage of old hashes
  • Add Config::watched_tx_max_size (default 10 000) read from WATCHED_TX_MAX_SIZE
  • Add Metrics::watched_tx_count IntGauge updated on every insert/eviction/removal
  • Add Prometheus alert WatchedTxCountHigh (>8000, warning) and WatchedTxCountCritical (>=10000, critical) in performance/config/alerts.yaml

closes #937 — Deduplication check for watched transactions

  • watch_transaction now returns Result<(), WatchTxError> instead of ()
  • WatchTxError::AlreadyWatched returned when hash already in map (no dup insert)
  • WatchTxError::CapReached returned when map is full (propagates to 503 in handler)
  • blockchain_tx_status handler matches on the error variants: AlreadyWatched is treated as idempotent (status still returned), CapReached returns 503 SERVICE_UNAVAILABLE with a clear message
  • Migration 019 adds UNIQUE constraint on tx_hash for DB-layer dedup

closes #917 — Stellar RPC reachability probe at startup & /health/ready endpoint

  • validate_network_passphrase now differentiates dev vs production: PREDICTIQ_ENV=production → process::exit(1) on failure/mismatch all other envs → log warning and continue
  • Add probe_stellar_ready() for per-request liveness checking
  • Add GET /health/ready readiness endpoint returning 200/503 + JSON body with ready bool and stellar_rpc field ("ok" | "unreachable")
  • Route registered in main.rs public_routes

Docs & config

  • services/api/README.md: document WATCHED_TX_TTL_SECS, WATCHED_TX_MAX_SIZE, PREDICTIQ_ENV, /health/ready endpoint, watched_tx_count metric
  • services/api/.env.example: add commented-out examples for new variables
  • Config test structs updated with new required fields

Description

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • CI / tooling change
  • Breaking change

Testing Done

Bundle Size

Chunk Before After
vendor.js
main*.js
pages/_app*.js

Checklist

  • Tests pass locally
  • Documentation updated (if applicable)
  • No breaking changes, or breaking changes are documented above
  • Bundle size checked (if frontend changes)

Related Issues

Closes #

…olutions-plug#934 solutions-plug#937 — reliability hardening

## solutions-plug#933 — WATCHED_TX_TTL now configurable (WATCHED_TX_TTL_SECS)
- Remove hardcoded 30-min Duration const; replace with config-driven value
- Add Config::watched_tx_ttl_secs (default 1800) read from WATCHED_TX_TTL_SECS
- Thread the value into BlockchainClient::watched_tx_ttl field
- Migration 019 creates watched_transactions table with expires_at column
  driven by the same TTL, satisfying the DB persistence requirement

## solutions-plug#934 — WATCHED_TX_MAX_SIZE cap now rejects (503) instead of silently evicting
- Cap behaviour changed from evict-oldest to reject-with-503; callers receive
  a clear error rather than silently losing monitor coverage of old hashes
- Add Config::watched_tx_max_size (default 10 000) read from WATCHED_TX_MAX_SIZE
- Add Metrics::watched_tx_count IntGauge updated on every insert/eviction/removal
- Add Prometheus alert WatchedTxCountHigh (>8000, warning) and
  WatchedTxCountCritical (>=10000, critical) in performance/config/alerts.yaml

## solutions-plug#937 — Deduplication check for watched transactions
- watch_transaction now returns Result<(), WatchTxError> instead of ()
- WatchTxError::AlreadyWatched returned when hash already in map (no dup insert)
- WatchTxError::CapReached returned when map is full (propagates to 503 in handler)
- blockchain_tx_status handler matches on the error variants:
  AlreadyWatched is treated as idempotent (status still returned),
  CapReached returns 503 SERVICE_UNAVAILABLE with a clear message
- Migration 019 adds UNIQUE constraint on tx_hash for DB-layer dedup

## solutions-plug#917 — Stellar RPC reachability probe at startup & /health/ready endpoint
- validate_network_passphrase now differentiates dev vs production:
  PREDICTIQ_ENV=production → process::exit(1) on failure/mismatch
  all other envs → log warning and continue
- Add probe_stellar_ready() for per-request liveness checking
- Add GET /health/ready readiness endpoint returning 200/503 + JSON body
  with ready bool and stellar_rpc field ("ok" | "unreachable")
- Route registered in main.rs public_routes

## Docs & config
- services/api/README.md: document WATCHED_TX_TTL_SECS, WATCHED_TX_MAX_SIZE,
  PREDICTIQ_ENV, /health/ready endpoint, watched_tx_count metric
- services/api/.env.example: add commented-out examples for new variables
- Config test structs updated with new required fields
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@knytcomics-ui 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

@hman38705 hman38705 merged commit 00362b6 into solutions-plug:main Jun 30, 2026
7 of 19 checks passed
hman38705 added a commit that referenced this pull request Jun 30, 2026
…_watched_transactions, cap check in watch_transaction, DB persistence for tx watch/resolve, fix duplicate health_live

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants