chain

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: 75 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckPoint = datastore.NewKey("/chain/checkPoint")

CheckPoint is the key which the check-point written in the datastore.

View Source
var DefaultChainIndexCacheSize = 1 << 15

DefaultChainIndexCacheSize no longer sets the maximum size, just the initial size of the map.

View Source
var DefaultTipsetLruCacheSize = 10000
View Source
var DrawRandomnessFromDigest = vm.DrawRandomnessFromDigest
View Source
var ErrNoCommonAncestor = errors.New("no common ancestor")

ErrNoCommonAncestor is returned when two chains assumed to have a common ancestor do not.

View Source
var ErrNotFound = errors.New("Key not found in tipindex")

ErrNotFound is returned when the key for a "Get" lookup is not in the index.

View Source
var ErrNotifeeDone = errors.New("notifee is done and should be removed")
View Source
var GenesisKey = datastore.NewKey("/consensus/genesisCid")

GenesisKey is the key at which the genesis Cid is written in the datastore.

View Source
var HeadKey = datastore.NewKey("/chain/heaviestTipSet")

HeadKey is the key at which the head tipset cid's are written in the datastore.

Functions

func AuthenticateMessage added in v1.10.0

func AuthenticateMessage(msg *types.SignedMessage, signer address.Address) error

AuthenticateMessage authenticates the message by verifying that the supplied SignedMessage was signed by the indicated Address, computing the correct signature payload depending on the signature type. The supplied Address type must be recognized by the registered verifier for the signature type.

func BlendEntropy

func BlendEntropy(tag crypto.DomainSeparationTag, seed RandomSeed, epoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)

BlendEntropy get randomness with chain value. sha256(buf(tag, seed, epoch, entropy))

func CollectTipSetsOfHeightAtLeast

func CollectTipSetsOfHeightAtLeast(ctx context.Context, iterator *TipsetIterator, minHeight abi.ChainEpoch) ([]*types.TipSet, error)

CollectTipSetsOfHeightAtLeast collects all tipsets with a height greater than or equal to minHeight from the input tipset.

func CollectTipsToCommonAncestor

func CollectTipsToCommonAncestor(ctx context.Context, store TipSetProvider, oldHead, newHead *types.TipSet) (oldTips, newTips []*types.TipSet, err error)

CollectTipsToCommonAncestor traverses chains from two tipsets (called old and new) until their common ancestor, collecting all tipsets that are in one chain but not the other. The resulting lists of tipsets are ordered by decreasing height.

func ComputeMsgMeta

func ComputeMsgMeta(bs blockstore.Blockstore, bmsgCids, smsgCids []cid.Cid) (cid.Cid, error)

computeMsgMeta computes the root CID of the combined arrays of message CIDs of both types (BLS and Secpk).

func ComputeNextBaseFee

func ComputeNextBaseFee(baseFee abi.TokenAmount, gasLimitUsed int64, noOfBlocks int, epoch abi.ChainEpoch, upgrade *config.ForkUpgradeConfig) abi.TokenAmount

todo move to a more suitable position

func DrawRandomnessFromBase added in v1.14.0

func DrawRandomnessFromBase(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

func FindCommonAncestor

func FindCommonAncestor(ctx context.Context, leftIter, rightIter *TipsetIterator) (*types.TipSet, error)

FindCommonAncestor returns the common ancestor of the two tipsets pointed to by the input iterators. If they share no common ancestor ErrNoCommonAncestor will be returned.

func FindLatestDRAND

func FindLatestDRAND(ctx context.Context, start *types.TipSet, reader TipSetProvider) (*types.BeaconEntry, error)

FindLatestDRAND returns the latest DRAND entry in the chain beginning at start

func GenesisBlock added in v1.11.0

func GenesisBlock(ctx context.Context, chainDs datastore.Datastore, bs blockstoreutil.Blockstore) (types.BlockHeader, error)

func GetChainMsgRoot

func GetChainMsgRoot(ctx context.Context, messages []types.ChainMsg) (cid.Cid, error)

func GetFilBurnt

func GetFilBurnt(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)

GetFilBurnt query burnt contract to get amount of burnt fil

func GetFilMined

func GetFilMined(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)

GetFilMined query reward contract to get amount of mined fil

func GetReceiptRoot

func GetReceiptRoot(receipts []types.MessageReceipt) (cid.Cid, error)

func IsReorg

func IsReorg(old, new, commonAncestor *types.TipSet) bool

IsReorg determines if choosing the end of the newChain as the new head would cause a "reorg" given the current head is at curHead. A reorg occurs when the old head is not a member of the new chain AND the old head is not a subset of the new head.

func IsValidSecpkSigType added in v1.10.0

func IsValidSecpkSigType(nv network.Version, typ crypto.SigType) bool

IsValidSecpkSigType checks that a signature type is valid for the network version, for a "secpk" message.

func LoadTipSetBlocks

func LoadTipSetBlocks(ctx context.Context, store BlockProvider, key types.TipSetKey) (*types.TipSet, error)

LoadTipSetBlocks loads all the blocks for a tipset from the store.

func MakeBlock

func MakeBlock(obj cbor2.Marshaler) (blocks.Block, error)

func PutMessage

func PutMessage(ctx context.Context, bs blockstoreutil.Blockstore, m storable) (cid.Cid, error)

func ReorgDiff

func ReorgDiff(old, new, commonAncestor *types.TipSet) (abi.ChainEpoch, abi.ChainEpoch, error)

ReorgDiff returns the dropped and added block heights resulting from the reorg given the old and new heads and their common ancestor.

func ReorgOps

func ReorgOps(ctx context.Context,
	lts func(ctx context.Context, _ types.TipSetKey) (*types.TipSet, error),
	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. todo should move this code into store.ReorgOps. anywhere use this function should invoke store.ReorgOps

func Reverse

func Reverse(chain []*types.TipSet)

Reverse reverses the order of the slice `chain`.

Types

type BlockBuilder

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

BlockBuilder mutates blocks as they are generated.

func (*BlockBuilder) AddMessages

func (bb *BlockBuilder) AddMessages(secpmsgs []*types.SignedMessage, blsMsgs []*types.Message)

AddMessages adds a message & receipt collection to the block.

func (*BlockBuilder) IncHeight

func (bb *BlockBuilder) IncHeight(nullBlocks abi.ChainEpoch)

IncHeight increments the block's height, implying a number of null blocks before this one is mined.

func (*BlockBuilder) SetBlockSig

func (bb *BlockBuilder) SetBlockSig(signature crypto.Signature)

SetBlockSig set a new signature

func (*BlockBuilder) SetStateRoot

func (bb *BlockBuilder) SetStateRoot(root cid.Cid)

SetStateRoot sets the block's state root.

func (*BlockBuilder) SetTicket

func (bb *BlockBuilder) SetTicket(raw []byte)

SetTicket sets the block's ticket.

func (*BlockBuilder) SetTimestamp

func (bb *BlockBuilder) SetTimestamp(timestamp uint64)

SetTimestamp sets the block's timestamp.

type BlockProvider

type BlockProvider interface {
	GetBlock(ctx context.Context, cid cid.Cid) (*types.BlockHeader, error)
}

BlockProvider provides blocks.

type Builder

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

Builder builds fake chains and acts as a provider and fetcher for the chain thus generated. All blocks are unique (even if they share parents) and form valid chains of parents and heights, but do not carry valid tickets. Each block contributes a weight of 1. state root CIDs are computed by an abstract StateBuilder. The default FakeStateBuilder produces state CIDs that are distinct but not CIDs of any real state tree. A more sophisticated builder could actually apply the messages to a state tree (not yet implemented). The builder is deterministic: two builders receiving the same sequence of calls will produce exactly the same chain.

func NewBuilder

func NewBuilder(t *testing.T, miner address.Address) *Builder

NewBuilder builds a new chain faker with default fake state building.

func NewBuilderWithDeps

func NewBuilderWithDeps(t *testing.T, miner address.Address, stamper TimeStamper) *Builder

NewBuilderWithDeps builds a new chain faker. Blocks will have `miner` set as the miner address, or a default if empty.

func (*Builder) AddPeer

func (f *Builder) AddPeer(peer peer.ID)

func (*Builder) AppendBlockOn

func (f *Builder) AppendBlockOn(ctx context.Context, parent *types.TipSet) *types.BlockHeader

AppendBlockOn creates and returns a new block child of `parent`, with no messages.

func (*Builder) AppendBlockOnBlocks

func (f *Builder) AppendBlockOnBlocks(ctx context.Context, parents ...*types.BlockHeader) *types.BlockHeader

AppendBlockOnBlocks creates and returns a new block child of `parents`, with no messages.

func (*Builder) AppendManyBlocksOn

func (f *Builder) AppendManyBlocksOn(ctx context.Context, height int, parent *types.TipSet) *types.BlockHeader

AppendManyBlocksOn appends `height` blocks to the chain.

func (*Builder) AppendManyBlocksOnBlocks

func (f *Builder) AppendManyBlocksOnBlocks(ctx context.Context, height int, parents ...*types.BlockHeader) *types.BlockHeader

AppendManyBlocksOnBlocks appends `height` blocks to the chain.

func (*Builder) AppendManyOn

func (f *Builder) AppendManyOn(ctx context.Context, height int, parent *types.TipSet) *types.TipSet

AppendManyOn appends `height` tipsets to the chain.

func (*Builder) AppendOn

func (f *Builder) AppendOn(ctx context.Context, parent *types.TipSet, width int) *types.TipSet

AppendOn creates and returns a new `width`-block tipset child of `parents`, with no messages.

func (*Builder) BlockStore

func (f *Builder) BlockStore() blockstoreutil.Blockstore

func (*Builder) Build

func (f *Builder) Build(ctx context.Context, parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet

Build creates and returns a new tipset child of `parent`. The tipset carries `width` > 0 blocks with the same height and parents, but different tickets. Note: the blocks will all have the same miner, which is unrealistic and forbidden by consensus; generalise this to random miner addresses when that is rejected by the syncer. The `build` function is invoked to modify the block before it is stored.

func (*Builder) BuildManyOn

func (f *Builder) BuildManyOn(ctx context.Context, height int, parent *types.TipSet, build func(b *BlockBuilder)) *types.TipSet

BuildManyOn builds a chain by invoking Build `height` times.

func (*Builder) BuildOn

func (f *Builder) BuildOn(ctx context.Context, parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet

BuildOn creates and returns a new `width` block tipset child of `parent`.

func (*Builder) BuildOnBlock

func (f *Builder) BuildOnBlock(ctx context.Context, parent *types.BlockHeader, build func(b *BlockBuilder)) *types.BlockHeader

BuildOnBlock creates and returns a new block child of singleton tipset `parent`. See Build.

func (*Builder) BuildOneOn

func (f *Builder) BuildOneOn(ctx context.Context, parent *types.TipSet, build func(b *BlockBuilder)) *types.TipSet

BuildOneOn creates and returns a new single-block tipset child of `parent`.

func (*Builder) BuildOrphaTipset

func (f *Builder) BuildOrphaTipset(parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet

func (*Builder) ComputeState

func (f *Builder) ComputeState(ctx context.Context, tip *types.TipSet) (cid.Cid, []types.MessageReceipt)

ComputeState computes the state for a tipset from its parent state.

func (*Builder) Cstore

func (f *Builder) Cstore() cbor.IpldStore

func (*Builder) FakeStateEvaluator added in v1.2.0

func (f *Builder) FakeStateEvaluator() *FakeStateEvaluator

func (*Builder) FetchTipSetHeaders

func (f *Builder) FetchTipSetHeaders(ctx context.Context, key types.TipSetKey, from peer.ID, done func(t *types.TipSet) (bool, error)) ([]*types.TipSet, error)

FetchTipSetHeaders fetchs the tipset at `tsKey` from the fetchers blockStore backed by the Builder.

func (*Builder) FetchTipSets

func (f *Builder) FetchTipSets(ctx context.Context, key types.TipSetKey, from peer.ID, done func(t *types.TipSet) (bool, error)) ([]*types.TipSet, error)

FetchTipSets fetchs the tipset at `tsKey` from the fetchers blockStore backed by the Builder.

func (*Builder) FlushHead added in v1.2.0

func (f *Builder) FlushHead(ctx context.Context) error

func (*Builder) GenMiners added in v1.15.0

func (f *Builder) GenMiners(str string) []address.Address

func (*Builder) GeneratorGenesis added in v0.9.7

func (f *Builder) GeneratorGenesis() *types.TipSet

func (*Builder) Genesis

func (f *Builder) Genesis() *types.TipSet

func (*Builder) GetBlock

func (f *Builder) GetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)

GetBlock returns the block identified by `c`.

func (*Builder) GetBlocks

func (f *Builder) GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error)

/// exchange /////

func (*Builder) GetBlocksByIds

func (f *Builder) GetBlocksByIds(ctx context.Context, cids []cid.Cid) ([]*types.BlockHeader, error)

GetBlocks returns the blocks identified by `cids`.

func (*Builder) GetBlockstoreValue

func (f *Builder) GetBlockstoreValue(ctx context.Context, c cid.Cid) (blocks.Block, error)

GetBlockstoreValue gets data straight out of the underlying blockstore by cid

func (*Builder) GetChainMessages

func (f *Builder) GetChainMessages(ctx context.Context, tipsets []*types.TipSet) ([]*exchange.CompactedMessages, error)

func (*Builder) GetFullTipSet

func (f *Builder) GetFullTipSet(ctx context.Context, peer []peer.ID, tsk types.TipSetKey) (*types.FullTipSet, error)

func (*Builder) GetTipSet

func (f *Builder) GetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error)

GetTipSet returns the tipset identified by `key`.

func (*Builder) GetTipSetByHeight

func (f *Builder) GetTipSetByHeight(ctx context.Context, ts *types.TipSet, h abi.ChainEpoch, prev bool) (*types.TipSet, error)

func (*Builder) GetTipSetStateRoot

func (f *Builder) GetTipSetStateRoot(key types.TipSetKey) (cid.Cid, error)

GetTipSetStateRoot returns the state root that was computed for a tipset.

func (*Builder) IStmgr added in v1.2.0

func (f *Builder) IStmgr() IStmgr

func (*Builder) LoadMetaMessages

func (f *Builder) LoadMetaMessages(ctx context.Context, metaCid cid.Cid) ([]*types.SignedMessage, []*types.Message, error)

LoadMessages returns the message collections tracked by the builder.

func (*Builder) LoadReceipts

func (f *Builder) LoadReceipts(ctx context.Context, c cid.Cid) ([]types.MessageReceipt, error)

LoadReceipts returns the message collections tracked by the builder.

func (*Builder) LoadSignedMessagesFromCids

func (f *Builder) LoadSignedMessagesFromCids(ctx context.Context, secpCids []cid.Cid) ([]*types.SignedMessage, error)

func (*Builder) LoadTipSetMessage

func (f *Builder) LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error)

func (*Builder) LoadTxMeta

func (f *Builder) LoadTxMeta(ctx context.Context, metaCid cid.Cid) (types.MessageRoot, error)

LoadTxMeta returns the tx meta wrapper tracked by the builder.

func (*Builder) LoadUnsignedMessagesFromCids

func (f *Builder) LoadUnsignedMessagesFromCids(ctx context.Context, blsCids []cid.Cid) ([]*types.Message, error)

func (*Builder) MessageStore added in v1.10.0

func (f *Builder) MessageStore() *MessageStore

func (*Builder) Mstore

func (f *Builder) Mstore() *MessageStore

func (*Builder) ReadMsgMetaCids

func (f *Builder) ReadMsgMetaCids(ctx context.Context, metaCid cid.Cid) ([]cid.Cid, []cid.Cid, error)

func (*Builder) RemovePeer

func (f *Builder) RemovePeer(peer peer.ID)

func (*Builder) Repo

func (f *Builder) Repo() repo.Repo

func (*Builder) RequireTipSet

func (f *Builder) RequireTipSet(ctx context.Context, key types.TipSetKey) *types.TipSet

RequireTipSet returns a tipset by key, which must exist.

func (*Builder) RequireTipSets

func (f *Builder) RequireTipSets(ctx context.Context, head types.TipSetKey, count int) []*types.TipSet

RequireTipSets returns a chain of tipsets from key, which must exist and be long enough.

func (*Builder) ResetMiners added in v1.15.0

func (f *Builder) ResetMiners()

func (*Builder) StateForKey

func (f *Builder) StateForKey(ctx context.Context, key types.TipSetKey) cid.Cid

StateForKey loads (or computes) the state root for a tipset key.

func (*Builder) Store

func (f *Builder) Store() *Store

func (*Builder) StoreReceipts

func (f *Builder) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error)

StoreReceipts stores message receipts and returns a commitment.

func (*Builder) StoreTxMeta

func (f *Builder) StoreTxMeta(ctx context.Context, meta types.MessageRoot) (cid.Cid, error)

StoreTxMeta stores a tx meta

type ChainIndex

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

ChainIndex tipset height index, used to getting tipset by height quickly

func NewChainIndex

func NewChainIndex(lts loadTipSetFunc) *ChainIndex

NewChainIndex return a new chain index with arc cache

func (*ChainIndex) GetTipSetByHeight

func (ci *ChainIndex) GetTipSetByHeight(ctx context.Context, from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error)

GetTipSetByHeight get tipset at specify height from specify tipset the tipset within the skiplength is directly obtained by reading the database. if the height difference exceeds the skiplength, the tipset is read from caching. if the caching fails, the tipset is obtained by reading the database and updating the cache

func (*ChainIndex) GetTipsetByHeightWithoutCache

func (ci *ChainIndex) GetTipsetByHeightWithoutCache(ctx context.Context, from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error)

GetTipsetByHeightWithoutCache get the tipset of specific height by reading the database directly

type ChainRandomnessSource

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

A randomness source that seeds computations with a sample drawn from a chain epoch.

func (*ChainRandomnessSource) GetBeaconRandomness added in v1.14.0

func (c *ChainRandomnessSource) GetBeaconRandomness(ctx context.Context, randEpoch abi.ChainEpoch) ([32]byte, error)

func (*ChainRandomnessSource) GetBeaconRandomnessTipset added in v1.1.0

func (c *ChainRandomnessSource) GetBeaconRandomnessTipset(ctx context.Context, randEpoch abi.ChainEpoch, lookback bool) (*types.TipSet, error)

func (*ChainRandomnessSource) GetBeaconRandomnessV1 added in v1.1.0

func (c *ChainRandomnessSource) GetBeaconRandomnessV1(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)

network v0-12

func (*ChainRandomnessSource) GetBeaconRandomnessV2 added in v1.1.0

func (c *ChainRandomnessSource) GetBeaconRandomnessV2(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)

network v13

func (*ChainRandomnessSource) GetBeaconRandomnessV3 added in v1.1.0

func (c *ChainRandomnessSource) GetBeaconRandomnessV3(ctx context.Context, filecoinEpoch abi.ChainEpoch) ([32]byte, error)

network v14 and on

func (*ChainRandomnessSource) GetChainRandomness added in v1.1.0

func (c *ChainRandomnessSource) GetChainRandomness(ctx context.Context, filecoinEpoch abi.ChainEpoch) ([32]byte, error)

func (*ChainRandomnessSource) GetChainRandomnessV1 added in v1.1.0

func (c *ChainRandomnessSource) GetChainRandomnessV1(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)

network v0-12

func (*ChainRandomnessSource) GetChainRandomnessV2 added in v1.1.0

func (c *ChainRandomnessSource) GetChainRandomnessV2(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)

network v13 and on

type CirculatingSupplyCalculator

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

CirculatingSupplyCalculator used to calculate the funds at a specific block height

func NewCirculatingSupplyCalculator

func NewCirculatingSupplyCalculator(bstore blockstoreutil.Blockstore, genesisRoot cid.Cid, upgradeConfig *config.ForkUpgradeConfig) *CirculatingSupplyCalculator

NewCirculatingSupplyCalculator create new circulating supply calculator

func (*CirculatingSupplyCalculator) GetCirculatingSupplyDetailed

func (caculator *CirculatingSupplyCalculator) GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (types.CirculatingSupply, error)

GetCirculatingSupplyDetailed query contract and calculate circulation status at specific height and tree state

func (*CirculatingSupplyCalculator) GetFilLocked

func (caculator *CirculatingSupplyCalculator) GetFilLocked(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)

GetFilLocked query the market contract and power contract to get the amount of locked fils

func (*CirculatingSupplyCalculator) GetFilReserveDisbursed

func (caculator *CirculatingSupplyCalculator) GetFilReserveDisbursed(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)

func (*CirculatingSupplyCalculator) GetFilVested

func (caculator *CirculatingSupplyCalculator) GetFilVested(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error)

GetVestedFunds returns all funds that have "left" actors that are in the genesis state: - For Multisigs, it counts the actual amounts that have vested at the given epoch - For Accounts, it counts max(currentBalance - genesisBalance, 0).

type ClockTimestamper

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

ClockTimestamper writes timestamps based on a blocktime and genesis time

func NewClockTimestamper

func NewClockTimestamper(chainClock clock.ChainEpochClock) *ClockTimestamper

NewClockTimestamper makes a new stamper for creating production valid timestamps

func (*ClockTimestamper) Stamp

func (ct *ClockTimestamper) Stamp(height abi.ChainEpoch) uint64

Stamp assigns a valid timestamp given genesis time and block time to a block of the provided height.

type FakeChainSelector

type FakeChainSelector struct {
	FakeStateBuilder
}

FakeChainSelector is a syncChainSelector that delegates to the FakeStateBuilder

func (*FakeChainSelector) IsHeavier

func (e *FakeChainSelector) IsHeavier(ctx context.Context, a, b *types.TipSet) (bool, error)

IsHeavier compares chains weighed with StateBuilder.Weigh.

func (*FakeChainSelector) Weight

func (e *FakeChainSelector) Weight(ctx context.Context, ts *types.TipSet) (big.Int, error)

Weight delegates to the statebuilder

type FakeStateBuilder

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

FakeStateBuilder computes a fake state CID by hashing the CIDs of a block's parents and messages.

func (FakeStateBuilder) ComputeState

func (f FakeStateBuilder) ComputeState(prev cid.Cid, blockmsg []types.BlockMessagesInfo) (cid.Cid, []types.MessageReceipt, error)

ComputeState computes a fake state from a previous state root CID and the messages contained in list-of-lists of messages in blocks. Note that if there are no messages, the resulting state is the same as the input state. This differs from the true state transition function in that messages that are duplicated between blocks in the tipset are not ignored.

func (FakeStateBuilder) Weigh

func (f FakeStateBuilder) Weigh(ctx context.Context, tip *types.TipSet) (big.Int, error)

Weigh computes a tipset's weight as its parent weight plus one for each block in the tipset.

type FakeStateEvaluator

type FakeStateEvaluator struct {
	ChainStore   *Store
	MessageStore *MessageStore
	FakeStateBuilder
	ChsWorkingOn map[types.TipSetKey]chan struct{}
	// contains filtered or unexported fields
}

FakeStateEvaluator is a syncStateEvaluator that delegates to the FakeStateBuilder.

func (*FakeStateEvaluator) RunStateTransition

func (e *FakeStateEvaluator) RunStateTransition(ctx context.Context, ts *types.TipSet, cb vm.ExecCallBack, vmTracing bool) (rootCid cid.Cid, receiptCid cid.Cid, err error)

RunStateTransition delegates to StateBuilder.ComputeState

func (*FakeStateEvaluator) ValidateFullBlock added in v0.9.1

func (e *FakeStateEvaluator) ValidateFullBlock(ctx context.Context, blk *types.BlockHeader) error

type GenesisRandomnessSource added in v1.1.0

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

A sampler for use when computing genesis state (the state that the genesis block points to as parent state). There is no chain to sample a seed from.

func NewGenesisRandomnessSource added in v1.1.0

func NewGenesisRandomnessSource(vrf types.VRFPi) *GenesisRandomnessSource

func (*GenesisRandomnessSource) ChainGetRandomnessFromBeacon added in v1.1.0

func (g *GenesisRandomnessSource) ChainGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)

func (*GenesisRandomnessSource) ChainGetRandomnessFromTickets added in v1.1.0

func (g *GenesisRandomnessSource) ChainGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)

func (*GenesisRandomnessSource) GetBeaconRandomness added in v1.14.0

func (g *GenesisRandomnessSource) GetBeaconRandomness(ctx context.Context, randEpoch abi.ChainEpoch) ([32]byte, error)

func (*GenesisRandomnessSource) GetChainRandomness added in v1.14.0

func (g *GenesisRandomnessSource) GetChainRandomness(ctx context.Context, randEpoch abi.ChainEpoch) ([32]byte, error)

type HeadChangeCoalescer

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

func NewHeadChangeCoalescer(fn ReorgNotifee, minDelay, maxDelay, mergeInterval time.Duration) *HeadChangeCoalescer

NewHeadChangeCoalescer creates a HeadChangeCoalescer.

func (*HeadChangeCoalescer) Close

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

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 ICirculatingSupplyCalcualtor added in v1.1.0

type ICirculatingSupplyCalcualtor interface {
	GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (types.CirculatingSupply, error)
	GetFilVested(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error)
}

func NewMockCirculatingSupplyCalculator added in v1.1.0

func NewMockCirculatingSupplyCalculator() ICirculatingSupplyCalcualtor

type IStmgr added in v1.2.0

type IStmgr interface {
	GetActorAt(context.Context, address.Address, *types.TipSet) (*types.Actor, error)
	RunStateTransition(context.Context, *types.TipSet, vm.ExecCallBack, bool) (root cid.Cid, receipts cid.Cid, err error)
}

type MessageProvider

type MessageProvider interface {
	LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error)
	LoadMetaMessages(context.Context, cid.Cid) ([]*types.SignedMessage, []*types.Message, error)
	ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error)
	LoadUnsignedMessagesFromCids(ctx context.Context, blsCids []cid.Cid) ([]*types.Message, error)
	LoadSignedMessagesFromCids(ctx context.Context, secpCids []cid.Cid) ([]*types.SignedMessage, error)
	LoadReceipts(context.Context, cid.Cid) ([]types.MessageReceipt, error)
	LoadTxMeta(context.Context, cid.Cid) (types.MessageRoot, error)
}

MessageProvider is an interface exposing the load methods of the MessageStore.

type MessageStore

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

MessageStore stores and loads collections of signed messages and receipts.

func NewMessageStore

func NewMessageStore(bs blockstoreutil.Blockstore, fkCfg *config.ForkUpgradeConfig) *MessageStore

NewMessageStore creates and returns a new store

func (*MessageStore) ComputeBaseFee

func (ms *MessageStore) ComputeBaseFee(ctx context.Context, ts *types.TipSet, upgrade *config.ForkUpgradeConfig) (abi.TokenAmount, error)

todo move to a more suitable position

func (*MessageStore) LoadMessage

func (ms *MessageStore) LoadMessage(ctx context.Context, mid cid.Cid) (types.ChainMsg, error)

LoadMessage load message of specify message cid First get the unsigned message. If it is not found, then get the signed message. If still not found, an error will be returned

func (*MessageStore) LoadMetaMessages

func (ms *MessageStore) LoadMetaMessages(ctx context.Context, metaCid cid.Cid) ([]*types.SignedMessage, []*types.Message, error)

LoadMetaMessages loads the signed messages in the collection with cid c from ipld storage.

func (*MessageStore) LoadReceipts

func (ms *MessageStore) LoadReceipts(ctx context.Context, c cid.Cid) ([]types.MessageReceipt, error)

LoadReceipts loads the signed messages in the collection with cid c from ipld storage and returns the slice implied by the collection

func (*MessageStore) LoadSignedMessage

func (ms *MessageStore) LoadSignedMessage(ctx context.Context, mid cid.Cid) (*types.SignedMessage, error)

LoadSignedMessage load signed message of cid

func (*MessageStore) LoadSignedMessagesFromCids

func (ms *MessageStore) LoadSignedMessagesFromCids(ctx context.Context, secpCids []cid.Cid) ([]*types.SignedMessage, error)

LoadSignedMessagesFromCids load signed messages of cid array

func (*MessageStore) LoadTipSetMessage

func (ms *MessageStore) LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error)

LoadTipSetMessage message from tipset NOTICE skip message with the same nonce

func (*MessageStore) LoadTipSetMesssages

func (ms *MessageStore) LoadTipSetMesssages(ctx context.Context, ts *types.TipSet) ([][]*types.SignedMessage, [][]*types.Message, error)

load message from tipset NOTICE skip message with the same nonce

func (*MessageStore) LoadTxMeta

func (ms *MessageStore) LoadTxMeta(ctx context.Context, c cid.Cid) (types.MessageRoot, error)

LoadTxMeta loads the secproot, blsroot data from the message store

func (*MessageStore) LoadUnsignedMessage

func (ms *MessageStore) LoadUnsignedMessage(ctx context.Context, mid cid.Cid) (*types.Message, error)

LoadUnsignedMessage load unsigned messages in tipset

func (*MessageStore) LoadUnsignedMessagesFromCids

func (ms *MessageStore) LoadUnsignedMessagesFromCids(ctx context.Context, blsCids []cid.Cid) ([]*types.Message, error)

LoadUnsignedMessagesFromCids load unsigned messages of cid array

func (*MessageStore) MessagesForTipset

func (ms *MessageStore) MessagesForTipset(ts *types.TipSet) ([]types.ChainMsg, error)

MessagesForTipset return of message ( bls message + secp message) of tipset

func (*MessageStore) ReadMsgMetaCids

func (ms *MessageStore) ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error)

ReadMsgMetaCids load messager from message meta cid

func (*MessageStore) SecpkMessagesForBlock added in v1.10.0

func (ms *MessageStore) SecpkMessagesForBlock(ctx context.Context, b *types.BlockHeader) ([]*types.SignedMessage, error)

func (*MessageStore) StoreMessage

func (ms *MessageStore) StoreMessage(message types.ChainMsg) (cid.Cid, error)

StoreMessage put message(include signed message and unsigned message) to database

func (*MessageStore) StoreMessages

func (ms *MessageStore) StoreMessages(ctx context.Context, secpMessages []*types.SignedMessage, blsMessages []*types.Message) (cid.Cid, error)

StoreMessages puts the input signed messages to a collection and then writes this collection to ipld storage. The cid of the collection is returned.

func (*MessageStore) StoreReceipts

func (ms *MessageStore) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error)

StoreReceipts puts the input signed messages to a collection and then writes this collection to ipld storage. The cid of the collection is returned.

func (*MessageStore) StoreTxMeta

func (ms *MessageStore) StoreTxMeta(ctx context.Context, meta types.MessageRoot) (cid.Cid, error)

StoreTxMeta writes the secproot, blsroot block to the message store

type MessageWriter

type MessageWriter interface {
	StoreMessages(ctx context.Context, secpMessages []*types.SignedMessage, blsMessages []*types.Message) (cid.Cid, error)
	StoreReceipts(context.Context, []types.MessageReceipt) (cid.Cid, error)
	StoreTxMeta(context.Context, types.MessageRoot) (cid.Cid, error)
}

MessageWriter is an interface exposing the write methods of the MessageStore.

type MockCirculatingSupplyCalculator added in v1.1.0

type MockCirculatingSupplyCalculator struct{}

func (MockCirculatingSupplyCalculator) GetCirculatingSupplyDetailed added in v1.1.0

func (m MockCirculatingSupplyCalculator) GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (types.CirculatingSupply, error)

func (MockCirculatingSupplyCalculator) GetFilVested added in v1.6.0

type MsgLookup added in v0.9.1

type MsgLookup struct {
	Message   cid.Cid // Can be different than requested, in case it was replaced, but only gas values changed
	Receipt   types.MessageReceipt
	ReturnDec interface{}
	TipSet    types.TipSetKey
	Height    abi.ChainEpoch
}

type NetworkVersionGetter added in v1.6.0

type NetworkVersionGetter func(context.Context, abi.ChainEpoch) network.Version

type RandomSeed

type RandomSeed []byte

func MakeRandomSeed

func MakeRandomSeed(rawVRFProof types.VRFPi) (RandomSeed, error)

Computes a random seed from raw ticket bytes. A randomness seed is the VRF digest of the minimum ticket of the tipset at or before the requested epoch

type RandomnessSource

type RandomnessSource = vm.ChainRandomness

func NewChainRandomnessSource added in v1.1.0

func NewChainRandomnessSource(reader TipSetByHeight, head types.TipSetKey, beacon beacon.Schedule, networkVersionGetter NetworkVersionGetter) RandomnessSource

type ReorgNotifee

type ReorgNotifee func(rev, app []*types.TipSet) error

ReorgNotifee represents a callback that gets called upon reorgs.

func WrapHeadChangeCoalescer

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.

type StateBuilder

type StateBuilder interface {
	ComputeState(prev cid.Cid, blockmsg []types.BlockMessagesInfo) (cid.Cid, []types.MessageReceipt, error)
	Weigh(ctx context.Context, tip *types.TipSet) (big.Int, error)
}

StateBuilder abstracts the computation of state root CIDs from the chain builder.

type Store

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

Store is a generic implementation of the Store interface. It works(tm) for now.

func NewStore

func NewStore(chainDs repo.Datastore,
	bsstore blockstoreutil.Blockstore,
	genesisCid cid.Cid,
	circulatiingSupplyCalculator ICirculatingSupplyCalcualtor,
	weight WeightFunc,
) *Store

NewStore constructs a new default store.

func (*Store) AccountView added in v0.9.1

func (store *Store) AccountView(ctx context.Context, ts *types.TipSet) (state.AccountView, error)

AccountView return account view at ts state

func (*Store) AddToTipSetTracker added in v1.15.0

func (store *Store) AddToTipSetTracker(ctx context.Context, b *types.BlockHeader) error

func (*Store) Blockstore

func (store *Store) Blockstore() blockstoreutil.Blockstore

Blockstore return local blockstore todo remove this method, and code that need blockstore should get from blockstore submodule

func (*Store) DeleteTipSetMetadata added in v1.2.0

func (store *Store) DeleteTipSetMetadata(ctx context.Context, ts *types.TipSet) error

deleteTipSetMetadata delete the state root id from the datastore for the tipset key.

func (*Store) Export added in v1.1.0

func (store *Store) Export(ctx context.Context, ts *types.TipSet, inclRecentRoots abi.ChainEpoch, skipOldMsgs bool, w io.Writer) error

func (*Store) FormHeaviestTipSetForHeight added in v1.15.0

func (store *Store) 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 (*Store) GenesisCid

func (store *Store) GenesisCid() cid.Cid

GenesisCid returns the genesis cid of the chain tracked by the default store.

func (*Store) GenesisRootCid

func (store *Store) GenesisRootCid() cid.Cid

GenesisRootCid returns the genesis root cid of the chain tracked by the default store.

func (*Store) GetActorAt added in v0.9.1

func (store *Store) GetActorAt(ctx context.Context, ts *types.TipSet, addr address.Address) (*types.Actor, error)

GetActorAt returns an actor at a specified tipset key.

func (*Store) GetBlock

func (store *Store) GetBlock(ctx context.Context, blockID cid.Cid) (*types.BlockHeader, error)

GetBlock returns the block identified by `cid`.

func (*Store) GetCheckPoint

func (store *Store) GetCheckPoint() types.TipSetKey

GetCheckPoint get the check point from store or disk.

func (*Store) GetCirculatingSupplyDetailed

func (store *Store) GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (types.CirculatingSupply, error)

func (*Store) GetFilVested added in v1.6.0

func (store *Store) GetFilVested(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error)

func (*Store) GetGenesisBlock

func (store *Store) GetGenesisBlock(ctx context.Context) (*types.BlockHeader, error)

GetGenesisBlock returns the genesis block held by the chain store.

func (*Store) GetHead

func (store *Store) GetHead() *types.TipSet

GetHead returns the current head tipset cids.

func (*Store) GetLatestBeaconEntry

func (store *Store) GetLatestBeaconEntry(ctx context.Context, ts *types.TipSet) (*types.BeaconEntry, error)

GetLatestBeaconEntry get latest beacon from the height. there're no beacon values in the block, try to get beacon in the parents tipset. the max find depth is 20.

func (*Store) GetLookbackTipSetForRound added in v0.9.1

func (store *Store) GetLookbackTipSetForRound(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, version network.Version) (*types.TipSet, cid.Cid, error)

GetLookbackTipSetForRound get loop back tipset and state root

func (*Store) GetParentReceipt added in v0.9.1

func (store *Store) GetParentReceipt(b *types.BlockHeader, i int) (*types.MessageReceipt, error)

GetParentReceipt get the receipt of parent tipset at specify message slot

func (*Store) GetTipSet

func (store *Store) GetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error)

GetTipSet returns the tipset identified by `key`.

func (*Store) GetTipSetByCid added in v1.10.0

func (store *Store) GetTipSetByCid(ctx context.Context, c cid.Cid) (*types.TipSet, error)

func (*Store) GetTipSetByHeight

func (store *Store) GetTipSetByHeight(ctx context.Context, ts *types.TipSet, h abi.ChainEpoch, prev bool) (*types.TipSet, error)

GetTipSetByHeight looks back for a tipset at the specified epoch. 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 (*Store) GetTipSetReceiptsRoot

func (store *Store) GetTipSetReceiptsRoot(ctx context.Context, key *types.TipSet) (cid.Cid, error)

GetTipSetReceiptsRoot returns the root CID of the message receipts for the tipset identified by `key`.

func (*Store) GetTipSetState

func (store *Store) GetTipSetState(ctx context.Context, ts *types.TipSet) (tree.Tree, error)

GetTipSetState returns the aggregate state of the tipset identified by `key`.

func (*Store) GetTipSetStateRoot

func (store *Store) GetTipSetStateRoot(ctx context.Context, key *types.TipSet) (cid.Cid, error)

GetTipSetStateRoot returns the aggregate state root CID of the tipset identified by `key`.

func (*Store) GetTipsetMetadata added in v1.2.0

func (store *Store) GetTipsetMetadata(ctx context.Context, ts *types.TipSet) (*TipSetMetadata, error)

func (*Store) HasTipSetAndState

func (store *Store) HasTipSetAndState(ctx context.Context, ts *types.TipSet) bool

HasTipSetAndState returns true iff the default store's tipindex is indexing the tipset identified by `key`.

func (*Store) Import

func (store *Store) Import(ctx context.Context, r io.Reader) (*types.TipSet, *types.BlockHeader, error)

Import import a car file into local db

func (*Store) Load

func (store *Store) Load(ctx context.Context) (err error)

Load rebuilds the Store's caches by traversing backwards from the most recent best head as stored in its datastore. Because Load uses a content addressed datastore it guarantees that parent blocks are correctly resolved from the datastore. Furthermore Load ensures that all tipsets references correctly have the same parent height, weight and parent set. However, Load DOES NOT validate state transitions, it assumes that the tipset were only Put to the Store after checking for valid transitions.

Furthermore Load trusts that the Store's backing datastore correctly preserves the cids of the heaviest tipset under the "HeadKey" datastore key. If the HeadKey cids are tampered with and invalid blocks added to the datastore then Load could be tricked into loading an invalid chain. Load will error if the head does not link back to the expected genesis block, or the Store's datastore does not store a link in the chain. In case of error the caller should not consider the chain useable and propagate the error.

func (*Store) LoadTipsetMetadata

func (store *Store) LoadTipsetMetadata(ctx context.Context, ts *types.TipSet) (*TipSetMetadata, error)

LoadTipsetMetadata load tipset status (state root and reciepts)

func (*Store) LookupID added in v0.9.1

func (store *Store) LookupID(ctx context.Context, ts *types.TipSet, addr address.Address) (address.Address, error)

LookupID resolves ID address for actor

func (*Store) Ls added in v0.9.1

func (store *Store) Ls(ctx context.Context, fromTS *types.TipSet, count int) ([]*types.TipSet, error)

Ls returns an iterator over tipsets from head to genesis.

func (*Store) LsActors added in v0.9.1

func (store *Store) LsActors(ctx context.Context) (map[address.Address]*types.Actor, error)

LsActors returns a channel with actors from the latest state on the chain

func (*Store) ParentStateView added in v0.9.1

func (store *Store) ParentStateView(ts *types.TipSet) (*state.View, error)

ParentStateView get parent state view of ts

func (*Store) PersistGenesisCID added in v1.11.0

func (store *Store) PersistGenesisCID(ctx context.Context, blk *types.BlockHeader) error

func (*Store) PersistTipSetKey added in v1.10.0

func (store *Store) PersistTipSetKey(ctx context.Context, key types.TipSetKey)

func (*Store) PutMessage

func (store *Store) PutMessage(ctx context.Context, m storable) (cid.Cid, error)

PutMessage put message in local db

func (*Store) PutObject

func (store *Store) PutObject(ctx context.Context, obj interface{}) (cid.Cid, error)

GetBlock returns the block identified by `cid`.

func (*Store) PutTipSetMetadata

func (store *Store) PutTipSetMetadata(ctx context.Context, tsm *TipSetMetadata) error

PutTipSetMetadata persists the blocks of a tipset and the tipset index.

func (*Store) ReadOnlyStateStore

func (store *Store) ReadOnlyStateStore() util.ReadOnlyIpldStore

ReadOnlyStateStore provides a read-only IPLD store for access to chain state.

func (*Store) RefreshHeaviestTipSet added in v1.15.0

func (store *Store) 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 (*Store) ReorgOps

func (store *Store) ReorgOps(ctx context.Context, a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)

ReorgOps used to reorganize the blockchain. Whenever a new tipset is approved, the new tipset compared with the local tipset to obtain which tipset need to be revert and which tipsets are applied

func (*Store) ResolveToDeterministicAddress added in v1.10.0

func (store *Store) ResolveToDeterministicAddress(ctx context.Context, ts *types.TipSet, addr address.Address) (address.Address, error)

ResolveToDeterministicAddress get key address of specify address. if ths addr is bls/secpk address, return directly, other get the pubkey and generate address

func (*Store) SetCheckPoint

func (store *Store) SetCheckPoint(checkPoint types.TipSetKey)

SetCheckPoint set current checkpoint

func (*Store) SetHead

func (store *Store) SetHead(ctx context.Context, newTS *types.TipSet) error

SetHead sets the passed in tipset as the new head of this chain.

func (*Store) StateCirculatingSupply

func (store *Store) StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error)

StateCirculatingSupply get circulate supply at specify epoch

func (*Store) StateView added in v0.9.1

func (store *Store) StateView(ctx context.Context, ts *types.TipSet) (*state.View, error)

StateView return state view at ts epoch

func (*Store) Stop

func (store *Store) Stop()

Stop stops all activities and cleans up.

func (*Store) Store added in v0.9.1

func (store *Store) Store(ctx context.Context) adt.Store

Store wrap adt store

func (*Store) SubHeadChanges

func (store *Store) SubHeadChanges(ctx context.Context) chan []*types.HeadChange

SubHeadChanges returns channel with chain head updates. First message is guaranteed to be of len == 1, and type == 'current'. Then event in the message may be HCApply and HCRevert.

func (*Store) SubscribeHeadChanges

func (store *Store) SubscribeHeadChanges(f ReorgNotifee)

SubscribeHeadChanges subscribe head change event

func (*Store) WalkSnapshot added in v1.1.0

func (store *Store) WalkSnapshot(ctx context.Context, ts *types.TipSet, inclRecentRoots abi.ChainEpoch, skipOldMsgs, skipMsgReceipts bool, cb func(cid.Cid) error) error

func (*Store) Weight added in v1.15.0

func (store *Store) Weight(ctx context.Context, ts *types.TipSet) (big.Int, error)

func (*Store) WriteCheckPoint

func (store *Store) WriteCheckPoint(ctx context.Context, cids types.TipSetKey) error

WriteCheckPoint writes the given cids to disk.

type TSState added in v0.9.7

type TSState struct {
	StateRoot cid.Cid
	Receipts  cid.Cid
}

TSState export this func is just for gen cbor tool to work

func (*TSState) MarshalCBOR added in v0.9.7

func (t *TSState) MarshalCBOR(w io.Writer) error

func (*TSState) UnmarshalCBOR added in v0.9.7

func (t *TSState) UnmarshalCBOR(r io.Reader) (err error)

type TimeStamper

type TimeStamper interface {
	Stamp(abi.ChainEpoch) uint64
}

TimeStamper is an object that timestamps blocks

type TipSetByHeight

type TipSetByHeight interface {
	GetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
	GetTipSetByHeight(context.Context, *types.TipSet, abi.ChainEpoch, bool) (*types.TipSet, error)
}

type TipSetMetadata

type TipSetMetadata struct {
	// TipSetStateRoot is the root of aggregate state after applying tipset
	TipSetStateRoot cid.Cid

	// TipSet is the set of blocks that forms the tip set
	TipSet *types.TipSet

	// TipSetReceipts receipts from all message contained within this tipset
	TipSetReceipts cid.Cid
}

TipSetMetadata is the type stored at the leaves of the TipStateCache. It contains a tipset pointing to blocks, the root cid of the chain's state after applying the messages in this tipset to it's parent state, and the cid of the receipts for these messages.

type TipSetProvider

type TipSetProvider interface {
	GetTipSet(ctx context.Context, tsKey types.TipSetKey) (*types.TipSet, error)
}

TipSetProvider provides tipsets for traversal.

func TipSetProviderFromBlocks

func TipSetProviderFromBlocks(ctx context.Context, blocks BlockProvider) TipSetProvider

TipSetProviderFromBlocks builds a tipset provider backed by a block provider. Blocks will be loaded with the provided context, since GetTipSet does not accept a context parameter. This can and should be removed when GetTipSet does take a context.

type TipStateCache

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

TipStateCache tracks tipsets and their states by tipset block ids. All methods are thread safe.

func NewTipStateCache

func NewTipStateCache(loader tipLoader) *TipStateCache

NewTipStateCache is the TipStateCache constructor.

func (*TipStateCache) Del added in v1.2.0

func (ti *TipStateCache) Del(ts *types.TipSet)

func (*TipStateCache) Get

func (ti *TipStateCache) Get(ctx context.Context, ts *types.TipSet) (TSState, error)

Get returns the tipset given by the input ID and its state.

func (*TipStateCache) GetTipSetReceiptsRoot

func (ti *TipStateCache) GetTipSetReceiptsRoot(ctx context.Context, ts *types.TipSet) (cid.Cid, error)

GetTipSetReceiptsRoot returns the tipsetReceipts from func (ti *TipStateCache) Get(tsKey string).

func (*TipStateCache) GetTipSetStateRoot

func (ti *TipStateCache) GetTipSetStateRoot(ctx context.Context, ts *types.TipSet) (cid.Cid, error)

GetTipSetStateRoot returns the tipsetStateRoot from func (ti *TipStateCache) Get(tsKey string).

func (*TipStateCache) Has

func (ti *TipStateCache) Has(ctx context.Context, ts *types.TipSet) bool

Has returns true iff the tipset with the input ID is stored in the TipStateCache.

func (*TipStateCache) Put

func (ti *TipStateCache) Put(tsm *TipSetMetadata)

Put adds an entry to both of TipStateCache's internal indexes. After this call the input TipSetMetadata can be looked up by the ID of the tipset.

type TipsetIterator

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

TipsetIterator is an iterator over tipsets.

func IterAncestors

func IterAncestors(ctx context.Context, store TipSetProvider, start *types.TipSet) *TipsetIterator

IterAncestors returns an iterator over tipset ancestors, yielding first the start tipset and then its parent tipsets until (and including) the genesis tipset.

func (*TipsetIterator) Complete

func (it *TipsetIterator) Complete() bool

Complete tests whether the iterator is exhausted.

func (*TipsetIterator) Next

func (it *TipsetIterator) Next(ctx context.Context) error

Next advances the iterator to the next value.

func (*TipsetIterator) Value

func (it *TipsetIterator) Value() *types.TipSet

Value returns the iterator's current value, if not Complete().

type WaitPredicate added in v0.9.1

type WaitPredicate func(msg *types.Message, msgCid cid.Cid) bool

WaitPredicate is a function that identifies a message and returns true when found.

type Waiter added in v0.9.1

type Waiter struct {
	Stmgr IStmgr
	// contains filtered or unexported fields
}

Waiter waits for a message to appear on chain.

func NewWaiter added in v0.9.1

func NewWaiter(chainStore waiterChainReader, messages MessageProvider, bs bstore.Blockstore, cst cbor.IpldStore) *Waiter

NewWaiter returns a new Waiter.

func (*Waiter) Find added in v0.9.1

func (w *Waiter) Find(ctx context.Context, msg types.ChainMsg, lookback abi.ChainEpoch, ts *types.TipSet, allowReplaced bool) (*types.ChainMessage, bool, error)

Find searches the blockchain history (but doesn't wait).

func (*Waiter) Wait added in v0.9.1

func (w *Waiter) Wait(ctx context.Context, msg types.ChainMsg, confidence uint64, lookbackLimit abi.ChainEpoch, allowReplaced bool) (*types.ChainMessage, error)

Wait uses WaitPredicate to invoke the callback when a message with the given cid appears on chain.

func (*Waiter) WaitPredicate added in v0.9.1

func (w *Waiter) WaitPredicate(ctx context.Context, msg types.ChainMsg, confidence uint64, lookback abi.ChainEpoch, allowReplaced bool) (*types.ChainMessage, error)

WaitPredicate invokes the callback when the passed predicate succeeds. See api description.

Note: this method does too much -- the callback should just receive the tipset containing the message and the caller should pull the receipt out of the block if in fact that's what it wants to do, using something like receiptFromTipset. Something like receiptFromTipset is necessary because not every message in a block will have a receipt in the tipset: it might be a duplicate message. This method will always check for the message in the current head tipset. A lookback parameter > 1 will cause this method to check for the message in up to that many previous tipsets on the chain of the current head.

type WeightFunc added in v1.15.0

type WeightFunc func(context.Context, cbor.IpldStore, *types.TipSet) (big.Int, error)

type ZeroTimestamper

type ZeroTimestamper struct{}

ZeroTimestamper writes a default of 0 to the timestamp

func (*ZeroTimestamper) Stamp

func (zt *ZeroTimestamper) Stamp(height abi.ChainEpoch) uint64

Stamp returns a stamp for the current block

Jump to

Keyboard shortcuts

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