Description
Problem
Large contract state payloads can increase serialization overhead, storage requirements, and network transfer costs. The SDK currently has no standardized mechanism for analyzing state representation or applying safe compression/encoding optimizations.
Different state structures may also contain repetitive data that can be represented more efficiently.
Solution
Introduce contract state optimization utilities that analyze state payloads before storage or transmission.
The system should support compression for eligible payloads, optimized encoding for common primitive and structured types, and metadata describing how the state was encoded.
Compression must be transparent to consumers: callers should be able to write optimized state and read the original logical representation without manually handling decompression.
Acceptance Criteria
Note for Contributors
Do not assume every Soroban storage value should be compressed. Clearly define supported payload boundaries and preserve deterministic serialization. The implementation should prioritize correctness and compatibility over maximum compression.
Description
Problem
Large contract state payloads can increase serialization overhead, storage requirements, and network transfer costs. The SDK currently has no standardized mechanism for analyzing state representation or applying safe compression/encoding optimizations.
Different state structures may also contain repetitive data that can be represented more efficiently.
Solution
Introduce contract state optimization utilities that analyze state payloads before storage or transmission.
The system should support compression for eligible payloads, optimized encoding for common primitive and structured types, and metadata describing how the state was encoded.
Compression must be transparent to consumers: callers should be able to write optimized state and read the original logical representation without manually handling decompression.
Acceptance Criteria
compressContractState(state, options)is implemented.decompressContractState(data, metadata)restores the original state.src/soroban/index.ts.Note for Contributors
Do not assume every Soroban storage value should be compressed. Clearly define supported payload boundaries and preserve deterministic serialization. The implementation should prioritize correctness and compatibility over maximum compression.