rpc

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLeader = errors.New("refusing to proxy request to non-leader sequencer")
View Source
var ExecutionRPCNamespace = "eth"
View Source
var NodeAdminRPCNamespace = "admin"
View Source
var NodeRPCNamespace = "optimism"
View Source
var RPCNamespace = "conductor"

Functions

This section is empty.

Types

type API

type API interface {
	// Pause pauses op-conductor.
	Pause(ctx context.Context) error
	// Resume resumes op-conductor.
	Resume(ctx context.Context) error
	// Paused returns true if op-conductor is paused.
	Paused(ctx context.Context) (bool, error)
	// Stopped returns true if op-conductor is stopped.
	Stopped(ctx context.Context) (bool, error)
	// SequencerHealthy returns true if the sequencer is healthy.
	SequencerHealthy(ctx context.Context) (bool, error)

	// Consensus related APIs
	// Leader returns true if the server is the leader.
	Leader(ctx context.Context) (bool, error)
	// LeaderWithID returns the current leader's server info.
	LeaderWithID(ctx context.Context) (*consensus.ServerInfo, error)
	// AddServerAsVoter adds a server as a voter to the cluster.
	AddServerAsVoter(ctx 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.
	AddServerAsNonvoter(ctx context.Context, id string, addr string) error
	// RemoveServer removes a server from the cluster.
	RemoveServer(ctx context.Context, id string) error
	// TransferLeader transfers leadership to another server.
	TransferLeader(ctx context.Context) error
	// TransferLeaderToServer transfers leadership to a specific server.
	TransferLeaderToServer(ctx context.Context, id string, addr string) error
	// ClusterMembership returns the current cluster membership configuration.
	ClusterMembership(ctx context.Context) ([]*consensus.ServerInfo, error)

	// APIs called by op-node
	// Active returns true if op-conductor is active (not paused or stopped).
	Active(ctx context.Context) (bool, error)
	// CommitUnsafePayload commits a unsafe payload (latest head) to the consensus layer.
	CommitUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error
}

API defines the interface for the op-conductor API.

type APIBackend

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

APIBackend is the backend implementation of the API. TODO: (https://github.com/ethereum-optimism/protocol-quest/issues/45) Add metrics tracer here. TODO: (https://github.com/ethereum-optimism/protocol-quest/issues/44) add tests after e2e setup.

func NewAPIBackend

func NewAPIBackend(log log.Logger, con conductor) *APIBackend

NewAPIBackend creates a new APIBackend instance.

func (*APIBackend) Active

func (api *APIBackend) Active(_ context.Context) (bool, error)

Active implements API.

func (*APIBackend) AddServerAsNonvoter

func (api *APIBackend) AddServerAsNonvoter(ctx context.Context, id string, addr string) error

AddServerAsNonvoter implements API.

func (*APIBackend) AddServerAsVoter

func (api *APIBackend) AddServerAsVoter(ctx context.Context, id string, addr string) error

AddServerAsVoter implements API.

func (*APIBackend) ClusterMembership added in v1.7.0

func (api *APIBackend) ClusterMembership(ctx context.Context) ([]*consensus.ServerInfo, error)

ClusterMembership implements API.

func (*APIBackend) CommitUnsafePayload

func (api *APIBackend) CommitUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error

CommitUnsafePayload implements API.

func (*APIBackend) Leader

func (api *APIBackend) Leader(ctx context.Context) (bool, error)

Leader implements API, returns true if current conductor is leader of the cluster.

func (*APIBackend) LeaderWithID

func (api *APIBackend) LeaderWithID(ctx context.Context) (*consensus.ServerInfo, error)

LeaderWithID implements API, returns the leader's server ID and address (not necessarily the current conductor).

func (*APIBackend) Pause

func (api *APIBackend) Pause(ctx context.Context) error

Pause implements API.

func (*APIBackend) Paused added in v1.7.4

func (api *APIBackend) Paused(ctx context.Context) (bool, error)

Paused implements API.

func (*APIBackend) RemoveServer

func (api *APIBackend) RemoveServer(ctx context.Context, id string) error

RemoveServer implements API.

func (*APIBackend) Resume

func (api *APIBackend) Resume(ctx context.Context) error

Resume implements API.

func (*APIBackend) SequencerHealthy

func (api *APIBackend) SequencerHealthy(ctx context.Context) (bool, error)

SequencerHealthy implements API.

func (*APIBackend) Stopped added in v1.7.4

func (api *APIBackend) Stopped(ctx context.Context) (bool, error)

Stopped implements API.

func (*APIBackend) TransferLeader

func (api *APIBackend) TransferLeader(ctx context.Context) error

TransferLeader implements API. With Raft implementation, a successful call does not mean that leadership transfer is complete It just means that leadership transfer is in progress (current leader has initiated a new leader election round and stepped down as leader)

func (*APIBackend) TransferLeaderToServer

func (api *APIBackend) TransferLeaderToServer(ctx context.Context, id string, addr string) error

TransferLeaderToServer implements API. With Raft implementation, a successful call does not mean that leadership transfer is complete It just means that leadership transfer is in progress (current leader has initiated a new leader election round and stepped down as leader)

type APIClient

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

APIClient provides a client for calling API methods.

func NewAPIClient

func NewAPIClient(c *rpc.Client) *APIClient

NewAPIClient creates a new APIClient instance.

func (*APIClient) Active

func (c *APIClient) Active(ctx context.Context) (bool, error)

Active implements API.

func (*APIClient) AddServerAsNonvoter

func (c *APIClient) AddServerAsNonvoter(ctx context.Context, id string, addr string) error

AddServerAsNonvoter implements API.

func (*APIClient) AddServerAsVoter

func (c *APIClient) AddServerAsVoter(ctx context.Context, id string, addr string) error

AddServerAsVoter implements API.

func (*APIClient) Close

func (c *APIClient) Close()

Close closes the underlying RPC client.

func (*APIClient) ClusterMembership added in v1.7.0

func (c *APIClient) ClusterMembership(ctx context.Context) ([]*consensus.ServerInfo, error)

ClusterMembership implements API.

func (*APIClient) CommitUnsafePayload

func (c *APIClient) CommitUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error

CommitUnsafePayload implements API.

func (*APIClient) Leader

func (c *APIClient) Leader(ctx context.Context) (bool, error)

Leader implements API.

func (*APIClient) LeaderWithID

func (c *APIClient) LeaderWithID(ctx context.Context) (*consensus.ServerInfo, error)

LeaderWithID implements API.

func (*APIClient) Pause

func (c *APIClient) Pause(ctx context.Context) error

Pause implements API.

func (*APIClient) Paused added in v1.7.4

func (c *APIClient) Paused(ctx context.Context) (bool, error)

Paused implements API.

func (*APIClient) RemoveServer

func (c *APIClient) RemoveServer(ctx context.Context, id string) error

RemoveServer implements API.

func (*APIClient) Resume

func (c *APIClient) Resume(ctx context.Context) error

Resume implements API.

func (*APIClient) SequencerHealthy

func (c *APIClient) SequencerHealthy(ctx context.Context) (bool, error)

SequencerHealthy implements API.

func (*APIClient) Stopped added in v1.7.4

func (c *APIClient) Stopped(ctx context.Context) (bool, error)

Stopped implements API.

func (*APIClient) TransferLeader

func (c *APIClient) TransferLeader(ctx context.Context) error

TransferLeader implements API.

func (*APIClient) TransferLeaderToServer

func (c *APIClient) TransferLeaderToServer(ctx context.Context, id string, addr string) error

TransferLeaderToServer implements API.

type ExecutionProxyAPI

type ExecutionProxyAPI interface {
	GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
}

ExecutionProxyAPI defines the methods proxied to the execution rpc backend This should include all methods that are called by op-batcher or op-proposer

type ExecutionProxyBackend

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

ExecutionProxyBackend implements an execution rpc proxy with a leadership check before each call.

func NewExecutionProxyBackend

func NewExecutionProxyBackend(log log.Logger, con conductor, client *ethclient.Client) *ExecutionProxyBackend

func (*ExecutionProxyBackend) GetBlockByNumber

func (api *ExecutionProxyBackend) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

type NodeAdminProxyAPI

type NodeAdminProxyAPI interface {
	SequencerActive(ctx context.Context) (bool, error)
}

NodeProxyAPI defines the methods proxied to the node rpc backend This should include all methods that are called by op-batcher or op-proposer

func NewNodeAdminProxyBackend

func NewNodeAdminProxyBackend(log log.Logger, con conductor, client *sources.RollupClient) NodeAdminProxyAPI

NewNodeAdminProxyBackend creates a new NodeAdminProxyBackend instance.

type NodeAdminProxyBackend

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

NodeAdminProxyAPI implements a node admin rpc proxy with a leadership check to make sure only leader returns the result.

func (*NodeAdminProxyBackend) SequencerActive

func (api *NodeAdminProxyBackend) SequencerActive(ctx context.Context) (bool, error)

type NodeProxyAPI

type NodeProxyAPI interface {
	OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
	SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
	RollupConfig(ctx context.Context) (*rollup.Config, error)
}

NodeProxyAPI defines the methods proxied to the node rpc backend This should include all methods that are called by op-batcher or op-proposer

type NodeProxyBackend

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

NodeProxyBackend implements a node rpc proxy with a leadership check before each call.

func NewNodeProxyBackend

func NewNodeProxyBackend(log log.Logger, con conductor, client *sources.RollupClient) *NodeProxyBackend

func (*NodeProxyBackend) OutputAtBlock

func (api *NodeProxyBackend) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)

func (*NodeProxyBackend) RollupConfig

func (api *NodeProxyBackend) RollupConfig(ctx context.Context) (*rollup.Config, error)

func (*NodeProxyBackend) SyncStatus

func (api *NodeProxyBackend) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)

Jump to

Keyboard shortcuts

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