Map keys that collide
A contract stores and emits a map with five distinct keys that all read as "1" once converted to a native object. A lossy reader keeps one.
The shape
An ScMap may hold keys of different types that print the same: u32 1, i32 1, u64 1, the string "1" and the symbol "1" are five distinct, correctly ordered keys on chain. Converting the map to a native object keyed by text collapses them. js-stellar-sdk's scValToNative silently kept one of them (#1789). This entry is real stellar-core output: a contract wrote the map to storage, returned it and emitted it in an event.
The five keys are u32 1, i32 1, u64 1, the string "1" and the symbol 1. Each maps to a different value (10, 20, 30, 40, 50), so a conversion that drops entries is easy to detect.
Variants
| Variant | Protocol | Network | Source | Size | sha256 |
|---|---|---|---|---|---|
p30-mainnet-generated | P30 | mainnet passphrase | generated by stellar-core v30.0.0 | 2,972 B | 744986731d97… |
p28-mainnet-generated | P28 | mainnet passphrase | generated by stellar-core v30.0.0 | 2,964 B | 6d54aaf35a75… |
p30-testnet-generated | P30 | testnet passphrase | generated by stellar-core v30.0.0 | 2,972 B | a70bc215e806… |
p28-testnet-generated | P28 | testnet passphrase | generated by stellar-core v30.0.0 | 2,964 B | 46fed2036c0f… |
What a correct reader returns
This entry has an SDK check (1 of 201 entries do). It is a rule for the SDK's own helper, not a value: keep all five entries, or refuse the map. Never return fewer.
Not run yet
| A correct reader finds | Value | Backed by |
|---|---|---|
The contract wrote a persistent entry keyed collide whose value is a 5-entry map with keys u32 1, i32 1, u64 1, string "1", symbol "1" (in core's order). | some change where 7 fields match | constructionsnapshotcorewalker |
| The event emitted by the call carries the same map with all 5 entries. | length 5 | constructionsnapshot |
| The return value is the same 5-entry map. | length 5 | constructionsnapshot |
| Each key maps to a different value (10, 20, 30, 40, 50), so a lossy conversion is detectable. | 50 | constructionsnapshotcorewalker |
| SDK check | Must |
|---|---|
| Native projection of the event's map keeps all five entries or rejects the map; it never silently drops one. | return 5 entries, or raise an error; returning fewer than 5 is a failure (js-stellar-sdk#1789) |
What it reproduces
js-stellar-sdk#1789make conformance runs a vector with the same kind of collision (a two-entry map whose keys both read as "1") through js-stellar-sdk builds before and after the fix. The recorded matrix shows 17.2.0 and 17.2.1 keeping 1 of 2 entries, and 17.3.0 rejecting the map.
Check it yourself
make verify
make conformanceA map whose five keys collide on native conversion, used as a storage key
The colliding map (u32 1, i32 1, u64 1, string "1", symbol 1) is the contract-data KEY: it sits in the LedgerKey and the event topic.
A Soroban transaction with 20 signatures and a 32-byte symbol
signatures<20> full (carol needs all 20 signers at thresholds 20) and SCSymbol<32> at 32 bytes as storage key, event topic and argument.