MCPcopy Index your code
hub / github.com/circlefin/malachite

github.com/circlefin/malachite @v0.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.0 ↗ · + Follow
2,508 symbols 6,972 edges 336 files 432 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Malachite

Flexible BFT Consensus Engine in Rust State-of-the-art implementation of Tendermint


Build Status Quint tests MBT tests Code coverage

Apache 2.0 Licensed Rust Stable Rust 1.82+ [Quint 0.22]quint-repo

Telegram Chat

Documentation

About

Malachite is a Byzantine-fault tolerant (BFT) consensus engine implemented in Rust.

Malachite /ˈmæl.ə.kaɪt/ is pronounced as follows: "Mala" (like in Malaysia) + "kite" (like the flying toy).

[!IMPORTANT] Malachite is alpha software and under heavy development. The software is provided "as is" and has not been externally audited; use at your own risk.

Goals

The goal is for Malachite to enable developers to decentralize whatever the future may bring—sequencers, social networks, Layer 1s, etc. Therefore, Malachite addresses a particular void in the market: The lack of flexible, reliable, and high-performance distributed systems foundations, such as BFT consensus libraries.

Features

Tendermint as a Library

Bundled with Malachite comes a state-of-the-art implementation of the Tendermint BFT consensus algorithm. Tendermint is an optimistically responsive consensus algorithm, and therefore exhibits high-performance, and has found adoption in many decentralized systems through its implementation in Go as part of CometBFT.

Design

Key design decisions in Malachite are heavily inspired by lessons and experiences of maintaining CometBFT throughout the years. Malachite addresses numerous points of technical debt in the design of consensus engines, resulting in a lean, flexible, and reliable solution that performs at the highest level.

Reliability and Performance

Parts of Malachite were co-designed with their formal specification and model checking, notably for the Tendermint algorithm, which improved the confidence and reliability of this core library.

Early experiments with Malachite show an average finalization latency of 780 ms at a scale of 100 validators with 1MB blocks. Depending on the setup, Malachite can clear up to 2.5 blocks per second or finalize up to 13.5 MB/s (around 50,000 transactions per second).

We publish regular performance benchmarks on the dashboard.

Use-cases

Malachite originated as a consensus core for the Starknet L2 decentralized sequencer. It will serve as the core consensus library in the Madara and Pathfinder Starknet clients. Malachite is also being used for Farcaster’s newest backend layer called Snapchain. Thanks to its flexible design, Malachite is amenable to a broad range of environments, and a number of other teams are building and exploring in private. Please reach-out if interested, we would love to speak with more teams.

To follow-up with use-cases and more general announcements, see the blog.

Overview

Repository

The repository is split into three areas, each covering one of the important aspects of this project:

  1. code: Contains the Rust implementation of the Tendermint consensus algorithm, split across multiple Rust crates.
  2. docs: Contains Architectural Decision Records (ADRs) and other documentation, such as the 2018 paper describing the core consensus algorithm.
  3. specs: Contains English and Quint specifications.

Crates and Status

[!NOTE] The actual name of each crate is prefixed with informalsystems-malachitebft-. For instance, the crate denoted by core-consensus below can be found on crates.io as informalsystems-malachitebft-core-consensus.

Core consensus algorithm

Crate name Crate Docs
core-consensus core-consensus [![core-consensus Docs][core-consensus-docs-image]][core-consensus-docs-link]
core-driver [core-driver][core-driver-crate-link] [![core-driver Docs][core-driver-docs-image]][core-driver-docs-link]
core-state-machine [![core-state-machine][core-state-machine-crate-image]][core-state-machine-crate-link] [![core-state-machine Docs][core-state-machine-docs-image]][core-state-machine-docs-link]
core-types [![core-types][core-types-crate-image]][core-types-crate-link] [![core-types Docs][core-types-docs-image]][core-types-docs-link]
core-votekeeper [![core-votekeeper][core-votekeeper-crate-image]][core-votekeeper-crate-link] [![core-votekeeper Docs][core-votekeeper-docs-image]][core-votekeeper-docs-link]

Consensus engine

Crate name Crate Docs
app-channel [![app-channel][app-channel-crate-image]][app-channel-crate-link] [![app-channel Docs][app-channel-docs-image]][app-channel-docs-link]
app [![app][app-crate-image]][app-crate-link] [![app Docs][app-docs-image]][app-docs-link]
codec [![codec][codec-crate-image]][codec-crate-link] [![codec Docs][codec-docs-image]][codec-docs-link]
config [![config][config-crate-image]][config-crate-link] [![config Docs][config-docs-image]][config-docs-link]
discovery [![discovery][discovery-crate-image]][discovery-crate-link] [![discovery Docs][discovery-docs-image]][discovery-docs-link]
engine [![engine][engine-crate-image]][engine-crate-link] [![engine Docs][engine-docs-image]][engine-docs-link]
metrics [![metrics][metrics-crate-image]][metrics-crate-link] [![metrics Docs][metrics-docs-image]][metrics-docs-link]
network [![network][network-crate-image]][network-crate-link] [![network Docs][network-docs-image]][network-docs-link]
peer [![peer][peer-crate-image]][peer-crate-link] [![peer Docs][peer-docs-image]][peer-docs-link]
proto [![proto][proto-crate-image]][proto-crate-link] [![proto Docs][proto-docs-image]][proto-docs-link]
sync [![sync][sync-crate-image]][sync-crate-link] [![sync Docs][sync-docs-image]][sync-docs-link]
wal [![wal][wal-crate-image]][wal-crate-link] [![wal Docs][wal-docs-image]][wal-docs-link]

Building with Malachite

As a guiding point to understand how to use Malachite, please read ARCHITECTURE.md.

You can also check out the examples for a more in-depth experience.

Contributing

If you would like to contribute to the Malachite open-source codebase, please see CONTRIBUTING.md. We invite all contributors.

Requirements

Join Us

Malachite is developed by Informal Systems.

If you'd like to work full-time on challenging problems of distributed systems and decentralization, we're always looking for talented people to join!

Acknowledgements

Malachite would not have been possible without the kind support of the Starknet ecosystem. We are grateful to StarkWare Industries for prompting the initial discussions of building Tendermint in Rust, to Starknet Foundation for funding and fostering a collaborative environment, and to both of these organizations plus numerous others in the ecosystem for their constructive feedback on earlier designs of Malachite.

We are also thankful for the collaboration with Farcaster. This led to further refinements and maturing of the Malachite codebase, and their approach to building complex systems and shipping valuable products is an inspiration for us.

License

Copyright © 2024 Informal Systems Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use the files in this repository except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Extension points exported contracts — how you extend this code

Resumable (Interface)
Provides a way to construct the appropriate [`Resume`] value to resume execution after handling an [`Effect`]. Eeach `E [8 …
code/crates/core-consensus/src/effect.rs
Protobuf (Interface)
(no doc) [21 implementers]
code/crates/proto/src/lib.rs
Middleware (Interface)
(no doc) [7 implementers]
code/crates/test/src/middleware.rs
Extension (Interface)
Vote extensions allows applications to extend the pre-commit vote with arbitrary data. This allows applications to force [4 …
code/crates/core-types/src/vote_extension.rs
SigningProvider (Interface)
A provider of signing functionality for the consensus engine. This trait defines the core signing operations needed by [4 …
code/crates/core-types/src/signing.rs

Core symbols most depended-on inside this repo

map
called by 173
code/crates/core-types/src/value.rs
send
called by 132
code/crates/engine/src/util/events.rs
iter
called by 123
code/crates/wal/src/log.rs
as_ref
called by 81
code/crates/core-types/src/value.rs
push
called by 69
code/crates/core-consensus/src/util/bounded_queue.rs
start
called by 60
code/crates/starknet/host/src/node.rs
id
called by 50
code/crates/core-consensus/src/full_proposal.rs
insert
called by 44
code/crates/starknet/host/src/streaming.rs

Shape

Method 1,353
Function 644
Class 333
Enum 132
Interface 46

Languages

Rust99%
Python1%

Modules by API surface

code/crates/config/src/lib.rs47 symbols
code/crates/core-driver/src/driver.rs43 symbols
code/crates/engine/src/consensus.rs37 symbols
code/crates/core-driver/tests/it/utils.rs37 symbols
code/crates/sync/src/scoring.rs35 symbols
code/crates/starknet/host/src/node.rs31 symbols
code/crates/wal/src/log.rs30 symbols
code/crates/test/framework/src/node.rs30 symbols
code/crates/starknet/host/src/codec.rs29 symbols
code/crates/starknet/host/src/block_store.rs28 symbols
code/crates/core-consensus/src/util/bounded_queue.rs27 symbols
code/examples/channel/src/store.rs26 symbols

For agents

$ claude mcp add malachite \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact