Conversation
There was a problem hiding this comment.
Pull request overview
This PR experiments with introducing an optional SCV_SPARSE_MAP variant into the Soroban SCVal XDR by conditionally compiling enum/union members behind a SPARSE_MAP preprocessor define.
Changes:
- Adds
SCV_SPARSE_MAPtoSCValTypewhenSPARSE_MAPis defined. - Adds a corresponding
SCV_SPARSE_MAParm to theSCValunion whenSPARSE_MAPis defined.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Stellar-contract.x
Outdated
There was a problem hiding this comment.
Using #ifdef SPARSE_MAP inside the XDR enum makes the numeric type space dependent on compile-time flags. This can lead to incompatible serialized data between components built with different defines (e.g., one side knows SCV_SPARSE_MAP and the other doesn’t). Prefer keeping the XDR schema deterministic (e.g., define the new enum value unconditionally or introduce a separate, versioned XDR type) rather than CPP-guarding enum members.
Stellar-contract.x
Outdated
There was a problem hiding this comment.
The SCV_SPARSE_MAP union arm is also CPP-guarded. If one producer is built with SPARSE_MAP and emits type 22, a consumer built without it will fail to decode the SCVal union. Consider keeping the union arm present (even if unused) to maintain wire compatibility across builds, or move this experiment behind protocol-versioned/explicit feature negotiation instead of preprocessor guards in XDR.
|
|
||
| #ifdef SPARSE_MAP | ||
| case SCV_SPARSE_MAP: | ||
| SCMap *sparseMap; |
There was a problem hiding this comment.
Field name sparseMap uses camelCase, while other SCVal union arms use snake_case (e.g., nonce_key) or short identifiers (vec, map). Rename to a consistent style (e.g., sparse_map) to match the surrounding XDR conventions and generated bindings.
| SCMap *sparseMap; | |
| SCMap *sparse_map; |
What
Experiment with ifdef-guarded changes.
Why
For: