Closed Kangmo closed 2 years ago
Update: Done upgrading Kotlin compiler to the latest one, 1.1.3.
Which POW algo? I'm interested a lot in this part
The first goal is to make it work with PoW used in Bitcoin.
Removed PBFT, now using PoW. Unit tests passed, need to run integration test.
TODO : 1) Need to implement/test initial block download 2) Need to process orphan blocks 3) Need to request parents of an orphan block to the peer who sent an orphan 4) Need to run tests with four nodes.
code commit: https://github.com/ScaleChain/scalechain/commit/b43c60d110e6be135cd591678e046683d30a79f4
Write integration test cases so that we can guarantee nodes run as expected.
Make sure all tests are passed
TBD
Dev design for the concurrency control for Block message handler, Tx message handler, SubmitBlock, acceptBlock, SendRawTransaction is done.
Conclusions: (1) Need to have a global mutex so that no transaction validation is done during the block reorg or attaching the new best block. (2) Need to run transaction validations on blocks in a forked chain when the forked chain becomes the best blockchain as two chains should have different UTXO databases, but we only keep the UTXO database of the best chain only.
For the details on the dependency on modules for the concurrency control, check data/docs/design/net-layer.mdj, which is a StarUML file.
When a block is received either by the Block message or by the SubmitBlock API, we need to run validation checks on the transactions in the block to see if there is any issue in any of transactions in the block. For example, if there is any double spending transaction, we need to reject the block.
But we maintain the UTXO database of the best blockchain, so we will skip the transaction validations for transactions in a block in a forked chain. We will run validation on such a chain when the chain becomes the best blockchain.
Accepting orphan blocks has two problems (1) An attacker may flood orphan blocks to fill in block chain database of peers. (2) When we receive an orphan block, we need to request parent blocks to the origin peer of the orphan block, but this makes our code quite complicated.
So, we will reject all orphan blocks(=blocks whose parents are not stored in the blockchain) but use IBD for downloading blocks from other peers if we are behind of other peers in terms of the best block height.
Currently, we are having code snippets in each of message handlers, but it makes hard to read codes as code snippets for a logic such as initial block download is scattered in multiple message handlers.
We will create a controller interface and then create a concrete class for each logic that sends and receives messages from/to peers.
For example, 'IBD; initial block download' logic sends and receives GetBlocks, Inv, GetData, Block. And also it needs to reject Tx messages or SendRawTransaction API when the IBD is in progress.
Benefits of having such controllers are as follows. (1) We can unit test the controller as well as we have a central file for a logic which has all code snippets so that we can easily understand the code. (2) We can make the message handler code as simple as possible even though we have additional controllers dealing with different kinds of logics on the net layer.
Closing this issue, distributing following work items into separate issues.
What
PBFT is the root of evil. Get rid of it!!
Why
FIs are using PBFT, we don't make this project for FIs anymore.
How
Just get rid of PBFT, and get PoW work.