node

package
v0.0.0-...-23d24bf Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT, MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 rpcMetrics) *adminAPI

func NewNodeAPI

func NewNodeAPI(config *rollup.Config, l2Client l2EthClient, dr driverClient, log log.Logger, m rpcMetrics) *nodeAPI

Types

type Config

type Config struct {
	L1     L1EndpointSetup
	L2     L2EndpointSetup
	L2Sync L2SyncEndpointSetup

	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 ptpprof.CLIConfig

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

	// Optional
	Tracer    Tracer
	Heartbeat HeartbeatConfig
}

func (*Config) Check

func (cfg *Config) Check() error

Check verifies that the given configuration makes sense

type HeartbeatConfig

type HeartbeatConfig struct {
	Enabled bool
	Moniker string
	URL     string
}

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

	// 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 string // Address of L2 Engine JSON-RPC endpoint to use (engine and eth namespace required)

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

type L2SyncEndpointConfig struct {
	// Address of the L2 RPC to use for backup sync, may be empty if RPC alt-sync is disabled.
	L2NodeAddr string
	TrustRPC   bool
}

L2SyncEndpointConfig contains configuration for the fallback sync endpoint

func (*L2SyncEndpointConfig) Check

func (cfg *L2SyncEndpointConfig) Check() error

func (*L2SyncEndpointConfig) Setup

Setup creates an RPC client to sync from. It will return nil without error if no sync method is configured.

type L2SyncEndpointSetup

type L2SyncEndpointSetup interface {
	// Setup a RPC client to another L2 node to sync L2 blocks from.
	// It may return a nil client with nil error if RPC based sync is not enabled.
	Setup(ctx context.Context, log log.Logger, rollupCfg *rollup.Config) (cl client.RPC, rpcCfg *sources.SyncClientConfig, err error)
	Check() error
}

type MetricsConfig

type MetricsConfig struct {
	Enabled    bool
	ListenAddr string
	ListenPort int
}

func (MetricsConfig) Check

func (m MetricsConfig) Check() error

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 PreparedL2SyncEndpoint

type PreparedL2SyncEndpoint struct {
	// RPC endpoint to use for syncing, may be nil if RPC alt-sync is disabled.
	Client   client.RPC
	TrustRPC bool
}

func (*PreparedL2SyncEndpoint) Check

func (cfg *PreparedL2SyncEndpoint) Check() error

func (*PreparedL2SyncEndpoint) Setup

type PtNode

type PtNode 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) (*PtNode, error)

func (*PtNode) Close

func (n *PtNode) Close() error

Close closes all resources.

func (*PtNode) HTTPEndpoint

func (n *PtNode) HTTPEndpoint() string

func (*PtNode) ListenAddr

func (n *PtNode) ListenAddr() string

func (*PtNode) OnNewL1Finalized

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

func (*PtNode) OnNewL1Head

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

func (*PtNode) OnNewL1Safe

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

func (*PtNode) OnUnsafeL2Payload

func (n *PtNode) OnUnsafeL2Payload(ctx context.Context, from peer.ID, payload *eth.ExecutionPayload) error

func (*PtNode) P2P

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

func (*PtNode) PublishL2Payload

func (n *PtNode) PublishL2Payload(ctx context.Context, payload *eth.ExecutionPayload) error

func (*PtNode) RequestL2Range

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

func (*PtNode) Start

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

type RPCConfig

type RPCConfig struct {
	ListenAddr  string
	ListenPort  int
	EnableAdmin bool
}

func (*RPCConfig) HttpEndpoint

func (cfg *RPCConfig) HttpEndpoint() string

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 Tracer

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

Tracer configures the PtNode to share events

Jump to

Keyboard shortcuts

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