statesync

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SnapshotChannel exchanges snapshot metadata
	SnapshotChannel = p2p.ChannelID(0x60)

	// ChunkChannel exchanges chunk contents
	ChunkChannel = p2p.ChannelID(0x61)

	// LightBlockChannel exchanges light blocks
	LightBlockChannel = p2p.ChannelID(0x62)

	// ParamsChannel exchanges consensus params
	ParamsChannel = p2p.ChannelID(0x63)
)
View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this package.
	MetricsSubsystem = "statesync"
)

Variables

This section is empty.

Functions

func GetChunkChannelDescriptor

func GetChunkChannelDescriptor() *p2p.ChannelDescriptor

func GetLightBlockChannelDescriptor

func GetLightBlockChannelDescriptor() *p2p.ChannelDescriptor

func GetParamsChannelDescriptor

func GetParamsChannelDescriptor() *p2p.ChannelDescriptor

func GetSnapshotChannelDescriptor

func GetSnapshotChannelDescriptor() *p2p.ChannelDescriptor

Types

type Metricer

type Metricer interface {
	TotalSnapshots() int64
	ChunkProcessAvgTime() time.Duration
	SnapshotHeight() int64
	SnapshotChunksCount() int64
	SnapshotChunksTotal() int64
	BackFilledBlocks() int64
	BackFillBlocksTotal() int64
}

Metricer defines an interface used for the rpc sync info query, please see statesync.metrics for the details.

type Metrics

type Metrics struct {
	// The total number of snapshots discovered.
	TotalSnapshots metrics.Counter
	// The average processing time per chunk.
	ChunkProcessAvgTime metrics.Gauge
	// The height of the current snapshot the has been processed.
	SnapshotHeight metrics.Gauge
	// The current number of chunks that have been processed.
	SnapshotChunk metrics.Counter
	// The total number of chunks in the current snapshot.
	SnapshotChunkTotal metrics.Gauge
	// The current number of blocks that have been back-filled.
	BackFilledBlocks metrics.Counter
	// The total number of blocks that need to be back-filled.
	BackFillBlocksTotal metrics.Gauge
}

Metrics contains metrics exposed by this package.

func NopMetrics

func NopMetrics() *Metrics

func PrometheusMetrics

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

type Reactor

type Reactor struct {
	service.BaseService
	// contains filtered or unexported fields
}

Reactor handles state sync, both restoring snapshots for the local node and serving snapshots for other nodes.

func NewReactor

func NewReactor(
	chainID string,
	initialHeight int64,
	cfg config.StateSyncConfig,
	logger log.Logger,
	conn abciclient.Client,
	peerEvents p2p.PeerEventSubscriber,
	stateStore sm.Store,
	blockStore *store.BlockStore,
	tempDir string,
	ssMetrics *Metrics,
	eventBus *eventbus.EventBus,
	postSyncHook func(context.Context, sm.State) error,
	needsStateSync bool,
	restartCh chan struct{},
	selfRemediationConfig *config.SelfRemediationConfig,
) *Reactor

NewReactor returns a reference to a new state sync reactor, which implements the service.Service interface. It accepts a logger, connections for snapshots and querying, references to p2p Channels and a channel to listen for peer updates on. Note, the reactor will close all p2p Channels when stopping.

func (*Reactor) BackFillBlocksTotal

func (r *Reactor) BackFillBlocksTotal() int64

func (*Reactor) BackFilledBlocks

func (r *Reactor) BackFilledBlocks() int64

func (*Reactor) Backfill

func (r *Reactor) Backfill(ctx context.Context, state sm.State) error

Backfill sequentially fetches, verifies and stores light blocks in reverse order. It does not stop verifying blocks until reaching a block with a height and time that is less or equal to the stopHeight and stopTime. The trustedBlockID should be of the header at startHeight.

func (*Reactor) ChunkProcessAvgTime

func (r *Reactor) ChunkProcessAvgTime() time.Duration

func (*Reactor) OnStart

func (r *Reactor) OnStart(ctx context.Context) error

OnStart starts separate go routines for each p2p Channel and listens for envelopes on each. In addition, it also listens for peer updates and handles messages on that p2p channel accordingly. Note, we do not launch a go-routine to handle individual envelopes as to not have to deal with bounding workers or pools. The caller must be sure to execute OnStop to ensure the outbound p2p Channels are closed. No error is returned.

func (*Reactor) OnStop

func (r *Reactor) OnStop()

OnStop stops the reactor by signaling to all spawned goroutines to exit and blocking until they all exit.

func (*Reactor) SetChunkChannel

func (r *Reactor) SetChunkChannel(ch *p2p.Channel)

func (*Reactor) SetLightBlockChannel

func (r *Reactor) SetLightBlockChannel(ch *p2p.Channel)

func (*Reactor) SetParamsChannel

func (r *Reactor) SetParamsChannel(ch *p2p.Channel)

func (*Reactor) SetSnapshotChannel

func (r *Reactor) SetSnapshotChannel(ch *p2p.Channel)

func (*Reactor) SnapshotChunksCount

func (r *Reactor) SnapshotChunksCount() int64

func (*Reactor) SnapshotChunksTotal

func (r *Reactor) SnapshotChunksTotal() int64

func (*Reactor) SnapshotHeight

func (r *Reactor) SnapshotHeight() int64

func (*Reactor) Sync

func (r *Reactor) Sync(ctx context.Context) (sm.State, error)

Sync runs a state sync, fetching snapshots and providing chunks to the application. At the close of the operation, Sync will bootstrap the state store and persist the commit at that height so that either consensus or blocksync can commence. It will then proceed to backfill the necessary amount of historical blocks before participating in consensus

func (*Reactor) TotalSnapshots

func (r *Reactor) TotalSnapshots() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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