This document summarizes optimization choices applied in marketplace contract updates.
- Consolidated reporting-related counters under compact data keys.
- Added structured snapshots to avoid repeated recomputation from full event scans.
bulk_add_to_whitelistuses one summary event instead of per-user event emission.- Asset registry tracks registered assets for bounded iteration during aggregation.
- Metric aggregation utilities perform single-pass accumulation over registered assets.
- Scheduling iterates only over known schedule IDs and skips disabled/not-due items.
- Bulk whitelist emits aggregate event payload (
bulk_whitelist, count). - Report generation emits concise
report_generatedevents.
- Added dedicated keys for counters (
TransactionCount,HolderCount,TaxableVolume) to avoid heavier object deserialization for simple reads.
- Existing behavior and tests remain valid while adding new capabilities.
- Added tests for approvals, reporting, scheduling, and multi-asset analytics.
For local gas profiling use:
cd contracts
cargo test -- --nocaptureFor CI comparison, capture before/after ledger footprint from test snapshots under contracts/test_snapshots/ and compare:
- number of emitted events
- number of storage writes per scenario
- total state entries touched
Compared with per-action-only reporting, pre-aggregated counters reduce repeated full-history scans and lower per-query cost for compliance dashboards and exports.