conductor

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResumeTimeout                           = errors.New("timeout to resume conductor")
	ErrPauseTimeout                            = errors.New("timeout to pause conductor")
	ErrUnsafeHeadMismarch                      = errors.New("unsafe head mismatch")
	ErrUnableToRetrieveUnsafeHeadFromConsensus = errors.New("unable to retrieve unsafe head from consensus")
)

Functions

func NewState

func NewState(leader, healthy, active bool) *state

NewState creates a new state instance.

Types

type Config

type Config struct {
	// ConsensusAddr is the address to listen for consensus connections.
	ConsensusAddr string

	// ConsensusPort is the port to listen for consensus connections.
	ConsensusPort int

	// RaftServerID is the unique ID for this server used by raft consensus.
	RaftServerID string

	// RaftStorageDir is the directory to store raft data.
	RaftStorageDir string

	// RaftBootstrap is true if this node should bootstrap a new raft cluster.
	RaftBootstrap bool

	// NodeRPC is the HTTP provider URL for op-node.
	NodeRPC string

	// ExecutionRPC is the HTTP provider URL for execution layer.
	ExecutionRPC string

	// Paused is true if the conductor should start in a paused state.
	Paused bool

	// HealthCheck is the health check configuration.
	HealthCheck HealthCheckConfig

	// RollupCfg is the rollup config.
	RollupCfg rollup.Config

	// RPCEnableProxy is true if the sequencer RPC proxy should be enabled.
	RPCEnableProxy bool

	LogConfig     oplog.CLIConfig
	MetricsConfig opmetrics.CLIConfig
	PprofConfig   oppprof.CLIConfig
	RPC           oprpc.CLIConfig
}

func NewConfig

func NewConfig(ctx *cli.Context, log log.Logger) (*Config, error)

NewConfig parses the Config from the provided flags or environment variables.

func (*Config) Check

func (c *Config) Check() error

Check validates the CLIConfig.

type HealthCheckConfig

type HealthCheckConfig struct {
	// Interval is the interval (in seconds) to check the health of the sequencer.
	Interval uint64

	// UnsafeInterval is the interval allowed between unsafe head and now in seconds.
	UnsafeInterval uint64

	// SafeInterval is the interval between safe head progression measured in seconds.
	SafeInterval uint64

	// MinPeerCount is the minimum number of peers required for the sequencer to be healthy.
	MinPeerCount uint64
}

HealthCheckConfig defines health check configuration.

func (*HealthCheckConfig) Check

func (c *HealthCheckConfig) Check() error

type OpConductor

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

OpConductor represents a full conductor instance and its resources, it does:

  1. performs health checks on sequencer
  2. participate in consensus protocol for leader election
  3. and control sequencer state based on leader, sequencer health and sequencer active status.

OpConductor has three states:

  1. running: it is running normally, which executes control loop and participates in leader election.
  2. paused: control loop (sequencer start/stop) is paused, but it still participates in leader election, and receives health updates.
  3. stopped: it is stopped, which means it is not participating in leader election and control loop. OpConductor cannot be started again from stopped mode.

func New

func New(ctx context.Context, cfg *Config, log log.Logger, version string) (*OpConductor, error)

New creates a new OpConductor instance.

func NewOpConductor

func NewOpConductor(
	ctx context.Context,
	cfg *Config,
	log log.Logger,
	version string,
	ctrl client.SequencerControl,
	cons consensus.Consensus,
	hmon health.HealthMonitor,
) (*OpConductor, error)

NewOpConductor creates a new OpConductor instance.

func (*OpConductor) AddServerAsNonvoter

func (oc *OpConductor) AddServerAsNonvoter(_ context.Context, id string, addr string) error

AddServerAsNonvoter adds a server as a non-voter to the cluster. non-voter will not participate in leader election.

func (*OpConductor) AddServerAsVoter

func (oc *OpConductor) AddServerAsVoter(_ context.Context, id string, addr string) error

AddServerAsVoter adds a server as a voter to the cluster.

func (*OpConductor) ClusterMembership

func (oc *OpConductor) ClusterMembership(_ context.Context) ([]*consensus.ServerInfo, error)

ClusterMembership returns current cluster's membership information.

func (*OpConductor) CommitUnsafePayload

func (oc *OpConductor) CommitUnsafePayload(_ context.Context, payload *eth.ExecutionPayloadEnvelope) error

CommitUnsafePayload commits a unsafe payload (latest head) to the cluster FSM.

func (*OpConductor) HTTPEndpoint

func (oc *OpConductor) HTTPEndpoint() string

func (*OpConductor) LatestUnsafePayload

func (oc *OpConductor) LatestUnsafePayload(_ context.Context) *eth.ExecutionPayloadEnvelope

LatestUnsafePayload returns the latest unsafe payload envelope from FSM.

func (*OpConductor) Leader

func (oc *OpConductor) Leader(_ context.Context) bool

Leader returns true if OpConductor is the leader.

func (*OpConductor) LeaderWithID

func (oc *OpConductor) LeaderWithID(_ context.Context) *consensus.ServerInfo

LeaderWithID returns the current leader's server ID and address.

func (*OpConductor) Pause

func (oc *OpConductor) Pause(ctx context.Context) error

Pause pauses the control loop of OpConductor, but still allows it to participate in leader election.

func (*OpConductor) Paused

func (oc *OpConductor) Paused() bool

Paused returns true if OpConductor is paused.

func (*OpConductor) RemoveServer

func (oc *OpConductor) RemoveServer(_ context.Context, id string) error

RemoveServer removes a server from the cluster.

func (*OpConductor) Resume

func (oc *OpConductor) Resume(ctx context.Context) error

Resume resumes the control loop of OpConductor.

func (*OpConductor) SequencerHealthy

func (oc *OpConductor) SequencerHealthy(_ context.Context) bool

SequencerHealthy returns true if sequencer is healthy.

func (*OpConductor) Start

func (oc *OpConductor) Start(ctx context.Context) error

Start implements cliapp.Lifecycle.

func (*OpConductor) Stop

func (oc *OpConductor) Stop(ctx context.Context) error

Stop implements cliapp.Lifecycle.

func (*OpConductor) Stopped

func (oc *OpConductor) Stopped() bool

Stopped implements cliapp.Lifecycle.

func (*OpConductor) TransferLeader

func (oc *OpConductor) TransferLeader(_ context.Context) error

TransferLeader transfers leadership to another server.

func (*OpConductor) TransferLeaderToServer

func (oc *OpConductor) TransferLeaderToServer(_ context.Context, id string, addr string) error

TransferLeaderToServer transfers leadership to a specific server.

Jump to

Keyboard shortcuts

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