Documentation
¶
Index ¶
- func NewDARetriever(client da.Client, cache cache.CacheManager, genesis genesis.Genesis, ...) *daRetriever
- type BlockSyncer
- type DARetriever
- type MockDARetriever
- type MockDARetriever_Expecter
- type MockDARetriever_RetrieveFromDA_Call
- func (_c *MockDARetriever_RetrieveFromDA_Call) Return(dAHeightEvents []common.DAHeightEvent, err error) *MockDARetriever_RetrieveFromDA_Call
- func (_c *MockDARetriever_RetrieveFromDA_Call) Run(run func(ctx context.Context, daHeight uint64)) *MockDARetriever_RetrieveFromDA_Call
- func (_c *MockDARetriever_RetrieveFromDA_Call) RunAndReturn(run func(ctx context.Context, daHeight uint64) ([]common.DAHeightEvent, error)) *MockDARetriever_RetrieveFromDA_Call
- type P2PHandler
- type Syncer
- func (s *Syncer) ApplyBlock(ctx context.Context, header types.Header, data *types.Data, ...) (types.State, error)
- func (s *Syncer) IsSyncedWithRaft(raftState *raft.RaftBlockState) (int, error)
- func (s *Syncer) RecoverFromRaft(ctx context.Context, raftState *raft.RaftBlockState) error
- func (s *Syncer) SetBlockSyncer(bs BlockSyncer)
- func (s *Syncer) SetLastState(state types.State)
- func (s *Syncer) Start(ctx context.Context) error
- func (s *Syncer) Stop() error
- func (s *Syncer) TrySyncNextBlock(ctx context.Context, event *common.DAHeightEvent) error
- func (s *Syncer) ValidateBlock(_ context.Context, currState types.State, data *types.Data, ...) error
- func (s *Syncer) VerifyForcedInclusionTxs(ctx context.Context, currentState types.State, data *types.Data) error
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 ¶
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 (_m *MockDARetriever) EXPECT() *MockDARetriever_Expecter
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 ¶
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 (_c *MockDARetriever_RetrieveFromDA_Call) Return(dAHeightEvents []common.DAHeightEvent, err error) *MockDARetriever_RetrieveFromDA_Call
func (*MockDARetriever_RetrieveFromDA_Call) Run ¶
func (_c *MockDARetriever_RetrieveFromDA_Call) Run(run func(ctx context.Context, daHeight uint64)) *MockDARetriever_RetrieveFromDA_Call
func (*MockDARetriever_RetrieveFromDA_Call) RunAndReturn ¶
func (_c *MockDARetriever_RetrieveFromDA_Call) RunAndReturn(run func(ctx context.Context, daHeight uint64) ([]common.DAHeightEvent, error)) *MockDARetriever_RetrieveFromDA_Call
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 ¶
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 ¶
SetLastState updates the current state
func (*Syncer) TrySyncNextBlock ¶
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).