Skip to content

Refactor invoice struct to use compact XDR encoding for storage efficiency #334

Description

@Kingsman-99

Overview

The invoice struct stores several redundant or padded fields that inflate storage costs. Refactor the on-chain representation to use compact types and remove redundant fields without breaking the external API.

Acceptance Criteria

  • Audit all invoice struct fields; identify and remove computed fields (e.g. funded_percentage derivable from funded_amount / target_amount)
  • Replace String status field with a u8 enum to save XDR bytes
  • Replace u64 timestamps with u32 ledger sequences where wall-clock time is not needed
  • Measure before/after storage bytes per invoice using soroban-sdk storage().has() size inspection
  • Target: ≥ 20% reduction in bytes per invoice in persistent storage
  • get_invoice view function still returns the full external struct (status as string, etc.) — remapped from compact storage
  • Migration: a one-time compact_migrate(invoice_id) helper for upgrading stored invoices
  • Integration tests verify stored and returned data is identical before/after migration

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsrefactorCode quality and restructuring

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