79 lines
3.4 KiB
Markdown
79 lines
3.4 KiB
Markdown
# Side BFT-CRDT PoC
|
|
|
|
This is a proof of concept implementation of a BFT-CRDT blockchain system.
|
|
|
|
## Running in development
|
|
|
|
Run the watcher first:
|
|
|
|
```bash
|
|
cd side-watcher
|
|
cargo watch -x run
|
|
```
|
|
|
|
To init a Side node:
|
|
|
|
```bash
|
|
cd side-node
|
|
cargo run -- init node1
|
|
cargo run -- init node2
|
|
cargo run -- init node3
|
|
cargo run -- init node4
|
|
```
|
|
|
|
To start a node with a cargo watch for development purposes (from the side-node dir), open up a few terminals and run:
|
|
|
|
```bash
|
|
cargo watch -x "run -- run -- node1"
|
|
cargo watch -x "run -- run -- node2"
|
|
cargo watch -x "run -- run -- node3"
|
|
cargo watch -x "run -- run -- node4"
|
|
```
|
|
|
|
## Discussion
|
|
|
|
What we have here is a very simple system comprised of two key parts: the Side Node, and the Side Watcher.
|
|
|
|
### Side Node(s)
|
|
|
|
The Side Nodes make up a system of BFT-CRDT-producing nodes that can make a blockchain. Currently they can reliably send transactions to each other in a secure way, such that all nodes they communicate with can tell whether received transactions are obeying the rules of the system.
|
|
|
|
Next dev tasks:
|
|
|
|
- [ ] enable Side Nodes to download current P2P chain state so that they start - out with a consistent copy of transaction data
|
|
- [ ] remove the proc macro code from bft-json-crdt
|
|
- [ ] add smart contract execution engine (CosmWasm would be a good first choice)
|
|
- [ ] enable Side Nodes to download contract code for a given contract
|
|
- [ ] enable Side Nodes to download current contract state for a given contract
|
|
- [ ] switch to full P2P messaging instead of websockets
|
|
- [ ] take the Side Watcher out of the system by electing a Side Node as a leader, so that agreement about transaction inclusion can be reached for a given block.
|
|
|
|
### Side Watcher
|
|
|
|
The Side Watcher is a simple relayer node that sits between the Side Chain (Cosmos) and the decentralized Side Nodes. At the moment, it simply relays transactions between nodes via a websocket. We aim to eliminate this component from the architecture, but for the moment it simplifies networking and consensus agreement while we experiment with higher-value concepts.
|
|
|
|
To fulfill the promises in the Lite Paper, the Side Watcher needs to:
|
|
|
|
- [ ] make a block for the BFT-CRDT chain when the Side Chain creates a block
|
|
- [ ] submit BFT-CRDT chain data to the Side Chain
|
|
|
|
Later, we will aim to remove the Side Watcher from the architecture, by (a) moving to pure P2P transactions between Side Nodes, and (b) doing leader election of a Side Node to reach agreement on the submitted block.
|
|
|
|
## Bitcoin integration
|
|
|
|
There is a Bitcoin client integrated into the node, which can do simple coin transfers using esplora and the Mutinynet server's Signet (30 second blocktime).
|
|
|
|
The client's demo driver can be run by doing:
|
|
|
|
```
|
|
cargo run -- init dave
|
|
cargo run -- init sammy
|
|
cargo run -- btc
|
|
```
|
|
|
|
You'll need to have funded the "dave" address prior to running the `btc` command - otherwise the transfer will fail gracefully.
|
|
|
|
I was using this primarily as a way to experiment with constructing and broadcasting Bitcoin transactions, with the hope that it would be possible to move on to more advanced constructions (e.g. state channels). However, now that I look at all the options, it seems that multi-party state channels in Bitcoin are (probably) impossible to construct.
|
|
|
|
There is a second, unused Bitcoin client in place which uses Blockstream's Electrum server, but this didn't seem to be working properly with respect to Signet Bitcoin network during my testing, so I went with the esplora / Mutiny version instead.
|