Skip to content

My dissertation project code, which is a port of Bitcoin Core to a PoW-PoS hybrid called proof of activity (PoA).

License

Notifications You must be signed in to change notification settings

Harleyoc1/bitcoin-pos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitcoin Core PoS port

This project contains the code written for my dissertation, in which I aimed to create a Proof of Stake (PoS) port of Bitcoin. This was based on Bitcoin Core, and the implementation used a hybrid mechanism which enhanced Bitcoin's Proof of Work (PoW) with PoS elements. This mechanism is called Proof of Activity (PoA), proposed in a paper by Iddo Bentov et al.

The high-level outline of how this works is as follows:

  • Miners construct an empty (base) block, find a valid PoW, and propagate this out to peers who have announced themselves as validators
  • Validators check the base block hash for valid PoW, and use it to derive $N$ pseudorandom values between 0 and the total supply in the network (in Satoshis*)
  • Validators use a 'follow-the-satoshi' (FTS) algorithm to derive the coin output and hence the validator who controls this Satoshi, who is selected as a validator for this block
  • Validators, upon deriving themselves for a base block, sign this block and propagate their
    signature out to other validators
  • When the Nth validator for a block derives themselves, they create a full block from this base one, filling it with transactions from the mempool (pool of transactions not yet in a block), signing it, and then attempting to submit it to the active chainstate
  • As in the current Bitcoin implementation, nodes build upon the chain with the most chainwork and use this to achieve consensus

*Satoshis are the lowest possible denomination of Bitcoins. 1 Bitcoin is made up of 100,000,000 Satoshis.

Building

This project uses a Docker setup to compile Linux binaries for the program, and Docker compose is used to combine these into an on-device testnet with a few nodes. This provides a simulation for the network. For help installing Docker see this webpage. To compile it, first we build the Docker image using:

cd <project-dir>
docker build -t bitcoin-core .

Testing

Then, there are three simple sh scripts to provide easy management of the testnet:

./start-dockertestnet.sh
./stop-dockertestnet.sh
./reset-dockertestnet.sh

There are also a number of scripts provided which were used for automated testing and data collection.

By default, testnet files will be mounted locally to ./dockertestnet, in which the debug log can be viewed at node<i>/dockertestnet/debug.log. This can be analysed to view blocks being viewed to the network, but an easier way to analyse it is provided through bitcoin-cli. This is a program Bitcoin provides to interact with the running node via command line arguments, returning Json-formatted responses. I provide a request script that sends a bitcoin-cli command to the given $i$-th node, for example if we want to get mining info:

./request-dockertestnet.sh <i> getblockchaininfo

Which will return blockchain data for the active node. This can be used to inspect the blockchain, ensuring nodes are updated correctly, as well as doing things such as creating and submitting transactions.

If left alone the nodes should simply keep running the network, updating the chainstate indefinitely with blocks only containing coinbase transactions and maintaining consensus.

About

My dissertation project code, which is a port of Bitcoin Core to a PoW-PoS hybrid called proof of activity (PoA).

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published