common

package
v0.35.13 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: AGPL-3.0 Imports: 40 Imported by: 15

Documentation

Index

Constants

View Source
const (
	DefaultAccessNodeIDSMinimumMainnet = 2
	DefaultAccessNodeIDSMinimum        = 1
)

Variables

This section is empty.

Functions

func ConstructClusterAssignment added in v0.33.30

func ConstructClusterAssignment(log zerolog.Logger, partnerNodes, internalNodes flow.IdentityList, numCollectionClusters int) (flow.AssignmentList, flow.ClusterList, error)

ConstructClusterAssignment generates a partially randomized collector cluster assignment with internal and partner nodes. The number of nodes in each cluster is deterministic and only depends on the number of clusters and the number of nodes. The repartition of internal and partner nodes is also deterministic and only depends on the number of clusters and nodes. The identity of internal and partner nodes in each cluster is the non-deterministic and is randomized using the system entropy. The function guarantees a specific constraint when partitioning the nodes into clusters: Each cluster must contain strictly more than 2/3 of internal nodes. If the constraint can't be satisfied, an exception is returned. Note that if an exception is returned with a certain number of internal/partner nodes, there is no chance of succeeding the assignment by re-running the function without increasing the internal nodes ratio. Args: - log: the logger instance. - partnerNodes: identity list of partner nodes. - internalNodes: identity list of internal nodes. - numCollectionClusters: the number of clusters to generate Returns: - flow.AssignmentList: the generated assignment list. - flow.ClusterList: the generate collection cluster list. - error: if any error occurs. Any error returned from this function is irrecoverable.

func ConstructRootQCsForClusters added in v0.33.30

func ConstructRootQCsForClusters(log zerolog.Logger, clusterList flow.ClusterList, nodeInfos []bootstrap.NodeInfo, clusterBlocks []*cluster.Block) []*flow.QuorumCertificate

ConstructRootQCsForClusters constructs a root QC for each cluster in the list. Args: - log: the logger instance. - clusterList: list of clusters - nodeInfos: list of NodeInfos (must contain all internal nodes) - clusterBlocks: list of root blocks for each cluster Returns: - flow.AssignmentList: the generated assignment list. - flow.ClusterList: the generate collection cluster list.

func ConvertClusterAssignmentsCdc added in v0.33.30

func ConvertClusterAssignmentsCdc(assignments flow.AssignmentList) cadence.Array

ConvertClusterAssignmentsCdc converts golang cluster assignments type to Cadence type `[[String]]`.

func ConvertClusterQcsCdc added in v0.33.30

func ConvertClusterQcsCdc(qcs []*flow.QuorumCertificate, clusterList flow.ClusterList) ([]*flow.ClusterQCVoteData, error)

ConvertClusterQcsCdc converts cluster QCs from `QuorumCertificate` type to `ClusterQCVoteData` type.

func FilesInDir added in v0.33.30

func FilesInDir(dir string) ([]string, error)

func GetNodeInfoForProposedNodesScript added in v0.25.0

func GetNodeInfoForProposedNodesScript(network string) ([]byte, error)

GetNodeInfoForProposedNodesScript returns a script that will return an array of FlowIDTableStaking.NodeInfo for each node in the proposed table.

func GetSnapshot added in v0.33.30

func GetSnapshot(ctx context.Context, client *grpc.Client) (*inmem.Snapshot, error)

GetSnapshot will attempt to get the latest finalized protocol snapshot with the given flow configs

func GetSnapshotAtEpochAndPhase added in v0.33.30

func GetSnapshotAtEpochAndPhase(ctx context.Context, log zerolog.Logger, startupEpoch uint64, startupEpochPhase flow.EpochPhase, retryInterval time.Duration, getSnapshot GetProtocolSnapshot) (protocol.Snapshot, error)

GetSnapshotAtEpochAndPhase will get the latest finalized protocol snapshot and check the current epoch and epoch phase. If we are past the target epoch and epoch phase we exit the retry mechanism immediately. If not check the snapshot at the specified interval until we reach the target epoch and phase. Args: - ctx: context used when getting the snapshot from the network. - log: the logger - startupEpoch: the desired epoch in which to take a snapshot for startup. - startupEpochPhase: the desired epoch phase in which to take a snapshot for startup. - retryInterval: sleep interval used to retry getting the snapshot from the network in our desired epoch and epoch phase. - getSnapshot: func used to get the snapshot. Returns: - protocol.Snapshot: the protocol snapshot. - error: if any error occurs. Any error returned from this function is irrecoverable.

func InitProtocolState added in v0.12.0

func InitProtocolState(db *badger.DB, storages *storage.All) (protocol.State, error)

func InitStorage

func InitStorage(datadir string) *badger.DB

func InitStorageWithTruncate added in v0.11.0

func InitStorageWithTruncate(datadir string, truncate bool) *badger.DB

func InitStorages added in v0.12.0

func InitStorages(db *badger.DB) *storage.All

func NodeCountByRole added in v0.33.30

func NodeCountByRole(nodes []bootstrap.NodeInfo) map[flow.Role]uint16

func PathExists added in v0.33.30

func PathExists(path string) (bool, error)

PathExists

func PrettyPrint added in v0.13.0

func PrettyPrint(entity interface{})

PrettyPrint an interface

func PrettyPrintEntity added in v0.12.0

func PrettyPrintEntity(entity flow.Entity)

PrettyPrintEntity pretty print a flow entity

func PubKeyToString added in v0.33.30

func PubKeyToString(key crypto.PublicKey) string

func ReadFullInternalNodeInfos added in v0.33.30

func ReadFullInternalNodeInfos(log zerolog.Logger, internalNodePrivInfoDir, internalWeightsConfig string) ([]bootstrap.NodeInfo, error)

ReadFullInternalNodeInfos reads internal node info and internal node weight information from the specified paths and constructs a list of full bootstrap.NodeInfo for each internal node. Args: - log: logger used to log debug information. - internalNodePrivInfoDir: path to internal nodes private info. - internalWeightsConfig: path to internal weights configuration file. Returns: - []bootstrap.NodeInfo: the generated node info list. Caution: contains private keys! - error: if any error occurs. Any error returned from this function is irrecoverable.

func ReadFullPartnerNodeInfos added in v0.33.30

func ReadFullPartnerNodeInfos(log zerolog.Logger, partnerWeightsPath, partnerNodeInfoDir string) ([]bootstrap.NodeInfo, error)

ReadFullPartnerNodeInfos reads partner node info and partner weight information from the specified paths and constructs a list of full bootstrap.NodeInfo for each partner node. Args: - log: logger used to log debug information. - partnerWeightsPath: path to partner weights configuration file. - partnerNodeInfoDir: path to partner nodes configuration file. Returns: - []bootstrap.NodeInfo: the generated node info list. (public information, private keys not set) - error: if any error occurs. Any error returned from this function is irrecoverable.

func ReadInternalNodeInfos added in v0.33.30

func ReadInternalNodeInfos(internalNodePrivInfoDir string) ([]bootstrap.NodeInfoPriv, error)

ReadInternalNodeInfos reads our internal node private infos generated by `keygen` command and returns it. Args: - internalNodePrivInfoDir: path to internal nodes private info. Returns: - []bootstrap.NodeInfo: the generated private node info list. Caution: contains private keys! - error: if any error occurs. Any error returned from this function is irrecoverable.

func ReadJSON added in v0.33.30

func ReadJSON(path string, target interface{}) error

func ReadPartnerNodeInfos added in v0.33.30

func ReadPartnerNodeInfos(partnerNodeInfoDir string) ([]bootstrap.NodeInfoPub, error)

ReadPartnerNodeInfos reads the partner node info from the configuration file and returns a list of []bootstrap.NodeInfoPub. Args: - partnerNodeInfoDir: path to partner nodes configuration file. Returns: - []bootstrap.NodeInfoPub: the generated partner node info list. - error: if any error occurs. Any error returned from this function is irrecoverable.

func ValidateAccessNodeIDSFlag added in v0.23.0

func ValidateAccessNodeIDSFlag(accessNodeIDS []string, chainID flow.ChainID, snapshot protocol.Snapshot) ([]flow.Identifier, error)

ValidateAccessNodeIDSFlag validates flag --access-node-ids and converts all ids to flow.Identifier

func ValidateAddressFormat added in v0.33.30

func ValidateAddressFormat(log zerolog.Logger, address string)

ValidateAddressFormat validates the address provided by pretty much doing what the network layer would do before starting the node

func ValidateNetworkPubKey added in v0.33.30

func ValidateNetworkPubKey(key encodable.NetworkPubKey) error

ValidateNetworkPubKey returns an error if network public key is nil. Args: - key: the public key. Returns: - error: if the network key is nil.

func ValidateNodeID added in v0.33.30

func ValidateNodeID(nodeID flow.Identifier) error

ValidateNodeID returns an error if node ID is non-zero. Args: - nodeID: the node ID to validate. Returns: - error: if node id is the zero value.

func ValidateStakingPubKey added in v0.33.30

func ValidateStakingPubKey(key encodable.StakingPubKey) error

ValidateStakingPubKey returns an error if the staking key is nil. Args: - key: the public key. Returns: - error: if the staking key is nil.

func ValidateWeight added in v0.33.30

func ValidateWeight(weight uint64) bool

ValidateWeight returns true if weight is greater than 0. Args: - weight: the weight to check. Returns: - bool: true if weight is greater than 0.

func WriteJSON added in v0.33.30

func WriteJSON(path string, out string, data interface{}) error

func WriteText added in v0.33.30

func WriteText(path string, out string, data []byte) error

Types

type GetProtocolSnapshot added in v0.33.30

type GetProtocolSnapshot func(ctx context.Context) (protocol.Snapshot, error)

GetProtocolSnapshot callback that will get latest finalized protocol snapshot

type PartnerWeights added in v0.33.30

type PartnerWeights map[flow.Identifier]uint64

PartnerWeights is the format of the JSON file specifying partner node weights.

func ReadPartnerWeights added in v0.33.30

func ReadPartnerWeights(partnerWeightsPath string) (PartnerWeights, error)

ReadPartnerWeights reads the partner weights configuration file and returns a list of PartnerWeights. Args: - partnerWeightsPath: path to partner weights configuration file. Returns: - PartnerWeights: map from NodeID → node's weight - error: if any error occurs. Any error returned from this function is irrecoverable.

Jump to

Keyboard shortcuts

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