stmgr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2021 License: Apache-2.0, MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const LookbackNoLimit = abi.ChainEpoch(-1)
View Source
const ReceiptAmtBitwidth = 3

Variables

View Source
var ErrExpensiveFork = errors.New("refusing explicit call due to state fork at epoch")
View Source
var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{}

Functions

func CheckTotalEPK

func CheckTotalEPK(ctx context.Context, sm *StateManager, ts *types.TipSet) (abi.TokenAmount, error)

func ComputeState

func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, msgs []*types.Message, ts *types.TipSet) (cid.Cid, []*api.InvocResult, error)

func GetEpkBurnt

func GetEpkBurnt(ctx context.Context, st *state.StateTree) (abi.TokenAmount, error)

func GetEpkMined

func GetEpkMined(ctx context.Context, st *state.StateTree) (abi.TokenAmount, error)

func GetLookbackTipSetForRound

func GetLookbackTipSetForRound(ctx context.Context, sm *StateManager, ts *types.TipSet, round abi.ChainEpoch) (*types.TipSet, cid.Cid, error)

func GetMinerSlashed

func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error)

func GetMinerWorkerRaw

func GetMinerWorkerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr address.Address) (address.Address, error)

func GetNetworkName

func GetNetworkName(ctx context.Context, sm *StateManager, st cid.Cid) (dtypes.NetworkName, error)

func GetParamType

func GetParamType(actCode cid.Cid, method abi.MethodNum) (cbg.CBORUnmarshaler, error)

func GetPower

func GetPower(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (power.Claim, power.Claim, bool, error)

func GetPowerRaw

func GetPowerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr address.Address) (power.Claim, power.Claim, bool, error)

func GetReturnType

func GetReturnType(ctx context.Context, sm *StateManager, to address.Address, method abi.MethodNum, ts *types.TipSet) (cbg.CBORUnmarshaler, error)

func GetSectorsForWinningPoSt

func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv ffiwrapper.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]builtin.SectorInfo, error)

func GetStorageDeal

func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts *types.TipSet) (*api.MarketDeal, error)

func ListExpertActors

func ListExpertActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error)

func ListMinerActors

func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error)

func LookbackStateGetterForTipset

func LookbackStateGetterForTipset(sm *StateManager, ts *types.TipSet) vm.LookbackStateGetter

func MakeMsgGasCost

func MakeMsgGasCost(msg *types.Message, ret *vm.ApplyRet) api.MsgGasCost

func MinerEligibleToMine

func MinerEligibleToMine(ctx context.Context, sm *StateManager, addr address.Address, baseTs *types.TipSet, lookbackTs *types.TipSet) (bool, error)

func MinerGetBaseInfo

func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule, tsk types.TipSetKey, round abi.ChainEpoch, maddr address.Address, pv ffiwrapper.Verifier) (*api.MiningBaseInfo, error)

func MinerSectorInfo

func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorOnChainInfo, error)

func PreCommitInfo

func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorPreCommitOnChainInfo, error)

func StateExpertDatas

func StateExpertDatas(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *bitfield.BitField, filterOut bool) ([]*expert.DataOnChainInfo, error)

Types

type ExecCallback

type ExecCallback func(cid.Cid, *types.Message, *vm.ApplyRet) error

type MethodMeta

type MethodMeta struct {
	Name string

	Params reflect.Type
	Ret    reflect.Type
}

type MigrationCache

type MigrationCache interface {
	Write(key string, value cid.Cid) error
	Read(key string) (bool, cid.Cid, error)
	Load(key string, loadFunc func() (cid.Cid, error)) (cid.Cid, error)
}

MigrationCache can be used to cache information used by a migration. This is primarily useful to "pre-compute" some migration state ahead of time, and make it accessible in the migration itself.

type MigrationFunc

type MigrationFunc func(
	ctx context.Context,
	sm *StateManager, cache MigrationCache,
	cb ExecCallback, oldState cid.Cid,
	height abi.ChainEpoch, ts *types.TipSet,
) (newState cid.Cid, err error)

MigrationFunc is a migration function run at every upgrade.

  • The cache is a per-upgrade cache, pre-populated by pre-migrations.
  • The oldState is the state produced by the upgrade epoch.
  • The returned newState is the new state that will be used by the next epoch.
  • The height is the upgrade epoch height (already executed).
  • The tipset is the tipset for the last non-null block before the upgrade. Do not assume that ts.Height() is the upgrade height.

type PreMigration

type PreMigration struct {
	// PreMigration is the pre-migration function to run at the specified time. This function is
	// run asynchronously and must abort promptly when canceled.
	PreMigration PreMigrationFunc

	// StartWithin specifies that this pre-migration should be started at most StartWithin
	// epochs before the upgrade.
	StartWithin abi.ChainEpoch

	// DontStartWithin specifies that this pre-migration should not be started DontStartWithin
	// epochs before the final upgrade epoch.
	//
	// This should be set such that the pre-migration is likely to complete before StopWithin.
	DontStartWithin abi.ChainEpoch

	// StopWithin specifies that this pre-migration should be stopped StopWithin epochs of the
	// final upgrade epoch.
	StopWithin abi.ChainEpoch
}

PreMigration describes a pre-migration step to prepare for a network state upgrade. Pre-migrations are optimizations, are not guaranteed to run, and may be canceled and/or run multiple times.

type PreMigrationFunc

type PreMigrationFunc func(
	ctx context.Context,
	sm *StateManager, cache MigrationCache,
	oldState cid.Cid,
	height abi.ChainEpoch, ts *types.TipSet,
) error

PreMigrationFunc is a function run _before_ a network upgrade to pre-compute part of the network upgrade and speed it up.

type StateManager

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

func NewStateManager

func NewStateManager(cs *store.ChainStore) *StateManager

func NewStateManagerWithUpgradeSchedule

func NewStateManagerWithUpgradeSchedule(cs *store.ChainStore, us UpgradeSchedule) (*StateManager, error)

func (*StateManager) ApplyBlocks

func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEpoch, pstate cid.Cid, bms []store.BlockMessages, epoch abi.ChainEpoch, r vm.Rand, cb ExecCallback, baseFee abi.TokenAmount, ts *types.TipSet) (cid.Cid, cid.Cid, error)

func (*StateManager) Call

func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.TipSet) (*api.InvocResult, error)

func (*StateManager) CallWithGas

func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, priorMsgs []types.ChainMsg, ts *types.TipSet) (*api.InvocResult, error)

func (*StateManager) ChainStore

func (sm *StateManager) ChainStore() *store.ChainStore

func (*StateManager) ExecutionTrace

func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (cid.Cid, []*api.InvocResult, error)

func (*StateManager) GetBlsPublicKey

func (sm *StateManager) GetBlsPublicKey(ctx context.Context, addr address.Address, ts *types.TipSet) (pubk []byte, err error)

func (*StateManager) GetCirculatingSupply

func (sm *StateManager) GetCirculatingSupply(ctx context.Context, height abi.ChainEpoch, st *state.StateTree) (abi.TokenAmount, error)

func (*StateManager) GetEpkLocked

func (sm *StateManager) GetEpkLocked(ctx context.Context, st *state.StateTree) (abi.TokenAmount, error)

func (*StateManager) GetEpkVested

func (sm *StateManager) GetEpkVested(ctx context.Context, height abi.ChainEpoch, st *state.StateTree) (
	total, team, foundation, investor, relocked abi.TokenAmount, err 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).

func (*StateManager) GetFlowchState

func (sm *StateManager) GetFlowchState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, flowch.State, error)

func (*StateManager) GetMarketState

func (sm *StateManager) GetMarketState(ctx context.Context, ts *types.TipSet) (market.State, error)

func (*StateManager) GetNtwkVersion

func (sm *StateManager) GetNtwkVersion(ctx context.Context, height abi.ChainEpoch) network.Version

func (*StateManager) GetPaychState

func (sm *StateManager) GetPaychState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, paych.State, error)

func (*StateManager) GetReceipt

func (sm *StateManager) GetReceipt(ctx context.Context, msg cid.Cid, ts *types.TipSet) (*types.MessageReceipt, error)

func (*StateManager) GetVMCirculatingSupply

func (sm *StateManager) GetVMCirculatingSupply(ctx context.Context, height abi.ChainEpoch, st *state.StateTree) (abi.TokenAmount, error)

func (*StateManager) GetVMCirculatingSupplyDetailed

func (sm *StateManager) GetVMCirculatingSupplyDetailed(ctx context.Context, height abi.ChainEpoch, st *state.StateTree) (api.CirculatingSupply, error)

func (*StateManager) ListAllActors

func (sm *StateManager) ListAllActors(ctx context.Context, ts *types.TipSet) ([]address.Address, error)

func (*StateManager) LoadActor

func (sm *StateManager) LoadActor(_ context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, error)

func (*StateManager) LoadActorRaw

func (sm *StateManager) LoadActorRaw(_ context.Context, addr address.Address, st cid.Cid) (*types.Actor, error)

func (*StateManager) LoadActorTsk

func (sm *StateManager) LoadActorTsk(_ context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error)

func (*StateManager) LookupID

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

func (*StateManager) ParentState

func (sm *StateManager) ParentState(ts *types.TipSet) (*state.StateTree, error)

func (*StateManager) ParentStateTsk

func (sm *StateManager) ParentStateTsk(tsk types.TipSetKey) (*state.StateTree, error)

func (*StateManager) Replay

func (sm *StateManager) Replay(ctx context.Context, ts *types.TipSet, mcid cid.Cid) (*types.Message, *vm.ApplyRet, error)

func (*StateManager) ReplayBlock

func (sm *StateManager) ReplayBlock(ctx context.Context, nth int, ts *types.TipSet) (*api.BlockReward, error)

func (*StateManager) ResolveToKeyAddress

func (sm *StateManager) ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)

ResolveToKeyAddress is similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses. Uses the `TipSet` `ts` to generate the VM state.

func (*StateManager) SearchForMessage

func (sm *StateManager) SearchForMessage(ctx context.Context, mcid cid.Cid, lookbackLimit abi.ChainEpoch) (*types.TipSet, *types.MessageReceipt, cid.Cid, error)

func (*StateManager) SetVMConstructor

func (sm *StateManager) SetVMConstructor(nvm func(context.Context, *vm.VMOpts) (*vm.VM, error))

func (*StateManager) Start

func (sm *StateManager) Start(context.Context) error

Start starts the state manager's optional background processes. At the moment, this schedules pre-migration functions to run ahead of network upgrades.

This method is not safe to invoke from multiple threads or concurrently with Stop.

func (*StateManager) StateTree

func (sm *StateManager) StateTree(st cid.Cid) (*state.StateTree, error)

func (*StateManager) Stop

func (sm *StateManager) Stop(ctx context.Context) error

Stop starts the state manager's background processes.

This method is not safe to invoke concurrently with Start.

func (*StateManager) TipSetState

func (sm *StateManager) TipSetState(ctx context.Context, ts *types.TipSet) (st cid.Cid, rec cid.Cid, err error)

func (*StateManager) ValidateChain

func (sm *StateManager) ValidateChain(ctx context.Context, ts *types.TipSet) error

func (*StateManager) WaitForMessage

func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid, confidence uint64, lookbackLimit abi.ChainEpoch) (*types.TipSet, *types.MessageReceipt, cid.Cid, error)

WaitForMessage blocks until a message appears on chain. It looks backwards in the chain to see if this has already happened, with an optional limit to how many epochs it will search. It guarantees that the message has been on chain for at least confidence epochs without being reverted before returning.

type StateManagerAPI

type StateManagerAPI interface {
	Call(ctx context.Context, msg *types.Message, ts *types.TipSet) (*api.InvocResult, error)
	GetPaychState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, paych.State, error)
	GetFlowchState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, flowch.State, error)
	LoadActorTsk(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error)
	LookupID(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
	ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
}

type Upgrade

type Upgrade struct {
	Height    abi.ChainEpoch
	Network   network.Version
	Expensive bool
	Migration MigrationFunc

	// PreMigrations specifies a set of pre-migration functions to run at the indicated epochs.
	// These functions should fill the given cache with information that can speed up the
	// eventual full migration at the upgrade epoch.
	PreMigrations []PreMigration
}

type UpgradeSchedule

type UpgradeSchedule []Upgrade

func DefaultUpgradeSchedule

func DefaultUpgradeSchedule() UpgradeSchedule

func (UpgradeSchedule) Validate

func (us UpgradeSchedule) Validate() error

Jump to

Keyboard shortcuts

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