chain

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0, BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestProcessingStatusUnknown = RequestProcessingStatus(iota)
	RequestProcessingStatusBacklog
	RequestProcessingStatusCompleted
)
View Source
const (
	PeerMsgTypeMissingRequestIDs = iota
	PeerMsgTypeMissingRequest
	PeerMsgTypeOffLedgerRequest
	PeerMsgTypeRequestAck
)
View Source
const (
	// TimerTickPeriod time tick for consensus and state manager objects
	TimerTickPeriod = 100 * time.Millisecond
)

Variables

This section is empty.

Functions

func LogGovernanceTransition added in v0.2.0

func LogGovernanceTransition(msg *ChainTransitionEventData, log *logger.Logger)

LogGovernanceTransition

func LogStateTransition added in v0.2.0

func LogStateTransition(msg *ChainTransitionEventData, reqids []iscp.RequestID, log *logger.Logger)

LogStateTransition also used in testing

func PublishGovernanceTransition added in v0.2.0

func PublishGovernanceTransition(stateOutput *ledgerstate.AliasOutput)

func PublishRequestsSettled added in v0.2.0

func PublishRequestsSettled(chainID *iscp.ChainID, stateIndex uint32, reqids []iscp.RequestID)

func PublishStateTransition added in v0.2.0

func PublishStateTransition(chainID *iscp.ChainID, stateOutput *ledgerstate.AliasOutput, reqIDsLength int)

Types

type AsynchronousCommonSubsetRunner added in v0.2.0

type AsynchronousCommonSubsetRunner interface {
	RunACSConsensus(value []byte, sessionID uint64, stateIndex uint32, callback func(sessionID uint64, acs [][]byte))
	Close()
}

type Chain

type Chain interface {
	ChainCore
	ChainRequests
	ChainEntry
	ChainMetrics
}

type ChainCore added in v0.2.0

type ChainCore interface {
	ID() *iscp.ChainID
	GetCommitteeInfo() *CommitteeInfo
	StateCandidateToStateManager(state.VirtualStateAccess, ledgerstate.OutputID)
	TriggerChainTransition(*ChainTransitionEventData)
	Processors() *processors.Cache
	GlobalStateSync() coreutil.ChainStateSync
	GetStateReader() state.OptimisticStateReader
	GetChainNodes() []peering.PeerStatusProvider     // CommitteeNodes + AccessNodes
	GetCandidateNodes() []*governance.AccessNodeInfo // All the current candidates.
	Log() *logger.Logger

	// Most of these methods are made public for mocking in tests
	EnqueueDismissChain(reason string) // This one should really be public
	EnqueueLedgerState(chainOutput *ledgerstate.AliasOutput, timestamp time.Time)
	EnqueueOffLedgerRequestMsg(msg *messages.OffLedgerRequestMsgIn)
	EnqueueRequestAckMsg(msg *messages.RequestAckMsgIn)
	EnqueueMissingRequestIDsMsg(msg *messages.MissingRequestIDsMsgIn)
	EnqueueMissingRequestMsg(msg *messages.MissingRequestMsg)
	EnqueueTimerTick(tick int)
}

type ChainEntry added in v0.2.0

type ChainEntry interface {
	ReceiveTransaction(*ledgerstate.Transaction)
	ReceiveState(stateOutput *ledgerstate.AliasOutput, timestamp time.Time)
	Dismiss(reason string)
	IsDismissed() bool
}

ChainEntry interface to access chain from the chain registry side

type ChainMetrics added in v0.2.3

type ChainMetrics interface {
	GetNodeConnectionMetrics() nodeconnmetrics.NodeConnectionMessagesMetrics
	GetConsensusWorkflowStatus() ConsensusWorkflowStatus
	GetConsensusPipeMetrics() ConsensusPipeMetrics
}

type ChainNodeConnection added in v0.2.3

type ChainNodeConnection interface {
	AttachToTransactionReceived(NodeConnectionHandleTransactionFun)
	AttachToInclusionStateReceived(NodeConnectionHandleInclusionStateFun)
	AttachToOutputReceived(NodeConnectionHandleOutputFun)
	AttachToUnspentAliasOutputReceived(NodeConnectionHandleUnspentAliasOutputFun)
	PullState()
	PullTransactionInclusionState(txid ledgerstate.TransactionID)
	PullConfirmedOutput(outputID ledgerstate.OutputID)
	PostTransaction(tx *ledgerstate.Transaction)
	GetMetrics() nodeconnmetrics.NodeConnectionMessagesMetrics
	DetachFromTransactionReceived()
	DetachFromInclusionStateReceived()
	DetachFromOutputReceived()
	DetachFromUnspentAliasOutputReceived()
	Close()
}

type ChainRequests added in v0.2.0

type ChainRequests interface {
	GetRequestProcessingStatus(id iscp.RequestID) RequestProcessingStatus
	AttachToRequestProcessed(func(iscp.RequestID)) (attachID *events.Closure)
	DetachFromRequestProcessed(attachID *events.Closure)
}

ChainRequests is an interface to query status of the request

type ChainTransitionEventData added in v0.2.0

type ChainTransitionEventData struct {
	VirtualState    state.VirtualStateAccess
	ChainOutput     *ledgerstate.AliasOutput
	OutputTimestamp time.Time
}

type Committee added in v0.2.0

type Committee interface {
	Address() ledgerstate.Address
	Size() uint16
	Quorum() uint16
	OwnPeerIndex() uint16
	DKShare() *tcrypto.DKShare
	IsAlivePeer(peerIndex uint16) bool
	QuorumIsAlive(quorum ...uint16) bool
	PeerStatus() []*PeerStatus
	IsReady() bool
	Close()
	RunACSConsensus(value []byte, sessionID uint64, stateIndex uint32, callback func(sessionID uint64, acs [][]byte))
	GetRandomValidators(upToN int) []*ed25519.PublicKey // TODO: Remove after OffLedgerRequest dissemination is changed.
}

Committee is ordered (indexed 0..size-1) list of peers which run the consensus

type CommitteeInfo added in v0.2.0

type CommitteeInfo struct {
	Address       ledgerstate.Address
	Size          uint16
	Quorum        uint16
	QuorumIsAlive bool
	PeerStatus    []*PeerStatus
}

type Consensus added in v0.2.0

type Consensus interface {
	EnqueueStateTransitionMsg(state.VirtualStateAccess, *ledgerstate.AliasOutput, time.Time)
	EnqueueSignedResultMsg(*messages.SignedResultMsgIn)
	EnqueueSignedResultAckMsg(*messages.SignedResultAckMsgIn)
	EnqueueInclusionsStateMsg(ledgerstate.TransactionID, ledgerstate.InclusionState)
	EnqueueAsynchronousCommonSubsetMsg(msg *messages.AsynchronousCommonSubsetMsg)
	EnqueueVMResultMsg(msg *messages.VMResultMsg)
	EnqueueTimerMsg(messages.TimerTick)
	IsReady() bool
	Close()
	GetStatusSnapshot() *ConsensusInfo
	GetWorkflowStatus() ConsensusWorkflowStatus
	ShouldReceiveMissingRequest(req iscp.Request) bool
	GetPipeMetrics() ConsensusPipeMetrics
}

type ConsensusInfo added in v0.2.0

type ConsensusInfo struct {
	StateIndex uint32
	Mempool    MempoolInfo
	TimerTick  int
}

type ConsensusPipeMetrics added in v0.2.5

type ConsensusPipeMetrics interface {
	GetEventStateTransitionMsgPipeSize() int
	GetEventSignedResultMsgPipeSize() int
	GetEventSignedResultAckMsgPipeSize() int
	GetEventInclusionStateMsgPipeSize() int
	GetEventACSMsgPipeSize() int
	GetEventVMResultMsgPipeSize() int
	GetEventTimerMsgPipeSize() int
}

type ConsensusWorkflowStatus added in v0.2.4

type ConsensusWorkflowStatus interface {
	IsStateReceived() bool
	IsBatchProposalSent() bool
	IsConsensusBatchKnown() bool
	IsVMStarted() bool
	IsVMResultSigned() bool
	IsTransactionFinalized() bool
	IsTransactionPosted() bool
	IsTransactionSeen() bool
	IsInProgress() bool
	GetBatchProposalSentTime() time.Time
	GetConsensusBatchKnownTime() time.Time
	GetVMStartedTime() time.Time
	GetVMResultSignedTime() time.Time
	GetTransactionFinalizedTime() time.Time
	GetTransactionPostedTime() time.Time
	GetTransactionSeenTime() time.Time
	GetCompletedTime() time.Time
	GetCurrentStateIndex() uint32
}

type Mempool added in v0.2.0

type Mempool interface {
	ReceiveRequests(reqs ...iscp.Request)
	ReceiveRequest(req iscp.Request) bool
	RemoveRequests(reqs ...iscp.RequestID)
	ReadyNow(nowis ...time.Time) []iscp.Request
	ReadyFromIDs(nowis time.Time, reqIDs ...iscp.RequestID) ([]iscp.Request, []int, bool)
	HasRequest(id iscp.RequestID) bool
	GetRequest(id iscp.RequestID) iscp.Request
	Info() MempoolInfo
	WaitRequestInPool(reqid iscp.RequestID, timeout ...time.Duration) bool // for testing
	WaitInBufferEmpty(timeout ...time.Duration) bool                       // for testing
	Close()
}

type MempoolInfo added in v0.2.0

type MempoolInfo struct {
	TotalPool      int
	ReadyCounter   int
	InBufCounter   int
	OutBufCounter  int
	InPoolCounter  int
	OutPoolCounter int
}

type NodeConnection added in v0.2.0

type NodeConnection interface {
	Subscribe(addr ledgerstate.Address)
	Unsubscribe(addr ledgerstate.Address)
	AttachToTransactionReceived(*ledgerstate.AliasAddress, NodeConnectionHandleTransactionFun)
	AttachToInclusionStateReceived(*ledgerstate.AliasAddress, NodeConnectionHandleInclusionStateFun)
	AttachToOutputReceived(*ledgerstate.AliasAddress, NodeConnectionHandleOutputFun)
	AttachToUnspentAliasOutputReceived(*ledgerstate.AliasAddress, NodeConnectionHandleUnspentAliasOutputFun)
	PullState(addr *ledgerstate.AliasAddress)
	PullTransactionInclusionState(addr ledgerstate.Address, txid ledgerstate.TransactionID)
	PullConfirmedOutput(addr ledgerstate.Address, outputID ledgerstate.OutputID)
	PostTransaction(tx *ledgerstate.Transaction)
	GetMetrics() nodeconnmetrics.NodeConnectionMetrics
	DetachFromTransactionReceived(*ledgerstate.AliasAddress)
	DetachFromInclusionStateReceived(*ledgerstate.AliasAddress)
	DetachFromOutputReceived(*ledgerstate.AliasAddress)
	DetachFromUnspentAliasOutputReceived(*ledgerstate.AliasAddress)
	Close()
}

type NodeConnectionHandleInclusionStateFun added in v0.2.3

type NodeConnectionHandleInclusionStateFun func(ledgerstate.TransactionID, ledgerstate.InclusionState)

type NodeConnectionHandleOutputFun added in v0.2.3

type NodeConnectionHandleOutputFun func(ledgerstate.Output)

type NodeConnectionHandleTransactionFun added in v0.2.3

type NodeConnectionHandleTransactionFun func(*ledgerstate.Transaction)

type NodeConnectionHandleUnspentAliasOutputFun added in v0.2.3

type NodeConnectionHandleUnspentAliasOutputFun func(*ledgerstate.AliasOutput, time.Time)

type PeerStatus

type PeerStatus struct {
	Index     int
	PubKey    *ed25519.PublicKey
	NetID     string
	Connected bool
}

func (*PeerStatus) String

func (p *PeerStatus) String() string

type ReadyListRecord added in v0.2.0

type ReadyListRecord struct {
	Request iscp.Request
	Seen    map[uint16]bool
}

type RequestProcessingStatus

type RequestProcessingStatus int

type StateManager

type StateManager interface {
	Ready() *ready.Ready
	EnqueueGetBlockMsg(msg *messages.GetBlockMsgIn)
	EnqueueBlockMsg(msg *messages.BlockMsgIn)
	EnqueueStateMsg(msg *messages.StateMsg)
	EnqueueOutputMsg(msg ledgerstate.Output)
	EnqueueStateCandidateMsg(state.VirtualStateAccess, ledgerstate.OutputID)
	EnqueueTimerMsg(msg messages.TimerTick)
	GetStatusSnapshot() *SyncInfo
	SetChainPeers(peers []*ed25519.PublicKey)
	Close()
}

type SyncInfo added in v0.2.0

type SyncInfo struct {
	Synced                bool
	SyncedBlockIndex      uint32
	SyncedStateHash       hashing.HashValue
	SyncedStateTimestamp  time.Time
	StateOutputBlockIndex uint32
	StateOutputID         ledgerstate.OutputID
	StateOutputHash       hashing.HashValue
	StateOutputTimestamp  time.Time
}

type WAL added in v0.2.4

type WAL interface {
	Write(bytes []byte) error
	Contains(i uint32) bool
	Read(i uint32) ([]byte, error)
}

Directories

Path Synopsis
Provides implementations for chain.ChainCore methods except the Enqueue*, which are provided in eventproc.go Provides implementations for chain.ChainEntry methods Provides implementations for chain.ChainMetrics methods Provides implementations for chain.ChainRequests methods
Provides implementations for chain.ChainCore methods except the Enqueue*, which are provided in eventproc.go Provides implementations for chain.ChainEntry methods Provides implementations for chain.ChainMetrics methods Provides implementations for chain.ChainRequests methods
commoncoin
Package commoncoin implements a common coin abstraction needed by the HoneyBadgerBFT for synchronization and randomness.
Package commoncoin implements a common coin abstraction needed by the HoneyBadgerBFT for synchronization and randomness.
mempool implements a buffer of requests sent to the ISCP chain, essentially a backlog of requests It contains both on-ledger and off-ledger requests.
mempool implements a buffer of requests sent to the ISCP chain, essentially a backlog of requests It contains both on-ledger and off-ledger requests.
Provides implementations for chain.ChainNodeConnection methods
Provides implementations for chain.ChainNodeConnection methods
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