Refactor distribute meta vault redemptions#725
Conversation
There was a problem hiding this comment.
A lot of rework in this file.
Previously:
distribute_meta_vault_redemption_assets- and
get_meta_vault_redemption_assets
looked similar. Separation of concerns was unclear. - Also there was recursion.
Now:
distribute_meta_vault_redemption_assets- does the main job of distributing assets deeplyget_sub_vaults_redemptions- distributes from meta vault to direct sub vaults- Recursion was replaced with queue.
There was a problem hiding this comment.
Pull request overview
Refactors how meta-vault redemption assets are distributed: replaces recursive distribution with a BFS traversal over the sub-vault tree, and changes the result so the returned mapping now also contains entries for root and intermediate meta vaults (not just leaves). The redemption-asset entry point in src/redemptions/tasks.py is split into a small wrapper plus a renamed pair of helpers (get_vault_to_redemption_assets_distributed / _direct) for clearer naming.
Changes:
- Rewrite
distribute_meta_vault_redemption_assetsas an iterative BFS using a queue, and haveget_sub_vaults_redemptionsreturn only direct sub-vaults. - Include meta vaults (root and intermediate) in the returned mapping alongside their distributed leaves; tests updated accordingly.
- Split
get_redemption_assetsinredemptions/tasks.pyintoget_vault_to_redemption_assets_distributed+_direct, demote a log line, and rework the comment about nonce handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/meta_vault/service.py | Rewrites distribution as BFS using queue.Queue; reduces get_sub_vaults_redemptions to a thin wrapper; meta vaults now appear in the result. |
| src/redemptions/tasks.py | Splits redemption-asset retrieval into _distributed + _direct helpers, downgrades zero-nonce log to debug, returns a defaultdict on the zero-nonce path. |
| src/meta_vault/tests/test_service.py | Updates expected results to include meta-vault and nested-meta-vault entries in the distributed mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: evgeny-stakewise <[email protected]>
No description provided.