Skip to content

Commit

Permalink
It is recommended to use ckb-cli to dump transactions (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson authored Nov 18, 2024
1 parent 0f4d195 commit 31ef8bb
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ckb-debugger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For Rust library usage, refer to the included tests, they are quite self-explana
See the command line help part for usage on the binary debugger:

```text
ckb-debugger 0.116.1
ckb-debugger 0.119.0
USAGE:
ckb-debugger [FLAGS] [OPTIONS] --mode <mode> [args]...
Expand All @@ -30,7 +30,7 @@ OPTIONS:
--gdb-listen <gdb-listen>
Address to listen for GDB remote debugging server [default: 127.0.0.1:9999]
--max-cycles <max-cycles> Max cycles [default: 70000000]
--max-cycles <max-cycles> Max cycles [default: 3500000000]
--mode <mode>
Execution mode of debugger [default: full] [possible values: decode-instruction, fast, full, gdb, probe]
Expand All @@ -48,7 +48,7 @@ ARGS:
<args>...
```

[ckb-transaction-dumper](https://github.com/xxuejie/ckb-transaction-dumper) can be used to dump the full mocked transaction used in the debugger from CKB.
[ckb-cli](https://github.com/nervosnetwork/ckb-cli) can be used to dump the full mocked transaction used in the debugger from CKB. This [example](./examples/mock_tx.md) shows how to use it.

# FAQ

Expand Down
68 changes: 68 additions & 0 deletions ckb-debugger/examples/mock_raw_tx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "0x0",
"cell_deps": [
{
"out_point": {
"tx_hash": "0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c",
"index": "0x0"
},
"dep_type": "dep_group"
},
{
"out_point": {
"tx_hash": "0x584ddf4379ae4fc87a435162c77faf9bbd55e5704f7ffbdcfa5052ed81f6770f",
"index": "0x1"
},
"dep_type": "code"
}
],
"header_deps": [],
"inputs": [
{
"since": "0x0",
"previous_output": {
"tx_hash": "0x129c00d14dfc2180df01382d9313692642c731bcdab75ff9b43cfb2291fd9555",
"index": "0x0"
}
},
{
"since": "0x0",
"previous_output": {
"tx_hash": "0x7a3ee6010411ab3f314e094abf0be15d6add8f0b56d80c4431fc9b465f329e5b",
"index": "0x1"
}
}
],
"outputs": [
{
"capacity": "0x35a4e9000",
"lock": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x3c2c45d0def478183ce14337d21bf55fa2308e03"
},
"type": {
"code_hash": "0x8b9cf1c536c2590282c2896ca34778590a3784b7daeafa241fe98e170a743ee0",
"hash_type": "data",
"args": "0x937602c81c5e6628e1ff615a91727daa2f6dbded304a5629b78e36e137ec3ee9"
}
},
{
"capacity": "0x48a1ef9d10",
"lock": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x3c2c45d0def478183ce14337d21bf55fa2308e03"
},
"type": null
}
],
"outputs_data": [
"0x17000000984ced3318cf80c981010000",
"0x"
],
"witnesses": [
"0x55000000100000005500000055000000410000001e657939f58f9ed8fc677f50a7c13538dafd1d60a88860bbe7dfe7dc3e92bfc557f393b0c2980491b63b2cac1367ef5a93379756e3dc6964cd015413288fb46a01",
"0x"
]
}
10 changes: 10 additions & 0 deletions ckb-debugger/examples/mock_tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ Run result: 1
Total cycles consumed: 1706(1.7K)
Transfer cycles: 764, running cycles: 942
```

In addition to debugging transactions that have been committed to the chain, you can also debug transactions that are not committed to the chain (including unsent transactions and transactions that failed to be committed to the chain).

To do this, we first need to prepare a transaction in json format, the file content is the same as the payload of json rpc [send_transaction](https://github.com/nervosnetwork/ckb/tree/develop/rpc#method-send_transaction).

```sh
$ ckb-cli --url https://mainnet.ckbapp.dev/rpc mock-tx dump --tx-file mock_raw_tx.json --output-file mock_tx.json
```

In the above command, we use `--tx-file mock_raw_tx.json` to specify a transaction, which is equivalent to `--tx-hash 0x5f0a4162622daa0e50b2cf8f49bc6ece22d1458d96fc12a094d6f074d6adbb55`.

0 comments on commit 31ef8bb

Please sign in to comment.