-
Notifications
You must be signed in to change notification settings - Fork 7
feat: replace ckb-transaction-dumper with ccc-based implementation #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
242c5f4
feat: replace ckb-transaction-dumper with ccc-based implementation
RetricSu c300786
chore: add changeset for ckb-transaction-dumper replacement
RetricSu 7a4ac6d
fix: address PR review comments for ckb-tx-dumper
RetricSu 1ebee29
fix: fix CCC-based transaction dumper for debug command
RetricSu f72d68b
fix: address Copilot PR review comments for ccc-based tx dumper
RetricSu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@offckb/cli': minor | ||
| --- | ||
|
|
||
| Replace ckb-transaction-dumper with ccc-based implementation | ||
|
|
||
| - Rewrite transaction dumper to use ccc Client and molecule codecs | ||
| - Implement dep_group unpacking using ccc.mol | ||
| - Remove ckb-transaction-dumper npm dependency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "active_plan": "/Users/retric/Desktop/offckb/.sisyphus/plans/ckb-tx-dumper.md", | ||
| "started_at": "2026-03-30T05:21:40.692Z", | ||
| "session_ids": [ | ||
| "ses_2c33429e4ffezuzNe4AF50Ln2T" | ||
| ], | ||
| "plan_name": "ckb-tx-dumper", | ||
| "agent": "atlas" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| # Replace ckb-transaction-dumper with ccc-based implementation | ||
|
|
||
| ## TL;DR | ||
|
|
||
| > **Quick Summary**: Replace `ckb-transaction-dumper` npm package with a pure ccc-based implementation. | ||
| > | ||
| > **Deliverables**: | ||
| > | ||
| > - New `src/tools/ckb-tx-dumper.ts` (replaces old implementation) | ||
| > - Removed `ckb-transaction-dumper` from package.json | ||
| > | ||
| > **Estimated Effort**: Medium (2-3 hours) | ||
| > **Parallel Execution**: NO - sequential | ||
|
|
||
| --- | ||
|
|
||
| ## Context | ||
|
|
||
| ### Request | ||
|
|
||
| Replace `ckb-transaction-dumper` with ccc-based implementation (no external dependencies, use ccc throughout). | ||
|
|
||
| ### Current Implementation | ||
|
|
||
| - `src/tools/ckb-tx-dumper.ts` spawns `ckb-transaction-dumper` binary | ||
| - Depends on npm package `ckb-transaction-dumper@0.4.2` | ||
|
|
||
| ### What TransactionDumper Does | ||
|
|
||
| 1. Load transaction (from file or fetch by hash) | ||
| 2. Resolve cell deps (handle dep_group type) | ||
| 3. Resolve inputs | ||
| 4. Output mock transaction JSON for ckb-debugger | ||
|
|
||
| ### ccc Molecule Support | ||
|
|
||
| ccc provides full molecule codec: | ||
|
|
||
| - `ccc.molecule.struct()` - for OutPoint { tx_hash, index } | ||
| - `ccc.molecule.vector()` - for OutPointVec | ||
| - `ccc.Byte32`, `ccc.Uint32LE` - predefined codecs | ||
|
|
||
| No manual bytes parsing needed! | ||
|
|
||
| --- | ||
|
|
||
| ## Work Objectives | ||
|
|
||
| ### Core Objective | ||
|
|
||
| Replace `ckb-transaction-dumper` with pure ccc implementation. | ||
|
|
||
| ### Must Have | ||
|
|
||
| - Keep `DumpOption` interface | ||
| - Keep `dumpTransaction()` signature | ||
| - Same JSON output format | ||
|
|
||
| ### Must NOT Have | ||
|
|
||
| - Breaking API changes | ||
| - New dependencies | ||
|
|
||
| --- | ||
|
|
||
| ## TODOs | ||
|
|
||
| - [ ] 1. Implement ccc-based transaction dumper | ||
|
|
||
| **What to do**: | ||
|
|
||
| - Rewrite `src/tools/ckb-tx-dumper.ts` | ||
| - Use ccc Client for RPC calls | ||
| - Use ccc molecule codecs for dep_group unpacking | ||
|
|
||
| **Key implementation**: | ||
|
|
||
| ```typescript | ||
| import { ccc } from '@ckb-ccc/core'; | ||
|
|
||
| // OutPoint codec for dep_group unpacking | ||
| const OutPointCodec = ccc.molecule.struct({ | ||
| txHash: ccc.Byte32, | ||
| index: ccc.Uint32LE, | ||
| }); | ||
|
|
||
| const OutPointVecCodec = ccc.molecule.vector(OutPointCodec); | ||
|
|
||
| // Unpack dep_group data | ||
| function unpackDepGroup(data: string): ccc.OutPoint[] { | ||
| return OutPointVecCodec.decode(data).map((o) => | ||
| ccc.OutPoint.from({ txHash: o.txHash, index: '0x' + o.index.toString(16) }), | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| **Acceptance Criteria**: | ||
|
|
||
| - [ ] Uses ccc Client for RPC | ||
| - [ ] Uses ccc molecule for dep_group | ||
| - [ ] Same output format | ||
|
|
||
| **QA Scenarios**: | ||
|
|
||
| ``` | ||
| Scenario: Compiles successfully | ||
| Tool: Bash | ||
| Steps: npm run typecheck | ||
| Expected: No errors | ||
| ``` | ||
|
|
||
| **Commit**: `feat: implement transaction dumper with ccc` | ||
|
|
||
| --- | ||
|
|
||
| - [ ] 2. Remove ckb-transaction-dumper dependency | ||
|
|
||
| **What to do**: | ||
|
|
||
| - Remove from `package.json` | ||
| - Run `pnpm install` | ||
|
|
||
| **Commit**: `chore: remove ckb-transaction-dumper` | ||
|
|
||
| --- | ||
|
|
||
| ## Verification | ||
|
|
||
| ```bash | ||
| npm run typecheck | ||
| npm run lint | ||
| grep -c "ckb-transaction-dumper" package.json || echo "Clean" | ||
| ``` | ||
|
|
||
| ## Key Implementation Notes | ||
|
|
||
| ### Dep Group Unpacking with ccc | ||
|
|
||
| ```typescript | ||
| const OutPointCodec = ccc.molecule.struct({ | ||
| txHash: ccc.Byte32, | ||
| index: ccc.Uint32LE, | ||
| }); | ||
| const OutPointVecCodec = ccc.molecule.vector(OutPointCodec); | ||
|
|
||
| // Usage | ||
| const outpoints = OutPointVecCodec.decode(cellData); | ||
| ``` | ||
|
|
||
| ### Mock Transaction Structure | ||
|
|
||
| ```typescript | ||
| interface MockTransaction { | ||
| mock_info: { | ||
| inputs: MockInput[]; | ||
| cell_deps: MockCellDep[]; | ||
| header_deps: any[]; | ||
| }; | ||
| tx: Transaction; | ||
| } | ||
| ``` | ||
|
|
||
| ### Algorithm | ||
|
|
||
| 1. Load tx from file | ||
| 2. For each cell_dep: | ||
| - Fetch cell | ||
| - If dep_type === 'dep_group': | ||
| - Decode cell.data as OutPointVec | ||
| - Fetch each referenced cell | ||
| - Add to mock_info.cell_deps | ||
| 3. For each input: | ||
| - Fetch referenced cell | ||
| - Add to mock_info.inputs | ||
| 4. Write JSON output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.