@inversealtruism/cairnx-core 0.2.3 → 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/CHANGELOG.md +149 -0
- package/CONVENTION.md +655 -34
- package/MAKERS.md +8 -4
- package/README.md +108 -65
- package/dist/index.cjs +1112 -391
- package/dist/index.d.cts +275 -14
- package/dist/index.d.ts +275 -14
- package/dist/index.js +1085 -382
- package/package.json +3 -2
- package/test/vectors/cases-rules.json +446 -0
- package/test/vectors/codes.json +200 -0
- package/test/vectors/events.json +70 -0
- package/test/vectors/hashes.json +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,154 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.7
|
|
4
|
+
|
|
5
|
+
- No state change; replay cost. `resolve()` no longer copies and walks every open offer, open bid, pending reservation
|
|
6
|
+
and recapture reservation before each event, nor every name or recapture reservation at each reveal for the
|
|
7
|
+
per-address reservation caps, nor every offer at each claim for the live-hold cap, at each bulk cancel and at each
|
|
8
|
+
displacement or recapture that voids a name's offers. `src/resolve/store.ts` holds those maps with private expiry
|
|
9
|
+
queues (`minqueue.ts`) and candidate sets (per owner, per holder, per seller and give asset, per name), and is the
|
|
10
|
+
only writer of the fields they key on (readonly to the handlers by type); each read evaluates the old walk's own
|
|
11
|
+
predicate over its candidates and applies a batch in the walk's order. The first sweep at V21 or above re-keys the
|
|
12
|
+
offers and bids anchored below V22 at their capped expiry. A sweep or a hold count at a height below an earlier
|
|
13
|
+
one's (only NaN heights reorder the replay) takes the old walk, which also serves as the reference of a check mode
|
|
14
|
+
the tests and the seal run. Nothing of it reaches the resolved state or the root exports.
|
|
15
|
+
- New root exports `applyOrder(a, b)`, the apply order of CONVENTION.md sections 3 and 33.3 (height, a block's Proposes
|
|
16
|
+
before its Attests, position, the ordinal order of the id), and `eventId(e)`, a Propose's id or an Attest's txid.
|
|
17
|
+
`resolve()` sorts with `applyOrder` and drops section 32's duplicates by `eventId`: the same comparison it made
|
|
18
|
+
before, moved out of its body, so a reader that must list events in apply order (the replica) imports it instead of
|
|
19
|
+
copying it.
|
|
20
|
+
- One run on the seal's streams on a loaded host, cairnx-core 0.2.4 against this release, in ms: 16,000 registrations
|
|
21
|
+
5,061 / 1,000; 20,000 open bids 3,494 / 364; 20,000 offers with holds 31,683 / 887; 20,000 live reservations
|
|
22
|
+
15,600 / 618; 20,000 live recaptures 22,508 / 1,872; 2,000 bulk cancels over 20,000 offers 14,230 / 523; 2,000
|
|
23
|
+
displacements over 20,000 offers 20,636 / 567. Entries visited per event stay flat as a stream doubles.
|
|
24
|
+
- Kept as 0.2.4 has them: a bulk cancel still visits the seller's matching offers a live fclaim hold freezes, on each
|
|
25
|
+
cancel while the hold lasts; below V29 a duplicated offer id applied after a same-block bulk cancel leaves the new
|
|
26
|
+
copy open with its id out of the open set, so it never expires (only a feed that repeats an event can produce it).
|
|
27
|
+
- The output does not move: `scripts/seal-differential.mjs cairnx-core-0.2.4 fc6e081` finds `canonicalState`
|
|
28
|
+
byte-identical to 0.2.4 and the whole result identical once `code` is left out, and identical to 0.2.6 with `code`,
|
|
29
|
+
over every input it had and the streams of `conformance/growth-streams.mjs` at full size.
|
|
30
|
+
|
|
31
|
+
## 0.2.6
|
|
32
|
+
|
|
33
|
+
- Stable reason codes, CONVENTION.md section 40: each entry of the applied log gains `code`, the rule that decided the
|
|
34
|
+
record, from a table of 113 (26 applied, 87 refused, 28 of them record codes; 3 caps). A code is never renamed,
|
|
35
|
+
reused or removed; the note text beside it may change, and a reader treats a code it does not know by the entry's
|
|
36
|
+
`ok`. New root exports `REASON_CODES`, `REASON_CODE_OUTCOME`, `CAP_CODES` and the types `ReasonCode`, `AppliedCode`,
|
|
37
|
+
`RefusalCode`, `RecordCode` (`src/codes.ts`). Every entry `resolve()` writes carries a code; an unparseable record's
|
|
38
|
+
entry carries its record code. Four codes guard states no event reaches (section 40.4 says why). The note texts are
|
|
39
|
+
unchanged, so a consumer that matches them keeps working; `provenOfferRefusal` returns the same strings as before.
|
|
40
|
+
- `test/vectors/codes.json`: 145 resolve cases and 50 record cases whose expected codes are written by hand in
|
|
41
|
+
`conformance/gen-codes-vectors.mjs`; together they reach the 109 codes an event can reach. The Python reference
|
|
42
|
+
writes no codes.
|
|
43
|
+
- `explainRecord(uri, payloadHash)`: `{ ok: true, record }` or `{ ok: false, code }`, the first record rule the uri
|
|
44
|
+
breaks. `parseRecord` keeps its signature and answers and shares one implementation with it. A builder that refuses
|
|
45
|
+
throws `RecordError`, an `Error` with `code`; its message is "record does not validate against CONVENTION.md (<code>)",
|
|
46
|
+
which until now ended at "CONVENTION.md".
|
|
47
|
+
- No state moves: `scripts/seal-differential.mjs` against cairnx-core 0.2.4 finds `canonicalState` byte-identical, the
|
|
48
|
+
whole result identical once `code` is left out, and `parseRecord` accepting exactly what it accepted.
|
|
49
|
+
|
|
50
|
+
## 0.2.5
|
|
51
|
+
|
|
52
|
+
- CONVENTION.md section 33, "From a block to events": the rule that turns the chain's blocks into the events
|
|
53
|
+
`resolve()` replays (membership from the activation height, first occurrence, order, field forms, the author as the
|
|
54
|
+
owner of the coin the first input spends, the byte form of an event list). It also accepts a sparse block: every
|
|
55
|
+
transaction with an app payload at its true position. Section 32's "there is no straddle case" is corrected (a
|
|
56
|
+
transaction can be mined again, in two blocks), and C3, section 3 and section 5 point at section 33.
|
|
57
|
+
- New root exports `eventOfTx`, `blockMembers`, `blockEvents` and `CAIRNX_EVENT_RULE`, with
|
|
58
|
+
`test/vectors/events.json` (40 transaction and 25 block vectors, `conformance/gen-events-vectors.mjs`), checked by
|
|
59
|
+
`test/events.test.ts` and against the Python reference by `conformance/events-crosslang.mjs`. In JavaScript a u64
|
|
60
|
+
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.
|
|
61
|
+
- `resolve()`, `records.ts` and `types.ts` are unchanged, and every pinned vector and replay hash is byte-identical.
|
|
62
|
+
Section 33.2 makes normative the input form the reference service's feed has always had: the first occurrence of a
|
|
63
|
+
transaction id at every height. A reader that feeds `resolve()` every copy of a re-mined transaction can differ from
|
|
64
|
+
the reference when a copy lies below V29: a transaction mined at 87,999 and again at 88,001 is one event under
|
|
65
|
+
section 33 and two applied records under `resolve()` fed both copies. For history the case is empty: a scan of every
|
|
66
|
+
block from 29,860 to 144,400 (block hash 0x0000000000001874564bd8df5a5893040b0981d96c646e132e3598488d0411b5) on
|
|
67
|
+
2026-11-18 read 114,541 blocks and 148,395 transactions with 148,395 distinct transaction ids, so no transaction id
|
|
68
|
+
has been mined twice since activation. The script for that scan ships with the block fixture in the next slice
|
|
69
|
+
(events-rule-b).
|
|
70
|
+
- A reader that switches to `eventOfTx` sees two forms change, neither of which moves state: an expiry above 2^53 - 1
|
|
71
|
+
becomes 2^53 (resolve() refuses both alike for offers, bids and fclaims, and reads it for nothing else), and a `uri`
|
|
72
|
+
holding U+0000 has it written as U+0001 (neither form is JSON, so neither is a record).
|
|
73
|
+
- CONVENTION.md section 34, "State hash and events hash": the two hashes replicas compare at one block, and what a
|
|
74
|
+
difference in each means. New root exports `stateHash` (sha256 of `canonicalState`'s UTF-8 bytes, the digest
|
|
75
|
+
`replay-hashes.json` already pins), `eventsHashStep`, `eventsHash` and `EVENTS_HASH_START`: a running sha256 over
|
|
76
|
+
each event-holding block's height and its events' positions, transaction ids and authors. Vectors in
|
|
77
|
+
`test/vectors/hashes.json` (43 cases, and both hashes over the replay corpus at its 21 pinned heights,
|
|
78
|
+
`conformance/gen-hashes-vectors.mjs`), checked by `test/hashes.test.ts` and against the Python reference by
|
|
79
|
+
`conformance/hashes-crosslang.mjs`; the replay-hash test and `replay-corpus-crosslang.mjs` call `stateHash`.
|
|
80
|
+
- New root export `FINAL_DEPTH` = 12: how far below its tip a replica holds an epoch boundary before it publishes or
|
|
81
|
+
compares the tuple of section 34.3 there. Section 38 names it; the thresholds of section 3 (3 and 6) are display
|
|
82
|
+
conventions and are not this depth.
|
|
83
|
+
- CONVENTION.md sections 35 to 39, with no gate: other applications (record types under `cairnx:v1` reserved, an
|
|
84
|
+
application's own domain, the profile as the place for data about a name), the profile-key registry with its caps,
|
|
85
|
+
keys, reader rules and byte budget (`scripts/profile-budget.mjs` prints it), what a result proves at each of the
|
|
86
|
+
three levels, conformance, and how the rules change. No package code and no state change.
|
|
87
|
+
- cairnx-core now declares `@noble/hashes` 1.8.0, the release csd-codec already pins, for its sha256 (csd-codec
|
|
88
|
+
exports none): no new package enters an install.
|
|
89
|
+
|
|
90
|
+
## 0.2.4
|
|
91
|
+
|
|
92
|
+
- `verifyFillSpv`'s contract and comments say what its window replay decides. A grant depends on the holds granted
|
|
93
|
+
in the `GAP_NEEDED` (104) blocks before it and on the proposer's live holds on other offers, so a window decides an
|
|
94
|
+
fclaim only when its low end is quiet. The comments no longer say a proven event "only moves the replay toward
|
|
95
|
+
truth" or that the replayed `paid` is the chain's, and its doc lists what it refuses over a window that holds the
|
|
96
|
+
offer's history, including one honest case: the cap count includes the buyer's earlier fclaims on other offers the
|
|
97
|
+
chain denied, so three denied ones refuse a later fill the chain granted. A "Known limits" list names, by step, what a
|
|
98
|
+
window without it gets wrong, first for a caller that uses only `verifyFillSpv` and then with the site's and the
|
|
99
|
+
wallet's own checks: the grant replay (a hold chain from below the window can grant the caller's own fclaim the
|
|
100
|
+
chain denied, with an honest resolver; the site's served-hold check and the wallet's second-source read bound it),
|
|
101
|
+
aged fills at delivery (an honest tail below `min` is refused; for a coarse give the delivery check can disagree
|
|
102
|
+
with the chain's either way, so a caller refuses a payment its served offer computes as undeliverable) and the
|
|
103
|
+
sums bind (a served offer that omits such a fill and serves a lower `paid` passes it; for the site and the wallet
|
|
104
|
+
that needs the project's resolver to lie). The `FillSpvIo` contract names the offer and its give-backing among the
|
|
105
|
+
events the replay needs, and says backing a seam synthesizes (the site and the wallet do) is not proven and makes
|
|
106
|
+
the grant verdict conditional on the offer's resolver-trusted admission. Reading the history below the window is
|
|
107
|
+
not implemented. CONVENTION.md section 31's client policy says the same and gives `FILL_TIP_MARGIN` as 4 (it
|
|
108
|
+
said 2). Comments and docs only.
|
|
109
|
+
- The `FillSpvIo.provenEvent` contract says `proposer` and `attester` are the prevout-bound author (csd-crypto
|
|
110
|
+
`authorOf`), never the signer read from the scriptSig, which the txid does not commit, and that an event whose
|
|
111
|
+
author cannot be bound is null. A seam that took the author from the scriptSig let a body server move a hold or
|
|
112
|
+
a fill to another address. The site's and the wallet's seams already bind it.
|
|
113
|
+
- `test/vectors/cases-rules.json` (5 vectors pinning 3 rules, `conformance/gen-rule-vectors.mjs`), replayed by
|
|
114
|
+
`test/vectors.test.ts` and against the Python oracle by `conformance/crosscheck-resolve.mjs`: a same-block fclaim
|
|
115
|
+
fill (the fill at the lower position and in the natural order) and a same-block seller cancel at the lower position
|
|
116
|
+
(proposals apply before attests within a block), a deploy whose uri is not its canonical JSON but whose payload
|
|
117
|
+
hash is the canonical form's (invalid), and a token offer giving and wanting one ticker (invalid). Removing or
|
|
118
|
+
reversing the order key, the canonical-uri check or the same-ticker refusal, in either implementation, now fails them.
|
|
119
|
+
- New root export `offerFillTooLate(expiresAt, tip)`, beside `offerExpiryHeightOf`: a policy refusal once fewer than
|
|
120
|
+
`FILL_TIP_MARGIN` (4) blocks of cushion remain before the offer's last live block (`expiresAt - 1 < tip +
|
|
121
|
+
FILL_TIP_MARGIN`). It does not mean the fill cannot mine (expiry 100, tip 96 returns true; inclusion at 97 to 99 is
|
|
122
|
+
possible). A fill not mined by that block is refused by the node: for an offer anchored at V22 or later it strands
|
|
123
|
+
and moves no payment; for one anchored before V22 whose expiry the v2.1 cap shortened, the resolver expires it while
|
|
124
|
+
the node still mines its attests, so a late fill there pays and delivers nothing. It was the wallet's own
|
|
125
|
+
predicate; the wallet, the site and cairn-sdk import this one. `fillEndorsement` was already a root export; both
|
|
126
|
+
are now pinned in the export-surface test.
|
|
127
|
+
- `requiredClaimDepth`'s doc and `CLAIM_ATTACKER_Q`'s comment no longer call the dominant block producer trusted or
|
|
128
|
+
the wait reorg-safe: the depth makes a reorg by a minority miner (20% of the hashrate) unlikely, and the external
|
|
129
|
+
pool that produces most blocks is outside the model. The depths are unchanged.
|
|
130
|
+
- Docs (README, CONVENTION.md's overview and section 4.5, MAKERS.md, the package description) no longer call
|
|
131
|
+
a fill atomic delivery-versus-payment or say a buyer cannot lose more than the anchor fee. One transaction pays and
|
|
132
|
+
records a fill and the replay decides delivery: a CSD-paid fill it refuses keeps the payment; a token-for-token
|
|
133
|
+
fill is atomic.
|
|
134
|
+
- README: the registration lifecycle and records table describe the v2.5 sealed reservation (a payment-free reveal
|
|
135
|
+
within 8 blocks, the fee at `nfinalize`), the open lane is the v2.8 `fclaim` reservation, the version table gains
|
|
136
|
+
v2.8 and v2.9 and drops a stale "pending" note, the conformance steps name every vector file, and cairn-cli
|
|
137
|
+
(deprecated) and the indexer's storage backend are no longer described.
|
|
138
|
+
- README: forward name resolution no longer says the wallet refuses a send whose sources disagree or cannot be
|
|
139
|
+
proven. It sends to the SPV-proven address with a "sources disagree" warning, shows an unprovable name as not
|
|
140
|
+
chain-verified with the served address and a caution, and refuses only an unresolved or lapsed name and a change
|
|
141
|
+
between review and confirm (the wallet's SECURITY.md).
|
|
142
|
+
- MAKERS.md's configuration table follows the reference bot: `MM_FILL_BIDS` defaults to 0 (fills and bid posts
|
|
143
|
+
off until set; with 1 and `MM_VERIFY_INCLUSION` off the bot alerts and publishes `build.fillsWithoutInclusion`),
|
|
144
|
+
and new rows for `MM_MAX_BALANCE_READS` (20 bidder balance reads a pass), `MM_SUNRISE_START_TIP` and
|
|
145
|
+
`MM_SKIM_TO` (the one address a live skim may send to; `MM_ISSUER_ADDR` is not the skim destination).
|
|
146
|
+
- New root export `FCLAIM_MAX_HOLD_SPAN` (89): the longest fclaim hold, so a fill at height f has its fclaim in
|
|
147
|
+
`[f - FCLAIM_MAX_HOLD_SPAN, f]`. `GAP_NEEDED` is now written as `FCLAIM_MAX_HOLD_SPAN + CLAIM_COOLDOWN_BLOCKS`, same
|
|
148
|
+
value (104). The site's refusal before the reservation fee needs it to tell which listed fills may lie below the
|
|
149
|
+
window its fill check reads; the wallet held a copy of it.
|
|
150
|
+
- `resolve()`, canonical state and every `verifyFillSpv` verdict are byte-identical to 0.2.3.
|
|
151
|
+
|
|
3
152
|
## 0.2.3
|
|
4
153
|
|
|
5
154
|
- `provenOfferRefusal` refuses the two record-only activation gates it lacked. An offer anchored below
|