Documentation ¶
Index ¶
- Constants
- func GetChunkChannelDescriptor() *p2p.ChannelDescriptor
- func GetLightBlockChannelDescriptor() *p2p.ChannelDescriptor
- func GetParamsChannelDescriptor() *p2p.ChannelDescriptor
- func GetSnapshotChannelDescriptor() *p2p.ChannelDescriptor
- type Metricer
- type Metrics
- type Reactor
- func (r *Reactor) BackFillBlocksTotal() int64
- func (r *Reactor) BackFilledBlocks() int64
- func (r *Reactor) Backfill(ctx context.Context, state sm.State) error
- func (r *Reactor) ChunkProcessAvgTime() time.Duration
- func (r *Reactor) OnStart(ctx context.Context) error
- func (r *Reactor) OnStop()
- func (r *Reactor) SetChunkChannel(ch *p2p.Channel)
- func (r *Reactor) SetLightBlockChannel(ch *p2p.Channel)
- func (r *Reactor) SetParamsChannel(ch *p2p.Channel)
- func (r *Reactor) SetSnapshotChannel(ch *p2p.Channel)
- func (r *Reactor) SnapshotChunksCount() int64
- func (r *Reactor) SnapshotChunksTotal() int64
- func (r *Reactor) SnapshotHeight() int64
- func (r *Reactor) Sync(ctx context.Context) (sm.State, error)
- func (r *Reactor) TotalSnapshots() int64
Constants ¶
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) )
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 ¶
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 (*Reactor) BackFilledBlocks ¶
func (*Reactor) Backfill ¶
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 (*Reactor) OnStart ¶
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 (*Reactor) SetLightBlockChannel ¶
func (*Reactor) SetParamsChannel ¶
func (*Reactor) SetSnapshotChannel ¶
func (*Reactor) SnapshotChunksCount ¶
func (*Reactor) SnapshotChunksTotal ¶
func (*Reactor) SnapshotHeight ¶
func (*Reactor) Sync ¶
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