@inversealtruism/cairnx-core 0.2.4 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -81,8 +81,9 @@ CNS is an **ENS-class** namespace native to Compute Substrate. A name like `alic
81
81
  address, **leased** (not sold forever), points to an address, and carries an optional profile, all as
82
82
  plain on-chain records, all resolvable by replay.
83
83
 
84
- - **Names are lowercase-ASCII only** (`^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$`, 1–32 chars). This kills
85
- the homograph/confusable phishing class outright, there is no unicode look-alike attack surface.
84
+ - **Names are lowercase-ASCII only** (`^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$`, 1–32 chars). This removes
85
+ the mixed-script homograph class: there is no Unicode look-alike surface. Look-alikes within ASCII remain
86
+ (`paypa1` and `paypal` are distinct, valid names), so an interface that shows a name should still warn on them.
86
87
  - **The `.csd` suffix is presentation, not consensus.** The on-chain record stores the *bare* name
87
88
  (`alice`); the UI renders `alice.csd`. The CNS rebrand and any display-suffix change are **UI-only**, they do not touch the resolver or chain history.
88
89
  - **Reserved names** (`csd`, `treasury`, `admin`, `official`, `root`, `www`, `support`) can never be
@@ -179,10 +180,11 @@ sequenceDiagram
179
180
  - **Ownership has an unambiguous total order:** lowest `(effectiveHeight, position, ordinal-id)` wins, with
180
181
  a paid market-fill (`viaFill`) immune to displacement. Exactly one owner per name at every height.
181
182
 
182
- > **Note on bought names:** a name you *register* is fully SPV-verifiable today. A name acquired via a
183
- > *market fill* is displacement-immune and correctly resolved, but its forward resolution currently shows
184
- > a caution rather than a green check (the wallet never shows it as verified) pending a resolver change
185
- > that makes name-fills name-local. Registration, the alpha's primary flow, is unaffected.
183
+ > **Note on names whose history reads other state:** a replay of one name's records alone cannot decide a
184
+ > name whose history touches a rule that reads other state (a name bought on the market can be one such
185
+ > case). The reference service's name-history read (`/cairnx/name-history/:name`) serves such a name with
186
+ > `scopedReplaySufficient: false`, and a per-name verifier should show it as unverified. A replay of the
187
+ > whole `cairnx:v1` domain decides every name exactly.
186
188
 
187
189
  ---
188
190
 
@@ -278,14 +280,15 @@ v2.4–v2.7 were re-pinned 2026-07-03 from their originally published heights (4
278
280
 
279
281
  ### Package layout
280
282
 
281
- `src/resolve.ts` + `src/resolve/` (the ledger: the replay loop and its per-record handlers) · `src/records.ts` (the parse/validate gate) · `src/types.ts` (constants +
283
+ `src/resolve.ts` + `src/resolve/` (the ledger: the replay loop and its per-record handlers) · `src/events.ts` (the rule
284
+ from a block to events, CONVENTION §33) · `src/hashes.ts` (the state and events hashes, §34) · `src/records.ts` (the parse/validate gate) · `src/types.ts` (constants +
282
285
  height-gated client selectors) · `src/client.ts` (the claim-burial depth a payer waits for, sized against a minority miner) · `src/preflight.ts`
283
286
  (build-side helpers every host must compute identically: `requiredFillOutputs`, `previewFill`/`fillIsSafe`,
284
287
  `buildFeeHeight` + `NAME_FEE_GATES`, `finalizeWinnerCheck`) · `src/primary.ts` (`pickPrimaryName` /
285
288
  `primaryRankBefore`, the one primary-name selection every host must agree on) · `src/mm/` (the
286
289
  `@inversealtruism/cairnx-core/mm` subpath: the market maker's bid sizer, fill notional, Sunrise spot curve and
287
290
  order pricing, and the RFQ all-in sum; not consensus and not part of the root export) · `CONVENTION.md`
288
- (normative spec, §1–§32) · `test/vectors/` (portable conformance corpus).
291
+ (normative spec, §1–§39) · `test/vectors/` (portable conformance corpus).
289
292
 
290
293
  ### Use it
291
294
 
@@ -301,18 +304,41 @@ const built = offer({ give: { ticker: "CAIRN", amount: "5000000000" },
301
304
  const tx = buildPropose({ domain: DOMAIN, uri: built.uri, payloadHash: built.payloadHash,
302
305
  expiresEpoch, fee: 25_000_000, utxos, priv });
303
306
 
304
- // RESOLVE the chain (events come from any indexer; see the Scanner reference impl)
307
+ // RESOLVE the chain. CONVENTION §33 turns blocks into events: blockMembers(height, txs, sofar) names the txs
308
+ // that need an author, blockEvents(height, txs, sofar, authors) returns the block's events, and eventOfTx maps
309
+ // one tx. The author is an input: bind it with csd-crypto's authorOf(tx, scriptPubkey) over the coin the first
310
+ // input spends, read from its source tx. csd-light's bindBlockTxs checks a block's txs against a verified header.
305
311
  const state = resolve(events, tipHeight);
306
312
  console.log(state.names, state.tokens.CAIRN, state.balances.CAIRN);
307
313
  ```
308
314
 
315
+ ### What a resolver result proves
316
+
317
+ - Display: an answer read from someone's API. It is worth the trust you place in that API.
318
+ - Record proof: one record is mined under valid proof of work and was written by the owner of the coin
319
+ its first input spends. It does not prove the record is the latest one, and it decides nothing for a name
320
+ whose history touches a cross-name rule.
321
+ - Replica: a replay of every `cairnx:v1` record. It is exact for names and tokens. What it proves depends
322
+ on where the records came from: one's own node, complete blocks checked against headers, or someone's
323
+ record feed, which is complete only on that feed's word.
324
+
325
+ Other applications, the profile-key registry with its byte budget, the three levels with their sources,
326
+ conformance and how the rules change are `CONVENTION.md` §35 to §39.
327
+
328
+ Why a record was applied or refused: each entry of `resolve(...).events` carries a stable `code` (`CONVENTION.md` §40,
329
+ `REASON_CODES`), and `explainRecord(uri, payloadHash)` names the rule a record breaks before it reaches the resolver.
330
+ Match the code, never the `note` text, which may change; a code your release does not know reads by the entry's `ok`.
331
+
309
332
  ### Write a conformant resolver in another language
310
333
 
311
- 1. Implement `CONVENTION.md` §1–§32 (apply order, every record type, the `V*_HEIGHT` activations (using
312
- the re-pinned v2.4–v2.7 heights), the canonical-state format, ordinal key ordering, data surface only).
313
- 2. Replay `test/vectors/cases.json`, `cases-v29.json` and `cases-rules.json`: your canonical state must equal
314
- `expectedState` **byte-for-byte**.
315
- 3. Replay the live chain and compare `sha256(canonicalState)` against `test/vectors/replay-hashes.json`.
334
+ 1. Implement `CONVENTION.md` §1–§34 (the events of a block, apply order, every record type, the `V*_HEIGHT`
335
+ activations (using the re-pinned v2.4–v2.7 heights), the canonical-state format, ordinal key ordering, data
336
+ surface only).
337
+ 2. Reproduce `test/vectors/events.json` (§33.7). Replay `test/vectors/cases.json`, `cases-v29.json` and
338
+ `cases-rules.json`: your canonical state must equal `expectedState` **byte-for-byte**.
339
+ 3. Replay the live chain and compare the state hash (§34.1) against `test/vectors/replay-hashes.json`, and reproduce
340
+ `test/vectors/hashes.json` (§34.4).
341
+ 4. Only if you publish reason codes (§40): reproduce `test/vectors/codes.json`.
316
342
 
317
343
  ---
318
344