Skip to content

Commit

Permalink
chore: fork tmsqlite from gordian core
Browse files Browse the repository at this point in the history
While the repository was private, using tmsqlite as a nested module was
much simpler than dealing with separate private Go modules.

Also add a better README.
  • Loading branch information
mark-rushakoff committed Oct 25, 2024
1 parent eb84680 commit 72fc096
Show file tree
Hide file tree
Showing 316 changed files with 68 additions and 54,763 deletions.
83 changes: 15 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,25 @@
# Gordian
# tmsqlite

Gordian is a modular, [Byzantine-fault-tolerant](https://en.wikipedia.org/wiki/Byzantine_fault) consensus engine.
tmsqlite provides an [SQLite](https://www.sqlite.org/)-backed storage layer
for [Gordian](https://github.com/gordian-engine/gordian)'s
[tmstore](https://pkg.go.dev/github.com/gordian-engine/gordian/tm/tmstore) package.

A consensus engine is a [replicated state machine](https://en.wikipedia.org/wiki/State_machine_replication) --
a participant in a distributed system where the participants agree on initial state, actions to apply, and resulting state.
This module defaults to using [github.com/mattn/go-sqlite3/](https://github.com/mattn/go-sqlite3/)
for a [CGo](https://pkg.go.dev/cmd/cgo)-backed SQLite driver.
If CGo is unavailable, it falls back to the [modernc.org/sqlite](https://pkg.go.dev/modernc.org/sqlite) driver,
which is a pure Go implementation of SQLite.

Gordian allows each participant to have a different voting power.
This effectively enables Gordian to be the consensus layer in a [proof of stake](https://en.wikipedia.org/wiki/Proof_of_stake) system.
If CGo is available and you still prefer to run the pure Go driver,
use the `purego` build tag, e.g. `go test -tags=purego ./...`.

Because Gordian uses an implementation of [the Tendermint® consensus algorithm](https://arxiv.org/abs/1807.04938)[^1],
systems backed by Gordian can tolerate failure or malicious behavior from participants constituting
up to, but less than, 1/3 of the total voting power.
## Project status

## Who should use Gordian?

Gordian was primarily written to support blockchain use cases,
but it should fit in any distributed system requiring peers to agree on state.

## How do I use Gordian?

Gordian is a modular system written in [Go](https://go.dev/).

The Gordian core Engine is designed to accept messages from the network
and replay a filtered set of those messages to a state machine.
The state machine consults a user-provided "driver" to track state changes
and determine what data to propose to other network participants.

The core Gordian repository (the one you are looking at now) does **not** provide a Driver.
See [https://github.com/gordian-engine/gcosmos](gcosmos) for an example Driver integrating with the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk).

Outside of the driver, Gordian currently provides a networking layer using [libp2p](https://libp2p.io/),
a storage layer using [SQLite](https://www.sqlite.org/),
Ed25519 signing keys for validators,
and some simple hashing schemes using [BLAKE2b](https://www.blake2.net/).

We have carefully designed the internal APIs to make it as easy as possible to swap out any of those implementations
(and to test that they comply with expectations within the consensus engine).

While it is easiest to integrate Go code with Gordian,
it should be straightforward to write a shim layer in Go such that
you can run an external process and have the core engine communicate with your component.
There is also the option of [CGo](https://pkg.go.dev/cmd/cgo) if you can provide a C ABI.

Refer to the [`_docs` directory](/_docs) for more technical details.

## Why would I use Gordian?

Most other consensus engines tend to have strong opinions about the way these subsystems work.
As a result, when teams run into bottlenecks, they are usually stuck looking for small performance gains
in the underlying framework.
Gordian makes it easy to swap out parts of the consensus engine,
whether you are making one small tweak to a standard component or writing one from scratch.
Whether it's a short experiment or code you've benchmarked and you are taking to production,
you can relax knowing that you can safely maintain one small library,
instead of forking the entire consensus engine.

## Try it out

### Full demo with gcosmos

We recommend the earlier mentioned [https://github.com/gordian-engine/gcosmos](gcosmos) repository
for a full-featured demo involving Gordian integrating with the Cosmos SDK.

### Lightweight demo

Clone the Gordian repository and `cd` into it.
Make sure you have [the most recent version of Go installed](https://go.dev/dl/).
Run `./demo-echo.bash start 4` to start a local network of 4 validators,
running a toy application where the network participants agree on the current height and round.
tmsqlite passes the [tmstore compliance tests](https://pkg.go.dev/github.com/gordian-engine/gordian/tm/tmstore/tmstoretest)
and it runs with [gcosmos](https://github.com/gordian-engine/gcosmos),
but until there is a tagged release, you should assume that the database schema may change in a backwards-incompatible way.

## License

The Gordian source code is available under the Apache 2.0 license.
The tmsqlite source code is available under the Apache 2.0 license.

Copyright (c) 2024 Strangelove Crypto, Inc.

[^1]: Tendermint is a registered trademark of All in Bits, Inc.
190 changes: 0 additions & 190 deletions _docs/architecture_overview.md

This file was deleted.

Loading

0 comments on commit 72fc096

Please sign in to comment.