Skip to content

Implementation of "Virtual Blockchain" (for faster boot up)  #90

@muneeb-ali

Description

@muneeb-ali

I've been thinking about speeding up initial indexing / boot up of blockstore (see Issue #69 #82 etc).

The main problem seems to be that:

a) We need txindex=1 for bitcoind which is something that most normal users don't do and significantly increases the system requirements for running a bitcoind node

b) Assuming you're not running your own bitcoind and are connecting to a remote bitcoind (like the one at btcd.onename.com) the sheer amount of remote RPC calls (for getting blocks and all transactions in blocks) will slow this down

We've discussed the concept of a "Virtual Blockchain" in our docs, but in the current implementation we don't really explicitly store anything resembling a virtual blockchain. I propose a solution where:

-- Each blockstored node stores the virtual blockchain (block number + transaction IDs which are relevant to blockstore). Let's assume that bitcoin_block 343883 is virtual_block 1 and any transactions in bicoin_block 343883 that has a valid OP_RETURN for blockstore can stored in virtual_block 1 (we only need to store the transaction ID). Let's say that in bitcoin_block 343889 there was another valid blockstore transaction, now bitcoind_block 343889 is stored as virtual_block 2 and so on.

-- Every LIVE blockstored node has the latest copy of virtual_blocks (just like every bitcoind node has a list/copy of bitcoin blocks).

-- When a new blockstored node boots up, it connects to peer blockstored nodes (through a discovery process) and fetches the "virtual blockchain". After getting the virtual blockchain (from multiple sources) the new node then talks to a bitcoind node to get the actual blocks and transactions. The virtual blockchain effectively acts as a filter for "only get these blocks and transactions, forget about processing all the other blocks/transactions".

-- The new blockstored node, calculates the namespace and the hash of the Merkle tree root independently after processing the blocks/transactions and checks if their view of the namespace is consistent with others (similar to how we're detecting if you're on a fork or not).

-- This significantly reduces the no. of blocks/transactions that new nodes will need to process to catch up to the rest of the network while maintaining the security properties.

-- Once a blockstore node has synced up with the rest of the network, it only needs to look at the new incoming bitcoin blocks and can update it's own virtual blockchain without any assistance from other peer blockstored nodes.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions