node

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, MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyClosed = errors.New("node is already closed")
View Source
var (
	// UnsafeBlockSignerAddressSystemConfigStorageSlot is the storage slot identifier of the unsafeBlockSigner
	// `address` storage value in the SystemConfig L1 contract. Computed as `keccak256("systemconfig.unsafeblocksigner")`
	UnsafeBlockSignerAddressSystemConfigStorageSlot = common.HexToHash("0x65a7ed542fb37fe237fdfbdd70b31598523fe5b32879e307bae27a0bd9581c08")
)

Functions

func NewAdminAPI

func NewAdminAPI(dr driverClient, m metrics.RPCMetricer, log log.Logger) *adminAPI

func NewNodeAPI

func NewNodeAPI(config *rollup.Config, l2Client l2EthClient, dr driverClient, safeDB SafeDBReader, log log.Logger, m metrics.RPCMetricer) *nodeAPI

Types

type ActiveConfigPersistence

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

func NewConfigPersistence

func NewConfigPersistence(file string) *ActiveConfigPersistence

func (*ActiveConfigPersistence) SequencerStarted

func (p *ActiveConfigPersistence) SequencerStarted() error

func (*ActiveConfigPersistence) SequencerState

func (p *ActiveConfigPersistence) SequencerState() (RunningState, error)

func (*ActiveConfigPersistence) SequencerStopped

func (p *ActiveConfigPersistence) SequencerStopped() error

type ConductorClient added in v1.4.0

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

ConductorClient is a client for the op-conductor RPC service.

func NewConductorClient added in v1.4.0

func NewConductorClient(cfg *Config, log log.Logger, metrics *metrics.Metrics) *ConductorClient

NewConductorClient returns a new conductor client for the op-conductor RPC service.

func (*ConductorClient) Close added in v1.4.0

func (c *ConductorClient) Close()

func (*ConductorClient) CommitUnsafePayload added in v1.4.0

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

CommitUnsafePayload commits an unsafe payload to the conductor log.

func (*ConductorClient) Leader added in v1.4.0

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

Leader returns true if this node is the leader sequencer.

type Config

type Config struct {
	L1 L1EndpointSetup
	L2 L2EndpointSetup

	Beacon L1BeaconEndpointSetup

	Driver driver.Config

	Rollup rollup.Config

	// P2PSigner will be used for signing off on published content
	// if the node is sequencing and if the p2p stack is enabled
	P2PSigner p2p.SignerSetup

	RPC RPCConfig

	P2P p2p.SetupP2P

	Metrics MetricsConfig

	Pprof oppprof.CLIConfig

	// Used to poll the L1 for new finalized or safe blocks
	L1EpochPollInterval time.Duration

	ConfigPersistence ConfigPersistence

	// Path to store safe head database. Disabled when set to empty string
	SafeDBPath string

	// RuntimeConfigReloadInterval defines the interval between runtime config reloads.
	// Disabled if <= 0.
	// Runtime config changes should be picked up from log-events,
	// but if log-events are not coming in (e.g. not syncing blocks) then the reload ensures the config stays accurate.
	RuntimeConfigReloadInterval time.Duration

	// Optional
	Tracer    Tracer
	Heartbeat HeartbeatConfig

	Sync sync.Config

	// Cancel to request a premature shutdown of the node itself, e.g. when halting. This may be nil.
	Cancel context.CancelCauseFunc

	// [OPTIONAL] The reth DB path to read receipts from
	RethDBPath string

	// Conductor is used to determine this node is the leader sequencer.
	ConductorEnabled    bool
	ConductorRpc        string
	ConductorRpcTimeout time.Duration

	// Plasma DA config
	Plasma plasma.CLIConfig
}

func (*Config) Check

func (cfg *Config) Check() error

Check verifies that the given configuration makes sense

func (*Config) LoadPersisted

func (cfg *Config) LoadPersisted(log log.Logger) error

type ConfigPersistence

type ConfigPersistence interface {
	SequencerStarted() error
	SequencerStopped() error
	SequencerState() (RunningState, error)
}

type DisabledConfigPersistence

type DisabledConfigPersistence struct {
}

DisabledConfigPersistence provides an implementation of config persistence that does not persist anything and reports unset for all values

func (DisabledConfigPersistence) SequencerStarted

func (d DisabledConfigPersistence) SequencerStarted() error

func (DisabledConfigPersistence) SequencerState

func (d DisabledConfigPersistence) SequencerState() (RunningState, error)

func (DisabledConfigPersistence) SequencerStopped

func (d DisabledConfigPersistence) SequencerStopped() error

type HeartbeatConfig

type HeartbeatConfig struct {
	Enabled bool
	Moniker string
	URL     string
}

type L1BeaconEndpointConfig added in v1.4.0

type L1BeaconEndpointConfig struct {
	BeaconAddr             string // Address of L1 User Beacon-API endpoint to use (beacon namespace required)
	BeaconHeader           string // Optional HTTP header for all requests to L1 Beacon
	BeaconArchiverAddr     string // Address of L1 User Beacon-API Archive endpoint to use for expired blobs (beacon namespace required)
	BeaconCheckIgnore      bool   // When false, halt startup if the beacon version endpoint fails
	BeaconFetchAllSidecars bool   // Whether to fetch all blob sidecars and filter locally
}

func (*L1BeaconEndpointConfig) Check added in v1.4.0

func (cfg *L1BeaconEndpointConfig) Check() error

func (*L1BeaconEndpointConfig) Setup added in v1.4.0

func (*L1BeaconEndpointConfig) ShouldFetchAllSidecars added in v1.4.0

func (cfg *L1BeaconEndpointConfig) ShouldFetchAllSidecars() bool

func (*L1BeaconEndpointConfig) ShouldIgnoreBeaconCheck added in v1.4.0

func (cfg *L1BeaconEndpointConfig) ShouldIgnoreBeaconCheck() bool

type L1BeaconEndpointSetup added in v1.4.0

type L1BeaconEndpointSetup interface {
	Setup(ctx context.Context, log log.Logger) (cl sources.BeaconClient, fb []sources.BlobSideCarsFetcher, err error)
	// ShouldIgnoreBeaconCheck returns true if the Beacon-node version check should not halt startup.
	ShouldIgnoreBeaconCheck() bool
	ShouldFetchAllSidecars() bool
	Check() error
}

type L1EndpointConfig

type L1EndpointConfig struct {
	L1NodeAddr string // Address of L1 User JSON-RPC endpoint to use (eth namespace required)

	// L1TrustRPC: if we trust the L1 RPC we do not have to validate L1 response contents like headers
	// against block hashes, or cached transaction sender addresses.
	// Thus we can sync faster at the risk of the source RPC being wrong.
	L1TrustRPC bool

	// L1RPCKind identifies the RPC provider kind that serves the RPC,
	// to inform the optimal usage of the RPC for transaction receipts fetching.
	L1RPCKind sources.RPCProviderKind

	// RateLimit specifies a self-imposed rate-limit on L1 requests. 0 is no rate-limit.
	RateLimit float64

	// BatchSize specifies the maximum batch-size, which also applies as L1 rate-limit burst amount (if set).
	BatchSize int

	// MaxConcurrency specifies the maximum number of concurrent requests to the L1 RPC.
	MaxConcurrency int

	// HttpPollInterval specifies the interval between polling for the latest L1 block,
	// when the RPC is detected to be an HTTP type.
	// It is recommended to use websockets or IPC for efficient following of the changing block.
	// Setting this to 0 disables polling.
	HttpPollInterval time.Duration
}

func (*L1EndpointConfig) Check

func (cfg *L1EndpointConfig) Check() error

func (*L1EndpointConfig) Setup

func (cfg *L1EndpointConfig) Setup(ctx context.Context, log log.Logger, rollupCfg *rollup.Config) (client.RPC, *sources.L1ClientConfig, error)

type L1EndpointSetup

type L1EndpointSetup interface {
	// Setup a RPC client to a L1 node to pull rollup input-data from.
	// The results of the RPC client may be trusted for faster processing, or strictly validated.
	// The kind of the RPC may be non-basic, to optimize RPC usage.
	Setup(ctx context.Context, log log.Logger, rollupCfg *rollup.Config) (cl client.RPC, rpcCfg *sources.L1ClientConfig, err error)
	Check() error
}

type L2EndpointConfig

type L2EndpointConfig struct {
	// L2EngineAddr is the address of the L2 Engine JSON-RPC endpoint to use. The engine and eth
	// namespaces must be enabled by the endpoint.
	L2EngineAddr string

	// JWT secrets for L2 Engine API authentication during HTTP or initial Websocket communication.
	// Any value for an IPC connection.
	L2EngineJWTSecret [32]byte
}

func (*L2EndpointConfig) Check

func (cfg *L2EndpointConfig) Check() error

func (*L2EndpointConfig) Setup

type L2EndpointSetup

type L2EndpointSetup interface {
	// Setup a RPC client to a L2 execution engine to process rollup blocks with.
	Setup(ctx context.Context, log log.Logger, rollupCfg *rollup.Config) (cl client.RPC, rpcCfg *sources.EngineClientConfig, err error)
	Check() error
}

type MetricsConfig

type MetricsConfig struct {
	Enabled    bool
	ListenAddr string
	ListenPort int
}

func (MetricsConfig) Check

func (m MetricsConfig) Check() error

type OpNode

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

func New

func New(ctx context.Context, cfg *Config, log log.Logger, snapshotLog log.Logger, appVersion string, m *metrics.Metrics) (*OpNode, error)

New creates a new OpNode instance. The provided ctx argument is for the span of initialization only; the node will immediately Stop(ctx) before finishing initialization if the context is canceled during initialization.

func (*OpNode) HTTPEndpoint

func (n *OpNode) HTTPEndpoint() string

func (*OpNode) OnNewL1Finalized

func (n *OpNode) OnNewL1Finalized(ctx context.Context, sig eth.L1BlockRef)

func (*OpNode) OnNewL1Head

func (n *OpNode) OnNewL1Head(ctx context.Context, sig eth.L1BlockRef)

func (*OpNode) OnNewL1Safe

func (n *OpNode) OnNewL1Safe(ctx context.Context, sig eth.L1BlockRef)

func (*OpNode) OnUnsafeL2Payload

func (n *OpNode) OnUnsafeL2Payload(ctx context.Context, from peer.ID, envelope *eth.ExecutionPayloadEnvelope) error

func (*OpNode) P2P

func (n *OpNode) P2P() p2p.Node

func (*OpNode) PublishL2Payload

func (n *OpNode) PublishL2Payload(ctx context.Context, envelope *eth.ExecutionPayloadEnvelope) error

func (*OpNode) RequestL2Range

func (n *OpNode) RequestL2Range(ctx context.Context, start, end eth.L2BlockRef) error

func (*OpNode) RuntimeConfig

func (n *OpNode) RuntimeConfig() ReadonlyRuntimeConfig

func (*OpNode) Start

func (n *OpNode) Start(ctx context.Context) error

func (*OpNode) Stop

func (n *OpNode) Stop(ctx context.Context) error

Stop stops the node and closes all resources. If the provided ctx is expired, the node will accelerate the stop where possible, but still fully close.

func (*OpNode) Stopped

func (n *OpNode) Stopped() bool

type PreparedL1Endpoint

type PreparedL1Endpoint struct {
	Client          client.RPC
	TrustRPC        bool
	RPCProviderKind sources.RPCProviderKind
}

PreparedL1Endpoint enables testing with an in-process pre-setup RPC connection to L1

func (*PreparedL1Endpoint) Check

func (cfg *PreparedL1Endpoint) Check() error

func (*PreparedL1Endpoint) Setup

type PreparedL2Endpoints

type PreparedL2Endpoints struct {
	Client client.RPC
}

PreparedL2Endpoints enables testing with in-process pre-setup RPC connections to L2 engines

func (*PreparedL2Endpoints) Check

func (p *PreparedL2Endpoints) Check() error

func (*PreparedL2Endpoints) Setup

type RPCConfig

type RPCConfig struct {
	ListenAddr  string
	ListenPort  int
	EnableAdmin bool
}

func (*RPCConfig) HttpEndpoint

func (cfg *RPCConfig) HttpEndpoint() string

type ReadonlyRuntimeConfig

type ReadonlyRuntimeConfig interface {
	P2PSequencerAddress() common.Address
}

type RunningState

type RunningState int
const (
	StateUnset RunningState = iota
	StateStarted
	StateStopped
)

type RuntimeCfgL1Source

type RuntimeCfgL1Source interface {
	ReadStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockHash common.Hash) (common.Hash, error)
}

type RuntimeConfig

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

RuntimeConfig maintains runtime-configurable options. These options are loaded based on initial loading + updates for every subsequent L1 block. Only the *latest* values are maintained however, the runtime config has no concept of chain history, does not require any archive data, and may be out of sync with the rollup derivation process.

func NewRuntimeConfig

func NewRuntimeConfig(log log.Logger, l1Client RuntimeCfgL1Source, rollupCfg *rollup.Config) *RuntimeConfig

func (*RuntimeConfig) Load

func (r *RuntimeConfig) Load(ctx context.Context, l1Ref eth.L1BlockRef) error

Load resets the runtime configuration by fetching the latest config data from L1 at the given L1 block. Load is safe to call concurrently, but will lock the runtime configuration modifications only, and will thus not block other Load calls with possibly alternative L1 block views.

func (*RuntimeConfig) P2PSequencerAddress

func (r *RuntimeConfig) P2PSequencerAddress() common.Address

type SafeDBReader added in v1.4.0

type SafeDBReader interface {
	SafeHeadAtL1(ctx context.Context, l1BlockNum uint64) (l1 eth.BlockID, l2 eth.BlockID, err error)
}

type Tracer

type Tracer interface {
	OnNewL1Head(ctx context.Context, sig eth.L1BlockRef)
	OnUnsafeL2Payload(ctx context.Context, from peer.ID, payload *eth.ExecutionPayloadEnvelope)
	OnPublishL2Payload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope)
}

Tracer configures the OpNode to share events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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