Help us shape the future of Go! Take the 2026 Go Developer Survey

consensus

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelManagedBy = common.LabelManagedBy
	LabelPartOf    = common.LabelPartOf
	LabelOrbit     = common.LabelOrbit
	LabelComponent = common.LabelComponent

	LabelNodeId        = "operator.solo.hiero.org/node-id"
	LabelSoloNodeName  = "operator.solo.hiero.org/node-name"
	LabelSoloAccountId = "operator.solo.hiero.org/account-id"
	LabelSoloType      = "operator.solo.hiero.org/type"
	LabelSoloPromEndpt = "operator.solo.hiero.org/prometheus-endpoint"
)

Label keys — generic keys alias common; consensus-specific keys defined here.

View Source
const (
	ManagedByValue         = common.ManagedByValue
	PartOfConsensusNode    = "consensus-node"
	ComponentConsensusNode = common.ComponentConsensusNode
)

Label values — generic values alias common; consensus-specific values defined here.

View Source
const (
	ServiceAccountSuffix = "-sa"
	RoleSuffix           = "-role"
	RoleBindingSuffix    = "-rb"
	ConfigMapSuffix      = "-cm"
)

Resource name suffixes

View Source
const (
	// ClusterConfigMapName is the legacy cluster-config ConfigMap created by NetworkGenesis.
	ClusterConfigMapName = "cluster-config"
	// GenesisConfigMapName holds genesis-network.json — mounted by ConsensusCapsule pods.
	GenesisConfigMapName = "genesis-config"
	// GenesisNetworkFileName is the key inside GenesisConfigMapName.
	GenesisNetworkFileName = "genesis-network.json"
	// GenesisPropertiesFileName is the key inside GenesisConfigMapName for genesis.properties.
	GenesisPropertiesFileName = "genesis.properties"
	// PublicKeysConfigMapName holds all nodes' signing public certs — mounted into data/keys.
	PublicKeysConfigMapName = "public-keys"
)

Resource names. The genesis package re-exports the ConfigMap-related constants from this block (single source of truth lives here so deployment.go can mount them without importing the genesis package, which would create a cycle since genesis imports consensus for hostname helpers).

View Source
const (
	CheckpointKeyGenesisInitialized = "genesis-initialized"
	// Keep these in sync with the shell-script comparison in buildGenesisInitContainer.
	CheckpointValueTrue  = "true"
	CheckpointValueFalse = "false"
)

Checkpoint ConfigMap constants — [capsule-name]-checkpoint.

View Source
const (
	GossipPort     = common.GossipPort
	GrpcPort       = common.GrpcPort
	GrpcsPort      = common.GrpcsPort
	PrometheusPort = 9999
	UCMetricsPort  = 9990
	AlloyHTTPPort  = 12345
)

Port numbers — gossip/gRPC alias common; consensus-specific ports defined here.

View Source
const (
	VolumeTypeLogs    = "logs"
	VolumeTypeStats   = "stats"
	VolumeTypeSaved   = "saved"
	VolumeTypeState   = "state"
	VolumeTypeUpgrade = "upgrade"
	VolumeTypeBlocks  = "blocks"
	VolumeTypeRecords = "records"
	VolumeTypeEvents  = "events"
	VolumeTypeUCData  = "uc-data"
)

Volume types

View Source
const (
	PathBlockStreams  = "/opt/hgcapp/blockStreams"
	PathRecordStreams = "/opt/hgcapp/recordStreams"
	PathEventsStreams = "/opt/hgcapp/eventsStreams"
)

Stream mount paths — single source of truth shared by volume builders and getVolumeNameForPath.

View Source
const (
	// DefaultConsensusContainerName is the consensus-node container name used when
	// spec.podProperties.containers.consensusNode.name is unset.
	DefaultConsensusContainerName = "consensus-node"

	// HapiBase is the working directory inside the consensus-node container.
	HapiBase = "/opt/hgcapp/services-hedera/HapiApp2.0"

	// HederaUID is the uid/gid the consensus-node image runs as (the "hedera"
	// user). The UC sidecar runs as the same uid:gid so it shares ownership of
	// the upgrade PVC (data/upgrade) with the node; fsGroup uses it as well.
	HederaUID int64 = 2000

	// GenesisInitImage is the image used by the genesis-config init container.
	// It only needs sh and cp.
	GenesisInitImage = "busybox:1.36.1"

	// SavedStateDir is the subdirectory written by the platform under data/saved
	// once the first round completes. Its presence means the node has live state
	// and does not need genesis-network.json on the next restart.
	SavedStateDir = "com.hedera.services.ServicesMain"
)
View Source
const (
	// AlloyDefaultAppName is the default application name label.
	AlloyDefaultAppName = "hedera-node"

	// AlloyDefaultEnvironment is the default environment label.
	AlloyDefaultEnvironment = "integration"

	// AlloyDefaultLogLevel is the default Alloy logging level.
	AlloyDefaultLogLevel = "info"
)

Alloy telemetry sidecar defaults.

View Source
const (
	// CheetahDefaultLogLevel is the default pipeline log level.
	CheetahDefaultLogLevel = "Debug"

	// CheetahDefaultMaxProcessors is the default max concurrent file processors per pipeline.
	CheetahDefaultMaxProcessors = 10

	// CheetahDefaultConfigCheckInterval is the default interval for config hot-reload.
	CheetahDefaultConfigCheckInterval = "30s"

	// CheetahPprofPort is the pprof HTTP server port exposed by each cheetah container.
	CheetahPprofPort int32 = 6061

	// CheetahStatsPort is the stats HTTP server port exposed by each cheetah container.
	CheetahStatsPort int32 = 6060
)

Cheetah uploader defaults — kept in one place so that ConfigMap generation, container building, and tests all share the same values.

View Source
const (
	// ReasonOrbitRequired is returned when a sidecar that requires spec.orbit
	// (e.g. the UC sidecar) is enabled but the field is empty.
	ReasonOrbitRequired errx.Reason = "OrbitRequired"

	ReasonImageRequired   errx.Reason = "ImageRequired"
	ReasonBlobURLRequired errx.Reason = "BlobURLRequired"
	ReasonOrbitNotFound   errx.Reason = "OrbitNotFound"
)
View Source
const (
	ReasonOrbitDefaultsResolved errx.Reason = "OrbitDefaultsResolved"
	ReasonUCModeResolved        errx.Reason = "UCModeResolved"

	// ReasonExecTransportFailed: the pods/exec stream could not be established
	// (pod not found/ready, or transport error).
	ReasonExecTransportFailed errx.Reason = "ExecTransportFailed"

	// ReasonExecForbidden: the API server rejected the pods/exec request with a
	// 403. The WebSocket exec transport authorizes against pods/exec with the
	// `get` verb; a forbidden here means the operator ServiceAccount lacks it.
	ReasonExecForbidden errx.Reason = "ExecForbidden"

	// ReasonExecCommandFailed: the s6 command exited non-zero.
	ReasonExecCommandFailed errx.Reason = "ExecCommandFailed"
)

Consensus-specific reason codes. Generic K8s lifecycle codes live in internal/common.

View Source
const (
	// UCDataPath is the root directory for all UC runtime state (crs/, events/, backup/, uc.sock).
	// Backed by the "uc-data" volume, which is an emptyDir by default or a PVC when
	// spec.persistentVolumeClaims.ucData is set. The UC binary creates subdirs as needed.
	UCDataPath = "/opt/solo/weaver/uc"
)

Variables

This section is empty.

Functions

func AlloyConfigMapName

func AlloyConfigMapName(capsule *operatorv1alpha1.ConsensusCapsule) string

AlloyConfigMapName returns the Alloy ConfigMap name for a capsule

func BuildAlloyRiverConfig

func BuildAlloyRiverConfig(capsule *operatorv1alpha1.ConsensusCapsule, alloy *operatorv1alpha1.AlloyConfig) string

BuildAlloyRiverConfig generates the Alloy River configuration from CR fields

func CheckpointConfigMapName added in v0.3.0

func CheckpointConfigMapName(capsule *operatorv1alpha1.ConsensusCapsule) string

CheckpointConfigMapName returns the checkpoint ConfigMap name for a capsule.

func CheetahConfigMapName

func CheetahConfigMapName(capsule *operatorv1alpha1.ConsensusCapsule) string

CheetahConfigMapName returns the per-capsule Cheetah ConfigMap name. Each capsule has its own ConfigMap so reconcilers for different nodes do not overwrite each other's config, which would cause an infinite update loop.

func CommonLabels

func CommonLabels(capsule *operatorv1alpha1.ConsensusCapsule) map[string]string

CommonLabels returns the common labels for consensus capsule resources

func ConsensusContainerName added in v0.4.0

func ConsensusContainerName(capsule *operatorv1alpha1.ConsensusCapsule) string

ConsensusContainerName returns the consensus-node container name, honoring the spec override and falling back to DefaultConsensusContainerName. Shared by the container builder and the s6 exec target so they never diverge.

func DefaultApplicationProperties added in v0.3.0

func DefaultApplicationProperties() map[string]string

DefaultApplicationProperties returns the baseline application.properties values required by Solo.

func GetPVCNames

func GetPVCNames(capsule *operatorv1alpha1.ConsensusCapsule) []string

GetPVCNames returns a list of all PVC names for a capsule

func InternalHostname

func InternalHostname(capsule *operatorv1alpha1.ConsensusCapsule) string

InternalHostname returns the per-capsule service FQDN for a capsule, or InternalAddress if set.

func MergeApplicationProperties added in v0.3.0

func MergeApplicationProperties(overrides map[string]string) string

MergeApplicationProperties merges overrides into the default application.properties map.

func NewSubReconcilersWithS6 added in v0.6.0

func NewSubReconcilersWithS6(c client.Client, scheme *runtime.Scheme, recorder events.EventRecorder, s6 S6Runner) *subreconciler.Chain[*operatorv1alpha1.ConsensusCapsule]

NewSubReconcilersWithS6 creates all consensus capsule subreconcilers with an explicit S6Runner.

func PVCName

func PVCName(capsule *operatorv1alpha1.ConsensusCapsule, volumeType string) string

PVCName returns the PVC name for a capsule and volume type

func PodLabels

func PodLabels(capsule *operatorv1alpha1.ConsensusCapsule) map[string]string

PodLabels returns the full label set for pod template metadata. LabelManagedBy + LabelPartOf are required for the consensus headless service selector to match.

func PodName added in v0.4.0

func PodName(capsule *operatorv1alpha1.ConsensusCapsule) string

PodName returns the name of the capsule's single StatefulSet pod (ordinal 0). The consensus StatefulSet always runs one replica, so the pod name is deterministic ("<statefulset>-0") — it matches the UC_POD_NAME the sidecar reads from the downward API and is used to scope the UC's pods/status RBAC to its own pod.

func RenderProperties added in v0.3.0

func RenderProperties(m map[string]string) string

RenderProperties renders a map[string]string as a sorted Java-properties-style key=value file.

func RenderSettingsTxt added in v0.3.0

func RenderSettingsTxt(m map[string]string) string

RenderSettingsTxt renders a settings map in the padded-comma format expected by the Hedera platform:

"checkSignedStateFromDisk,              1"

Keys are sorted for deterministic output so ConfigMap content is stable across reconciles.

func ResolveAlloyConfig

ResolveAlloyConfig returns the effective AlloyConfig for a capsule by merging orbit-level defaults with capsule-level overrides. Capsule fields take precedence.

Resolution order:

  1. If the capsule has an explicit alloy config, it overrides orbit defaults field-by-field.
  2. If the capsule has no alloy config, orbit defaults are used as-is.
  3. If neither orbit nor capsule define alloy config, nil is returned.

func ResolveGossipPort added in v0.3.0

func ResolveGossipPort(capsule *operatorv1alpha1.ConsensusCapsule) int32

ResolveGossipPort returns the gossip port from the capsule spec, falling back to the default.

func ResolveGrpcPort added in v0.3.0

func ResolveGrpcPort(capsule *operatorv1alpha1.ConsensusCapsule) int32

ResolveGrpcPort returns the gRPC port from the capsule spec, falling back to the default.

func ResolveUCMode added in v0.4.0

func ResolveUCMode(ctx context.Context, c client.Client, capsule *operatorv1alpha1.ConsensusCapsule) (uc.Mode, error)

ResolveUCMode returns the UC deployment mode for a capsule by reading Orbit.Spec.Consensus.ProvisionerDaemonEnabled. The default (ProvisionerDaemonEnabled=false) is cluster-only. When true, a host-level provisioner daemon handles the execute phase so the UC runs in mainnet mode. An empty Orbit reference is a terminal error when UC is enabled because UC_ORBIT is required. NotFound is treated as cluster-only; other errors are propagated so the reconciler can requeue.

func RoleBindingName

func RoleBindingName(capsule *operatorv1alpha1.ConsensusCapsule) string

RoleBindingName returns the role binding name for a capsule

func RoleName added in v0.3.2

func RoleName(capsule *operatorv1alpha1.ConsensusCapsule) string

RoleName returns the per-capsule Role name.

func SelectorLabels added in v0.3.0

func SelectorLabels(capsule *operatorv1alpha1.ConsensusCapsule) map[string]string

SelectorLabels returns the minimal stable labels used for StatefulSet MatchLabels and pod listing. Kept independent from CommonLabels so additions to CommonLabels never corrupt the immutable selector.

func ServiceAccountName

func ServiceAccountName(capsule *operatorv1alpha1.ConsensusCapsule) string

ServiceAccountName returns the service account name for a capsule

func StatefulSetName added in v0.3.0

func StatefulSetName(capsule *operatorv1alpha1.ConsensusCapsule) string

StatefulSetName returns the StatefulSet name for a capsule.

Types

type ActuationSubReconciler added in v0.6.0

type ActuationSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
	// contains filtered or unexported fields
}

func NewActuationSubReconciler added in v0.6.0

func NewActuationSubReconciler(c client.Client, s *runtime.Scheme, s6 S6Runner, recorder events.EventRecorder) *ActuationSubReconciler

func (*ActuationSubReconciler) Reconcile added in v0.6.0

func (*ActuationSubReconciler) ShouldReconcile added in v0.6.0

func (r *ActuationSubReconciler) ShouldReconcile(ctx context.Context, capsule *operatorv1alpha1.ConsensusCapsule) bool

type AlloyConfigMapSubReconciler

type AlloyConfigMapSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

AlloyConfigMapSubReconciler manages the Alloy ConfigMap

func NewAlloyConfigMapSubReconciler

func NewAlloyConfigMapSubReconciler(c client.Client, scheme *runtime.Scheme) *AlloyConfigMapSubReconciler

NewAlloyConfigMapSubReconciler creates a new AlloyConfigMapSubReconciler

func (*AlloyConfigMapSubReconciler) Reconcile

Reconcile ensures the Alloy ConfigMap exists

type CheckpointSubReconciler added in v0.3.0

type CheckpointSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

CheckpointSubReconciler creates [capsule]-checkpoint once and never overwrites it. The controller patches it to mark genesis done; the init container reads it at pod start.

func NewCheckpointSubReconciler added in v0.3.0

func NewCheckpointSubReconciler(c client.Client, scheme *runtime.Scheme) *CheckpointSubReconciler

func (*CheckpointSubReconciler) Reconcile added in v0.3.0

type CheetahConfigMapSubReconciler

type CheetahConfigMapSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

CheetahConfigMapSubReconciler manages the Cheetah ConfigMap

func NewCheetahConfigMapSubReconciler

func NewCheetahConfigMapSubReconciler(c client.Client, scheme *runtime.Scheme) *CheetahConfigMapSubReconciler

NewCheetahConfigMapSubReconciler creates a new CheetahConfigMapSubReconciler

func (*CheetahConfigMapSubReconciler) Reconcile

Reconcile ensures the Cheetah ConfigMap exists

type ExecResult added in v0.4.0

type ExecResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

type PVCSubReconciler

PVCSubReconciler manages PersistentVolumeClaims for a ConsensusCapsule

func NewPVCSubReconciler

func NewPVCSubReconciler(c client.Client, scheme *runtime.Scheme) *PVCSubReconciler

NewPVCSubReconciler creates a new PVCSubReconciler

func (*PVCSubReconciler) Reconcile

Reconcile ensures all configured PVCs exist

func (*PVCSubReconciler) ShouldReconcile

func (r *PVCSubReconciler) ShouldReconcile(ctx context.Context, capsule *operatorv1alpha1.ConsensusCapsule) bool

ShouldReconcile returns true if PVCs are configured

type RoleBindingSubReconciler

type RoleBindingSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

RoleBindingSubReconciler manages the RoleBinding for a ConsensusCapsule

func NewRoleBindingSubReconciler

func NewRoleBindingSubReconciler(c client.Client, scheme *runtime.Scheme) *RoleBindingSubReconciler

NewRoleBindingSubReconciler creates a new RoleBindingSubReconciler

func (*RoleBindingSubReconciler) Reconcile

Reconcile ensures the role binding exists

type RoleSubReconciler added in v0.3.2

type RoleSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

func NewRoleSubReconciler added in v0.3.2

func NewRoleSubReconciler(c client.Client, scheme *runtime.Scheme) *RoleSubReconciler

func (*RoleSubReconciler) Reconcile added in v0.3.2

type S6Controller added in v0.4.0

type S6Controller struct {
	// contains filtered or unexported fields
}

S6Controller controls the s6 service via pods/exec.

func NewS6Controller added in v0.4.0

func NewS6Controller(clientset kubernetes.Interface, restConfig *rest.Config) *S6Controller

func (*S6Controller) IsUp added in v0.4.0

func (*S6Controller) Start added in v0.4.0

func (*S6Controller) Stop added in v0.4.0

type S6Runner added in v0.6.0

type S6Runner interface {
	Start(ctx context.Context, capsule *operatorv1alpha1.ConsensusCapsule) error
	Stop(ctx context.Context, capsule *operatorv1alpha1.ConsensusCapsule) error
	IsUp(ctx context.Context, capsule *operatorv1alpha1.ConsensusCapsule) (bool, error)
}

S6Runner controls and inspects the s6-supervised consensus process.

type ServiceAccountSubReconciler

type ServiceAccountSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

ServiceAccountSubReconciler manages the ServiceAccount for a ConsensusCapsule

func NewServiceAccountSubReconciler

func NewServiceAccountSubReconciler(c client.Client, scheme *runtime.Scheme) *ServiceAccountSubReconciler

NewServiceAccountSubReconciler creates a new ServiceAccountSubReconciler

func (*ServiceAccountSubReconciler) Reconcile

Reconcile ensures the ServiceAccount exists and is up to date.

type ServiceSubReconciler

type ServiceSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
}

ServiceSubReconciler manages the Service for a ConsensusCapsule

func NewServiceSubReconciler

func NewServiceSubReconciler(c client.Client, scheme *runtime.Scheme) *ServiceSubReconciler

NewServiceSubReconciler creates a new ServiceSubReconciler

func (*ServiceSubReconciler) Reconcile

Reconcile ensures the service exists

type StatefulSetSubReconciler added in v0.3.0

type StatefulSetSubReconciler struct {
	*subreconciler.BaseSubReconciler[*operatorv1alpha1.ConsensusCapsule]
	Recorder events.EventRecorder
}

StatefulSetSubReconciler manages the StatefulSet for a ConsensusCapsule.

func NewStatefulSetSubReconciler added in v0.3.0

func NewStatefulSetSubReconciler(c client.Client, scheme *runtime.Scheme, recorder events.EventRecorder) *StatefulSetSubReconciler

NewStatefulSetSubReconciler creates a new StatefulSetSubReconciler.

func (*StatefulSetSubReconciler) Reconcile added in v0.3.0

Reconcile ensures the StatefulSet exists and is up to date.

Jump to

Keyboard shortcuts

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