Skip to content

L4: mapkeys — SC state key enumeration for DVM-BASIC #108

Description

@liqdmetal

Summary

L4 from the DVM-BASIC language agenda (P1): mapkeys() -> String — map enumeration for SC state. Batch/paged contracts can iterate their stored keys instead of hand-rolling key sets.

The intrinsic

LET ks = mapkeys()     ' "alpha,beta,gamma" — sorted, comma-separated

The effective key set is the union of:

  • RamStore — keys loaded from disk (via DiskLoader) during this call
  • RawKeys — keys written during this call (TX_Storage.RawKeys)

Keys are the String/Uint64 values of the stored Variables, unmarshaled, deduped, sorted, and joined. The comma-separated String is the DVM-friendly return (intrinsics return String/Uint64); contracts split it for iteration, and L3 arrays give the next natural return type.

Why it matters

Today a contract that batches/pages state must hand-roll its key set (store a counter, maintain a registry). With mapkeys, the keys themselves are enumerable — combined with L1's FOR and L3's arrays, a contract can:

FOR i = 0 TO <n>
    LET k = <split(ks, i)>
    LET v = LOAD(k)
    ... process ...
NEXT i

Consensus safety

  • Gated >= 10.0.0 like L1/L2/L3 — pre-fork contracts can't use it
  • Read-only: enumerates keys, changes no state

Tests (dvm/control_flow_l4_test.go, 3 cases)

Test Verifies
TestL4_MapkeysBasic STORE alpha/beta/gamma → "alpha,beta,gamma" (sorted)
TestL4_MapkeysIterate batch iteration pattern
TestL4_MapkeysVersionGate rejected at 1.2.3

Full dvm suite green.

Relationship


Branch: feature/dvm-l4-mapkeys in the fork liqdmetal/derohe-improvements-by-liqdmetal (stacked on feature/dvm-l3-arrays).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions