-
-
Save moofone/67f2b2fc2dcf0c5596d0f55d8ee7d950 to your computer and use it in GitHub Desktop.
GET_BLOCK_TEMPLATE | |
{"bytes_limit":"0x91c08","cellbase":{"cycles":null,"data":{"cell_deps":[],"header_deps":[],"inputs":[{"previous_output":{"index":"0xffffffff","tx_hash":"0x0000000000000000000000000000000000000000000000000000000000000000"},"since":"0x51b5"}],"outputs":[{"capacity":"0x3dfc9dcd68","lock":{"args":"0xb2e61ff569acf041b3c2c17724e2379c581eeac3","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null}],"outputs_data":["0x"],"version":"0x0","witnesses":["0x590000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8011400000048b12c67274f56be27ccf4920402e16cd401c71c00000000"]},"hash":"0x47ad3afa5e8cb070929b92c9bbec5a76076bea8ce40494bef9a28233faf05691"},"compact_target":"0x1d722992","current_time":"0x16e67721478","cycles_limit":"0x2540be400","dao":"0x6180438021b5630054f3c3099883260012d1aa0131ef05000036d94c26860b00","epoch":"0x2eb012a00001f","number":"0x51b5","parent_hash":"0x097048451c099f846f2c4d19b79360cd9fe54b415496b454e008748bed493e8b","proposals":[],"raw":"0x000000009229721d8d0072676e010000b5510000000000001f00002a01eb0200097048451c099f846f2c4d19b79360cd9fe54b415496b454e008748bed493e8b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006180438021b5630054f3c3099883260012d1aa0131ef05000036d94c26860b00","transactions":[],"uncles":[],"uncles_count_limit":"0x2","version":"0x0","work_id":"0x1"} | |
POW | |
extraNonce2:0000000000000002a9df0189 | |
nonceBuf:000000010000000000000002a9df0189 | |
(not used currently.. tried this) nonceBigNum (LE,auto) base10:182113964086912058668270381438167154688 | |
(not used currently.. tried this) nonceBigNum (LE,auto) baase16:8901dfa9020000000000000001000000 | |
HSPACE:010000000000000000000000000000000000000000000000000000000000000000 | |
blockCompactDiff:494021010 | |
blockTgt:3077811784929926005267193015430431727813141032940143402072250542718976 | |
blockDiff: 37621562 | |
headerHash:26b720beb675ea36c1042993cdd51f40c5ff1479588e583eafd984119e26bc69 | |
headerHashWithNonce:26b720beb675ea36c1042993cdd51f40c5ff1479588e583eafd984119e26bc69000000010000000000000002a9df0189 | |
powHash(eaglesonog):000000009d2125a3f0dd2afa7c8d4fd08dec2f429bd00a99f472d44cbcdad873 | |
powBigNum:9d2125a3f0dd2afa7c8d4fd08dec2f429bd00a99f472d44cbcdad873 | |
shareDiff:6997487827 | |
RAW HEADER | |
000000009229721d8d0072676e010000b5510000000000001f00002a01eb0200097048451c099f846f2c4d19b79360cd9fe54b415496b454e008748bed493e8b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006180438021b5630054f3c3099883260012d1aa0131ef05000036d94c26860b00 | |
SUBMIT_BLOCK | |
arg[0]:0x1 | |
args[1]:{"header":{"compact_target":"0x1d722992","dao":"0x6180438021b5630054f3c3099883260012d1aa0131ef05000036d94c26860b00","epoch":"0x2eb012a00001f","nonce":"0x10000000000000002a9df0189","number":"0x51b5","parent_hash":"0x097048451c099f846f2c4d19b79360cd9fe54b415496b454e008748bed493e8b","proposals_hash":"0x0000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x16e6772008d","transactions_root":"0x0000000000000000000000000000000000000000000000000000000000000000","uncles_hash":"0x0000000000000000000000000000000000000000000000000000000000000000","version":"0x0"},"proposals":[],"transactions":[{"cell_deps":[],"header_deps":[],"inputs":[{"previous_output":{"index":"0xffffffff","tx_hash":"0x0000000000000000000000000000000000000000000000000000000000000000"},"since":"0x51b5"}],"outputs":[{"capacity":"0x3dfc9dcd68","lock":{"args":"0xb2e61ff569acf041b3c2c17724e2379c581eeac3","code_hash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hash_type":"type"},"type":null}],"outputs_data":["0x"],"version":"0x0","witnesses":["0x590000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8011400000048b12c67274f56be27ccf4920402e16cd401c71c00000000"]}],"uncles":[]} | |
ERROR [1573693559859] (21491 on ice-devlab): ckb submit_block error 0 when submitting block with submit_block {"code":-3,"message":"Header(Pow(InvalidNonce))"} |
Great analysis - thank you.
Let's start with an easy one: How much impact does timestamp have on this validation? you are correct in that where I get the raw header and get_block_template call are different sources. if this really matters, what is the source of truth for time?
It's OK to just use the one returned from block template. The miner also can use the latest time, but ensure use the same time in both raw header and the submit block request.
There's two rules related to timestamp:
- A block timestamp has to be larger than the median of the timestamp in the previous 37 blocks.
- CKB node will hold a block if the block timestamp is more than 15 seconds in the future.
The time returned by get_block_template
have already ensure the timestamp can pass the two rules.
Can you also tell me the proper source of transactions_root?
We define blake256 as blake2b with personal ckb-default-hash and output size 256 bits.
||
denotes bytes concatenation.
transactions_root = blake256( transaction hashes CBMT root || transaction witness hashes CBMT root)
- transaction hashes CBMT is the root of a CBMT which nodes are the hashes of all the transactions in the block, and the merge function is
blake256(left || right)
- transaction witness hashes CBMT root is also a CBMT, but the nodes are the witness hashes of all the transactions.
A transaction hash is blake256(serialized RawTransaction)
and transaction witness hash is blake256(serialized Transaction)
.
In your
submit_block
requests, there are three differencesI have mentioned the first two in raw header. The reason of the last one is the invalid format of nonce.