continue expanding vm abstraction layer

This commit is contained in:
Steven Allen 2020-09-28 12:48:08 -07:00
parent 271ceb968a
commit 5f3160cf5b
10 changed files with 135 additions and 193 deletions

View File

@ -10,9 +10,11 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
smoothing1 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
)
@ -49,3 +51,18 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
}
return loader(store, act.Head)
}
func ActorNameByCode(c cid.Cid) string {
switch {
case builtin0.IsBuiltinActor(c):
return builtin0.ActorNameByCode(c)
case builtin1.IsBuiltinActor(c):
return builtin1.ActorNameByCode(c)
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
return builtin0.IsBuiltinActor(c) || builtin1.IsBuiltinActor(c)
}

View File

@ -8,9 +8,11 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/specs-actors/actors/builtin"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/multiformats/go-multihash"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
@ -25,7 +27,8 @@ import (
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/ipfs/go-cid"
ipldcbor "github.com/ipfs/go-ipld-cbor"
logging "github.com/ipfs/go-log"
cbg "github.com/whyrusleeping/cbor-gen"
)
@ -41,6 +44,18 @@ const testForkHeight = 40
type testActor struct {
}
var testActorCodeID = func() cid.Cid {
builder := cid.V1Builder{Codec: cid.Raw, MhType: multihash.IDENTITY}
c, err := builder.Sum([]byte("fil/any/test"))
if err != nil {
panic(err)
}
return c
}()
func (testActor) Code() cid.Cid { return testActorCodeID }
func (testActor) State() cbor.Er { return new(testActorState) }
type testActorState struct {
HasUpgraded uint64
}
@ -61,7 +76,7 @@ func (tas *testActorState) UnmarshalCBOR(r io.Reader) error {
return nil
}
func (ta *testActor) Exports() []interface{} {
func (ta testActor) Exports() []interface{} {
return []interface{}{
1: ta.Constructor,
2: ta.TestMethod,
@ -115,7 +130,7 @@ func TestForkHeightTriggers(t *testing.T) {
}
stmgr.ForksAtHeight[testForkHeight] = func(ctx context.Context, sm *StateManager, st types.StateTree, ts *types.TipSet) error {
cst := cbor.NewCborStore(sm.ChainStore().Blockstore())
cst := ipldcbor.NewCborStore(sm.ChainStore().Blockstore())
act, err := st.GetActor(taddr)
if err != nil {
@ -143,7 +158,7 @@ func TestForkHeightTriggers(t *testing.T) {
return nil
}
inv.Register(actors.Version0, builtin.PaymentChannelActorCodeID, &testActor{}, &testActorState{}, false)
inv.Register(nil, testActor{})
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) {
nvm, err := vm.NewVM(ctx, vmopt)
if err != nil {
@ -157,7 +172,7 @@ func TestForkHeightTriggers(t *testing.T) {
var msgs []*types.SignedMessage
enc, err := actors.SerializeParams(&init_.ExecParams{CodeCID: builtin.PaymentChannelActorCodeID})
enc, err := actors.SerializeParams(&init_.ExecParams{CodeCID: (testActor{}).Code()})
if err != nil {
t.Fatal(err)
}

View File

@ -17,32 +17,13 @@ import (
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/rt"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
account0 "github.com/filecoin-project/specs-actors/actors/builtin/account"
cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
exported1 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
account1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
cron1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron"
init1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
market1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
msig1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
paych1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
reward1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
@ -545,34 +526,13 @@ type MethodMeta struct {
var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{}
func init() {
cidToMethods := map[cid.Cid][2]interface{}{
// builtin.SystemActorCodeID: {builtin.MethodsSystem, system.Actor{} }- apparently it doesn't have methods
builtin0.InitActorCodeID: {builtin0.MethodsInit, init0.Actor{}},
builtin0.CronActorCodeID: {builtin0.MethodsCron, cron0.Actor{}},
builtin0.AccountActorCodeID: {builtin0.MethodsAccount, account0.Actor{}},
builtin0.StoragePowerActorCodeID: {builtin0.MethodsPower, power0.Actor{}},
builtin0.StorageMinerActorCodeID: {builtin0.MethodsMiner, miner0.Actor{}},
builtin0.StorageMarketActorCodeID: {builtin0.MethodsMarket, market0.Actor{}},
builtin0.PaymentChannelActorCodeID: {builtin0.MethodsPaych, paych0.Actor{}},
builtin0.MultisigActorCodeID: {builtin0.MethodsMultisig, msig0.Actor{}},
builtin0.RewardActorCodeID: {builtin0.MethodsReward, reward0.Actor{}},
builtin0.VerifiedRegistryActorCodeID: {builtin0.MethodsVerifiedRegistry, verifreg0.Actor{}},
// TODO: combine with the runtime actor registry.
var actors []rt.VMActor
actors = append(actors, exported0.BuiltinActors()...)
actors = append(actors, exported1.BuiltinActors()...)
// builtin1.SystemActorCodeID: {builtin1.MethodsSystem, system.Actor{} }- apparently it doesn't have methods
builtin1.InitActorCodeID: {builtin1.MethodsInit, init1.Actor{}},
builtin1.CronActorCodeID: {builtin1.MethodsCron, cron1.Actor{}},
builtin1.AccountActorCodeID: {builtin1.MethodsAccount, account1.Actor{}},
builtin1.StoragePowerActorCodeID: {builtin1.MethodsPower, power1.Actor{}},
builtin1.StorageMinerActorCodeID: {builtin1.MethodsMiner, miner1.Actor{}},
builtin1.StorageMarketActorCodeID: {builtin1.MethodsMarket, market1.Actor{}},
builtin1.PaymentChannelActorCodeID: {builtin1.MethodsPaych, paych1.Actor{}},
builtin1.MultisigActorCodeID: {builtin1.MethodsMultisig, msig1.Actor{}},
builtin1.RewardActorCodeID: {builtin1.MethodsReward, reward1.Actor{}},
builtin1.VerifiedRegistryActorCodeID: {builtin1.MethodsVerifiedRegistry, verifreg1.Actor{}},
}
for c, m := range cidToMethods {
exports := m[1].(vm.Invokee).Exports()
for _, actor := range actors {
exports := actor.Exports()
methods := make(map[abi.MethodNum]MethodMeta, len(exports))
// Explicitly add send, it's special.
@ -583,17 +543,6 @@ func init() {
Ret: reflect.TypeOf(new(abi.EmptyValue)),
}
// Learn method names from the builtin.Methods* structs.
rv := reflect.ValueOf(m[0])
rt := rv.Type()
nf := rt.NumField()
methodToName := make([]string, len(exports))
for i := 0; i < nf; i++ {
name := rt.Field(i).Name
number := rv.Field(i).Interface().(abi.MethodNum)
methodToName[number] = name
}
// Iterate over exported methods. Some of these _may_ be nil and
// must be skipped.
for number, export := range exports {
@ -604,24 +553,19 @@ func init() {
ev := reflect.ValueOf(export)
et := ev.Type()
// Make sure the method name is correct.
// This is just a nice sanity check.
// Extract the method names using reflection. These
// method names always match the field names in the
// `builtin.Method*` structs (tested in the specs-actors
// tests).
fnName := runtime.FuncForPC(ev.Pointer()).Name()
fnName = strings.TrimSuffix(fnName[strings.LastIndexByte(fnName, '.')+1:], "-fm")
mName := methodToName[number]
if mName != fnName {
panic(fmt.Sprintf(
"actor method name is %s but exported method name is %s",
fnName, mName,
))
}
switch abi.MethodNum(number) {
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
case builtin0.MethodSend:
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
panic("method 0 is reserved for Send")
// Note that builtin1.MethodConstructor = builtin0.MethodConstructor = 1.
case builtin0.MethodConstructor:
// Note that builtin1.MethodConstructor = builtin0.MethodConstructor = 1.
if fnName != "Constructor" {
panic("method 1 is reserved for Constructor")
}
@ -633,7 +577,7 @@ func init() {
Ret: et.Out(0),
}
}
MethodsMap[c] = methods
MethodsMap[actor.Code()] = methods
}
}

View File

@ -10,35 +10,13 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
account0 "github.com/filecoin-project/specs-actors/actors/builtin/account"
cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
system0 "github.com/filecoin-project/specs-actors/actors/builtin/system"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
account1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
cron1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron"
init1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
market1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
msig1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
paych1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
reward1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
system1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system"
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
exported1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported"
vmr "github.com/filecoin-project/specs-actors/v2/actors/runtime"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/exitcode"
rtt "github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
@ -49,15 +27,27 @@ type ActorRegistry struct {
actors map[cid.Cid]*actorInfo
}
// An ActorPredicate returns an error if the given actor is not valid for the given runtime environment (e.g., chain height, version, etc.).
type ActorPredicate func(vmr.Runtime, rtt.VMActor) error
func ActorsVersionPredicate(ver actors.Version) ActorPredicate {
return func(rt vmr.Runtime, v rtt.VMActor) error {
nver := actors.VersionForNetwork(rt.NetworkVersion())
if nver != ver {
return xerrors.Errorf("actor %s is a version %d actor; chain only supports actor version %d at height %d", v.Code(), ver, nver, rt.CurrEpoch())
}
return nil
}
}
type invokeFunc func(rt vmr.Runtime, params []byte) ([]byte, aerrors.ActorError)
type nativeCode []invokeFunc
type actorInfo struct {
methods nativeCode
stateType reflect.Type
methods nativeCode
vmActor rtt.VMActor
// TODO: consider making this a network version range?
version actors.Version
singleton bool
predicate ActorPredicate
}
func NewActorRegistry() *ActorRegistry {
@ -66,29 +56,8 @@ func NewActorRegistry() *ActorRegistry {
// TODO: define all these properties on the actors themselves, in specs-actors.
// add builtInCode using: register(cid, singleton)
inv.Register(actors.Version0, builtin0.SystemActorCodeID, system0.Actor{}, abi.EmptyValue{}, true)
inv.Register(actors.Version0, builtin0.InitActorCodeID, init0.Actor{}, init0.State{}, true)
inv.Register(actors.Version0, builtin0.RewardActorCodeID, reward0.Actor{}, reward0.State{}, true)
inv.Register(actors.Version0, builtin0.CronActorCodeID, cron0.Actor{}, cron0.State{}, true)
inv.Register(actors.Version0, builtin0.StoragePowerActorCodeID, power0.Actor{}, power0.State{}, true)
inv.Register(actors.Version0, builtin0.StorageMarketActorCodeID, market0.Actor{}, market0.State{}, true)
inv.Register(actors.Version0, builtin0.VerifiedRegistryActorCodeID, verifreg0.Actor{}, verifreg0.State{}, true)
inv.Register(actors.Version0, builtin0.StorageMinerActorCodeID, miner0.Actor{}, miner0.State{}, false)
inv.Register(actors.Version0, builtin0.MultisigActorCodeID, msig0.Actor{}, msig0.State{}, false)
inv.Register(actors.Version0, builtin0.PaymentChannelActorCodeID, paych0.Actor{}, paych0.State{}, false)
inv.Register(actors.Version0, builtin0.AccountActorCodeID, account0.Actor{}, account0.State{}, false)
inv.Register(actors.Version1, builtin1.SystemActorCodeID, system1.Actor{}, abi.EmptyValue{}, true)
inv.Register(actors.Version1, builtin1.InitActorCodeID, init1.Actor{}, init1.State{}, true)
inv.Register(actors.Version1, builtin1.RewardActorCodeID, reward1.Actor{}, reward1.State{}, true)
inv.Register(actors.Version1, builtin1.CronActorCodeID, cron1.Actor{}, cron1.State{}, true)
inv.Register(actors.Version1, builtin1.StoragePowerActorCodeID, power1.Actor{}, power1.State{}, true)
inv.Register(actors.Version1, builtin1.StorageMarketActorCodeID, market1.Actor{}, market1.State{}, true)
inv.Register(actors.Version1, builtin1.VerifiedRegistryActorCodeID, verifreg1.Actor{}, verifreg1.State{}, true)
inv.Register(actors.Version1, builtin1.StorageMinerActorCodeID, miner1.Actor{}, miner1.State{}, false)
inv.Register(actors.Version1, builtin1.MultisigActorCodeID, msig1.Actor{}, msig1.State{}, false)
inv.Register(actors.Version1, builtin1.PaymentChannelActorCodeID, paych1.Actor{}, paych1.State{}, false)
inv.Register(actors.Version1, builtin1.AccountActorCodeID, account1.Actor{}, account1.State{}, false)
inv.Register(ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...)
inv.Register(ActorsVersionPredicate(actors.Version1), exported1.BuiltinActors()...)
return inv
}
@ -102,23 +71,27 @@ func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.Meth
if method >= abi.MethodNum(len(act.methods)) || act.methods[method] == nil {
return nil, aerrors.Newf(exitcode.SysErrInvalidMethod, "no method %d on actor", method)
}
if curVer := actors.VersionForNetwork(rt.NetworkVersion()); curVer != act.version {
return nil, aerrors.Newf(exitcode.SysErrInvalidMethod, "unsupported actors code version %d, expected %d", act.version, curVer)
if err := act.predicate(rt, act.vmActor); err != nil {
return nil, aerrors.Newf(exitcode.SysErrInvalidMethod, "unsupported actor: %s", err)
}
return act.methods[method](rt, params)
}
func (ar *ActorRegistry) Register(version actors.Version, c cid.Cid, instance Invokee, state interface{}, singleton bool) {
code, err := ar.transform(instance)
if err != nil {
panic(xerrors.Errorf("%s: %w", string(c.Hash()), err))
func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor) {
if pred == nil {
pred = func(vmr.Runtime, rtt.VMActor) error { return nil }
}
ar.actors[c] = &actorInfo{
methods: code,
version: version,
stateType: reflect.TypeOf(state),
singleton: singleton,
for _, a := range actors {
code, err := ar.transform(a)
if err != nil {
panic(xerrors.Errorf("%s: %w", string(a.Code().Hash()), err))
}
ar.actors[a.Code()] = &actorInfo{
methods: code,
vmActor: a,
predicate: pred,
}
}
}
@ -127,11 +100,12 @@ func (ar *ActorRegistry) Create(codeCid cid.Cid, rt vmr.Runtime) (*types.Actor,
if !ok {
return nil, aerrors.Newf(exitcode.SysErrorIllegalArgument, "Can only create built-in actors.")
}
if version := actors.VersionForNetwork(rt.NetworkVersion()); act.version != version {
return nil, aerrors.Newf(exitcode.SysErrorIllegalArgument, "Can only create version %d actors, attempted to create version %d actor", version, act.version)
if err := act.predicate(rt, act.vmActor); err != nil {
return nil, aerrors.Newf(exitcode.SysErrorIllegalArgument, "Cannot create actor: %w", err)
}
if act.singleton {
if rtt.IsSingletonActor(act.vmActor) {
return nil, aerrors.Newf(exitcode.SysErrorIllegalArgument, "Can only have one instance of singleton actors.")
}
return &types.Actor{
@ -142,11 +116,11 @@ func (ar *ActorRegistry) Create(codeCid cid.Cid, rt vmr.Runtime) (*types.Actor,
}, nil
}
type Invokee interface {
type invokee interface {
Exports() []interface{}
}
func (*ActorRegistry) transform(instance Invokee) (nativeCode, error) {
func (*ActorRegistry) transform(instance invokee) (nativeCode, error) {
itype := reflect.TypeOf(instance)
exports := instance.Exports()
runtimeType := reflect.TypeOf((*vmr.Runtime)(nil)).Elem()
@ -247,15 +221,10 @@ func DumpActorState(act *types.Actor, b []byte) (interface{}, error) {
return nil, xerrors.Errorf("state type for actor %s not found", act.Code)
}
rv := reflect.New(actInfo.stateType)
um, ok := rv.Interface().(cbg.CBORUnmarshaler)
if !ok {
return nil, xerrors.New("state type does not implement CBORUnmarshaler")
}
um := actInfo.vmActor.State()
if err := um.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("unmarshaling actor state: %w", err)
}
return rv.Elem().Interface(), nil
return um, nil
}

View File

@ -14,8 +14,6 @@ import (
"strings"
"time"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/multiformats/go-multiaddr"
"github.com/ipfs/go-cid"
@ -30,7 +28,6 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/exported"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
@ -1513,28 +1510,18 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er
return nil, nil
}
var target runtime.Invokee
for _, actor := range exported.BuiltinActors() {
if actor.Code() == act {
target = actor
}
}
if target == nil {
// TODO: consider moving this to a dedicated helper
actMeta, ok := stmgr.MethodsMap[act]
if !ok {
return nil, fmt.Errorf("unknown actor %s", act)
}
methods := target.Exports()
if uint64(len(methods)) <= method || methods[method] == nil {
methodMeta, ok := actMeta[abi.MethodNum(method)]
if !ok {
return nil, fmt.Errorf("unknown method %d for actor %s", method, act)
}
f := methods[method]
rf := reflect.TypeOf(f)
if rf.NumIn() != 2 {
return nil, fmt.Errorf("expected referenced method to have three arguments")
}
paramObj := rf.In(1).Elem()
paramObj := methodMeta.Params
if paramObj.NumField() != len(args) {
return nil, fmt.Errorf("not enough arguments given to call that method (expecting %d)", paramObj.NumField())
}

View File

@ -9,12 +9,15 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin"
_init "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/events/state"
"github.com/filecoin-project/lotus/chain/types"
cw_util "github.com/filecoin-project/lotus/cmd/lotus-chainwatch/util"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/ipfs/go-cid"
)
func (p *Processor) setupCommonActors() error {
@ -135,15 +138,15 @@ func (p Processor) storeActorAddresses(ctx context.Context, actors map[cid.Cid]A
addressToID := map[address.Address]address.Address{}
// HACK until genesis storage is figured out:
addressToID[builtin.SystemActorAddr] = builtin.SystemActorAddr
addressToID[builtin.InitActorAddr] = builtin.InitActorAddr
addressToID[builtin.RewardActorAddr] = builtin.RewardActorAddr
addressToID[builtin.CronActorAddr] = builtin.CronActorAddr
addressToID[builtin.StoragePowerActorAddr] = builtin.StoragePowerActorAddr
addressToID[builtin.StorageMarketActorAddr] = builtin.StorageMarketActorAddr
addressToID[builtin.VerifiedRegistryActorAddr] = builtin.VerifiedRegistryActorAddr
addressToID[builtin.BurntFundsActorAddr] = builtin.BurntFundsActorAddr
initActor, err := p.node.StateGetActor(ctx, builtin.InitActorAddr, types.EmptyTSK)
addressToID[builtin1.SystemActorAddr] = builtin1.SystemActorAddr
addressToID[builtin1.InitActorAddr] = builtin1.InitActorAddr
addressToID[builtin1.RewardActorAddr] = builtin1.RewardActorAddr
addressToID[builtin1.CronActorAddr] = builtin1.CronActorAddr
addressToID[builtin1.StoragePowerActorAddr] = builtin1.StoragePowerActorAddr
addressToID[builtin1.StorageMarketActorAddr] = builtin1.StorageMarketActorAddr
addressToID[builtin1.VerifiedRegistryActorAddr] = builtin1.VerifiedRegistryActorAddr
addressToID[builtin1.BurntFundsActorAddr] = builtin1.BurntFundsActorAddr
initActor, err := p.node.StateGetActor(ctx, builtin1.InitActorAddr, types.EmptyTSK)
if err != nil {
return err
}

View File

@ -3,7 +3,9 @@ package chaos
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/ipfs/go-cid"
@ -86,7 +88,11 @@ func (a Actor) Exports() []interface{} {
}
}
var _ runtime.Invokee = Actor{}
func (a Actor) Code() cid.Cid { return ChaosActorCodeCID }
func (a Actor) State() cbor.Er { return new(State) }
func (a Actor) IsSingleton() bool { return true }
var _ rt.VMActor = Actor{}
// SendArgs are the arguments for the Send method.
type SendArgs struct {

View File

@ -5,7 +5,6 @@ import (
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
@ -145,7 +144,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, preroot cid.Cid, epoch
// register the chaos actor if required by the vector.
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
invoker.Register(actors.Version0, chaos.ChaosActorCodeCID, chaos.Actor{}, chaos.State{}, true)
invoker.Register(nil, chaos.Actor{})
}
lvm.SetInvoker(invoker)

6
go.mod
View File

@ -32,12 +32,12 @@ require (
github.com/filecoin-project/go-multistore v0.0.3
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261
github.com/filecoin-project/go-state-types v0.0.0-20200911004822-964d6c679cfc
github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab
github.com/filecoin-project/go-statemachine v0.0.0-20200813232949-df9b130df370
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
github.com/filecoin-project/specs-actors v0.9.10
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252
github.com/filecoin-project/specs-actors v0.9.12-0.20200928180918-488a087c5add
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796
github.com/filecoin-project/test-vectors/schema v0.0.1
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1

10
go.sum
View File

@ -247,6 +247,8 @@ github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4/go
github.com/filecoin-project/go-state-types v0.0.0-20200905071437-95828685f9df/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I=
github.com/filecoin-project/go-state-types v0.0.0-20200911004822-964d6c679cfc h1:1vr/LoqGq5m5g37Q3sNSAjfwF1uJY0zmiHcvnxY6hik=
github.com/filecoin-project/go-state-types v0.0.0-20200911004822-964d6c679cfc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab h1:cEDC5Ei8UuT99hPWhCjA72SM9AuRtnpvdSTIYbnzN8I=
github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-statemachine v0.0.0-20200714194326-a77c3ae20989/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v0.0.0-20200813232949-df9b130df370 h1:Jbburj7Ih2iaJ/o5Q9A+EAeTabME6YII7FLi9SKUf5c=
github.com/filecoin-project/go-statemachine v0.0.0-20200813232949-df9b130df370/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
@ -257,10 +259,10 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/
github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4=
github.com/filecoin-project/specs-actors v0.9.7/go.mod h1:wM2z+kwqYgXn5Z7scV1YHLyd1Q1cy0R8HfTIWQ0BFGU=
github.com/filecoin-project/specs-actors v0.9.9/go.mod h1:czlvLQGEX0fjLLfdNHD7xLymy6L3n7aQzRWzsYGf+ys=
github.com/filecoin-project/specs-actors v0.9.10 h1:gU0TrRhgkCsBEOP42sGDE7RQuR0Cov9hJhBqq+RJmjU=
github.com/filecoin-project/specs-actors v0.9.10/go.mod h1:czlvLQGEX0fjLLfdNHD7xLymy6L3n7aQzRWzsYGf+ys=
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252 h1:0vOZo6xlVDyPhuRS3ArrAy1fml7H2FEY65IFx6rwp3o=
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252/go.mod h1:vV1UOOKlmdKg4dy3YKixtJtVf15WMuZsS6KgKRDxkWg=
github.com/filecoin-project/specs-actors v0.9.12-0.20200928180918-488a087c5add h1:iXQOxr8uSyZ/qnTlOZf7ALp0io+jwLxmuWsNAk/YdoQ=
github.com/filecoin-project/specs-actors v0.9.12-0.20200928180918-488a087c5add/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684 h1:sjWZqblOOf1RaohI9w2R2AVp5uifNdzsusy7oVi5ioU=
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684/go.mod h1:/2Zra1BhLtpRywUhm++QP+3I5Ir+hBk/W24TpYjj43E=
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796 h1:dJsTPWpG2pcTeojO2pyn0c6l+x/3MZYCBgo/9d11JEk=
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g=
github.com/filecoin-project/test-vectors/schema v0.0.1 h1:5fNF76nl4qolEvcIsjc0kUADlTMVHO73tW4kXXPnsus=