block

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 47 Imported by: 1

Documentation

Index

Constants

View Source
const DAIncludedHeightKey = "da included height"

DAIncludedHeightKey is the key used for persisting the da included height in store.

View Source
const LastSubmittedHeightKey = "last submitted"

LastSubmittedHeightKey is the key used for persisting the last submitted height in store.

View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this
	// package.
	MetricsSubsystem = "sequencer"
)

Variables

View Source
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")
)

These errors are used by Manager.

View Source
var ErrNoBatch = errors.New("no batch to process")

ErrNoBatch indicate no batch is available for creating block

Functions

This section is empty.

Types

type BatchQueue added in v0.14.0

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

BatchQueue is a queue of transaction batches with timestamps

func NewBatchQueue added in v0.14.0

func NewBatchQueue() *BatchQueue

NewBatchQueue creates a new BatchQueue

func (*BatchQueue) AddBatch added in v0.14.0

func (bq *BatchQueue) AddBatch(batch BatchWithTime)

AddBatch adds a new batch to the queue

func (*BatchQueue) Next added in v0.14.0

func (bq *BatchQueue) Next() *BatchWithTime

Next returns the next batch in the queue

type BatchWithTime added in v0.14.0

type BatchWithTime struct {
	*sequencing.Batch
	time.Time
}

BatchWithTime is used to pass batch and time to BatchQueue

type DataCache added in v0.14.0

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

DataCache maintains data that are seen and hard confirmed

func NewDataCache added in v0.14.0

func NewDataCache() *DataCache

NewDataCache returns a new DataCache struct

type DataSyncService added in v0.14.0

type DataSyncService = SyncService[*types.Data]

DataSyncService is the P2P Sync Service for blocks.

func NewDataSyncService added in v0.14.0

func NewDataSyncService(store ds.TxnDatastore, conf config.NodeConfig, genesis *cmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*DataSyncService, error)

NewDataSyncService returns a new DataSyncService.

type HeaderCache added in v0.14.0

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

HeaderCache maintains headers that are seen and hard confirmed

func NewHeaderCache added in v0.14.0

func NewHeaderCache() *HeaderCache

NewHeaderCache returns a new HeaderCache struct

type HeaderSyncService added in v0.10.7

type HeaderSyncService = SyncService[*types.SignedHeader]

HeaderSyncService is the P2P Sync Service for headers.

func NewHeaderSyncService added in v0.10.7

func NewHeaderSyncService(store ds.TxnDatastore, conf config.NodeConfig, genesis *cmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*HeaderSyncService, error)

NewHeaderSyncService returns a new HeaderSyncService.

type Manager

type Manager struct {
	HeaderCh chan *types.SignedHeader
	DataCh   chan *types.Data
	// contains filtered or unexported fields
}

Manager is responsible for aggregating transactions into blocks.

func NewManager

func NewManager(
	proposerKey crypto.PrivKey,
	conf config.BlockManagerConfig,
	genesis *cmtypes.GenesisDoc,
	store store.Store,
	mempool mempool.Mempool,
	mempoolReaper *mempool.CListMempoolReaper,
	seqClient *grpc.Client,
	proxyApp proxy.AppConnConsensus,
	dalc *da.DAClient,
	eventBus *cmtypes.EventBus,
	logger log.Logger,
	headerStore *goheaderstore.Store[*types.SignedHeader],
	dataStore *goheaderstore.Store[*types.Data],
	seqMetrics *Metrics,
	execMetrics *state.Metrics,
) (*Manager, error)

NewManager creates new block Manager.

func (*Manager) AggregationLoop

func (m *Manager) AggregationLoop(ctx context.Context)

AggregationLoop is responsible for aggregating transactions into rollup-blocks.

func (*Manager) BatchRetrieveLoop added in v0.14.0

func (m *Manager) BatchRetrieveLoop(ctx context.Context)

BatchRetrieveLoop is responsible for retrieving batches from the sequencer.

func (*Manager) DataStoreRetrieveLoop added in v0.14.0

func (m *Manager) DataStoreRetrieveLoop(ctx context.Context)

DataStoreRetrieveLoop is responsible for retrieving data from the Data Store.

func (*Manager) GetDAIncludedHeight added in v0.13.7

func (m *Manager) GetDAIncludedHeight() uint64

GetDAIncludedHeight returns the rollup height at which all blocks have been included in the DA

func (*Manager) GetDataInCh added in v0.14.0

func (m *Manager) GetDataInCh() chan NewDataEvent

GetDataInCh returns the manager's dataInCh

func (*Manager) GetHeaderInCh added in v0.14.0

func (m *Manager) GetHeaderInCh() chan NewHeaderEvent

GetHeaderInCh returns the manager's blockInCh

func (*Manager) GetStoreHeight added in v0.10.2

func (m *Manager) GetStoreHeight() uint64

GetStoreHeight returns the manager's store height

func (*Manager) HeaderStoreRetrieveLoop added in v0.14.0

func (m *Manager) HeaderStoreRetrieveLoop(ctx context.Context)

HeaderStoreRetrieveLoop is responsible for retrieving headers from the Header Store.

func (*Manager) HeaderSubmissionLoop added in v0.14.0

func (m *Manager) HeaderSubmissionLoop(ctx context.Context)

HeaderSubmissionLoop is responsible for submitting blocks to the DA layer.

func (*Manager) IsBlockHashSeen added in v0.11.8

func (m *Manager) IsBlockHashSeen(blockHash string) bool

IsBlockHashSeen returns true if the block with the given hash has been seen.

func (*Manager) IsDAIncluded added in v0.10.7

func (m *Manager) IsDAIncluded(hash types.Hash) bool

IsDAIncluded returns true if the block with the given hash has been seen on DA.

func (*Manager) RetrieveLoop

func (m *Manager) RetrieveLoop(ctx context.Context)

RetrieveLoop is responsible for interacting with DA layer.

func (*Manager) SetDALC

func (m *Manager) SetDALC(dalc *da.DAClient)

SetDALC is used to set DataAvailabilityLayerClient used by Manager.

func (*Manager) SetLastState added in v0.11.8

func (m *Manager) SetLastState(state types.State)

SetLastState is used to set lastState used by Manager.

func (*Manager) SyncLoop

func (m *Manager) SyncLoop(ctx context.Context, cancel context.CancelFunc)

SyncLoop is responsible for syncing blocks.

SyncLoop processes headers gossiped in P2P network to know what's the latest block height, block data is retrieved from DA layer.

type Metrics added in v0.11.19

type Metrics struct {
	// Height of the chain.
	Height metrics.Gauge

	// Number of transactions.
	NumTxs metrics.Gauge
	// Size of the block.
	BlockSizeBytes metrics.Gauge
	// Total number of transactions.
	TotalTxs metrics.Gauge
	// The latest block height.
	CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"`
}

Metrics contains metrics exposed by this package.

func NopMetrics added in v0.11.19

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics added in v0.11.19

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").

type NewDataEvent added in v0.14.0

type NewDataEvent struct {
	Data     *types.Data
	DAHeight uint64
}

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 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

lastSubmittedHeight 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 store.Store, logger log.Logger) (*PendingHeaders, error)

NewPendingHeaders returns a new PendingHeaders struct

type SaveBlockError added in v0.14.0

type SaveBlockError struct {
	Err error
}

SaveBlockError is returned on failure to save block data

func (SaveBlockError) Error added in v0.14.0

func (e SaveBlockError) Error() string

func (SaveBlockError) Unwrap added in v0.14.0

func (e SaveBlockError) Unwrap() error

type SaveBlockResponsesError added in v0.14.0

type SaveBlockResponsesError struct {
	Err error
}

SaveBlockResponsesError is returned on failure to save block responses

func (SaveBlockResponsesError) Error added in v0.14.0

func (e SaveBlockResponsesError) Error() string

func (SaveBlockResponsesError) Unwrap added in v0.14.0

func (e SaveBlockResponsesError) Unwrap() error

type SyncService added in v0.13.6

type SyncService[H header.Header[H]] struct {
	// contains filtered or unexported fields
}

SyncService is the P2P Sync Service for blocks and headers.

Uses the go-header library for handling all P2P logic.

func (*SyncService[H]) Start added in v0.13.6

func (syncService *SyncService[H]) Start(ctx context.Context) error

Start is a part of Service interface.

func (*SyncService[H]) StartSyncer added in v0.13.6

func (syncService *SyncService[H]) StartSyncer(ctx context.Context) error

StartSyncer starts the SyncService's syncer

func (*SyncService[H]) Stop added in v0.13.6

func (syncService *SyncService[H]) Stop(ctx context.Context) error

Stop is a part of Service interface.

`store` is closed last because it's used by other services.

func (*SyncService[H]) Store added in v0.13.6

func (syncService *SyncService[H]) Store() *goheaderstore.Store[H]

Store returns the store of the SyncService

func (*SyncService[H]) WriteToStoreAndBroadcast added in v0.13.6

func (syncService *SyncService[H]) WriteToStoreAndBroadcast(ctx context.Context, headerOrData H) error

WriteToStoreAndBroadcast initializes store if needed and broadcasts provided header or block. Note: Only returns an error in case store can't be initialized. Logs error if there's one while broadcasting.

type SyncerStatus added in v0.10.5

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

SyncerStatus is used by header and block exchange service for keeping track of the status of the syncer in them.

Jump to

Keyboard shortcuts

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