package cosipbft
import "go.dedis.ch/dela/core/ordering/cosipbft"
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
- func (p Proof) GetKey() []byte
- func (p Proof) GetValue() []byte
- func (p Proof) Verify(genesis types.Genesis, fac crypto.VerifierFactory) error
- type Service
- func NewService(param ServiceParam, opts ...ServiceOption) (*Service, error)
- func NewServiceStruct(param ServiceParam, opts ...ServiceOption) (*Service, error)
- 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
- func WithBlockStore(store blockstore.BlockStore) ServiceOption
- func WithGenesisStore(store blockstore.GenesisStore) ServiceOption
- func WithHashFactory(fac crypto.HashFactory) 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 )
Functions ¶
func NewServiceStart ¶
func NewServiceStart(s *Service)
NewServiceStart runs the necessary go-routines to start the service
func RegisterRosterContract ¶
RegisterRosterContract registers the native smart contract to update the roster to the given 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
func (Proof) GetKey ¶
GetKey implements ordering.Proof. It returns the key associated to the proof.
func (Proof) GetValue ¶
GetValue implements ordering.Proof. It returns the value associated to the proof if the key exists, otherwise it returns nil.
func (Proof) Verify ¶
Verify takes the genesis block and the verifier factory to verify the chain up to the latest block. It verifies the whole chain.
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) GetRoster ¶
GetRoster returns the current roster of the service.
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) Process ¶
Process implements mino.Handler. It processes the messages from the RPC.
func (*Service) SetTimeouts ¶
SetTimeouts sets the timeouts for the service.
func (*Service) Setup ¶
Setup creates a genesis block and sends it to the collective authority.
func (*Service) Watch ¶
Watch implements ordering.Service. It returns a channel that will be populated with new incoming blocks and some information about them. The channel must be listened at all time and the context must be closed when done.
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.
Source Files ¶
cosipbft.go proc.go proof.go
Directories ¶
Path | Synopsis |
---|---|
core/ordering/cosipbft/authority | Package authority defines the collective authority for cosipbft. |
core/ordering/cosipbft/authority/json | |
core/ordering/cosipbft/blockstore | Package blockstore defines the different storage the ordering service is using. |
core/ordering/cosipbft/blocksync | Package blocksync defines a block synchronizer for the ordering service. |
core/ordering/cosipbft/blocksync/json | |
core/ordering/cosipbft/blocksync/types | Package types implements the network messages for a synchronization. |
core/ordering/cosipbft/contracts | |
core/ordering/cosipbft/contracts/viewchange | Package viewchange implements a native smart contract to update the roster of a chain. |
core/ordering/cosipbft/controller | Package controller implements a minimal controller for cosipbft. |
core/ordering/cosipbft/json | |
core/ordering/cosipbft/pbft | Package pbft defines a state machine to perform PBFT using collective signatures. |
core/ordering/cosipbft/types | Package types implements the network messages for cosipbft. |
- Version
- v0.1.0 (latest)
- Published
- Apr 10, 2024
- Platform
- linux/amd64
- Imports
- 29 packages
- Last checked
- 1 month ago –
Tools for package owners.