syncer

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrForkTooLong is return when the syncing chain has fork with local
	ErrForkTooLong = fmt.Errorf("fork longer than threshold")
	// ErrChainHasBadTipSet is returned when the syncer traverses a chain with a cached bad tipset.
	ErrChainHasBadTipSet = errors.New("input chain contains a cached bad tipset")
	// ErrNewChainTooLong is returned when processing a fork that split off from the main chain too many blocks ago.
	ErrNewChainTooLong = errors.New("input chain forked from best chain past finality limit")
	// ErrUnexpectedStoreState indicates that the syncer's chain bsstore is violating expected invariants.
	ErrUnexpectedStoreState = errors.New("the chain bsstore is in an unexpected state")
)

Functions

This section is empty.

Types

type BlockValidator

type BlockValidator interface {
	ValidateFullBlock(ctx context.Context, blk *types.BlockHeader) error
}

BlockValidator used to validate full block

type ChainReaderWriter

type ChainReaderWriter interface {
	GetHead() *types.TipSet
	GetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
	GetTipSetStateRoot(context.Context, *types.TipSet) (cid.Cid, error)
	GetTipSetReceiptsRoot(context.Context, *types.TipSet) (cid.Cid, error)
	HasTipSetAndState(context.Context, *types.TipSet) bool
	GetTipsetMetadata(context.Context, *types.TipSet) (*chain.TipSetMetadata, error)
	PutTipSetMetadata(context.Context, *chain.TipSetMetadata) error
	SetHead(context.Context, *types.TipSet) error
	GetLatestBeaconEntry(context.Context, *types.TipSet) (*types.BeaconEntry, error)
	GetGenesisBlock(context.Context) (*types.BlockHeader, error)
}

ChainReaderWriter reads and writes the chain bsstore.

type ChainSelector

type ChainSelector interface {
	// IsHeavier returns true if tipset a is heavier than tipset b and false if
	// tipset b is heavier than tipset a.
	IsHeavier(ctx context.Context, a, b *types.TipSet) (bool, error)
	// Weight returns the weight of a tipset after the upgrade to version 1
	Weight(ctx context.Context, ts *types.TipSet) (big.Int, error)
}

ChainSelector chooses the heaviest between chains.

type StateProcessor added in v0.9.1

type StateProcessor interface {
	// RunStateTransition returns the state root CID resulting from applying the input ts to the
	// prior `stateRoot`.  It returns an error if the transition is invalid.
	RunStateTransition(ctx context.Context, ts *types.TipSet) (root cid.Cid, receipt cid.Cid, err error)
}

StateProcessor does semantic validation on fullblocks.

type Syncer

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

Syncer used to synchronize the block from the specified target, including acquiring the relevant block data and message data, verifying the block machine messages one by one and calculating them, checking the weight of the target after the calculation, and check whether it can become the latest tipset

func NewSyncer

func NewSyncer(stmgr *statemanger.Stmgr,
	hv BlockValidator,
	s *chain.Store,
	m messageStore,
	bsstore blockstoreutil.Blockstore,
	exchangeClient exchange.Client,
	c clock.Clock,
	fork fork.IFork,
) (*Syncer, error)

NewSyncer constructs a Syncer ready for use. The chain reader must have a head tipset to initialize the staging field.

func (*Syncer) HandleNewTipSet

func (syncer *Syncer) HandleNewTipSet(ctx context.Context, target *syncTypes.Target) (err error)

HandleNewTipSet validates and syncs the chain rooted at the provided tipset to a chain bsstore. Iff catchup is false then the syncer will set the head.

func (*Syncer) Head added in v0.9.1

func (syncer *Syncer) Head() *types.TipSet

Head get latest head from chain store

Jump to

Keyboard shortcuts

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