driver

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 32 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 AnchorConstructor added in v0.1.6

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

AnchorConstructor is responsible for assembling the anchor transaction (TaikoL2.anchor) in each L2 block, which is always the first transaction.

func NewAnchorConstructor added in v0.1.6

func NewAnchorConstructor(
	rpc *rpc.Client,
	gasLimit uint64,
	goldenTouchAddress common.Address,
	goldenTouchPrivKey string,
) (*AnchorConstructor, error)

NewAnchorConstructor creates a new AnchorConstructor instance.

func (*AnchorConstructor) AssembleAnchorTx added in v0.1.6

func (c *AnchorConstructor) AssembleAnchorTx(
	ctx context.Context,

	l1Height *big.Int,
	l1Hash common.Hash,

	l2Height *big.Int,
) (*types.Transaction, error)

AssembleAnchorTx assembles a signed TaikoL2.anchor transaction.

type BeaconSyncProgressTracker added in v0.1.9

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

BeaconSyncProgressTracker is responsible for tracking the L2 execution engine's sync progress, after a beacon sync is triggered in it, and check whether the L2 execution is not able to sync through P2P (due to no connected peer or some other reasons).

func NewBeaconSyncProgressTracker added in v0.1.9

func NewBeaconSyncProgressTracker(c *ethclient.Client, timeout time.Duration) *BeaconSyncProgressTracker

NewBeaconSyncProgressTracker creates a new BeaconSyncProgressTracker instance.

func (*BeaconSyncProgressTracker) ClearMeta added in v0.1.9

func (s *BeaconSyncProgressTracker) ClearMeta()

ClearMeta cleans the inner beacon sync meta data.

func (*BeaconSyncProgressTracker) HeadChanged added in v0.1.9

func (s *BeaconSyncProgressTracker) HeadChanged(newID *big.Int) bool

HeadChanged checks if a new beacon sync request will be needed.

func (*BeaconSyncProgressTracker) LastSyncedVerifiedBlockHash added in v0.1.9

func (s *BeaconSyncProgressTracker) LastSyncedVerifiedBlockHash() common.Hash

LastSyncedVerifiedBlockHash returns tracker.lastSyncedVerifiedBlockHash.

func (*BeaconSyncProgressTracker) LastSyncedVerifiedBlockHeight added in v0.1.9

func (s *BeaconSyncProgressTracker) LastSyncedVerifiedBlockHeight() *big.Int

LastSyncedVerifiedBlockHeight returns tracker.lastSyncedVerifiedBlockHeight.

func (*BeaconSyncProgressTracker) LastSyncedVerifiedBlockID added in v0.1.9

func (s *BeaconSyncProgressTracker) LastSyncedVerifiedBlockID() *big.Int

LastSyncedVerifiedBlockID returns tracker.lastSyncedVerifiedBlockID.

func (*BeaconSyncProgressTracker) OutOfSync added in v0.1.9

func (s *BeaconSyncProgressTracker) OutOfSync() bool

OutOfSync tells whether the L2 execution engine is marked as out of sync.

func (*BeaconSyncProgressTracker) Track added in v0.1.9

Track starts the inner event loop, to monitor the sync progress.

func (*BeaconSyncProgressTracker) Triggered added in v0.1.9

func (s *BeaconSyncProgressTracker) Triggered() bool

Triggered returns tracker.triggered.

func (*BeaconSyncProgressTracker) UpdateMeta added in v0.1.9

func (s *BeaconSyncProgressTracker) UpdateMeta(id, height *big.Int, blockHash common.Hash)

UpdateMeta updates the inner beacon sync meta data.

type Config

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

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 execution engine'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 HeightOrID added in v0.1.9

type HeightOrID struct {
	Height *big.Int
	ID     *big.Int
}

HeightOrID contains a block height or a block ID.

func (*HeightOrID) NotEmpty added in v0.1.9

func (h *HeightOrID) NotEmpty() bool

NotEmpty checks whether this is an empty struct.

type L2ChainSyncer added in v0.1.5

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

L2ChainSyncer is responsible for keeping the L2 execution engine's local chain in sync with the one in TaikoL1 contract.

func NewL2ChainSyncer added in v0.1.5

func NewL2ChainSyncer(
	ctx context.Context,
	rpc *rpc.Client,
	state *State,
	throwawayBlocksBuilderPrivKey *ecdsa.PrivateKey,
	p2pSyncVerifiedBlocks bool,
	p2pSyncTimeout time.Duration,
) (*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 execution engine'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 execution engine's local chain.

func (*L2ChainSyncer) TriggerBeaconSync added in v0.1.5

func (s *L2ChainSyncer) TriggerBeaconSync() error

TriggerBeaconSync triggers the L2 execution engine 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 execution engine'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