sync

package
v1.9.7-0...-06ccbb3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package sync is a generated GoMock package.

Package sync is a generated GoMock package.

Index

Constants

View Source
const EventTypeNewBlock = "new-block"
View Source
const EventTypeNewBlockHashes = "new-block-hashes"
View Source
const EventTypeNewMilestone = "new-milestone"
View Source
const EventTypeNewSpan = "new-span"

Variables

This section is empty.

Functions

func VerifyAccumulatedHeaders

func VerifyAccumulatedHeaders(waypoint heimdall.Waypoint, headers []*types.Header) error

func VerifyBlocks

func VerifyBlocks(blocks []*types.Block) error

Types

type AccumulatedHeadersVerifier

type AccumulatedHeadersVerifier func(waypoint heimdall.Waypoint, headers []*types.Header) error

type BlockDownloader

type BlockDownloader interface {
	DownloadBlocksUsingCheckpoints(ctx context.Context, start uint64) (tip *types.Header, err error)
	DownloadBlocksUsingMilestones(ctx context.Context, start uint64) (tip *types.Header, err error)
}

func NewBlockDownloader

func NewBlockDownloader(
	logger log.Logger,
	p2pService p2p.Service,
	heimdall heimdall.HeimdallNoStore,
	headersVerifier AccumulatedHeadersVerifier,
	blocksVerifier BlocksVerifier,
	storage Storage,
) BlockDownloader

type BlocksVerifier

type BlocksVerifier func(blocks []*types.Block) error

type CanonicalChainBuilder

type CanonicalChainBuilder interface {
	Reset(root *types.Header)
	ContainsHash(hash libcommon.Hash) bool
	Tip() *types.Header
	Root() *types.Header
	HeadersInRange(start uint64, count uint64) []*types.Header
	Prune(newRootNum uint64) error
	Connect(headers []*types.Header) error
}

func NewCanonicalChainBuilder

func NewCanonicalChainBuilder(
	root *types.Header,
	difficultyCalc DifficultyCalculator,
	headerValidator HeaderValidator,
	spansCache *SpansCache,
) CanonicalChainBuilder

type DifficultyCalculator

type DifficultyCalculator interface {
	HeaderDifficulty(header *types.Header) (uint64, error)
}

func NewDifficultyCalculator

func NewDifficultyCalculator(
	borConfig *borcfg.BorConfig,
	spans *SpansCache,
	validatorSetFactory func(headerNum uint64) validatorSetInterface,
	signaturesCache *lru.ARCCache[libcommon.Hash, libcommon.Address],
) DifficultyCalculator

type Event

type Event struct {
	Type string
	// contains filtered or unexported fields
}

func (Event) AsNewBlock

func (e Event) AsNewBlock() EventNewBlock

func (Event) AsNewBlockHashes

func (e Event) AsNewBlockHashes() EventNewBlockHashes

func (Event) AsNewMilestone

func (e Event) AsNewMilestone() EventNewMilestone

func (Event) AsNewSpan

func (e Event) AsNewSpan() EventNewSpan

type EventChannel

type EventChannel[TEvent any] struct {
	// contains filtered or unexported fields
}

EventChannel is a buffered channel that drops oldest events when full.

func NewEventChannel

func NewEventChannel[TEvent any](capacity uint) *EventChannel[TEvent]

func (*EventChannel[TEvent]) Events

func (ec *EventChannel[TEvent]) Events() <-chan TEvent

Events returns a channel for reading events.

func (*EventChannel[TEvent]) PushEvent

func (ec *EventChannel[TEvent]) PushEvent(e TEvent)

PushEvent queues an event. If the queue is full, it drops the oldest event to make space.

func (*EventChannel[TEvent]) Run

func (ec *EventChannel[TEvent]) Run(ctx context.Context) error

Run pumps events from the queue to the events channel.

type EventNewBlock

type EventNewBlock struct {
	NewBlock *types.Block
	PeerId   *p2p.PeerId
}

type EventNewBlockHashes

type EventNewBlockHashes struct {
	NewBlockHashes eth.NewBlockHashesPacket
	PeerId         *p2p.PeerId
}

type EventNewMilestone

type EventNewMilestone = *heimdall.Milestone

type EventNewSpan

type EventNewSpan = *heimdall.Span

type ExecutionClient

type ExecutionClient interface {
	InsertBlocks(ctx context.Context, blocks []*types.Block) error
	UpdateForkChoice(ctx context.Context, tip *types.Header, finalizedHeader *types.Header) error
	CurrentHeader(ctx context.Context) (*types.Header, error)
}

type HeaderTimeValidator

type HeaderTimeValidator interface {
	ValidateHeaderTime(header *types.Header, now time.Time, parent *types.Header) error
}

func NewHeaderTimeValidator

func NewHeaderTimeValidator(
	borConfig *borcfg.BorConfig,
	spans *SpansCache,
	validatorSetFactory func(headerNum uint64) validatorSetInterface,
	signaturesCache *lru.ARCCache[libcommon.Hash, libcommon.Address],
) HeaderTimeValidator

type HeaderValidator

type HeaderValidator interface {
	ValidateHeader(header *types.Header, parent *types.Header, now time.Time) error
}

func NewHeaderValidator

func NewHeaderValidator(
	chainConfig *chain.Config,
	borConfig *borcfg.BorConfig,
	headerTimeValidator HeaderTimeValidator,
) HeaderValidator

type MockCanonicalChainBuilder

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

MockCanonicalChainBuilder is a mock of CanonicalChainBuilder interface.

func NewMockCanonicalChainBuilder

func NewMockCanonicalChainBuilder(ctrl *gomock.Controller) *MockCanonicalChainBuilder

NewMockCanonicalChainBuilder creates a new mock instance.

func (*MockCanonicalChainBuilder) Connect

func (m *MockCanonicalChainBuilder) Connect(arg0 []*types.Header) error

Connect mocks base method.

func (*MockCanonicalChainBuilder) ContainsHash

func (m *MockCanonicalChainBuilder) ContainsHash(arg0 common.Hash) bool

ContainsHash mocks base method.

func (*MockCanonicalChainBuilder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCanonicalChainBuilder) HeadersInRange

func (m *MockCanonicalChainBuilder) HeadersInRange(arg0, arg1 uint64) []*types.Header

HeadersInRange mocks base method.

func (*MockCanonicalChainBuilder) Prune

func (m *MockCanonicalChainBuilder) Prune(arg0 uint64) error

Prune mocks base method.

func (*MockCanonicalChainBuilder) Reset

func (m *MockCanonicalChainBuilder) Reset(arg0 *types.Header)

Reset mocks base method.

func (*MockCanonicalChainBuilder) Root

Root mocks base method.

func (*MockCanonicalChainBuilder) Tip

Tip mocks base method.

type MockCanonicalChainBuilderConnectCall

type MockCanonicalChainBuilderConnectCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderConnectCall wrap *gomock.Call

func (*MockCanonicalChainBuilderConnectCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderConnectCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderConnectCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderContainsHashCall

type MockCanonicalChainBuilderContainsHashCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderContainsHashCall wrap *gomock.Call

func (*MockCanonicalChainBuilderContainsHashCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderContainsHashCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderContainsHashCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderHeadersInRangeCall

type MockCanonicalChainBuilderHeadersInRangeCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderHeadersInRangeCall wrap *gomock.Call

func (*MockCanonicalChainBuilderHeadersInRangeCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderHeadersInRangeCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderHeadersInRangeCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderMockRecorder

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

MockCanonicalChainBuilderMockRecorder is the mock recorder for MockCanonicalChainBuilder.

func (*MockCanonicalChainBuilderMockRecorder) Connect

Connect indicates an expected call of Connect.

func (*MockCanonicalChainBuilderMockRecorder) ContainsHash

ContainsHash indicates an expected call of ContainsHash.

func (*MockCanonicalChainBuilderMockRecorder) HeadersInRange

HeadersInRange indicates an expected call of HeadersInRange.

func (*MockCanonicalChainBuilderMockRecorder) Prune

Prune indicates an expected call of Prune.

func (*MockCanonicalChainBuilderMockRecorder) Reset

Reset indicates an expected call of Reset.

func (*MockCanonicalChainBuilderMockRecorder) Root

Root indicates an expected call of Root.

func (*MockCanonicalChainBuilderMockRecorder) Tip

Tip indicates an expected call of Tip.

type MockCanonicalChainBuilderPruneCall

type MockCanonicalChainBuilderPruneCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderPruneCall wrap *gomock.Call

func (*MockCanonicalChainBuilderPruneCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderPruneCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderPruneCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderResetCall

type MockCanonicalChainBuilderResetCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderResetCall wrap *gomock.Call

func (*MockCanonicalChainBuilderResetCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderResetCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderResetCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderRootCall

type MockCanonicalChainBuilderRootCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderRootCall wrap *gomock.Call

func (*MockCanonicalChainBuilderRootCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderRootCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderRootCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderTipCall

type MockCanonicalChainBuilderTipCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderTipCall wrap *gomock.Call

func (*MockCanonicalChainBuilderTipCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderTipCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderTipCall) Return

Return rewrite *gomock.Call.Return

type MockStorage

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

MockStorage is a mock of Storage interface.

func NewMockStorage

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance.

func (*MockStorage) EXPECT

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStorage) Flush

func (m *MockStorage) Flush(arg0 context.Context) error

Flush mocks base method.

func (*MockStorage) InsertBlocks

func (m *MockStorage) InsertBlocks(arg0 context.Context, arg1 []*types.Block) error

InsertBlocks mocks base method.

func (*MockStorage) Run

func (m *MockStorage) Run(arg0 context.Context) error

Run mocks base method.

type MockStorageFlushCall

type MockStorageFlushCall struct {
	*gomock.Call
}

MockStorageFlushCall wrap *gomock.Call

func (*MockStorageFlushCall) Do

Do rewrite *gomock.Call.Do

func (*MockStorageFlushCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStorageFlushCall) Return

Return rewrite *gomock.Call.Return

type MockStorageInsertBlocksCall

type MockStorageInsertBlocksCall struct {
	*gomock.Call
}

MockStorageInsertBlocksCall wrap *gomock.Call

func (*MockStorageInsertBlocksCall) Do

Do rewrite *gomock.Call.Do

func (*MockStorageInsertBlocksCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStorageInsertBlocksCall) Return

Return rewrite *gomock.Call.Return

type MockStorageMockRecorder

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

MockStorageMockRecorder is the mock recorder for MockStorage.

func (*MockStorageMockRecorder) Flush

Flush indicates an expected call of Flush.

func (*MockStorageMockRecorder) InsertBlocks

func (mr *MockStorageMockRecorder) InsertBlocks(arg0, arg1 any) *MockStorageInsertBlocksCall

InsertBlocks indicates an expected call of InsertBlocks.

func (*MockStorageMockRecorder) Run

Run indicates an expected call of Run.

type MockStorageRunCall

type MockStorageRunCall struct {
	*gomock.Call
}

MockStorageRunCall wrap *gomock.Call

func (*MockStorageRunCall) Do

Do rewrite *gomock.Call.Do

func (*MockStorageRunCall) DoAndReturn

func (c *MockStorageRunCall) DoAndReturn(f func(context.Context) error) *MockStorageRunCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStorageRunCall) Return

func (c *MockStorageRunCall) Return(arg0 error) *MockStorageRunCall

Return rewrite *gomock.Call.Return

type Service

type Service interface {
	Run(ctx context.Context) error
}

func NewService

func NewService(
	logger log.Logger,
	chainConfig *chain.Config,
	sentryClient direct.SentryClient,
	maxPeers int,
	statusDataProvider *sentry.StatusDataProvider,
	heimdallUrl string,
	executionEngine executionclient.ExecutionEngine,
) Service

type SpansCache

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

func NewSpansCache

func NewSpansCache() *SpansCache

func (*SpansCache) Add

func (cache *SpansCache) Add(span *heimdall.Span)

func (*SpansCache) IsEmpty

func (cache *SpansCache) IsEmpty() bool

func (*SpansCache) Prune

func (cache *SpansCache) Prune(blockNum uint64)

Prune removes spans that ended before blockNum.

func (*SpansCache) SpanAt

func (cache *SpansCache) SpanAt(blockNum uint64) *heimdall.Span

SpanAt finds a span that contains blockNum.

type Storage

type Storage interface {
	// InsertBlocks queues blocks for writing into the local canonical chain.
	InsertBlocks(ctx context.Context, blocks []*types.Block) error
	// Flush makes sure that all queued blocks have been written.
	Flush(ctx context.Context) error
	// Run performs the block writing.
	Run(ctx context.Context) error
}

func NewStorage

func NewStorage(logger log.Logger, execution ExecutionClient, queueCapacity int) Storage

type Sync

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

func NewSync

func NewSync(
	storage Storage,
	execution ExecutionClient,
	headersVerifier AccumulatedHeadersVerifier,
	blocksVerifier BlocksVerifier,
	p2pService p2p.Service,
	blockDownloader BlockDownloader,
	ccBuilderFactory func(root *types.Header, span *heimdall.Span) CanonicalChainBuilder,
	spansCache *SpansCache,
	fetchLatestSpan func(ctx context.Context) (*heimdall.Span, error),
	events <-chan Event,
	logger log.Logger,
) *Sync

func (*Sync) Run

func (s *Sync) Run(ctx context.Context) error

type TipEvents

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

func NewTipEvents

func NewTipEvents(
	logger log.Logger,
	p2pService p2p.Service,
	heimdallService heimdall.HeimdallNoStore,
) *TipEvents

func (*TipEvents) Events

func (te *TipEvents) Events() <-chan Event

func (*TipEvents) Run

func (te *TipEvents) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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