Renamed binaries to make things a bit more general

This commit is contained in:
Dave Hrycyszyn
2024-10-19 16:50:45 +01:00
parent 4cf3d03349
commit e821ed2a57
30 changed files with 91 additions and 69 deletions

5
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

17
.idea/side-crdt.iml generated Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/crates/bft-json-crdt/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/crates/bft-json-crdt/bft-crdt-derive/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crates/bft-json-crdt/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crates/bft-json-crdt/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/crdt-node/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crdt-node/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/crdt-relayer/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

82
Cargo.lock generated
View File

@@ -951,6 +951,47 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crdt-node"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"bdk",
"bdk_esplora",
"bdk_sqlite",
"bdk_wallet",
"bft-crdt-derive",
"bft-json-crdt",
"bitcoin 0.32.2",
"clap 4.5.7",
"dirs",
"electrum-client 0.20.0",
"ezsockets",
"fastcrypto",
"indexmap 2.2.6",
"reqwest",
"serde",
"serde_json",
"sha256",
"tokio",
"toml",
"tracing",
"uuid",
]
[[package]]
name = "crdt-relayer"
version = "0.1.0"
dependencies = [
"async-trait",
"ezsockets",
"sha256",
"tokio",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "criterion"
version = "0.4.0"
@@ -3333,47 +3374,6 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "side-node"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"bdk",
"bdk_esplora",
"bdk_sqlite",
"bdk_wallet",
"bft-crdt-derive",
"bft-json-crdt",
"bitcoin 0.32.2",
"clap 4.5.7",
"dirs",
"electrum-client 0.20.0",
"ezsockets",
"fastcrypto",
"indexmap 2.2.6",
"reqwest",
"serde",
"serde_json",
"sha256",
"tokio",
"toml",
"tracing",
"uuid",
]
[[package]]
name = "side-watcher"
version = "0.1.0"
dependencies = [
"async-trait",
"ezsockets",
"sha256",
"tokio",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"

View File

@@ -1,4 +1,4 @@
[workspace]
members = ["side-node", "side-watcher"]
members = ["crdt-node", "crdt-relayer"]
resolver = "2"

View File

@@ -11,21 +11,21 @@ Install a recent version of Rust.
Run the watcher first:
```bash
cd side-watcher
cd crdt-relayer
cargo watch -x run
```
To init a Side node:
```bash
cd side-node
cd crdt-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:
To start a node with a cargo watch for development purposes (from the `crdt-node` dir), open up a few terminals and run:
```bash
cargo watch -x "run -- run -- node1"
@@ -34,41 +34,41 @@ cargo watch -x "run -- run -- node3"
cargo watch -x "run -- run -- node4"
```
You can then type directly into each of the Side Node consoles. Messages will be relayed to each Side Node, and the transaction history will end up being the same on all nodes.
You can then type directly into each of the Crdt Node consoles. Messages will be relayed to each Crdt Node, and the transaction history will end up being the same on all nodes.
## Discussion
What we have here is a very simple system comprised of two key parts: the Side Node, and the Side Watcher.
What we have here is a very simple system comprised of two key parts: the Crdt Node, and the Crdt Relayer.
### 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.
The Crdt Nodes make up a system of BFT-CRDT-producing nodes that can make a sort of wildly insecure 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.
The Side Node does not download any chain state, and if one goes off-line it will miss transactions. This is expected at the moment and fairly easy to fix, with a bit of work.
The Crdt Node does not download any chain state, and if one goes off-line it will miss transactions. This is expected at the moment and fairly easy to fix, with a bit of work.
Next dev tasks:
- [ ] we don't need a Watcher, the first node can act as a leader until people decide they don't want to trust it any more
- [ ] we don't need a relayer, the first crdt node can act as a leader until people decide they don't want to trust it any more
- [ ] the leader node can have a timer in it for block creation
- [ ] code up the ability to switch leaders (can be a human decision at first, later an (optional) automated choice)
- [ ] pick a commit and reveal scheme to remove MEV. One thing to investigate is [single-use seals](https://docs.rgb.info/distributed-computing-concepts/single-use-seals)
- [ ] enable Side Nodes to download current P2P chain state so that they start - out with a consistent copy of transaction data, and also do catch-up after going off-line
- [ ] remove the proc macro code from bft-json-crdt
- [ ] enable Crdt Nodes should download current P2P chain/dag state so that they start - out with a consistent copy of transaction data, and also do catch-up after going off-line
- [ ] remove the proc macro code from bft-json-crdt, it's not really needed in this implementation
- [ ] 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
- [ ] enable Crdt Nodes to download contract code for a given contract
- [ ] enable Crdt Nodes to download current contract state for a given contract
- [ ] switch to full P2P messaging instead of websockets
### Side Watcher
### Crdt Relayer
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.
The Crdt Relayer is a simple relayer node that sits between a Cosmos chain and the decentralized Crdt 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:
In future, the Crdt Relayer 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
- [ ] make a block for the BFT-CRDT chain when the Cosmos chain creates a block
- [ ] submit BFT-CRDT chain data to the Cosmos 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.
Later, we will aim to remove the Crdt Relayer from the architecture, by (a) moving to pure P2P transactions between Crdt Nodes, and (b) doing leader election of a Crdt Node to reach agreement on the submitted block.
## Bitcoin integration
@@ -92,10 +92,10 @@ There is a second, unused Bitcoin client in place which uses Blockstream's Elect
### DKG
It strikes me that there are many, many systems which rely on a trusted setup, and which might be able to use Distributed Key Generation (DKG) instead. SNARK systems for instance all have this problem.
It strikes me that there are many, many systems which rely on a trusted setup, and which might be able to use Distributed Key Generation (DKG) instead. SNARK systems for instance all have this problem. Could BFT-CRDTs help here?
It is not necessarily the case that e.g. signer participants and validators are the same entities. Being able to quickly spin up a blockchain and use it to sign (potentially temporary or ephemeral) keyshare data might be pretty useful.
### Cross chain transfers
The ability to be part of multiple consensus groups at once might provide new opportunities for cross-chain transfers.
Might the ability to be part of multiple consensus groups at once provide new opportunities for cross-chain transfers?

View File

@@ -1,5 +1,5 @@
[package]
name = "side-node"
name = "crdt-node"
version = "0.1.0"
edition = "2021"

5
crdt-node/src/main.rs Normal file
View File

@@ -0,0 +1,5 @@
use crdt_node;
fn main() {
crdt_node::run();
}

View File

@@ -1,5 +1,5 @@
[package]
name = "side-watcher"
name = "crdt-relayer"
version = "0.1.0"
edition = "2021"

View File

@@ -1,5 +0,0 @@
use side_node;
fn main() {
side_node::run();
}