I would also like to finish off what I started with my
Anatomy of the Slimcoin genesis block: the tx parsing (the last section) doesn't work as expected (as the output indicates), which is where I ran out of understanding - in that my modelling of the anticipated output doesn't match the reality. I've been as persuasive as I can be but reality has proved quite obdurate and declines to change the output to match my model, so I'll just have to adjust my model to match the reality, sigh.
barrysty1e helped me adjust my model. The Anatomy of the Slimcoin Genesis Block is now complete (but not yet written up) and the Python script now successfully reads and interprets the genesis block data. It also, importantly, positions the "read head" at the start of the sequence of "magic bytes" that marks the start of the next block (block 1).
Block 1 isn't the same as block 0 (the genesis block) but it isn't all
that different, so I have been able to extend the anatomical model to include block 1 and any subsequent block that contains just one transaction. This condition holds up until block 522 which contains >1 transactions and which I'm working on atm ...
===================== Details of Block 521: ======================
magic: 6e8b92a5 (6e, 8b, 92, a5)
block_size: 356
version: 16777216
prevhash: 0000002ed6d345cb4b9b48667e73227b97bb5d93b8b348db957aafa09fc8f6db
merkle_root: 59b794adc98b4375b89fe123dfa13601f8a12158fabfebb703eb508393318e2d
timestamp: 1401357104 (2014-05-29T10:51:44)
nBits: 1d313deb
nonce: 671088975
fproofofburn: True
hashburnblock: 0000000000000000000000000000000000000000000000000000000000000000
burnhash: 0000000000000000000000000000000000000000000000000000000000000000
burnblockheight: -1
burnctx: -1
burnctxout: -1
neffectiveburncoins: 0
nburnbits: 0
number_of_transactions: 1
------------- Details of Transaction 0: -----------------
tx_version: 00000001
tx_ntime: 1401357087 (5387031f) 2014-05-29T10:51:27
tx_input_num: 1
tx_prev_output_hash: 0000000000000000000000000000000000000000000000000000000000000000
tx_prev_output_sequence: ffffffff
coinbase_tx_length: 15
coinbase_tx: 043003875302ff46062f503253482f
sequence: ffffffff
tx_output_num: 01
BTC_num: 16550000
pk_script_len: 35
pk_script: 2103fbfa443d3891689d7a58e2fb99a8ec142f1d228eac42f520bb17719bc63c4b11ac
lock_time: 1401357104 (00000000) 1970-01-01T01:00:00
coinbase_sig_length: 71
coinbase_tx: 30450221009e228ced771d9eac8b0ec8e0fb3ae297137582aed75e97c1dcd70918750ad31e02200 1da8e2b11da59d43a58d5414dcc7e8fc6838226dc78e5b57783d4ab816a3778
===================== Details of Block 522: ======================
magic: 6e8b92a5 (6e, 8b, 92, a5)
block_size: 1668
version: 16777216
prevhash: 000000094bf8a3d3ea0d9865e75a36fb41c48e2b20c3b0bdbb21c252f509448b
merkle_root: 754706aa21a2a1d4670e576a7fadff4de9281c059b363431f90da9fc78f607d4
timestamp: 1401357253 (2014-05-29T10:54:13)
nBits: 1d2da57c
nonce: 3221226870
fproofofburn: True
hashburnblock: 0000000000000000000000000000000000000000000000000000000000000000
burnhash: 0000000000000000000000000000000000000000000000000000000000000000
burnblockheight: -1
burnctx: -1
burnctxout: -1
neffectiveburncoins: 5796779233262960640
nburnbits: 0
number_of_transactions: 7
------------- Details of Transaction 0: -----------------
tx_version: 00000001
tx_ntime: 1401357231 (538703af) 2014-05-29T10:53:51
tx_input_num: 1
tx_prev_output_hash: 0000000000000000000000000000000000000000000000000000000000000000
tx_prev_output_sequence: ffffffff
coinbase_tx_length: 15
coinbase_tx: 04c5038753025f01062f503253482f
sequence: ffffffff
tx_output_num: 01
BTC_num: 16240000
pk_script_len: 35
pk_script: 2102afc065fa163072680264129f9cc27de71c95eefc1a2432a12d058c459d1d5cd5ac
lock_time: 1401357253 (00000000) 1970-01-01T01:00:00
coinbase_sig_length: 1
coinbase_tx: 00
------------- Details of Transaction 1: -----------------
tx_version: 031d0000
tx_ntime: 2332119943 (8b015387) 2043-11-26T03:05:43
tx_input_num: 124
tx_prev_output_hash: 00009f18572d7c68a866a487d93669856a060d64a08f689bf032fa66bcba442f
tx_prev_output_sequence: 48490000
coinbase_tx_length: 48
coinbase_tx: 4502200efdd68eb56c89d8d57edc3f79f5ad2e244308fa5204ca9d4919df9447b51d0e022100acb 58485ccd8d8a5d076
sequence: 5ed73fc3
tx_output_num: a7
BTC_num: 9814135143075891166
pk_script_len: 92
pk_script: a9248cbe695263d401ffffffff0270117202000000001976a914895d46e34a4b4df5d90b7af0e6f 2c03d14addff288ac40420f00000000001976a914c705b76b8164c13596716b8fd1159f8343d541 e688ac00000000010000006e03
lock_time: 1627476871 (61015387) 2021-07-28T13:54:31
coinbase_sig_length: 39
coinbase_tx: 53b107260969ebdfad8afa3f2d69d528e189fbc474a27769d5552bf26ee3000000004a49304602
------------- Details of Transaction 2: -----------------
tx_version: 33e40021
tx_ntime: 2691749403 (a070d61b) 2055-04-19T13:10:03
tx_input_num: 55
...
I truncated the output because at this point it's obviously run off the rails in terms of making sense of the input. I'm still working on it but I wanted to pass on what I'd found thus far.
I haven't yet been able to build a detailed model of the contents of the burn-related fields and the roles they play nor do I yet understand the roles played by the sequences. One thing does occur to me though: the file
blk0001.dat is
the result of one node transcribing to disk what it is retrieves from the network and, I am given to understand, it is only during the relatively short period immediately after syncing from the network that the file
blk0001.dat is free of orphans - up to the last confirmed block. Because,
all accepted blocks get written to
blk0001.dat, even if they subsequently become orphans as the result of a later re-org.
The <lastmintedblock> (current block height) can only have a null value for <nexthash> because it is the hash of <next block to be found> which doesn't exist - yet. When a new block
is found and accepted as the new <lastmintedblock>, the client must connect this new block to the end of the chain, i.e. write this latest block's hash into the empty <nexthash> of the previous block (the one that
used to be <lastmintedblock> with a null <nexthash>).
Two blocks are special in respect of connectivity, the genesis block has no <prevhash> and the <lastblockminted> has no <nexthash>. All other blocks have both a <prevhash> and a <nexthash>. However, just because it has both, doesn't mean it's actually part of the blockchain, it may be an orphan.
A re-org is "simply" a matter of changing the content of the last-known-to-be-good block's <nexthash> from the hash of
this (now-rejected block) to the hash of
that (now-known-to-be-good) block - which then becomes the new next link in the chain. In this way,
blk0001.dat fills up with orphaned blocks and the only way to detect whether they are orphans is to see if the block's <prevhash> matches the allegedly-previous block's <nexthash>. If they don't match, the block is an orphan.
Which is why the file
blk0001.dat is only orphan-less up until the last confirmed block of a just-synced-from-the-net blockchain. As soon as those conditions no longer pertain, expect
blk0001.dat to contain orphaned blocks.
Fun and games.
Cheers
Graham