nervosnetwork / ckb-cli

CKB command line interface
MIT License
55 stars 35 forks source link

The format of `epoch` and `timestamp` fileds for some `rpc` subcommands' is not a `0x-` prefixed hex string #577

Closed eval-exec closed 5 months ago

eval-exec commented 5 months ago

For example:

❯ ckb-cli rpc get_tip_header --output-format json
{
  "compact_target": "0x190941fa",
  "dao": "0x7a29096a3c6c144e69c41d97d94e2800ef5f39b20f962c06005b0af58d9c3707",
  "epoch": "0x461015100236d {number: 9069, index: 337, length: 1121}",
  "extra_hash": "0x4a0da5f0ded211c50182e0680b8c0ecd7b17b977ac466597857e3602bdd06964",
  "hash": "0xfe59be861ed7eb966f3dc6ecaefd878aea1cbceed5707b91305916e719bd7f08",
  "nonce": "0x84f24ff87e94ce740000001386223c72",
  "number": 11931673,
  "parent_hash": "0x2de03cef8f55f714873358388f47dbac9fcda4ab0b421a1ba887533e7acad052",
  "proposals_hash": "0x007fd55a09f1525ac56e932e5ac26c1e8d9c412983fadf84097213ca15d9136e",
  "timestamp": "1704878027667 (2024-01-10 17:13:47.667 +08:00)",
  "transactions_root": "0xf4df714df8b4bcfcdb8b13c87660cc40cb8d6bcee1ccaac8b3c016329ef3abe7",
  "version": 0
}

the epoch and timestamp fields should be a valid 0x-prefixed hex string.

Note: I believe the format of ckb rpc get_tip_header --output-format json should be the same as ckb molecule default --type Header --output-format json

$ ckb-cli molecule default --type Header --output-format json
{
  "compact_target": "0x0",
  "dao": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "epoch": "0x0",
  "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "nonce": "0x0",
  "number": "0x0",
  "parent_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x0",
  "transactions_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "version": "0x0"
}
eval-exec commented 5 months ago

This issue has existed for a long time

Screenshot_20240110_171825

eval-exec commented 5 months ago
$ ckb-cli rpc get_tip_header --output-format json --raw-data
{
  "compact_target": "0x190941fa",
  "dao": "0xd61f69de4073144e32a90701db4e2800c0bc43f38b982c0600a1f4d1b79c3707",
  "epoch": "0x461018800236d",
  "extra_hash": "0x47ab2b4db77d39b42d000da890ba12150a7fc0710309f42e5f5da4ffae5d3c01",
  "hash": "0xb1b273ba646be67cb9f84e32ca82a9a1f0cf5ad8c840c74329f001b87218fac2",
  "nonce": "0x51481be24680294f0000000242050500",
  "number": "0xb61050",
  "parent_hash": "0x4ee148108c47094264b4c1f45054a84404675be8d7330a59364f5192d73f7a0b",
  "proposals_hash": "0x643fc1e2b3595a556fa7a0c73c72325d93e2bcffc2584f1012be18ccaf2ce640",
  "timestamp": "0x18cf2af943c",
  "transactions_root": "0x3bb3bd4722029f0f9e7a537eacce9e5097f652290892397ab1f5cccd35dc8aba",
  "version": "0x0"
}

The --raw-data option allows for specifying epoch and timestamp fields as 0x-prefixed strings. close this.

doitian commented 5 months ago

Don't know there's a option --raw-data