chain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0, BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestProcessingStatusUnknown = RequestProcessingStatus(iota)
	RequestProcessingStatusBacklog
	RequestProcessingStatusCompleted
)
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))
	TryHandleMessage(recv *peering.RecvEvent) bool
	Close()
}

type Chain

type Chain interface {
	ChainCore
	ChainRequests
	ChainEntry
}

type ChainCore added in v0.2.0

type ChainCore interface {
	ID() *iscp.ChainID
	GetCommitteeInfo() *CommitteeInfo
	ReceiveMessage(interface{})
	Events() ChainEvents
	Processors() *processors.Cache
	GlobalStateSync() coreutil.ChainStateSync
	GetStateReader() state.OptimisticStateReader
	Log() *logger.Logger
}

type ChainEntry added in v0.2.0

type ChainEntry interface {
	ReceiveTransaction(*ledgerstate.Transaction)
	ReceiveInclusionState(ledgerstate.TransactionID, ledgerstate.InclusionState)
	ReceiveState(stateOutput *ledgerstate.AliasOutput, timestamp time.Time)
	ReceiveOutput(output ledgerstate.Output)
	ReceiveOffLedgerRequest(req *request.OffLedger, senderNetID string)

	Dismiss(reason string)
	IsDismissed() bool
}

ChainEntry interface to access chain from the chain registry side

type ChainEvents added in v0.2.0

type ChainEvents interface {
	RequestProcessed() *events.Event
	ChainTransition() *events.Event
}

type ChainRequests added in v0.2.0

type ChainRequests interface {
	GetRequestProcessingStatus(id iscp.RequestID) RequestProcessingStatus
	EventRequestProcessed() *events.Event
}

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
	SendMsg(targetPeerIndex uint16, msgType byte, msgData []byte) error
	SendMsgToPeers(msgType byte, msgData []byte, ts int64, except ...uint16)
	IsAlivePeer(peerIndex uint16) bool
	QuorumIsAlive(quorum ...uint16) bool
	PeerStatus() []*PeerStatus
	Attach(chain ChainCore)
	IsReady() bool
	Close()
	RunACSConsensus(value []byte, sessionID uint64, stateIndex uint32, callback func(sessionID uint64, acs [][]byte))
	GetOtherValidatorsPeerIDs() []string
	GetRandomValidators(upToN int) []string
}

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 {
	EventStateTransitionMsg(*messages.StateTransitionMsg)
	EventSignedResultMsg(*messages.SignedResultMsg)
	EventSignedResultAckMsg(*messages.SignedResultAckMsg)
	EventInclusionsStateMsg(*messages.InclusionStateMsg)
	EventAsynchronousCommonSubsetMsg(msg *messages.AsynchronousCommonSubsetMsg)
	EventVMResultMsg(msg *messages.VMResultMsg)
	EventTimerMsg(messages.TimerTick)
	IsReady() bool
	Close()
	GetStatusSnapshot() *ConsensusInfo
	ShouldReceiveMissingRequest(req iscp.Request) bool
}

type ConsensusInfo added in v0.2.0

type ConsensusInfo struct {
	StateIndex uint32
	Mempool    MempoolInfo
	TimerTick  int
}

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 {
	PullBacklog(addr *ledgerstate.AliasAddress)
	PullState(addr *ledgerstate.AliasAddress)
	PullConfirmedTransaction(addr ledgerstate.Address, txid ledgerstate.TransactionID)
	PullTransactionInclusionState(addr ledgerstate.Address, txid ledgerstate.TransactionID)
	PullConfirmedOutput(addr ledgerstate.Address, outputID ledgerstate.OutputID)
	PostTransaction(tx *ledgerstate.Transaction)
}

type PeerStatus

type PeerStatus struct {
	Index     int
	PeeringID string
	IsSelf    bool
	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
	EventGetBlockMsg(msg *messages.GetBlockMsg)
	EventBlockMsg(msg *messages.BlockMsg)
	EventStateMsg(msg *messages.StateMsg)
	EventOutputMsg(msg ledgerstate.Output)
	EventStateCandidateMsg(msg *messages.StateCandidateMsg)
	EventTimerMsg(msg messages.TimerTick)
	GetStatusSnapshot() *SyncInfo
	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
}

Directories

Path Synopsis
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.
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