Documentation ¶
Index ¶
- Constants
- Variables
- func ActorStore(ctx context.Context, bs blockstore.Blockstore) adt.Store
- func BlendEntropy(tag crypto.DomainSeparationTag, seed RandomSeed, epoch abi.ChainEpoch, ...) (abi.Randomness, error)
- func CollectTipSetsOfHeightAtLeast(ctx context.Context, iterator *TipsetIterator, minHeight abi.ChainEpoch) ([]*types.TipSet, error)
- func CollectTipsToCommonAncestor(ctx context.Context, store TipSetProvider, oldHead, newHead *types.TipSet) (oldTips, newTips []*types.TipSet, err error)
- func ComputeMsgMeta(bs blockstore.Blockstore, bmsgCids, smsgCids []cid.Cid) (cid.Cid, error)
- func ComputeNextBaseFee(baseFee abi.TokenAmount, gasLimitUsed int64, noOfBlocks int, ...) abi.TokenAmount
- func DrawRandomness(rbase []byte, pers acrypto.DomainSeparationTag, round abi.ChainEpoch, ...) ([]byte, error)
- func FindCommonAncestor(leftIter, rightIter *TipsetIterator) (*types.TipSet, error)
- func FindLatestDRAND(ctx context.Context, start *types.TipSet, reader TipSetProvider) (*types.BeaconEntry, error)
- func GetChainMsgRoot(ctx context.Context, messages []types.ChainMsg) (cid.Cid, error)
- func GetFilBurnt(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)
- func GetFilMined(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)
- func GetReceiptRoot(receipts []types.MessageReceipt) (cid.Cid, error)
- func IsReorg(old, new, commonAncestor *types.TipSet) bool
- func LoadTipSetBlocks(ctx context.Context, store BlockProvider, key types.TipSetKey) (*types.TipSet, error)
- func MakeBlock(obj cbor2.Marshaler) (blocks.Block, error)
- func PutMessage(bs blockstoreutil.Blockstore, m storable) (cid.Cid, error)
- func ReorgDiff(old, new, commonAncestor *types.TipSet) (abi.ChainEpoch, abi.ChainEpoch, error)
- func ReorgOps(lts func(types.TipSetKey) (*types.TipSet, error), a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)
- func Reverse(chain []*types.TipSet)
- type BlockBuilder
- func (bb *BlockBuilder) AddMessages(secpmsgs []*types.SignedMessage, blsMsgs []*types.UnsignedMessage)
- func (bb *BlockBuilder) IncHeight(nullBlocks abi.ChainEpoch)
- func (bb *BlockBuilder) SetBlockSig(signature crypto.Signature)
- func (bb *BlockBuilder) SetStateRoot(root cid.Cid)
- func (bb *BlockBuilder) SetTicket(raw []byte)
- func (bb *BlockBuilder) SetTimestamp(timestamp uint64)
- type BlockProvider
- type Builder
- func (f *Builder) AddPeer(peer peer.ID)
- func (f *Builder) AppendBlockOn(parent *types.TipSet) *types.BlockHeader
- func (f *Builder) AppendBlockOnBlocks(parents ...*types.BlockHeader) *types.BlockHeader
- func (f *Builder) AppendManyBlocksOn(height int, parent *types.TipSet) *types.BlockHeader
- func (f *Builder) AppendManyBlocksOnBlocks(height int, parents ...*types.BlockHeader) *types.BlockHeader
- func (f *Builder) AppendManyOn(height int, parent *types.TipSet) *types.TipSet
- func (f *Builder) AppendOn(parent *types.TipSet, width int) *types.TipSet
- func (f *Builder) BlockStore() blockstore.Blockstore
- func (f *Builder) Build(parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet
- func (f *Builder) BuildManyOn(height int, parent *types.TipSet, build func(b *BlockBuilder)) *types.TipSet
- func (f *Builder) BuildOn(parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet
- func (f *Builder) BuildOnBlock(parent *types.BlockHeader, build func(b *BlockBuilder)) *types.BlockHeader
- func (f *Builder) BuildOneOn(parent *types.TipSet, build func(b *BlockBuilder)) *types.TipSet
- func (f *Builder) BuildOrphaTipset(parent *types.TipSet, width int, build func(b *BlockBuilder, i int)) *types.TipSet
- func (f *Builder) ComputeState(tip *types.TipSet) (cid.Cid, []types.MessageReceipt)
- func (f *Builder) Cstore() cbor.IpldStore
- func (f *Builder) FetchTipSetHeaders(ctx context.Context, key types.TipSetKey, from peer.ID, ...) ([]*types.TipSet, error)
- func (f *Builder) FetchTipSets(ctx context.Context, key types.TipSetKey, from peer.ID, ...) ([]*types.TipSet, error)
- func (f *Builder) GeneratorGenesis() *types.TipSet
- func (f *Builder) Genesis() *types.TipSet
- func (f *Builder) GetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)
- func (f *Builder) GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error)
- func (f *Builder) GetBlocksByIds(ctx context.Context, cids []cid.Cid) ([]*types.BlockHeader, error)
- func (f *Builder) GetBlockstoreValue(ctx context.Context, c cid.Cid) (blocks.Block, error)
- func (f *Builder) GetChainMessages(ctx context.Context, tipsets []*types.TipSet) ([]*exchange.CompactedMessages, error)
- func (f *Builder) GetFullTipSet(ctx context.Context, peer []peer.ID, tsk types.TipSetKey) (*types.FullTipSet, error)
- func (f *Builder) GetTipSet(key types.TipSetKey) (*types.TipSet, error)
- func (f *Builder) GetTipSetByHeight(ctx context.Context, ts *types.TipSet, h abi.ChainEpoch, prev bool) (*types.TipSet, error)
- func (f *Builder) GetTipSetStateRoot(key types.TipSetKey) (cid.Cid, error)
- func (f *Builder) LoadMetaMessages(ctx context.Context, metaCid cid.Cid) ([]*types.SignedMessage, []*types.UnsignedMessage, error)
- func (f *Builder) LoadReceipts(ctx context.Context, c cid.Cid) ([]types.MessageReceipt, error)
- func (f *Builder) LoadSignedMessagesFromCids(secpCids []cid.Cid) ([]*types.SignedMessage, error)
- func (f *Builder) LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error)
- func (f *Builder) LoadTxMeta(ctx context.Context, metaCid cid.Cid) (types.TxMeta, error)
- func (f *Builder) LoadUnsignedMessagesFromCids(blsCids []cid.Cid) ([]*types.UnsignedMessage, error)
- func (f *Builder) Mstore() *MessageStore
- func (f *Builder) ReadMsgMetaCids(ctx context.Context, metaCid cid.Cid) ([]cid.Cid, []cid.Cid, error)
- func (f *Builder) RemovePeer(peer peer.ID)
- func (f *Builder) Repo() repo.Repo
- func (f *Builder) RequireTipSet(key types.TipSetKey) *types.TipSet
- func (f *Builder) RequireTipSets(head types.TipSetKey, count int) []*types.TipSet
- func (f *Builder) StateForKey(key types.TipSetKey) cid.Cid
- func (f *Builder) Store() *Store
- func (f *Builder) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error)
- func (f *Builder) StoreTxMeta(ctx context.Context, meta types.TxMeta) (cid.Cid, error)
- type ChainIndex
- type ChainMessage
- type ChainRandomnessSource
- func (c *ChainRandomnessSource) GetBeaconRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, ...) ([]byte, error)
- func (c *ChainRandomnessSource) GetBeaconRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, ...) ([]byte, error)
- func (c *ChainRandomnessSource) GetChainRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, ...) ([]byte, error)
- func (c *ChainRandomnessSource) GetChainRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, ...) ([]byte, error)
- func (c *ChainRandomnessSource) GetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, ...) (abi.Randomness, error)
- type ChainSampler
- type CirculatingSupply
- type CirculatingSupplyCalculator
- func (caculator *CirculatingSupplyCalculator) GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (CirculatingSupply, error)
- func (caculator *CirculatingSupplyCalculator) GetFilLocked(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)
- func (caculator *CirculatingSupplyCalculator) GetFilReserveDisbursed(ctx context.Context, st tree.Tree) (abi.TokenAmount, error)
- func (caculator *CirculatingSupplyCalculator) GetFilVested(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (abi.TokenAmount, error)
- type ClockTimestamper
- type FakeChainSelector
- type FakeStateBuilder
- type FakeStateEvaluator
- type GenesisSampler
- type HeadChange
- type HeadChangeCoalescer
- type MessageProvider
- type MessageStore
- func (ms *MessageStore) ComputeBaseFee(ctx context.Context, ts *types.TipSet, upgrade *config.ForkUpgradeConfig) (abi.TokenAmount, error)
- func (ms *MessageStore) LoadMessage(mid cid.Cid) (types.ChainMsg, error)
- func (ms *MessageStore) LoadMetaMessages(ctx context.Context, metaCid cid.Cid) ([]*types.SignedMessage, []*types.UnsignedMessage, error)
- func (ms *MessageStore) LoadReceipts(ctx context.Context, c cid.Cid) ([]types.MessageReceipt, error)
- func (ms *MessageStore) LoadSignedMessage(mid cid.Cid) (*types.SignedMessage, error)
- func (ms *MessageStore) LoadSignedMessagesFromCids(secpCids []cid.Cid) ([]*types.SignedMessage, error)
- func (ms *MessageStore) LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error)
- func (ms *MessageStore) LoadTipSetMesssages(ctx context.Context, ts *types.TipSet) ([][]*types.SignedMessage, [][]*types.UnsignedMessage, error)
- func (ms *MessageStore) LoadTxMeta(ctx context.Context, c cid.Cid) (types.TxMeta, error)
- func (ms *MessageStore) LoadUnsignedMessage(mid cid.Cid) (*types.UnsignedMessage, error)
- func (ms *MessageStore) LoadUnsignedMessagesFromCids(blsCids []cid.Cid) ([]*types.UnsignedMessage, error)
- func (ms *MessageStore) MessagesForTipset(ts *types.TipSet) ([]types.ChainMsg, error)
- func (ms *MessageStore) ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error)
- func (ms *MessageStore) StoreMessage(message types.ChainMsg) (cid.Cid, error)
- func (ms *MessageStore) StoreMessages(ctx context.Context, secpMessages []*types.SignedMessage, ...) (cid.Cid, error)
- func (ms *MessageStore) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error)
- func (ms *MessageStore) StoreTxMeta(ctx context.Context, meta types.TxMeta) (cid.Cid, error)
- type MessageWriter
- type MethodMeta
- type MsgLookup
- type RandomSeed
- type RandomnessSamplerAtTipSet
- type RandomnessSource
- type ReorgNotifee
- type Sampler
- type StateBuilder
- type Store
- func (store *Store) AccountView(ts *types.TipSet) (state.AccountView, error)
- func (store *Store) Blockstore() blockstore.Blockstore
- func (store *Store) GenesisCid() cid.Cid
- func (store *Store) GenesisRootCid() cid.Cid
- func (store *Store) GetActorAt(ctx context.Context, ts *types.TipSet, addr address.Address) (*types.Actor, error)
- func (store *Store) GetBeaconRandomness(ctx context.Context, tsk types.TipSetKey, ...) (abi.Randomness, error)
- func (store *Store) GetBlock(ctx context.Context, blockID cid.Cid) (*types.BlockHeader, error)
- func (store *Store) GetChainRandomness(ctx context.Context, tsk types.TipSetKey, pers acrypto.DomainSeparationTag, ...) ([]byte, error)
- func (store *Store) GetCheckPoint() types.TipSetKey
- func (store *Store) GetCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st tree.Tree) (CirculatingSupply, error)
- func (store *Store) GetGenesisBlock(ctx context.Context) (*types.BlockHeader, error)
- func (store *Store) GetHead() *types.TipSet
- func (store *Store) GetLatestBeaconEntry(ts *types.TipSet) (*types.BeaconEntry, error)
- func (store *Store) GetLookbackTipSetForRound(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, ...) (*types.TipSet, cid.Cid, error)
- func (store *Store) GetParentReceipt(b *types.BlockHeader, i int) (*types.MessageReceipt, error)
- func (store *Store) GetSiblingState(ts *types.TipSet) ([]*TipSetMetadata, error)
- func (store *Store) GetTipSet(key types.TipSetKey) (*types.TipSet, error)
- func (store *Store) GetTipSetByHeight(ctx context.Context, ts *types.TipSet, h abi.ChainEpoch, prev bool) (*types.TipSet, error)
- func (store *Store) GetTipSetReceiptsRoot(key *types.TipSet) (cid.Cid, error)
- func (store *Store) GetTipSetState(ctx context.Context, ts *types.TipSet) (tree.Tree, error)
- func (store *Store) GetTipSetStateRoot(key *types.TipSet) (cid.Cid, error)
- func (store *Store) HasSiblingState(ts *types.TipSet) bool
- func (store *Store) HasTipSetAndState(ctx context.Context, ts *types.TipSet) bool
- func (store *Store) Import(r io.Reader) (*types.TipSet, error)
- func (store *Store) Load(ctx context.Context) (err error)
- func (store *Store) LoadTipsetMetadata(ts *types.TipSet) (*TipSetMetadata, error)
- func (store *Store) LookupID(ctx context.Context, ts *types.TipSet, addr address.Address) (address.Address, error)
- func (store *Store) Ls(ctx context.Context, fromTS *types.TipSet, count int) ([]*types.TipSet, error)
- func (store *Store) LsActors(ctx context.Context) (map[address.Address]*types.Actor, error)
- func (store *Store) ParentStateView(ts *types.TipSet) (*state.View, error)
- func (store *Store) PutMessage(m storable) (cid.Cid, error)
- func (store *Store) PutObject(ctx context.Context, obj interface{}) (cid.Cid, error)
- func (store *Store) PutTipSetMetadata(ctx context.Context, tsm *TipSetMetadata) error
- func (store *Store) ReadOnlyStateStore() util.ReadOnlyIpldStore
- func (store *Store) ReorgOps(a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)
- func (store *Store) ResolveToKeyAddr(ctx context.Context, ts *types.TipSet, addr address.Address) (address.Address, error)
- func (store *Store) SetCheckPoint(checkPoint types.TipSetKey)
- func (store *Store) SetHead(ctx context.Context, newTS *types.TipSet) error
- func (store *Store) StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error)
- func (store *Store) StateView(ts *types.TipSet) (*state.View, error)
- func (store *Store) Stop()
- func (store *Store) Store(ctx context.Context) adt.Store
- func (store *Store) SubHeadChanges(ctx context.Context) chan []*HeadChange
- func (store *Store) SubscribeHeadChanges(f ReorgNotifee)
- func (store *Store) WriteCheckPoint(ctx context.Context, cids types.TipSetKey) error
- type TSState
- type TimeStamper
- type TipSetByHeight
- type TipSetMetadata
- type TipSetProvider
- type TipStateCache
- func (ti *TipStateCache) Get(ts *types.TipSet) (*TipSetMetadata, error)
- func (ti *TipStateCache) GetSiblingState(ts *types.TipSet) ([]*TipSetMetadata, error)
- func (ti *TipStateCache) GetTipSetReceiptsRoot(ts *types.TipSet) (cid.Cid, error)
- func (ti *TipStateCache) GetTipSetStateRoot(ts *types.TipSet) (cid.Cid, error)
- func (ti *TipStateCache) Has(ts *types.TipSet) bool
- func (ti *TipStateCache) HasSiblingState(ts *types.TipSet) bool
- func (ti *TipStateCache) Put(tsas *TipSetMetadata) error
- type TipsetIterator
- type WaitPredicate
- type Waiter
- func (w *Waiter) Find(ctx context.Context, msg types.ChainMsg, lookback abi.ChainEpoch, ...) (*ChainMessage, bool, error)
- func (w *Waiter) Wait(ctx context.Context, msg types.ChainMsg, confidence uint64, ...) (*ChainMessage, error)
- func (w *Waiter) WaitPredicate(ctx context.Context, msg types.ChainMsg, confidence uint64, ...) (*ChainMessage, error)
- type ZeroTimestamper
Constants ¶
const ( HeadChangeTopic = "headchange" HCRevert = "revert" HCApply = "apply" HCCurrent = "current" )
HeadChangeTopic is the topic used to publish new heads.
Variables ¶
var CheckPoint = datastore.NewKey("/chain/checkPoint")
CheckPoint is the key which the check-point written in the datastore.
var DefaultChainIndexCacheSize = 32 << 10
var ErrNoActorImpl = errors.New("no actor implementation")
ErrNoActorImpl is returned by Get when the actor implementation doesn't exist, eg the actor address is an empty actor, an address that has received a transfer of FIL but hasn't yet been upgraded to an account actor. (The actor implementation might also genuinely be missing, which is not expected.)
var ErrNoCommonAncestor = errors.New("no common ancestor")
ErrNoCommonAncestor is returned when two chains assumed to have a common ancestor do not.
var ErrNoMethod = errors.New("no method")
ErrNoMethod is returned by Get when there is no method signature (eg, transfer).
var ( // ErrNotFound is returned when the key for a "Get" lookup is not in the index. ErrNotFound = errors.New("Key not found in tipindex") )
var ErrNotifeeDone = errors.New("notifee is done and should be removed")
var GenesisKey = datastore.NewKey("/consensus/genesisCid")
GenesisKey is the key at which the genesis Cid is written in the datastore.
var HeadKey = datastore.NewKey("/chain/heaviestTipSet")
HeadKey is the key at which the head tipset cid's are written in the datastore.
var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{}
Functions ¶
func ActorStore ¶ added in v0.9.1
func ActorStore(ctx context.Context, bs blockstore.Blockstore) adt.Store
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 DrawRandomness ¶
func DrawRandomness(rbase []byte, pers acrypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
func FindCommonAncestor ¶
func FindCommonAncestor(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 GetChainMsgRoot ¶
func GetFilBurnt ¶
GetFilBurnt query burnt contract to get amount of burnt fil
func GetFilMined ¶
GetFilMined query reward contract to get amount of mined fil
func GetReceiptRoot ¶
func GetReceiptRoot(receipts []types.MessageReceipt) (cid.Cid, error)
func IsReorg ¶
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 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 PutMessage ¶
func PutMessage(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.
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.UnsignedMessage)
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 ¶
NewBuilder builds a new chain faker with default fake state building.
func NewBuilderWithDeps ¶
func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, 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) AppendBlockOn ¶
func (f *Builder) AppendBlockOn(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(parents ...*types.BlockHeader) *types.BlockHeader
AppendBlockOnBlocks creates and returns a new block child of `parents`, with no messages.
func (*Builder) AppendManyBlocksOn ¶
AppendManyBlocksOn appends `height` blocks to the chain.
func (*Builder) AppendManyBlocksOnBlocks ¶
func (f *Builder) AppendManyBlocksOnBlocks(height int, parents ...*types.BlockHeader) *types.BlockHeader
AppendManyBlocksOnBlocks appends `height` blocks to the chain.
func (*Builder) AppendManyOn ¶
AppendManyOn appends `height` tipsets to the chain.
func (*Builder) AppendOn ¶
AppendOn creates and returns a new `width`-block tipset child of `parents`, with no messages.
func (*Builder) BlockStore ¶
func (f *Builder) BlockStore() blockstore.Blockstore
func (*Builder) Build ¶
func (f *Builder) Build(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(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(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(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 ¶
BuildOneOn creates and returns a new single-block tipset child of `parent`.
func (*Builder) BuildOrphaTipset ¶
func (*Builder) ComputeState ¶
func (f *Builder) ComputeState(tip *types.TipSet) (cid.Cid, []types.MessageReceipt)
ComputeState computes the state for a tipset from its parent state.
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) GeneratorGenesis ¶ added in v0.9.7
func (*Builder) GetBlocks ¶
func (f *Builder) GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error)
/// exchange /////
func (*Builder) GetBlocksByIds ¶
GetBlocks returns the blocks identified by `cids`.
func (*Builder) GetBlockstoreValue ¶
GetBlockstoreValue gets data straight out of the underlying blockstore by cid
func (*Builder) GetChainMessages ¶
func (*Builder) GetFullTipSet ¶
func (*Builder) GetTipSetByHeight ¶
func (*Builder) GetTipSetStateRoot ¶
GetTipSetStateRoot returns the state root that was computed for a tipset.
func (*Builder) LoadMetaMessages ¶
func (f *Builder) LoadMetaMessages(ctx context.Context, metaCid cid.Cid) ([]*types.SignedMessage, []*types.UnsignedMessage, error)
LoadMessages returns the message collections tracked by the builder.
func (*Builder) LoadReceipts ¶
LoadReceipts returns the message collections tracked by the builder.
func (*Builder) LoadSignedMessagesFromCids ¶
func (f *Builder) LoadSignedMessagesFromCids(secpCids []cid.Cid) ([]*types.SignedMessage, error)
func (*Builder) LoadTipSetMessage ¶
func (*Builder) LoadTxMeta ¶
LoadTxMeta returns the tx meta wrapper tracked by the builder.
func (*Builder) LoadUnsignedMessagesFromCids ¶
func (f *Builder) LoadUnsignedMessagesFromCids(blsCids []cid.Cid) ([]*types.UnsignedMessage, error)
func (*Builder) Mstore ¶
func (f *Builder) Mstore() *MessageStore
func (*Builder) ReadMsgMetaCids ¶
func (*Builder) RemovePeer ¶
func (*Builder) RequireTipSet ¶
RequireTipSet returns a tipset by key, which must exist.
func (*Builder) RequireTipSets ¶
RequireTipSets returns a chain of tipsets from key, which must exist and be long enough.
func (*Builder) StateForKey ¶
StateForKey loads (or computes) the state root for a tipset key.
func (*Builder) StoreReceipts ¶
func (f *Builder) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error)
StoreReceipts stores message receipts and returns a commitment.
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(_ 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(from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error)
GetTipsetByHeightWithoutCache get the tipset of specific height by reading the database directly
type ChainMessage ¶ added in v0.9.1
type ChainMessage struct { TS *types.TipSet Message types.ChainMsg Block *types.BlockHeader Receipt *types.MessageReceipt }
ChainMessage is an on-chain message with its block and receipt.
type ChainRandomnessSource ¶
type ChainRandomnessSource struct {
Sampler ChainSampler
}
A randomness source that seeds computations with a sample drawn from a chain epoch.
func (*ChainRandomnessSource) GetBeaconRandomnessLookingBack ¶ added in v0.9.7
func (c *ChainRandomnessSource) GetBeaconRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
func (*ChainRandomnessSource) GetBeaconRandomnessLookingForward ¶ added in v0.9.7
func (c *ChainRandomnessSource) GetBeaconRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
func (*ChainRandomnessSource) GetChainRandomnessLookingBack ¶ added in v0.9.7
func (c *ChainRandomnessSource) GetChainRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
func (*ChainRandomnessSource) GetChainRandomnessLookingForward ¶ added in v0.9.7
func (c *ChainRandomnessSource) GetChainRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
func (*ChainRandomnessSource) GetRandomnessFromBeacon ¶
func (c *ChainRandomnessSource) GetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
GetRandomnessFromBeacon get randomness from beacon
type ChainSampler ¶
type ChainSampler interface { Sample(ctx context.Context, epoch abi.ChainEpoch, lookback bool) (RandomSeed, error) GetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, lookback bool) (abi.Randomness, error) }
/// Chain sampling /////
type CirculatingSupply ¶
type CirculatingSupply struct { FilVested abi.TokenAmount FilMined abi.TokenAmount FilBurnt abi.TokenAmount FilLocked abi.TokenAmount FilCirculating abi.TokenAmount }
CirculatingSupply circulation information, including mining, public offering, private placement, release, combustion, mortgage, circulation,
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, genesisReader genesisReader, 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) (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, st tree.Tree) (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
type FakeStateBuilder ¶
type FakeStateBuilder struct { }
FakeStateBuilder computes a fake state CID by hashing the CIDs of a block's parents and messages.
func (FakeStateBuilder) ComputeState ¶
func (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.
type FakeStateEvaluator ¶
type FakeStateEvaluator struct { MessageStore *MessageStore FakeStateBuilder }
FakeStateEvaluator is a syncStateEvaluator that delegates to the FakeStateBuilder.
func (*FakeStateEvaluator) RunStateTransition ¶
func (e *FakeStateEvaluator) RunStateTransition(ctx context.Context, ts *types.TipSet, parentStateRoot cid.Cid) (cid.Cid, cid.Cid, 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 GenesisSampler ¶
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 (*GenesisSampler) GetRandomnessFromBeacon ¶
func (g *GenesisSampler) GetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, _ bool) (abi.Randomness, error)
func (*GenesisSampler) Sample ¶
func (g *GenesisSampler) Sample(_ context.Context, epoch abi.ChainEpoch, _ bool) (RandomSeed, error)
Sample get genesis ticket randomSeed , t
type HeadChange ¶
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 MessageProvider ¶
type MessageProvider interface { LoadTipSetMessage(ctx context.Context, ts *types.TipSet) ([]types.BlockMessagesInfo, error) LoadMetaMessages(context.Context, cid.Cid) ([]*types.SignedMessage, []*types.UnsignedMessage, error) ReadMsgMetaCids(ctx context.Context, mmc cid.Cid) ([]cid.Cid, []cid.Cid, error) LoadUnsignedMessagesFromCids(blsCids []cid.Cid) ([]*types.UnsignedMessage, error) LoadSignedMessagesFromCids(secpCids []cid.Cid) ([]*types.SignedMessage, error) LoadReceipts(context.Context, cid.Cid) ([]types.MessageReceipt, error) LoadTxMeta(context.Context, cid.Cid) (types.TxMeta, 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 blockstore.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(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.UnsignedMessage, 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(mid cid.Cid) (*types.SignedMessage, error)
LoadUnsignedMessagesFromCids load unsigned messages of cid array
func (*MessageStore) LoadSignedMessagesFromCids ¶
func (ms *MessageStore) LoadSignedMessagesFromCids(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.UnsignedMessage, error)
load message from tipset NOTICE skip message with the same nonce
func (*MessageStore) LoadTxMeta ¶
LoadTxMeta loads the secproot, blsroot data from the message store
func (*MessageStore) LoadUnsignedMessage ¶
func (ms *MessageStore) LoadUnsignedMessage(mid cid.Cid) (*types.UnsignedMessage, error)
LoadUnsignedMessage load unsigned messages in tipset
func (*MessageStore) LoadUnsignedMessagesFromCids ¶
func (ms *MessageStore) LoadUnsignedMessagesFromCids(blsCids []cid.Cid) ([]*types.UnsignedMessage, error)
LoadUnsignedMessagesFromCids load unsigned messages of cid array
func (*MessageStore) MessagesForTipset ¶
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) 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.UnsignedMessage) (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 ¶
StoreTxMeta writes the secproot, blsroot block to the message store
type MessageWriter ¶
type MessageWriter interface { StoreMessages(ctx context.Context, secpMessages []*types.SignedMessage, blsMessages []*types.UnsignedMessage) (cid.Cid, error) StoreReceipts(context.Context, []types.MessageReceipt) (cid.Cid, error) StoreTxMeta(context.Context, types.TxMeta) (cid.Cid, error) }
MessageWriter is an interface exposing the write methods of the MessageStore.
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 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 RandomnessSamplerAtTipSet ¶
type RandomnessSamplerAtTipSet struct {
// contains filtered or unexported fields
}
/// A chain sampler with a specific head tipset key. /////
func NewRandomnessSamplerAtTipSet ¶
func NewRandomnessSamplerAtTipSet(reader TipSetByHeight, genesisTicket types.Ticket, head types.TipSetKey) *RandomnessSamplerAtTipSet
Creates a new sampler for the chain identified by `head`.
func (*RandomnessSamplerAtTipSet) GetRandomnessFromBeacon ¶
func (s *RandomnessSamplerAtTipSet) GetRandomnessFromBeacon(ctx context.Context, personalization acrypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, lookback bool) (abi.Randomness, error)
GetRandomnessFromBeacon compute randomness with beacon value at head tipset
func (*RandomnessSamplerAtTipSet) Sample ¶
func (s *RandomnessSamplerAtTipSet) Sample(ctx context.Context, epoch abi.ChainEpoch, lookback bool) (RandomSeed, error)
Sample get randomness from ticket at head tipset
type RandomnessSource ¶
type RandomnessSource interface { GetChainRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) GetChainRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) GetBeaconRandomnessLookingBack(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) GetBeaconRandomnessLookingForward(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) }
RandomnessSource provides randomness to actors.
type ReorgNotifee ¶
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 Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
A sampler draws randomness seeds from the chain.
This implementation doesn't do any caching: it traverses the chain each time. A cache that could be directly indexed by epoch could speed up repeated samples from the same chain.
func NewSampler ¶
func NewSampler(reader TipSetByHeight, genesisTicket types.Ticket) *Sampler
func (*Sampler) SampleRandomnessFromBeacon ¶
func (s *Sampler) SampleRandomnessFromBeacon(ctx context.Context, tsk types.TipSetKey, personalization acrypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, lookback bool) (abi.Randomness, error)
SampleRandomnessFromBeacon first get beacon value specify height (tsk height - randEpoch). if beacon value at that height is empty, use parent block beacon value, go back until get beacon value
func (*Sampler) SampleTicket ¶
func (s *Sampler) SampleTicket(ctx context.Context, head types.TipSetKey, epoch abi.ChainEpoch, lookback bool) (types.Ticket, error)
Draws a ticket from the chain identified by `head` and the highest tipset with height <= `epoch`. If `head` is empty (as when processing the pre-genesis state or the genesis block), the seed derived from a fixed genesis ticket. Note that this may produce the same value for different, neighbouring epochs when the epoch references a round in which no blocks were produced (an empty tipset or "null block"). A caller desiring a unique see for each epoch should blend in some distinguishing value (such as the epoch itself) into a hash of this ticket.
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(ds repo.Datastore, cst cbor.IpldStore, bsstore blockstore.Blockstore, forkConfig *config.ForkUpgradeConfig, genesisCid cid.Cid, ) *Store
NewStore constructs a new default store.
func (*Store) AccountView ¶ added in v0.9.1
AccountView return account view at ts state
func (*Store) Blockstore ¶
func (store *Store) Blockstore() blockstore.Blockstore
Blockstore return local blockstore todo remove this method, and code that need blockstore should get from blockstore submodule
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) GetBeaconRandomness ¶ added in v0.9.7
func (store *Store) GetBeaconRandomness(ctx context.Context, tsk types.TipSetKey, personalization acrypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, lookback bool) (abi.Randomness, error)
func (*Store) GetChainRandomness ¶ added in v0.9.7
func (store *Store) GetChainRandomness(ctx context.Context, tsk types.TipSetKey, pers acrypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte, lookback bool) ([]byte, error)
Randomness SampleChainRandomness computes randomness seeded by a ticket from the chain `head` at `sampleHeight`.
func (*Store) GetCheckPoint ¶
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) (CirculatingSupply, error)
func (*Store) GetGenesisBlock ¶
GetGenesisBlock returns the genesis block held by the chain store.
func (*Store) GetLatestBeaconEntry ¶
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) GetSiblingState ¶
func (store *Store) GetSiblingState(ts *types.TipSet) ([]*TipSetMetadata, error)
GetSiblingState returns the the tipsets and states tracked by the default store's tipIndex that have parents identified by `parentKey`.
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. If there are no blocks at the specified epoch, a tipset at an earlier epoch will be returned.
func (*Store) GetTipSetReceiptsRoot ¶
GetTipSetReceiptsRoot returns the root CID of the message receipts for the tipset identified by `key`.
func (*Store) GetTipSetState ¶
GetTipSetState returns the aggregate state of the tipset identified by `key`.
func (*Store) GetTipSetStateRoot ¶
GetTipSetStateRoot returns the aggregate state root CID of the tipset identified by `key`.
func (*Store) HasSiblingState ¶
HasSiblingState returns true if the default store's tipindex contains any tipset identified by `parentKey`.
func (*Store) HasTipSetAndState ¶
HasTipSetAndState returns true iff the default store's tipindex is indexing the tipset identified by `key`.
func (*Store) Load ¶
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(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
LsActors returns a channel with actors from the latest state on the chain
func (*Store) ParentStateView ¶ added in v0.9.1
ParentStateView get parent state view of ts
func (*Store) PutMessage ¶
PutMessage put message in local db
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) ReorgOps ¶
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) ResolveToKeyAddr ¶ added in v0.9.1
func (store *Store) ResolveToKeyAddr(ctx context.Context, ts *types.TipSet, addr address.Address) (address.Address, error)
ResolveToKeyAddr 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 ¶
SetCheckPoint set current checkpoint
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) SubHeadChanges ¶
func (store *Store) SubHeadChanges(ctx context.Context) chan []*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
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
type TimeStamper ¶
type TimeStamper interface {
Stamp(abi.ChainEpoch) uint64
}
TimeStamper is an object that timestamps blocks
type TipSetByHeight ¶
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 ¶
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 and parent block ids. All methods are threadsafe as shared data is guarded by a mutex.
func NewTipStateCache ¶
func NewTipStateCache(loader tipLoader) *TipStateCache
NewTipStateCache is the TipStateCache constructor.
func (*TipStateCache) Get ¶
func (ti *TipStateCache) Get(ts *types.TipSet) (*TipSetMetadata, error)
Get returns the tipset given by the input ID and its state.
func (*TipStateCache) GetSiblingState ¶
func (ti *TipStateCache) GetSiblingState(ts *types.TipSet) ([]*TipSetMetadata, error)
GetSiblingState returns the all tipsets and states stored in the TipStateCache such that the parent ID of these tipsets equals the input.
func (*TipStateCache) GetTipSetReceiptsRoot ¶
func (ti *TipStateCache) GetTipSetReceiptsRoot(ts *types.TipSet) (cid.Cid, error)
GetTipSetReceiptsRoot returns the tipsetReceipts from func (ti *TipStateCache) Get(tsKey string).
func (*TipStateCache) GetTipSetStateRoot ¶
func (ti *TipStateCache) GetTipSetStateRoot(ts *types.TipSet) (cid.Cid, error)
GetTipSetStateRoot returns the tipsetStateRoot from func (ti *TipStateCache) Get(tsKey string).
func (*TipStateCache) Has ¶
func (ti *TipStateCache) Has(ts *types.TipSet) bool
Has returns true iff the tipset with the input ID is stored in the TipStateCache.
func (*TipStateCache) HasSiblingState ¶
func (ti *TipStateCache) HasSiblingState(ts *types.TipSet) bool
HasSiblingState returns true iff there exist tipsets, and states, tracked in the TipStateCache such that the parent ID of these tipsets equals the input.
func (*TipStateCache) Put ¶
func (ti *TipStateCache) Put(tsas *TipSetMetadata) error
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, or the tipset's parent.
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() 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.UnsignedMessage, 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 {
// 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) (*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) (*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) (*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 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