sync

package
v0.1.0-beta5-bridge-tmp Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWaitPeriodBlockNotFound = time.Millisecond * 100
)

Variables

View Source
var ErrInconsistentState = errors.New("state is inconsistent, try again later once the state is consolidated")

Functions

func UnhaltIfAffectedRows

func UnhaltIfAffectedRows(halted *bool, haltedReason *string, mu *sync.RWMutex, rowsAffected int64)

Types

type Block

type Block struct {
	Num    uint64
	Events []interface{}
	Hash   common.Hash
}

type EVMBlock

type EVMBlock struct {
	EVMBlockHeader
	IsFinalizedBlock bool
	Events           []interface{}
}

type EVMBlockHeader

type EVMBlockHeader struct {
	Num        uint64
	Hash       common.Hash
	ParentHash common.Hash
	Timestamp  uint64
}

type EVMBlocks added in v0.0.2

type EVMBlocks []*EVMBlock

func (EVMBlocks) Len added in v0.0.2

func (e EVMBlocks) Len() int

type EVMDownloader

type EVMDownloader struct {
	EVMDownloaderInterface
	// contains filtered or unexported fields
}

func NewEVMDownloader

func NewEVMDownloader(
	syncerID string,
	ethClient EthClienter,
	syncBlockChunkSize uint64,
	blockFinalityType etherman.BlockNumberFinality,
	waitForNewBlocksPeriod time.Duration,
	appender LogAppenderMap,
	adressessToQuery []common.Address,
	rh *RetryHandler,
	finalizedBlockType etherman.BlockNumberFinality,
) (*EVMDownloader, error)

func (*EVMDownloader) Download

func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, downloadedCh chan EVMBlock)

type EVMDownloaderImplementation

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

func NewEVMDownloaderImplementation

func NewEVMDownloaderImplementation(
	syncerID string,
	ethClient EthClienter,
	blockFinality *big.Int,
	waitForNewBlocksPeriod time.Duration,
	appender LogAppenderMap,
	topicsToQuery []common.Hash,
	adressessToQuery []common.Address,
	rh *RetryHandler,
) *EVMDownloaderImplementation

func (*EVMDownloaderImplementation) GetBlockHeader

func (d *EVMDownloaderImplementation) GetBlockHeader(ctx context.Context, blockNum uint64) (EVMBlockHeader, bool)

func (*EVMDownloaderImplementation) GetEventsByBlockRange

func (d *EVMDownloaderImplementation) GetEventsByBlockRange(ctx context.Context, fromBlock, toBlock uint64) EVMBlocks

func (*EVMDownloaderImplementation) GetLastFinalizedBlock added in v0.0.2

func (d *EVMDownloaderImplementation) GetLastFinalizedBlock(ctx context.Context) (*types.Header, error)

func (*EVMDownloaderImplementation) GetLogs

func (d *EVMDownloaderImplementation) GetLogs(ctx context.Context, fromBlock, toBlock uint64) []types.Log

func (*EVMDownloaderImplementation) WaitForNewBlocks

func (d *EVMDownloaderImplementation) WaitForNewBlocks(
	ctx context.Context, lastBlockSeen uint64,
) (newLastBlock uint64)

type EVMDownloaderInterface

type EVMDownloaderInterface interface {
	WaitForNewBlocks(ctx context.Context, lastBlockSeen uint64) (newLastBlock uint64)
	GetEventsByBlockRange(ctx context.Context, fromBlock, toBlock uint64) EVMBlocks
	GetLogs(ctx context.Context, fromBlock, toBlock uint64) []types.Log
	GetBlockHeader(ctx context.Context, blockNum uint64) (EVMBlockHeader, bool)
	GetLastFinalizedBlock(ctx context.Context) (*types.Header, error)
}

type EVMDownloaderMock

type EVMDownloaderMock struct {
	mock.Mock
}

EVMDownloaderMock is an autogenerated mock type for the evmDownloaderFull type

func NewEVMDownloaderMock

func NewEVMDownloaderMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *EVMDownloaderMock

NewEVMDownloaderMock creates a new instance of EVMDownloaderMock. 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 (*EVMDownloaderMock) Download

func (_m *EVMDownloaderMock) Download(ctx context.Context, fromBlock uint64, downloadedCh chan EVMBlock)

Download provides a mock function with given fields: ctx, fromBlock, downloadedCh

func (*EVMDownloaderMock) EXPECT

func (*EVMDownloaderMock) GetBlockHeader

func (_m *EVMDownloaderMock) GetBlockHeader(ctx context.Context, blockNum uint64) (EVMBlockHeader, bool)

GetBlockHeader provides a mock function with given fields: ctx, blockNum

func (*EVMDownloaderMock) GetEventsByBlockRange

func (_m *EVMDownloaderMock) GetEventsByBlockRange(ctx context.Context, fromBlock uint64, toBlock uint64) EVMBlocks

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

func (*EVMDownloaderMock) GetLastFinalizedBlock added in v0.0.2

func (_m *EVMDownloaderMock) GetLastFinalizedBlock(ctx context.Context) (*types.Header, error)

GetLastFinalizedBlock provides a mock function with given fields: ctx

func (*EVMDownloaderMock) GetLogs

func (_m *EVMDownloaderMock) GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64) []types.Log

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

func (*EVMDownloaderMock) WaitForNewBlocks

func (_m *EVMDownloaderMock) WaitForNewBlocks(ctx context.Context, lastBlockSeen uint64) uint64

WaitForNewBlocks provides a mock function with given fields: ctx, lastBlockSeen

type EVMDownloaderMock_Download_Call

type EVMDownloaderMock_Download_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_Download_Call) Return

func (*EVMDownloaderMock_Download_Call) Run

func (_c *EVMDownloaderMock_Download_Call) Run(run func(ctx context.Context, fromBlock uint64, downloadedCh chan EVMBlock)) *EVMDownloaderMock_Download_Call

func (*EVMDownloaderMock_Download_Call) RunAndReturn

type EVMDownloaderMock_Expecter

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

func (*EVMDownloaderMock_Expecter) Download

func (_e *EVMDownloaderMock_Expecter) Download(ctx interface{}, fromBlock interface{}, downloadedCh interface{}) *EVMDownloaderMock_Download_Call

Download is a helper method to define mock.On call

  • ctx context.Context
  • fromBlock uint64
  • downloadedCh chan EVMBlock

func (*EVMDownloaderMock_Expecter) GetBlockHeader

func (_e *EVMDownloaderMock_Expecter) GetBlockHeader(ctx interface{}, blockNum interface{}) *EVMDownloaderMock_GetBlockHeader_Call

GetBlockHeader is a helper method to define mock.On call

  • ctx context.Context
  • blockNum uint64

func (*EVMDownloaderMock_Expecter) GetEventsByBlockRange

func (_e *EVMDownloaderMock_Expecter) GetEventsByBlockRange(ctx interface{}, fromBlock interface{}, toBlock interface{}) *EVMDownloaderMock_GetEventsByBlockRange_Call

GetEventsByBlockRange is a helper method to define mock.On call

  • ctx context.Context
  • fromBlock uint64
  • toBlock uint64

func (*EVMDownloaderMock_Expecter) GetLastFinalizedBlock added in v0.0.2

func (_e *EVMDownloaderMock_Expecter) GetLastFinalizedBlock(ctx interface{}) *EVMDownloaderMock_GetLastFinalizedBlock_Call

GetLastFinalizedBlock is a helper method to define mock.On call

  • ctx context.Context

func (*EVMDownloaderMock_Expecter) GetLogs

func (_e *EVMDownloaderMock_Expecter) GetLogs(ctx interface{}, fromBlock interface{}, toBlock interface{}) *EVMDownloaderMock_GetLogs_Call

GetLogs is a helper method to define mock.On call

  • ctx context.Context
  • fromBlock uint64
  • toBlock uint64

func (*EVMDownloaderMock_Expecter) WaitForNewBlocks

func (_e *EVMDownloaderMock_Expecter) WaitForNewBlocks(ctx interface{}, lastBlockSeen interface{}) *EVMDownloaderMock_WaitForNewBlocks_Call

WaitForNewBlocks is a helper method to define mock.On call

  • ctx context.Context
  • lastBlockSeen uint64

type EVMDownloaderMock_GetBlockHeader_Call

type EVMDownloaderMock_GetBlockHeader_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_GetBlockHeader_Call) Return

func (*EVMDownloaderMock_GetBlockHeader_Call) Run

func (*EVMDownloaderMock_GetBlockHeader_Call) RunAndReturn

type EVMDownloaderMock_GetEventsByBlockRange_Call

type EVMDownloaderMock_GetEventsByBlockRange_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_GetEventsByBlockRange_Call) Return

func (*EVMDownloaderMock_GetEventsByBlockRange_Call) Run

func (*EVMDownloaderMock_GetEventsByBlockRange_Call) RunAndReturn

type EVMDownloaderMock_GetLastFinalizedBlock_Call added in v0.0.2

type EVMDownloaderMock_GetLastFinalizedBlock_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_GetLastFinalizedBlock_Call) Return added in v0.0.2

func (*EVMDownloaderMock_GetLastFinalizedBlock_Call) Run added in v0.0.2

func (*EVMDownloaderMock_GetLastFinalizedBlock_Call) RunAndReturn added in v0.0.2

type EVMDownloaderMock_GetLogs_Call

type EVMDownloaderMock_GetLogs_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_GetLogs_Call) Return

func (*EVMDownloaderMock_GetLogs_Call) Run

func (_c *EVMDownloaderMock_GetLogs_Call) Run(run func(ctx context.Context, fromBlock uint64, toBlock uint64)) *EVMDownloaderMock_GetLogs_Call

func (*EVMDownloaderMock_GetLogs_Call) RunAndReturn

type EVMDownloaderMock_WaitForNewBlocks_Call

type EVMDownloaderMock_WaitForNewBlocks_Call struct {
	*mock.Call
}

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

func (*EVMDownloaderMock_WaitForNewBlocks_Call) Return

func (*EVMDownloaderMock_WaitForNewBlocks_Call) Run

func (*EVMDownloaderMock_WaitForNewBlocks_Call) RunAndReturn

type EVMDriver

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

func NewEVMDriver

func NewEVMDriver(
	reorgDetector ReorgDetector,
	processor processorInterface,
	downloader downloader,
	reorgDetectorID string,
	downloadBufferSize int,
	rh *RetryHandler,
) (*EVMDriver, error)

func (*EVMDriver) Sync

func (d *EVMDriver) Sync(ctx context.Context)

type EthClienter

type EthClienter interface {
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
}

type L2Mock

type L2Mock struct {
	mock.Mock
}

L2Mock is an autogenerated mock type for the EthClienter type

func NewL2Mock

func NewL2Mock(t interface {
	mock.TestingT
	Cleanup(func())
}) *L2Mock

NewL2Mock creates a new instance of L2Mock. 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 (*L2Mock) EXPECT

func (_m *L2Mock) EXPECT() *L2Mock_Expecter

func (*L2Mock) FilterLogs

func (_m *L2Mock) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

FilterLogs provides a mock function with given fields: ctx, q

func (*L2Mock) HeaderByNumber

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

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

type L2Mock_Expecter

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

func (*L2Mock_Expecter) FilterLogs

func (_e *L2Mock_Expecter) FilterLogs(ctx interface{}, q interface{}) *L2Mock_FilterLogs_Call

FilterLogs is a helper method to define mock.On call

  • ctx context.Context
  • q ethereum.FilterQuery

func (*L2Mock_Expecter) HeaderByNumber

func (_e *L2Mock_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *L2Mock_HeaderByNumber_Call

HeaderByNumber is a helper method to define mock.On call

  • ctx context.Context
  • number *big.Int

type L2Mock_FilterLogs_Call

type L2Mock_FilterLogs_Call struct {
	*mock.Call
}

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

func (*L2Mock_FilterLogs_Call) Return

func (*L2Mock_FilterLogs_Call) Run

func (*L2Mock_FilterLogs_Call) RunAndReturn

type L2Mock_HeaderByNumber_Call

type L2Mock_HeaderByNumber_Call struct {
	*mock.Call
}

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

func (*L2Mock_HeaderByNumber_Call) Return

func (*L2Mock_HeaderByNumber_Call) Run

func (*L2Mock_HeaderByNumber_Call) RunAndReturn

type LogAppenderMap

type LogAppenderMap map[common.Hash]func(b *EVMBlock, l types.Log) error

type ProcessorMock

type ProcessorMock struct {
	mock.Mock
}

ProcessorMock is an autogenerated mock type for the processorInterface type

func NewProcessorMock

func NewProcessorMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *ProcessorMock

NewProcessorMock creates a new instance of ProcessorMock. 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 (*ProcessorMock) EXPECT

func (_m *ProcessorMock) EXPECT() *ProcessorMock_Expecter

func (*ProcessorMock) GetLastProcessedBlock

func (_m *ProcessorMock) GetLastProcessedBlock(ctx context.Context) (uint64, error)

GetLastProcessedBlock provides a mock function with given fields: ctx

func (*ProcessorMock) ProcessBlock

func (_m *ProcessorMock) ProcessBlock(ctx context.Context, block Block) error

ProcessBlock provides a mock function with given fields: ctx, block

func (*ProcessorMock) Reorg

func (_m *ProcessorMock) Reorg(ctx context.Context, firstReorgedBlock uint64) error

Reorg provides a mock function with given fields: ctx, firstReorgedBlock

type ProcessorMock_Expecter

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

func (*ProcessorMock_Expecter) GetLastProcessedBlock

func (_e *ProcessorMock_Expecter) GetLastProcessedBlock(ctx interface{}) *ProcessorMock_GetLastProcessedBlock_Call

GetLastProcessedBlock is a helper method to define mock.On call

  • ctx context.Context

func (*ProcessorMock_Expecter) ProcessBlock

func (_e *ProcessorMock_Expecter) ProcessBlock(ctx interface{}, block interface{}) *ProcessorMock_ProcessBlock_Call

ProcessBlock is a helper method to define mock.On call

  • ctx context.Context
  • block Block

func (*ProcessorMock_Expecter) Reorg

func (_e *ProcessorMock_Expecter) Reorg(ctx interface{}, firstReorgedBlock interface{}) *ProcessorMock_Reorg_Call

Reorg is a helper method to define mock.On call

  • ctx context.Context
  • firstReorgedBlock uint64

type ProcessorMock_GetLastProcessedBlock_Call

type ProcessorMock_GetLastProcessedBlock_Call struct {
	*mock.Call
}

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

func (*ProcessorMock_GetLastProcessedBlock_Call) Return

func (*ProcessorMock_GetLastProcessedBlock_Call) Run

func (*ProcessorMock_GetLastProcessedBlock_Call) RunAndReturn

type ProcessorMock_ProcessBlock_Call

type ProcessorMock_ProcessBlock_Call struct {
	*mock.Call
}

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

func (*ProcessorMock_ProcessBlock_Call) Return

func (*ProcessorMock_ProcessBlock_Call) Run

func (*ProcessorMock_ProcessBlock_Call) RunAndReturn

type ProcessorMock_Reorg_Call

type ProcessorMock_Reorg_Call struct {
	*mock.Call
}

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

func (*ProcessorMock_Reorg_Call) Return

func (*ProcessorMock_Reorg_Call) Run

func (_c *ProcessorMock_Reorg_Call) Run(run func(ctx context.Context, firstReorgedBlock uint64)) *ProcessorMock_Reorg_Call

func (*ProcessorMock_Reorg_Call) RunAndReturn

type ReorgDetector

type ReorgDetector interface {
	Subscribe(id string) (*reorgdetector.Subscription, error)
	AddBlockToTrack(ctx context.Context, id string, blockNum uint64, blockHash common.Hash) error
	GetFinalizedBlockType() etherman.BlockNumberFinality
	String() string
}

type ReorgDetectorMock

type ReorgDetectorMock struct {
	mock.Mock
}

ReorgDetectorMock is an autogenerated mock type for the ReorgDetector type

func NewReorgDetectorMock

func NewReorgDetectorMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *ReorgDetectorMock

NewReorgDetectorMock creates a new instance of ReorgDetectorMock. 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 (*ReorgDetectorMock) AddBlockToTrack

func (_m *ReorgDetectorMock) AddBlockToTrack(ctx context.Context, id string, blockNum uint64, blockHash common.Hash) error

AddBlockToTrack provides a mock function with given fields: ctx, id, blockNum, blockHash

func (*ReorgDetectorMock) EXPECT

func (*ReorgDetectorMock) GetFinalizedBlockType added in v0.0.2

func (_m *ReorgDetectorMock) GetFinalizedBlockType() etherman.BlockNumberFinality

GetFinalizedBlockType provides a mock function with no fields

func (*ReorgDetectorMock) String added in v0.0.2

func (_m *ReorgDetectorMock) String() string

String provides a mock function with no fields

func (*ReorgDetectorMock) Subscribe

Subscribe provides a mock function with given fields: id

type ReorgDetectorMock_AddBlockToTrack_Call

type ReorgDetectorMock_AddBlockToTrack_Call struct {
	*mock.Call
}

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

func (*ReorgDetectorMock_AddBlockToTrack_Call) Return

func (*ReorgDetectorMock_AddBlockToTrack_Call) Run

func (*ReorgDetectorMock_AddBlockToTrack_Call) RunAndReturn

type ReorgDetectorMock_Expecter

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

func (*ReorgDetectorMock_Expecter) AddBlockToTrack

func (_e *ReorgDetectorMock_Expecter) AddBlockToTrack(ctx interface{}, id interface{}, blockNum interface{}, blockHash interface{}) *ReorgDetectorMock_AddBlockToTrack_Call

AddBlockToTrack is a helper method to define mock.On call

  • ctx context.Context
  • id string
  • blockNum uint64
  • blockHash common.Hash

func (*ReorgDetectorMock_Expecter) GetFinalizedBlockType added in v0.0.2

GetFinalizedBlockType is a helper method to define mock.On call

func (*ReorgDetectorMock_Expecter) String added in v0.0.2

String is a helper method to define mock.On call

func (*ReorgDetectorMock_Expecter) Subscribe

func (_e *ReorgDetectorMock_Expecter) Subscribe(id interface{}) *ReorgDetectorMock_Subscribe_Call

Subscribe is a helper method to define mock.On call

  • id string

type ReorgDetectorMock_GetFinalizedBlockType_Call added in v0.0.2

type ReorgDetectorMock_GetFinalizedBlockType_Call struct {
	*mock.Call
}

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

func (*ReorgDetectorMock_GetFinalizedBlockType_Call) Return added in v0.0.2

func (*ReorgDetectorMock_GetFinalizedBlockType_Call) Run added in v0.0.2

func (*ReorgDetectorMock_GetFinalizedBlockType_Call) RunAndReturn added in v0.0.2

type ReorgDetectorMock_String_Call added in v0.0.2

type ReorgDetectorMock_String_Call struct {
	*mock.Call
}

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

func (*ReorgDetectorMock_String_Call) Return added in v0.0.2

func (*ReorgDetectorMock_String_Call) Run added in v0.0.2

func (*ReorgDetectorMock_String_Call) RunAndReturn added in v0.0.2

type ReorgDetectorMock_Subscribe_Call

type ReorgDetectorMock_Subscribe_Call struct {
	*mock.Call
}

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

func (*ReorgDetectorMock_Subscribe_Call) Return

func (*ReorgDetectorMock_Subscribe_Call) Run

func (*ReorgDetectorMock_Subscribe_Call) RunAndReturn

type RetryHandler

type RetryHandler struct {
	RetryAfterErrorPeriod      time.Duration
	MaxRetryAttemptsAfterError int
}

func (*RetryHandler) Handle

func (h *RetryHandler) Handle(funcName string, attempts int)

Jump to

Keyboard shortcuts

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