dial

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: 16 Imported by: 12

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

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, callerOpts ...client.RPCOption) (*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 added in v1.7.4

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

Types

type ActiveL2EndpointProvider added in v1.4.2

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

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

func (p *ActiveL2EndpointProvider) Close()

func (*ActiveL2EndpointProvider) EthClient added in v1.4.2

type ActiveL2RollupProvider added in v1.4.2

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

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

func (p *ActiveL2RollupProvider) Close()

func (*ActiveL2RollupProvider) RollupClient added in v1.4.2

type EthClientInterface added in v1.4.2

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

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

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

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

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

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

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

func (*StaticL2EndpointProvider) Close added in v1.4.2

func (p *StaticL2EndpointProvider) Close()

func (*StaticL2EndpointProvider) EthClient added in v1.4.2

type StaticL2RollupProvider added in v1.4.2

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

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

func NewStaticL2RollupProviderFromExistingRollup added in v1.4.2

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

The NewStaticL2EndpointProviderFromExistingRollup constructor is used in e2e testing

func (*StaticL2RollupProvider) Close added in v1.4.2

func (p *StaticL2RollupProvider) Close()

func (*StaticL2RollupProvider) RollupClient added in v1.4.2

type SyncStatusProvider added in v1.7.4

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