Documentation
¶
Overview ¶
Package cosipbft implements an ordering service using collective signatures for the consensus.
The consensus follows the PBFT algorithm using collective signatures to perform the prepare and commit phases. The leader is orchestrating the protocol and the followers wait for incoming messages to update their own state machines and reply with signatures when the leader candidate is valid. If the leader fails to send a candidate, or finalize it, the followers will timeout after some time and move to a view change state.
The view change procedure is always waiting on the leader+1 confirmation before moving to leader+2, leader+3, etc. It means that if not enough nodes are online to create a block, the round will fail until enough wakes up and confirm leader+1. If leader+1 fails to create a block within the round timeout, a new view change starts for leader+2 and so on until a block is created.
Before each PBFT round, a synchronization is run from the leader to allow nodes that have fallen behind (or are new) to catch missing blocks. Only a PBFT threshold of nodes needs to confirm a hard synchronization (having all the blocks) for the round to proceed, but others will keep catching up.
Related Papers:
Enhancing Bitcoin Security and Performance with Strong Consistency via Collective Signing (2016) https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_kokoris-kogias.pdf
Documentation Last Review: 12.10.2020
Index ¶
- Constants
- func NewServiceStart(s *Service)
- func RegisterRosterContract(exec *native.Service, rFac authority.Factory, srvc access.Service)
- type Proof
- type Service
- func (s *Service) Close() error
- func (s *Service) GetProof(key []byte) (ordering.Proof, error)
- func (s *Service) GetRoster() (authority.Authority, error)
- func (s *Service) GetStore() store.Readable
- func (h Service) Invoke(from mino.Address, msg serde.Message) ([]byte, error)
- func (h Service) Process(req mino.Request) (serde.Message, error)
- func (s *Service) SetTimeouts(round, roundAfterFailure, transaction time.Duration)
- func (s *Service) Setup(ctx context.Context, ca crypto.CollectiveAuthority) error
- func (s *Service) Watch(ctx context.Context) <-chan ordering.Event
- type ServiceOption
- type ServiceParam
Constants ¶
const ( // DefaultRoundTimeout is the maximum round time the service waits // for an event to happen. DefaultRoundTimeout = 10 * time.Second // DefaultFailedRoundTimeout is the maximum round time the service waits // for an event to happen, after a round has failed, thus letting time // for a view change to establish a new leader. // DefaultFailedRoundTimeout is generally bigger than DefaultRoundTimeout DefaultFailedRoundTimeout = 20 * time.Second // DefaultTransactionTimeout is the maximum allowed age of transactions // before a view change is executed. DefaultTransactionTimeout = 30 * time.Second // RoundWait is the constant value of the exponential backoff use between // round failures. RoundWait = 5 * time.Millisecond // RoundMaxWait is the maximum amount for the backoff. RoundMaxWait = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func NewServiceStart ¶
func NewServiceStart(s *Service)
NewServiceStart runs the necessary go-routines to start the service
Types ¶
type Proof ¶
type Proof struct {
// contains filtered or unexported fields
}
Proof is a combination of elements that will prove the inclusion or the absence of a key/value pair in the given block.
- implements ordering.Proof
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an ordering service using collective signatures combined with PBFT to create a chain of blocks.
- implements ordering.Service
func NewService ¶
func NewService(param ServiceParam, opts ...ServiceOption) (*Service, error)
NewService starts a new ordering service.
func NewServiceStruct ¶
func NewServiceStruct(param ServiceParam, opts ...ServiceOption) (*Service, error)
NewServiceStruct returns the service struct without actually starting the service. This is useful for testing purposes.
func (*Service) Close ¶
Close implements ordering.Service. It gracefully closes the service. It will announce the closing request and wait for the current to end before returning.
func (*Service) GetProof ¶
GetProof implements ordering.Service. It returns the proof of absence or inclusion for the latest block. The proof integrity is not verified as this is assumed the node is acting correctly so the data is anyway consistent. The proof must be verified by the caller when leaving the trusted environment, for instance when the proof is sent over the network.
func (*Service) GetStore ¶
GetStore implements ordering.Service. It returns the current tree as a read-only storage.
func (Service) Invoke ¶
Invoke implements cosi.Reactor. It processes the messages from the collective signature module. The messages are either from the the prepare or the commit phase.
func (*Service) SetTimeouts ¶
SetTimeouts sets the timeouts for the service.
type ServiceOption ¶
type ServiceOption func(*serviceTemplate)
ServiceOption is the type of option to set some fields of the service.
func WithBlockStore ¶
func WithBlockStore(store blockstore.BlockStore) ServiceOption
WithBlockStore is an option to set the block store.
func WithGenesisStore ¶
func WithGenesisStore(store blockstore.GenesisStore) ServiceOption
WithGenesisStore is an option to set the genesis store.
func WithHashFactory ¶
func WithHashFactory(fac crypto.HashFactory) ServiceOption
WithHashFactory is an option to set the hash factory used by the service.
type ServiceParam ¶
type ServiceParam struct { Mino mino.Mino Cosi cosi.CollectiveSigning Validation validation.Service Access access.Service Pool pool.Pool Tree hashtree.Tree DB kv.DB }
ServiceParam is the different components to provide to the service. All the fields are mandatory and it will panic if any is nil.
Directories
¶
Path | Synopsis |
---|---|
Package authority defines the collective authority for cosipbft.
|
Package authority defines the collective authority for cosipbft. |
Package blockstore defines the different storage the ordering service is using.
|
Package blockstore defines the different storage the ordering service is using. |
Package blocksync defines a block synchronizer for the ordering service.
|
Package blocksync defines a block synchronizer for the ordering service. |
types
Package types implements the network messages for a synchronization.
|
Package types implements the network messages for a synchronization. |
contracts
|
|
viewchange
Package viewchange implements a native smart contract to update the roster of a chain.
|
Package viewchange implements a native smart contract to update the roster of a chain. |
Package controller implements a minimal controller for cosipbft.
|
Package controller implements a minimal controller for cosipbft. |
Package pbft defines a state machine to perform PBFT using collective signatures.
|
Package pbft defines a state machine to perform PBFT using collective signatures. |
Package types implements the network messages for cosipbft.
|
Package types implements the network messages for cosipbft. |