feat: improve contract performance, storage migrations, and SDK reliability - #590
Merged
Levi-Ojukwu merged 3 commits intoJul 26, 2026
Conversation
|
@yours-anjikon 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.
Summary
This PR improves the ILN protocol across three major areas:
It implements efficient top-payer selection, introduces a storage migration framework, adds comprehensive SDK error handling, and enables historical event replay with automatic ledger catch-up.
Closes #550
Closes #551
Closes #552
Closes #553
Overview
This contribution focuses on protocol scalability and long-term maintainability.
The improvements include:
These changes improve developer experience while preparing the protocol for future upgrades and larger production deployments.
Issue #550 — Optimize Top Payers Heap
Problem
The existing
get_top_payersimplementation performs O(n²) selection, which becomes increasingly expensive as the payer set grows.For large liquidity pools this increases dashboard query latency.
Solution
Replaced the quadratic selection logic with an efficient top-k algorithm.
Improvements include:
Performance
Benchmarked before and after implementation.
Observed improvements include:
No functional behavior changed.
Issue #551 — Storage Migration Framework
Problem
Future contract upgrades may introduce storage schema changes.
Without a migration framework upgrades become risky and difficult to validate.
Solution
Implemented a reusable migration framework.
Features include:
Migration Safety
Framework now supports:
Documentation
Added documentation describing:
Issue #552 — Comprehensive SDK Error Handling
Problem
Contract failures currently expose limited information to SDK consumers.
Developers receive generic failures with little guidance.
Solution
Implemented typed SDK errors mapped to contract error codes.
Examples include:
Error Context
Errors now include additional metadata when available:
This significantly improves debugging.
Retry Guidance
Transient errors now include retry recommendations.
Examples:
Permanent contract failures do not recommend retry.
Issue #553 — Event Replay & Catch-up
Problem
Applications cannot reliably recover historical events after downtime.
Restarting applications risks missing ledger events.
Solution
Added historical replay support.
New functionality:
allows applications to replay events beginning at any ledger.
Catch-up Support
Subscription logic now:
This significantly improves SDK reliability.
Files Updated
Smart Contract
Storage
SDK
Testing
Added comprehensive tests covering:
Contract
Storage
SDK Errors
Event Replay
Validation
Executed:
Verified:
Result
This PR strengthens the ILN ecosystem by improving smart contract scalability, enabling safe protocol upgrades, and making the SDK significantly more reliable for production applications.
The changes remain backward compatible while laying the foundation for future protocol evolution.