You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements **#104 – Develop Advanced Performance Optimization and Caching**: intelligent caching, query optimization, performance monitoring, and regression testing in both the Soroban contract and the NestJS indexer.
5
+
6
+
**Contract:** Performance cache module stores a bridge summary (health score + top chains by volume) with 1-hour TTL; admin can invalidate cache; bounded chain iteration for gas; new events for cache compute/invalidate.
7
+
8
+
**Indexer:** In-memory cache (60s TTL) for dashboard analytics; dashboard aggregates use SQL SUM/COUNT/AVG instead of full-table loads; `GET /health` and `GET /metrics` for load balancers and monitoring; MetricsService tracks cache hit rate and latency; dashboard tests include cache behavior and a 2s latency regression test.
9
+
10
+
## 🔗 Related Issue(s)
11
+
- Closes #104
12
+
13
+
## 🎯 Type of Change
14
+
-[x] ✨ New feature (non-breaking change that adds functionality)
- Added `get_top_chains_by_volume_bounded` in `analytics.rs` (max 50 chains) for gas-bound cache; kept existing `get_top_chains_by_volume` for backward compatibility.
21
+
- Wired performance module in `lib.rs`; public API: `get_cached_bridge_summary`, `compute_and_cache_bridge_summary`, `invalidate_performance_cache`.
22
+
- Added `contracts/teachlink/tests/test_performance.rs` (registration + type tests).
23
+
-**Indexer**
24
+
-`CacheModule` (60s TTL, global) in `AppModule`; `DashboardService` caches `getCurrentAnalytics()` with key `dashboard:analytics`; `invalidateDashboardCache()` for manual invalidation.
25
+
- Dashboard query optimization: escrow/reward totals via `SUM`/`COUNT`/`AVG` in SQL (no full-table `find()` + reduce).
26
+
- New `PerformanceModule`: `MetricsService` (request count, cache hits/misses, last dashboard ms, uptime), `PerformanceController` with `GET /health` and `GET /metrics`.
27
+
- Dashboard spec: `CACHE_MANAGER` and `MetricsService` mocks; cache-hit test; performance regression test (getCurrentAnalytics < 2s); fixed `generatedBy`/`save` types in `dashboard.service.ts`.
28
+
-`IMPLEMENTATION.md`: new “Performance optimization and caching” section.
29
+
30
+
## 🧪 Testing
31
+
32
+
### ✅ Pre-Merge Checklist (Required)
33
+
-[ ] 🧪 **Unit Tests**: Contract tests include `test_performance.rs`; indexer: `npx jest --testPathPattern="dashboard"` passes (7 tests).
34
+
-[ ] 🔨 **Debug Build**: `cargo build` (may require MSVC on Windows; CI runs on Linux).
35
+
-[ ] 🎯 **WASM Build**: `cargo build -p teachlink-contract --target wasm32-unknown-unknown` or `.\scripts\check-wasm.ps1` on Windows.
0 commit comments