Skip to content

list_configs and get_config_snapshot expose the same data in different shapes and orders: consumers have two conventions for reading config #520

Description

@usmanimamu17-create

Problem

Two public endpoints return the same config data in different forms:

// get_config_snapshot — Vec<SLAConfigEntry> in canonical order
let mut entries = Vec::new(&env);
for severity in Self::canonical_severities(&env) { entries.push_back(SLAConfigEntry { severity, config }); }
Ok(SLAConfigSnapshot { version: symbol_short!("v1"), entries })

// list_configs — the raw Map
pub fn list_configs(env: Env) -> Result<Map<Symbol, SLAConfig>, SLAError> {
    env.storage().instance().get(&CONFIG_KEY).ok_or(SLAError::NotInitialized)
}

list_configs returns the Map (map-internal ordering, raw SLAConfig values) while the snapshot guarantees canonical severity order with typed entries; both are in get_public_api.

Consequences:

  • Consumers get different ordering guarantees for the same data: code reading list_configs and iterating the map cannot rely on the canonical order the snapshot guarantees; a consumer that switched endpoints for efficiency would silently change its ordering semantics.
  • Two shapes for one concept: Map<Symbol, SLAConfig> vs. Vec<SLAConfigEntry> — serialization, iteration, and diffing logic must exist twice; offchain/readCostRegression.ts models config as a flat map (the list_configs shape) while the recommended bundle uses the snapshot shape, so even the repo's own tooling disagrees about the canonical shape.
  • Neither endpoint is marked preferred: the docs describe both without saying which consumers should use, so new consumers pick arbitrarily and inherit whichever ordering contract.

Root cause

list_configs predates the snapshot; when the snapshot was introduced as the backend-friendly canonical order, list_configs was kept for compatibility without deprecation or cross-documentation.

Why this is architecturally hard

  1. The resolution options: deprecate list_configs (an ABI-visible change; the descriptor and consumers must coordinate), re-document it as the raw/low-level view (leaving two shapes), or make it return the snapshot shape (a breaking change to its return type).
  2. The Map return is also less stable across SDK versions (map ordering), so the "raw" framing is itself fragile — the issue should state which surface is canonical for new consumers.
  3. The descriptor-completeness companion issue's machinery should enforce that deprecated/alternative endpoints are marked, so consumers can tell.

Acceptance criteria

  • The docs state which endpoint is canonical for reading config (and why).
  • list_configs is either deprecated, aligned to the snapshot shape, or explicitly documented as the raw variant with its ordering caveats.
  • The offchain config model matches the canonical shape.

Out of scope

The snapshot version label (companion issue in batch 12) and the config-count semantics (companion issue in batch 06).

Getting started

just test

Good first files to read: apexchainx_calculator/src/lib.rs (list_configs, get_config_snapshot), offchain/readCostRegression.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardStellar WaveIssues in the Stellar wave programThird CampaignCampaign: Third Campaignarea/apiImported campaign issue labelpriority/mediumImported campaign issue label

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions