sync

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package sync is a generated GoMock package.

Package sync is a generated GoMock package.

Package sync is a generated GoMock package.

Index

Constants

View Source
const InMemorySignatures = 4096 // Number of recent block signatures to keep in memory

Variables

View Source
var (
	ErrFailedToComputeHeadersRootHash = errors.New("failed to compute headers root hash")
	ErrBadHeadersRootHash             = errors.New("bad headers root hash")
	ErrIncorrectHeadersLength         = errors.New("incorrect headers length")
	ErrDisconnectedHeaders            = errors.New("disconnected headers")
)
View Source
var ErrForkChoiceUpdateBadBlock = errors.New("fork choice update bad block")
View Source
var ErrForkChoiceUpdateFailure = errors.New("fork choice update failure")

Functions

func VerifyBlocks

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

func VerifyCheckpointHeaders

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

func VerifyMilestoneHeaders

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

func WithEventChannelLogging

func WithEventChannelLogging(logger log.Logger, lvl log.Lvl, id string) eventChannelOption

Types

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,
	waypointReader waypointReader,
	checkpointVerifier WaypointHeadersVerifier,
	milestoneVerifier WaypointHeadersVerifier,
	blocksVerifier BlocksVerifier,
	store Store,
	blockLimit uint,
) 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
	PruneRoot(newRootNum uint64) error
	PruneNode(hash libcommon.Hash) error
	Connect(ctx context.Context, headers []*types.Header) (newConnectedHeaders []*types.Header, err error)
	LowestCommonAncestor(a, b libcommon.Hash) (*types.Header, bool)
}

func NewCanonicalChainBuilder

func NewCanonicalChainBuilder(
	root *types.Header,
	difficultyCalc difficultyCalculator,
	headerValidator headerValidator,
) CanonicalChainBuilder

type CanonicalChainBuilderFactory

type CanonicalChainBuilderFactory func(root *types.Header) CanonicalChainBuilder

func NewCanonicalChainBuilderFactory

func NewCanonicalChainBuilderFactory(
	chainConfig *chain.Config,
	borConfig *borcfg.BorConfig,
	blockProducersReader blockProducersReader,
) CanonicalChainBuilderFactory

type DifficultyCalculator

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

func (*DifficultyCalculator) HeaderDifficulty

func (calc *DifficultyCalculator) HeaderDifficulty(ctx context.Context, header *types.Header) (uint64, error)

type Event

type Event struct {
	Type EventType
	// 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) Topic

func (e Event) Topic() EventTopic

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, opts ...eventChannelOption) *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
	Source   EventSource
}

type EventNewBlockHashes

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

type EventNewMilestone

type EventNewMilestone = *heimdall.Milestone

type EventSource

type EventSource string
const EventSourceP2PNewBlock EventSource = "p2p-new-block-source"
const EventSourceP2PNewBlockHashes EventSource = "p2p-new-block-hashes-source"

type EventTopic

type EventTopic string
const EventTopicHeimdall EventTopic = "heimdall"
const EventTopicP2P EventTopic = "p2p"

func (EventTopic) String

func (t EventTopic) String() string

type EventType

type EventType string
const EventTypeNewBlock EventType = "new-block"
const EventTypeNewBlockHashes EventType = "new-block-hashes"
const EventTypeNewMilestone EventType = "new-milestone"

type ExecutionClient

type ExecutionClient interface {
	Prepare(ctx context.Context) error
	InsertBlocks(ctx context.Context, blocks []*types.Block) error
	UpdateForkChoice(ctx context.Context, tip *types.Header, finalizedHeader *types.Header) (common.Hash, error)
	CurrentHeader(ctx context.Context) (*types.Header, error)
	GetHeader(ctx context.Context, blockNum uint64) (*types.Header, error)
	GetTd(ctx context.Context, blockNum uint64, blockHash common.Hash) (*big.Int, error)
}

func NewExecutionClient

func NewExecutionClient(client executionproto.ExecutionClient) ExecutionClient

type HeaderTimeValidator

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

func (*HeaderTimeValidator) ValidateHeaderTime

func (htv *HeaderTimeValidator) ValidateHeaderTime(
	ctx context.Context,
	header *types.Header,
	now time.Time,
	parent *types.Header,
) error

type HeaderValidator

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

func (*HeaderValidator) ValidateHeader

func (hv *HeaderValidator) ValidateHeader(
	ctx context.Context,
	header *types.Header,
	parent *types.Header,
	now time.Time,
) error

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(ctx context.Context, headers []*types.Header) ([]*types.Header, error)

Connect mocks base method.

func (*MockCanonicalChainBuilder) ContainsHash

func (m *MockCanonicalChainBuilder) ContainsHash(hash 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(start, count uint64) []*types.Header

HeadersInRange mocks base method.

func (*MockCanonicalChainBuilder) LowestCommonAncestor

func (m *MockCanonicalChainBuilder) LowestCommonAncestor(a, b common.Hash) (*types.Header, bool)

LowestCommonAncestor mocks base method.

func (*MockCanonicalChainBuilder) PruneNode

func (m *MockCanonicalChainBuilder) PruneNode(hash common.Hash) error

PruneNode mocks base method.

func (*MockCanonicalChainBuilder) PruneRoot

func (m *MockCanonicalChainBuilder) PruneRoot(newRootNum uint64) error

PruneRoot mocks base method.

func (*MockCanonicalChainBuilder) Reset

func (m *MockCanonicalChainBuilder) Reset(root *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 MockCanonicalChainBuilderLowestCommonAncestorCall

type MockCanonicalChainBuilderLowestCommonAncestorCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderLowestCommonAncestorCall wrap *gomock.Call

func (*MockCanonicalChainBuilderLowestCommonAncestorCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderLowestCommonAncestorCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderLowestCommonAncestorCall) 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) LowestCommonAncestor

LowestCommonAncestor indicates an expected call of LowestCommonAncestor.

func (*MockCanonicalChainBuilderMockRecorder) PruneNode

PruneNode indicates an expected call of PruneNode.

func (*MockCanonicalChainBuilderMockRecorder) PruneRoot

PruneRoot indicates an expected call of PruneRoot.

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 MockCanonicalChainBuilderPruneNodeCall

type MockCanonicalChainBuilderPruneNodeCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderPruneNodeCall wrap *gomock.Call

func (*MockCanonicalChainBuilderPruneNodeCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderPruneNodeCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderPruneNodeCall) Return

Return rewrite *gomock.Call.Return

type MockCanonicalChainBuilderPruneRootCall

type MockCanonicalChainBuilderPruneRootCall struct {
	*gomock.Call
}

MockCanonicalChainBuilderPruneRootCall wrap *gomock.Call

func (*MockCanonicalChainBuilderPruneRootCall) Do

Do rewrite *gomock.Call.Do

func (*MockCanonicalChainBuilderPruneRootCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockCanonicalChainBuilderPruneRootCall) 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 MockStore

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

MockStore is a mock of Store interface.

func NewMockStore

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance.

func (*MockStore) EXPECT

func (m *MockStore) EXPECT() *MockStoreMockRecorder

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

func (*MockStore) Flush

func (m *MockStore) Flush(ctx context.Context) error

Flush mocks base method.

func (*MockStore) InsertBlocks

func (m *MockStore) InsertBlocks(ctx context.Context, blocks []*types.Block) error

InsertBlocks mocks base method.

func (*MockStore) Run

func (m *MockStore) Run(ctx context.Context) error

Run mocks base method.

type MockStoreFlushCall

type MockStoreFlushCall struct {
	*gomock.Call
}

MockStoreFlushCall wrap *gomock.Call

func (*MockStoreFlushCall) Do

Do rewrite *gomock.Call.Do

func (*MockStoreFlushCall) DoAndReturn

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

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStoreFlushCall) Return

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

Return rewrite *gomock.Call.Return

type MockStoreInsertBlocksCall

type MockStoreInsertBlocksCall struct {
	*gomock.Call
}

MockStoreInsertBlocksCall wrap *gomock.Call

func (*MockStoreInsertBlocksCall) Do

Do rewrite *gomock.Call.Do

func (*MockStoreInsertBlocksCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStoreInsertBlocksCall) Return

Return rewrite *gomock.Call.Return

type MockStoreMockRecorder

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

MockStoreMockRecorder is the mock recorder for MockStore.

func (*MockStoreMockRecorder) Flush

Flush indicates an expected call of Flush.

func (*MockStoreMockRecorder) InsertBlocks

func (mr *MockStoreMockRecorder) InsertBlocks(ctx, blocks any) *MockStoreInsertBlocksCall

InsertBlocks indicates an expected call of InsertBlocks.

func (*MockStoreMockRecorder) Run

Run indicates an expected call of Run.

type MockStoreRunCall

type MockStoreRunCall struct {
	*gomock.Call
}

MockStoreRunCall wrap *gomock.Call

func (*MockStoreRunCall) Do

Do rewrite *gomock.Call.Do

func (*MockStoreRunCall) DoAndReturn

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

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockStoreRunCall) Return

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

Return rewrite *gomock.Call.Return

type MockwaypointReader

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

MockwaypointReader is a mock of waypointReader interface.

func NewMockwaypointReader

func NewMockwaypointReader(ctrl *gomock.Controller) *MockwaypointReader

NewMockwaypointReader creates a new mock instance.

func (*MockwaypointReader) CheckpointsFromBlock

func (m *MockwaypointReader) CheckpointsFromBlock(ctx context.Context, startBlock uint64) ([]*heimdall.Checkpoint, error)

CheckpointsFromBlock mocks base method.

func (*MockwaypointReader) EXPECT

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

func (*MockwaypointReader) MilestonesFromBlock

func (m *MockwaypointReader) MilestonesFromBlock(ctx context.Context, startBlock uint64) ([]*heimdall.Milestone, error)

MilestonesFromBlock mocks base method.

type MockwaypointReaderCheckpointsFromBlockCall

type MockwaypointReaderCheckpointsFromBlockCall struct {
	*gomock.Call
}

MockwaypointReaderCheckpointsFromBlockCall wrap *gomock.Call

func (*MockwaypointReaderCheckpointsFromBlockCall) Do

Do rewrite *gomock.Call.Do

func (*MockwaypointReaderCheckpointsFromBlockCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockwaypointReaderCheckpointsFromBlockCall) Return

Return rewrite *gomock.Call.Return

type MockwaypointReaderMilestonesFromBlockCall

type MockwaypointReaderMilestonesFromBlockCall struct {
	*gomock.Call
}

MockwaypointReaderMilestonesFromBlockCall wrap *gomock.Call

func (*MockwaypointReaderMilestonesFromBlockCall) Do

Do rewrite *gomock.Call.Do

func (*MockwaypointReaderMilestonesFromBlockCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockwaypointReaderMilestonesFromBlockCall) Return

Return rewrite *gomock.Call.Return

type MockwaypointReaderMockRecorder

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

MockwaypointReaderMockRecorder is the mock recorder for MockwaypointReader.

func (*MockwaypointReaderMockRecorder) CheckpointsFromBlock

func (mr *MockwaypointReaderMockRecorder) CheckpointsFromBlock(ctx, startBlock any) *MockwaypointReaderCheckpointsFromBlockCall

CheckpointsFromBlock indicates an expected call of CheckpointsFromBlock.

func (*MockwaypointReaderMockRecorder) MilestonesFromBlock

func (mr *MockwaypointReaderMockRecorder) MilestonesFromBlock(ctx, startBlock any) *MockwaypointReaderMilestonesFromBlockCall

MilestonesFromBlock indicates an expected call of MilestonesFromBlock.

type Service

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

func NewService

func NewService(
	logger log.Logger,
	chainConfig *chain.Config,
	sentryClient sentryproto.SentryClient,
	maxPeers int,
	statusDataProvider *sentry.StatusDataProvider,
	executionClient executionproto.ExecutionClient,
	blockReader *freezeblocks.BlockReader,
	blockLimit uint,
	bridgeService bridge.Service,
	heimdallService heimdall.Service,
) Service

type Store

type Store 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 NewStore

func NewStore(logger log.Logger, executionStore executionStore, bridgeStore bridgeStore) Store

type Sync

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

func NewSync

func NewSync(
	store Store,
	execution ExecutionClient,
	milestoneVerifier WaypointHeadersVerifier,
	blocksVerifier BlocksVerifier,
	p2pService p2p.Service,
	blockDownloader BlockDownloader,
	ccBuilderFactory CanonicalChainBuilderFactory,
	heimdallSync heimdallSynchronizer,
	bridgeSync bridgeSynchronizer,
	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,
	p2pObserverRegistrar p2pObserverRegistrar,
	heimdallObserverRegistrar heimdallObserverRegistrar,
) *TipEvents

func (*TipEvents) Events

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

func (*TipEvents) Run

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

type TipEventsCompositeChannel

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

func NewTipEventsCompositeChannel

func NewTipEventsCompositeChannel(
	heimdallEventsChannel *EventChannel[Event],
	p2pEventsChannel *EventChannel[Event],
) *TipEventsCompositeChannel

func (TipEventsCompositeChannel) Events

func (c TipEventsCompositeChannel) Events() <-chan Event

func (TipEventsCompositeChannel) PushEvent

func (c TipEventsCompositeChannel) PushEvent(e Event)

func (TipEventsCompositeChannel) Run

type WaypointHeadersVerifier

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

Jump to

Keyboard shortcuts

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