Skip to content

[CT-21] Optimize batch operations to reduce ledger storage reads in assetsup in opsce crate #818

@yusuftomilola

Description

@yusuftomilola

Problem

Several assetsup functions iterate over collections by calling individual env.storage().get() inside loops. Each storage read is a separate ledger entry access. For large datasets this pattern is inefficient and increases transaction fees.

Proposed Solution

Create contracts/opsce/src/storage_optimization.rs. Refactor identified hot-path functions to batch reads using a single Vec-backed storage key where possible.

Acceptance Criteria

  • Identify at least 3 functions in assetsup/src/ that iterate with per-item storage reads
  • Propose and implement a batch_get storage pattern using a single Vec storage entry for collections of up to 50 items
  • The refactored implementation produces identical outputs as the original for all inputs
  • Unit tests confirm behavioral equivalence before and after optimization
  • A code comment documents the trade-off: single-entry reads are faster for lookup; Vec-backed reads are faster for iteration
  • cargo test passes after the change

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions