driver

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Time to wait before the next try, when receiving subscription errors.
	RetryDelay         = 10 * time.Second
	MaxReorgDepth      = 500
	ReorgRollbackDepth = 20
)

Variables

This section is empty.

Functions

func InitFromConfig

func InitFromConfig(ctx context.Context, d *Driver, cfg *Config) (err error)

InitFromConfig initializes the driver instance based on the given configurations.

Types

type Config

type Config struct {
	L1Endpoint                    string
	L2Endpoint                    string
	L2EngineEndpoint              string
	TaikoL1Address                common.Address
	TaikoL2Address                common.Address
	ThrowawayBlocksBuilderPrivKey *ecdsa.PrivateKey
	JwtSecret                     string
	P2PSyncVerifiedBlocks         bool
}

Config contains the configurations to initialize a Taiko driver.

func NewConfigFromCliContext

func NewConfigFromCliContext(c *cli.Context) (*Config, error)

NewConfigFromCliContext creates a new config instance from the command line inputs.

type Driver

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

Driver keeps the L2 node's local block chain in sync with the TaikoL1 contract.

func (*Driver) ChainSyncer added in v0.1.5

func (d *Driver) ChainSyncer() *L2ChainSyncer

ChainSyncer returns the driver's chain syncer.

func (*Driver) Close

func (d *Driver) Close()

Close closes the driver instance.

func (*Driver) InitFromCli

func (d *Driver) InitFromCli(ctx context.Context, c *cli.Context) error

New initializes the given driver instance based on the command line flags.

func (*Driver) Name

func (d *Driver) Name() string

Name returns the application name.

func (*Driver) Start

func (d *Driver) Start() error

Start starts the driver instance.

type L2ChainSyncer added in v0.1.5

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

func NewL2ChainSyncer added in v0.1.5

func NewL2ChainSyncer(
	ctx context.Context,
	rpc *rpc.Client,
	state *State,
	throwawayBlocksBuilderPrivKey *ecdsa.PrivateKey,
	p2pSyncVerifiedBlocks bool,
) (*L2ChainSyncer, error)

NewL2ChainSyncer creates a new chain syncer instance.

func (*L2ChainSyncer) AheadOfProtocolVerifiedHead added in v0.1.5

func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead() bool

AheadOfProtocolVerifiedHead checks whether the L2 chain is ahead of verified head in protocol.

func (*L2ChainSyncer) ProcessL1Blocks added in v0.1.5

func (s *L2ChainSyncer) ProcessL1Blocks(ctx context.Context, l1End *types.Header) error

ProcessL1Blocks fetches all `TaikoL1.BlockProposed` events between given L1 block heights, and then tries inserting them into L2 node's block chain.

func (*L2ChainSyncer) Sync added in v0.1.5

func (s *L2ChainSyncer) Sync(l1End *types.Header) error

Sync performs a sync operation to L2 node's local chain.

func (*L2ChainSyncer) TriggerBeaconSync added in v0.1.5

func (s *L2ChainSyncer) TriggerBeaconSync() error

TriggerBeaconSync triggers the L2 node to start performing a beacon-sync.

type State

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

func NewState

func NewState(ctx context.Context, rpc *rpc.Client) (*State, error)

NewState creates a new driver state instance.

func (*State) Close

func (s *State) Close()

Close closes all inner subscriptions.

func (*State) GetL1Head added in v0.1.5

func (s *State) GetL1Head() *types.Header

GetL1Head reads the L1 head concurrent safely.

func (*State) GetL2Head added in v0.1.5

func (s *State) GetL2Head() *types.Header

GetL2Head reads the L2 head concurrent safely.

func (*State) SubL1HeadsFeed

func (s *State) SubL1HeadsFeed(ch chan *types.Header) event.Subscription

SubL1HeadsFeed registers a subscription of new L1 heads.

func (*State) VerifyL2Block added in v0.1.5

func (s *State) VerifyL2Block(ctx context.Context, protocolBlockHash common.Hash) error

VerifyL2Block checks whether the given block is in L2 node's local chain.

type VerifiedHeaderInfo added in v0.1.5

type VerifiedHeaderInfo struct {
	ID     *big.Int
	Hash   common.Hash
	Height *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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