syncing

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDARetriever

func NewDARetriever(
	client da.Client,
	cache cache.CacheManager,
	genesis genesis.Genesis,
	logger zerolog.Logger,
) *daRetriever

NewDARetriever creates a new DA retriever

Types

type BlockSyncer

type BlockSyncer interface {
	// TrySyncNextBlock attempts to sync the next available block from DA or P2P.
	TrySyncNextBlock(ctx context.Context, event *common.DAHeightEvent) error

	// ApplyBlock executes block transactions and returns the new state.
	ApplyBlock(ctx context.Context, header types.Header, data *types.Data, currentState types.State) (types.State, error)

	// ValidateBlock validates block structure and state transitions.
	ValidateBlock(ctx context.Context, currState types.State, data *types.Data, header *types.SignedHeader) error

	// VerifyForcedInclusionTxs verifies that forced inclusion transactions are properly handled.
	VerifyForcedInclusionTxs(ctx context.Context, currentState types.State, data *types.Data) error
}

BlockSyncer defines operations for block synchronization that can be traced. The Syncer implements this interface, and a tracing decorator can wrap it to add OpenTelemetry spans to each operation.

func WithTracingBlockSyncer

func WithTracingBlockSyncer(inner BlockSyncer) BlockSyncer

WithTracingBlockSyncer decorates the provided BlockSyncer with tracing spans.

type DARetriever

type DARetriever interface {
	RetrieveFromDA(ctx context.Context, daHeight uint64) ([]common.DAHeightEvent, error)
}

DARetriever defines the interface for retrieving events from the DA layer

func WithTracingDARetriever

func WithTracingDARetriever(inner DARetriever) DARetriever

WithTracingDARetriever wraps a DARetriever with OpenTelemetry tracing.

type MockDARetriever

type MockDARetriever struct {
	mock.Mock
}

MockDARetriever is an autogenerated mock type for the DARetriever type

func NewMockDARetriever

func NewMockDARetriever(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDARetriever

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

func (*MockDARetriever) RetrieveFromDA

func (_mock *MockDARetriever) RetrieveFromDA(ctx context.Context, daHeight uint64) ([]common.DAHeightEvent, error)

RetrieveFromDA provides a mock function for the type MockDARetriever

type MockDARetriever_Expecter

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

func (*MockDARetriever_Expecter) RetrieveFromDA

func (_e *MockDARetriever_Expecter) RetrieveFromDA(ctx interface{}, daHeight interface{}) *MockDARetriever_RetrieveFromDA_Call

RetrieveFromDA is a helper method to define mock.On call

  • ctx context.Context
  • daHeight uint64

type MockDARetriever_RetrieveFromDA_Call

type MockDARetriever_RetrieveFromDA_Call struct {
	*mock.Call
}

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

func (*MockDARetriever_RetrieveFromDA_Call) Return

func (*MockDARetriever_RetrieveFromDA_Call) Run

func (*MockDARetriever_RetrieveFromDA_Call) RunAndReturn

type P2PHandler

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

P2PHandler coordinates block retrieval from P2P stores for the syncer. It waits for both header and data to be available at a given height, validates their consistency, and emits events to the syncer for processing.

The handler maintains a processedHeight to track the highest block that has been successfully validated and sent to the syncer, preventing duplicate processing.

func NewP2PHandler

func NewP2PHandler(
	headerStore goheader.Store[*types.SignedHeader],
	dataStore goheader.Store[*types.Data],
	cache cache.CacheManager,
	genesis genesis.Genesis,
	logger zerolog.Logger,
) *P2PHandler

NewP2PHandler creates a new P2P handler.

func (*P2PHandler) ProcessHeight

func (h *P2PHandler) ProcessHeight(ctx context.Context, height uint64, heightInCh chan<- common.DAHeightEvent) error

ProcessHeight retrieves and validates both header and data for the given height from P2P stores. It blocks until both are available, validates consistency (proposer address and data hash match), then emits the event to heightInCh or stores it as pending. Updates processedHeight on success.

func (*P2PHandler) SetProcessedHeight

func (h *P2PHandler) SetProcessedHeight(height uint64)

SetProcessedHeight updates the highest processed block height.

type Syncer

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

Syncer handles block synchronization from DA and P2P sources.

func NewSyncer

func NewSyncer(
	store store.Store,
	exec coreexecutor.Executor,
	daClient da.Client,
	cache cache.Manager,
	metrics *common.Metrics,
	config config.Config,
	genesis genesis.Genesis,
	headerStore common.Broadcaster[*types.SignedHeader],
	dataStore common.Broadcaster[*types.Data],
	logger zerolog.Logger,
	options common.BlockOptions,
	errorCh chan<- error,
	raftNode common.RaftNode,
) *Syncer

NewSyncer creates a new block syncer

func (*Syncer) ApplyBlock

func (s *Syncer) ApplyBlock(ctx context.Context, header types.Header, data *types.Data, currentState types.State) (types.State, error)

ApplyBlock applies a block to get the new state

func (*Syncer) IsSyncedWithRaft

func (s *Syncer) IsSyncedWithRaft(raftState *raft.RaftBlockState) (int, error)

IsSyncedWithRaft checks if the local state is synced with the given raft state, including hash check.

func (*Syncer) RecoverFromRaft

func (s *Syncer) RecoverFromRaft(ctx context.Context, raftState *raft.RaftBlockState) error

RecoverFromRaft attempts to recover the state from a raft block state

func (*Syncer) SetBlockSyncer

func (s *Syncer) SetBlockSyncer(bs BlockSyncer)

SetBlockSyncer sets the block syncer interface, allowing injection of a tracing wrapper or other decorator.

func (*Syncer) SetLastState

func (s *Syncer) SetLastState(state types.State)

SetLastState updates the current state

func (*Syncer) Start

func (s *Syncer) Start(ctx context.Context) error

Start begins the syncing component

func (*Syncer) Stop

func (s *Syncer) Stop() error

Stop shuts down the syncing component

func (*Syncer) TrySyncNextBlock

func (s *Syncer) TrySyncNextBlock(ctx context.Context, event *common.DAHeightEvent) error

TrySyncNextBlock attempts to sync the next available block the event is always the next block in sequence as processHeightEvent ensures it.

func (*Syncer) ValidateBlock

func (s *Syncer) ValidateBlock(_ context.Context, currState types.State, data *types.Data, header *types.SignedHeader) error

ValidateBlock validates a synced block NOTE: if the header was gibberish and somehow passed all validation prior but the data was correct or if the data was gibberish and somehow passed all validation prior but the header was correct we are still losing both in the pending event. This should never happen.

func (*Syncer) VerifyForcedInclusionTxs

func (s *Syncer) VerifyForcedInclusionTxs(ctx context.Context, currentState types.State, data *types.Data) error

VerifyForcedInclusionTxs verifies that forced inclusion transactions from DA are properly handled. Note: Due to block size constraints (MaxBytes), sequencers may defer forced inclusion transactions to future blocks (smoothing). This is legitimate behavior within an epoch. However, ALL forced inclusion txs from an epoch MUST be included before the next epoch begins or grace boundary (whichever comes later).

Jump to

Keyboard shortcuts

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