factory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootstrapComponentsName is the bootstrap components identifier
	BootstrapComponentsName = "managedBootstrapComponents"
	// ConsensusComponentsName is the consensus components identifier
	ConsensusComponentsName = "managedConsensusComponents"
	// CoreComponentsName is the core components identifier
	CoreComponentsName = "managedCoreComponents"
	// StatusCoreComponentsName is the status core components identifier
	StatusCoreComponentsName = "managedStatusCoreComponents"
	// CryptoComponentsName is the crypto components identifier
	CryptoComponentsName = "managedCryptoComponents"
	// DataComponentsName is the data components identifier
	DataComponentsName = "managedDataComponents"
	// HeartbeatV2ComponentsName is the heartbeat V2 components identifier
	HeartbeatV2ComponentsName = "managedHeartbeatV2Components"
	// NetworkComponentsName is the network components identifier
	NetworkComponentsName = "managedNetworkComponents"
	// ProcessComponentsName is the process components identifier
	ProcessComponentsName = "managedProcessComponents"
	// StateComponentsName is the state components identifier
	StateComponentsName = "managedStateComponents"
	// StatusComponentsName is the status components identifier
	StatusComponentsName = "managedStatusComponents"
)

Variables

This section is empty.

Functions

func DecodeAddresses

func DecodeAddresses(pkConverter core.PubkeyConverter, stringAddresses []string) ([][]byte, error)

DecodeAddresses will decode the provided string addresses

Types

type BootstrapComponentsHandler

type BootstrapComponentsHandler interface {
	ComponentHandler
	BootstrapComponentsHolder
}

BootstrapComponentsHandler defines the bootstrap components handler actions

type BootstrapComponentsHolder

type BootstrapComponentsHolder interface {
	EpochStartBootstrapper() EpochStartBootstrapper
	EpochBootstrapParams() BootstrapParamsHolder
	NodeType() core.NodeType
	ShardCoordinator() sharding.Coordinator
	VersionedHeaderFactory() factory.VersionedHeaderFactory
	HeaderVersionHandler() factory.HeaderVersionHandler
	HeaderIntegrityVerifier() factory.HeaderIntegrityVerifierHandler
	GuardedAccountHandler() process.GuardedAccountHandler
	NodesCoordinatorRegistryFactory() nodesCoordinator.NodesCoordinatorRegistryFactory
	IsInterfaceNil() bool
}

BootstrapComponentsHolder holds the bootstrap components

type BootstrapParamsHolder

type BootstrapParamsHolder interface {
	Epoch() uint32
	SelfShardID() uint32
	NumOfShards() uint32
	NodesConfig() nodesCoordinator.NodesCoordinatorRegistryHandler
	IsInterfaceNil() bool
}

BootstrapParamsHolder gives read access to parameters after bootstrap

type Closer

type Closer interface {
	Close() error
}

Closer defines the Close behavior

type ComponentHandler

type ComponentHandler interface {
	Create() error
	Close() error
	CheckSubcomponents() error
	String() string
}

ComponentHandler defines the actions common to all component handlers

type ConsensusComponentsHandler

type ConsensusComponentsHandler interface {
	ComponentHandler
	ConsensusComponentsHolder
}

ConsensusComponentsHandler defines the consensus components handler actions

type ConsensusComponentsHolder

type ConsensusComponentsHolder interface {
	Chronology() consensus.ChronologyHandler
	ConsensusWorker() ConsensusWorker
	BroadcastMessenger() consensus.BroadcastMessenger
	ConsensusGroupSize() (int, error)
	Bootstrapper() process.Bootstrapper
	IsInterfaceNil() bool
}

ConsensusComponentsHolder holds the consensus components

type ConsensusWorker

type ConsensusWorker interface {
	Close() error
	StartWorking()
	// AddReceivedMessageCall adds a new handler function for a received message type
	AddReceivedMessageCall(messageType consensus.MessageType, receivedMessageCall func(ctx context.Context, cnsDta *consensus.Message) bool)
	// AddReceivedHeaderHandler adds a new handler function for a received header
	AddReceivedHeaderHandler(handler func(data.HeaderHandler))
	// RemoveAllReceivedMessagesCalls removes all the functions handlers
	RemoveAllReceivedMessagesCalls()
	// ProcessReceivedMessage method redirects the received message to the channel which should handle it
	ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID, source p2p.MessageHandler) error
	// Extend does an extension for the subround with subroundId
	Extend(subroundId int)
	// GetConsensusStateChangedChannel gets the channel for the consensusStateChanged
	GetConsensusStateChangedChannel() chan bool
	// ExecuteStoredMessages tries to execute all the messages received which are valid for execution
	ExecuteStoredMessages()
	// DisplayStatistics method displays statistics of worker at the end of the round
	DisplayStatistics()
	// ResetConsensusMessages resets at the start of each round all the previous consensus messages received
	ResetConsensusMessages()
	// ReceivedHeader method is a wired method through which worker will receive headers from network
	ReceivedHeader(headerHandler data.HeaderHandler, headerHash []byte)
	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool
}

ConsensusWorker is the consensus worker handle for the exported functionality

type CoreComponentsHandler

type CoreComponentsHandler interface {
	ComponentHandler
	CoreComponentsHolder
}

CoreComponentsHandler defines the core components handler actions

type CoreComponentsHolder

type CoreComponentsHolder interface {
	InternalMarshalizer() marshal.Marshalizer
	SetInternalMarshalizer(marshalizer marshal.Marshalizer) error
	TxMarshalizer() marshal.Marshalizer
	VmMarshalizer() marshal.Marshalizer
	Hasher() hashing.Hasher
	TxSignHasher() hashing.Hasher
	Uint64ByteSliceConverter() typeConverters.Uint64ByteSliceConverter
	AddressPubKeyConverter() core.PubkeyConverter
	ValidatorPubKeyConverter() core.PubkeyConverter
	PathHandler() storage.PathManagerHandler
	Watchdog() core.WatchdogTimer
	AlarmScheduler() core.TimersScheduler
	SyncTimer() ntp.SyncTimer
	RoundHandler() consensus.RoundHandler
	EconomicsData() process.EconomicsDataHandler
	APIEconomicsData() process.EconomicsDataHandler
	RatingsData() process.RatingsInfoHandler
	Rater() sharding.PeerAccountListAndRatingHandler
	GenesisNodesSetup() sharding.GenesisNodesSetupHandler
	NodesShuffler() nodesCoordinator.NodesShuffler
	EpochNotifier() process.EpochNotifier
	EnableRoundsHandler() process.EnableRoundsHandler
	RoundNotifier() process.RoundNotifier
	EpochStartNotifierWithConfirm() EpochStartNotifierWithConfirm
	ChanStopNodeProcess() chan endProcess.ArgEndProcess
	GenesisTime() time.Time
	ChainID() string
	MinTransactionVersion() uint32
	TxVersionChecker() process.TxVersionCheckerHandler
	EncodedAddressLen() uint32
	NodeTypeProvider() core.NodeTypeProviderHandler
	WasmVMChangeLocker() common.Locker
	ProcessStatusHandler() common.ProcessStatusHandler
	HardforkTriggerPubKey() []byte
	EnableEpochsHandler() common.EnableEpochsHandler
	IsInterfaceNil() bool
}

CoreComponentsHolder holds the core components

type CryptoComponentsHandler

type CryptoComponentsHandler interface {
	ComponentHandler
	CryptoComponentsHolder
}

CryptoComponentsHandler defines the crypto components handler actions

type CryptoComponentsHolder

type CryptoComponentsHolder interface {
	CryptoParamsHolder
	P2pPublicKey() crypto.PublicKey
	P2pPrivateKey() crypto.PrivateKey
	P2pSingleSigner() crypto.SingleSigner
	TxSingleSigner() crypto.SingleSigner
	BlockSigner() crypto.SingleSigner
	SetMultiSignerContainer(container cryptoCommon.MultiSignerContainer) error
	MultiSignerContainer() cryptoCommon.MultiSignerContainer
	GetMultiSigner(epoch uint32) (crypto.MultiSigner, error)
	PeerSignatureHandler() crypto.PeerSignatureHandler
	BlockSignKeyGen() crypto.KeyGenerator
	TxSignKeyGen() crypto.KeyGenerator
	P2pKeyGen() crypto.KeyGenerator
	MessageSignVerifier() vm.MessageSignVerifier
	ConsensusSigningHandler() consensus.SigningHandler
	ManagedPeersHolder() common.ManagedPeersHolder
	KeysHandler() consensus.KeysHandler
	Clone() interface{}
	IsInterfaceNil() bool
}

CryptoComponentsHolder holds the crypto components

type CryptoParamsHolder

type CryptoParamsHolder interface {
	PublicKey() crypto.PublicKey
	PrivateKey() crypto.PrivateKey
	PublicKeyString() string
	PublicKeyBytes() []byte
}

CryptoParamsHolder permits access to crypto parameters such as the private and public keys

type DataComponentsHandler

type DataComponentsHandler interface {
	ComponentHandler
	DataComponentsHolder
}

DataComponentsHandler defines the data components handler actions

type DataComponentsHolder

type DataComponentsHolder interface {
	Blockchain() data.ChainHandler
	SetBlockchain(chain data.ChainHandler) error
	StorageService() dataRetriever.StorageService
	Datapool() dataRetriever.PoolsHolder
	MiniBlocksProvider() MiniBlockProvider
	Clone() interface{}
	IsInterfaceNil() bool
}

DataComponentsHolder holds the data components

type EconomicsHandler

type EconomicsHandler interface {
	LeaderPercentage() float64
	ProtocolSustainabilityPercentage() float64
	ProtocolSustainabilityAddress() string
	MinInflationRate() float64
	MaxInflationRate(year uint32) float64
	DeveloperPercentage() float64
	GenesisTotalSupply() *big.Int
	MaxGasLimitPerBlock(shardID uint32) uint64
	ComputeGasLimit(tx data.TransactionWithFeeHandler) uint64
	ComputeMoveBalanceFee(tx data.TransactionWithFeeHandler) *big.Int
	CheckValidityTxValues(tx data.TransactionWithFeeHandler) error
	MinGasPrice() uint64
	MinGasLimit() uint64
	GasPerDataByte() uint64
	GasPriceModifier() float64
	ComputeFeeForProcessing(tx data.TransactionWithFeeHandler, gasToUse uint64) *big.Int
	IsInterfaceNil() bool
}

EconomicsHandler provides some economics related computation and read access to economics data

type EpochStartBootstrapper

type EpochStartBootstrapper interface {
	Bootstrap() (bootstrap.Parameters, error)
	IsInterfaceNil() bool
	Close() error
}

EpochStartBootstrapper defines the epoch start bootstrap functionality

type EpochStartNotifier

type EpochStartNotifier interface {
	RegisterHandler(handler epochStart.ActionHandler)
	UnregisterHandler(handler epochStart.ActionHandler)
	NotifyAll(hdr data.HeaderHandler)
	NotifyAllPrepare(metaHdr data.HeaderHandler, body data.BodyHandler)
	NotifyEpochChangeConfirmed(epoch uint32)
	IsInterfaceNil() bool
}

EpochStartNotifier defines which actions should be done for handling new epoch's events

type EpochStartNotifierWithConfirm

type EpochStartNotifierWithConfirm interface {
	EpochStartNotifier
	RegisterForEpochChangeConfirmed(handler func(epoch uint32))
}

EpochStartNotifierWithConfirm defines which actions should be done for handling new epoch's events and confirmation

type HardforkTrigger

type HardforkTrigger interface {
	SetExportFactoryHandler(exportFactoryHandler update.ExportFactoryHandler) error
	TriggerReceived(payload []byte, data []byte, pkBytes []byte) (bool, error)
	RecordedTriggerMessage() ([]byte, bool)
	Trigger(epoch uint32, withEarlyEndOfEpoch bool) error
	CreateData() []byte
	AddCloser(closer update.Closer) error
	NotifyTriggerReceivedV2() <-chan struct{}
	IsSelfTrigger() bool
	IsInterfaceNil() bool
}

HardforkTrigger defines the hard-fork trigger functionality

type HeartbeatV2ComponentsHandler

type HeartbeatV2ComponentsHandler interface {
	ComponentHandler
	HeartbeatV2ComponentsHolder
}

HeartbeatV2ComponentsHandler defines the heartbeatV2 components handler actions

type HeartbeatV2ComponentsHolder

type HeartbeatV2ComponentsHolder interface {
	Monitor() HeartbeatV2Monitor
	IsInterfaceNil() bool
}

HeartbeatV2ComponentsHolder holds the heartbeatV2 components

type HeartbeatV2Monitor

type HeartbeatV2Monitor interface {
	GetHeartbeats() []heartbeatData.PubKeyHeartbeat
	IsInterfaceNil() bool
}

HeartbeatV2Monitor monitors the cache of heartbeatV2 messages

type KeyLoaderHandler

type KeyLoaderHandler interface {
	LoadKey(string, int) ([]byte, string, error)
	LoadAllKeys(path string) ([][]byte, []string, error)
	IsInterfaceNil() bool
}

KeyLoaderHandler defines the loading of a key from a pem file and index

type LogsFacade

type LogsFacade interface {
	GetLog(logKey []byte, epoch uint32) (*transaction.ApiLogs, error)
	IncludeLogsInTransactions(txs []*transaction.ApiTransactionResult, logsKeys [][]byte, epoch uint32) error
	IsInterfaceNil() bool
}

LogsFacade defines the interface of a logs facade

type MiniBlockProvider

type MiniBlockProvider interface {
	GetMiniBlocks(hashes [][]byte) ([]*block.MiniblockAndHash, [][]byte)
	GetMiniBlocksFromPool(hashes [][]byte) ([]*block.MiniblockAndHash, [][]byte)
	GetMiniBlocksFromStorer(hashes [][]byte) ([]*block.MiniblockAndHash, [][]byte)
	IsInterfaceNil() bool
}

MiniBlockProvider defines what a miniblock data provider should do

type NetworkComponentsHandler

type NetworkComponentsHandler interface {
	ComponentHandler
	NetworkComponentsHolder
}

NetworkComponentsHandler defines the network components handler actions

type NetworkComponentsHolder

type NetworkComponentsHolder interface {
	NetworkMessenger() p2p.Messenger
	InputAntiFloodHandler() P2PAntifloodHandler
	OutputAntiFloodHandler() P2PAntifloodHandler
	PubKeyCacher() process.TimeCacher
	PeerBlackListHandler() process.PeerBlackListCacher
	PeerHonestyHandler() PeerHonestyHandler
	PreferredPeersHolderHandler() PreferredPeersHolderHandler
	PeersRatingHandler() p2p.PeersRatingHandler
	PeersRatingMonitor() p2p.PeersRatingMonitor
	FullArchiveNetworkMessenger() p2p.Messenger
	FullArchivePreferredPeersHolderHandler() PreferredPeersHolderHandler
	IsInterfaceNil() bool
}

NetworkComponentsHolder holds the network components

type NetworkStatisticsProvider

type NetworkStatisticsProvider interface {
	BpsSent() uint64
	BpsRecv() uint64
	BpsSentPeak() uint64
	BpsRecvPeak() uint64
	PercentSent() uint64
	PercentRecv() uint64
	TotalBytesSentInCurrentEpoch() uint64
	TotalBytesReceivedInCurrentEpoch() uint64
	TotalSentInCurrentEpoch() string
	TotalReceivedInCurrentEpoch() string
	EpochConfirmed(epoch uint32, timestamp uint64)
	Close() error
	IsInterfaceNil() bool
}

NetworkStatisticsProvider is able to provide network statistics

type P2PAntifloodHandler

type P2PAntifloodHandler interface {
	CanProcessMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
	CanProcessMessagesOnTopic(peer core.PeerID, topic string, numMessages uint32, totalSize uint64, sequence []byte) error
	ResetForTopic(topic string)
	SetMaxMessagesForTopic(topic string, maxNum uint32)
	SetDebugger(debugger process.AntifloodDebugger) error
	SetPeerValidatorMapper(validatorMapper process.PeerValidatorMapper) error
	SetTopicsForAll(topics ...string)
	ApplyConsensusSize(size int)
	BlacklistPeer(peer core.PeerID, reason string, duration time.Duration)
	IsOriginatorEligibleForTopic(pid core.PeerID, topic string) error
	Close() error
	IsInterfaceNil() bool
}

P2PAntifloodHandler defines the behavior of a component able to signal that the system is too busy (or flooded) processing p2p messages

type PeerHonestyHandler

type PeerHonestyHandler interface {
	ChangeScore(pk string, topic string, units int)
	IsInterfaceNil() bool
	Close() error
}

PeerHonestyHandler defines the behaivour of a component able to handle/monitor the peer honesty of nodes which are participating in consensus

type PersistentStatusHandler

type PersistentStatusHandler interface {
	core.AppStatusHandler
	SetStorage(store storage.Storer) error
}

PersistentStatusHandler defines a persistent status handler

type PreferredPeersHolderHandler

type PreferredPeersHolderHandler interface {
	PutConnectionAddress(peerID core.PeerID, address string)
	PutShardID(peerID core.PeerID, shardID uint32)
	Get() map[uint32][]core.PeerID
	Contains(peerID core.PeerID) bool
	Remove(peerID core.PeerID)
	Clear()
	IsInterfaceNil() bool
}

PreferredPeersHolderHandler defines the behavior of a component able to handle preferred peers operations

type ProcessComponentsHandler

type ProcessComponentsHandler interface {
	ComponentHandler
	ProcessComponentsHolder
}

ProcessComponentsHandler defines the process components handler actions

type ProcessComponentsHolder

type ProcessComponentsHolder interface {
	NodesCoordinator() nodesCoordinator.NodesCoordinator
	ShardCoordinator() sharding.Coordinator
	InterceptorsContainer() process.InterceptorsContainer
	FullArchiveInterceptorsContainer() process.InterceptorsContainer
	ResolversContainer() dataRetriever.ResolversContainer
	RequestersFinder() dataRetriever.RequestersFinder
	RoundHandler() consensus.RoundHandler
	EpochStartTrigger() epochStart.TriggerHandler
	EpochStartNotifier() EpochStartNotifier
	ForkDetector() process.ForkDetector
	BlockProcessor() process.BlockProcessor
	BlackListHandler() process.TimeCacher
	BootStorer() process.BootStorer
	HeaderSigVerifier() process.InterceptedHeaderSigVerifier
	HeaderIntegrityVerifier() process.HeaderIntegrityVerifier
	ValidatorsStatistics() process.ValidatorStatisticsProcessor
	ValidatorsProvider() process.ValidatorsProvider
	BlockTracker() process.BlockTracker
	PendingMiniBlocksHandler() process.PendingMiniBlocksHandler
	RequestHandler() process.RequestHandler
	TxLogsProcessor() process.TransactionLogProcessorDatabase
	HeaderConstructionValidator() process.HeaderConstructionValidator
	PeerShardMapper() process.NetworkShardingCollector
	FullArchivePeerShardMapper() process.NetworkShardingCollector
	FallbackHeaderValidator() process.FallbackHeaderValidator
	APITransactionEvaluator() TransactionEvaluator
	WhiteListHandler() process.WhiteListHandler
	WhiteListerVerifiedTxs() process.WhiteListHandler
	HistoryRepository() dblookupext.HistoryRepository
	ImportStartHandler() update.ImportStartHandler
	RequestedItemsHandler() dataRetriever.RequestedItemsHandler
	NodeRedundancyHandler() consensus.NodeRedundancyHandler
	CurrentEpochProvider() process.CurrentNetworkEpochProviderHandler
	ScheduledTxsExecutionHandler() process.ScheduledTxsExecutionHandler
	TxsSenderHandler() process.TxsSenderHandler
	HardforkTrigger() HardforkTrigger
	ProcessedMiniBlocksTracker() process.ProcessedMiniBlocksTracker
	DCDTDataStorageHandlerForAPI() vmcommon.DCDTNFTStorageHandler
	AccountsParser() genesis.AccountsParser
	ReceiptsRepository() ReceiptsRepository
	SentSignaturesTracker() process.SentSignaturesTracker
	EpochSystemSCProcessor() process.EpochStartSystemSCProcessor
	IsInterfaceNil() bool
}

ProcessComponentsHolder holds the process components

type ProcessDebuggerSetter

type ProcessDebuggerSetter interface {
	SetProcessDebugger(debugger process.Debugger) error
}

ProcessDebuggerSetter allows setting a debugger on the process component

type ReceiptsRepository

type ReceiptsRepository interface {
	SaveReceipts(holder common.ReceiptsHolder, header data.HeaderHandler, headerHash []byte) error
	LoadReceipts(header data.HeaderHandler, headerHash []byte) (common.ReceiptsHolder, error)
	IsInterfaceNil() bool
}

ReceiptsRepository defines the interface of a receiptsRepository

type ResourceMonitor

type ResourceMonitor interface {
	Close() error
	IsInterfaceNil() bool
}

ResourceMonitor defines the function implemented by a struct that can monitor resources

type ShuffleOutCloser

type ShuffleOutCloser interface {
	EndOfProcessingHandler(event endProcess.ArgEndProcess) error
	IsInterfaceNil() bool
	Close() error
}

ShuffleOutCloser defines the action for end of processing

type StateComponentsHandler

type StateComponentsHandler interface {
	ComponentHandler
	StateComponentsHolder
}

StateComponentsHandler defines the state components handler actions

type StateComponentsHolder

type StateComponentsHolder interface {
	PeerAccounts() state.AccountsAdapter
	AccountsAdapter() state.AccountsAdapter
	AccountsAdapterAPI() state.AccountsAdapter
	AccountsRepository() state.AccountsRepository
	TriesContainer() common.TriesHolder
	TrieStorageManagers() map[string]common.StorageManager
	MissingTrieNodesNotifier() common.MissingTrieNodesNotifier
	Close() error
	IsInterfaceNil() bool
}

StateComponentsHolder holds the

type StatusComponentsHandler

type StatusComponentsHandler interface {
	ComponentHandler
	StatusComponentsHolder
	// SetForkDetector should be set before starting Polling for updates
	SetForkDetector(forkDetector process.ForkDetector) error
	StartPolling() error
	ManagedPeersMonitor() common.ManagedPeersMonitor
}

StatusComponentsHandler defines the status components handler actions

type StatusComponentsHolder

type StatusComponentsHolder interface {
	OutportHandler() outport.OutportHandler
	SoftwareVersionChecker() statistics.SoftwareVersionChecker
	ManagedPeersMonitor() common.ManagedPeersMonitor
	IsInterfaceNil() bool
}

StatusComponentsHolder holds the status components

type StatusCoreComponentsHandler

type StatusCoreComponentsHandler interface {
	ComponentHandler
	StatusCoreComponentsHolder
}

StatusCoreComponentsHandler defines the status core components handler actions

type StatusCoreComponentsHolder

type StatusCoreComponentsHolder interface {
	ResourceMonitor() ResourceMonitor
	NetworkStatistics() NetworkStatisticsProvider
	TrieSyncStatistics() TrieSyncStatisticsProvider
	AppStatusHandler() core.AppStatusHandler
	StatusMetrics() external.StatusMetricsHandler
	PersistentStatusHandler() PersistentStatusHandler
	StateStatsHandler() common.StateStatisticsHandler
	IsInterfaceNil() bool
}

StatusCoreComponentsHolder holds the status core components

type TransactionEvaluator

type TransactionEvaluator interface {
	SimulateTransactionExecution(tx *transaction.Transaction) (*txSimData.SimulationResultsWithVMOutput, error)
	ComputeTransactionGasLimit(tx *transaction.Transaction) (*transaction.CostResponse, error)
	IsInterfaceNil() bool
}

TransactionEvaluator defines the transaction evaluator actions

type TrieSyncStatisticsProvider

type TrieSyncStatisticsProvider interface {
	data.SyncStatisticsHandler
	AddNumBytesReceived(bytes uint64)
	NumBytesReceived() uint64
	NumTries() int
	AddProcessingTime(duration time.Duration)
	IncrementIteration()
	ProcessingTime() time.Duration
	NumIterations() int
}

TrieSyncStatisticsProvider is able to provide trie sync statistics

Jump to

Keyboard shortcuts

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