Skip to content

Commit dfc6d17

Browse files
committed
chore: some progress
1 parent 12a2224 commit dfc6d17

File tree

33 files changed

+1783
-46
lines changed

33 files changed

+1783
-46
lines changed

Cargo.lock

Lines changed: 539 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
[workspace]
22
members = [
3+
"crates/bfte",
4+
"crates/bfte-node",
35
"crates/consensus",
46
"crates/consensus-core",
57
"crates/util-array-type",
8+
"crates/util-db",
9+
"crates/util-error",
610
]
711
resolver = "2"
812

@@ -11,8 +15,8 @@ name = "bfte"
1115
version = "0.1.0"
1216
edition = "2024"
1317

14-
authors = ["Your Name <[email protected]>"]
15-
description = "Rust project to test BFT consensus protocol properties"
18+
authors = ["Dawid Ciężarkiewicz <[email protected]>"]
19+
description = "BFTE is a federated consesus engine"
1620
license = "MIT"
1721
repository = "https://github.com/username/consensus-test"
1822

@@ -21,24 +25,38 @@ collapsible_if = "allow"
2125
collapsible_else_if = "allow"
2226

2327
[workspace.dependencies]
24-
bfte-util-array-type = { path = "./crates/util-array-type" }
25-
bfte-consensus = { path = "./crates/consensus" }
28+
bfte = { path = "./crates/bfte" }
2629
bfte-consensus-core = { path = "./crates/consensus-core" }
30+
bfte-consensus = { path = "./crates/consensus" }
31+
bfte-node = { path = "./crates/bfte-node" }
32+
bfte-util-array-type = { path = "./crates/util-array-type" }
33+
bfte-util-db = { path = "./crates/util-db" }
34+
bfte-util-error = { path = "./crates/util-error" }
2735

2836
anyhow = "1.0"
2937
assert_matches = "1.5.0"
3038
bincode = { version = "2.0.0", features = ["derive"] }
39+
bit-set = { version = "0.8" }
40+
bon = "3.6.1"
41+
blake3 = "1.8.2"
3142
bytes = "1.0"
43+
convi = { version = "0.1.1", features = ["min_target_pointer_width_32"] }
3244
data-encoding = "2.7"
33-
derive_more = { version = "2.0.1", features = ["from"] }
45+
derive_more = { version = "2.0.1", features = ["from", "deref", "deref_mut"] }
3446
ed25519-dalek = "2.1.1"
3547
futures = "0.3"
3648
log = "0.4"
3749
rand = "0.8"
50+
redb-bincode = "0.4.0"
51+
nutype = "0.6.1"
52+
num-bigint = "0.4.6"
3853
serde_bytes = "0.11.17"
3954
serde = { version = "1.0", features = ["derive"] }
55+
snafu = { version = "0.8.5", features = ["rust_1_81"] }
4056
tokio-test = "0.4.4"
4157
tokio = { version = "1.0", features = ["full"] }
58+
tracing = "0.1.41"
59+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
4260

4361

4462
[profile]
@@ -48,3 +66,6 @@ inherits = "dev"
4866
incremental = false
4967
debug = "line-tables-only"
5068
lto = "off"
69+
70+
[patch.crates-io]
71+
redb-bincode = { git = "https://github.com/rustshop/redb-bincode", rev = "e8f2d2783b2972f8e6b097bf1e18d90f1cf570b1" }

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# BTF Engine
2+
3+
BTFE is a BFT consensus solution.
4+
5+
A group of peers maintains a ledger.
6+
7+
### BFTE vs Fedimint
8+
9+
This project aims at the very similar very-long term goals as [fedimint][fedimint],
10+
but having benefit of years of extra experience, and allowing focus
11+
on parts and goals that the author (dpc) finds most promising and interesting.
12+
13+
[fedimint]: http://github.com/fedimint/fedimint
14+
15+
16+
Fedimint started as a Bitcoin Ecash Mint solution, with a side-goal/need
17+
of building a general purpose consensus engine. BFTE stars with
18+
a goal of being a good general purpose consensus engine most, with ability
19+
to support Bitcoin/cryptography applications like Ecash Mints "maybe one
20+
day".
21+
22+
Things like Bitcoin and Lightning Network support are a huge time sinks,
23+
largely still in development applications and ecosystems, with a huge
24+
expectations on stability and robustness, and other barriers to becoming
25+
widely deployed.
26+
27+
So, no dealing with 3 versions of LN nodes, each with it's own stupid
28+
problems.
29+
30+
BFTE can just let Fedimint chart these difficult waters, while only
31+
ensuring the general architecture can be eventually supported, while
32+
building less mission-critical things, like:
33+
34+
* CI system coordination,
35+
* review systems,
36+
* etc.
37+
38+
Similarly, Fedimint's ambition was reaching broad Bitcoin end user appeal.
39+
This requires a lot of effort: building end user clients including web and
40+
mobile apps. While years of working in Bitcoin space thought me: There is
41+
no market for self-custodial Bitcoin solutions. The UX is clunky, userbase
42+
interested in it small, and amount of money they are willing to pay small.
43+
44+
By ignoring all these ambitions, BFTE can focus first on honing the primary
45+
goal: becoming good general purpose modular consensus engine.
46+
47+
So (at least in near to medium term future):
48+
49+
No support for anything that isn't Linux. If you can't install Linux
50+
you don't deserve good stuff, and you probably don't value your freedom
51+
much anyway, so you have no use for censorship resistant software.
52+
Go pay someone for dealing with your stupid Windows or MacOS, Android, MacOS,
53+
and especially your stupid fucking XCode development ecosystem.
54+
55+
No WASM support. Fuck WASM, that shit is just yet another, even more difficult
56+
to run platform that is ultimately hostile to distribted, censorship
57+
resistant applications.
58+
59+
You'll get a Linux daemon that you can run on a server, or a desktop,
60+
with a built-in web interface, and you'll be happy.
61+
62+
Other than this "focus", BFTE tries to steal and borrow as much as it can
63+
from Fedimint.
64+
65+
### Design (Ideas):
66+
67+
In BFTE *everything* is part of the consensus.
68+
69+
A BFTE node stars either by becoming non-voting follower of existing
70+
consensus, or starts a fresh consensus with itself a single-peer consensus.
71+
72+
Adding and removing peers, changes to configuration like adding new modules,
73+
software upgrades, etc. are all implemented by consensus items agreed on
74+
and published on a shared ledger.
75+
76+
A simple consensus algorithm (Simplex) is used to perfectly match
77+
the needs of BFTE.
78+
79+
80+
Simplicity is achieved through interactions between very few well
81+
thought general purpose pritmivites:
82+
83+
* consensus
84+
* module
85+
86+
87+
88+
89+
No client APIs, all nodes follow consensus, even if they don't participate in it.
90+
Maintaining APIs, and client side state machines is just duplicating effort.
91+
The mutable part of the consensus state is typically small anyway and
92+
"clients" might maybe throw away the bulk data that they don't need anyway,
93+
as they not validate anything
94+
95+
DKGs can just happen as a part of consensus. Mint module should support
96+
multiple keysets , and generating new ones on demand.
97+
98+
Consensus items should be just module specific inputs/outputs, signed by the
99+
node itself. This allows creating transactions
100+
101+
Effect system as the only means of inter-module interactions. Modules can process
102+
effects published by other modules. Process input/output.
103+
104+
105+
106+
### License
107+
108+
MPLE is licensed under MIT.

crates/bfte-node/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "bfte-node"
3+
4+
description.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
7+
version.workspace = true
8+
9+
[dependencies]
10+
bfte-util-array-type = { workspace = true }
11+
bfte-consensus-core = { workspace = true }
12+
bincode = { workspace = true }
13+
blake3 = { workspace = true }
14+
convi = { workspace = true }
15+
data-encoding = { workspace = true }
16+
derive_more = { workspace = true }
17+
ed25519-dalek = { workspace = true }
18+
nutype = { workspace = true }
19+
serde_bytes = { workspace = true }
20+
serde = { workspace = true, features = ["derive"] }

crates/bfte-node/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct Node {}

crates/bfte/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "bfte"
3+
4+
description.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
7+
version.workspace = true
8+
9+
[dependencies]
10+
bon = { workspace = true }
11+
bfte-util-array-type = { workspace = true }
12+
bfte-consensus-core = { workspace = true }
13+
bincode = { workspace = true }
14+
blake3 = { workspace = true }
15+
convi = { workspace = true }
16+
data-encoding = { workspace = true }
17+
derive_more = { workspace = true }
18+
ed25519-dalek = { workspace = true }
19+
nutype = { workspace = true }
20+
serde_bytes = { workspace = true }
21+
serde = { workspace = true, features = ["derive"] }
22+
23+
[dev-dependencies]
24+
tokio-test = { workspace = true }

crates/bfte/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub struct Bfte {}
2+
3+
#[bon::bon]
4+
impl Bfte {
5+
#[builder(finish_fn = run)]
6+
pub fn build() {}
7+
}

crates/bfte/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use bfte::Bfte;
2+
3+
fn main() {
4+
Bfte::build().run();
5+
}

crates/consensus-core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ version.workspace = true
77
[dependencies]
88
bfte-util-array-type = { workspace = true }
99
bincode = { workspace = true }
10+
blake3 = { workspace = true }
11+
convi = { workspace = true }
1012
data-encoding = { workspace = true }
1113
derive_more = { workspace = true }
1214
ed25519-dalek = { workspace = true }
15+
num-bigint = { workspace = true }
1316
serde_bytes = { workspace = true }
1417
serde = { workspace = true, features = ["derive"] }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use bincode::config;
2+
3+
pub const STANDARD_LIMIT_16M: usize = 0x1_0000_0000;
4+
pub const STD_BINCODE_CONFIG: config::Configuration<
5+
config::BigEndian,
6+
config::Varint,
7+
config::Limit<STANDARD_LIMIT_16M>,
8+
> = config::standard()
9+
.with_limit::<STANDARD_LIMIT_16M>()
10+
.with_big_endian()
11+
.with_variable_int_encoding();

0 commit comments

Comments
 (0)