chain

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0, MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActorStatesRawTask      = "actorstatesraw"      // task that only extracts raw actor state
	ActorStatesPowerTask    = "actorstatespower"    // task that only extracts power actor states (but not the raw state)
	ActorStatesRewardTask   = "actorstatesreward"   // task that only extracts reward actor states (but not the raw state)
	ActorStatesMinerTask    = "actorstatesminer"    // task that only extracts miner actor states (but not the raw state)
	ActorStatesInitTask     = "actorstatesinit"     // task that only extracts init actor states (but not the raw state)
	ActorStatesMarketTask   = "actorstatesmarket"   // task that only extracts market actor states (but not the raw state)
	ActorStatesMultisigTask = "actorstatesmultisig" // task that only extracts multisig actor states (but not the raw state)
	ActorStatesVerifreg     = "actorstatesverifreg" // task that only extracts verified registry actor states (but not the raw state)
	BlocksTask              = "blocks"              // task that extracts block data
	MessagesTask            = "messages"            // task that extracts message data
	ChainEconomicsTask      = "chaineconomics"      // task that extracts chain economics data
	MultisigApprovalsTask   = "msapprovals"         // task that extracts multisig actor approvals
	ImplicitMessageTask     = "implicitmessage"     // task that extract implicitly executed messages: cron tick and block reward.
	ChainConsensusTask      = "consensus"
)
View Source
const (
	// HeadEventRevert indicates that the event signals a reversion of a tipset from the chain
	HeadEventRevert = "revert"

	// HeadEventRevert indicates that the event signals the application of a tipset to the chain
	HeadEventApply = "apply"

	// HeadEventRevert indicates that the event signals the current known head tipset
	HeadEventCurrent = "current"
)

Constants for HeadEvent types

View Source
const MainnetGenesisTs = 1598306400 // unix timestamp of genesis epoch

Variables

View Source
var (
	ErrCacheEmpty       = errors.New("cache empty")
	ErrAddOutOfOrder    = errors.New("added tipset height lower than current head")
	ErrRevertOutOfOrder = errors.New("reverted tipset does not match current head")
	ErrEmptyRevert      = errors.New("reverted received on empty cache")
)
View Source
var FullTaskSet mapset.Set

Functions

func CurrentMainnetHeight

func CurrentMainnetHeight() int64

CurrentMainnetHeight calculates the current height of the filecoin mainnet.

func HeightToUnix

func HeightToUnix(height int64, genesisTs int64) int64

HeightToUnix converts a chain height to a unix timestamp given the unix timestamp of the genesis epoch.

func UnixToHeight

func UnixToHeight(ts int64, genesisTs int64) int64

UnixToHeight converts a unix timestamp a chain height given the unix timestamp of the genesis epoch.

Types

type ActorProcessor

type ActorProcessor interface {
	// ProcessActors processes a set of actors. If error is non-nil then the processor encountered a fatal error.
	// Any data returned must be accompanied by a processing report.
	ProcessActors(ctx context.Context, ts *types.TipSet, pts *types.TipSet, actors map[string]lens.ActorStateChange, emsgs []*lens.ExecutedMessage) (model.Persistable, *visormodel.ProcessingReport, error)
}

type GapFiller

type GapFiller struct {
	DB *storage.Database
	// contains filtered or unexported fields
}

func NewGapFiller

func NewGapFiller(node lens.API, db *storage.Database, name string, minHeight, maxHeight uint64, tasks []string) *GapFiller

func (*GapFiller) Run

func (g *GapFiller) Run(ctx context.Context) error

type GapIndexer

type GapIndexer struct {
	DB *storage.Database
	// contains filtered or unexported fields
}

func NewGapIndexer

func NewGapIndexer(node lens.API, db *storage.Database, name string, minHeight, maxHeight uint64, tasks []string) *GapIndexer

func (*GapIndexer) Run

func (g *GapIndexer) Run(ctx context.Context) error

type GapIndexerLens

type GapIndexerLens interface {
	ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
}

type HeadEvent

type HeadEvent struct {
	Type   string
	TipSet *types.TipSet
}

A HeadEvent is a notification of a change at the head of the chain

type HeadNotifier

type HeadNotifier interface {
	// HeadEvents returns a channel that receives head events. It may be closed
	// by the sender of the events, in which case Err will return a non-nil error
	// explaining why. HeadEvents may return nil if this implementation will never
	// notify any events.
	HeadEvents() <-chan *HeadEvent

	// Err returns the reason for the closing of the HeadEvents channel.
	Err() error
}

A HeadNotifier reports tipset events that occur at the head of the chain

type MessageExecutionProcessor

type MessageExecutionProcessor interface {
	ProcessMessageExecutions(ctx context.Context, store adt.Store, ts *types.TipSet, pts *types.TipSet, imsgs []*lens.MessageExecution) (model.Persistable, *visormodel.ProcessingReport, error)
}

type MessageProcessor

type MessageProcessor interface {
	// ProcessMessages processes messages contained within a tipset. If error is non-nil then the processor encountered a fatal error.
	// pts is the tipset containing the messages, ts is the tipset containing the receipts
	// Any data returned must be accompanied by a processing report.
	ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types.TipSet, emsgs []*lens.ExecutedMessage, blkMsgs []*lens.BlockMessages) (model.Persistable, *visormodel.ProcessingReport, error)
}

type TaskHeight

type TaskHeight struct {
	Task   string
	Height uint64
	Status string
}

type TaskResult

type TaskResult struct {
	Task        string
	Error       error
	Report      visormodel.ProcessingReportList
	Data        model.Persistable
	StartedAt   time.Time
	CompletedAt time.Time
}

A TaskResult is either some data to persist or an error which indicates that the task did not complete. Partial completions are possible provided the Data contains a persistable log of the results.

type TipSetCache

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

TipSetCache is a cache of recent tipsets that can keep track of reversions. Inspired by tipSetCache in Lotus chain/events package.

func NewTipSetCache

func NewTipSetCache(size int) *TipSetCache

func (*TipSetCache) Add

func (c *TipSetCache) Add(ts *types.TipSet) (*types.TipSet, error)

Add adds a new tipset which becomes the new head of the cache. If the buffer is full, the tail being evicted is also returned.

func (*TipSetCache) Confidence added in v0.8.2

func (c *TipSetCache) Confidence() int

Confidence returns the number of tipset that the cache must hold before tipsets are evicted on Add.

func (*TipSetCache) Head

func (c *TipSetCache) Head() (*types.TipSet, error)

Head returns the tipset at the head of the cache.

func (*TipSetCache) Height

func (c *TipSetCache) Height() abi.ChainEpoch

Height returns the height of the current head or zero if the cache is empty.

func (*TipSetCache) Len

func (c *TipSetCache) Len() int

Len returns the number of tipsets in the cache. This will never exceed the size of the cache.

func (*TipSetCache) Reset

func (c *TipSetCache) Reset()

Reset removes all tipsets from the cache

func (*TipSetCache) Revert

func (c *TipSetCache) Revert(ts *types.TipSet) error

Revert removes the head tipset

func (*TipSetCache) SetCurrent

func (c *TipSetCache) SetCurrent(ts *types.TipSet) error

SetCurrent replaces the current head

func (*TipSetCache) Size

func (c *TipSetCache) Size() int

Size returns the maximum number of tipsets that may be present in the cache.

func (*TipSetCache) Tail

func (c *TipSetCache) Tail() (*types.TipSet, error)

Tail returns the tipset at the tail of the cache.

func (*TipSetCache) TailHeight

func (c *TipSetCache) TailHeight() abi.ChainEpoch

TailHeight returns the height of the current tail or zero if the cache is empty.

func (*TipSetCache) Warm added in v0.8.2

func (c *TipSetCache) Warm(ctx context.Context, head *types.TipSet, getTipSetFn func(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)) error

Warm fills the TipSetCache with confidence tipsets so that subsequent calls to Add return a tipset.

type TipSetIndexer

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

TipSetIndexer waits for tipsets and persists their block data into a database.

func NewTipSetIndexer

func NewTipSetIndexer(node lens.API, d model.Storage, window time.Duration, name string, tasks []string, options ...TipSetIndexerOpt) (*TipSetIndexer, error)

NewTipSetIndexer extracts block, message and actor state data from a tipset and persists it to storage. Extraction and persistence are concurrent. Extraction of the a tipset can proceed while data from the previous extraction is being persisted. The indexer may be given a time window in which to complete data extraction. The name of the indexer is used as the reporter in the visor_processing_reports table.

func (*TipSetIndexer) Close

func (t *TipSetIndexer) Close() error

func (*TipSetIndexer) SkipTipSet

func (t *TipSetIndexer) SkipTipSet(ctx context.Context, ts *types.TipSet, reason string) error

SkipTipSet writes a processing report to storage for each indexer task to indicate that the entire tipset was not processed.

func (*TipSetIndexer) TipSet

func (t *TipSetIndexer) TipSet(ctx context.Context, ts *types.TipSet) error

TipSet is called when a new tipset has been discovered

type TipSetIndexerOpt

type TipSetIndexerOpt func(t *TipSetIndexer)

type TipSetObserver

type TipSetObserver interface {
	TipSet(ctx context.Context, ts *types.TipSet) error
	SkipTipSet(ctx context.Context, ts *types.TipSet, reason string) error
	Close() error
}

A TipSetObserver waits for notifications of new tipsets.

type TipSetProcessor

type TipSetProcessor interface {
	// ProcessTipSet processes a tipset. If error is non-nil then the processor encountered a fatal error.
	// Any data returned must be accompanied by a processing report.
	ProcessTipSet(ctx context.Context, ts *types.TipSet) (model.Persistable, *visormodel.ProcessingReport, error)
}

type TipSetsProcessor

type TipSetsProcessor interface {
	// ProcessTipSets processes a parent and child tipset. If error is non-nil then the processor encountered a fatal error.
	// Any data returned must be accompanied by a processing report.
	ProcessTipSets(ctx context.Context, child, parent *types.TipSet) (model.Persistable, visormodel.ProcessingReportList, error)
}

type Walker

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

Walker is a job that indexes blocks by walking the chain history.

func NewWalker

func NewWalker(obs TipSetObserver, node lens.API, minHeight, maxHeight int64) *Walker

func (*Walker) Run

func (c *Walker) Run(ctx context.Context) error

Run starts walking the chain history and continues until the context is done or the start of the chain is reached.

func (*Walker) WalkChain

func (c *Walker) WalkChain(ctx context.Context, node lens.API, ts *types.TipSet) error

type Watcher

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

Watcher is a task that indexes blocks by following the chain head.

func NewWatcher

func NewWatcher(obs TipSetObserver, hn HeadNotifier, cache *TipSetCache) *Watcher

NewWatcher creates a new Watcher. confidence sets the number of tipsets that will be held in a cache awaiting possible reversion. Tipsets will be written to the database when they are evicted from the cache due to incoming later tipsets.

func (*Watcher) Run

func (c *Watcher) Run(ctx context.Context) error

Run starts following the chain head and blocks until the context is done or an error occurs.

Directories

Path Synopsis
adt
builtin
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/account
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/cron
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/init
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/market
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/miner
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/multisig
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/paych
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/power
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/reward
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/verifreg
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
policy
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.

Jump to

Keyboard shortcuts

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