Categorygithub.com/yonggewang/bdls
modulepackage
0.0.0-20230125193903-4e4ac5f346a4
Repository: https://github.com/yonggewang/bdls.git
Documentation: pkg.go.dev

# README

BDLS

Efficient BFT in partial synchronous networks

BDLS Consensus

Introduction

BDLS is an innovative BFT consensus algorithm that features safety and liveness by presenting a mathematically proven secure BFT protocol that is resilient in open networks such as the Internet. BDLS overcomes many problems, such as the deadlock problem caused by unreliable p2p/broadcast channels. These problems are all very relevant to existing realistic open network scenarios, and are the focus of extensive work in improving Internet security, but it is an area largely ignored by most in mainstream BFT protocol design. (Paper: https://eprint.iacr.org/2019/1460.pdf or https://dl.acm.org/doi/abs/10.1145/3538227 or https://doi.org/10.1145/3538227 or https://www.doi.org/10.1007/978-3-030-91859-0_2 )

For this library, to make the runtime behavior of consensus algorithm predictable as function: y = f(x, t), where 'x' is the message it received, and 't' is the time while being called, then'y' is the deterministic status of consensus after 'x' and 't' applied to 'f', it has been designed in a deterministic scheme, without parallel computing, networking, and the correctness of program implementation can be proven with proper test cases.

Features

  1. Pure algorithm implementation in deterministic and predictable behavior, easily to be integrated into existing projects, refer to DFA for more.
  2. Well-tested on various platforms with complicated cases.
  3. Auto back-off under heavy payload, guaranteed finalization(worst case gurantee).
  4. Easy integratation into Blockchain & non-Blockchain consensus, like WAL replication in database.
  5. Builtin network emulation for various network latency with comprehensive statistics.

Documentation

For complete documentation, see the associated Godoc.

Install BDLS on Ubuntu Server 20.04

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install autoconf automake libtool curl make g++ unzip
cd /tmp
wget https://go.dev/dl/go1.19.linux-amd64.tar.gz 
sudo tar -xvf go1.19.linux-amd64.tar.gz
sudo mv go /usr/local
cd
echo 'export GOROOT=/usr/local/go' >> .profile
echo 'export GOPATH=$HOME/go' >> .profile
echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> .profile
source ~/.profile 
go version
go env
git clone https://github.com/yonggewang/bdls.git
cd bdls/
git checkout master
cd cmd/emucon/
go build .
./emucon help genkeys
./emucon genkeys --count 4

[open four terminals to run four participants. if you log to remote Linux, 
you may use tmux commands. In tmux, you can switch termian using "ctrl+b d" 
and use "tmux attach -t 0" to enter the terminal. Use "tmux list-session" 
to check the current active terminals]


./emucon run --id 0 --listen ":4680"
./emucon run --id 1 --listen ":4681"
./emucon run --id 2 --listen ":4682"
./emucon run --id 3 --listen ":4683"

cd ../..
go test -v -cpuprofile=cpu.out -memprofile=mem.out -timeout 2h

Regenerate go.mod and go.sum

rm go.*
go mod init github.com/yonggewang/bdls
go mod tidy
go mod vendor

See benchmark ourput at: AMD-NORMAL.TXT and PI4-OVERLOAD.TXT

Specification

  1. Consensus messages are specified in message.proto, users of this library can encapsulate this message in a carrier message, like gossip in TCP.
  2. Consensus algorithm is NOT thread-safe, it MUST be protected by some synchronization mechanism, like sync.Mutex or chan + goroutine.

Usage

  1. A testing IPC peer -- ipc_peer.go
  2. A testing TCP node -- TCP based Consensus Emualtor

Status

On-going

# Packages

Package agent-tcp implements a TCP based agent to participate in consensus Challenge-Response scheme has been adopted to do interactive authentication.
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

DecodeMessage decodes a binary representation of consensus message.
DecodeSignedMessage decodes a binary representation of signed consensus message.
default method to derive coordinate from public key.
NewConsensus creates a BDLS consensus object to participant in consensus procedure, the consensus object returned is data in memory without goroutines or other non-deterministic objects, and errors will be returned if there is problem, with the given config.
NewIPCPeer creates IPC based peer with latency, latency is distributed with standard normal distribution.
VerifyConfig verifies the integrity of this config when creating new consensus object.

# Constants

ConfigMinimumParticipants is the minimum number of participant allow in consensus protocol.
DefaultConsensusLatency is the default propagation latency setting for consensus protocol, user can adjust consensus object's latency setting via Consensus.SetLatency().
MaxConsensusLatency is the ceiling of latencies.
MessageCommit = <commit> message.
MessageDecide = <decide> message.
MessageLock = <lock> message.
MessageLockRelease = <lock-release> message.
No operation, for default message type, and keepalive connection.
MessageResync= <resync> message.
MessageRoundChange = <roundchange> message.
MessageSelect = <select> message.
the current BDLS protocol version, version will be sent along with messages for protocol upgrading.
SignaturePrefix is the prefix for signing a consensus message.
SizeAxis defines byte size of X-axis or Y-axis in a public key.

# Variables

<commit> related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Config Related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
<decide> Related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
<lock> related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
<lock-release> related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
common errors related to every message.
<decide> verification.
ErrPubKey will be returned if error found while decoding message's public key.
<roundchange> related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
<select> related.
No description provided by the author
No description provided by the author
No description provided by the author
secp256k1 elliptic curve.

# Structs

Config is to config the parameters of BDLS consensus protocol.
Consensus implements a deterministic BDLS consensus protocol.
IPCPeer represents an in-process peer for testing, which sends messages directly via function call, message delivery latency can be customizable to emulate variety of network latency.
Message defines a consensus message.
SignedProto defines a message with signature and it's publickey.

# Interfaces

PeerInterface is a channel for consensus to send message to the peer.

# Type aliases

Identity is a user-defined struct to encode X-axis and Y-axis for a publickey in an array.
MessageType defines supported message types.
PubKeyAxis defines X-axis or Y-axis in a public key.
No description provided by the author
No description provided by the author