Documentation ¶
Index ¶
- Constants
- Variables
- func ActorStore(ctx context.Context, bs bstore.Blockstore) adt.Store
- func ComputeNextBaseFee(baseFee types.BigInt, gasLimitUsed int64, noOfBlocks int, epoch abi.ChainEpoch) types.BigInt
- func FlushValidationCache(ctx context.Context, ds dstore.Batching) error
- func PutMessage(ctx context.Context, bs bstore.Blockstore, m storable) (cid.Cid, error)
- func ReorgOps(ctx context.Context, ...) ([]*types.TipSet, []*types.TipSet, error)
- type BlockMessages
- type ChainIndex
- type ChainStore
- func (cs *ChainStore) ActorStore(ctx context.Context) adt.Store
- func (cs *ChainStore) AddToTipSetTracker(ctx context.Context, b *types.BlockHeader) error
- func (cs *ChainStore) BlockMsgsForTipset(ctx context.Context, ts *types.TipSet) ([]BlockMessages, error)
- func (cs *ChainStore) ChainBlockstore() bstore.Blockstore
- func (cs *ChainStore) ChainLocalBlockstore() bstore.Blockstore
- func (cs *ChainStore) Close() error
- func (cs *ChainStore) ComputeBaseFee(ctx context.Context, ts *types.TipSet) (abi.TokenAmount, error)
- func (cs *ChainStore) Contains(ctx context.Context, ts *types.TipSet) (bool, error)
- func (cs *ChainStore) Export(ctx context.Context, ts *types.TipSet, inclRecentRoots abi.ChainEpoch, ...) error
- func (cs *ChainStore) ExportRange(ctx context.Context, w io.Writer, head, tail *types.TipSet, ...) error
- func (cs *ChainStore) FlushValidationCache(ctx context.Context) error
- func (cs *ChainStore) ForceHeadSilent(ctx context.Context, ts *types.TipSet) error
- func (cs *ChainStore) FormHeaviestTipSetForHeight(ctx context.Context, height abi.ChainEpoch) (*types.TipSet, types.BigInt, error)
- func (cs *ChainStore) GetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)
- func (cs *ChainStore) GetCMessage(ctx context.Context, c cid.Cid) (types.ChainMsg, error)
- func (cs *ChainStore) GetCheckpoint() *types.TipSet
- func (cs *ChainStore) GetGenesis(ctx context.Context) (*types.BlockHeader, error)
- func (cs *ChainStore) GetHeaviestTipSet() (ts *types.TipSet)
- func (cs *ChainStore) GetLatestBeaconEntry(ctx context.Context, ts *types.TipSet) (*types.BeaconEntry, error)
- func (cs *ChainStore) GetMessage(ctx context.Context, c cid.Cid) (*types.Message, error)
- func (cs *ChainStore) GetParentReceipt(ctx context.Context, b *types.BlockHeader, i int) (*types.MessageReceipt, error)
- func (cs *ChainStore) GetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*api.HeadChange, error)
- func (cs *ChainStore) GetSignedMessage(ctx context.Context, c cid.Cid) (*types.SignedMessage, error)
- func (cs *ChainStore) GetTipSetByCid(ctx context.Context, c cid.Cid) (*types.TipSet, error)
- func (cs *ChainStore) GetTipSetFromKey(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
- func (cs *ChainStore) GetTipsetByHeight(ctx context.Context, h abi.ChainEpoch, ts *types.TipSet, prev bool) (*types.TipSet, error)
- func (cs *ChainStore) Import(ctx context.Context, r io.Reader) (head *types.TipSet, genesis *types.BlockHeader, err error)
- func (cs *ChainStore) IsAncestorOf(ctx context.Context, a, b *types.TipSet) (bool, error)
- func (cs *ChainStore) IsBlockValidated(ctx context.Context, blkid cid.Cid) (bool, error)
- func (cs *ChainStore) IsStoringEvents() bool
- func (cs *ChainStore) Load(ctx context.Context) error
- func (cs *ChainStore) LoadMessagesFromCids(ctx context.Context, cids []cid.Cid) ([]*types.Message, error)
- func (cs *ChainStore) LoadSignedMessagesFromCids(ctx context.Context, cids []cid.Cid) ([]*types.SignedMessage, error)
- func (cs *ChainStore) LoadTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
- func (cs *ChainStore) MarkBlockAsValidated(ctx context.Context, blkid cid.Cid) error
- func (cs *ChainStore) MessagesForBlock(ctx context.Context, b *types.BlockHeader) ([]*types.Message, []*types.SignedMessage, error)
- func (cs *ChainStore) MessagesForTipset(ctx context.Context, ts *types.TipSet) ([]types.ChainMsg, error)
- func (cs *ChainStore) NearestCommonAncestor(ctx context.Context, a, b *types.TipSet) (*types.TipSet, error)
- func (cs *ChainStore) PersistTipsets(ctx context.Context, tipsets []*types.TipSet) error
- func (cs *ChainStore) PutMessage(ctx context.Context, m storable) (cid.Cid, error)
- func (cs *ChainStore) ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error)
- func (cs *ChainStore) ReadReceipts(ctx context.Context, root cid.Cid) ([]types.MessageReceipt, error)
- func (cs *ChainStore) RefreshHeaviestTipSet(ctx context.Context, newTsHeight abi.ChainEpoch) error
- func (cs *ChainStore) RemoveCheckpoint(ctx context.Context) error
- func (cs *ChainStore) ReorgOps(ctx context.Context, a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)
- func (cs *ChainStore) SecpkMessagesForBlock(ctx context.Context, b *types.BlockHeader) ([]*types.SignedMessage, error)
- func (cs *ChainStore) SetCheckpoint(ctx context.Context, ts *types.TipSet) error
- func (cs *ChainStore) SetGenesis(ctx context.Context, b *types.BlockHeader) error
- func (cs *ChainStore) SetHead(ctx context.Context, ts *types.TipSet) error
- func (cs *ChainStore) StateBlockstore() bstore.Blockstore
- func (cs *ChainStore) StoreEvents(store bool)
- func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*api.HeadChange
- func (cs *ChainStore) SubscribeHeadChanges(f ReorgNotifee)
- func (cs *ChainStore) TryFillTipSet(ctx context.Context, ts *types.TipSet) (*FullTipSet, error)
- func (cs *ChainStore) UnionStore() bstore.Blockstore
- func (cs *ChainStore) UnmarkBlockAsValidated(ctx context.Context, blkid cid.Cid) error
- func (cs *ChainStore) WalkSnapshot(ctx context.Context, ts *types.TipSet, inclRecentRoots abi.ChainEpoch, ...) error
- func (cs *ChainStore) Weight(ctx context.Context, hts *types.TipSet) (types.BigInt, error)
- type FullTipSet
- type HeadChangeCoalescer
- type HeadChangeEvt
- type ReorgNotifee
- type WeightFunc
Constants ¶
const ( HCRevert = "revert" HCApply = "apply" HCCurrent = "current" )
const TipsetkeyBackfillRange = 2 * build.Finality
Variables ¶
var DefaultChainIndexCacheSize = 1 << 15
DefaultChainIndexCacheSize no longer sets the maximum size, just the initial size of the map.
var DefaultMsgMetaCacheSize = 2048
var DefaultTipSetCacheSize = 8192
var ErrNotifeeDone = errors.New("notifee is done and should be removed")
Functions ¶
func ActorStore ¶ added in v0.3.0
func ComputeNextBaseFee ¶ added in v0.7.0
func FlushValidationCache ¶ added in v1.4.1
func PutMessage ¶
func PutMessage(ctx context.Context, bs bstore.Blockstore, m storable) (cid.Cid, error)
Types ¶
type BlockMessages ¶ added in v0.5.0
type ChainIndex ¶ added in v0.4.0
type ChainIndex struct {
// contains filtered or unexported fields
}
func NewChainIndex ¶ added in v0.4.0
func NewChainIndex(lts loadTipSetFunc) *ChainIndex
func (*ChainIndex) GetTipsetByHeight ¶ added in v0.4.0
func (ci *ChainIndex) GetTipsetByHeight(ctx context.Context, from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error)
func (*ChainIndex) GetTipsetByHeightWithoutCache ¶ added in v0.4.0
func (ci *ChainIndex) GetTipsetByHeightWithoutCache(ctx context.Context, from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error)
type ChainStore ¶
type ChainStore struct {
// contains filtered or unexported fields
}
ChainStore is the main point of access to chain data.
Raw chain data is stored in the Blockstore, with relevant markers (genesis, latest head tipset references) being tracked in the Datastore (key-value store).
To alleviate disk access, the ChainStore has two ARC caches:
- a tipset cache
- a block => messages references cache.
func NewChainStore ¶
func NewChainStore(chainBs bstore.Blockstore, stateBs bstore.Blockstore, ds dstore.Batching, weight WeightFunc, j journal.Journal) *ChainStore
func (*ChainStore) ActorStore ¶ added in v1.5.1
func (cs *ChainStore) ActorStore(ctx context.Context) adt.Store
func (*ChainStore) AddToTipSetTracker ¶
func (cs *ChainStore) AddToTipSetTracker(ctx context.Context, b *types.BlockHeader) error
func (*ChainStore) BlockMsgsForTipset ¶ added in v0.5.0
func (cs *ChainStore) BlockMsgsForTipset(ctx context.Context, ts *types.TipSet) ([]BlockMessages, error)
func (*ChainStore) ChainBlockstore ¶ added in v1.5.1
func (cs *ChainStore) ChainBlockstore() bstore.Blockstore
ChainBlockstore returns the chain blockstore. Currently the chain and state // stores are both backed by the same physical store, albeit with different // caching policies, but in the future they will segregate.
func (*ChainStore) ChainLocalBlockstore ¶ added in v1.20.0
func (cs *ChainStore) ChainLocalBlockstore() bstore.Blockstore
func (*ChainStore) Close ¶ added in v1.2.0
func (cs *ChainStore) Close() error
func (*ChainStore) ComputeBaseFee ¶ added in v0.5.0
func (cs *ChainStore) ComputeBaseFee(ctx context.Context, ts *types.TipSet) (abi.TokenAmount, error)
func (*ChainStore) Contains ¶
Contains returns whether our BlockStore has all blocks in the supplied TipSet.
func (*ChainStore) ExportRange ¶ added in v1.23.0
func (*ChainStore) FlushValidationCache ¶ added in v0.10.0
func (cs *ChainStore) FlushValidationCache(ctx context.Context) error
FlushValidationCache removes all results of block validation from the chain metadata store. Usually the first step after a new chain import.
func (*ChainStore) ForceHeadSilent ¶ added in v1.1.3
ForceHeadSilent forces a chain head tipset without triggering a reorg operation.
CAUTION: Use it only for testing, such as to teleport the chain to a particular tipset to carry out a benchmark, verification, etc. on a chain segment.
func (*ChainStore) FormHeaviestTipSetForHeight ¶ added in v1.25.0
func (cs *ChainStore) FormHeaviestTipSetForHeight(ctx context.Context, height abi.ChainEpoch) (*types.TipSet, types.BigInt, error)
FormHeaviestTipSetForHeight looks up all valid blocks at a given height, and returns the heaviest tipset that can be made at that height It does not consider ANY blocks from miners that have "equivocated" (produced 2 blocks at the same height)
func (*ChainStore) GetBlock ¶
func (cs *ChainStore) GetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)
GetBlock fetches a BlockHeader with the supplied CID. It returns blockstore.ErrNotFound if the block was not found in the BlockStore.
func (*ChainStore) GetCMessage ¶
func (*ChainStore) GetCheckpoint ¶ added in v1.11.0
func (cs *ChainStore) GetCheckpoint() *types.TipSet
func (*ChainStore) GetGenesis ¶
func (cs *ChainStore) GetGenesis(ctx context.Context) (*types.BlockHeader, error)
func (*ChainStore) GetHeaviestTipSet ¶
func (cs *ChainStore) GetHeaviestTipSet() (ts *types.TipSet)
GetHeaviestTipSet returns the current heaviest tipset known (i.e. our head).
func (*ChainStore) GetLatestBeaconEntry ¶ added in v0.3.0
func (cs *ChainStore) GetLatestBeaconEntry(ctx context.Context, ts *types.TipSet) (*types.BeaconEntry, error)
func (*ChainStore) GetMessage ¶
func (*ChainStore) GetParentReceipt ¶
func (cs *ChainStore) GetParentReceipt(ctx context.Context, b *types.BlockHeader, i int) (*types.MessageReceipt, error)
func (*ChainStore) GetPath ¶ added in v0.2.5
func (cs *ChainStore) GetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*api.HeadChange, error)
GetPath returns the sequence of atomic head change operations that need to be applied in order to switch the head of the chain from the `from` tipset to the `to` tipset.
func (*ChainStore) GetSignedMessage ¶
func (cs *ChainStore) GetSignedMessage(ctx context.Context, c cid.Cid) (*types.SignedMessage, error)
func (*ChainStore) GetTipSetByCid ¶ added in v1.20.0
func (*ChainStore) GetTipSetFromKey ¶ added in v0.2.8
func (*ChainStore) GetTipsetByHeight ¶
func (cs *ChainStore) GetTipsetByHeight(ctx context.Context, h abi.ChainEpoch, ts *types.TipSet, prev bool) (*types.TipSet, error)
GetTipsetByHeight returns the tipset on the chain behind 'ts' at the given height. In the case that the given height is a null round, the 'prev' flag selects the tipset before the null round if true, and the tipset following the null round if false.
func (*ChainStore) Import ¶ added in v0.2.6
func (cs *ChainStore) Import(ctx context.Context, r io.Reader) (head *types.TipSet, genesis *types.BlockHeader, err error)
func (*ChainStore) IsAncestorOf ¶
IsAncestorOf returns true if 'a' is an ancestor of 'b'
func (*ChainStore) IsBlockValidated ¶ added in v0.4.0
func (cs *ChainStore) IsBlockValidated(ctx context.Context, blkid cid.Cid) (bool, error)
func (*ChainStore) IsStoringEvents ¶ added in v1.20.0
func (cs *ChainStore) IsStoringEvents() bool
IsStoringEvents indicates if this ChainStore is storing events.
func (*ChainStore) LoadMessagesFromCids ¶
func (*ChainStore) LoadSignedMessagesFromCids ¶
func (cs *ChainStore) LoadSignedMessagesFromCids(ctx context.Context, cids []cid.Cid) ([]*types.SignedMessage, error)
func (*ChainStore) LoadTipSet ¶
func (*ChainStore) MarkBlockAsValidated ¶ added in v0.4.0
func (cs *ChainStore) MarkBlockAsValidated(ctx context.Context, blkid cid.Cid) error
func (*ChainStore) MessagesForBlock ¶
func (cs *ChainStore) MessagesForBlock(ctx context.Context, b *types.BlockHeader) ([]*types.Message, []*types.SignedMessage, error)
func (*ChainStore) MessagesForTipset ¶
func (*ChainStore) NearestCommonAncestor ¶
func (*ChainStore) PersistTipsets ¶ added in v1.23.1
PersistTipsets writes the provided blocks and the TipSetKey objects to the blockstore
func (*ChainStore) PutMessage ¶
func (cs *ChainStore) PutMessage(ctx context.Context, m storable) (cid.Cid, error)
func (*ChainStore) ReadMsgMetaCids ¶ added in v0.5.8
func (cs *ChainStore) ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error)
func (*ChainStore) ReadReceipts ¶ added in v1.23.0
func (cs *ChainStore) ReadReceipts(ctx context.Context, root cid.Cid) ([]types.MessageReceipt, error)
func (*ChainStore) RefreshHeaviestTipSet ¶ added in v1.25.0
func (cs *ChainStore) RefreshHeaviestTipSet(ctx context.Context, newTsHeight abi.ChainEpoch) error
RefreshHeaviestTipSet receives a newTsHeight at which a new tipset might exist. It then: - "refreshes" the heaviest tipset that can be formed at its current heaviest height
- if equivocation is detected among the miners of the current heaviest tipset, the head is immediately updated to the heaviest tipset that can be formed in a range of 5 epochs
- forms the best tipset that can be formed at the _input_ height - compares the three tipset weights: "current" heaviest tipset, "refreshed" tipset, and best tipset at newTsHeight - updates "current" heaviest to the heaviest of those 3 tipsets (if an update is needed), assuming it doesn't violate the maximum fork rule
func (*ChainStore) RemoveCheckpoint ¶ added in v1.11.0
func (cs *ChainStore) RemoveCheckpoint(ctx context.Context) error
RemoveCheckpoint removes the current checkpoint.
func (*ChainStore) ReorgOps ¶
func (cs *ChainStore) ReorgOps(ctx context.Context, a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)
ReorgOps takes two tipsets (which can be at different heights), and walks their corresponding chains backwards one step at a time until we find a common ancestor. It then returns the respective chain segments that fork from the identified ancestor, in reverse order, where the first element of each slice is the supplied tipset, and the last element is the common ancestor.
If an error happens along the way, we return the error with nil slices.
func (*ChainStore) SecpkMessagesForBlock ¶ added in v1.20.0
func (cs *ChainStore) SecpkMessagesForBlock(ctx context.Context, b *types.BlockHeader) ([]*types.SignedMessage, error)
func (*ChainStore) SetCheckpoint ¶ added in v1.11.0
SetCheckpoint will set a checkpoint past which the chainstore will not allow forks.
NOTE: Checkpoints cannot be set beyond ForkLengthThreshold epochs in the past.
func (*ChainStore) SetGenesis ¶
func (cs *ChainStore) SetGenesis(ctx context.Context, b *types.BlockHeader) error
func (*ChainStore) SetHead ¶
SetHead sets the chainstores current 'best' head node. This should only be called if something is broken and needs fixing.
This function will bypass and remove any checkpoints.
func (*ChainStore) StateBlockstore ¶ added in v1.5.1
func (cs *ChainStore) StateBlockstore() bstore.Blockstore
StateBlockstore returns the state blockstore. Currently the chain and state stores are both backed by the same physical store, albeit with different caching policies, but in the future they will segregate.
func (*ChainStore) StoreEvents ¶ added in v1.20.0
func (cs *ChainStore) StoreEvents(store bool)
StoreEvents marks this ChainStore as storing events.
func (*ChainStore) SubHeadChanges ¶
func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*api.HeadChange
func (*ChainStore) SubscribeHeadChanges ¶
func (cs *ChainStore) SubscribeHeadChanges(f ReorgNotifee)
func (*ChainStore) TryFillTipSet ¶
func (cs *ChainStore) TryFillTipSet(ctx context.Context, ts *types.TipSet) (*FullTipSet, error)
func (*ChainStore) UnionStore ¶ added in v1.15.1
func (cs *ChainStore) UnionStore() bstore.Blockstore
func (*ChainStore) UnmarkBlockAsValidated ¶ added in v0.8.1
func (cs *ChainStore) UnmarkBlockAsValidated(ctx context.Context, blkid cid.Cid) error
func (*ChainStore) WalkSnapshot ¶ added in v0.9.0
func (cs *ChainStore) WalkSnapshot(ctx context.Context, ts *types.TipSet, inclRecentRoots abi.ChainEpoch, skipOldMsgs, skipMsgReceipts bool, cb func(cid.Cid) error) error
type FullTipSet ¶
FullTipSet is an expanded version of the TipSet that contains all the blocks and messages
func NewFullTipSet ¶
func NewFullTipSet(blks []*types.FullBlock) *FullTipSet
func (*FullTipSet) Cids ¶
func (fts *FullTipSet) Cids() []cid.Cid
func (*FullTipSet) TipSet ¶
func (fts *FullTipSet) TipSet() *types.TipSet
TipSet returns a narrower view of this FullTipSet elliding the block messages.
type HeadChangeCoalescer ¶ added in v1.1.3
type HeadChangeCoalescer struct {
// contains filtered or unexported fields
}
HeadChangeCoalescer is a stateful reorg notifee which coalesces incoming head changes with pending head changes to reduce state computations from head change notifications.
func NewHeadChangeCoalescer ¶ added in v1.1.3
func NewHeadChangeCoalescer(fn ReorgNotifee, minDelay, maxDelay, mergeInterval time.Duration) *HeadChangeCoalescer
NewHeadChangeCoalescer creates a HeadChangeCoalescer.
func (*HeadChangeCoalescer) Close ¶ added in v1.1.3
func (c *HeadChangeCoalescer) Close() error
Close closes the coalescer and cancels the background dispatch goroutine. Any further notification will result in an error.
func (*HeadChangeCoalescer) HeadChange ¶ added in v1.1.3
func (c *HeadChangeCoalescer) HeadChange(revert, apply []*types.TipSet) error
HeadChange is the ReorgNotifee callback for the stateful coalescer; it receives an incoming head change and schedules dispatch of a coalesced head change in the background.
type HeadChangeEvt ¶ added in v0.7.1
type HeadChangeEvt struct { From types.TipSetKey FromHeight abi.ChainEpoch To types.TipSetKey ToHeight abi.ChainEpoch RevertCount int ApplyCount int }
type ReorgNotifee ¶ added in v0.4.0
ReorgNotifee represents a callback that gets called upon reorgs.
func WrapHeadChangeCoalescer ¶ added in v1.1.3
func WrapHeadChangeCoalescer(fn ReorgNotifee, minDelay, maxDelay, mergeInterval time.Duration) ReorgNotifee
WrapHeadChangeCoalescer wraps a ReorgNotifee with a head change coalescer. minDelay is the minimum coalesce delay; when a head change is first received, the coalescer will
wait for that long to coalesce more head changes.
maxDelay is the maximum coalesce delay; the coalescer will not delay delivery of a head change
more than that.
mergeInterval is the interval that triggers additional coalesce delay; if the last head change was
within the merge interval when the coalesce timer fires, then the coalesce time is extended by min delay and up to max delay total.