committee

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 0

README

consensus states

Consensus operator
- INIT immediately after activation
- NEW_STATE immediately after transition to the new state
- NEW_LEADER immediately after leader change
non-leader states
- NOTIFICATIONS_SENT for non-leader immediately after notifications sent to the leader
- VM_RUN_STARTED after was received request for calculation from the leader which is assumed
- RESULT_SENT result was sent to the leader
- CALCULATION_EVIDENCE_received from the leader
- CALCULATION_EVIDENCE_received from the tangle (not confirmed yet)
leader-states
- RUN_CALCULATIONS sent to peers and own calculation started
- RESULT-finalize (sent to the tangle and peers)

Documentation

Index

Constants

View Source
const (
	RequestProcessingStatusUnknown = RequestProcessingStatus(iota)
	RequestProcessingStatusBacklog
	RequestProcessingStatusCompleted
)
View Source
const (
	// confirmation time assumption. Average time from posting a transaction to finality
	ConfirmationTime = 10 * time.Second

	// additional period after committee quorum of connections is reached
	AdditionalConnectPeriod = 3 * time.Second

	// time tick for consensus and state manager objects
	TimerTickPeriod = 100 * time.Millisecond

	// retry delay for congested input channel for the consensus and state manager objects.channel.
	ReceiveMsgChannelRetryDelay = 500 * time.Millisecond

	RequestBalancesPeriod = 10 * time.Second

	// if node is behind the current state (not synced) it send GetBatch messages to pseudo-randomly
	// selected peer to get the batch it needs. Node expects answer, if not the message is repeated to another
	// peer after some time
	PeriodBetweenSyncMessages = 1 * time.Second

	// if pongs do not make a quorum, pings are repeated to all peer nodes
	RepeatPingAfter = 5 * time.Second

	// State Manager is requesting transaction to confirm a pending batch from the goshimmer node.
	// Request is repeated if necessary.
	StateTransactionRequestTimeout = 10 * time.Second

	// maximum time difference allowed between leader and local clocks for consensus
	MaxClockDifferenceAllowed = 3 * time.Second
)
View Source
const (
	MsgStateIndexPingPong      = 0 + peering.FirstCommitteeMsgCode
	MsgNotifyRequests          = 1 + peering.FirstCommitteeMsgCode
	MsgNotifyFinalResultPosted = 2 + peering.FirstCommitteeMsgCode
	MsgStartProcessingRequest  = 3 + peering.FirstCommitteeMsgCode
	MsgSignedHash              = 4 + peering.FirstCommitteeMsgCode
	MsgGetBatch                = 5 + peering.FirstCommitteeMsgCode
	MsgStateUpdate             = 6 + peering.FirstCommitteeMsgCode
	MsgBatchHeader             = 7 + peering.FirstCommitteeMsgCode
	MsgTestTrace               = 8 + peering.FirstCommitteeMsgCode
)

Variables

View Source
var ConstructorNew func(bootupData *registry.BootupData, log *logger.Logger, onActivation func()) Committee

Functions

This section is empty.

Types

type BalancesMsg

type BalancesMsg struct {
	Balances map[valuetransaction.ID][]*balance.Balance
}

type BatchHeaderMsg

type BatchHeaderMsg struct {
	PeerMsgHeader
	// state index of the batch
	Size uint16
	// approving transaction id
	StateTransactionId valuetransaction.ID
}

the header of the batch message sent by peers in the process of syncing it is sent as a first message while syncing a batch

func (*BatchHeaderMsg) Read

func (msg *BatchHeaderMsg) Read(r io.Reader) error

func (*BatchHeaderMsg) Write

func (msg *BatchHeaderMsg) Write(w io.Writer) error

type Committee

type Committee interface {
	Address() *address.Address
	OwnerAddress() *address.Address
	Color() *balance.Color
	Size() uint16
	Quorum() uint16
	OwnPeerIndex() uint16
	NumPeers() uint16
	SendMsg(targetPeerIndex uint16, msgType byte, msgData []byte) error
	SendMsgToCommitteePeers(msgType byte, msgData []byte, ts int64) uint16
	SendMsgInSequence(msgType byte, msgData []byte, seqIndex uint16, seq []uint16) (uint16, error)
	IsAlivePeer(peerIndex uint16) bool
	ReceiveMessage(msg interface{})
	InitTestRound()
	HasQuorum() bool
	PeerStatus() []*PeerStatus
	//
	SetReadyStateManager()
	SetReadyConsensus()
	Dismiss()
	IsDismissed() bool
	GetRequestProcessingStatus(*sctransaction.RequestId) RequestProcessingStatus
}

func New

func New(bootupData *registry.BootupData, log *logger.Logger, onActivation func()) Committee

type GetBatchMsg

type GetBatchMsg struct {
	PeerMsgHeader
}

request batch of updates from peer. Used in syn process

func (*GetBatchMsg) Read

func (msg *GetBatchMsg) Read(r io.Reader) error

func (*GetBatchMsg) Write

func (msg *GetBatchMsg) Write(w io.Writer) error

type NotifyFinalResultPostedMsg

type NotifyFinalResultPostedMsg struct {
	PeerMsgHeader
	TxId valuetransaction.ID
}

message is sent by the leader to all peers immediately after the final transaction is posted to the tangle. Main purpose of the message is to prevent unnecessary leader rotation in long confirmation times Final signature is sent to prevent possibility for a leader node to lie (is it necessary)

func (*NotifyFinalResultPostedMsg) Read

func (*NotifyFinalResultPostedMsg) Write

func (msg *NotifyFinalResultPostedMsg) Write(w io.Writer) error

type NotifyReqMsg

type NotifyReqMsg struct {
	PeerMsgHeader
	// list of request ids ordered by the time of arrival
	RequestIds []sctransaction.RequestId
}

message is sent to the leader of the state processing it is sent upon state change or upon arrival of the new request the receiving operator will ignore repeating messages

func (*NotifyReqMsg) Read

func (msg *NotifyReqMsg) Read(r io.Reader) error

func (*NotifyReqMsg) Write

func (msg *NotifyReqMsg) Write(w io.Writer) error

type Operator

type Operator interface {
	EventProcessorReady(ProcessorIsReady)
	EventStateTransitionMsg(*StateTransitionMsg)
	EventBalancesMsg(BalancesMsg)
	EventRequestMsg(*RequestMsg)
	EventNotifyReqMsg(*NotifyReqMsg)
	EventStartProcessingBatchMsg(*StartProcessingBatchMsg)
	EventResultCalculated(*vm.VMTask)
	EventSignedHashMsg(*SignedHashMsg)
	EventNotifyFinalResultPostedMsg(*NotifyFinalResultPostedMsg)
	EventTransactionInclusionLevelMsg(msg *TransactionInclusionLevelMsg)
	EventTimerMsg(TimerTick)
	//
	IsRequestInBacklog(*sctransaction.RequestId) bool
}

type PeerMsgHeader

type PeerMsgHeader struct {
	// is set upon receive the message
	SenderIndex uint16
	// state index in the context of which the message is sent
	StateIndex uint32
}

all peer messages have this

type PeerStatus

type PeerStatus struct {
	Index     int
	PeeringID string
	IsSelf    bool
	Connected bool
}

func (*PeerStatus) String

func (p *PeerStatus) String() string

type PendingBatchMsg

type PendingBatchMsg struct {
	Batch state.Batch
}

message of complete batch. Is sent by consensus operator to the state manager as a VM result - state manager to itself when batch is completed after syncing

type ProcessorIsReady

type ProcessorIsReady struct {
	ProgramHash string // base58
}

message sent to notify VM processor is ready. It is a successful finish of asynchronous loading of the processor

type RequestMsg

type RequestMsg struct {
	*sctransaction.Transaction
	Index uint16
}

func (*RequestMsg) RequestBlock

func (reqMsg *RequestMsg) RequestBlock() *sctransaction.RequestBlock

func (*RequestMsg) RequestId

func (reqMsg *RequestMsg) RequestId() *sctransaction.RequestId

func (*RequestMsg) Timelock

func (reqMsg *RequestMsg) Timelock() uint32

type RequestProcessingStatus

type RequestProcessingStatus int

type SignedHashMsg

type SignedHashMsg struct {
	PeerMsgHeader
	// timestamp of this message. Field is set upon receive the message to sender's timestamp
	Timestamp int64
	// returns hash of all req ids
	BatchHash hashing.HashValue
	// original timestamp, the parameter for calculations, which is signed as part of the essence
	OrigTimestamp int64
	// hash of the signed data (essence)
	EssenceHash hashing.HashValue
	// signature
	SigShare tbdn.SigShare
}

after calculations the result peer responds to the start processing msg with SignedHashMsg, which contains result hash and signatures

func (*SignedHashMsg) Read

func (msg *SignedHashMsg) Read(r io.Reader) error

func (*SignedHashMsg) Write

func (msg *SignedHashMsg) Write(w io.Writer) error

type StartProcessingBatchMsg

type StartProcessingBatchMsg struct {
	PeerMsgHeader
	// timestamp of the message. Field is set upon receive the message to sender's timestamp
	Timestamp int64
	// batch of request ids
	RequestIds []sctransaction.RequestId
	// reward address
	RewardAddress address.Address
	// balances/outputs
	Balances map[valuetransaction.ID][]*balance.Balance
}

message is sent by the leader to other peers to initiate request processing other peers are expected to check is timestamp is acceptable then process request batch and sign the result hash with the timestamp proposed by the leader

func (*StartProcessingBatchMsg) Read

func (msg *StartProcessingBatchMsg) Read(r io.Reader) error

func (*StartProcessingBatchMsg) Write

func (msg *StartProcessingBatchMsg) Write(w io.Writer) error

type StateIndexPingPongMsg

type StateIndexPingPongMsg struct {
	PeerMsgHeader
	RSVP bool
}

Ping is sent to receive Pong

func (*StateIndexPingPongMsg) Read

func (msg *StateIndexPingPongMsg) Read(r io.Reader) error

func (*StateIndexPingPongMsg) Write

func (msg *StateIndexPingPongMsg) Write(w io.Writer) error

type StateManager

type StateManager interface {
	EvidenceStateIndex(idx uint32)
	EventStateIndexPingPongMsg(msg *StateIndexPingPongMsg)
	EventGetBatchMsg(msg *GetBatchMsg)
	EventBatchHeaderMsg(msg *BatchHeaderMsg)
	EventStateUpdateMsg(msg *StateUpdateMsg)
	EventStateTransactionMsg(msg *StateTransactionMsg)
	EventPendingBatchMsg(msg PendingBatchMsg)
	EventTimerMsg(msg TimerTick)
}

type StateTransactionEvidenced

type StateTransactionEvidenced struct {
	TxId      valuetransaction.ID
	StateHash hashing.HashValue
}

message is sent to the consensus manager after it receives state transaction which is valid but not confirmed yet.

type StateTransactionMsg

type StateTransactionMsg struct {
	*sctransaction.Transaction
}

type StateTransitionMsg

type StateTransitionMsg struct {
	// new variable state
	VariableState state.VirtualState
	// corresponding state transaction
	StateTransaction *sctransaction.Transaction
	// processed requests
	RequestIds []*sctransaction.RequestId
	// is the state index last seen
	Synchronized bool
}

state manager notifies consensus operator about changed state only sent internally within committee state transition is always from state N to state N+1

type StateUpdateMsg

type StateUpdateMsg struct {
	PeerMsgHeader
	// state update
	StateUpdate state.StateUpdate
	// position in a batch
	BatchIndex uint16
}

state update sent to peer. Used in sync process, as part of batch

func (*StateUpdateMsg) Read

func (msg *StateUpdateMsg) Read(r io.Reader) error

func (*StateUpdateMsg) Write

func (msg *StateUpdateMsg) Write(w io.Writer) error

type TestTraceMsg

type TestTraceMsg struct {
	PeerMsgHeader
	InitTime      int64
	InitPeerIndex uint16
	Sequence      []uint16
	NumHops       uint16
}

used for testing of the communications

func (*TestTraceMsg) Read

func (msg *TestTraceMsg) Read(r io.Reader) error

func (*TestTraceMsg) Write

func (msg *TestTraceMsg) Write(w io.Writer) error

type TimerTick

type TimerTick int

type TransactionInclusionLevelMsg

type TransactionInclusionLevelMsg struct {
	TxId  *valuetransaction.ID
	Level byte
}

Directories

Path Synopsis
the file contains functions responsible for the request batch selection logic
the file contains functions responsible for the request batch selection logic
statemgr package implements object which is responsible for the smart contract ledger state to be synchronized and validated
statemgr package implements object which is responsible for the smart contract ledger state to be synchronized and validated

Jump to

Keyboard shortcuts

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