l1_parallel_sync

package
v0.5.0-RC7 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 19 Imported by: 0

Documentation

Overview

package synchronizer This file contains common struct definitions and functions used by L1 sync. l1DataMessage : struct to hold L1 rollup info data package send from producer to consumer

This packages could contain data or control information.
 - data is a real rollup info
 - control send actions to consumer

Constructors: - newL1PackageDataControl: create a l1PackageData with only control information - newL1PackageData: create a l1PackageData with data and control information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewL1RollupInfoConsumer

func NewL1RollupInfoConsumer(cfg ConfigConsumer,
	synchronizer synchronizerProcessBlockRangeInterface, ch chan L1SyncMessage) *l1RollupInfoConsumer

NewL1RollupInfoConsumer creates a new l1RollupInfoConsumer

Types

type ConfigConsumer

type ConfigConsumer struct {
	ApplyAfterNumRollupReceived int
	AceptableInacctivityTime    time.Duration
}

ConfigConsumer configuration for L1 sync parallel consumer

type ConfigProducer

type ConfigProducer struct {
	// SyncChunkSize is the number of blocks to be retrieved in each request
	SyncChunkSize uint64
	// TtlOfLastBlockOnL1 is the time to wait before ask for a new last block on L1
	TtlOfLastBlockOnL1 time.Duration
	// TimeoutForRequestLastBlockOnL1 is the timeout for request a new last block on L1
	TimeoutForRequestLastBlockOnL1 time.Duration
	// NumOfAllowedRetriesForRequestLastBlockOnL1 is the number of retries for request a new last block on L1
	NumOfAllowedRetriesForRequestLastBlockOnL1 int

	//TimeOutMainLoop timeout for main loop if no is synchronized yet, this time is a safeguard because is not needed
	TimeOutMainLoop time.Duration
	//TimeForShowUpStatisticsLog how ofter we show a log with statistics, 0 means disabled
	TimeForShowUpStatisticsLog time.Duration
	// MinTimeBetweenRetriesForRollupInfo is the minimum time between retries for rollup info
	MinTimeBetweenRetriesForRollupInfo time.Duration
}

ConfigProducer : configuration for producer

func (*ConfigProducer) String

func (cfg *ConfigProducer) String() string

type L1ParallelEthermanInterface

type L1ParallelEthermanInterface interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error)
	GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)
	EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error)
	GetLatestBatchNumber() (uint64, error)
	GetTrustedSequencerURL() (string, error)
	VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error)
	GetLatestVerifiedBatchNum() (uint64, error)
}

L1ParallelEthermanInterface is an interface for the etherman package

type L1ParallelEthermanInterfaceMock

type L1ParallelEthermanInterfaceMock struct {
	mock.Mock
}

L1ParallelEthermanInterfaceMock is an autogenerated mock type for the L1ParallelEthermanInterface type

func NewL1ParallelEthermanInterfaceMock

func NewL1ParallelEthermanInterfaceMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *L1ParallelEthermanInterfaceMock

NewL1ParallelEthermanInterfaceMock creates a new instance of L1ParallelEthermanInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*L1ParallelEthermanInterfaceMock) EXPECT

func (*L1ParallelEthermanInterfaceMock) EthBlockByNumber

func (_m *L1ParallelEthermanInterfaceMock) EthBlockByNumber(ctx context.Context, blockNumber uint64) (*types.Block, error)

EthBlockByNumber provides a mock function with given fields: ctx, blockNumber

func (*L1ParallelEthermanInterfaceMock) GetLatestBatchNumber

func (_m *L1ParallelEthermanInterfaceMock) GetLatestBatchNumber() (uint64, error)

GetLatestBatchNumber provides a mock function with given fields:

func (*L1ParallelEthermanInterfaceMock) GetLatestVerifiedBatchNum

func (_m *L1ParallelEthermanInterfaceMock) GetLatestVerifiedBatchNum() (uint64, error)

GetLatestVerifiedBatchNum provides a mock function with given fields:

func (*L1ParallelEthermanInterfaceMock) GetRollupInfoByBlockRange

func (_m *L1ParallelEthermanInterfaceMock) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)

GetRollupInfoByBlockRange provides a mock function with given fields: ctx, fromBlock, toBlock

func (*L1ParallelEthermanInterfaceMock) GetTrustedSequencerURL

func (_m *L1ParallelEthermanInterfaceMock) GetTrustedSequencerURL() (string, error)

GetTrustedSequencerURL provides a mock function with given fields:

func (*L1ParallelEthermanInterfaceMock) HeaderByNumber

func (_m *L1ParallelEthermanInterfaceMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber provides a mock function with given fields: ctx, number

func (*L1ParallelEthermanInterfaceMock) VerifyGenBlockNumber

func (_m *L1ParallelEthermanInterfaceMock) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error)

VerifyGenBlockNumber provides a mock function with given fields: ctx, genBlockNumber

type L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call

type L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EthBlockByNumber'

func (*L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call) Return

func (*L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call) Run

func (*L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_Expecter

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

func (*L1ParallelEthermanInterfaceMock_Expecter) EthBlockByNumber

func (_e *L1ParallelEthermanInterfaceMock_Expecter) EthBlockByNumber(ctx interface{}, blockNumber interface{}) *L1ParallelEthermanInterfaceMock_EthBlockByNumber_Call

EthBlockByNumber is a helper method to define mock.On call

  • ctx context.Context
  • blockNumber uint64

func (*L1ParallelEthermanInterfaceMock_Expecter) GetLatestBatchNumber

GetLatestBatchNumber is a helper method to define mock.On call

func (*L1ParallelEthermanInterfaceMock_Expecter) GetLatestVerifiedBatchNum

GetLatestVerifiedBatchNum is a helper method to define mock.On call

func (*L1ParallelEthermanInterfaceMock_Expecter) GetRollupInfoByBlockRange

func (_e *L1ParallelEthermanInterfaceMock_Expecter) GetRollupInfoByBlockRange(ctx interface{}, fromBlock interface{}, toBlock interface{}) *L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call

GetRollupInfoByBlockRange is a helper method to define mock.On call

  • ctx context.Context
  • fromBlock uint64
  • toBlock *uint64

func (*L1ParallelEthermanInterfaceMock_Expecter) GetTrustedSequencerURL

GetTrustedSequencerURL is a helper method to define mock.On call

func (*L1ParallelEthermanInterfaceMock_Expecter) HeaderByNumber

func (_e *L1ParallelEthermanInterfaceMock_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *L1ParallelEthermanInterfaceMock_HeaderByNumber_Call

HeaderByNumber is a helper method to define mock.On call

  • ctx context.Context
  • number *big.Int

func (*L1ParallelEthermanInterfaceMock_Expecter) VerifyGenBlockNumber

func (_e *L1ParallelEthermanInterfaceMock_Expecter) VerifyGenBlockNumber(ctx interface{}, genBlockNumber interface{}) *L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call

VerifyGenBlockNumber is a helper method to define mock.On call

  • ctx context.Context
  • genBlockNumber uint64

type L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call

type L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBatchNumber'

func (*L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call) Return

func (*L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call) Run

func (*L1ParallelEthermanInterfaceMock_GetLatestBatchNumber_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call

type L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestVerifiedBatchNum'

func (*L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call) Return

func (*L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call) Run

func (*L1ParallelEthermanInterfaceMock_GetLatestVerifiedBatchNum_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call

type L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollupInfoByBlockRange'

func (*L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call) Return

func (*L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call) Run

func (*L1ParallelEthermanInterfaceMock_GetRollupInfoByBlockRange_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call

type L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTrustedSequencerURL'

func (*L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call) Return

func (*L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call) Run

func (*L1ParallelEthermanInterfaceMock_GetTrustedSequencerURL_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_HeaderByNumber_Call

type L1ParallelEthermanInterfaceMock_HeaderByNumber_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_HeaderByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByNumber'

func (*L1ParallelEthermanInterfaceMock_HeaderByNumber_Call) Return

func (*L1ParallelEthermanInterfaceMock_HeaderByNumber_Call) Run

func (*L1ParallelEthermanInterfaceMock_HeaderByNumber_Call) RunAndReturn

type L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call

type L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call struct {
	*mock.Call
}

L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VerifyGenBlockNumber'

func (*L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call) Return

func (*L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call) Run

func (*L1ParallelEthermanInterfaceMock_VerifyGenBlockNumber_Call) RunAndReturn

type L1RollupInfoProducer

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

L1RollupInfoProducer is the object that retrieves data from L1

func NewL1DataRetriever

func NewL1DataRetriever(cfg ConfigProducer, ethermans []L1ParallelEthermanInterface, outgoingChannel chan L1SyncMessage) *L1RollupInfoProducer

NewL1DataRetriever creates a new object

func (*L1RollupInfoProducer) Abort

func (l *L1RollupInfoProducer) Abort()

Abort stop inmediatly the current process

func (*L1RollupInfoProducer) Reset

func (l *L1RollupInfoProducer) Reset(startingBlockNumber uint64)

Reset reset the object and stop the current process. Set first block to be retrieved

func (*L1RollupInfoProducer) Start

func (l *L1RollupInfoProducer) Start(ctx context.Context) error

Start a producer

func (*L1RollupInfoProducer) Stop

func (l *L1RollupInfoProducer) Stop()

Stop stop the current process sending a stop command to the process queue so it stops when finish to process all packages in queue

type L1SyncMessage

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

L1SyncMessage : struct to hold L1 rollup info data package It could contain data or control information, or both. A control package is used to send actions to consumer or to notify that producer is fully synced.

type L1SyncOrchestration

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

L1SyncOrchestration is the object that coordinates the producer and the consumer process.

func NewL1SyncOrchestration

func NewL1SyncOrchestration(ctx context.Context, producer l1RollupProducerInterface, consumer l1RollupConsumerInterface) *L1SyncOrchestration

NewL1SyncOrchestration create a new L1 sync orchestration object

func (*L1SyncOrchestration) Abort

func (l *L1SyncOrchestration) Abort()

Abort stop inmediatly the current process

func (*L1SyncOrchestration) IsProducerRunning

func (l *L1SyncOrchestration) IsProducerRunning() bool

IsProducerRunning return true if producer is running

func (*L1SyncOrchestration) Reset

func (l *L1SyncOrchestration) Reset(startingBlockNumber uint64)

Reset set a new starting point and cancel current process if any

func (*L1SyncOrchestration) Start

func (l *L1SyncOrchestration) Start(lastEthBlockSynced *state.Block) (*state.Block, error)

Start launch a new process to retrieve and execute data from L1

Jump to

Keyboard shortcuts

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