nervosnetwork / ckb

The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.
https://www.nervos.org
MIT License
1.14k stars 224 forks source link

proposal tx out of block, query tx but `pending` #4510

Closed EthanYuan closed 1 week ago

EthanYuan commented 1 week ago

Bug Report

dev chain with IntegrationTest module

Current Behavior

submit tx with cli

CKB> wallet transfer --capacity 100 --to-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqw6vjzy9kahx3lyvlgap8dp8ewd8g80pcgcexzrj  --privkey-path ./key
0x842973098828ced54bc89bcec83c96b61be6c03e71df9bfef86850277d9555ac

generate block with generate_block rpc

ethan@T14s-Gen4:~$ echo '{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "generate_block",
  "params": []
}' | tr -d '\n' | curl -H 'content-type: application/json' -d @- http://localhost:8114
{"jsonrpc":"2.0","result":"0x47394aa8ed2f92fa4a9f59ed4ef985b55d124de25d178caa71fe07471b526f3b","id":42}

call get_block -> "proposals":["0x842973098828ced54bc8"]

ethan@T14s-Gen4:~$ echo '{  curl -X POST -H "Content-Type: application/json" --data
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_block",
    "params": [
            "0x47394aa8ed2f92fa4a9f59ed4ef985b55d124de25d178caa71fe07471b526f3b"
    ]
}' http://localhost:8114
{"jsonrpc":"2.0","result":{"extension":"0xe2ddd6d3facf80098bb467d326e051728c1d63353319b752bf764e629ef2519e","header":{"compact_target":"0x20010000","dao":"0xd05f67469030e62e885f9d0fa9932300e552b3742d3e0e000029597e3bfffe06","epoch":"0xa000700004c","extra_hash":"0xf563ee427dc15c21e37e65591094ce26458c3faee415c3dc596a6d77c9e98da7","hash":"0x47394aa8ed2f92fa4a9f59ed4ef985b55d124de25d178caa71fe07471b526f3b","nonce":"0x0","number":"0x2ff","parent_hash":"0x90f21bb051a8dad620544dbf09cab646aa2a5b6e7486832e28854ad20883a9c8","proposals_hash":"0x6414858f439f4b4ff6c6a2ed8293175291e44f90d51c5f937abd9b1dbcbe365e","timestamp":"0x19090841511","transactions_root":"0x443582ae5aefd1d553c5d7015daaa5ace2a35941513b0fb34bfe62718dc86ce2","version":"0x0"},"proposals":["0x842973098828ced54bc8"],"transactions":[{"cell_deps":[],"hash":"0xd4ce72e6a4ee9092673a32491de3546ed8267ac3120aaae7cdcbe6b0f88ec908","header_deps":[],"inputs":[{"previous_output":{"index":"0xffffffff","tx_hash":"0x0000000000000000000000000000000000000000000000000000000000000000"},"since":"0x2ff"}],"outputs":[{"capacity":"0x12466a0659a2","lock":{"args":"0x470dcdc5e44064909650113a274b3b36aecb6dc7","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null}],"outputs_data":["0x"],"version":"0x0","witnesses":["0x7a0000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce80114000000470dcdc5e44064909650113a274b3b36aecb6dc7210000000000000020302e3131362e3120286232653336653720323032342d30352d313129"]}],"uncles":[]},"id":2}

get_transaction -> pending

ethan@T14s-Gen4:~$ echo '{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_transaction",
  "params": ["0x842973098828ced54bc89bcec83c96b61be6c03e71df9bfef86850277d9555ac"]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- http://localhost:8114
{"jsonrpc":"2.0","result":{"cycles":"0x1927a8","fee":"0x1d0","min_replace_fee":"0x488","time_added_to_pool":"0x19090841446","transaction":{"cell_deps":[{"dep_type":"dep_group","out_point":{"index":"0x0","tx_hash":"0xabe0d532881c91840165390469e469b33e685ed3d504830f8f7bdffb8f85970a"}}],"hash":"0x842973098828ced54bc89bcec83c96b61be6c03e71df9bfef86850277d9555ac","header_deps":[],"inputs":[{"previous_output":{"index":"0x0","tx_hash":"0xe5468a9e04b9b9409266d140fd425361e2876c1fa51204f7c1491f6ccc8c849f"},"since":"0x0"}],"outputs":[{"capacity":"0x2540be400","lock":{"args":"0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null},{"capacity":"0x124549d4fa26","lock":{"args":"0x470dcdc5e44064909650113a274b3b36aecb6dc7","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null}],"outputs_data":["0x","0x"],"version":"0x0","witnesses":["0x5500000010000000550000005500000041000000cd170886066a28637f1d6f566b3daec71f842870dc8c79588ee58c36c9ca42d041fb6b94ee6e8684e8160997f641b00ae781242be4f632133984404f09da401301"]},"tx_status":{"block_hash":null,"block_number":null,"reason":null,"status":"pending"}},"id":42}

call generate_block again can get proposed

Expected Behavior

Expected Behavior: after tx proposed block was generated, get_transaction status is proposed.

get_transaction -> proposed

ethan@T14s-Gen4:~$ echo '{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_transaction",
  "params": ["0x842973098828ced54bc89bcec83c96b61be6c03e71df9bfef86850277d9555ac"]
}' | tr -d '\n' | curl -H 'content-type: application/json' -d @- http://localhost:8114
{"jsonrpc":"2.0","result":{"cycles":"0x1927a8","fee":"0x1d0","min_replace_fee":null,"time_added_to_pool":"0x19090841446","transaction":{"cell_deps":[{"dep_type":"dep_group","out_point":{"index":"0x0","tx_hash":"0xabe0d532881c91840165390469e469b33e685ed3d504830f8f7bdffb8f85970a"}}],"hash":"0x842973098828ced54bc89bcec83c96b61be6c03e71df9bfef86850277d9555ac","header_deps":[],"inputs":[{"previous_output":{"index":"0x0","tx_hash":"0xe5468a9e04b9b9409266d140fd425361e2876c1fa51204f7c1491f6ccc8c849f"},"since":"0x0"}],"outputs":[{"capacity":"0x2540be400","lock":{"args":"0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null},{"capacity":"0x124549d4fa26","lock":{"args":"0x470dcdc5e44064909650113a274b3b36aecb6dc7","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null}],"outputs_data":["0x","0x"],"version":"0x0","witnesses":["0x5500000010000000550000005500000041000000cd170886066a28637f1d6f566b3daec71f842870dc8c79588ee58c36c9ca42d041fb6b94ee6e8684e8160997f641b00ae781242be4f632133984404f09da401301"]},"tx_status":{"block_hash":null,"block_number":null,"reason":null,"status":"proposed"}},"id":42}

Environment

Additional context/Screenshots

quake commented 1 week ago

CKB requires to propose the transaction short id before committing it into the chain, and there is a window of blocks that the transaction can be committed. Only in this window, the transaction status will be shown as proposed, otherwise, it will be shown as pending. The window of mainnet is 2 ~ 10, so it's an expected behavior that the transaction status is pending for +1 block after proposing it, and it will be shown as pending again after +10 blocks.

EthanYuan commented 1 week ago

CKB requires to propose the transaction short id before committing it into the chain, and there is a window of blocks that the transaction can be committed. Only in this window, the transaction status will be shown as proposed, otherwise, it will be shown as pending. The window of mainnet is 2 ~ 10, so it's an expected behavior that the transaction status is pending for +1 block after proposing it, and it will be shown as pending again after +10 blocks.

Thx. Understood.