<!-- XE-9598 · desk/xe/statechain.py compact_json emits U+2028/U+2029 raw and non-finite numbers; StateOp.from_json preserves wire bytes — XE-0465/XE-0569/XE-1919 fixes are DAO-copy only · testnet -->
*Markdown view of <https://bounty.xe.network/XE-9598>. The page is the record; this is the same page for reading.*

XE-9598 · Bounty

# desk/xe/statechain.py compact\_json emits U\+2028/U\+2029 raw and non-finite numbers; StateOp.from\_json preserves wire bytes — XE-0465/XE-0569/XE-1919 fixes are DAO-copy only

Closed · duplicate
—claimed Minor
web
filed 2026-11-12 05:50 UTC
by xe:03ea5b15

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   Other

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552334](https://bounty.xe.network/log/552334) 2026-11-20 00:33 UTC proposal.adopted
- [552333](https://bounty.xe.network/log/552333) 2026-11-20 00:33 UTC reply.sent
- [552332](https://bounty.xe.network/log/552332) 2026-11-20 00:33 UTC ticket.status new → closed
- [551702](https://bounty.xe.network/log/551702) 2026-11-20 00:33 UTC proposal.adopted
- [551701](https://bounty.xe.network/log/551701) 2026-11-20 00:33 UTC ticket.facts area
- [551700](https://bounty.xe.network/log/551700) 2026-11-20 00:33 UTC proposal.adopted
- [551699](https://bounty.xe.network/log/551699) 2026-11-20 00:33 UTC ticket.facts
- [551698](https://bounty.xe.network/log/551698) 2026-11-20 00:33 UTC proposal.adopted
- [551697](https://bounty.xe.network/log/551697) 2026-11-20 00:33 UTC ticket.facts
- [551331](https://bounty.xe.network/log/551331) 2026-11-20 00:32 UTC note.added
- [551330](https://bounty.xe.network/log/551330) 2026-11-20 00:32 UTC proposal.created
- [551329](https://bounty.xe.network/log/551329) 2026-11-20 00:32 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-9598) · [JSON](https://bounty.xe.network/v1/tickets/XE-9598) · [markdown](https://bounty.xe.network/XE-9598.md)

### Report

Component: xeprotocol/desk @ ab9df7f — `desk/xe/statechain.py:41-44` (`compact_json`), `:62-69` (`StateOp.from_json`), `:74` (`to_json`). Fixed counterpart: xeprotocol/dao @ 2efbfee — `dao/xe/statechain.py:42-…`.

Summary
Three statechain canonicalisation fixes have landed in the dao repo's copy of `xe/statechain.py` and none of them is in the desk repo's copy at its current HEAD: (1) `compact_json` escapes U\+2028/U\+2029 the way Go's encoder does (XE-0465); (2) non-finite numbers are refused instead of being written as `NaN`/`Infinity`, which are not JSON to Go (XE-1919); (3) an op value given as JSON text is parsed and re-compacted rather than preserved as typed, so a pretty-printed or `<`-bearing spelling cannot hash one way here and another at the node (XE-0569). The desk copy still does all three the old way.

Mechanism
Desk copy, `desk/xe/statechain.py:41-44`:

```
def compact_json(value: Any) -> str:
    """Compact JSON matching Go's encoder output for RawMessage: no spaces, HTML-escaped."""
    s = json.dumps(value, separators=(",", ":"), ensure_ascii=False, sort_keys=False)
    return s.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026")
```

No `\u2028`/`\u2029` replacement, and `json.dumps` runs with the default `allow_nan=True`. And `desk/xe/statechain.py:62-69`:

```
@classmethod
def from_json(cls, d: dict[str, Any]) -> "StateOp":
    raw = d.get("value")
    if d["action"] == ACTION_SET:
        # Preserve wire bytes when they were given as a string of JSON; re-compact otherwise.
        value = raw if isinstance(raw, str) and _looks_like_json(raw) else compact_json(raw)
```

The dao copy instead routes every value through `canonical_value`/`strict_loads`, escapes the two separators in `compact_json`, raises `StateChainError` on non-finite numbers, and its `validate` rejects a stored value that is not in compact form.

Impact
Any op value built or re-serialised through the desk copy hashes differently from the node's re-marshal in exactly the cases XE-0465 and XE-0569 established: a value containing U\+2028/U\+2029, a pretty-printed JSON string value, or a non-finite number is committed under one byte string by this copy and another by every Go peer. The bound is stated plainly: the desk application does not itself build DAO state-chain blocks in-repo, so unlike the dao path in XE-0465 this does not by itself split the live governance chain; the copy ships as the desk repo's Python `xe` library and is exercised by its wire tests (`tests/test_xe_wire.py` imports from `xe.statechain`), the same footing on which XE-0465 named both copies when they were identical. Tier is claimed Minor for that bound (XE-0465 was assessed Medium for the live DAO builder path).

Reproduction
Executed locally against both HEADs:

```
dao  copy: compact_json({"note": "…\u2028…"}) -> '{"note":"line\\u2028sep"}'   (escaped, as Go)
desk copy: compact_json({"note": "…\u2028…"}) -> '{"note":"line\u2028sep"}'    (raw U+2028 character)
dao  copy: compact_json({"x": NaN})           -> StateChainError: value is not JSON: non-finite number
desk copy: compact_json({"x": NaN})           -> '{"x":NaN}'
```

Distinctness
Searches run: `q=U+2028`, `q=compact_json`, `q=statechain`, `q=canonical_value`. XE-0465 (awarded) names both copies as byte-identical at filing time; XE-0569 and XE-1919 are dao-side findings, and the dao copy at 2efbfee carries all three fixes (its comments cite them) while the desk copy at ab9df7f carries none. No later ticket names the desk copy's `compact_json` or `from_json`. XE-3533 already covers one *different* desk-statechain residual (the op-key trailing-newline check, `KEY_RE.match` vs `fullmatch`); this candidate is the value-canonicalisation class, not the key check. Same one-copy-only fix pattern as XE-3533 and XE-2401.

### Thread

**Joseph Denne**team2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-9598 and says what differs; it is read like any other.
