<<  >> (p.17)
    Author Topic: Spin-offs: bootstrap an altcoin with a btc-blockchain-based initial distribution  (Read 53673 times)
    Peter R (OP)
    Legendary
    *
    Offline Offline

    Activity: 1162
    Merit: 1014



    View Profile
    June 09, 2014, 06:10:33 PM
    Last edit: June 09, 2014, 10:01:24 PM by Peter R
     #321

    Refining the format of snapshot.bin

    DeathAndTaxes showed that over 99.9% of unspent outputs (by count) remain claimable if the snapshot.bin file is a uniform list of {{hash1, balance1}…{hashN, balanceN}}.  This file format works for Simplified Claim Verification (SCV) and Full Claim Verification (FCV).  

    I updated the file format proposal for snapshot.bin below.  I know D&T discussed further compression, but I'd propose that this be done as part of the client installation procedure or during snapshot.bin transport, rather than further compressing snapshot.bin itself.  For this reason, I typically used 64-bit fields even when smaller data types would be work.  

    I continued to break snapshot.bin into Sections based on output type.  This isn't strictly necessary as pubKeys and redeemScripts are all hashed to a consistent bit length, but I thought it might still be useful.  

    Code:
    // File header:
    version (1 byte)  blockheight_of_snapshot (8 bytes) blockheight_when_live (8 bytes)  num_bytes_H (8 bytes)  header data  / total of num_bytes_H of header data

    // File body:

    // Section A: Wealth data for pay2PubKeyHash (sorted by hash):
    tagA=0x4E (1 byte)  num_bytes_A (8 bytes)  pubkeyhash_1 (20 bytes)  balance_1 (8 bytes)  …  pubkeyhash_N (20 bytes)  balance_N (8 bytes)  // total of num_bytes_A of records here

    // Section B: Wealth data for pay2PubKey (sorted by hash):
    tagB=0xB2 (1 byte)  num_bytes_B (8 bytes)  hash_of_pubkey_1 (20 bytes)  balance_1 (8 bytes)  …  hash_of_pubkey_N (20 bytes)  balance_N (8 bytes)  // total of num_bytes_B of records here

    // Section C: Wealth data for native multisig (sorted by hash):
    tagC=0xA7 (1 byte)  num_bytes_C (8 bytes)  hash_of_pubkeysInCanonicalOrder_1 (20 bytes) balance_1 (8 bytes)  …  hash_of_pubkeysInCanonicalOrder_N (20 bytes)  balance_N (8 bytes)  // total of num_bytes_C of records here

    // Section D: Wealth data for pay2ScriptHash (sorted by hash):
    tagD=0x24 (1 byte)  num_bytes_D (8 bytes)  hash_of_redeemScript_1 (20 bytes)  balance_1 (8 bytes)  …  hash_of_redeemScript_N (20 bytes)  balance_N (8 bytes)  // total of num_bytes_D of records here

    // Section E: Wealth data for other types of outputs:
    tagE=0xB4 (1 byte)  num_bytes_E (8 bytes)  should we record the unspent outputs that don't fit into Sections A - D verbatim here, just in case?


    The file header for snapshot.bin needs to contain the blockheader of the snapshot block in order for SCV to work.  I also propose that it contains every blockheader between the snapshot and the agreed-upon block where the coin "goes live."  This acts as a time stamp that proves to the world that the developers couldn't have possibly begun mining earlier than the date when, e.g., Block 314,000 was found.

    Code:
    // File header:
    version (1 byte)  blockheight_snapshot (8 bytes)   blockheight_whenLive (8 bytes)  num_bytes_H (8 bytes)  header data  / total of num_bytes_H of header data

    // Header data:
    Blockheader_for_snapshotBlock (80 bytes)  Blockheader_for_snapshotBlock+1 (80 bytes) … Blockheader_for_whenLiveBlock-1 (80 bytes)   Blockheader_for_whenLiveBlock (80 bytes)

    Run Bitcoin Unlimited (www.bitcoinunlimited.info)
Page 16
Viewing Page: 17