Documentation ¶
Index ¶
- Constants
- func ConstructClusterAssignment(log zerolog.Logger, partnerNodes, internalNodes flow.IdentityList, ...) (flow.AssignmentList, flow.ClusterList, error)
- func ConvertClusterAssignmentsCdc(assignments flow.AssignmentList) cadence.Array
- func ConvertClusterQcsCdc(qcs []*flow.QuorumCertificate, clusterList flow.ClusterList, ...) ([]cadence.Value, error)
- func FilesInDir(dir string) ([]string, error)
- func GetNodeInfoForProposedNodesScript(network string) ([]byte, error)
- func GetSnapshot(ctx context.Context, client *grpc.Client) (*inmem.Snapshot, error)
- func GetSnapshotAtEpochAndPhase(ctx context.Context, log zerolog.Logger, startupEpoch uint64, ...) (protocol.Snapshot, error)
- func InitProtocolState(db *badger.DB, storages *storage.All) (protocol.State, error)
- func InitStorage(datadir string) *badger.DB
- func InitStorageWithTruncate(datadir string, truncate bool) *badger.DB
- func InitStorages(db *badger.DB) *storage.All
- func NodeCountByRole(nodes []bootstrap.NodeInfo) map[flow.Role]uint16
- func PathExists(path string) (bool, error)
- func PrettyPrint(entity interface{})
- func PrettyPrintEntity(entity flow.Entity)
- func PubKeyToString(key crypto.PublicKey) string
- func ReadFullInternalNodeInfos(log zerolog.Logger, internalNodePrivInfoDir, internalWeightsConfig string) ([]bootstrap.NodeInfo, error)
- func ReadFullPartnerNodeInfos(log zerolog.Logger, partnerWeightsPath, partnerNodeInfoDir string) ([]bootstrap.NodeInfo, error)
- func ReadInternalNodeInfos(internalNodePrivInfoDir string) ([]bootstrap.NodeInfoPriv, error)
- func ReadJSON(path string, target interface{}) error
- func ReadPartnerNodeInfos(partnerNodeInfoDir string) ([]bootstrap.NodeInfoPub, error)
- func ValidateAccessNodeIDSFlag(accessNodeIDS []string, chainID flow.ChainID, snapshot protocol.Snapshot) ([]flow.Identifier, error)
- func ValidateAddressFormat(log zerolog.Logger, address string)
- func ValidateNetworkPubKey(key encodable.NetworkPubKey) error
- func ValidateNodeID(nodeID flow.Identifier) error
- func ValidateStakingPubKey(key encodable.StakingPubKey) error
- func ValidateWeight(weight uint64) bool
- func WriteJSON(path string, out string, data interface{}) error
- func WriteText(path string, out string, data []byte) error
- type GetProtocolSnapshot
- type PartnerWeights
Constants ¶
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 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, flowClusterQCAddress string) ([]cadence.Value, error)
ConvertClusterQcsCdc converts cluster QCs from `QuorumCertificate` type to `ClusterQCVoteData` type. Args:
- qcs: list of quorum certificates.
- clusterList: the list of cluster lists each used to generate one of the quorum certificates in qcs.
- flowClusterQCAddress: the FlowClusterQC contract address where the ClusterQCVoteData type is defined.
Returns:
- []cadence.Value: cadence representation of the list of cluster qcs.
- error: error if the cluster qcs and cluster lists don't match in size or signature indices decoding fails.
func FilesInDir ¶ added in v0.33.30
func GetNodeInfoForProposedNodesScript ¶ added in v0.25.0
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
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 InitStorage ¶
func InitStorage(datadir string) *badger.DB
func InitStorageWithTruncate ¶ added in v0.11.0
func InitStorages ¶ added in v0.12.0
func NodeCountByRole ¶ added in v0.33.30
func PrettyPrintEntity ¶ added in v0.12.0
PrettyPrintEntity pretty print a flow entity
func PubKeyToString ¶ added in v0.33.30
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 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
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
ValidateWeight returns true if weight is greater than 0. Args: - weight: the weight to check. Returns: - bool: true if weight is greater than 0.
Types ¶
type GetProtocolSnapshot ¶ added in v0.33.30
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.