fixed undedrlying issues and also implemented: Txn timestamps optimiz… - #862
Open
Sadeequ wants to merge 1 commit into
Open
fixed undedrlying issues and also implemented: Txn timestamps optimiz…#862Sadeequ wants to merge 1 commit into
Sadeequ wants to merge 1 commit into
Conversation
…ation, SLA breach alert, mem cahce for TOML and CSS theme option
|
@Sadeequ 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is a summary of all the changes I made across the four issues.
Issue 1: Composite database index on Transaction table [ CLOSES #742 ] ✔️
I added @@index([status, createdAt]) to the Transaction model in backend/prisma/schema.prisma (line 156). This composite index speeds up dashboard queries that filter by transaction status and sort or filter by creation timestamp.
Issue 2: SLA breach alerts for stuck pending transactions [ CLOSES #745 ] ✔️
I modified backend/src/services/hot-wallet-monitor.service.ts with the following changes:
Added import prisma from '../lib/prisma' to enable database queries.
Added a slaBreachTransactionsGauge Prometheus gauge metric (sla_breach_transactions_count) to track the number of stuck transactions.
Added checkSlaBreaches() method that queries prisma.transaction.findMany() for transactions with status: 'PENDING_EXTERNAL' and createdAt older than 2 hours. It sets the gauge metric and, if any are found, calls the alert handler.
Added handleSlaBreachAlert() method that dispatches alerts in parallel via Slack, email, and custom webhook channels.
Added sendSlaSlackAlert() method that formats a Slack message listing each stuck transaction with its ID, type, amount, asset code, and pending duration.
Added sendSlaEmailAlert() method that sends an email to the ops recipients with the full list of stuck transactions.
Integrated checkSlaBreaches() into the existing checkAll() polling cycle so SLA breaches are detected on every check interval.
Issue 3: Redis caching layer for SEP-1 TOML metadata [ CLOSES #748 ] ✔️
I modified backend/src/services/indexer/toml.fetcher.ts with the following changes:
Added imports for redis and RedisService.
Added CACHE_KEY_PREFIX ("sep1:toml:") and CACHE_TTL_SECONDS (3600, i.e., 1 hour) constants.
Added a RedisService instance to TomlFetcherImpl.
Modified fetch() to check Redis cache before issuing the HTTP GET to /.well-known/stellar.toml. On a cache hit, the parsed result is returned immediately. On a cache miss, the result is stored in Redis with a 1-hour TTL after fetching and parsing.
Added an exported purgeTomlCache(homeDomain?: string) function that deletes cached entries — either for a specific domain or all entries when called without arguments.
I also modified backend/src/api/routes/admin.route.ts:
Added import { purgeTomlCache } from the toml fetcher.
Added POST /admin/cache/purge-toml endpoint that accepts an optional homeDomain in the request body and returns the number of cache entries purged.
Issue 4: Dark/light theme persistence with CSS variables [ CLOSES #750 ] ✔️
I modified dashboard/src/index.css:
Added :root.light selector with --bg-primary: #f8fafc, --text-primary: #0f172a, and --card-bg: #ffffff.
Added :root.dark selector with --bg-primary: #020617, --text-primary: #f8fafc, and --card-bg: #0f172a.
Updated the body rule to use var(--bg-primary) and var(--text-primary) instead of hardcoded values.
I modified dashboard/src/App.tsx:
Added createContext and useContext to the React imports, plus Sun and Moon icons from lucide-react.
Created ThemeContext with theme and toggleTheme values, and exported a useTheme() hook.
Added theme state initialized from localStorage (defaults to 'dark').
Added toggleTheme callback that toggles between 'light' and 'dark' and persists the preference to localStorage.
Added a useEffect that applies the light or dark class to document.documentElement whenever the theme changes.
Wrapped the entire JSX return value in <ThemeContext.Provider value={{ theme, toggleTheme }}>.
Added a component in the header navbar, rendered between the notification bell and the wallet connect button. The toggle displays a Sun icon in dark mode and a Moon icon in light mode, with a text label.