dial

package
v0.0.0-...-011bec4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultActiveSequencerFollowerCheckDuration = 2 * DefaultDialTimeout
View Source
const DefaultDialTimeout = 1 * time.Minute

DefaultDialTimeout is a default timeout for dialing a client.

Variables

This section is empty.

Functions

func DialEthClientWithTimeout

func DialEthClientWithTimeout(ctx context.Context, timeout time.Duration, log log.Logger, url string) (*ethclient.Client, error)

DialEthClientWithTimeout attempts to dial the L1 provider using the provided URL. If the dial doesn't complete within defaultDialTimeout seconds, this method will return an error.

func DialRPCClientWithTimeout

func DialRPCClientWithTimeout(ctx context.Context, timeout time.Duration, log log.Logger, url string) (*rpc.Client, error)

DialRPCClientWithTimeout attempts to dial the RPC provider using the provided URL. If the dial doesn't complete within timeout seconds, this method will return an error.

func DialRollupClientWithTimeout

func DialRollupClientWithTimeout(ctx context.Context, timeout time.Duration, log log.Logger, url string) (*sources.RollupClient, error)

DialRollupClientWithTimeout attempts to dial the RPC provider using the provided URL. If the dial doesn't complete within timeout seconds, this method will return an error.

func WaitRollupSync

func WaitRollupSync(
	ctx context.Context,
	lgr log.Logger,
	rollup SyncStatusProvider,
	l1BlockTarget uint64,
	pollInterval time.Duration,
) error

Types

type ActiveL2EndpointProvider

type ActiveL2EndpointProvider struct {
	ActiveL2RollupProvider
	// contains filtered or unexported fields
}

ActiveL2EndpointProvider is an interface for providing a RollupClient and l2 eth client It manages the lifecycle of the RollupClient and eth client for callers It does this by failing over down the list of rollupUrls if the current one is inactive or broken

func NewActiveL2EndpointProvider

func NewActiveL2EndpointProvider(ctx context.Context,
	ethUrls, rollupUrls []string,
	checkDuration time.Duration,
	networkTimeout time.Duration,
	logger log.Logger,
) (*ActiveL2EndpointProvider, error)

NewActiveL2EndpointProvider creates a new ActiveL2EndpointProvider the checkDuration is the duration between checks to see if the current rollup client is active provide a checkDuration of 0 to check every time

func (*ActiveL2EndpointProvider) Close

func (p *ActiveL2EndpointProvider) Close()

func (*ActiveL2EndpointProvider) EthClient

type ActiveL2RollupProvider

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

ActiveL2EndpointProvider is an interface for providing a RollupClient It manages the lifecycle of the RollupClient for callers It does this by failing over down the list of rollupUrls if the current one is inactive or broken

func NewActiveL2RollupProvider

func NewActiveL2RollupProvider(
	ctx context.Context,
	rollupUrls []string,
	checkDuration time.Duration,
	networkTimeout time.Duration,
	logger log.Logger,
) (*ActiveL2RollupProvider, error)

NewActiveL2RollupProvider creates a new ActiveL2RollupProvider the checkDuration is the duration between checks to see if the current rollup client is active provide a checkDuration of 0 to check every time

func (*ActiveL2RollupProvider) Close

func (p *ActiveL2RollupProvider) Close()

func (*ActiveL2RollupProvider) RollupClient

type EthClientInterface

type EthClientInterface interface {
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

	Close()
}

EthClientInterface is an interface for providing an ethclient.Client It does not describe all of the functions an ethclient.Client has, only the ones used by callers of the L2 Providers

type L2EndpointProvider

type L2EndpointProvider interface {
	RollupProvider
	// EthClient(ctx) returns the underlying ethclient pointing to the L2 execution node.
	// Note: ctx should be a lifecycle context without an attached timeout as client selection may involve
	// multiple network operations, specifically in the case of failover.
	EthClient(ctx context.Context) (EthClientInterface, error)
}

L2EndpointProvider is an interface for providing a RollupClient and l2 eth client It manages the lifecycle of the RollupClient and eth client for callers It does this by extending the RollupProvider interface to add the ability to get an EthClient

type RollupClientInterface

type RollupClientInterface interface {
	SyncStatusProvider
	OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
	RollupConfig(ctx context.Context) (*rollup.Config, error)
	StartSequencer(ctx context.Context, unsafeHead common.Hash) error
	SequencerActive(ctx context.Context) (bool, error)
	Close()
}

RollupClientInterface is an interface for providing a RollupClient It does not describe all of the functions a RollupClient has, only the ones used by the L2 Providers and their callers

type RollupProvider

type RollupProvider interface {
	// RollupClient(ctx) returns the underlying sources.RollupClient pointing to the L2 rollup consensus node.
	// Note: ctx should be a lifecycle context without an attached timeout as client selection may involve
	// multiple network operations, specifically in the case of failover.
	RollupClient(ctx context.Context) (RollupClientInterface, error)
	// Close() closes the underlying client or clients
	Close()
}

RollupProvider is an interface for providing a RollupClient It manages the lifecycle of the RollupClient for callers

type StaticL2EndpointProvider

type StaticL2EndpointProvider struct {
	StaticL2RollupProvider
	// contains filtered or unexported fields
}

StaticL2EndpointProvider is a L2EndpointProvider that always returns the same static RollupClient and eth client It is meant for scenarios where a single, unchanging (L2 rollup node, L2 execution node) pair is used

func NewStaticL2EndpointProvider

func NewStaticL2EndpointProvider(ctx context.Context, log log.Logger, ethClientUrl string, rollupClientUrl string) (*StaticL2EndpointProvider, error)

func (*StaticL2EndpointProvider) Close

func (p *StaticL2EndpointProvider) Close()

func (*StaticL2EndpointProvider) EthClient

type StaticL2RollupProvider

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

StaticL2RollupProvider is a RollupProvider that always returns the same static RollupClient It is meant for scenarios where a single, unchanging L2 rollup node is used

func NewStaticL2RollupProvider

func NewStaticL2RollupProvider(ctx context.Context, log log.Logger, rollupClientUrl string) (*StaticL2RollupProvider, error)

func NewStaticL2RollupProviderFromExistingRollup

func NewStaticL2RollupProviderFromExistingRollup(rollupCl *sources.RollupClient) (*StaticL2RollupProvider, error)

The NewStaticL2EndpointProviderFromExistingRollup constructor is used in e2e testing

func (*StaticL2RollupProvider) Close

func (p *StaticL2RollupProvider) Close()

func (*StaticL2RollupProvider) RollupClient

type SyncStatusProvider

type SyncStatusProvider interface {
	SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
}

SyncStatusProvider is the interface of a rollup client from which its sync status can be queried.

Jump to

Keyboard shortcuts

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