tinychainorg / tinychain

The tiniest blockchain implementation in the world
https://www.tinycha.in/
MIT License
53 stars 3 forks source link

State sync implementation #12

Closed liamzebedee closed 1 month ago

liamzebedee commented 2 months ago

This contains the state sync engine.

State synchronisation has been a long time coming lol. It took some figuring out to do.

State sync incorporates BitTorrent-like downloads. Block headers and transactions are downloaded in parallel from multiple peers. There is a simple program that illustrates the algorithm in core/dumbtorrent. This was fun to figure out and should be illustrative to anyone who wants to understand it, although it's a proof-of-concept and not designed for standalone use.

The state sync PR does the following:

For this PR, sync is just downloading the block headers. Next PR will include the full blocks, and a simple way to query your balance and send some transactions. $TNY coming soon

Part of https://github.com/tinychainorg/tinychain/issues/10