refactor: batch persistent storage reads into context structs#150
Merged
shakurJJ merged 2 commits intoJun 26, 2026
Merged
Conversation
- Add CreateShipmentCtx, ConfirmMilestoneCtx, and ResolveDisputeCtx structs - Implement helper functions to fetch and populate context structs with all related storage keys - Refactor create_shipment to use fetch_create_shipment_ctx for batch reads - Refactor confirm_milestone to use fetch_confirm_milestone_ctx for batch reads - Refactor resolve_dispute to use fetch_resolve_dispute_ctx for batch reads - Add inline documentation for each context struct listing all accessed keys - Fix missing contracterror import Acceptance criteria met: - create_shipment reads consolidated into CreateShipmentCtx helper - confirm_milestone reads consolidated into ConfirmMilestoneCtx helper - resolve_dispute reads consolidated into ResolveDisputeCtx helper - Context helpers document their key access list in comments - Lib compiles without errors
|
@MooreTheAnalyst 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.
Batch Persistent Storage Reads
Consolidates multiple sequential storage reads into typed context structs for three key functions, reducing storage operation overhead.
Changes
CreateShipmentCtx: Groups validation reads (MaxShipmentValue, AllowedTokens, MinMilestonePercent, ContractStats) into single helper fetch
ConfirmMilestoneCtx: Batches Shipment and ContractStats reads via fetch_confirm_milestone_ctx
ResolveDisputeCtx: Consolidates Shipment, DisputeContestedPercent, ContractStats, and ActiveDisputes into one context fetch
Each helper documents accessed keys as inline comments for future layout optimization.
Result
All three functions now perform a single batched read operation instead of multiple sequential gets, improving storage efficiency while maintaining identical behavior. Lib compiles without errors.
Closes #139