-
Notifications
You must be signed in to change notification settings - Fork 1
Integrate LDK events #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate LDK events #487
Conversation
bcdd66c to
185c51f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utAck
I pushed a commit for a a few formatting fixes and the nit comment about the outdated docs for a function.
Starting to test 🧪
|
Pushed another commit for the few lint issues: 2f0122f, no lint issue remaining to fix |
Pull Request Review: LDK Events IntegrationOverviewThis PR successfully integrates LDK node onchain events to replace the previous polling and full syncs, removes AddressChecker, and improves handling of RBF and CPFP transactions. The changes span 27 files with 962 additions and 769 deletions. ✅ StrengthsArchitecture Improvements
Code Quality
🔍 Issues & RecommendationsHigh Priority1. Race Condition Risk in Event Handlers (CoreService.kt:782-808)suspend fun handleOnchainTransactionReceived(txid: String, details: TransactionDetails) {
ServiceQueue.CORE.background {
runCatching {
val payments = lightningService.payments ?: run {
Logger.warn("No payments available for transaction $txid", context = TAG)
return@background
}Issue: When a transaction event arrives, Recommendation:
2. Potential Data Loss in RBF Handling (CoreService.kt:838-854)suspend fun handleOnchainTransactionReplaced(txid: String, conflicts: List<String>) {
// ...
markReplacedActivity(txid, replacedActivity, conflicts)
for (conflictTxid in conflicts) {
val replacementActivity = getOrCreateReplacementActivity(conflictTxid)Issue: If multiple conflicts are provided and processing one fails, the others may not be processed due to early return in Recommendation: Move the 3. Missing Transaction Details Handling (CoreService.kt:529-533)val details = transactionDetails ?: lightningService.getTransactionDetails(kind.txid)
if (details == null) {
Logger.verbose("Transaction details not available for txid: ${kind.txid}", context = TAG)
return null
}Issue: For inbound payments, if transaction details aren't available, the address won't be resolved. This could lead to "Loading..." being permanently shown. Recommendation: Add a fallback mechanism or retry logic for critical fields like address resolution. Medium Priority4. Inconsistent Channel ID Resolution (ActivityRepo.kt:133-168 vs CoreService.kt:642-652)Channel finding logic exists in both Recommendation: Consolidate this logic in one place to avoid inconsistencies. 5. Large Class Warning (CoreService.kt:207)
Recommendation: Consider splitting into separate services:
6. Removed Functionality Without Clear Migration (ActivityRepo.kt:166-191)The Recommendation: Verify that all edge cases previously handled are still covered in the new implementation within CoreService. Low Priority7. Magic Numbers (AppViewModel.kt:292)delay(DELAY_FOR_ACTIVITY_SYNC_MS)Recommendation: Ensure this constant is well-documented explaining why the delay is necessary. 8. Test Coverage Reduction (ActivityRepoTest.kt, WalletRepoTest.kt)Test files show significant line reductions (140 lines removed from ActivityRepoTest, 43 from WalletRepoTest). Recommendation: Verify that the removed tests are no longer applicable and not just deleted without replacement. Add tests for new event handling logic. 9. String Resources (strings.xml)Only 2 new strings were added. Verify all user-facing messages for the new events are using string resources and not hardcoded. 🔒 Security Considerations
⚡ Performance Considerations
Recommendation: Monitor the performance impact of processing each event. If events come in bursts, consider batching updates. 🧪 Testing Recommendations
📝 Code Style & Best Practices✅ Follows Guidelines:
🎯 SummaryOverall Assessment: ✅ Approve with recommendations This is a solid refactoring that modernizes the transaction handling architecture. The event-driven approach is the right direction. The main concerns are around edge cases in event handling and ensuring data consistency during rapid state changes (like multiple RBF replacements). Critical Action Items:
Recommendation: Once the high-priority issues are addressed, this PR should be good to merge. Consider a staged rollout with monitoring to catch any edge cases in production. 📋 Testing Checklist (as mentioned in PR description)Please confirm testing of:
Review conducted with focus on code quality, architecture, security, and adherence to the repository's coding standards as defined in |
app/src/main/java/to/bitkit/ui/settings/advanced/AddressViewerViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/to/bitkit/ui/settings/lightning/LightningConnectionsViewModel.kt
Outdated
Show resolved
Hide resolved
ovitrif
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests
- Boost
- RBF 🟢
- CPFP 🟢
- Activity
- Home Screen 🟢
- Activity List 🟢
- Activity List (and filtering) regression test 🟢
- Activity Detail 🟢
- Activity Explore 🟢
- When electrum was very slow, an optimisation idea surfaced to me:
- we should cache transaction details in the viewmodel of activity details
- I went back to detail screen then returned, I had to wait again too much for the spinner to load the transaction details on the explore screen.
- we should cache transaction details in the viewmodel of activity details
- When electrum was very slow, an optimisation idea surfaced to me:
- Transfers
- Transfer to savings 🟢
- Transfer to spending 🟢
- Toasts
5. RBF sent transaction replaced 🟢
6. RBF from sender’s side (toast + removed from mempool activity for receiver) 🟢 - Payment Received 🟢
- Onchain
- fg 🟢
- bg 🟢
- LN
- fg 🟢
- bg 🟢
- wake2pay ⚪
- couldn’t test because right in that moment Electrum server on STAG died again.
- but on the bright side, the wake was already starting as seen in logs
- Onchain
Pull Request Review: Integrate LDK EventsI've completed a thorough review of this PR. Overall, this is a well-architected and significant improvement to the codebase. The integration of LDK node onchain events to replace polling is a solid architectural decision that should improve performance and reliability. ✅ Strengths1. Excellent Architecture
2. Comprehensive Event HandlingThe event handlers in
3. Good Test CoverageThe
4. Removal of AddressCheckerRemoving the external polling dependency (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested
- Open and close channels ✅
- Send and receive ✅
- CPFP and RBF for send and receive ✅
- Transaction details ✅
- Received sheet ✅
- All activities ✅
- Filter activities ✅
|
Merging this PR with its parent, then we'll make sure e2e pass there. |
This PR integrates LDK node onchain events to replace the previous polling and full syncs.
It also removes Address Checker, and improves handling of RBF and CPFP transactions.
Testing:
Should test all actions, send, receive (onchain and LN), transfer to savings, transfer to spendings, etc.