{"id":"XE-9598","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":693,"title":"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","area":"other","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T05:50:03.443488+00:00","updated_at":"2026-11-20T00:33:17.565533+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:17.588552+00:00","status_changed_at":"2026-11-20T00:33:17.573088+00:00","url":"https://bounty.xe.network/XE-9598","body":"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-…`.\r\n\r\nSummary\r\nThree 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.\r\n\r\nMechanism\r\nDesk copy, `desk/xe/statechain.py:41-44`:\r\n\r\n```python\r\ndef compact_json(value: Any) -> str:\r\n    \"\"\"Compact JSON matching Go's encoder output for RawMessage: no spaces, HTML-escaped.\"\"\"\r\n    s = json.dumps(value, separators=(\",\", \":\"), ensure_ascii=False, sort_keys=False)\r\n    return s.replace(\"<\", \"\\\\u003c\").replace(\">\", \"\\\\u003e\").replace(\"&\", \"\\\\u0026\")\r\n```\r\n\r\nNo `\\u2028`/`\\u2029` replacement, and `json.dumps` runs with the default `allow_nan=True`. And `desk/xe/statechain.py:62-69`:\r\n\r\n```python\r\n@classmethod\r\ndef from_json(cls, d: dict[str, Any]) -> \"StateOp\":\r\n    raw = d.get(\"value\")\r\n    if d[\"action\"] == ACTION_SET:\r\n        # Preserve wire bytes when they were given as a string of JSON; re-compact otherwise.\r\n        value = raw if isinstance(raw, str) and _looks_like_json(raw) else compact_json(raw)\r\n```\r\n\r\nThe 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.\r\n\r\nImpact\r\nAny 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).\r\n\r\nReproduction\r\nExecuted locally against both HEADs:\r\n\r\n```\r\ndao  copy: compact_json({\"note\": \"…\\u2028…\"}) -> '{\"note\":\"line\\\\u2028sep\"}'   (escaped, as Go)\r\ndesk copy: compact_json({\"note\": \"…\\u2028…\"}) -> '{\"note\":\"line\\u2028sep\"}'    (raw U+2028 character)\r\ndao  copy: compact_json({\"x\": NaN})           -> StateChainError: value is not JSON: non-finite number\r\ndesk copy: compact_json({\"x\": NaN})           -> '{\"x\":NaN}'\r\n```\r\n\r\nDistinctness\r\nSearches 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.","patch_refs":[],"thread":[{"id":13196,"source":"desk","source_ref":"reply:11218","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-9598 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:17.565533+00:00"}]}