Gaussia
Research blog

Deterministic results: canonical JSON and the result hash

Two honest nodes must hash the same bytes. How gaussia-search and gaussia-match each turn a result into bytes, why their formats differ today, and what still breaks equality.

Gaussia5 min readgaussia-searchgaussia-matchdeterminism

Agreement is a byte comparison

In Gaussia’s design, two nodes run the same job without seeing each other’s work and commit to a hash of their result. The job is verified only when the two hashes are equal. A hash does not care that 3.2860001 and 3.28600009999 mean the same period, or that two JSON files list their keys in a different order. If honest nodes produce different bytes, honest work gets sent to a tiebreak.

So both open-source pieces define a canonical JSON: one exact byte form for any result, hashed with sha256. They do it in two different ways today, and this post shows both, with real output.

gaussia-match: canonical JSON v0

The matching library defines its own form for any JSON result it hashes [3]:

  • Keys sorted by UTF-16 code units, the default JavaScript sort, as in RFC 8785. No whitespace.
  • Strings escaped as ECMAScript’s JSON.stringify does, other characters left as UTF-8.
  • Every number rounded to 6 decimal places, half to even on the exact binary value, then written with the fewest digits: 2.50 → 2.5, 0.1 + 0.2 → 0.3, 4e-7 → 0.
  • Duplicate keys are refused, since parsers disagree on which one wins (v0.9.2 added the strict parser to every command that reads JSON).
  • result_hash = sha256(utf8(canonical)) as 64 hex characters; sha256:<hex> is accepted as input.

The rounding is there because two nodes on different GPUs can differ in the last bits of a float. Rounding lets those runs hash equal in the common case.

The same values in both formats

We ran both canonicalisers on the grid block and on peak 3 (L 98-59 d) of the real L 98-59 result file [2]:

gaussia-search canonical_json

{"log_step":1.0050828e-04,"n_periods":36703,"period_max_days":1.9999509e+01,"period_min_days":5.0000000e-01}
{"depth_ppm":8.8291154e+02,"duration_days":4.0000000e-02,"period_days":7.4507475e+00,"t0":2.9646501e+03}

gaussia-match canonical JSON v0

{"log_step":0.000101,"n_periods":36703,"period_max_days":19.999509,"period_min_days":0.5}
{"depth_ppm":882.91154,"duration_days":0.04,"period_days":7.450748,"t0":2964.6501}
Fieldgaussia-searchgaussia-match v0What changed
period_days7.4507475e+007.4507487th decimal rounded away
log_step1.0050828e-040.0001015 of 8 significant digits lost
depth_ppm8.8291154e+02882.91154same value, different text

Fixed decimal places treat small numbers badly, which is why the spec tells producers to pick units where 6 decimals keep the precision that matters, such as depth in ppm rather than as a fraction [3]. Significant digits suit values of any size but need an exponent in the text.

Hashing the whole file gives two different hashes: the search tool checks its stored sha256:905cb980…c08acc384, while gaussia-match canonicalises the same file its own way:

$ gaussia-search hash examples/l98-59-s61-65.json
ok: matches result_hash in file
$ gaussia-match result-hash examples/l98-59-s61-65.json
result_hash d9933af60f3b156eb6ea0564ccd85cf9a6cc7fb25faafd7935a7f71f5530e04d

How the two fit together today

That is the note in the docs, word for word [4]. So a node running gaussia-search can commit the search tool’s own result_hash directly, and the two formats never have to meet. Still, two implementations of one idea is a cost, and settling on a single format is open work, not a decision we have made.

What still breaks equality

  • Rounding edges. Rounding hides last-bit noise except when a value sits right on a boundary; then two honest runs round apart and the hashes differ like any other mismatch [1] [3].
  • Versions. Any library version difference changes the search hash, so both nodes must run the same pinned release. The Docker image pins its base images by digest [1].
  • Inputs. MAST may reprocess a sector. The input file’s sha256 in the result shows which file was searched.
  • Platforms. Byte equality is tested on x86-64 Linux. Tests on other CPUs and platforms are in progress.

What's in progress

  • One shared canonical format for search results and matching. Today there are two, as above.
  • Byte-equality tests beyond x86-64 Linux, and on GPUs: GPU BLS is in progress.
  • The node software that would run gaussia-search and commit its hash with gaussia-match, and the coordinator that would compare them.
  • Both specs are drafts and may change before v1.
gaussia-search ↗Source, README and honest limitsdocs.gaussia.app ↗Specs and guidesSignal check ↗Cross-match a signal on dapp.gaussia.app

Sources

  1. gaussia-search SPEC.md: canonical JSON, result_hash, what can break byte equality
  2. examples/l98-59-s61-65.json and CHANGELOG v0.6.0
  3. gaussia-match SPEC.md: canonical JSON v0
  4. Gaussia docs: gaussia-search result format