maobft

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2020 License: MIT Imports: 5 Imported by: 0

README

mao-bft

mao-bft is an efficient byzantine fault tolerance protocol without leader reelection

GoDoc Build Status

Consensus layer

We design consensus layer independent from upper application layer, this mean that our BFT algorithm should be able to carry any message. To achieve this, we define the message to be any protobuf payload. In the mean time, each node in the cluster should be http server based on gRPC, we define RPC as below:

Message Flow

We use RBC(Reliable Broadcast) as a building block. Optional: use threshold signature instead of "echo and prepare"

Message Types
  1. Common Types This message defines common messages shared by RPC.
message Payload {
  string merkel_root;
  repeated string merkel_branch;
  bytes data;
}
  1. PrepareValue This message is sent by leader and makes value known to every follower.
rpc PrepareValue (PrepareValueRequest) returns (PrepareValueResponse) {}

message PrepareValueRequest {
  Payload payload;
}

message PrepareValueResponse {}
  1. EchoValue This message is send from everyone uppon receiving PrepareValue
rpc EchoValue (EchoValueRequest) returns (EchoValueResponse) {}

message EchoValueRequest {
  Payload payload;
}

message EchoValueResponse {}
  1. ReadyValue This message is send from everyone uppon receiving enough EchoValue
rpc EchoValue (EchoValueRequest) returns (EchoValueResponse) {}

message ReadyValueRequest {
  string merkel_root;
}

message ReadyValueResponse {}
Application layer
  1. GetTransactionStatus This message is used by client to get TX status in the system.
define RPC here

Applications

We can utilize this protocal to implement different type of applications, in example folder we have a blockchain for demo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Common

type Common interface {
	Name() string
	SendEcho(conn *grpc.ClientConn, merkleProof *pb.MerkleProof, data []byte) error
	SendReady(conn *grpc.ClientConn, merkleRoot []byte) error
	pb.ReadyServer
	pb.EchoServer
}

type Follower

type Follower struct {
	pb.UnimplementedPrepareServer
	// contains filtered or unexported fields
}

func NewFollower

func NewFollower(name string) Follower

func (*Follower) Echo

func (c *Follower) Echo(ctx context.Context, req *pb.Payload) (*pb.EchoResponse, error)

Echo serves echo messages from other nodes

func (*Follower) Name

func (c *Follower) Name() string

Name is the node's name

func (*Follower) Prepare

func (s *Follower) Prepare(ctx context.Context, req *pb.Payload) (*pb.PrepareResponse, error)

Prepare serves Prepare messages sent from Leader

func (*Follower) Ready

func (c *Follower) Ready(ctx context.Context, req *pb.ReadyRequest) (*pb.ReadyResponse, error)

Ready serves ready messages from other nodes

type Leader

type Leader struct {
	rbc.PrepareClientWrapper
	// contains filtered or unexported fields
}

func NewLeader

func NewLeader(name string) Leader

func (*Leader) Echo

func (c *Leader) Echo(ctx context.Context, req *pb.Payload) (*pb.EchoResponse, error)

Echo serves echo messages from other nodes

func (*Leader) Name

func (c *Leader) Name() string

Name is the node's name

func (*Leader) Ready

func (c *Leader) Ready(ctx context.Context, req *pb.ReadyRequest) (*pb.ReadyResponse, error)

Ready serves ready messages from other nodes

type Mao

type Mao interface {
	SendPrepare(conn *grpc.ClientConn, merkleProof *pb.MerkleProof, data []byte) error
	Common
}

type MaoFollower

type MaoFollower interface {
	pb.PrepareServer
	Common
}

type Message

type Message interface {
	encoding.BinaryMarshaler
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL