@inversealtruism/cairnx-core 0.2.2 → 0.2.4
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 +75 -0
- package/CONVENTION.md +15 -10
- package/MAKERS.md +8 -4
- package/README.md +74 -57
- package/dist/index.cjs +13 -6
- package/dist/index.d.cts +52 -13
- package/dist/index.d.ts +52 -13
- package/dist/index.js +10 -6
- package/package.json +2 -2
- package/test/vectors/cases-rules.json +446 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.4
|
|
4
|
+
|
|
5
|
+
- `verifyFillSpv`'s contract and comments say what its window replay decides. A grant depends on the holds granted
|
|
6
|
+
in the `GAP_NEEDED` (104) blocks before it and on the proposer's live holds on other offers, so a window decides an
|
|
7
|
+
fclaim only when its low end is quiet. The comments no longer say a proven event "only moves the replay toward
|
|
8
|
+
truth" or that the replayed `paid` is the chain's, and its doc lists what it refuses over a window that holds the
|
|
9
|
+
offer's history, including one honest case: the cap count includes the buyer's earlier fclaims on other offers the
|
|
10
|
+
chain denied, so three denied ones refuse a later fill the chain granted. A "Known limits" list names, by step, what a
|
|
11
|
+
window without it gets wrong, first for a caller that uses only `verifyFillSpv` and then with the site's and the
|
|
12
|
+
wallet's own checks: the grant replay (a hold chain from below the window can grant the caller's own fclaim the
|
|
13
|
+
chain denied, with an honest resolver; the site's served-hold check and the wallet's second-source read bound it),
|
|
14
|
+
aged fills at delivery (an honest tail below `min` is refused; for a coarse give the delivery check can disagree
|
|
15
|
+
with the chain's either way, so a caller refuses a payment its served offer computes as undeliverable) and the
|
|
16
|
+
sums bind (a served offer that omits such a fill and serves a lower `paid` passes it; for the site and the wallet
|
|
17
|
+
that needs the project's resolver to lie). The `FillSpvIo` contract names the offer and its give-backing among the
|
|
18
|
+
events the replay needs, and says backing a seam synthesizes (the site and the wallet do) is not proven and makes
|
|
19
|
+
the grant verdict conditional on the offer's resolver-trusted admission. Reading the history below the window is
|
|
20
|
+
not implemented. CONVENTION.md section 31's client policy says the same and gives `FILL_TIP_MARGIN` as 4 (it
|
|
21
|
+
said 2). Comments and docs only.
|
|
22
|
+
- The `FillSpvIo.provenEvent` contract says `proposer` and `attester` are the prevout-bound author (csd-crypto
|
|
23
|
+
`authorOf`), never the signer read from the scriptSig, which the txid does not commit, and that an event whose
|
|
24
|
+
author cannot be bound is null. A seam that took the author from the scriptSig let a body server move a hold or
|
|
25
|
+
a fill to another address. The site's and the wallet's seams already bind it.
|
|
26
|
+
- `test/vectors/cases-rules.json` (5 vectors pinning 3 rules, `conformance/gen-rule-vectors.mjs`), replayed by
|
|
27
|
+
`test/vectors.test.ts` and against the Python oracle by `conformance/crosscheck-resolve.mjs`: a same-block fclaim
|
|
28
|
+
fill (the fill at the lower position and in the natural order) and a same-block seller cancel at the lower position
|
|
29
|
+
(proposals apply before attests within a block), a deploy whose uri is not its canonical JSON but whose payload
|
|
30
|
+
hash is the canonical form's (invalid), and a token offer giving and wanting one ticker (invalid). Removing or
|
|
31
|
+
reversing the order key, the canonical-uri check or the same-ticker refusal, in either implementation, now fails them.
|
|
32
|
+
- New root export `offerFillTooLate(expiresAt, tip)`, beside `offerExpiryHeightOf`: a policy refusal once fewer than
|
|
33
|
+
`FILL_TIP_MARGIN` (4) blocks of cushion remain before the offer's last live block (`expiresAt - 1 < tip +
|
|
34
|
+
FILL_TIP_MARGIN`). It does not mean the fill cannot mine (expiry 100, tip 96 returns true; inclusion at 97 to 99 is
|
|
35
|
+
possible). A fill not mined by that block is refused by the node: for an offer anchored at V22 or later it strands
|
|
36
|
+
and moves no payment; for one anchored before V22 whose expiry the v2.1 cap shortened, the resolver expires it while
|
|
37
|
+
the node still mines its attests, so a late fill there pays and delivers nothing. It was the wallet's own
|
|
38
|
+
predicate; the wallet, the site and cairn-sdk import this one. `fillEndorsement` was already a root export; both
|
|
39
|
+
are now pinned in the export-surface test.
|
|
40
|
+
- `requiredClaimDepth`'s doc and `CLAIM_ATTACKER_Q`'s comment no longer call the dominant block producer trusted or
|
|
41
|
+
the wait reorg-safe: the depth makes a reorg by a minority miner (20% of the hashrate) unlikely, and the external
|
|
42
|
+
pool that produces most blocks is outside the model. The depths are unchanged.
|
|
43
|
+
- Docs (README, CONVENTION.md's overview and section 4.5, MAKERS.md, the package description) no longer call
|
|
44
|
+
a fill atomic delivery-versus-payment or say a buyer cannot lose more than the anchor fee. One transaction pays and
|
|
45
|
+
records a fill and the replay decides delivery: a CSD-paid fill it refuses keeps the payment; a token-for-token
|
|
46
|
+
fill is atomic.
|
|
47
|
+
- README: the registration lifecycle and records table describe the v2.5 sealed reservation (a payment-free reveal
|
|
48
|
+
within 8 blocks, the fee at `nfinalize`), the open lane is the v2.8 `fclaim` reservation, the version table gains
|
|
49
|
+
v2.8 and v2.9 and drops a stale "pending" note, the conformance steps name every vector file, and cairn-cli
|
|
50
|
+
(deprecated) and the indexer's storage backend are no longer described.
|
|
51
|
+
- README: forward name resolution no longer says the wallet refuses a send whose sources disagree or cannot be
|
|
52
|
+
proven. It sends to the SPV-proven address with a "sources disagree" warning, shows an unprovable name as not
|
|
53
|
+
chain-verified with the served address and a caution, and refuses only an unresolved or lapsed name and a change
|
|
54
|
+
between review and confirm (the wallet's SECURITY.md).
|
|
55
|
+
- MAKERS.md's configuration table follows the reference bot: `MM_FILL_BIDS` defaults to 0 (fills and bid posts
|
|
56
|
+
off until set; with 1 and `MM_VERIFY_INCLUSION` off the bot alerts and publishes `build.fillsWithoutInclusion`),
|
|
57
|
+
and new rows for `MM_MAX_BALANCE_READS` (20 bidder balance reads a pass), `MM_SUNRISE_START_TIP` and
|
|
58
|
+
`MM_SKIM_TO` (the one address a live skim may send to; `MM_ISSUER_ADDR` is not the skim destination).
|
|
59
|
+
- New root export `FCLAIM_MAX_HOLD_SPAN` (89): the longest fclaim hold, so a fill at height f has its fclaim in
|
|
60
|
+
`[f - FCLAIM_MAX_HOLD_SPAN, f]`. `GAP_NEEDED` is now written as `FCLAIM_MAX_HOLD_SPAN + CLAIM_COOLDOWN_BLOCKS`, same
|
|
61
|
+
value (104). The site's refusal before the reservation fee needs it to tell which listed fills may lie below the
|
|
62
|
+
window its fill check reads; the wallet held a copy of it.
|
|
63
|
+
- `resolve()`, canonical state and every `verifyFillSpv` verdict are byte-identical to 0.2.3.
|
|
64
|
+
|
|
65
|
+
## 0.2.3
|
|
66
|
+
|
|
67
|
+
- `provenOfferRefusal` refuses the two record-only activation gates it lacked. An offer anchored below
|
|
68
|
+
`ACTIVATION_HEIGHT` (29,860), where `resolve()` skips every event, is refused with "anchored before CairnX
|
|
69
|
+
activation (block 29860)"; a name offer anchored below `V11_HEIGHT` (29,960) with the resolver's own note "name
|
|
70
|
+
offers need v1.1". Before, a canonical name offer proven at 29,959 returned no refusal. Correction to 0.2.2: its
|
|
71
|
+
entry said `provenOfferRefusal` returns the resolver's note "for every rule that needs no chain state"; it covered
|
|
72
|
+
only the rules in `offerEnvelopeRefusal`, without these two.
|
|
73
|
+
- The name-offer v1.1 rule moved from `applyOffer` into `offerEnvelopeRefusal`, after the rules already there, which
|
|
74
|
+
is where `applyOffer` checked it. New root export `beforeActivation(height)`, which `resolve()` reads to skip
|
|
75
|
+
events below `ACTIVATION_HEIGHT` and `provenOfferRefusal` reads to refuse them.
|
|
76
|
+
- `resolve()` and canonical state are byte-identical to 0.2.2.
|
|
77
|
+
|
|
3
78
|
## 0.2.2
|
|
4
79
|
|
|
5
80
|
- `verifyFillSpv` fails closed when any id `offerEventIds` returns cannot be proven: `provenEvent` throws,
|
package/CONVENTION.md
CHANGED
|
@@ -22,7 +22,7 @@ replayer gates each rule on its own height constant, never on "version X implies
|
|
|
22
22
|
> it is the one that must never lag the code. Keep the two in lockstep when editing.
|
|
23
23
|
|
|
24
24
|
CairnX is a meta-asset and exchange convention on Compute Substrate (CSD). It defines fungible
|
|
25
|
-
tokens and
|
|
25
|
+
tokens and trades, one transaction paying and recording each fill, using **only** the chain's existing `Propose`
|
|
26
26
|
and `Attest` transactions: no fork, no new transaction types, no custodian. Token semantics are
|
|
27
27
|
enforced by a **pure, deterministic resolver** that any party can run; independent resolvers
|
|
28
28
|
replaying the same chain converge on identical state.
|
|
@@ -149,7 +149,7 @@ CairnX meaning for deploys. The **deployer** is the anchoring proposer.
|
|
|
149
149
|
- `memo` (64 UTF-16 units max) and `ts` are optional free fields with the same rules as
|
|
150
150
|
`transfer` (4.3); `ts` MUST be a JS-safe integer (A8).
|
|
151
151
|
|
|
152
|
-
### 4.5 `fill`:
|
|
152
|
+
### 4.5 `fill`: payment and record in one transaction (an Attest, not a Propose)
|
|
153
153
|
|
|
154
154
|
A fill is an **`Attest` transaction** referencing the offer's proposal id with **`score = 100`**,
|
|
155
155
|
whose **own outputs** pay the seller:
|
|
@@ -159,10 +159,12 @@ whose **own outputs** pay the seller:
|
|
|
159
159
|
- `Σ(outputs of the attesting tx paying want.payto) ≥ want.value`;
|
|
160
160
|
- on apply: the locked `give.amount` moves to the **attester**, the offer closes.
|
|
161
161
|
|
|
162
|
-
Because payment outputs and the attestation are one transaction (C2), **
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
Because payment outputs and the attestation are one transaction (C2), **one transaction pays and
|
|
163
|
+
records the fill**, and the replay then decides delivery by the rules above. A CSD-paid fill the replay
|
|
164
|
+
refuses keeps the payment: CairnX rejecting the fill does not undo or refund the transaction's CSD outputs,
|
|
165
|
+
which stand as the chain keeps them (subject to reorganization). A token-for-token fill
|
|
166
|
+
(§11) is atomic: the replay moves both sides or neither. The seller's tokens were already
|
|
167
|
+
convention-locked. The fill costs only the attest fee floor (0.05 CSD) plus the payment.
|
|
166
168
|
|
|
167
169
|
The **first valid fill in apply order wins**. For a **CSD-priced** fill `confidence` is ignored
|
|
168
170
|
(set 100); a **token-priced** fill (§11) additionally requires the `confidence = 1 000 000` opt-in
|
|
@@ -1134,10 +1136,13 @@ audit flags such a burn.
|
|
|
1134
1136
|
**Client policy (not consensus, does not affect canonical state).** A filler waits a value-scaled
|
|
1135
1137
|
`requiredClaimDepth` (§20 reorg note) on BOTH the offer and the fclaim (and, for a partial tail-fill, on the
|
|
1136
1138
|
offer's earlier fill-basis events) before signing, and refuses to broadcast a fill within `FILL_TIP_MARGIN`
|
|
1137
|
-
(`=
|
|
1138
|
-
height and `expires_epoch`.
|
|
1139
|
-
`GAP_NEEDED = EPOCH_LEN*(FCLAIM_MAX_EPOCH_AHEAD + 1) - 1 + CLAIM_COOLDOWN_BLOCKS` (`= 104`) blocks
|
|
1140
|
-
|
|
1139
|
+
(`= 4`) blocks of `holdEnd` (a stranded no-op, never a fund risk), computed from the fclaim's actual confirmed
|
|
1140
|
+
height and `expires_epoch`. Whether an fclaim was granted depends on the holds granted in the
|
|
1141
|
+
`GAP_NEEDED = EPOCH_LEN*(FCLAIM_MAX_EPOCH_AHEAD + 1) - 1 + CLAIM_COOLDOWN_BLOCKS` (`= 104`) blocks before it and on
|
|
1142
|
+
its proposer's live holds on other offers. A client replaying a window of blocks it read completely therefore
|
|
1143
|
+
decides an fclaim only when the window reaches `GAP_NEEDED` below it and the fclaims in that span are decided as
|
|
1144
|
+
well; an fclaim in the window's lowest `GAP_NEEDED` blocks, and a fill older than the window, are not decided by
|
|
1145
|
+
it. cairnx-core's `verifyFillSpv` replays such a window and names these as known limits.
|
|
1141
1146
|
|
|
1142
1147
|
- **Adoption note:** at/above V28 the fill's referenced proposal changes (offer id becomes fclaim txid) and
|
|
1143
1148
|
`SCORE_CLAIM` is rejected, so v2.8 is BOTH a relaxation (an fclaim fill a fresh core accepts, a stale core
|
package/MAKERS.md
CHANGED
|
@@ -37,7 +37,8 @@ Since v1.3 (`V13_HEIGHT = 31,100`) the CSD-priced market is an RFQ loop:
|
|
|
37
37
|
2. A maker answers with a taker-bound offer: `give` is X, `want` is N CSD, `taker` is the bidder, and the record
|
|
38
38
|
carries `bid: <bidId>`. Only that bidder can fill it, so there is no same-block fill race and a losing buyer can
|
|
39
39
|
never forfeit a payment.
|
|
40
|
-
3. The bidder fills it. One
|
|
40
|
+
3. The bidder fills it. One transaction pays the maker and records the fill; CairnX delivers X when the fill matches
|
|
41
|
+
the offer. A CSD-paid fill it refuses (expired, underpaid) keeps the payment, so the bidder's wallet checks first.
|
|
41
42
|
|
|
42
43
|
Open (non-taker-bound) CSD offers are rejected by consensus in `[v1.3, v1.7)`, which is why making is RFQ. From v1.7
|
|
43
44
|
(`V17_HEIGHT = 34,000`) open CSD asks are allowed again and are made race-safe a second way; see "Open asks and the
|
|
@@ -246,12 +247,13 @@ Amounts named "base" are base units (CSD has 8 decimals). Defaults are those of
|
|
|
246
247
|
| `MM_FEE_BUDGET` | `1000000000` | Base CSD per UTC day of fees that bought nothing back. Live and filled answers are not counted; answers that expired unfilled are. Past half of it, addresses with no prior fill on CairnX are answered only for bids of at least `MM_FRESH_MIN_CSD` (reason `budget-fresh-min`); past all of it the bot posts nothing of its own and answers returning buyers only (`budget-returning-only`). Answers to returning buyers are bounded by `MM_MAX_BID_ANSWERS` and `MM_MIN_FLOAT_HARD`, not by this budget. |
|
|
247
248
|
| `MM_FRESH_MIN_CSD`, `MM_FRESH_SLOTS` | `2000000000`, `16` | A bid below the minimum from an address with no prior fill is "fresh small" (in Sunrise the answer price is compared, not the bid). Such answers hold at most `MM_FRESH_SLOTS` of the `MM_MAX_BID_ANSWERS` slots (reason `fresh-slots`). |
|
|
248
249
|
| `MM_BID_MIN`, `MM_BID_MARGIN_BPS`, `MM_MAX_BID_ANSWERS` | `200000000`, `200`, `24` | Bid dust floor (2 CSD), accept margin over the reference, and outstanding-answer cap. |
|
|
250
|
+
| `MM_MAX_BALANCE_READS` | `20` | Bidder balances one answer pass reads from the node (each `/utxos` read walks the node's UTXO set). The checks that need no balance run first; a balance is cached per address and tip, and one read insolvent is not read again for 3 blocks. Returning bidders are read first, then addresses never read, then re-reads, each resuming where the last capped pass stopped; a bid whose turn is a later pass is skipped that pass as `balance-unknown`. At least 1. |
|
|
249
251
|
| `MM_LOCK_FRAC` | `2500` | Token locked in open answers is at most this many bps of inventory. |
|
|
250
252
|
| `MM_DAY_SELL_CAIRN`, `MM_DAY_SELL_CSD` | `3000000000000`, `50000000000` | Daily sell caps in base units (30,000 CAIRN at 8 decimals, 500 CSD): today's fills plus live answers. In Sunrise an answer whose taker can no longer pay for it is not reserved against them; `MM_LOCK_FRAC`, inventory and `MM_SUNRISE_E` still count every live answer. |
|
|
251
253
|
| `MM_EXCLUDE_ADDRS` | the CairnX treasury address | Comma list; excluded from the reference, from answers and from fills. |
|
|
252
254
|
| `MM_BID_SPREAD_BPS`, `MM_BID_SIZE`, `MM_MAX_OPEN_BIDS` | `800`, `2000000000`, `2` | Thin bid side (Reservoir only). The bid reference is collared at the ask reference so the book cannot cross. `MM_MAX_OPEN_BIDS=0` stops new posts only, not fills of existing bids. |
|
|
253
255
|
| `MM_BID_LEVELS` | `[]` | `[[spreadBps, sizeCsd],...]`; empty means a single `MM_BID_SPREAD_BPS` bid. |
|
|
254
|
-
| `MM_FILL_BIDS` | `
|
|
256
|
+
| `MM_FILL_BIDS` | `0` | `1` turns on fills of answers to the maker's bids and new bid posts; at `0` cancels still run, so a start without the setting buys nothing. With `1` and `MM_VERIFY_INCLUSION` off the bot starts, alerts at boot and publishes `build.fillsWithoutInclusion` in its health and quotes files: its fills would pay on what the indexer serves. The buy side runs only in the Reservoir: the Sunrise posts no bids. Must be 0 or 1. |
|
|
255
257
|
| `MM_DAY_BUY_CSD`, `MM_BID_EXPIRY` | `10000000000`, `24` | An absolute ceiling on the day's bid-side CSD (100 CSD); the buy-back guards below set the working limit. Bid life in epochs; bids are cancellable. |
|
|
256
258
|
| `MM_BUY_SALE_BPS` | `1000` | All-in buybacks over the trailing 7 days at most this share of the maker's 7-day sale proceeds. No recent sales, no buying. |
|
|
257
259
|
| `MM_BUY_LIFE_BPS` | `500` | Buybacks since the start tip at most this share of the sale proceeds since then. |
|
|
@@ -274,8 +276,10 @@ Amounts named "base" are base units (CSD has 8 decimals). Defaults are those of
|
|
|
274
276
|
| `MM_SUNRISE_E`, `MM_SUNRISE_DAY_QUOTA`, `MM_SUNRISE_MAX_EPOCHS` | `100000`, `5000`, `2160` | Scheduled emission (display units), per-UTC-day quota with no accrual, and the epoch cap after which the schedule graduates. |
|
|
275
277
|
| `MM_SUNRISE_MAX_ORDER` | `60000` | Largest single Sunrise answer in display units; the day quota caps it too. Published as `sunrise.maxOrder` in base units. |
|
|
276
278
|
| `MM_SUNRISE_BID_BUFFER_BPS` | `200` | Buffer a Swap UI adds to a Sunrise bid above the rung; the answer asks the maker's price, so this is the buyer's tolerance. At most 2000. |
|
|
279
|
+
| `MM_SUNRISE_START_TIP` | `0` | The tip a Sunrise record starts at when the bot creates one (`0`: the current tip). Pin it to the launch tip, so a state file lost with its marker re-derives the sale, its clock and its price from the chain since the pin instead of restarting at P0. A whole number. |
|
|
277
280
|
| `MM_SUNRISE_TARGET_DEPTH_BPS` | `500` | Part of the float target behind `sunrise.skimmable`: this many bps of the remaining Sunrise value. |
|
|
278
|
-
| `MM_ISSUER_ADDR`, `MM_SKIM_LEDGER` | empty, `~/.config/cairn/mm-skim.jsonl` |
|
|
281
|
+
| `MM_ISSUER_ADDR`, `MM_SKIM_LEDGER` | empty, `~/.config/cairn/mm-skim.jsonl` | The issuer address the quotes file publishes (`issuer`), and the skim ledger. The bot never sends CSD itself; see "Skimming CSD". |
|
|
282
|
+
| `MM_SKIM_TO` | empty | The one address a live skim may send to. The skim script refuses a live run without it or with another `--to`; the bot's loader parses it and no pass reads it. |
|
|
279
283
|
|
|
280
284
|
`MM_SUNRISE_PRICE_LOCK_BLOCKS` and `MM_SUNRISE_PRICE_LOCK_LOOKBACK` are not read any more.
|
|
281
285
|
|
|
@@ -372,7 +376,7 @@ if that is the floor you want. Graduation is not a claim that the market is liqu
|
|
|
372
376
|
### Skimming CSD
|
|
373
377
|
|
|
374
378
|
Excess CSD is moved out with an operator script (`scripts/mm-skim.mjs` in the reference repo). `--dry` is the default and
|
|
375
|
-
`--live` submits. It refuses amounts above the quotes file's `sunrise.skimmable`: the float above a target of `MM_SUNRISE_TARGET_DEPTH_BPS` of the remaining Sunrise value plus 30 days of `MM_FEE_BUDGET`, never less than twice `MM_MIN_FLOAT`, and only when the float exceeds 1.5 times that target. The
|
|
379
|
+
`--live` submits, only to `MM_SKIM_TO`, which `--to` must repeat. It refuses amounts above the quotes file's `sunrise.skimmable`: the float above a target of `MM_SUNRISE_TARGET_DEPTH_BPS` of the remaining Sunrise value plus 30 days of `MM_FEE_BUDGET`, never less than twice `MM_MIN_FLOAT`, and only when the float exceeds 1.5 times that target. The
|
|
376
380
|
ledger is `MM_SKIM_LEDGER` (mode 600).
|
|
377
381
|
|
|
378
382
|
## Honest limits
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @inversealtruism/cairnx-core
|
|
2
2
|
|
|
3
3
|
**CairnX** is the application layer of [Compute Substrate](https://cairn-substrate.com/docs) (CSD): an
|
|
4
|
-
on-chain **name service (CNS / `.csd`)**, **tokens**, and **
|
|
4
|
+
on-chain **name service (CNS / `.csd`)**, **tokens**, and **trades** (one transaction pays and records a fill; the replay decides delivery), implemented as a **pure deterministic convention** over the chain's native `Propose`/`Attest`
|
|
5
5
|
transactions. No fork, no smart contracts, no custodian. The same trust class as Bitcoin
|
|
6
6
|
Ordinals/Runes/BRC-20, stated plainly, and engineered to be byte-for-byte reproducible.
|
|
7
7
|
|
|
@@ -32,27 +32,29 @@ the operator's resolver does, and disagreement is detectable.
|
|
|
32
32
|
```
|
|
33
33
|
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
34
34
|
│ APP SURFACES CNS UI (/names) · Market (/trade) · Cairn Wallet │
|
|
35
|
-
│ Explorer ·
|
|
35
|
+
│ Explorer · 3rd-party dApps │
|
|
36
36
|
└───────────────▲───────────────────────────────────────────────▲──────────────┘
|
|
37
37
|
│ read derived state │ build + sign records
|
|
38
38
|
┌───────────────┴───────────────────────────────────────────────┴──────────────┐
|
|
39
39
|
│ cairnX OVERLAY = resolve(events, tip) → state (THIS PACKAGE) │
|
|
40
40
|
│ every replayer runs the SAME pure function and gets the SAME bytes: │
|
|
41
|
-
│ wallet (SPV, in-browser) · reference resolver · clarvis
|
|
41
|
+
│ wallet (SPV, in-browser) · reference resolver · clarvis │
|
|
42
42
|
└───────────────▲────────────────────────────────────────────────────────────────┘
|
|
43
43
|
│ events (Propose/Attest) + block headers
|
|
44
44
|
┌───────────────┴────────────────────────────────────────────────────────────────┐
|
|
45
|
-
│ COMPUTE SUBSTRATE (base chain) PoW · records & orders txs ·
|
|
46
|
-
│
|
|
45
|
+
│ COMPUTE SUBSTRATE (base chain) PoW · records & orders txs · pays every output │
|
|
46
|
+
│ it mines, enforces expiry - decides NOTHING │
|
|
47
47
|
└──────────────────────────────────────────────────────────────────────────────────┘
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
**The safety consequence of "overlay":** CairnX names and tokens have **no native-CSD backing**. A bug,
|
|
51
51
|
an over-mint, or even a fully-lying indexer can only fork the *overlay view* of whoever trusts it, it
|
|
52
|
-
**cannot move CSD**. CSD moves *only* via real
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
**cannot move CSD**. CSD moves *only* via real payment outputs in the fill's own transaction. The chain pays them
|
|
53
|
+
whenever it mines the transaction; CairnX then decides delivery by replay, and a CSD-paid fill it refuses (an expired
|
|
54
|
+
offer, a wrong target, an underpaid leg, a denied reservation) keeps the payment. So a buyer's wallet and the site
|
|
55
|
+
check the fill against the offer's merkle-proven terms and the reservation before signing. An overlay bug can
|
|
56
|
+
therefore not create or move CSD on its own; it can make a fill a buyer signs deliver nothing, which those checks
|
|
57
|
+
exist to refuse.
|
|
56
58
|
|
|
57
59
|
```mermaid
|
|
58
60
|
flowchart TD
|
|
@@ -63,13 +65,12 @@ flowchart TD
|
|
|
63
65
|
W["Cairn Wallet<br/>in-browser SPV replayer"]
|
|
64
66
|
G["reference resolver svc :8794"]
|
|
65
67
|
CL["clarvis · 2nd source"]
|
|
66
|
-
CLI["cairn-cli"]
|
|
67
68
|
UIN["CNS UI /names"]
|
|
68
69
|
UIT["Market /trade"]
|
|
69
70
|
TX --> CORE
|
|
70
|
-
CORE --> W & G & CL
|
|
71
|
+
CORE --> W & G & CL
|
|
71
72
|
G --> UIN & UIT
|
|
72
|
-
W -. "self-verifies
|
|
73
|
+
W -. "self-verifies; an unprovable name shows the served address with a caution" .-> UIN
|
|
73
74
|
```
|
|
74
75
|
|
|
75
76
|
---
|
|
@@ -85,14 +86,16 @@ plain on-chain records, all resolvable by replay.
|
|
|
85
86
|
- **The `.csd` suffix is presentation, not consensus.** The on-chain record stores the *bare* name
|
|
86
87
|
(`alice`); the UI renders `alice.csd`. The CNS rebrand and any display-suffix change are **UI-only**, they do not touch the resolver or chain history.
|
|
87
88
|
- **Reserved names** (`csd`, `treasury`, `admin`, `official`, `root`, `www`, `support`) can never be
|
|
88
|
-
registered, anti-impersonation
|
|
89
|
+
registered, anti-impersonation. The convention's parse rule refuses them (`isName`, `src/records.ts`), so every
|
|
90
|
+
replayer agrees; the chain itself does not read names.
|
|
89
91
|
|
|
90
92
|
### 2.1 · Lifecycle
|
|
91
93
|
|
|
92
94
|
```mermaid
|
|
93
95
|
stateDiagram-v2
|
|
94
96
|
[*] --> Committed: ncommit · hash(name+salt+owner)
|
|
95
|
-
Committed -->
|
|
97
|
+
Committed --> Reserved: name (reveal within 8 blocks, ~16 min) · payment-free reservation
|
|
98
|
+
Reserved --> Active: nfinalize (once the contest froze) · pays the fee, starts a 1-year lease
|
|
96
99
|
Active --> Active: nrenew · nset (point to addr) · nprofile (identity) · nxfer (transfer) · sell (offer/fill)
|
|
97
100
|
Active --> Grace: lease term ends (~1 year)
|
|
98
101
|
Grace --> Active: nrenew · OWNER ONLY, ~30-day window
|
|
@@ -101,10 +104,12 @@ stateDiagram-v2
|
|
|
101
104
|
Active --> [*]
|
|
102
105
|
```
|
|
103
106
|
|
|
104
|
-
1. **Commit → Reveal (registration
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
1. **Commit → Reveal → Finalize (registration, v2.5 sealed reservation, `CONVENTION.md` section 28).** You
|
|
108
|
+
first publish `ncommit`, a hash of `{name, salt, owner}`. Within 8 blocks (~16 min) you publish the `name`
|
|
109
|
+
record revealing the name; the reveal pays nothing and makes a reservation. The resolver **back-dates** it to
|
|
110
|
+
the commit height, so a front-runner who copies your reveal loses the race. Once the displacement contest has
|
|
111
|
+
frozen, the winner publishes `nfinalize`, which pays the fee and starts the lease; a reservation not finalized
|
|
112
|
+
in time lapses. Recapture of a lapsed name runs through the same machinery (v2.6, section 29).
|
|
108
113
|
2. **Active lease (~1 year).** You own the name: point it at an address (`nset`), set an identity profile
|
|
109
114
|
(`nprofile`), transfer it (`nxfer`), renew it (`nrenew`), or list it for sale.
|
|
110
115
|
3. **Grace (~30 days).** When the term ends, **only the current owner** may renew during a grace window, your name is never sniped out from under you while you still hold it.
|
|
@@ -118,7 +123,8 @@ stateDiagram-v2
|
|
|
118
123
|
| Record | What it does |
|
|
119
124
|
|---|---|
|
|
120
125
|
| `ncommit` | Commit to a name (hash of name+salt+owner), opens the front-run-safe reveal window |
|
|
121
|
-
| `name` | Reveal
|
|
126
|
+
| `name` | Reveal (registration): a payment-free reservation, back-dated to the commit |
|
|
127
|
+
| `nfinalize` | Finalize the reservation: pays the registration fee, starts the lease |
|
|
122
128
|
| `nrenew` | Extend the lease (owner-only in grace) |
|
|
123
129
|
| `nxfer` | Transfer ownership to another address |
|
|
124
130
|
| `nset` | Set the forward address record (`alice.csd → 0x…`) |
|
|
@@ -137,9 +143,9 @@ stateDiagram-v2
|
|
|
137
143
|
### 2.4 · How a name resolves, and what's actually *verified*
|
|
138
144
|
|
|
139
145
|
This is what makes CNS trust-minimized rather than "ask a server." When the wallet resolves `alice.csd`
|
|
140
|
-
to choose a send recipient, it does **not**
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
to choose a send recipient, it does **not** take the resolver's answer as the address: it SPV-verifies every
|
|
147
|
+
relevant record into the proof-of-work chain it built itself, replays them, and sends to the recomputed winner
|
|
148
|
+
when the replay proves one. When it cannot prove one, it says so and leaves the decision to the user.
|
|
143
149
|
|
|
144
150
|
```mermaid
|
|
145
151
|
sequenceDiagram
|
|
@@ -153,17 +159,21 @@ sequenceDiagram
|
|
|
153
159
|
Wallet->>SPV: merkle-verify each record into the PoW-verified headers
|
|
154
160
|
Note over Wallet,SPV: union of sources: a source can only ADD real,<br/>signer-authenticated, prevout-bound events (never fabricate)
|
|
155
161
|
Wallet->>Wallet: resolve() the verified events to a deterministic owner + addr
|
|
156
|
-
alt
|
|
157
|
-
Wallet-->>U: verified
|
|
158
|
-
else
|
|
159
|
-
Wallet-->>U:
|
|
162
|
+
alt the replay proves an address
|
|
163
|
+
Wallet-->>U: verified: send to the proven address (warn if a source stated another)
|
|
164
|
+
else nothing provable, or the sources prove different addresses
|
|
165
|
+
Wallet-->>U: not chain-verified: show the served address with a caution, the user decides
|
|
160
166
|
end
|
|
161
167
|
```
|
|
162
168
|
|
|
163
|
-
- **Forward resolution (`name → address`, the funds path) is SPV-verified and
|
|
164
|
-
treats the resolver as untrusted, merkle-binds each record to a PoW header
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
- **Forward resolution (`name → address`, the funds path) is SPV-verified, and a disagreement is a warning.**
|
|
170
|
+
The wallet treats the resolver as untrusted, merkle-binds each record to a PoW header and replays. When a
|
|
171
|
+
source states another address than the replay proves, the send goes to the proven address with a "sources
|
|
172
|
+
disagree" warning; when nothing can be proven, the name is shown as not chain-verified, with the served
|
|
173
|
+
address and a caution, and the user decides. Every `.csd` send carries the name-service caution. It refuses
|
|
174
|
+
a name that does not resolve or whose lease lapsed, and at signing it re-checks and refuses an address change
|
|
175
|
+
or a drop from verified to not verified. The wallet's `SECURITY.md` ("What happens when the sources
|
|
176
|
+
disagree") is the full list.
|
|
167
177
|
- **Reverse resolution (`address → primary name`, a display label) is server-trusted.** It is never a send
|
|
168
178
|
target, an identity badge only, so it is cheaper and clearly bounded as "unverified label."
|
|
169
179
|
- **Ownership has an unambiguous total order:** lowest `(effectiveHeight, position, ordinal-id)` wins, with
|
|
@@ -171,7 +181,7 @@ sequenceDiagram
|
|
|
171
181
|
|
|
172
182
|
> **Note on bought names:** a name you *register* is fully SPV-verifiable today. A name acquired via a
|
|
173
183
|
> *market fill* is displacement-immune and correctly resolved, but its forward resolution currently shows
|
|
174
|
-
> a caution rather than a green check (the wallet
|
|
184
|
+
> a caution rather than a green check (the wallet never shows it as verified) pending a resolver change
|
|
175
185
|
> that makes name-fills name-local. Registration, the alpha's primary flow, is unaffected.
|
|
176
186
|
|
|
177
187
|
---
|
|
@@ -192,11 +202,14 @@ can never touch CSD.
|
|
|
192
202
|
|
|
193
203
|
---
|
|
194
204
|
|
|
195
|
-
## 4 ·
|
|
205
|
+
## 4 · Trades: one transaction pays and records the fill
|
|
196
206
|
|
|
197
|
-
Sell a token **or a name** for CSD or another token
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
Sell a token **or a name** for CSD or another token. The offer locks the give-side in the resolver; the fill is an
|
|
208
|
+
`Attest` whose **same transaction carries the payment outputs**, so the chain records the payment and the fill
|
|
209
|
+
together, and CairnX decides delivery by replay. A token-for-token fill is atomic: the replay moves both sides or
|
|
210
|
+
neither. A CSD-paid fill the replay refuses keeps the payment: CairnX rejecting the fill does not undo or refund
|
|
211
|
+
the transaction's CSD outputs (only a chain reorganization can drop the transaction), so the buyer's client checks the offer's proven terms, the reservation and the amount before signing
|
|
212
|
+
(`verifyFillSpv`, `fillEndorsement`). No escrow, no custodian.
|
|
200
213
|
|
|
201
214
|
```mermaid
|
|
202
215
|
sequenceDiagram
|
|
@@ -204,16 +217,16 @@ sequenceDiagram
|
|
|
204
217
|
participant Chain as Compute Substrate
|
|
205
218
|
participant Taker
|
|
206
219
|
Maker->>Chain: offer { give: alice.csd or token, want: 100 CSD, payto } (locks the give)
|
|
207
|
-
Note over Chain: open CSD
|
|
220
|
+
Note over Chain: an open CSD offer is reserved first (fclaim, v2.8):<br/>only the holder's fill delivers, no race
|
|
208
221
|
Taker->>Chain: fill (Attest) + SAME-TX outputs · 100 CSD to payto, fee to treasury, rebate to maker
|
|
209
|
-
Chain-->>Chain: resolve(): payment satisfies want? deliver give to taker, else
|
|
210
|
-
Note over Maker,Taker:
|
|
222
|
+
Chain-->>Chain: resolve(): payment satisfies want? deliver give to taker, else no delivery
|
|
223
|
+
Note over Maker,Taker: a refused CSD-paid fill keeps the payment · check before signing
|
|
211
224
|
```
|
|
212
225
|
|
|
213
226
|
Highlights: partial fills (pro-rata, maker-favoring), bids (RFQ buy-side intents), `ocancel` (maker's mass
|
|
214
|
-
kill-switch), a 1.5% taker fee + maker rebate on resting liquidity (v1.6), and the
|
|
215
|
-
|
|
216
|
-
payment. Listing duration is a **UI policy** (consensus places no cap as of v2.2), long-rester inventory
|
|
227
|
+
kill-switch), a 1.5% taker fee + maker rebate on resting liquidity (v1.6), and the reservation lane for open CSD
|
|
228
|
+
offers: a short-expiry `fclaim` proposal reserves an untaken offer and the fill attests it (v2.8, `CONVENTION.md`
|
|
229
|
+
section 31, which replaced v1.7's claim attest), so two buyers can't race into a refused payment. Listing duration is a **UI policy** (consensus places no cap as of v2.2), long-rester inventory
|
|
217
230
|
is bounded in the light client, not the chain.
|
|
218
231
|
|
|
219
232
|
---
|
|
@@ -232,18 +245,21 @@ is bounded in the light client, not the chain.
|
|
|
232
245
|
mixed-version fleet can't fork during a rollout.
|
|
233
246
|
- **The determinism contract is *enforced*, not asserted.** An independent Python reference
|
|
234
247
|
(`conformance/cairnx_ref.py`) runs the same corpus and a 1500-iteration JS↔Python differential fuzzer on
|
|
235
|
-
every CI run, plus
|
|
248
|
+
every CI run, plus the language-neutral vectors in `test/vectors/` and pinned live-chain replay hashes.
|
|
236
249
|
|
|
237
250
|
### Version history (activation heights are consensus-grade, never reinterpret history)
|
|
238
251
|
|
|
252
|
+
Each row's normative statement is its section of `CONVENTION.md` (v2.5 to v2.9 are sections 28 to 32); the heights
|
|
253
|
+
live in `src/types.ts`.
|
|
254
|
+
|
|
239
255
|
| Version | Height | What |
|
|
240
256
|
|---|---|---|
|
|
241
257
|
| v1.0 / 1.1 | 29 860 / 29 960 | tokens · **names (CNS)** + protocol fees |
|
|
242
258
|
| v1.2 | 30 300 | token⇄token swaps · partial fills · bids (RFQ) · `ocancel` |
|
|
243
|
-
| v1.3 / 1.4 | 31 100 / 31 400 | CSD-priced offers taker-bound · fill-before-cancel
|
|
259
|
+
| v1.3 / 1.4 | 31 100 / 31 400 | CSD-priced offers taker-bound · fill-before-cancel (a same-block fill beats a cancel) |
|
|
244
260
|
| v1.5 | 32 000 | **name leasing** (renew / grace / decaying-premium recapture) · `tmeta` |
|
|
245
261
|
| v1.6 | 33 600 | taker fee 1% → 1.5% + maker rebate on resting liquidity |
|
|
246
|
-
| v1.7 | 34 000 | claim-to-fill, race-safe open CSD offers |
|
|
262
|
+
| v1.7 | 34 000 | claim-to-fill, race-safe open CSD offers (claim attests rejected from v2.8) |
|
|
247
263
|
| v1.9 | 36 700 | `nprofile`, ENS-class identity on a name |
|
|
248
264
|
| v2.0 | 38 400 | bounded claim grace (the late-fill fix) |
|
|
249
265
|
| v1.8 | 40 000 | flat two-tier name fee (6.7 / 3 CSD) |
|
|
@@ -253,7 +269,9 @@ is bounded in the light client, not the chain.
|
|
|
253
269
|
| v2.5 | 46 440 | sealed-reservation registration: payment-free reveal, winner-only fee at `nfinalize` |
|
|
254
270
|
| v2.6 | 46 480 | sealed-reservation recapture (lapsed-name premium paid by the settled winner only) |
|
|
255
271
|
| v2.7 | 46 520 | young-name sale embargo shrinks 240 → 8 blocks |
|
|
256
|
-
| v2.3 | 52 000 | `nset` to the zero address CLEARS the pointer
|
|
272
|
+
| v2.3 | 52 000 | `nset` to the zero address CLEARS the pointer |
|
|
273
|
+
| v2.8 | 60 000 | `fclaim`: the open-lane reservation becomes a short-expiry proposal the fill attests |
|
|
274
|
+
| v2.9 | 88 000 | replay-feed de-duplication; the concurrent-claim cap counts open holds only |
|
|
257
275
|
|
|
258
276
|
v2.4–v2.7 were re-pinned 2026-07-03 from their originally published heights (49 200 / 51 000 / 51 200 /
|
|
259
277
|
52 500); see the re-pin history note in `CONVENTION.md` and `CONSENSUS_CHANGES.md` 0.1.33.
|
|
@@ -261,13 +279,13 @@ v2.4–v2.7 were re-pinned 2026-07-03 from their originally published heights (4
|
|
|
261
279
|
### Package layout
|
|
262
280
|
|
|
263
281
|
`src/resolve.ts` + `src/resolve/` (the ledger: the replay loop and its per-record handlers) · `src/records.ts` (the parse/validate gate) · `src/types.ts` (constants +
|
|
264
|
-
height-gated client selectors) · `src/client.ts` (
|
|
282
|
+
height-gated client selectors) · `src/client.ts` (the claim-burial depth a payer waits for, sized against a minority miner) · `src/preflight.ts`
|
|
265
283
|
(build-side helpers every host must compute identically: `requiredFillOutputs`, `previewFill`/`fillIsSafe`,
|
|
266
284
|
`buildFeeHeight` + `NAME_FEE_GATES`, `finalizeWinnerCheck`) · `src/primary.ts` (`pickPrimaryName` /
|
|
267
285
|
`primaryRankBefore`, the one primary-name selection every host must agree on) · `src/mm/` (the
|
|
268
286
|
`@inversealtruism/cairnx-core/mm` subpath: the market maker's bid sizer, fill notional, Sunrise spot curve and
|
|
269
287
|
order pricing, and the RFQ all-in sum; not consensus and not part of the root export) · `CONVENTION.md`
|
|
270
|
-
(normative spec, §1–§
|
|
288
|
+
(normative spec, §1–§32) · `test/vectors/` (portable conformance corpus).
|
|
271
289
|
|
|
272
290
|
### Use it
|
|
273
291
|
|
|
@@ -279,7 +297,7 @@ import { buildPropose } from "@inversealtruism/csd-tx";
|
|
|
279
297
|
const built = offer({ give: { ticker: "CAIRN", amount: "5000000000" },
|
|
280
298
|
want: { value: "100000000" }, min: "10000000", taker: buyerAddr });
|
|
281
299
|
|
|
282
|
-
// ANCHOR it (the record IS the uri; same
|
|
300
|
+
// ANCHOR it (the record IS the uri; outputs in the same tx pay fees and sellers)
|
|
283
301
|
const tx = buildPropose({ domain: DOMAIN, uri: built.uri, payloadHash: built.payloadHash,
|
|
284
302
|
expiresEpoch, fee: 25_000_000, utxos, priv });
|
|
285
303
|
|
|
@@ -290,9 +308,10 @@ console.log(state.names, state.tokens.CAIRN, state.balances.CAIRN);
|
|
|
290
308
|
|
|
291
309
|
### Write a conformant resolver in another language
|
|
292
310
|
|
|
293
|
-
1. Implement `CONVENTION.md` §1–§
|
|
311
|
+
1. Implement `CONVENTION.md` §1–§32 (apply order, every record type, the `V*_HEIGHT` activations (using
|
|
294
312
|
the re-pinned v2.4–v2.7 heights), the canonical-state format, ordinal key ordering, data surface only).
|
|
295
|
-
2. Replay `test/vectors/cases.json`: your canonical state must equal
|
|
313
|
+
2. Replay `test/vectors/cases.json`, `cases-v29.json` and `cases-rules.json`: your canonical state must equal
|
|
314
|
+
`expectedState` **byte-for-byte**.
|
|
296
315
|
3. Replay the live chain and compare `sha256(canonicalState)` against `test/vectors/replay-hashes.json`.
|
|
297
316
|
|
|
298
317
|
---
|
|
@@ -310,13 +329,12 @@ is a silent chain fork, the exact bug class the shared-core de-dup (`cairn/docs/
|
|
|
310
329
|
| **cairnx svc** (`cairnx/`, the live resolver `:8794`) | npm pin → re-export shim | svc replay-hash conformance |
|
|
311
330
|
| **cairn /trade + /names UI** (browser) | `public/vendor/cairnx-core.js` (esbuild of this dist) | `vendor-cairnx-parity.test.mjs` + `check-vendor-fresh.mjs` |
|
|
312
331
|
| **cairn-wallet** (MV3, fund custody) | `src/vendor/cairnx-spv.js` (esbuild, `export *`) | `test/cairnx.ts` + `check-vendor-fresh.mjs` + `PROVENANCE.json` |
|
|
313
|
-
| **cairn-cli** | npm pin → imports regexes/limits | `test/cairnx.mjs` |
|
|
314
332
|
| **the Python oracle** `conformance/cairnx_ref.py` | INDEPENDENT re-implementation (the differential, **KEEP**) | `test:crosslang` (JS⇄Python) |
|
|
315
333
|
|
|
316
334
|
**To make a consensus change:** edit `src/` here **and** `conformance/cairnx_ref.py`; add a height-gated
|
|
317
335
|
`V*_HEIGHT` (never reinterpret history) + a vector; `pnpm build && pnpm test && pnpm test:crosslang`
|
|
318
336
|
(all green); **bump the version** (`node scripts/check-lockstep.mjs` fails until you do: it compares the
|
|
319
|
-
published tarball of the current version with this build); `
|
|
337
|
+
published tarball of the current version with this build); the npm window (`node scripts/npm-window.mjs`); **rebuild + recommit
|
|
320
338
|
the two vendored bundles**; re-pin every consumer and deploy them **between** activation heights, not
|
|
321
339
|
across one (below the gate the output is byte-identical, so the rollout is fork-free).
|
|
322
340
|
|
|
@@ -331,11 +349,10 @@ light-client + `namespv.ts`, the wallet `core/csdtx.ts` tx-codec twin, the porta
|
|
|
331
349
|
2-source name union whose two defaults share one apex, strong against *fabrication* (every event is
|
|
332
350
|
SPV/signer/prevout-bound), weaker against *withholding* until a genuinely independent second source runs.
|
|
333
351
|
The 2nd-indexer canonical-hash comparator is designed but parked until that exists.
|
|
334
|
-
- **The indexer ships on SQLite by default.** A Postgres backend is fully built (`csd-indexer/src/db.ts`)
|
|
335
|
-
and is a documented env-flip + from-genesis-replay cutover (`RUNBOOK-HOST.md §8.3`), the scale path, not
|
|
336
|
-
yet the running default.
|
|
337
352
|
- **`verifyInclusion` (merkle-binding the indexer's decoded outputs) is OFF by default** and is a hard
|
|
338
|
-
prerequisite before any lane treats received CSD as spendable. The overlay model
|
|
339
|
-
|
|
353
|
+
prerequisite before any lane treats received CSD as spendable. The overlay model keeps an overlay bug from
|
|
354
|
+
creating or moving CSD by itself; it does not make every payment safe. A CSD-paid fill CairnX refuses keeps the
|
|
355
|
+
payment, `verifyFillSpv`'s "Known limits" (in `src/verifyfill.ts`) list when a buyer's client can still sign one,
|
|
356
|
+
and a `.csd` send to a name the wallet cannot prove goes to the served address after a caution (section 2.4).
|
|
340
357
|
|
|
341
358
|
MIT · the same trust class as Ordinals/Runes, engineered for byte-for-byte reproducible replay.
|
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
EPOCH_LEN: () => import_csd_codec5.EPOCH_LEN,
|
|
40
40
|
FCLAIM_KEYS: () => FCLAIM_KEYS,
|
|
41
41
|
FCLAIM_MAX_EPOCH_AHEAD: () => FCLAIM_MAX_EPOCH_AHEAD,
|
|
42
|
+
FCLAIM_MAX_HOLD_SPAN: () => FCLAIM_MAX_HOLD_SPAN,
|
|
42
43
|
FCLAIM_WINDOW_MIN: () => FCLAIM_WINDOW_MIN,
|
|
43
44
|
FEE_BPS: () => FEE_BPS,
|
|
44
45
|
FEE_BPS_V16: () => FEE_BPS_V16,
|
|
@@ -111,6 +112,7 @@ __export(index_exports, {
|
|
|
111
112
|
V28_HEIGHT: () => V28_HEIGHT,
|
|
112
113
|
V29_HEIGHT: () => V29_HEIGHT,
|
|
113
114
|
ZERO_ADDR: () => ZERO_ADDR,
|
|
115
|
+
beforeActivation: () => beforeActivation,
|
|
114
116
|
bid: () => bid,
|
|
115
117
|
bindOfferTerms: () => bindOfferTerms,
|
|
116
118
|
bindProvenOffer: () => bindProvenOffer,
|
|
@@ -156,6 +158,7 @@ __export(index_exports, {
|
|
|
156
158
|
offer: () => offer,
|
|
157
159
|
offerCancelAll: () => offerCancelAll,
|
|
158
160
|
offerExpiryHeightOf: () => offerExpiryHeightOf,
|
|
161
|
+
offerFillTooLate: () => offerFillTooLate,
|
|
159
162
|
paidToFromOutputs: () => paidToFromOutputs,
|
|
160
163
|
parseAmount: () => parseAmount,
|
|
161
164
|
parseRecord: () => parseRecord,
|
|
@@ -182,6 +185,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
182
185
|
var import_csd_codec = require("@inversealtruism/csd-codec");
|
|
183
186
|
var DOMAIN = "cairnx:v1";
|
|
184
187
|
var ACTIVATION_HEIGHT = 29860;
|
|
188
|
+
var beforeActivation = (height) => height < ACTIVATION_HEIGHT;
|
|
185
189
|
var V11_HEIGHT = 29960;
|
|
186
190
|
var V12_HEIGHT = 30300;
|
|
187
191
|
var V13_HEIGHT = 31100;
|
|
@@ -288,6 +292,7 @@ var offerExpiryHeightOf = (expiresEpoch, anchorHeight) => {
|
|
|
288
292
|
const capped = ((0, import_csd_codec.epochOf)(anchorHeight) + MAX_OFFER_EPOCHS + 1) * import_csd_codec.EPOCH_LEN;
|
|
289
293
|
return Math.min(raw, Math.max(V21_HEIGHT, capped));
|
|
290
294
|
};
|
|
295
|
+
var offerFillTooLate = (expiresAt, tip) => expiresAt - 1 < tip + FILL_TIP_MARGIN;
|
|
291
296
|
var isNameGive = (g) => typeof g.name === "string";
|
|
292
297
|
var isTokenWant = (w) => typeof w.ticker === "string";
|
|
293
298
|
|
|
@@ -1267,10 +1272,6 @@ function applyOffer(c, ev, rec, who) {
|
|
|
1267
1272
|
const payto = (rec.want.payto ?? who).toLowerCase();
|
|
1268
1273
|
const give = rec.give;
|
|
1269
1274
|
if (isNameGive(give)) {
|
|
1270
|
-
if (!v11) {
|
|
1271
|
-
note(ev, ev.id, "offer", false, "name offers need v1.1");
|
|
1272
|
-
return;
|
|
1273
|
-
}
|
|
1274
1275
|
const n = names.get(give.name);
|
|
1275
1276
|
if (!n || n.owner !== who) {
|
|
1276
1277
|
note(ev, ev.id, "offer", false, "you don't own this name");
|
|
@@ -1466,6 +1467,7 @@ function offerEnvelopeRefusal(rec, who, height, expiresEpoch) {
|
|
|
1466
1467
|
if (!Number.isSafeInteger(expiresEpoch)) return "expiresEpoch out of safe-integer range";
|
|
1467
1468
|
if ((0, import_csd_codec.epochOf)(height) > expiresEpoch) return "already expired at anchor";
|
|
1468
1469
|
if (height >= V21_HEIGHT && height < V22_HEIGHT && expiresEpoch - (0, import_csd_codec.epochOf)(height) > MAX_OFFER_EPOCHS) return "v2.1: offer duration exceeds the max";
|
|
1470
|
+
if (isNameGive(rec.give) && height < V11_HEIGHT) return "name offers need v1.1";
|
|
1469
1471
|
return null;
|
|
1470
1472
|
}
|
|
1471
1473
|
|
|
@@ -1589,7 +1591,7 @@ function resolve(events, tipHeight) {
|
|
|
1589
1591
|
c.pendingCancels = [];
|
|
1590
1592
|
};
|
|
1591
1593
|
for (const ev of applied) {
|
|
1592
|
-
if (ev.height
|
|
1594
|
+
if (beforeActivation(ev.height)) continue;
|
|
1593
1595
|
if (ev.height !== pendingBlock) {
|
|
1594
1596
|
applyPendingCancels();
|
|
1595
1597
|
pendingBlock = ev.height;
|
|
@@ -1883,7 +1885,8 @@ function pickPrimaryName(names, a) {
|
|
|
1883
1885
|
|
|
1884
1886
|
// src/verifyfill.ts
|
|
1885
1887
|
var import_csd_codec4 = require("@inversealtruism/csd-codec");
|
|
1886
|
-
var
|
|
1888
|
+
var FCLAIM_MAX_HOLD_SPAN = import_csd_codec.EPOCH_LEN * (FCLAIM_MAX_EPOCH_AHEAD + 1) - 1;
|
|
1889
|
+
var GAP_NEEDED = FCLAIM_MAX_HOLD_SPAN + CLAIM_COOLDOWN_BLOCKS;
|
|
1887
1890
|
var SCAN_MARGIN = import_csd_codec.EPOCH_LEN;
|
|
1888
1891
|
var MAX_SCAN = GAP_NEEDED + SCAN_MARGIN;
|
|
1889
1892
|
function bindRecord(ev) {
|
|
@@ -2123,6 +2126,7 @@ function countOtherHoldsAtGrant(candidates, target, me, closed = /* @__PURE__ */
|
|
|
2123
2126
|
// src/admission.ts
|
|
2124
2127
|
function provenOfferRefusal(rec, tx) {
|
|
2125
2128
|
if (tx.domain !== DOMAIN) return `not a ${DOMAIN} Propose (domain ${JSON.stringify(String(tx.domain))})`;
|
|
2129
|
+
if (beforeActivation(tx.height)) return `anchored before CairnX activation (block ${ACTIVATION_HEIGHT})`;
|
|
2126
2130
|
const ee = typeof tx.expiresEpoch === "bigint" ? Number(tx.expiresEpoch) : tx.expiresEpoch;
|
|
2127
2131
|
return offerEnvelopeRefusal(rec, String(tx.seller).toLowerCase(), tx.height, ee);
|
|
2128
2132
|
}
|
|
@@ -2150,6 +2154,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2150
2154
|
EPOCH_LEN,
|
|
2151
2155
|
FCLAIM_KEYS,
|
|
2152
2156
|
FCLAIM_MAX_EPOCH_AHEAD,
|
|
2157
|
+
FCLAIM_MAX_HOLD_SPAN,
|
|
2153
2158
|
FCLAIM_WINDOW_MIN,
|
|
2154
2159
|
FEE_BPS,
|
|
2155
2160
|
FEE_BPS_V16,
|
|
@@ -2222,6 +2227,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2222
2227
|
V28_HEIGHT,
|
|
2223
2228
|
V29_HEIGHT,
|
|
2224
2229
|
ZERO_ADDR,
|
|
2230
|
+
beforeActivation,
|
|
2225
2231
|
bid,
|
|
2226
2232
|
bindOfferTerms,
|
|
2227
2233
|
bindProvenOffer,
|
|
@@ -2267,6 +2273,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2267
2273
|
offer,
|
|
2268
2274
|
offerCancelAll,
|
|
2269
2275
|
offerExpiryHeightOf,
|
|
2276
|
+
offerFillTooLate,
|
|
2270
2277
|
paidToFromOutputs,
|
|
2271
2278
|
parseAmount,
|
|
2272
2279
|
parseRecord,
|