conductor

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 35 Imported by: 2

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")
	ErrUnsafeHeadMismatch = errors.New("unsafe head mismatch")
	ErrNoUnsafeHead       = errors.New("no unsafe head")
)

Functions

func NewState added in v1.5.0

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

NewState creates a new state instance.

Types

type Config

type Config struct {
	// ConsensusAddr is the address, excluding port, to listen on for consensus connections.
	// E.g. 0.0.0.0 to bind to the external-facing network interface.
	ConsensusAddr string

	// ConsensusPort is the port to listen on for consensus connections.
	// If 0, the server binds to a port selected by the system.
	ConsensusPort int

	// ConsensusAdvertisedAddr is the network address, including port, to advertise to other peers.
	// This is optional: if empty, the address that the server network transport binds to is used instead.
	// E.g. local tests may use temporary addresses, rather than preset known addresses.
	ConsensusAdvertisedAddr string

	// 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

	// RaftSnapshotInterval is the interval to check if a snapshot should be taken.
	RaftSnapshotInterval time.Duration

	// RaftSnapshotThreshold is the number of logs to trigger a snapshot.
	RaftSnapshotThreshold uint64

	// RaftTrailingLogs is the number of logs to keep after a snapshot.
	RaftTrailingLogs uint64

	// 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 added in v1.4.3

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

	// SafeEnabled is whether to enable safe head progression checks.
	SafeEnabled bool

	// 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 added in v1.4.3

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 added in v1.4.3

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

NewOpConductor creates a new OpConductor instance.

func (*OpConductor) AddServerAsNonvoter added in v1.5.0

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

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

func (*OpConductor) AddServerAsVoter added in v1.5.0

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

AddServerAsVoter adds a server as a voter to the cluster.

func (*OpConductor) ClusterMembership added in v1.7.0

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

ClusterMembership returns current cluster's membership information.

func (*OpConductor) CommitUnsafePayload added in v1.5.0

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

CommitUnsafePayload commits an unsafe payload (latest head) to the cluster FSM ensuring strong consistency by leveraging Raft consensus mechanisms.

func (*OpConductor) ConsensusEndpoint added in v1.9.5

func (oc *OpConductor) ConsensusEndpoint() string

ConsensusEndpoint returns the raft consensus server address to connect to.

func (*OpConductor) HTTPEndpoint added in v1.5.0

func (oc *OpConductor) HTTPEndpoint() string

HTTPEndpoint returns the HTTP RPC endpoint

func (*OpConductor) LatestUnsafePayload added in v1.7.0

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

LatestUnsafePayload returns the latest unsafe payload envelope from FSM in a strongly consistent fashion.

func (*OpConductor) Leader added in v1.5.0

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

Leader returns true if OpConductor is the leader.

func (*OpConductor) LeaderOverridden added in v1.9.5

func (oc *OpConductor) LeaderOverridden() bool

func (*OpConductor) LeaderWithID added in v1.5.0

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

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

func (*OpConductor) OverrideLeader added in v1.9.5

func (oc *OpConductor) OverrideLeader(override bool)

func (*OpConductor) Pause added in v1.4.3

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 added in v1.4.3

func (oc *OpConductor) Paused() bool

Paused returns true if OpConductor is paused.

func (*OpConductor) RemoveServer added in v1.5.0

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

RemoveServer removes a server from the cluster.

func (*OpConductor) Resume added in v1.4.3

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

Resume resumes the control loop of OpConductor.

func (*OpConductor) SequencerHealthy added in v1.5.0

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 added in v1.5.0

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

TransferLeader transfers leadership to another server.

func (*OpConductor) TransferLeaderToServer added in v1.5.0

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