|
38 | 38 |
|
39 | 39 | ### Local UDT Handling May Overlap CCC Upstream (Medium) |
40 | 40 |
|
41 | | -- Issue: CCC now has a dedicated `@ckb-ccc/udt` package (at `ccc-fork/ccc/packages/udt/`). The local `packages/utils/src/udt.ts` and `packages/core/src/udt.ts` implement custom UDT handling (`UdtHandler` interface, `IckbUdtManager` class). While the local UDT handling is iCKB-specific (custom balance calculation accounting for DAO deposits), the generic UDT operations like `ccc.udtBalanceFrom()` are still being used from CCC upstream in `packages/utils/src/udt.ts` (4 locations). |
| 41 | +- Issue: CCC now has a dedicated `@ckb-ccc/udt` package (at `forks/ccc/packages/udt/`). The local `packages/utils/src/udt.ts` and `packages/core/src/udt.ts` implement custom UDT handling (`UdtHandler` interface, `IckbUdtManager` class). While the local UDT handling is iCKB-specific (custom balance calculation accounting for DAO deposits), the generic UDT operations like `ccc.udtBalanceFrom()` are still being used from CCC upstream in `packages/utils/src/udt.ts` (4 locations). |
42 | 42 | - Files: |
43 | 43 | - `packages/utils/src/udt.ts` - `UdtHandler` interface, `UdtManager` class (~370 lines) |
44 | 44 | - `packages/core/src/udt.ts` - `IckbUdtManager` extending UDT handling for iCKB-specific logic |
45 | | - - `ccc-fork/ccc/packages/udt/src/` - CCC upstream UDT package |
| 45 | + - `forks/ccc/packages/udt/src/` - CCC upstream UDT package |
46 | 46 | - Usage of `ccc.udtBalanceFrom()`: `packages/utils/src/udt.ts` lines 169, 197, 323, 368 |
47 | 47 | - Impact: There may be duplicated utility code for standard UDT operations (finding cells, calculating balances). The iCKB-specific extensions (e.g., `IckbUdtManager` which modifies balance calculations based on DAO deposit/withdrawal state) are domain-specific and unlikely to be in CCC. |
48 | 48 | - Fix approach: Audit the CCC `@ckb-ccc/udt` package to identify which local utilities can be replaced. Keep iCKB-specific extensions but delegate standard UDT operations (cell finding, basic balance) to CCC where possible. |
49 | 49 |
|
50 | 50 | ### Fragile CCC Local Override Mechanism (Medium) |
51 | 51 |
|
52 | | -- Issue: The `.pnpmfile.cjs` hook and `fork-scripts/record.sh` script create a fragile mechanism for overriding published CCC packages with local builds. The `.pnpmfile.cjs` `readPackage` hook intercepts pnpm's dependency resolution to redirect `@ckb-ccc/*` packages to local paths under `ccc-fork/ccc/packages/*/`. |
| 52 | +- Issue: The `.pnpmfile.cjs` hook and `forks/forker/record.sh` script create a fragile mechanism for overriding published CCC packages with local builds. The `.pnpmfile.cjs` `readPackage` hook intercepts pnpm's dependency resolution to redirect `@ckb-ccc/*` packages to local paths under `forks/ccc/packages/*/`. |
53 | 53 | - Files: |
54 | 54 | - `.pnpmfile.cjs` - pnpm hook that overrides `@ckb-ccc/*` package resolutions |
55 | | - - `fork-scripts/record.sh` - generic fork record script (clones repo, merges refs, builds locally) |
56 | | - - `ccc-fork/config.json` - CCC fork configuration (upstream URL, refs, workspace config) |
57 | | - - `pnpm-workspace.yaml` - includes `ccc-fork/ccc/packages/*` in workspace (auto-generated section) |
58 | | - - `ccc-fork/ccc/` - local CCC checkout (when present) |
| 55 | + - `forks/forker/record.sh` - generic fork record script (clones repo, merges refs, builds locally) |
| 56 | + - `forks/config.json` - CCC fork configuration (upstream URL, refs, workspace config) |
| 57 | + - `pnpm-workspace.yaml` - includes `forks/ccc/packages/*` in workspace (auto-generated section) |
| 58 | + - `forks/ccc/` - local CCC checkout (when present) |
59 | 59 | - Impact: Multiple fragility points: |
60 | | - 1. The local CCC repo at `ccc-fork/ccc/` must be manually cloned and kept in sync with a specific branch/commit. |
| 60 | + 1. The local CCC repo at `forks/ccc/` must be manually cloned and kept in sync with a specific branch/commit. |
61 | 61 | 2. The `readPackage` hook modifies `dependencies` objects at install time, which can silently break if CCC reorganizes its packages. |
62 | | - 3. CI/CD (`fork-scripts/replay.sh`) must run this setup before `pnpm install`, creating an ordering dependency. |
| 62 | + 3. CI/CD (`forks/forker/replay.sh`) must run this setup before `pnpm install`, creating an ordering dependency. |
63 | 63 | 4. The override mechanism is invisible to developers who don't read `.pnpmfile.cjs`, leading to confusion when packages resolve differently than expected from `package.json`. |
64 | 64 | - Fix approach: Now that UDT and Epoch PRs have been merged into CCC upstream, evaluate whether the local overrides are still needed. If CCC publishes releases containing the merged features, switch to published versions and remove the override mechanism. |
65 | 65 |
|
|
154 | 154 | - Current capacity: Maximum 64 output cells per transaction containing NervosDAO operations. |
155 | 155 | - Limit: Enforced by the NervosDAO script itself. Consolidated into CCC core in Phase 1. |
156 | 156 | - Files: |
157 | | - - `ccc-fork/ccc/packages/core/src/ckb/transaction.ts` — `assertDaoOutputLimit` utility + `completeFee` safety net (contributed to CCC core in Phase 1) |
| 157 | + - `forks/ccc/packages/core/src/ckb/transaction.ts` — `assertDaoOutputLimit` utility + `completeFee` safety net (contributed to CCC core in Phase 1) |
158 | 158 | - `packages/dao/src/dao.ts` — calls `assertDaoOutputLimit` |
159 | 159 | - `packages/core/src/owned_owner.ts` — calls `assertDaoOutputLimit` |
160 | 160 | - `apps/bot/src/index.ts`, line 414 (limits to 58 outputs to reserve 6 for change) |
|
217 | 217 |
|
218 | 218 | ### TS Exchange Rate Must Match Rust Contract Logic |
219 | 219 |
|
220 | | -- What's not tested: The TypeScript exchange rate calculation (`packages/core/src/udt.ts`) must produce identical results to the Rust contract's `deposit_to_ickb()` function (`reference/contracts/scripts/contracts/ickb_logic/src/entry.rs`). Any discrepancy would cause transactions to be rejected on-chain. |
| 220 | +- What's not tested: The TypeScript exchange rate calculation (`packages/core/src/udt.ts`) must produce identical results to the Rust contract's `deposit_to_ickb()` function (`forks/contracts/scripts/contracts/ickb_logic/src/entry.rs`). Any discrepancy would cause transactions to be rejected on-chain. |
221 | 221 | - Key formula: `iCKB = capacity * AR_0 / AR_m` with soft cap penalty `amount - (amount - 100000) / 10` when `amount > ICKB_SOFT_CAP_PER_DEPOSIT` |
222 | 222 | - Contract constants that TS must match: |
223 | 223 | - `CKB_MINIMUM_UNOCCUPIED_CAPACITY_PER_DEPOSIT = 1,000 * 100_000_000` (1,000 CKB) |
224 | 224 | - `CKB_MAXIMUM_UNOCCUPIED_CAPACITY_PER_DEPOSIT = 1,000,000 * 100_000_000` (1,000,000 CKB) |
225 | 225 | - `ICKB_SOFT_CAP_PER_DEPOSIT = 100,000 * 100_000_000` (100,000 iCKB) |
226 | 226 | - `GENESIS_ACCUMULATED_RATE = 10_000_000_000_000_000` (10^16) |
227 | | -- Reference: `reference/contracts/scripts/contracts/ickb_logic/src/entry.rs` function `deposit_to_ickb()` |
| 227 | +- Reference: `forks/contracts/scripts/contracts/ickb_logic/src/entry.rs` function `deposit_to_ickb()` |
228 | 228 | - Fix approach: Add cross-validation tests with known inputs/outputs derived from the Rust contract logic |
229 | 229 |
|
230 | 230 | ### TS Molecule Codecs Must Match Contract Schemas |
231 | 231 |
|
232 | | -- What's not tested: The TypeScript Molecule codec definitions (`@ccc.codec` decorators in `packages/order/src/entities.ts`, `packages/core/src/entities.ts`) must produce byte-identical encodings to the Molecule schema at `reference/contracts/schemas/encoding.mol`. Field order, sizes, and endianness must match exactly. |
| 232 | +- What's not tested: The TypeScript Molecule codec definitions (`@ccc.codec` decorators in `packages/order/src/entities.ts`, `packages/core/src/entities.ts`) must produce byte-identical encodings to the Molecule schema at `forks/contracts/schemas/encoding.mol`. Field order, sizes, and endianness must match exactly. |
233 | 233 | - Key schemas: |
234 | 234 | - `ReceiptData { deposit_quantity: Uint32, deposit_amount: Uint64 }` = 12 bytes |
235 | 235 | - `OwnedOwnerData { owned_distance: Int32 }` = 4 bytes |
|
0 commit comments