stmgr

package
v1.26.3 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: 55 Imported by: 37

Documentation

Index

Constants

View Source
const EnvDisablePreMigrations = "LOTUS_DISABLE_PRE_MIGRATIONS"

EnvDisablePreMigrations when set to '1' stops pre-migrations from running

View Source
const LookbackNoLimit = api.LookbackNoLimit
View Source
const ReceiptAmtBitwidth = 3

Variables

View Source
var ErrExpensiveFork = errors.New("refusing explicit call due to state fork at epoch")
View Source
var ErrMetadataNotFound = errors.New("actor metadata not found")

Functions

func CheckTotalFIL added in v0.5.0

func CheckTotalFIL(ctx context.Context, cs *store.ChainStore, ts *types.TipSet) (abi.TokenAmount, error)

func ComputeState added in v0.2.5

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

func DoTransfer added in v1.11.3

func DoTransfer(tree types.StateTree, from, to address.Address, amt abi.TokenAmount, cb func(trace types.ExecutionTrace)) error

func GetFilBurnt added in v0.5.0

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

func GetFilLocked added in v1.15.1

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

func GetFilMined added in v0.5.0

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

func GetFilReserveDisbursed added in v0.9.0

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

func GetLookbackTipSetForRound added in v0.3.0

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

func GetManifestData added in v1.17.0

func GetManifestData(ctx context.Context, st *state.StateTree) (*manifest.ManifestData, 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 added in v0.3.0

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

func GetParamType added in v1.1.3

func GetParamType(ar *vm.ActorRegistry, 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 added in v0.3.0

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

func GetReturnType added in v0.5.0

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

func GetSectorsForWinningPoSt added in v0.3.0

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

func GetStorageDeal

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

func ListMinerActors added in v0.1.5

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

func LookbackStateGetterForTipset added in v1.1.2

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

func MakeFakeMsg added in v1.11.3

func MakeFakeMsg(from address.Address, to address.Address, amt abi.TokenAmount, nonce uint64) *types.Message

func MakeFakeRct added in v1.11.3

func MakeFakeRct() *types.MessageReceipt

func MakeKeyAddr added in v1.11.3

func MakeKeyAddr(splitAddr address.Address, count uint64) (address.Address, error)

func MakeMsgGasCost added in v1.0.0

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

func MinerEligibleToMine added in v0.9.0

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

func MinerGetBaseInfo added in v0.3.0

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

func MinerSectorInfo added in v0.3.1

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

Returns nil, nil if sector is not found

func PreCommitInfo added in v0.3.0

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

func SetNetworkName added in v1.11.3

func SetNetworkName(ctx context.Context, store adt.Store, tree *state.StateTree, name string) error

func TerminateActor added in v1.11.3

func TerminateActor(ctx context.Context, tree *state.StateTree, addr address.Address, em ExecMonitor, epoch abi.ChainEpoch, ts *types.TipSet) error

func TipSetGetterForTipset added in v1.20.0

func TipSetGetterForTipset(cs *store.ChainStore, ts *types.TipSet) vm.TipSetGetter

Types

type ExecMonitor added in v1.11.0

type ExecMonitor interface {
	// MessageApplied is called after a message has been applied. Returning an error will halt execution of any further messages.
	MessageApplied(ctx context.Context, ts *types.TipSet, mcid cid.Cid, msg *types.Message, ret *vm.ApplyRet, implicit bool) error
}

type Executor added in v1.11.3

type Executor interface {
	NewActorRegistry() *vm.ActorRegistry
	ExecuteTipSet(ctx context.Context, sm *StateManager, ts *types.TipSet, em ExecMonitor, vmTracing bool) (stateroot cid.Cid, rectsroot cid.Cid, err error)
}

type InvocationTracer added in v1.11.0

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

func (*InvocationTracer) MessageApplied added in v1.11.0

func (i *InvocationTracer) MessageApplied(ctx context.Context, ts *types.TipSet, mcid cid.Cid, msg *types.Message, ret *vm.ApplyRet, implicit bool) error

type MigrationCache added in v1.4.2

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

type MigrationFunc func(
	ctx context.Context,
	sm *StateManager, cache MigrationCache,
	cb ExecMonitor,
	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 first non-null tipset after the upgrade height (the tipset in which the upgrade is executed). Do not assume that ts.Height() is the upgrade height.

NOTE: In StateCompute and CallWithGas, the passed tipset is actually the tipset _before_ the upgrade. The tipset should really only be used for referencing the "current chain".

type PreMigration added in v1.4.2

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

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 {
	Syscalls vm.SyscallBuilder
	// contains filtered or unexported fields
}

func NewStateManager

func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder, us UpgradeSchedule, beacon beacon.Schedule, metadataDs dstore.Batching, msgIndex index.MsgIndex) (*StateManager, error)

func NewStateManagerWithUpgradeScheduleAndMonitor added in v1.11.0

func NewStateManagerWithUpgradeScheduleAndMonitor(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder, us UpgradeSchedule, b beacon.Schedule, em ExecMonitor, metadataDs dstore.Batching, msgIndex index.MsgIndex) (*StateManager, error)

func (*StateManager) Beacon added in v1.12.0

func (sm *StateManager) Beacon() beacon.Schedule

func (*StateManager) Call

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

Call applies the given message to the given tipset's parent state, at the epoch following the tipset's parent. In the presence of null blocks, the height at which the message is invoked may be less than the specified tipset.

func (*StateManager) CallAtStateAndVersion added in v1.20.0

func (sm *StateManager) CallAtStateAndVersion(ctx context.Context, msg *types.Message, stateCid cid.Cid, v network.Version) (*api.InvocResult, error)

CallAtStateAndVersion allows you to specify a message to execute on the given stateCid and network version. This should mostly be used for gas modelling on a migrated state. Tipset here is not needed because stateCid and network version fully describe execution we want. The internal function will get the heaviest tipset for use for things like basefee, which we don't really care about here.

func (*StateManager) CallWithGas added in v0.5.0

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

CallWithGas calculates the state for a given tipset, and then applies the given message on top of that state.

func (*StateManager) ChainStore

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

func (*StateManager) ExecutionTrace added in v0.3.0

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

func (*StateManager) ExecutionTraceWithMonitor added in v1.11.0

func (sm *StateManager) ExecutionTraceWithMonitor(ctx context.Context, ts *types.TipSet, em ExecMonitor) (cid.Cid, error)

func (*StateManager) GetBlsPublicKey

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

func (*StateManager) GetCirculatingSupply added in v0.5.0

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

func (*StateManager) GetFilVested added in v0.5.0

func (sm *StateManager) 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).

func (*StateManager) GetMarketState added in v0.7.2

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

func (*StateManager) GetNetworkVersion added in v1.14.0

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

func (*StateManager) GetPaychState added in v0.7.2

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

func (*StateManager) GetRandomnessDigestFromBeacon added in v1.24.0

func (sm *StateManager) GetRandomnessDigestFromBeacon(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) ([32]byte, error)

func (*StateManager) GetRandomnessDigestFromTickets added in v1.24.0

func (sm *StateManager) GetRandomnessDigestFromTickets(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) ([32]byte, error)

func (*StateManager) GetRandomnessFromBeacon added in v1.12.0

func (sm *StateManager) GetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)

func (*StateManager) GetRandomnessFromTickets added in v1.12.0

func (sm *StateManager) GetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)

func (*StateManager) GetVMCirculatingSupply added in v0.10.1

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

func (*StateManager) GetVMCirculatingSupplyDetailed added in v0.10.1

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

func (*StateManager) GetVerifregState added in v1.18.0

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

func (*StateManager) HandleStateForks added in v1.11.3

func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, height abi.ChainEpoch, cb ExecMonitor, ts *types.TipSet) (cid.Cid, error)

func (*StateManager) ListAllActors

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

func (*StateManager) LoadActor added in v0.7.2

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

func (*StateManager) LoadActorRaw added in v0.7.2

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

func (*StateManager) LoadActorTsk added in v0.7.2

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

func (*StateManager) LookupID added in v0.3.0

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

func (*StateManager) LookupRobustAddress added in v1.15.3

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

func (*StateManager) MarketBalance

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

func (*StateManager) ParentState added in v0.7.2

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

func (*StateManager) ParentStateTsk added in v0.7.2

func (sm *StateManager) ParentStateTsk(ctx context.Context, 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) ResolveToDeterministicAddress added in v1.20.0

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

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

func (*StateManager) ResolveToDeterministicAddressAtFinality added in v1.20.0

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

ResolveToDeterministicAddressAtFinality is similar to stmgr.ResolveToDeterministicAddress but fails if the ID address being resolved isn't reorg-stable yet. It should not be used for consensus-critical subsystems.

func (*StateManager) SearchForMessage added in v0.3.0

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

func (*StateManager) SetVMConstructor added in v0.2.8

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

func (*StateManager) Start added in v1.4.2

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 added in v0.7.2

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

func (*StateManager) Stop added in v1.4.2

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) VMConstructor added in v1.11.3

func (sm *StateManager) VMConstructor() func(context.Context, *vm.VMOpts) (vm.Interface, error)

func (*StateManager) VMSys added in v1.11.2

func (sm *StateManager) VMSys() vm.SyscallBuilder

func (*StateManager) ValidateChain added in v0.2.6

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, allowReplaced bool) (*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 added in v0.9.1

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)
	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)
	ResolveToDeterministicAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
}

type Upgrade added in v0.9.0

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 added in v0.9.0

type UpgradeSchedule []Upgrade

func (UpgradeSchedule) GetNtwkVersion added in v1.11.1

func (us UpgradeSchedule) GetNtwkVersion(e abi.ChainEpoch) (network.Version, error)

func (UpgradeSchedule) Validate added in v0.9.0

func (us UpgradeSchedule) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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