Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateHeaderHash(t *testing.T, height uint64, proposer []byte) []byte
- type BatchData
- type Manager
- func (m *Manager) AggregationLoop(ctx context.Context, errCh chan<- error)
- func (m *Manager) DAIncluderLoop(ctx context.Context, errCh chan<- error)
- func (m *Manager) DataCache() *cache.Cache[types.Data]
- func (m *Manager) DataStoreRetrieveLoop(ctx context.Context)
- func (m *Manager) DataSubmissionLoop(ctx context.Context)
- func (m *Manager) GetDAIncludedHeight() uint64
- func (m *Manager) GetExecutor() coreexecutor.Executor
- func (m *Manager) GetLastState() types.State
- func (m *Manager) GetStoreHeight(ctx context.Context) (uint64, error)
- func (m *Manager) HeaderCache() *cache.Cache[types.SignedHeader]
- func (m *Manager) HeaderStoreRetrieveLoop(ctx context.Context)
- func (m *Manager) HeaderSubmissionLoop(ctx context.Context)
- func (m *Manager) IsBlockHashSeen(blockHash string) bool
- func (m *Manager) IsDAIncluded(ctx context.Context, height uint64) (bool, error)
- func (m *Manager) LoadCache() error
- func (m *Manager) NotifyNewTransactions()
- func (m *Manager) PendingHeaders() *PendingHeaders
- func (m *Manager) RetrieveLoop(ctx context.Context)
- func (m *Manager) SaveCache() error
- func (m *Manager) SeqClient() coresequencer.Sequencer
- func (m *Manager) SetLastState(state types.State)
- func (m *Manager) SetRollkitHeightToDAHeight(ctx context.Context, height uint64) error
- func (m *Manager) SyncLoop(ctx context.Context, errCh chan<- error)
- func (m *Manager) Validate(ctx context.Context, header *types.SignedHeader, data *types.Data) error
- type ManagerOptions
- type Metrics
- type MetricsRecorder
- type MetricsTimer
- type MockLogger
- func (m *MockLogger) Debug(args ...interface{})
- func (m *MockLogger) Debugf(format string, args ...interface{})
- func (m *MockLogger) Error(args ...interface{})
- func (m *MockLogger) Errorf(format string, args ...interface{})
- func (m *MockLogger) Fatal(args ...interface{})
- func (m *MockLogger) Fatalf(format string, args ...interface{})
- func (m *MockLogger) Info(args ...interface{})
- func (m *MockLogger) Infof(format string, args ...interface{})
- func (m *MockLogger) Panic(args ...interface{})
- func (m *MockLogger) Panicf(format string, args ...interface{})
- func (m *MockLogger) Warn(args ...interface{})
- func (m *MockLogger) Warnf(format string, args ...interface{})
- func (m *MockLogger) With(keyvals ...interface{}) *zap.SugaredLogger
- type NewDataEvent
- type NewHeaderEvent
- type PendingData
- type PendingHeaders
- type Reaper
Constants ¶
const ( DAModeRetry = "retry" DAModeSuccess = "success" DAModeFail = "fail" )
DA metric modes
const DefaultInterval = 1 * time.Second
const LastSubmittedDataHeightKey = "last-submitted-data-height"
LastSubmittedDataHeightKey is the key used for persisting the last submitted data height in store.
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "sequencer" )
Variables ¶
var ( // ErrNoValidatorsInState is used when no validators/proposers are found in state ErrNoValidatorsInState = errors.New("no validators found in state") // ErrNotProposer is used when the manager is not a proposer ErrNotProposer = errors.New("not a proposer") // ErrNoBatch indicate no batch is available for creating block ErrNoBatch = errors.New("no batch to process") // ErrHeightFromFutureStr is the error message for height from future returned by da ErrHeightFromFutureStr = errors.New("given height is from the future") )
These errors are used by Manager.
Functions ¶
Types ¶
type BatchData ¶
type BatchData struct {
*coresequencer.Batch
time.Time
Data [][]byte
}
BatchData is used to pass batch, time and data (da.IDs) to BatchQueue
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for aggregating transactions into blocks.
func NewManager ¶
func NewManager( ctx context.Context, signer signer.Signer, config config.Config, genesis genesis.Genesis, store storepkg.Store, exec coreexecutor.Executor, sequencer coresequencer.Sequencer, da coreda.DA, logger logging.EventLogger, headerStore goheader.Store[*types.SignedHeader], dataStore goheader.Store[*types.Data], headerBroadcaster broadcaster[*types.SignedHeader], dataBroadcaster broadcaster[*types.Data], seqMetrics *Metrics, gasPrice float64, gasMultiplier float64, managerOpts ManagerOptions, ) (*Manager, error)
NewManager creates new block Manager.
func (*Manager) AggregationLoop ¶
AggregationLoop is responsible for aggregating transactions into blocks.
func (*Manager) DAIncluderLoop ¶
DAIncluderLoop is responsible for advancing the DAIncludedHeight by checking if blocks after the current height have both their header and data marked as DA-included in the caches. If so, it calls setDAIncludedHeight.
func (*Manager) DataStoreRetrieveLoop ¶ added in v0.14.0
DataStoreRetrieveLoop is responsible for retrieving data from the Data Store.
func (*Manager) DataSubmissionLoop ¶
DataSubmissionLoop is responsible for submitting data to the DA layer.
func (*Manager) GetDAIncludedHeight ¶ added in v0.13.7
GetDAIncludedHeight returns the height at which all blocks have been included in the DA
func (*Manager) GetExecutor ¶
func (m *Manager) GetExecutor() coreexecutor.Executor
GetExecutor returns the executor used by the manager.
Note: this is a temporary method to allow testing the manager. It will be removed once the manager is fully integrated with the execution client. TODO(tac0turtle): remove
func (*Manager) GetLastState ¶
GetLastState returns the last recorded state.
func (*Manager) GetStoreHeight ¶ added in v0.10.2
GetStoreHeight returns the manager's store height
func (*Manager) HeaderCache ¶
func (m *Manager) HeaderCache() *cache.Cache[types.SignedHeader]
HeaderCache returns the headerCache used by the manager.
func (*Manager) HeaderStoreRetrieveLoop ¶ added in v0.14.0
HeaderStoreRetrieveLoop is responsible for retrieving headers from the Header Store.
func (*Manager) HeaderSubmissionLoop ¶ added in v0.14.0
HeaderSubmissionLoop is responsible for submitting headers to the DA layer.
func (*Manager) IsBlockHashSeen ¶ added in v0.11.8
IsBlockHashSeen returns true if the block with the given hash has been seen.
func (*Manager) IsDAIncluded ¶ added in v0.10.7
IsDAIncluded returns true if the block with the given hash has been seen on DA. TODO(tac0turtle): should we use this for pending header system to verify how far ahead a chain is?
func (*Manager) NotifyNewTransactions ¶
func (m *Manager) NotifyNewTransactions()
NotifyNewTransactions signals that new transactions are available for processing This method will be called by the Reaper when it receives new transactions
func (*Manager) PendingHeaders ¶
func (m *Manager) PendingHeaders() *PendingHeaders
PendingHeaders returns the pending headers.
func (*Manager) RetrieveLoop ¶
RetrieveLoop is responsible for interacting with DA layer.
func (*Manager) SeqClient ¶
func (m *Manager) SeqClient() coresequencer.Sequencer
SeqClient returns the grpc sequencing client.
func (*Manager) SetLastState ¶ added in v0.11.8
SetLastState is used to set lastState used by Manager.
func (*Manager) SetRollkitHeightToDAHeight ¶
SetRollkitHeightToDAHeight stores the mapping from a Rollkit block height to the corresponding DA (Data Availability) layer heights where the block's header and data were included. This mapping is persisted in the store metadata and is used to track which DA heights contain the block components for a given Rollkit height.
For blocks with empty transactions, both header and data use the same DA height since empty transaction data is not actually published to the DA layer.
type ManagerOptions ¶
type ManagerOptions struct {
SignaturePayloadProvider types.SignaturePayloadProvider
ValidatorHasherProvider types.ValidatorHasherProvider
}
ManagerOptions defines the options for creating a new block Manager.
func DefaultManagerOptions ¶
func DefaultManagerOptions() ManagerOptions
DefaultManagerOptions returns the default options for creating a new block Manager.
func (*ManagerOptions) Validate ¶
func (opts *ManagerOptions) Validate() error
type Metrics ¶ added in v0.11.19
type Metrics struct {
// Original metrics
Height metrics.Gauge // Height of the chain
NumTxs metrics.Gauge // Number of transactions in the latest block
BlockSizeBytes metrics.Gauge // Size of the latest block
TotalTxs metrics.Gauge // Total number of transactions
CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"` // The latest block height
// Channel metrics
ChannelBufferUsage map[string]metrics.Gauge
DroppedSignals metrics.Counter
// Error metrics
ErrorsByType map[string]metrics.Counter
RecoverableErrors metrics.Counter
NonRecoverableErrors metrics.Counter
// Performance metrics
OperationDuration map[string]metrics.Histogram
GoroutineCount metrics.Gauge
// DA metrics
DASubmissionAttempts metrics.Counter
DASubmissionSuccesses metrics.Counter
DASubmissionFailures metrics.Counter
DARetrievalAttempts metrics.Counter
DARetrievalSuccesses metrics.Counter
DARetrievalFailures metrics.Counter
DAInclusionHeight metrics.Gauge
PendingHeadersCount metrics.Gauge
PendingDataCount metrics.Gauge
// Sync metrics
SyncLag metrics.Gauge
HeadersSynced metrics.Counter
DataSynced metrics.Counter
BlocksApplied metrics.Counter
InvalidHeadersCount metrics.Counter
// Block production metrics
BlockProductionTime metrics.Histogram
EmptyBlocksProduced metrics.Counter
LazyBlocksProduced metrics.Counter
NormalBlocksProduced metrics.Counter
TxsPerBlock metrics.Histogram
// State transition metrics
StateTransitions map[string]metrics.Counter
InvalidTransitions metrics.Counter
}
Metrics contains all metrics exposed by this package.
func PrometheusMetrics ¶ added in v0.11.19
PrometheusMetrics returns Metrics built using Prometheus client library
type MetricsRecorder ¶
type MetricsRecorder interface {
RecordMetrics(gasPrice float64, blobSize uint64, statusCode coreda.StatusCode, numPendingBlocks uint64, includedBlockHeight uint64)
}
MetricsRecorder defines the interface for sequencers that support recording metrics. This interface is used to avoid duplication of the anonymous interface definition across multiple files in the block package.
type MetricsTimer ¶
type MetricsTimer struct {
// contains filtered or unexported fields
}
MetricsTimer helps track operation duration
func NewMetricsTimer ¶
func NewMetricsTimer(operation string, metrics *Metrics) *MetricsTimer
NewMetricsTimer creates a new timer for tracking operation duration
func (*MetricsTimer) Stop ¶
func (t *MetricsTimer) Stop()
Stop stops the timer and records the duration
type MockLogger ¶
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(args ...interface{})
For non-f methods, the first arg is typically the message string, others are keyvals.
func (*MockLogger) Debugf ¶
func (m *MockLogger) Debugf(format string, args ...interface{})
func (*MockLogger) Error ¶
func (m *MockLogger) Error(args ...interface{})
func (*MockLogger) Errorf ¶
func (m *MockLogger) Errorf(format string, args ...interface{})
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(args ...interface{})
func (*MockLogger) Fatalf ¶
func (m *MockLogger) Fatalf(format string, args ...interface{})
func (*MockLogger) Info ¶
func (m *MockLogger) Info(args ...interface{})
func (*MockLogger) Infof ¶
func (m *MockLogger) Infof(format string, args ...interface{})
func (*MockLogger) Panic ¶
func (m *MockLogger) Panic(args ...interface{})
func (*MockLogger) Panicf ¶
func (m *MockLogger) Panicf(format string, args ...interface{})
func (*MockLogger) Warn ¶
func (m *MockLogger) Warn(args ...interface{})
func (*MockLogger) Warnf ¶
func (m *MockLogger) Warnf(format string, args ...interface{})
func (*MockLogger) With ¶
func (m *MockLogger) With(keyvals ...interface{}) *zap.SugaredLogger
type NewDataEvent ¶ added in v0.14.0
NewDataEvent is used to pass header and DA height to headerInCh
type NewHeaderEvent ¶ added in v0.14.0
type NewHeaderEvent struct {
Header *types.SignedHeader
DAHeight uint64
}
NewHeaderEvent is used to pass header and DA height to headerInCh
type PendingData ¶
type PendingData struct {
// contains filtered or unexported fields
}
PendingData maintains Data that need to be published to DA layer
Important assertions: - data is safely stored in database before submission to DA - data is always pushed to DA in order (by height) - DA submission of multiple data is atomic - it's impossible to submit only part of a batch
lastSubmittedDataHeight is updated only after receiving confirmation from DA. Worst case scenario is when data was successfully submitted to DA, but confirmation was not received (e.g. node was restarted, networking issue occurred). In this case data is re-submitted to DA (it's extra cost). rollkit is able to skip duplicate data so this shouldn't affect full nodes. Note: Submission of pending data to DA should account for the DA max blob size.
func NewPendingData ¶
func NewPendingData(store store.Store, logger logging.EventLogger) (*PendingData, error)
NewPendingData returns a new PendingData struct
type PendingHeaders ¶ added in v0.14.0
type PendingHeaders struct {
// contains filtered or unexported fields
}
PendingHeaders maintains headers that need to be published to DA layer
Important assertions: - headers are safely stored in database before submission to DA - headers are always pushed to DA in order (by height) - DA submission of multiple headers is atomic - it's impossible to submit only part of a batch
lastSubmittedHeaderHeight is updated only after receiving confirmation from DA. Worst case scenario is when headers was successfully submitted to DA, but confirmation was not received (e.g. node was restarted, networking issue occurred). In this case headers are re-submitted to DA (it's extra cost). rollkit is able to skip duplicate headers so this shouldn't affect full nodes. TODO(tzdybal): we shouldn't try to push all pending headers at once; this should depend on max blob size
func NewPendingHeaders ¶ added in v0.14.0
func NewPendingHeaders(store storepkg.Store, logger logging.EventLogger) (*PendingHeaders, error)
NewPendingHeaders returns a new PendingHeaders struct
type Reaper ¶
type Reaper struct {
// contains filtered or unexported fields
}
Reaper is responsible for periodically retrieving transactions from the executor, filtering out already seen transactions, and submitting new transactions to the sequencer.
func NewReaper ¶
func NewReaper(ctx context.Context, exec coreexecutor.Executor, sequencer coresequencer.Sequencer, chainID string, interval time.Duration, logger logging.EventLogger, store ds.Batching) *Reaper
NewReaper creates a new Reaper instance with persistent seenTx storage.
func (*Reaper) SetManager ¶
SetManager sets the Manager reference for transaction notifications