abft

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicatedRBCRequest is a specific error for receive duplicated request
	ErrDuplicatedRBCRequest = errors.New("receive duplicated request")
)

Functions

func GetNodeListFromConfig

func GetNodeListFromConfig(chainConfig *config.ChainConfig) (validators []string)

GetNodeListFromConfig get consensus node list

func VerifyBlockSignatures

func VerifyBlockSignatures(chainConf protocol.ChainConf, ac protocol.AccessControlProvider, block *common.Block) error

VerifyBlockSignatures verifies whether the signatures in block is qualified with the consensus algorithm. It should return nil error when verify successfully, and return corresponding error when failed.

Types

type ACS

type ACS struct {
	*Config
	sync.Mutex
	// contains filtered or unexported fields
}

ACS is asynchronous common subset instance

func NewACS

func NewACS(cfg *Config) *ACS

NewACS create acs instance

func (*ACS) Event

func (acs *ACS) Event() *Event

Event deliver event to ABFT

func (*ACS) GetACSStateJson

func (acs *ACS) GetACSStateJson() *ACSStateJson

GetACSStateJson return ACSStateJson

func (*ACS) HandleMessage

func (acs *ACS) HandleMessage(sender string, id string, acsMessage *abftpb.ACSMessage) error

HandleMessage handle rbc or bba message

func (*ACS) InputBBA

func (acs *ACS) InputBBA(output []byte) error

InputBBA process verify result of tx batch

func (*ACS) InputRBC

func (acs *ACS) InputRBC(val []byte) error

InputRBC process tx batch

type ACSStateJson

type ACSStateJson struct {
	// RBCStates rbc states
	RBCStates map[string]*RBCStateJson `json:"rbc_states"`
	// BBAStates bba states
	BBAStates map[string]*BBAStateJson `json:"bba_states"`

	// RBCResults rbc results
	RBCResults map[string][]byte `json:"rbc_results"`
	// BBAResults bba results
	BBAResults map[string]bool `json:"bba_results"`

	// Outputs acs outputs
	Outputs [][]byte `json:"outputs"`
	// Decided whether acs has decided
	Decided bool `json:"decided"`
}

ACSStateJson is acs state json

type BBA

type BBA struct {
	*Config
	sync.Mutex
	// contains filtered or unexported fields
}

BBA is asynchronous binary byzantine agreement instance

func NewBBA

func NewBBA(cfg *Config) *BBA

NewBBA create BBA

func (*BBA) AcceptInput

func (bba *BBA) AcceptInput() bool

AcceptInput judges whether bba can set est

func (*BBA) GetBBAStateJson

func (bba *BBA) GetBBAStateJson() *BBAStateJson

GetBBAStateJson return BBAStateJson

func (*BBA) HandleMessage

func (bba *BBA) HandleMessage(sender string, msg *abftpb.BBARequest) error

HandleMessage handle BVAL and AUX msg

func (*BBA) Input

func (bba *BBA) Input(val bool) error

Input val to set est and broadcast BVAL msg

func (*BBA) Messages

func (bba *BBA) Messages() []*abftpb.ABFTMessageReq

Messages deliver messages to ACS

func (*BBA) Output

func (bba *BBA) Output() (outputted bool, output bool)

Output deliver bba result to ACS only once

type BBAStateJson

type BBAStateJson struct {
	// Estimated json state
	Estimated bool `json:"estimated"`
	// Estimation json state
	Estimation bool `json:"estimation"`

	// BinValues bin values json state
	BinValues []bool `json:"bin_values"`
	// SentBvals sent Bvals json state
	SentBvals []bool `json:"sent_bvals"`

	// Outputted state
	Outputted bool `json:"outputted"`
	// Output state
	Output bool `json:"output"`

	// Decided state
	Decided bool `json:"decided"`
	// Decision state
	Decision bool `json:"decision"`

	// Done state
	Done bool `json:"done"`
}

BBAStateJson is bba state json

type Config

type Config struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Config is acs config

func (*Config) String

func (c *Config) String() string

String return config by string format

type ConsensusABFTImpl

type ConsensusABFTImpl struct {
	sync.RWMutex

	// Id is current nodeId
	Id string
	// contains filtered or unexported fields
}

ConsensusABFTImpl is the implementation of ABFT algorithm it implements the ConsensusEngine interface.

func New

New creates a abft consensus instance

func (*ConsensusABFTImpl) Close added in v3.0.1

func (consensus *ConsensusABFTImpl) Close() error

Close implements the Close method of ConsensusEngine interface and closes the abft instance.

func (*ConsensusABFTImpl) GetAllNodeInfos

func (consensus *ConsensusABFTImpl) GetAllNodeInfos() []consensuspb.ConsensusNodeInfo

GetAllNodeInfos Get consensus nodes info

func (*ConsensusABFTImpl) GetConsensusStateJSON

func (consensus *ConsensusABFTImpl) GetConsensusStateJSON() ([]byte, error)

GetConsensusStateJSON get consensus state json

func (*ConsensusABFTImpl) GetConsensusType

func (consensus *ConsensusABFTImpl) GetConsensusType() consensuspb.ConsensusType

GetConsensusType get consensus type

func (*ConsensusABFTImpl) GetLastHeight

func (consensus *ConsensusABFTImpl) GetLastHeight() uint64

GetLastHeight get current consensus block height

func (*ConsensusABFTImpl) GetValidators

func (consensus *ConsensusABFTImpl) GetValidators() ([]string, error)

GetValidators get validators

func (*ConsensusABFTImpl) OnMessage

func (consensus *ConsensusABFTImpl) OnMessage(message *msgbus.Message)

OnMessage implements the OnMessage interface of msgbus.Subscriber

func (*ConsensusABFTImpl) OnQuit

func (consensus *ConsensusABFTImpl) OnQuit()

OnQuit implements the OnQuit interface of msgbus.Subscriber

func (*ConsensusABFTImpl) Start

func (consensus *ConsensusABFTImpl) Start() error

Start implements the Stop method of ConsensusEngine interface and starts the abft instance.

func (*ConsensusABFTImpl) Stop

func (consensus *ConsensusABFTImpl) Stop() error

Stop implements the Stop method of ConsensusEngine interface and stops the abft instance.

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event transfer msg from acs to abft

type RBC

type RBC struct {
	// abft config
	*Config

	sync.Mutex
	// contains filtered or unexported fields
}

RBC represents an instance of "Reliable Broadcast".

func NewRBC

func NewRBC(cfg *Config) *RBC

NewRBC returns an instance of RBC for reliable broadcast.

func (*RBC) GetRBCStateJson

func (rbc *RBC) GetRBCStateJson() *RBCStateJson

GetRBCStateJson return RBCStateJson

func (*RBC) HandleMessage

func (rbc *RBC) HandleMessage(sender string, msg *abftpb.RBCRequest) error

HandleMessage handle RBC msg

func (*RBC) Input

func (rbc *RBC) Input(data []byte) error

Input inputs data to the rbc instance.

func (*RBC) Messages

func (rbc *RBC) Messages() []*abftpb.ABFTMessageReq

Messages return RBC messages to ACS

func (*RBC) Output

func (rbc *RBC) Output() []byte

Output return delivered tx batch to ACS

type RBCStateJson

type RBCStateJson struct {
	// ReceivedEchos EchoRequest json state
	ReceivedEchos map[string]*abft.EchoRequest `json:"received_echos"`
	// EchoSent state
	EchoSent bool `json:"echo_sent"`

	// ReceivedReadys state
	ReceivedReadys map[string][]byte `json:"received_readys"`
	// ReadySent state
	ReadySent bool `json:"ready_sent"`

	// Output state
	Output []byte `json:"output"`
	// OutputDecoded state
	OutputDecoded bool `json:"output_decoded"`
}

RBCStateJson is rbc state json

Jump to

Keyboard shortcuts

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