@inversealtruism/cairnx-core 0.2.4 → 0.2.8
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 +147 -0
- package/CONVENTION.md +885 -99
- package/README.md +58 -18
- package/dist/index.cjs +1177 -394
- package/dist/index.d.cts +301 -3
- package/dist/index.d.ts +301 -3
- package/dist/index.js +1148 -385
- package/package.json +2 -1
- package/test/vectors/cases-convention.json +2202 -0
- package/test/vectors/codes.json +200 -0
- package/test/vectors/events.json +70 -0
- package/test/vectors/forward.json +16 -0
- package/test/vectors/hashes.json +47 -0
- package/test/vectors/moves.json +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,152 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.8
|
|
4
|
+
|
|
5
|
+
- Token moves in the applied log (CONVENTION section 41, no gate): an applied mint, transfer or fill that moved tokens
|
|
6
|
+
carries `moves`, each `{ leg, ticker, from, to, amount }` (`TokenMove`, legs `mint`, `xfer`, `sale`, `fee` and
|
|
7
|
+
`fill`), written by the line that applies the balance change in `src/resolve/tokens.ts` and `src/resolve/attest.ts`.
|
|
8
|
+
A server that credits token deposits, or a replica that lists transfers, reads a capped mint's credit, a partial
|
|
9
|
+
fill's delivered units, a sale and its fee from the log instead of restating the rules that decide them. A zero
|
|
10
|
+
amount writes no move, a refused entry none, and `moves` is an entry's last key. No rule changed: canonical state,
|
|
11
|
+
`stateHash`, `eventsHash`, every pinned vector and `replay-hashes.json` are unchanged, and the log with `moves` left
|
|
12
|
+
out is 0.2.7's (`scripts/seal-differential.mjs` against npm's 0.2.7 and 0.2.4). `test/vectors/moves.json` (13 cases,
|
|
13
|
+
`conformance/gen-moves-vectors.mjs`, expectations written by hand) pins them; `conformance/moves-check.mjs` checks,
|
|
14
|
+
from the input events and the result, the identity (for every ticker and address, received less sent equals
|
|
15
|
+
available plus locked), each transfer's and mint's move against its own record and each fill's moves against its
|
|
16
|
+
fill record, run by `test/moves.test.ts` over the replay corpus at every pinned height and every case file, and by
|
|
17
|
+
the seal over every input of its differential.
|
|
18
|
+
- `CAIRNX_CORE_VERSION` (`src/version.ts`), this package's version, kept equal to package.json's by
|
|
19
|
+
`test/version.test.ts`: a host hands it to cairnx-api's `prepareView` without reading the manifest at run time.
|
|
20
|
+
- `GATE_HEIGHTS` (`src/gates.ts`), the gate table as frozen data: `ACTIVATION_HEIGHT` and every `V<n>_HEIGHT` by its
|
|
21
|
+
exported name, built from the constants of `types.ts`, which are unchanged; `test/gates.test.ts` keeps it equal to
|
|
22
|
+
the individual exports and complete. A reader that compares gate tables (the replica, a witness) imports it.
|
|
23
|
+
- Forward resolution is a root export, moved from the reference service without a change to its body: `resolveNameIn(names,
|
|
24
|
+
name)` answers `{ name, addr, via, lapsed, owner }` for the name's `nset` address, else its owner, with `lapsed` from
|
|
25
|
+
the name's `expired`, and null for an absent name or a pending reservation; `nameView(names, name)` gives the class a
|
|
26
|
+
reader shows (`held`, `pending`, `lapsed`, `free`, `reserved`), the owner, and a held name's address and profile
|
|
27
|
+
(CONVENTION section 35.3), or null for a string that is not a name. Both live in `src/forward.ts` and read `names`
|
|
28
|
+
only; that change left `resolve.ts`, `resolve/`, `records.ts` and `types.ts` as they were in 0.2.7. CONVENTION.md section 35.4
|
|
29
|
+
states the rule, and section 36.3 now says a name pays to its `addr`, else its owner, which is what the reference
|
|
30
|
+
service answers. `test/vectors/forward.json` (14 cases, `conformance/gen-forward-vectors.mjs`, expectations written
|
|
31
|
+
by hand) pins both functions; `test/forward.test.ts` replays it and compares the service's call shape with an oracle
|
|
32
|
+
over every name of the replay corpus at each pinned height.
|
|
33
|
+
- CONVENTION.md corrected to match the implementation; no behaviour changed (that change touched neither `src/` nor
|
|
34
|
+
`dist/`; every pinned replay hash and existing vector byte-identical). It now states: what a pending reservation refuses and how
|
|
35
|
+
it is materialized (sections 9, 17, 22, 28); the expiry sweep before each event and at `tipHeight + 1`, and that a
|
|
36
|
+
name's `expired` is read at the tip's epoch (section 5); the zero-delivery partial fill (12); the commit height as
|
|
37
|
+
the first anchoring of its hash, the salt form and the reveal's own position and id as the contest key (9, 28, 29);
|
|
38
|
+
the lowercase form of record hashes (3, 13, 18); the bid link and `done` (13); a token-priced offer's `"0"` price
|
|
39
|
+
(3, 11); the recapture premium as the integer staircase `1 + floor(19 * (720 - e) / 720)` and the recaptured
|
|
40
|
+
record's anchor (17, 29). Corrected sentences: `feesPaid` counts the fees applied records owed (10); a whole fill's
|
|
41
|
+
`paid` is what it paid to payto, and a completed partial offer's `fill` carries `got` (5, A3); the claim fields stay
|
|
42
|
+
after the hold and the offer end (20, A4); offers below 29 960 carry `feeBps` 0 (19); a same-block re-post of what
|
|
43
|
+
an `ocancel` releases is refused from V14, and section 16 no longer says the case cannot occur on chain (12b, 16);
|
|
44
|
+
the fclaim grant checks the expiry's 2^53 bound first and its order decides only the reason code (31); a list
|
|
45
|
+
holding a transaction id at two places with the first copy below V29 is not a list section 33 produces, no
|
|
46
|
+
conformance level covers it and the two reference implementations differ there (32); an un-finalized reservation
|
|
47
|
+
is gone from the state at a tip equal to `finalizeBy` (28); one key can anchor several records in one block (6,
|
|
48
|
+
16); the state's key order puts array-index keys first (5), the field lists of section 5 and A3/A4 are complete,
|
|
49
|
+
and `FILL_UNDERPAID`, `FILL_REBATE_UNPAID` and `TREASURY_FEE_UNPAID` say what they mean on the rebate lane (40.4).
|
|
50
|
+
README.md gives the recapture premium as 19x stepping down to 1x over about 28 days, where it said 20x to 1x over
|
|
51
|
+
about 30.
|
|
52
|
+
- `test/vectors/cases-convention.json` (16 vectors, `conformance/gen-convention-vectors.mjs`) pins those rules and
|
|
53
|
+
three the text stated that no vector pinned (`feeBps` 0 below 29 960, a CSD-priced offer wanting `"0"`, and a bid
|
|
54
|
+
anchored after the offer that names it ending `done` with empty `offers`), each in a vector an implementation of
|
|
55
|
+
the earlier text fails; replayed by `test/vectors.test.ts`, against the Python
|
|
56
|
+
reference by `conformance/crosscheck-resolve.mjs`, and by the seal, which pins the file's sha256. A file of its own
|
|
57
|
+
keeps the three case files the seal freezes at their bytes.
|
|
58
|
+
- `test/holdcount.test.ts`: the honest path of `countOtherHoldsAtGrant`'s skip of the buyer's closed holds, with the
|
|
59
|
+
call shape the site and wallet send (`closed` from `myProvenFillClosedOffer`, the count into `verifyFillSpv`): three
|
|
60
|
+
completed fclaim buys inside one hold window, then a fourth, counted 0 and safe to fill. No test passed `closed`
|
|
61
|
+
before.
|
|
62
|
+
|
|
63
|
+
## 0.2.7
|
|
64
|
+
|
|
65
|
+
- No state change; replay cost. `resolve()` no longer copies and walks every open offer, open bid, pending reservation
|
|
66
|
+
and recapture reservation before each event, nor every name or recapture reservation at each reveal for the
|
|
67
|
+
per-address reservation caps, nor every offer at each claim for the live-hold cap, at each bulk cancel and at each
|
|
68
|
+
displacement or recapture that voids a name's offers. `src/resolve/store.ts` holds those maps with private expiry
|
|
69
|
+
queues (`minqueue.ts`) and candidate sets (per owner, per holder, per seller and give asset, per name), and is the
|
|
70
|
+
only writer of the fields they key on (readonly to the handlers by type); each read evaluates the old walk's own
|
|
71
|
+
predicate over its candidates and applies a batch in the walk's order. The first sweep at V21 or above re-keys the
|
|
72
|
+
offers and bids anchored below V22 at their capped expiry. A sweep or a hold count at a height below an earlier
|
|
73
|
+
one's (only NaN heights reorder the replay) takes the old walk, which also serves as the reference of a check mode
|
|
74
|
+
the tests and the seal run. Nothing of it reaches the resolved state or the root exports.
|
|
75
|
+
- New root exports `applyOrder(a, b)`, the apply order of CONVENTION.md sections 3 and 33.3 (height, a block's Proposes
|
|
76
|
+
before its Attests, position, the ordinal order of the id), and `eventId(e)`, a Propose's id or an Attest's txid.
|
|
77
|
+
`resolve()` sorts with `applyOrder` and drops section 32's duplicates by `eventId`: the same comparison it made
|
|
78
|
+
before, moved out of its body, so a reader that must list events in apply order (the replica) imports it instead of
|
|
79
|
+
copying it.
|
|
80
|
+
- One run on the seal's streams on a loaded host, cairnx-core 0.2.4 against this release, in ms: 16,000 registrations
|
|
81
|
+
5,061 / 1,000; 20,000 open bids 3,494 / 364; 20,000 offers with holds 31,683 / 887; 20,000 live reservations
|
|
82
|
+
15,600 / 618; 20,000 live recaptures 22,508 / 1,872; 2,000 bulk cancels over 20,000 offers 14,230 / 523; 2,000
|
|
83
|
+
displacements over 20,000 offers 20,636 / 567. Entries visited per event stay flat as a stream doubles.
|
|
84
|
+
- Kept as 0.2.4 has them: a bulk cancel still visits the seller's matching offers a live fclaim hold freezes, on each
|
|
85
|
+
cancel while the hold lasts; below V29 a duplicated offer id applied after a same-block bulk cancel leaves the new
|
|
86
|
+
copy open with its id out of the open set, so it never expires (only a feed that repeats an event can produce it).
|
|
87
|
+
- The output does not move: `scripts/seal-differential.mjs cairnx-core-0.2.4 fc6e081` finds `canonicalState`
|
|
88
|
+
byte-identical to 0.2.4 and the whole result identical once `code` is left out, and identical to 0.2.6 with `code`,
|
|
89
|
+
over every input it had and the streams of `conformance/growth-streams.mjs` at full size.
|
|
90
|
+
|
|
91
|
+
## 0.2.6
|
|
92
|
+
|
|
93
|
+
- Stable reason codes, CONVENTION.md section 40: each entry of the applied log gains `code`, the rule that decided the
|
|
94
|
+
record, from a table of 113 (26 applied, 87 refused, 28 of them record codes; 3 caps). A code is never renamed,
|
|
95
|
+
reused or removed; the note text beside it may change, and a reader treats a code it does not know by the entry's
|
|
96
|
+
`ok`. New root exports `REASON_CODES`, `REASON_CODE_OUTCOME`, `CAP_CODES` and the types `ReasonCode`, `AppliedCode`,
|
|
97
|
+
`RefusalCode`, `RecordCode` (`src/codes.ts`). Every entry `resolve()` writes carries a code; an unparseable record's
|
|
98
|
+
entry carries its record code. Four codes guard states no event reaches (section 40.4 says why). The note texts are
|
|
99
|
+
unchanged, so a consumer that matches them keeps working; `provenOfferRefusal` returns the same strings as before.
|
|
100
|
+
- `test/vectors/codes.json`: 145 resolve cases and 50 record cases whose expected codes are written by hand in
|
|
101
|
+
`conformance/gen-codes-vectors.mjs`; together they reach the 109 codes an event can reach. The Python reference
|
|
102
|
+
writes no codes.
|
|
103
|
+
- `explainRecord(uri, payloadHash)`: `{ ok: true, record }` or `{ ok: false, code }`, the first record rule the uri
|
|
104
|
+
breaks. `parseRecord` keeps its signature and answers and shares one implementation with it. A builder that refuses
|
|
105
|
+
throws `RecordError`, an `Error` with `code`; its message is "record does not validate against CONVENTION.md (<code>)",
|
|
106
|
+
which until now ended at "CONVENTION.md".
|
|
107
|
+
- No state moves: `scripts/seal-differential.mjs` against cairnx-core 0.2.4 finds `canonicalState` byte-identical, the
|
|
108
|
+
whole result identical once `code` is left out, and `parseRecord` accepting exactly what it accepted.
|
|
109
|
+
|
|
110
|
+
## 0.2.5
|
|
111
|
+
|
|
112
|
+
- CONVENTION.md section 33, "From a block to events": the rule that turns the chain's blocks into the events
|
|
113
|
+
`resolve()` replays (membership from the activation height, first occurrence, order, field forms, the author as the
|
|
114
|
+
owner of the coin the first input spends, the byte form of an event list). It also accepts a sparse block: every
|
|
115
|
+
transaction with an app payload at its true position. Section 32's "there is no straddle case" is corrected (a
|
|
116
|
+
transaction can be mined again, in two blocks), and C3, section 3 and section 5 point at section 33.
|
|
117
|
+
- New root exports `eventOfTx`, `blockMembers`, `blockEvents` and `CAIRNX_EVENT_RULE`, with
|
|
118
|
+
`test/vectors/events.json` (40 transaction and 25 block vectors, `conformance/gen-events-vectors.mjs`), checked by
|
|
119
|
+
`test/events.test.ts` and against the Python reference by `conformance/events-crosslang.mjs`. In JavaScript a u64
|
|
120
|
+
input is a bigint in [0, 2^64) or a number that is an integer in [0, 2^53]; a number above 2^53 is refused.
|
|
121
|
+
- `resolve()`, `records.ts` and `types.ts` are unchanged, and every pinned vector and replay hash is byte-identical.
|
|
122
|
+
Section 33.2 makes normative the input form the reference service's feed has always had: the first occurrence of a
|
|
123
|
+
transaction id at every height. A reader that feeds `resolve()` every copy of a re-mined transaction can differ from
|
|
124
|
+
the reference when a copy lies below V29: a transaction mined at 87,999 and again at 88,001 is one event under
|
|
125
|
+
section 33 and two applied records under `resolve()` fed both copies. For history the case is empty: a scan of every
|
|
126
|
+
block from 29,860 to 144,400 (block hash 0x0000000000001874564bd8df5a5893040b0981d96c646e132e3598488d0411b5) on
|
|
127
|
+
2026-11-18 read 114,541 blocks and 148,395 transactions with 148,395 distinct transaction ids, so no transaction id
|
|
128
|
+
has been mined twice since activation. The script for that scan ships with the block fixture in the next slice
|
|
129
|
+
(events-rule-b).
|
|
130
|
+
- A reader that switches to `eventOfTx` sees two forms change, neither of which moves state: an expiry above 2^53 - 1
|
|
131
|
+
becomes 2^53 (resolve() refuses both alike for offers, bids and fclaims, and reads it for nothing else), and a `uri`
|
|
132
|
+
holding U+0000 has it written as U+0001 (neither form is JSON, so neither is a record).
|
|
133
|
+
- CONVENTION.md section 34, "State hash and events hash": the two hashes replicas compare at one block, and what a
|
|
134
|
+
difference in each means. New root exports `stateHash` (sha256 of `canonicalState`'s UTF-8 bytes, the digest
|
|
135
|
+
`replay-hashes.json` already pins), `eventsHashStep`, `eventsHash` and `EVENTS_HASH_START`: a running sha256 over
|
|
136
|
+
each event-holding block's height and its events' positions, transaction ids and authors. Vectors in
|
|
137
|
+
`test/vectors/hashes.json` (43 cases, and both hashes over the replay corpus at its 21 pinned heights,
|
|
138
|
+
`conformance/gen-hashes-vectors.mjs`), checked by `test/hashes.test.ts` and against the Python reference by
|
|
139
|
+
`conformance/hashes-crosslang.mjs`; the replay-hash test and `replay-corpus-crosslang.mjs` call `stateHash`.
|
|
140
|
+
- New root export `FINAL_DEPTH` = 12: how far below its tip a replica holds an epoch boundary before it publishes or
|
|
141
|
+
compares the tuple of section 34.3 there. Section 38 names it; the thresholds of section 3 (3 and 6) are display
|
|
142
|
+
conventions and are not this depth.
|
|
143
|
+
- CONVENTION.md sections 35 to 39, with no gate: other applications (record types under `cairnx:v1` reserved, an
|
|
144
|
+
application's own domain, the profile as the place for data about a name), the profile-key registry with its caps,
|
|
145
|
+
keys, reader rules and byte budget (`scripts/profile-budget.mjs` prints it), what a result proves at each of the
|
|
146
|
+
three levels, conformance, and how the rules change. No package code and no state change.
|
|
147
|
+
- cairnx-core now declares `@noble/hashes` 1.8.0, the release csd-codec already pins, for its sha256 (csd-codec
|
|
148
|
+
exports none): no new package enters an install.
|
|
149
|
+
|
|
3
150
|
## 0.2.4
|
|
4
151
|
|
|
5
152
|
- `verifyFillSpv`'s contract and comments say what its window replay decides. A grant depends on the holds granted
|