@inversealtruism/cairnx-core 0.2.7 → 0.2.9
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/CHANGELOG.md +82 -0
- package/CONVENTION.md +281 -89
- package/README.md +24 -6
- package/dist/index.cjs +140 -29
- package/dist/index.d.cts +77 -3
- package/dist/index.d.ts +77 -3
- package/dist/index.js +136 -29
- package/package.json +1 -1
- package/test/vectors/cases-convention.json +2202 -0
- package/test/vectors/forward.json +16 -0
- package/test/vectors/moves.json +15 -0
package/CONVENTION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CairnX Convention v1
|
|
2
2
|
|
|
3
|
-
**Status:** v2.9 (normative; v2.9 activated at `V29_HEIGHT` = 88 000, crossed 2026-08-31, see §32; v2.8 activated at 60 000, crossed 2026-07-23; supersedes the 2026-06-10 v1.0 draft; §33 to §
|
|
3
|
+
**Status:** v2.9 (normative; v2.9 activated at `V29_HEIGHT` = 88 000, crossed 2026-08-31, see §32; v2.8 activated at 60 000, crossed 2026-07-23; supersedes the 2026-06-10 v1.0 draft; §33 to §41 carry no gate and move no state) · **Domain:** `cairnx:v1` · **Base activation:** 29 860
|
|
4
4
|
|
|
5
5
|
**Version ladder** (each gate non-retroactive: below it, behavior + canonical hashes are byte-identical to history):
|
|
6
6
|
v1.1 @ 29 960 · v1.2 @ 30 300 · v1.3 @ 31 100 · v1.4 @ 31 400 · v1.5 @ 32 000 · v1.6 @ 33 600 (§19) ·
|
|
@@ -10,8 +10,8 @@ v2.3 @ 52 000 (§26) · v2.8 @ 60 000 (§31) · v2.9 @ 88 000 (§32; its replay
|
|
|
10
10
|
Sections §19–§32 are the normative semantics for v1.6–v2.9; §5.1 is the byte-level canonical-JSON contract that binds all of them.
|
|
11
11
|
§33 is the rule that turns the chain's blocks into the events every version replays; §34 defines the two hashes
|
|
12
12
|
replicas compare. §35 and §36 are for other applications (their domains, the profile-key registry), §37 states what
|
|
13
|
-
a result proves, §38 how a replica conforms, §39 how the rules change
|
|
14
|
-
and of record validation; none of §33 to §
|
|
13
|
+
a result proves, §38 how a replica conforms, §39 how the rules change, §40 the reason codes of the applied log
|
|
14
|
+
and of record validation and §41 the token moves of the applied log; none of §33 to §41 has a gate.
|
|
15
15
|
Activation order is by HEIGHT, not by version number (v1.8 activated after v2.0; v2.3 activates after v2.4–v2.7): a
|
|
16
16
|
replayer gates each rule on its own height constant, never on "version X implies version Y is active".
|
|
17
17
|
|
|
@@ -72,10 +72,13 @@ signatures in v1: anchoring *from your key* is the authorization.
|
|
|
72
72
|
|
|
73
73
|
## 3. Common rules
|
|
74
74
|
|
|
75
|
-
- **Amounts** are strings of decimal integers in base units, `"1"` ≤ x < `2^96
|
|
76
|
-
|
|
75
|
+
- **Amounts** are strings of decimal integers in base units, `"1"` ≤ x < `2^96`, except an offer's price: its
|
|
76
|
+
`want.value` (§4.4) and its `want.amount` (§11) may be `"0"`. Resolvers use arbitrary-precision integers.
|
|
77
|
+
`decimals` (0–8) is display-only.
|
|
77
78
|
- **Tickers** match `^[A-Z][A-Z0-9]{2,11}$`.
|
|
78
79
|
- **Addresses** are `0x` + 40 lowercase hex.
|
|
80
|
+
- **Hashes and ids in records** (`ncommit`'s `commit`, `tmeta`'s `hash`, an offer's `bid`, an `fclaim`'s `offer`) are
|
|
81
|
+
`0x` + 64 lowercase hex (`HASH_RE`); any other form makes the record an invalid no-op (`RECORD_BAD_HASH`).
|
|
79
82
|
- **Apply order:** events are replayed in consensus order: by block height; within a block,
|
|
80
83
|
all `cairnx:v1` proposals in tx order (`pos`), then all attestations on CairnX proposals in tx
|
|
81
84
|
order (the events of §33). (Mirrors the node’s propose/attest phases, C5.) Remaining ties (same height, phase, pos:
|
|
@@ -151,7 +154,7 @@ CairnX meaning for deploys. The **deployer** is the anchoring proposer.
|
|
|
151
154
|
- `taker` (optional): if present, only this address can fill. **Taker-bound offers are the
|
|
152
155
|
protected path** (see §6).
|
|
153
156
|
- The anchoring proposal's **`expires_epoch` is the offer's validity window**: after it, the
|
|
154
|
-
chain itself rejects fill attempts (C5), and the resolver releases the lock. Offers SHOULD
|
|
157
|
+
chain itself rejects fill attempts (C5), and the resolver releases the lock (the expiry sweep of §5). Offers SHOULD
|
|
155
158
|
use short windows (e.g. tip-epoch + 24 ≈ 1 day).
|
|
156
159
|
- An offer is identified by its **proposal id (txid)**.
|
|
157
160
|
- `memo` (64 UTF-16 units max) and `ts` are optional free fields with the same rules as
|
|
@@ -190,18 +193,71 @@ extension shipped at v1.7 (height 34 000) and uses **`score = 50`** (`SCORE_CLAI
|
|
|
190
193
|
## 5. Resolver state (normative output)
|
|
191
194
|
|
|
192
195
|
```
|
|
193
|
-
tokens: ticker → { deployId, deployer, name
|
|
196
|
+
tokens: ticker → { ticker, deployId, deployer, name?, decimals, supply, minted, mint, mintLimit?, height, tmeta? }
|
|
194
197
|
balances: ticker → address → { available, locked }
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
names: name → { name, owner, claimId, height, effectiveHeight, locked, addr?, viaFill?, profile?,
|
|
199
|
+
paidThroughEpoch?, expired? }
|
|
200
|
+
or, for a pending reservation (§28):
|
|
201
|
+
name → { name, owner, claimId, height, effectiveHeight, locked, pending, finalizeBy }
|
|
202
|
+
offers: offerId → { id, seller, give, want: { value, payto } | { ticker, amount, payto }, taker?,
|
|
203
|
+
status: open|filled|cancelled|expired, expiresEpoch, height, feeBps,
|
|
204
|
+
min?, paid?, delivered?, fills?, bid?, claimedBy?, claimUntilHeight?, claimTxid?,
|
|
205
|
+
fill?: { buyer, txid, height, paid, fee, got? } }
|
|
206
|
+
bids: bidId → { id, bidder, want, give: { value }, status: open|cancelled|expired|done,
|
|
207
|
+
expiresEpoch, height, offers }
|
|
208
|
+
feesPaid: the protocol fees owed by applied records (§10), a decimal string
|
|
209
|
+
events: ordered log of applied/no-op decisions { height, pos, id, kind, ok, code, note?, moves? } (for explorers &
|
|
210
|
+
audit; INFORMATIONAL, excluded from the canonical surface; each entry's `code` is stable (§40), its `note`
|
|
211
|
+
text a diagnostic, and an applied record that moved tokens carries its `moves` (§41))
|
|
199
212
|
```
|
|
200
213
|
|
|
214
|
+
An address whose `available` and `locked` are both 0 is left out of `balances`, and so is a ticker with no address
|
|
215
|
+
remaining. `want.payto` is always present: the record's `payto`, or the seller when the record has none.
|
|
216
|
+
|
|
217
|
+
**Fill records.** A whole fill sets `fill` once. Its `paid` is what the fill's transaction pays to `want.payto` (the
|
|
218
|
+
`paidTo` sum of §33.4), overpayment included, and so the maker rebate as well when `payto` is the seller (§19); for a
|
|
219
|
+
token-priced fill it is `want.amount`. Its `fee` is the fee the fill owed (§10, §14, §19). A partial fill (§12) appends
|
|
220
|
+
`{buyer, txid, height, paid, fee, got}` to `fills`, with `paid` its effective payment `x` and `got` the give units it
|
|
221
|
+
delivered; the partial fill that completes the offer also sets `fill` to that same entry, `got` included.
|
|
222
|
+
|
|
223
|
+
**Expiry in the state.** Before each event at height h the resolver expires every open offer and bid whose effective
|
|
224
|
+
expiry epoch (§24, §25) is below `epochOf(h)`, releasing an offer's give, and deletes every reservation (§28) and
|
|
225
|
+
recapture reservation (§29) whose `finalizeBy` is below h. After the last event, and after the deferred cancels of its
|
|
226
|
+
block (§16), it runs the same sweep once more at `tipHeight + 1`. So the state at a tip shows an offer or bid whose
|
|
227
|
+
effective expiry epoch, as the sweep at `tipHeight + 1` computes it, is `epochOf(tipHeight)` as `expired` when
|
|
228
|
+
`tipHeight` is the last height of that epoch (`tipHeight mod 30 = 29`), and as `open` at every earlier tip of the
|
|
229
|
+
epoch. For an offer or bid anchored below V22 that sweep applies the §24 cap once `tipHeight + 1` reaches V21
|
|
230
|
+
(40 100), that is from tip 40 099 on. A name's `expired` (§17) is read at the tip's own epoch: it is present when
|
|
231
|
+
`epochOf(tipHeight) > paidThroughEpoch + NAME_GRACE_EPOCHS`.
|
|
232
|
+
|
|
233
|
+
For the heights a chain produces (block heights, non-negative integers below 2^53) the state at a tip does not depend
|
|
234
|
+
on the heights at which sweeps ran between events: an item only becomes due as the height grows, whether it is due
|
|
235
|
+
reads that item alone, and an expiry writes the item's status and what it releases (an addition to one seller's
|
|
236
|
+
balance, or the unlock of one name) or deletes one reservation. A resolver may apply each expiry at the first height
|
|
237
|
+
it is due, or every due expiry before each event, as cairnx-core 0.2.8 and the Python reference do. So an event that
|
|
238
|
+
writes nothing (§40.1) changes no state: at most it adds a sweep at its height and runs the flush of the previous
|
|
239
|
+
block's deferred cancels (§16) that the next event at a new height would run before its own sweep; below activation,
|
|
240
|
+
or repeated at V29 or above, it adds neither.
|
|
241
|
+
|
|
242
|
+
`resolve()` takes heights and tips of any value, and outside that domain the heights at which sweeps run can matter:
|
|
243
|
+
an offer whose event height is NaN has a NaN cap (§24) from V21 on, so it is due below V21 and at no height from V21
|
|
244
|
+
on, and a commit at the string height "90000" gives a reservation the deadline "90000820", which a sweep compares as
|
|
245
|
+
text at a string height and as a number at a number one. cairnx-core from 0.2.9 applies each expiry at the first
|
|
246
|
+
height it is due only while every event height and the tip it has read is a safe integer (`Number.isSafeInteger`).
|
|
247
|
+
Inside that domain being due only grows with height, so batches at the due heights give the state of one batch per
|
|
248
|
+
sweep; the first height or tip outside it ends the batches before any sweep reads it; from then on every sweep is the
|
|
249
|
+
one before each event and at `tipHeight + 1`, as in 0.2.8. That gives the state 0.2.8 gives for inputs made of plain
|
|
250
|
+
values (what JSON carries); a getter or a conversion with side effects, which the fold reads a different number of
|
|
251
|
+
times, is outside that statement. Outside the domain the result is not consensus: released cores have answered
|
|
252
|
+
differently (0.2.4 and 0.2.7 on a string height), so a caller checks that event heights and the tip are safe integers
|
|
253
|
+
before the call.
|
|
254
|
+
|
|
201
255
|
**Canonical state (format 2, normative):** the canonical surface is
|
|
202
256
|
`{tipHeight, tokens, balances, names, offers, bids, feesPaid}`: the event log is excluded.
|
|
203
|
-
Serialization is **canonical JSON
|
|
204
|
-
depth,
|
|
257
|
+
Serialization is **canonical JSON** in the state form of §5.1: object keys sorted in ordinal (code-unit) order at every
|
|
258
|
+
depth, except that keys which are array indices (the canonical decimal of an integer in [0, 2^32 − 2]: an all-digit
|
|
259
|
+
name, an all-digit profile key) come first in ascending numeric order (§5.1 A2); arrays keep their order (`fills` and a
|
|
260
|
+
bid's `offers` in apply order); no insignificant whitespace, UTF-8, all amounts as decimal strings (no floats anywhere),
|
|
205
261
|
booleans/numbers in their shortest JS form. Two resolvers fed the events of §33 for the same chain prefix MUST produce
|
|
206
262
|
byte-identical canonical state; `sha256(canonicalState)` at the activation heights is pinned in
|
|
207
263
|
`test/vectors/replay-hashes.json`, and `test/vectors/cases.json` carries language-neutral replay
|
|
@@ -252,19 +308,24 @@ once a replay hash is pinned over data that exercises them, so they are stated h
|
|
|
252
308
|
`_js_obj_key_order`/`_js_stringify` in `conformance/cairnx_ref.py`); a third impl MUST reproduce both.
|
|
253
309
|
- **A3: Field types (bare number/boolean vs decimal string vs identity string).** Canonical state mixes
|
|
254
310
|
raw JSON integers and booleans with decimal-string amounts and raw identity strings. Emit as **bare
|
|
255
|
-
integers**: `decimals, height, effectiveHeight, expiresEpoch, feeBps, tipHeight, paidThroughEpoch`,
|
|
256
|
-
(v1.7) `claimUntilHeight` (all JS-safe, < 2^53). Emit as **bare booleans**: `locked, viaFill, expired
|
|
257
|
-
Emit as **decimal strings**: `supply, minted, mintLimit, feesPaid`, every
|
|
258
|
-
`want.value`, `want.amount`, `min`, `paid
|
|
259
|
-
a
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
311
|
+
integers**: `decimals, height, effectiveHeight, expiresEpoch, feeBps, tipHeight, paidThroughEpoch, finalizeBy`,
|
|
312
|
+
and (v1.7) `claimUntilHeight` (all JS-safe, < 2^53). Emit as **bare booleans**: `locked, viaFill, expired,
|
|
313
|
+
pending`. Emit as **decimal strings**: `supply, minted, mintLimit, feesPaid`, every
|
|
314
|
+
`balances.*.available`/`.locked`, an offer's `give.amount`, `want.value`, `want.amount`, `min`, `paid` and
|
|
315
|
+
`delivered`, a bid's `want.amount` and `give.value`, and each fill entry's `paid`, `fee` and `got` (see the fill
|
|
316
|
+
shapes below). Emit as **raw 0x-hex identity strings**: the 32-byte ids, that is the offer and bid `id`, the token
|
|
317
|
+
`deployId`, the name `claimId` (the anchor txid, present on **every** name), a fill's `txid`, the offer `bid` and
|
|
318
|
+
(v2.8) `claimTxid`, and the token `tmeta` (a content hash); and the 20-byte addresses `deployer`, `owner`, `addr`,
|
|
319
|
+
`seller`, `taker`, `want.payto`, `bidder`, `buyer` and (v1.7) `claimedBy`. Emit as plain strings: `ticker`, the
|
|
320
|
+
token `name`, `mint`, a name's `name` (also `give.name` and a bid's `want.name`) and `status`. Emit as **arrays**:
|
|
321
|
+
an offer's `fills` and a bid's `offers` (offer ids), in apply order. Emit as a nested **object**: the name `profile`
|
|
322
|
+
(v1.9 nprofile: a flat string→string map). **Two fill shapes (the `got`-presence rule):** a whole fill (of an offer
|
|
323
|
+
without `min`) is the singular object `fill` = `{buyer, txid, height, paid, fee}` with **no** `got`; a
|
|
324
|
+
partial-fillable (`min`) offer carries an **array** `fills`, each entry `{buyer, txid, height, paid, fee, got}`
|
|
325
|
+
**with** `got` (`got` = the give-asset units delivered by that partial), and the partial fill that completes it also
|
|
326
|
+
sets the singular `fill` to that same entry, `got` included (§5). An implementer who adds `got` to a whole fill, or
|
|
327
|
+
drops it from a `fills[]` entry or from a completed partial offer's `fill`, forks `sha256(canonicalState)`. Never
|
|
328
|
+
serialize an amount as a number or an `f64`; never stringify an integer field.
|
|
268
329
|
> **⚠ v1.7/v1.9 are part of this byte contract on every live tip past their gate** (`V17_HEIGHT=34000`
|
|
269
330
|
> claims, `V19_HEIGHT=36700` profiles). A second-language resolver built to an earlier copy of this list
|
|
270
331
|
> (omitting `claimedBy`/`claimUntilHeight`/`claimId`/`profile`/`fills`) **forks `sha256(canonicalState)`
|
|
@@ -272,11 +333,14 @@ once a replay hash is pinned over data that exercises them, so they are stated h
|
|
|
272
333
|
> `replay-hashes.json` at **every activation height through V20**: incl. 34 000 claims, 36 700 profiles,
|
|
273
334
|
> 38 400 grace; V18/V21 auto-pin once the chain tip crosses them. The static `cases.json` bar additionally
|
|
274
335
|
> pins the V20/V21/nprofile/name-op/lapse byte-contract with no live node required.)
|
|
275
|
-
- **A4: Optional fields are OMITTED, never `null`.** A key whose value is absent is dropped entirely
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
336
|
+
- **A4: Optional fields are OMITTED, never `null`.** A key whose value is absent is dropped entirely: the token
|
|
337
|
+
`name`, `mintLimit` and `tmeta`; the name `addr`, `viaFill`, `profile` (only when an nprofile is set, at v1.9+
|
|
338
|
+
tips), `paidThroughEpoch` (on every name at v1.5+ tips except a pending reservation), `expired`, and `pending` and
|
|
339
|
+
`finalizeBy` (only on a pending reservation, §28); the offer `taker`, `min`, `paid`, `delivered` and `fills` (only on
|
|
340
|
+
a `min` offer, from its creation), `bid`, `claimedBy` and `claimUntilHeight` (from the offer's first claim grant on,
|
|
341
|
+
and kept after the hold ends and after the offer closes, §20), `claimTxid` (from its first fclaim grant on, §31) and
|
|
342
|
+
`fill` (until a whole fill, or the partial fill that completes the offer); and a whole fill's `got`. A zero balance
|
|
343
|
+
is left out as §5 says. Never emit `"addr":null`.
|
|
280
344
|
- **A5: The acceptance gate is a byte-exact round-trip (stronger than the hash check).** A record anchor
|
|
281
345
|
is accepted iff **both** `canonicalJson(JSON.parse(uri)) === uri` (byte-for-byte) **and**
|
|
282
346
|
`sha256(uri) === payload_hash`. The round-trip is what rejects duplicate keys, leading-zero amounts,
|
|
@@ -347,9 +411,10 @@ cap: ecosystem doc 16 §4; these are NOT in canonical state today.)*
|
|
|
347
411
|
payment), so a losing claimer forfeits only the 0.05 CSD attest fee. On that basis v1.7 safely
|
|
348
412
|
**re-opens** untaken CSD offers via claim-to-fill (§20), and v2.0/§23 bounds its late-fill edge.)
|
|
349
413
|
- **No unconfirmed chaining (no CPFP).** The mempool only accepts txs whose inputs exist in the
|
|
350
|
-
confirmed UTXO set: you cannot spend change that hasn't been mined.
|
|
351
|
-
|
|
352
|
-
|
|
414
|
+
confirmed UTXO set: you cannot spend change that hasn't been mined. A key's next action needs a
|
|
415
|
+
confirmed coin: with one coin, one confirmation between actions; a key holding several confirmed
|
|
416
|
+
coins can anchor several records in one block (§16). Client software that spends one coin must
|
|
417
|
+
serialize its actions and surface this ("next action available after 1 conf").
|
|
353
418
|
- **No native-CSD pools.** CSD itself cannot be locked by convention (real UTXOs obey only
|
|
354
419
|
keys). CairnX trades CSD↔token atomically per-trade; it does not and cannot pool CSD.
|
|
355
420
|
- **Reorgs:** state is a pure function of the chain; resolvers recompute (or roll back) on
|
|
@@ -391,20 +456,27 @@ owned purely on-chain: register, hold, point it at an address, transfer, or sell
|
|
|
391
456
|
Reserved: `csd treasury admin official root www support` (`cairn`/`cairnx` are deliberately
|
|
392
457
|
NOT reserved: the operator registered them as ordinary, tradeable names).
|
|
393
458
|
- **`name` (claim):** `{v:1,t:"name",name,salt?}`. Owner = anchoring proposer. **Lowest
|
|
394
|
-
effective
|
|
459
|
+
effective anchor (effHeight, pos, id) wins**, numeric on `effHeight` and `pos`, ordinal (code-unit) on `id`:
|
|
460
|
+
`effHeight` is the claim's own height, or a reveal's commit height (below); `pos` and `id` are always the claim or
|
|
461
|
+
reveal record's own position and transaction id, never the commit's. Requires the registration fee (§ below).
|
|
395
462
|
- **Direct claim** (no `salt`): effective height = claim height. Simple, instant; front-runnable.
|
|
396
|
-
- **Commit-reveal** (`salt` present):
|
|
397
|
-
|
|
463
|
+
- **Commit-reveal** (`salt` present): `salt` is 16 to 128 hex digits in either case (`SALT_RE`,
|
|
464
|
+
`^[0-9a-fA-F]{16,128}$`); any other `salt` makes the record an invalid no-op (`RECORD_BAD_SALT`). A prior
|
|
465
|
+
`ncommit` of `sha256({t:"cairnx:name:commit:v1", name,salt,owner})` must exist at a strictly lower height within
|
|
466
|
+
`COMMIT_MAX_BLOCKS` (8 epochs): with the commit height the LOWEST height at which that commit hash was anchored,
|
|
467
|
+
the reveal is valid only when `0 < revealHeight − commitHeight ≤ COMMIT_MAX_BLOCKS` (`REG_COMMIT_MAX_BLOCKS = 8`
|
|
468
|
+
blocks from v2.5, §28). A later anchoring of the same commit hash leaves that height as it is, so it does not
|
|
469
|
+
reopen a window that has passed; a retry after the window needs a fresh salt.
|
|
398
470
|
The reveal **back-dates** its effective height to the commit height, so a committer beats any
|
|
399
471
|
direct-claim squatter who acts in between (the reveal **displaces** them). This is the
|
|
400
472
|
front-run defense (ENS/Namecoin/Runes pattern adapted to a fee-ordered chain).
|
|
401
473
|
- **`ncommit`:** `{v:1,t:"ncommit",commit}`: the commit hash (binds name+salt+owner, so it can't
|
|
402
474
|
be reused by another address). Cheap; the reg fee is paid at reveal.
|
|
403
475
|
- **`nxfer`:** `{v:1,t:"nxfer",name,to}`: owner gifts the name. Clears the resolver record. Fails
|
|
404
|
-
while the name is locked by an open offer.
|
|
476
|
+
while the name is locked by an open offer, and on a pending reservation (§28).
|
|
405
477
|
- **`nset`:** `{v:1,t:"nset",name,addr}`: owner points the name at an address (the resolver
|
|
406
|
-
record). Reverse resolution (address → names owned) is computed by the resolver.
|
|
407
|
-
- **Selling a name:** an `offer` with `give:{name}` (instead of `{ticker,amount}`). Anchoring it
|
|
478
|
+
record). Fails on a pending reservation (§28). Reverse resolution (address → names owned) is computed by the resolver.
|
|
479
|
+
- **Selling a name:** an `offer` with `give:{name}` (instead of `{ticker,amount}`), not on a pending reservation (§28). Anchoring it
|
|
408
480
|
**locks** the name (can't transfer/re-offer); a `fill` transfers ownership to the buyer and pays
|
|
409
481
|
the seller (+ protocol fee), atomically, in one tx; cancel/expiry release the lock.
|
|
410
482
|
- **Honest limits (v1.1, superseded):** names were **perpetual** through v1.4 (the registration fee
|
|
@@ -427,8 +499,12 @@ bearing action is a **no-op unless its own transaction pays the fee to the treas
|
|
|
427
499
|
|
|
428
500
|
Mint, transfer, name-xfer, name-set, offer, commit and cancel pay only the chain's own anchor fee
|
|
429
501
|
(to miners), not a protocol fee. An offer's `want.payto` may not be the treasury (keeps the
|
|
430
|
-
payment and fee output buckets distinct)
|
|
431
|
-
|
|
502
|
+
payment and fee output buckets distinct); since `payto` defaults to the seller, an offer the treasury anchors names
|
|
503
|
+
another `payto`. The resolver tracks `feesPaid`, recomputable by anyone like all CairnX state: the sum of the fees
|
|
504
|
+
that applied fee-bearing records owed, not of what was paid to the treasury. Each applied deploy (from 29 960),
|
|
505
|
+
registration or finalize, renewal and recapture adds its fee or premium, and each applied CSD-priced fill, whole or
|
|
506
|
+
partial, adds its trade fee (§19); an overpayment, a treasury output on a record that owes no fee and the outputs of a
|
|
507
|
+
refused record add nothing, and the in-kind fee of a token-priced fill is not counted (§14).
|
|
432
508
|
|
|
433
509
|
---
|
|
434
510
|
|
|
@@ -449,6 +525,9 @@ An offer's `want` may now be a **token amount** instead of a CSD value:
|
|
|
449
525
|
- `want.ticker` must exist at fill time (checked at apply, like every balance rule); a
|
|
450
526
|
token-priced offer over an unknown ticker simply can never fill until that ticker exists.
|
|
451
527
|
`give.ticker ≠ want.ticker`. `give` may also be a **name** (sell a name for tokens).
|
|
528
|
+
- `want.amount` may be `"0"` (§3), as `want.value` may (§4.4). Such an offer is filled for nothing: the fill debits
|
|
529
|
+
`0 + ceil(0)` = 0, so an attester holding none of `want.ticker` fills it (with the marker below, and as its taker
|
|
530
|
+
when it is taker-bound).
|
|
452
531
|
- Anchoring locks `give` exactly as in v1 (§4.4). `want.payto` (default seller) receives the
|
|
453
532
|
want-tokens; it may not be the treasury.
|
|
454
533
|
- **Fill** = an `Attest` with `score = 100` **and `confidence = 1 000 000`** whose attester's
|
|
@@ -488,10 +567,13 @@ A CSD-priced **token** offer may opt into partial fills with `min`:
|
|
|
488
567
|
`deliveredCum' = floor(give.amount × paidCum' / want.value)`: each fill delivers
|
|
489
568
|
`deliveredCum' − deliveredCum`. The final fill (`paidCum' = want.value`) therefore delivers
|
|
490
569
|
exactly the undelivered remainder; rounding dust never strands in the lock.
|
|
570
|
+
- A partial fill that would deliver nothing (`deliveredCum' = deliveredCum`) is a no-op (`FILL_ZERO_DELIVERY`): it is
|
|
571
|
+
not appended, `paid`, `delivered` and `feesPaid` do not move, and its payment stays with `payto` (§4.5).
|
|
491
572
|
- `fee = ceil(1% × x)` to the treasury in the same tx, per fill.
|
|
492
573
|
- The offer stays `open` until `paidCum = want.value` → `filled`. Cancel/expiry release the
|
|
493
574
|
undelivered remainder to the seller; completed partial fills stand.
|
|
494
|
-
- Each fill is appended to the offer's `fills[]` (buyer, txid, height, paid
|
|
575
|
+
- Each applied partial fill is appended to the offer's `fills[]` (buyer, txid, height, paid = `x`, got, fee); the one
|
|
576
|
+
that completes the offer is also its `fill` (§5).
|
|
495
577
|
- Open partially-fillable offers race like v1 open offers (fee auction, §6), but losing a
|
|
496
578
|
race now only costs the loser the *overlap*: their payment still buys whatever remained.
|
|
497
579
|
Wallets must still warn on open-offer fills.
|
|
@@ -503,10 +585,16 @@ A CSD-priced **token** offer may opt into partial fills with `min`:
|
|
|
503
585
|
```
|
|
504
586
|
|
|
505
587
|
Cancels **all of the proposer's open offers anchored strictly earlier in apply order**, releasing
|
|
506
|
-
their locks, optionally filtered to one `give` asset (`ticker` or `name`, at most one)
|
|
588
|
+
their locks, optionally filtered to one `give` asset (`ticker` or `name`, at most one), except what §31 exempts: a
|
|
589
|
+
taker-bound offer anchored at V28 or above is not a target (Lane B), and from V28 the block-boundary flush skips a
|
|
590
|
+
target under a live fclaim hold (Correction 2). Without
|
|
507
591
|
cheap mass-cancel a market maker cannot keep a ladder of quotes honest (per-offer cancel = one tx
|
|
508
|
-
each: the 0x `minValidSalt` lesson). Anchor an `ocancel`, then re-post the fresh ladder
|
|
509
|
-
|
|
592
|
+
each: the 0x `minValidSalt` lesson). Anchor an `ocancel`, then re-post the fresh ladder in a later block. From v1.4
|
|
593
|
+
(height 31 400, §16) an `ocancel`'s effect waits for the end of its block, so the give it releases stays locked for the
|
|
594
|
+
rest of that block: an offer of that give later in the same block is refused (`TOKEN_BALANCE_LOW` for tokens,
|
|
595
|
+
`NAME_LOCKED` for a name) and its anchor fee is spent for nothing. A same-block offer at a later position is not a
|
|
596
|
+
target of the `ocancel` (its targets are fixed when it applies), so it stands when the proposer's available balance
|
|
597
|
+
covers it without the released amount.
|
|
510
598
|
|
|
511
599
|
**Self-fills** (attester == seller) are **valid** and pay the protocol fee like any fill: wash
|
|
512
600
|
trading is self-punishing, and a no-op rule would just complicate determinism. **Fill races on
|
|
@@ -529,12 +617,17 @@ of the book is instead built from **bids**, on-chain discovery records:
|
|
|
529
617
|
- `memo` (64 UTF-16 units max) and `ts` are optional free fields, same rules as 4.3; `ts` MUST
|
|
530
618
|
be a JS-safe integer (A8).
|
|
531
619
|
- **Fulfillment** is the two-step RFQ: the asset owner anchors a **taker-bound offer**
|
|
532
|
-
(`taker = bidder`, price ≤ bid) optionally tagged `"bid":"<bidId>"
|
|
620
|
+
(`taker = bidder`, price ≤ bid) optionally tagged `"bid":"<bidId>"` (the bid's id, §3); the bidder's client
|
|
533
621
|
detects the responding offer and fills it atomically. Two anchors + one fill: the
|
|
534
622
|
scriptless ceiling for buy-side flow.
|
|
535
|
-
- The resolver tracks `bids` (open/cancelled/expired)
|
|
536
|
-
|
|
537
|
-
|
|
623
|
+
- The resolver tracks `bids` (open/cancelled/expired/done). An applied offer whose `bid` names a bid in `bids` is
|
|
624
|
+
appended to that bid's `offers` (in apply order) whatever its taker, its price and the bid's status: taker = bidder
|
|
625
|
+
and price ≤ bid describe an honest answer, not a condition of the link. An offer whose `bid` names no bid when it
|
|
626
|
+
applies is created with its `bid` and is never added to a bid's `offers`, then or later. A fill that closes an offer
|
|
627
|
+
carrying `bid` (a whole fill, or the partial fill that completes it) looks that id up in `bids` at the fill, not
|
|
628
|
+
through `offers`, and marks the bid `done` when it exists, the buyer is its bidder and it is still `open`; a bid
|
|
629
|
+
already cancelled or expired keeps its status, and a bid anchored after the offer naming it can be `done` with empty
|
|
630
|
+
`offers` (purely informational).
|
|
538
631
|
- No protocol fee on bids (the anchor fee to miners is the spam price; the trade fee is paid
|
|
539
632
|
when the responding offer fills).
|
|
540
633
|
|
|
@@ -642,10 +735,10 @@ From height **31 400**:
|
|
|
642
735
|
after the flush.
|
|
643
736
|
- **Why deferral, not reordering:** moving cancels after fills in the sort would break the
|
|
644
737
|
global ordered loop and the "offers settle before fills" invariant for every other record
|
|
645
|
-
type. Deferring only the effect keeps apply order intact.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
738
|
+
type. Deferring only the effect keeps apply order intact. A relist by the same key later in
|
|
739
|
+
the cancel's block sees the lock state before the flush, so a relist that needs the give the
|
|
740
|
+
cancel releases is refused (§12b). One key can anchor several records in one block, each spending
|
|
741
|
+
its own confirmed coin.
|
|
649
742
|
- **Determinism:** the deferred-cancel list is built and flushed in apply order, so the state
|
|
650
743
|
(and the event log) remains a pure function of the chain prefix. Non-retroactive: pre-v1.4
|
|
651
744
|
blocks never defer, so all historical replay is byte-identical.
|
|
@@ -659,17 +752,23 @@ lose more than the anchor fee: not to another buyer (race), and not to the selle
|
|
|
659
752
|
**once, forever**: squatting is free to carry, and lapsed projects strand names permanently.
|
|
660
753
|
From height **32 000** every name is a **lease**:
|
|
661
754
|
|
|
662
|
-
- **Term:** a claim (or premium re-claim) is paid through `claimEpoch + 8 760` epochs (≈ 1 year)
|
|
755
|
+
- **Term:** a claim (or premium re-claim) is paid through `claimEpoch + 8 760` epochs (≈ 1 year), with `claimEpoch`
|
|
756
|
+
the epoch of the claim or reveal record's own height, not of its back-dated effective height (from v2.5 the lease
|
|
757
|
+
starts at the finalize instead, §28, §29).
|
|
663
758
|
Names claimed before v1.5 are **grandfathered** one full term from activation
|
|
664
759
|
(`epochOf(32 000) + 8 760`), computed lazily, no state rewrite at the boundary.
|
|
665
760
|
- **`nrenew` `{v:1,t:"nrenew",name}`:** extends the lease one term from its CURRENT end. Valid
|
|
666
761
|
from **anyone** while the lease is live (third-party gifting, ENS-style) iff the same tx pays
|
|
667
|
-
`nameRegFee(name)` to the treasury. A renewal never changes ownership.
|
|
762
|
+
`nameRegFee(name)` to the treasury. A renewal never changes ownership. A pending reservation (§28) holds no lease and
|
|
763
|
+
is not renewed, by anyone.
|
|
668
764
|
- **Grace (720 epochs ≈ 30 days):** past `paidThroughEpoch`, only the **owner** may renew;
|
|
669
765
|
otherwise a squatter could extend a lapsing name they intend to take.
|
|
670
766
|
- **Lapse → decaying-premium recapture:** past grace the name is unowned again. Anyone may claim
|
|
671
|
-
it by paying `expiredClaimFee(name,
|
|
672
|
-
|
|
767
|
+
it by paying `expiredClaimFee(name, e) = nameRegFee(name) × m(e)`, priced at height `h` (the finalize from v2.6,
|
|
768
|
+
§29), where `e = epochOf(h) − (paidThroughEpoch + 720)` counts the epochs past the grace end (at least 1, since the
|
|
769
|
+
name has lapsed) and, in integer division, `m(e) = 1 + floor(19 × (720 − e) / 720)` for `e < 720` and `m(e) = 1`
|
|
770
|
+
from `e = 720` on. `m` is a staircase that steps down from 19 at `e = 1` to 1 from `e = 683` on.
|
|
771
|
+
The 20 of `NAME_PREMIUM_START` would apply only at `e = 0`, where the name has not lapsed. The re-claim is a
|
|
673
772
|
**fresh basis**: prior `viaFill` immunity is void (immunity protects a *paid* basis; an unpaid
|
|
674
773
|
lease is an abandoned one), and any still-open offer on the name is voided with its lock freed.
|
|
675
774
|
- **Guards:** `nxfer`/`nset` on a lapsed lease are no-ops. A name **offer** is a no-op unless the
|
|
@@ -677,14 +776,14 @@ From height **32 000** every name is a **lease**:
|
|
|
677
776
|
never hit a mid-window lapse; the alternative (a no-op'd CSD fill whose payment already
|
|
678
777
|
confirmed to the seller) would be a fund-loss shape, so it is made unrepresentable. Offers
|
|
679
778
|
anchored before v1.5 are exempt (their windows all end long before any grandfathered lease).
|
|
680
|
-
- **State:** at v1.5+ tips
|
|
681
|
-
lapsed; the record is kept for history until re-claimed). Pre-v1.5 canonical hashes are
|
|
779
|
+
- **State:** at v1.5+ tips every name except a pending reservation (§28) carries `paidThroughEpoch` (and
|
|
780
|
+
`expired: true` once lapsed at the tip's epoch, §5; the record is kept for history until re-claimed). Pre-v1.5 canonical hashes are
|
|
682
781
|
unchanged: the fields exist only at v1.5+ tips.
|
|
683
782
|
|
|
684
783
|
## 18. `tmeta`: issuer token metadata via the content layer (v1.5)
|
|
685
784
|
|
|
686
785
|
`{v:1,t:"tmeta",ticker,hash}`: **issuer-only**, last write wins, no fee beyond the anchor.
|
|
687
|
-
`hash` is a CSD Content Convention v1 hash (0x + 64 hex; `payloadHash` in csd-codec) pointing at
|
|
786
|
+
`hash` is a CSD Content Convention v1 hash (0x + 64 lowercase hex, §3; `payloadHash` in csd-codec) pointing at
|
|
688
787
|
the token's `{logo, description, links}` document: self-certifying content, so the record stays tiny
|
|
689
788
|
(the 512-byte `uri` cap is untouched) and any copy of the document can be checked against the hash
|
|
690
789
|
on read (`verifyContentBytes` in csd-codec). The csd-swarm content service this section was written
|
|
@@ -701,7 +800,8 @@ before v1.5 are no-ops.
|
|
|
701
800
|
|
|
702
801
|
- **Fee bump.** The taker fee becomes `FEE_BPS_V16 = 150` (1.5%, `ceil`) instead of `FEE_BPS = 100` (1%).
|
|
703
802
|
The rate is **captured per-offer at creation height** into `offers[id].feeBps` (a bare-int canonical field,
|
|
704
|
-
§5.1-A3): an offer anchored ≥ 33 600 carries `feeBps = 150`,
|
|
803
|
+
§5.1-A3): an offer anchored ≥ 33 600 carries `feeBps = 150`, one anchored in [29 960, 33 600) carries `100`, and one
|
|
804
|
+
anchored below 29 960 (v1.1) carries `0` and owes no trade fee (§10). Every fill of that
|
|
705
805
|
offer (whole, partial, token-priced) uses the offer's own `feeBps`, so pre-v1.6 offers are byte-identical
|
|
706
806
|
forever. A third-party resolver MUST select the fee by **offer-creation height**, not by fill height.
|
|
707
807
|
- **Maker rebate (whole CSD-priced fills only).** On a whole fill of a **resting-liquidity** CSD-priced offer,
|
|
@@ -736,7 +836,9 @@ the 0.05 CSD attest fee, never a payment.
|
|
|
736
836
|
- **Claim** = an `Attest` on the offer with **`score = SCORE_CLAIM = 50`** (∉ {fill 100, cancel 0}, so it is an
|
|
737
837
|
inert no-op below V17, non-retroactive). It grants the attester an **exclusive hold** of the offer for
|
|
738
838
|
`CLAIM_WINDOW_BLOCKS = 15` blocks: on grant the resolver records `offers[id].claimedBy = attester` and
|
|
739
|
-
`offers[id].claimUntilHeight = grantHeight + 15` (both canonical fields, §5.1-A3,
|
|
839
|
+
`offers[id].claimUntilHeight = grantHeight + 15` (both canonical fields, §5.1-A3, written at each grant and kept
|
|
840
|
+
after the hold ends and after the offer closes: a hold's end is read from `claimUntilHeight`, not from the fields'
|
|
841
|
+
absence).
|
|
740
842
|
- **Fill gate.** A `SCORE_FILL` fill on an **untaken** (`taker === undefined`) CSD-priced offer at height ≥ V17
|
|
741
843
|
is valid **only if** the offer is currently held **and the filler is the holder**: `claimHeld(o, h) &&
|
|
742
844
|
attester === o.claimedBy`, where `claimHeld(o, h) = (o.claimedBy !== undefined) && (h < o.claimUntilHeight)`
|
|
@@ -788,8 +890,8 @@ no-op that forfeits the treasury output.)
|
|
|
788
890
|
- **Inert metadata.** `p` is a flat string→string map. It carries **no fee, no value, and is never a send
|
|
789
891
|
target**: the address a name resolves to for payment stays in `nset` (`names[x].addr`). A resolver keeps
|
|
790
892
|
no reserved keys; the app layer keeps send targets out of `p`.
|
|
791
|
-
- **Owner-gated, last-write-wins.** Valid iff the proposer is the current name owner
|
|
792
|
-
lapsed (§17). The new `p` **replaces** the prior profile; an **empty `p` (`{}`) clears it**.
|
|
893
|
+
- **Owner-gated, last-write-wins.** Valid iff the proposer is the current name owner, the lease is not
|
|
894
|
+
lapsed (§17) and the name is not a pending reservation (§28). The new `p` **replaces** the prior profile; an **empty `p` (`{}`) clears it**.
|
|
793
895
|
- **Cleared on every ownership change**: `nxfer`, a name `fill`, and a lapsed-premium re-claim all clear
|
|
794
896
|
`profile` exactly as they clear `addr`.
|
|
795
897
|
- **Shape limits (deterministic):** keys match `PKEY = ^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$` (ASCII only,
|
|
@@ -867,9 +969,11 @@ The §24 lifetime cap proved to be an infrastructure symptom, not a market need,
|
|
|
867
969
|
- **Anchor in [40 100, 41 300):** the §24 rules apply to that offer/bid FOREVER (creation gate at its
|
|
868
970
|
anchor, capped `effExpiry` in every later sweep). Era membership is fixed by the anchor, so every
|
|
869
971
|
replayer ages the same record identically regardless of when it replays.
|
|
870
|
-
- **Anchor < 40 100:**
|
|
871
|
-
|
|
872
|
-
|
|
972
|
+
- **Anchor < 40 100:** no creation gate (the record predates it), but every sweep at a height ≥ V21 reads it with the
|
|
973
|
+
capped `effExpiry` of §24, so over-cap inventory from before V21 expires at the first such sweep past its cap; a
|
|
974
|
+
sweep below V21 reads the raw `expires_epoch`, so every pre-V21 state is unchanged.
|
|
975
|
+
- **Client closed form:** for anchor ≥ V22, `offerExpiryHeight = (expires_epoch+1)·30`; for every anchor below V22,
|
|
976
|
+
`min((expires_epoch+1)·30, max(40 100, (epochOf(anchor)+MAX_OFFER_EPOCHS+1)·30))` (`offerExpiryHeightOf`).
|
|
873
977
|
- **Adoption note:** a relaxation. A v2.1-only replayer rejects (no-ops) a long-dated offer the chain
|
|
874
978
|
accepts, so its book diverges from the canonical one from the first over-cap anchor onward. Every
|
|
875
979
|
replayer must run the v2.2 core before the tip crosses 41 300 (already long past; stated for the record).
|
|
@@ -945,16 +1049,21 @@ the settled winner ever pays.
|
|
|
945
1049
|
is rejected at/after v2.5 (`v2.5: registration requires a commit-reveal (salt)`): an unsealed
|
|
946
1050
|
registration could not be finalized.
|
|
947
1051
|
- **Reveal (`name` record, height ≥ 46 440):** carries NO registration fee. Creates a PENDING reservation,
|
|
948
|
-
materialized in canonical state as
|
|
949
|
-
`finalizeBy = effHeight + 8 + 20` (`REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS`).
|
|
1052
|
+
materialized in canonical state (at v2.5+ tips) as exactly `{name, owner, claimId, height, effectiveHeight, locked,
|
|
1053
|
+
pending: true, finalizeBy}`, with `finalizeBy = effHeight + 8 + 20` (`REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS`).
|
|
1054
|
+
It holds no lease, so it carries no `paidThroughEpoch` and no `expired`, and it carries no `addr`, `viaFill` or
|
|
1055
|
+
`profile`.
|
|
1056
|
+
- **While pending** the reservation gives its owner only the right to finalize it: `nxfer`, `nset`, `nprofile` and a
|
|
1057
|
+
name `offer` by the owner, and `nrenew` by anyone, are no-ops on it (`NAME_PENDING`). Only `nfinalize`, a displacing
|
|
1058
|
+
reveal (below) and the expiry sweep act on a reservation.
|
|
950
1059
|
- **Contest while pending:** a rival reveal with a strictly earlier `(effHeight, pos, id)` (numeric on
|
|
951
|
-
`effHeight` and `pos`, ordinal code-unit on `id`; earliest wins) DISPLACES the reservation; the displaced party has lost only its
|
|
1060
|
+
`effHeight` and `pos`, ordinal code-unit on `id`; `pos` and `id` the reveal's own, §9; earliest wins) DISPLACES the reservation; the displaced party has lost only its
|
|
952
1061
|
~0.25 CSD anchor. A FINALIZED name can never be displaced: any window-valid challenger has an
|
|
953
1062
|
`effHeight` within 8 blocks of the current height, which is strictly later than a finalized name's
|
|
954
1063
|
(its freeze has passed). Names owned `viaFill` are likewise never displaced.
|
|
955
1064
|
- **Per-address cap:** at most `MAX_PENDING_REG = 3` concurrent un-finalized reservations per owner
|
|
956
1065
|
(expired ones and a re-reveal of the same name do not count); excess reveals are no-ops.
|
|
957
|
-
- **Finalize (`nfinalize` record):** `{v:1, t:"nfinalize", name, salt}
|
|
1066
|
+
- **Finalize (`nfinalize` record):** `{v:1, t:"nfinalize", name, salt}`, `salt` in the form of §9. Valid iff ALL of: the name is
|
|
958
1067
|
pending and owned by the sender; `salt` re-derives the SAME commit that anchored the reservation
|
|
959
1068
|
(`sha256` per §9, binding name + salt + owner, and the commit's height must equal the reservation's
|
|
960
1069
|
`effHeight`); the freeze has passed (`ev.height > effHeight + 8`); the reservation has not expired
|
|
@@ -962,9 +1071,10 @@ the settled winner ever pays.
|
|
|
962
1071
|
(§27, priced at the FINALIZE height). On success the `pending`/`finalizeBy` keys become ABSENT, the
|
|
963
1072
|
lease starts (`paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS`), and the name is NOT
|
|
964
1073
|
`viaFill`.
|
|
965
|
-
- **Reservation expiry (lazy):** past `finalizeBy` an un-finalized reservation is
|
|
966
|
-
|
|
967
|
-
|
|
1074
|
+
- **Reservation expiry (lazy):** past `finalizeBy` an un-finalized reservation is deleted by the expiry sweep of §5
|
|
1075
|
+
(before each event above `finalizeBy`, and at the closing sweep at `tipHeight + 1`, so it is gone from the state at
|
|
1076
|
+
a tip equal to `finalizeBy`, although an `nfinalize` mined at that height still applies), and the name reopens. The
|
|
1077
|
+
would-be winner has lost only anchors, never the registration fee.
|
|
968
1078
|
- **Client timing rule** (`FINALIZE_TIP_MARGIN = 2`, client-side only): sign the finalize at
|
|
969
1079
|
`effHeight + 8 + 2` or later so one reorg cannot un-freeze the contest under a fee-bearing tx. The
|
|
970
1080
|
20-block grace exists so a slow inclusion still lands before `finalizeBy`.
|
|
@@ -989,12 +1099,15 @@ decaying premium (up to hundreds of CSD).
|
|
|
989
1099
|
record in `names` is left untouched (it is the premium basis; an abandoned reservation can never
|
|
990
1100
|
bypass the premium). Below v2.6, recapture stays pay-now at reveal (§17, byte-identical).
|
|
991
1101
|
- **Same windows and contest:** reveal window and freeze are `REG_COMMIT_MAX_BLOCKS = 8`;
|
|
992
|
-
`finalizeBy = effHeight + 8 + 20`; lowest `(effHeight, pos, id)` displaces among reservations; its own
|
|
1102
|
+
`finalizeBy = effHeight + 8 + 20`; lowest `(effHeight, pos, id)` (the reveal's own `pos` and `id`) displaces among reservations; its own
|
|
993
1103
|
`MAX_PENDING_REG = 3` per-address cap; overdue reservations are lazily swept.
|
|
994
1104
|
- **Finalize:** the same `nfinalize` record, salt-bound to the recapture commit. The winner pays the §17
|
|
995
1105
|
decaying premium priced at the FINALIZE height (slightly more decayed than at reveal: rounding favors
|
|
996
1106
|
the payer). On success the name becomes a normal fresh lease under the new owner, NOT `viaFill`
|
|
997
|
-
(displacement-immune by the same freeze arithmetic as §28).
|
|
1107
|
+
(displacement-immune by the same freeze arithmetic as §28). The new record keeps the reveal's anchor: `claimId` is
|
|
1108
|
+
the reveal's transaction id, `height` the reveal's height and `effectiveHeight` its commit's height (the finalize's
|
|
1109
|
+
own id and height are not recorded), and `paidThroughEpoch = epochOf(finalize height) + NAME_TERM_EPOCHS`; it
|
|
1110
|
+
carries no `addr` or `profile`, and `locked` is false.
|
|
998
1111
|
- **Replayer note:** because the reservation map is internal, pre-v2.6 canonical hashes are untouched,
|
|
999
1112
|
but a third-party resolver MUST still replicate the map (reveal, displacement, expiry) to agree on
|
|
1000
1113
|
which later `nfinalize` succeeds. The map is defined by this section plus the reference resolver and
|
|
@@ -1060,15 +1173,16 @@ gate a parsed fclaim is inert (nfinalize precedent, §28).
|
|
|
1060
1173
|
stays at the 0.05 attest floor; only the claim rises to the 0.25 propose floor.
|
|
1061
1174
|
|
|
1062
1175
|
**Grant (the propose handler, at height `h >= V28_HEIGHT`).** A well-formed fclaim grants a hold iff, in order:
|
|
1063
|
-
the referenced offer exists AND is `open` AND untaken (`!taker`) AND CSD-priced; `E <= effExpiry(offer, h)`
|
|
1176
|
+
`E` is at most 2^53 − 1 (§33.4); the referenced offer exists AND is `open` AND untaken (`!taker`) AND CSD-priced; `E <= effExpiry(offer, h)`
|
|
1064
1177
|
(§24 / §25, so the hold never outlives the offer); `E <= epochOf(h) + FCLAIM_MAX_EPOCH_AHEAD` (`= 2`, anti-squat,
|
|
1065
1178
|
bounding a hold to `EPOCH_LEN*(2 + 1) - 1 = 89` blocks); `epochOf(h) <= E` (lower bound); the offer has no live
|
|
1066
1179
|
hold (`!claimHeld`, unifying legacy and fclaim holds so one offer is never double-held); the same-offer cooldown
|
|
1067
1180
|
has elapsed (`h >= o.claimUntilHeight + grace + CLAIM_COOLDOWN_BLOCKS` for the last holder, where `grace` is the
|
|
1068
1181
|
prior hold's era grace per §20 / §23, i.e. 0 for a prior fclaim hold and `CLAIM_FILL_GRACE_BLOCKS` for a prior
|
|
1069
1182
|
legacy hold; the cooldown runs from the END of the prior hold, so a straddling legacy hold and a fresh fclaim
|
|
1070
|
-
never disagree); and the proposer holds fewer than `MAX_ACTIVE_CLAIMS` (`= 3`) live holds.
|
|
1071
|
-
|
|
1183
|
+
never disagree); and the proposer holds fewer than `MAX_ACTIVE_CLAIMS` (`= 3`) live holds. The grant is the
|
|
1184
|
+
conjunction of these clauses, so their order decides only the reason code of a denial: the code of the first clause
|
|
1185
|
+
broken (§40.1). The Python reference checks them in this order and writes no codes. On grant the resolver records `claimedBy = proposer`, `claimUntilHeight = (E + 1)*EPOCH_LEN`, and
|
|
1072
1186
|
`claimTxid = fclaimTxid`.
|
|
1073
1187
|
|
|
1074
1188
|
**Last-write-wins (fund-safety).** All three fields are last-write-wins: a later grant on the same offer (after
|
|
@@ -1179,7 +1293,12 @@ transaction can also be mined again: coinbase txids are not unique on this chain
|
|
|
1179
1293
|
created again and the same spending transaction mined in a later block. Those copies sit in two blocks,
|
|
1180
1294
|
possibly on both sides of the gate, and `resolve()` fed both drops the later copy only when both are at or
|
|
1181
1295
|
above the gate. §33 keeps the first occurrence, so a feed built by its rule holds neither kind of duplicate;
|
|
1182
|
-
the drop above stays the rule for a feed that is not built by it.
|
|
1296
|
+
the drop above stays the rule for a feed that is not built by it. A list holding one transaction id at two places (a
|
|
1297
|
+
later height, or another position in the same block) with the first copy below the gate is not a list §33 produces
|
|
1298
|
+
(§33.2), and no level of §38 covers `resolve()` over it; there the two reference implementations differ: from V14, an
|
|
1299
|
+
offer among its seller's `ocancel` targets, fed again after that `ocancel` in its block, stays open past its expiry in
|
|
1300
|
+
cairnx-core and expires in the Python reference. Two copies at one height and position below the gate both apply in
|
|
1301
|
+
both, as `cases-v29.json` pins.
|
|
1183
1302
|
|
|
1184
1303
|
**M5: the concurrent-hold cap counts only OPEN holds (relaxation).** §20/§31 cap an address at
|
|
1185
1304
|
`MAX_ACTIVE_CLAIMS` (= 3) live holds, counted as `claimedBy === who && claimHeld(o, h)`. A FILLED offer
|
|
@@ -1476,7 +1595,7 @@ the name's profile, the `nprofile` record of §22, under the keys of §36.
|
|
|
1476
1595
|
its current value.
|
|
1477
1596
|
- A reader ignores the profile of a name that is expired or pending. In the state of §5 these are a name with
|
|
1478
1597
|
`expired: true` (its lease and grace have lapsed, §17) and a name with `pending: true` (a reservation of §28 not yet
|
|
1479
|
-
finalized). An expired name keeps its last profile in state until the name is claimed again; that profile is
|
|
1598
|
+
finalized; `resolve()` materializes it without a profile). An expired name keeps its last profile in state until the name is claimed again; that profile is
|
|
1480
1599
|
history, not the word of a current owner.
|
|
1481
1600
|
|
|
1482
1601
|
Known limit: only the owner writes a profile (§22), and two writers for one owner (two applications, or two devices)
|
|
@@ -1484,6 +1603,36 @@ that read the same profile and both write within one block interval lose one wri
|
|
|
1484
1603
|
replaces the map, and the keys only the earlier write carried are gone. The convention has no per-key write; a writer
|
|
1485
1604
|
that needs its write kept reads the profile again once its record is mined.
|
|
1486
1605
|
|
|
1606
|
+
### 35.4 Forward resolution: the address a name receives at
|
|
1607
|
+
|
|
1608
|
+
A payment to a name goes to its `addr` (set by `nset`, §9, §26), else to its owner, so a name receives before its owner
|
|
1609
|
+
sets an address. Read from `names` in the state of §5 at a tip:
|
|
1610
|
+
|
|
1611
|
+
| The name in `names` | Resolves to |
|
|
1612
|
+
|---|---|
|
|
1613
|
+
| held, with `addr` | `addr` (`via: "nset"`) |
|
|
1614
|
+
| held, without `addr` (not set, or cleared by an `nset` to the zero address from V23) | the owner (`via: "owner"`) |
|
|
1615
|
+
| held, with the zero address as `addr` (an `nset` to it below V23 stored it, §26) | the zero address (`via: "nset"`); a wallet refuses to pay it (§26) |
|
|
1616
|
+
| in grace (§17: past `paidThroughEpoch`, without `expired`) | as held |
|
|
1617
|
+
| with `expired: true` (§17) | the record's address, flagged `lapsed: true`; a sender refuses it |
|
|
1618
|
+
| with `pending: true` (§28) | nothing: a reservation confers no address |
|
|
1619
|
+
| absent | nothing |
|
|
1620
|
+
|
|
1621
|
+
A name an open offer locks (§9) resolves as held. A sale and an `nxfer` clear `addr`, so the new owner receives until
|
|
1622
|
+
it sets one. The profile is not read (§36.3). A reserved name (`RESERVED_NAMES`) is absent from `names`, since a record
|
|
1623
|
+
that claims it does not parse (§9), so it resolves to nothing. The name is looked up as `names` writes it: a reader
|
|
1624
|
+
lowercases its input, drops a `.csd` suffix and refuses a string that does not match `NAME_RE` before it asks. In
|
|
1625
|
+
JavaScript `names` is a plain object and `constructor` matches `NAME_RE`, so a reader tests for an own key: a bare index
|
|
1626
|
+
on an unregistered `constructor` reads `Object.prototype.constructor`.
|
|
1627
|
+
|
|
1628
|
+
cairnx-core exports the rule as `resolveNameIn(names, name)`, which answers `{name, addr, via, lapsed, owner}` or null,
|
|
1629
|
+
and `nameView(names, name)` for a reader that shows a name: its class (`held`, `pending`, `lapsed`, `free` when absent,
|
|
1630
|
+
`reserved`), its owner (the reserver of a pending name, the last owner of a lapsed one), its address and its profile (a
|
|
1631
|
+
held name's only, §35.3) and its `paidThroughEpoch`; null for a string that does not match `NAME_RE`.
|
|
1632
|
+
`test/vectors/forward.json` (`conformance/gen-forward-vectors.mjs`) holds the cases, one per line: the events, the tip,
|
|
1633
|
+
and for each name asked the answers of both functions over `resolve(events, tip).names`, written by hand. Neither
|
|
1634
|
+
function writes state, so this section has no gate.
|
|
1635
|
+
|
|
1487
1636
|
## 36. The profile-key registry
|
|
1488
1637
|
|
|
1489
1638
|
This is the registry of profile keys, the first version. The resolver validates keys by their form alone and keeps no
|
|
@@ -1527,7 +1676,7 @@ does not control. They are registered as the editor writes them and are the only
|
|
|
1527
1676
|
- An address that a name's profile publishes is that name owner's node. What is read through it is at most single
|
|
1528
1677
|
records, each proven for inclusion with its author bound to the coin it spent (§33.5; the record proof of §37),
|
|
1529
1678
|
never a complete history, and never what marks any name, that one or another, as verified.
|
|
1530
|
-
- A profile is never a send target (§22): the address a name pays to is `addr`, set by `nset
|
|
1679
|
+
- A profile is never a send target (§22): the address a name pays to is `addr`, set by `nset`, else the owner (§35.4).
|
|
1531
1680
|
- The profile of an expired or pending name is ignored (§35.3).
|
|
1532
1681
|
|
|
1533
1682
|
### 36.4 The byte budget
|
|
@@ -1591,7 +1740,7 @@ A result says which of three levels it is.
|
|
|
1591
1740
|
|
|
1592
1741
|
A replica conforms at three levels.
|
|
1593
1742
|
|
|
1594
|
-
1. The vectors: `test/vectors/cases.json`, `cases-v29.json` and `cases-
|
|
1743
|
+
1. The vectors: `test/vectors/cases.json`, `cases-v29.json`, `cases-rules.json` and `cases-convention.json` (replay, §5), `events.json`
|
|
1595
1744
|
(§33.7) and `hashes.json` (§34.4). A conformant implementation reproduces every case byte for byte.
|
|
1596
1745
|
2. The pinned replay hashes: `test/vectors/replay-hashes.json`, the state hash (§34.1) of the live chain at each
|
|
1597
1746
|
pinned height.
|
|
@@ -1609,13 +1758,14 @@ A form of the tuple recorded on chain is reserved under the reserved prefixes of
|
|
|
1609
1758
|
version.
|
|
1610
1759
|
|
|
1611
1760
|
`test/vectors/codes.json` (§40.7) is not a level: the reason codes move no state. A replica that publishes codes
|
|
1612
|
-
reproduces it.
|
|
1761
|
+
reproduces it. `test/vectors/moves.json` (§41) is not a level: the token moves move no state. A replica that publishes
|
|
1762
|
+
moves reproduces it.
|
|
1613
1763
|
|
|
1614
1764
|
## 39. Rule changes
|
|
1615
1765
|
|
|
1616
1766
|
- This specification is normative for the future. Pinned history stands: every height below a gate replays as it
|
|
1617
1767
|
did, and the pinned replay hashes do not move. Behaviour changes only at a gate, an activation height in
|
|
1618
|
-
`src/types.ts`; a section without a gate, such as §33 to §
|
|
1768
|
+
`src/types.ts`; a section without a gate, such as §33 to §41, moves no state.
|
|
1619
1769
|
- `CONSENSUS_CHANGES.md` in the csd-sdk repository is the ledger of every change. Each gate after v2.9 also has its
|
|
1620
1770
|
own file, `docs/gates/<gate>.md`, written from `docs/gates/TEMPLATE.md` and linked from its ledger entry. It
|
|
1621
1771
|
states the motivation, the rule text, the class of the change (reject-more: an input the earlier rule applied
|
|
@@ -1707,7 +1857,7 @@ NAME_NOT_LAPSED and INVARIANT_BROKEN (their rows say why).
|
|
|
1707
1857
|
| TOKEN_SUPPLY_EXHAUSTED | refused | | nothing is left to mint |
|
|
1708
1858
|
| TOKEN_MINT_AMOUNT_REQUIRED | refused | | an issuer mint without `amount` |
|
|
1709
1859
|
| TOKEN_BALANCE_LOW | refused | | the available balance is short (a transfer, an offer's give, a token fill's price and fee) |
|
|
1710
|
-
| TREASURY_FEE_UNPAID | refused | | the output to the treasury is below the fee or premium |
|
|
1860
|
+
| TREASURY_FEE_UNPAID | refused | | the output to the treasury is below the fee or premium (where the treasury is the seller on a rebate lane, below the fee plus the maker rebate, which sum on its output) |
|
|
1711
1861
|
| NAME_NO_COMMIT | refused | | no commit for this reveal below its height and inside the window |
|
|
1712
1862
|
| NAME_SALT_REQUIRED | refused | | a `name` without salt at V25 and above (registration) or V26 and above (recapture) |
|
|
1713
1863
|
| NAME_TAKEN_EARLIER | refused | | an earlier (effective height, position, id) holds the name or its reservation |
|
|
@@ -1746,8 +1896,8 @@ NAME_NOT_LAPSED and INVARIANT_BROKEN (their rows say why).
|
|
|
1746
1896
|
| FILL_NO_LIVE_CLAIM | refused | | an open CSD fill without the filler's live hold |
|
|
1747
1897
|
| FILL_BELOW_MIN | refused | | a partial payment below the effective minimum |
|
|
1748
1898
|
| FILL_ZERO_DELIVERY | refused | | the payment delivers no unit |
|
|
1749
|
-
| FILL_UNDERPAID | refused | | the payment to payto is below want.value |
|
|
1750
|
-
| FILL_REBATE_UNPAID | refused | | the maker rebate
|
|
1899
|
+
| FILL_UNDERPAID | refused | | the payment to payto is below want.value (where payto is the seller and a maker rebate applies, a shortfall there is FILL_REBATE_UNPAID) |
|
|
1900
|
+
| FILL_REBATE_UNPAID | refused | | the payment to the seller is below the maker rebate, or, where payto is the seller, below want.value plus the rebate |
|
|
1751
1901
|
| CLAIM_TAKER_BOUND | refused | | a taker-bound offer takes no claim |
|
|
1752
1902
|
| CLAIM_TOKEN_PRICED | refused | | claims are for CSD-priced offers |
|
|
1753
1903
|
| CLAIM_HOLD_LIVE | refused | | a hold (window and grace) is live, whoever holds it |
|
|
@@ -1807,3 +1957,45 @@ resolve cases (the events, the tip and the expected entries as `[id, kind, ok, c
|
|
|
1807
1957
|
cases (the uri, the payload hash and the expected code, or null for a record that parses), with every expectation
|
|
1808
1958
|
written by hand in `conformance/gen-codes-vectors.mjs`. A replica that publishes codes reproduces it. The Python
|
|
1809
1959
|
reference of `conformance/` writes no codes.
|
|
1960
|
+
|
|
1961
|
+
---
|
|
1962
|
+
|
|
1963
|
+
# Token moves (no gate)
|
|
1964
|
+
|
|
1965
|
+
## 41. Token moves
|
|
1966
|
+
|
|
1967
|
+
An applied entry of the log (§5) whose record moved tokens carries `moves`: the movements in the order the record
|
|
1968
|
+
applied them, each `{ leg, ticker, from, to, amount }`, that is `amount` base units of `ticker` from the address `from`
|
|
1969
|
+
to the address `to`. `amount` is a positive decimal string in the form of the state's balances (§5). The resolver
|
|
1970
|
+
writes each move where it applies the balance change, so a reader takes who received what from the log and does not
|
|
1971
|
+
restate the rules that decide the amounts (the mint caps, a whole fill's delivery, the partial fill's floor, the fee).
|
|
1972
|
+
|
|
1973
|
+
| leg | written by | from | to | amount |
|
|
1974
|
+
|---|---|---|---|---|
|
|
1975
|
+
| `mint` | an applied mint (§4.2) | null | the proposer | the credit: `min(amount, mintLimit, remaining)` for an open mint, `amount` defaulting to `mintLimit`; `min(amount, remaining)` for an issuer mint |
|
|
1976
|
+
| `xfer` | an applied transfer (§4.3) | the proposer | `to` | `amount` |
|
|
1977
|
+
| `sale` | an applied fill of a token-priced offer (§11) | the buyer | `want.payto` | `want.amount`, the fill's `paid` (§5) |
|
|
1978
|
+
| `fee` | the same fill | the buyer | the treasury (§10) | the fill's `fee` |
|
|
1979
|
+
| `fill` | an applied fill of an offer whose give is a token (§4.5, §11, §12) | the seller | the buyer | `give.amount` on a whole fill, the `got` of its `fills` entry on a partial one (§12) |
|
|
1980
|
+
|
|
1981
|
+
- A token-priced fill writes its sale, then its fee, then its give. A zero amount writes no move: the sale of a token
|
|
1982
|
+
priced at `"0"` (§11) and its fee of 0.
|
|
1983
|
+
- An offer, a cancel, an `ocancel` and an expiry move tokens between one address's `available` and `locked` and write
|
|
1984
|
+
no move; nor does a fill that moves no token (a name sold for CSD), nor any other record. A refused entry carries no
|
|
1985
|
+
moves. An entry with no move has no `moves` key, and `moves` is its last key.
|
|
1986
|
+
- In one result a ticker names one token: the first anchored deploy of a ticker wins and a later one is refused (§4.1),
|
|
1987
|
+
and no record removes a token. A replay of another chain, after a reorganisation below the deploy, can bind the
|
|
1988
|
+
ticker to another deploy. So a move carries no deploy id; `tokens[ticker].deployId` of the same result gives it.
|
|
1989
|
+
- The identity the moves meet: for every ticker and address, the amounts the address received less the amounts it
|
|
1990
|
+
sent, over every move of the log, equal its `available` plus `locked` in `balances`, an address left out of
|
|
1991
|
+
`balances` holding 0; and the mint moves of a ticker sum to its `minted`.
|
|
1992
|
+
- The log is outside canonical state (§5), so moves change no state hash, and a replica that writes no moves conforms
|
|
1993
|
+
at every level of §38. A replica that publishes moves reproduces `test/vectors/moves.json`.
|
|
1994
|
+
|
|
1995
|
+
`TokenMove` (`src/types.ts`) is the type; `src/resolve/tokens.ts` and `src/resolve/attest.ts` write the moves.
|
|
1996
|
+
`test/vectors/moves.json` holds 13 cases (the events, the tip, and the entries that carry moves with their moves, in
|
|
1997
|
+
log order), every expectation written by hand in `conformance/gen-moves-vectors.mjs`. `conformance/moves-check.mjs`
|
|
1998
|
+
checks a result's moves against its input events and its state by the rules above, each transfer's and mint's move
|
|
1999
|
+
against its own record; the cairnx-core tests run it over the replay corpus at
|
|
2000
|
+
every pinned height and over every case file, and the seal over every input of its differential. The Python reference
|
|
2001
|
+
of `conformance/` writes no moves.
|