Skip to content

Commit

Permalink
chore: actors: Allow builtin-actors to return a map of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Oct 21, 2022
1 parent ae91cbd commit f1b8f96
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 61 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/filecoin-project/go-fil-markets v1.24.0
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.1.12-beta
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b
github.com/filecoin-project/pubsub v1.0.0
github.com/filecoin-project/specs-actors v0.9.15
github.com/filecoin-project/specs-actors/v2 v2.3.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.12-beta h1:QZE00g75shqwhPn0/bZL38sFxVAqnXC7zjmYltRdhxI=
github.com/filecoin-project/go-state-types v0.1.12-beta/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b h1:s4F3e3EBo56j+4xmrzmoAIvtgvDwLn4nsIf5bqcU0Qg=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
Expand Down
11 changes: 4 additions & 7 deletions pkg/vm/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
Expand Down Expand Up @@ -44,7 +45,7 @@ type Dispatcher interface {

type actorDispatcher struct {
code cid.Cid
actor Actor
actor builtin.RegistryEntry
}

type method interface {
Expand Down Expand Up @@ -134,11 +135,7 @@ func (d *actorDispatcher) signature(methodID abi.MethodNum) (*methodSignature, *
exports := d.actor.Exports()

// get method entry
methodIdx := (uint64)(methodID)
if len(exports) <= (int)(methodIdx) {
return nil, NewExcuteError(exitcode.SysErrInvalidMethod, "Method undefined. method: %d, code: %s", methodID, d.code)
}
entry := exports[methodIdx]
entry := exports[(uint64)(methodID)]
if entry == nil {
return nil, NewExcuteError(exitcode.SysErrInvalidMethod, "Method undefined. method: %d, code: %s", methodID, d.code)
}
Expand All @@ -152,7 +149,7 @@ func (d *actorDispatcher) Signature(methodNum abi.MethodNum) (MethodSignature, *
return d.signature(methodNum)
}

//ExcuteError error in vm excute
// ExcuteError error in vm excute
type ExcuteError struct {
code exitcode.ExitCode
msg string
Expand Down
23 changes: 11 additions & 12 deletions pkg/vm/dispatch/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/exitcode"
rtt "github.com/filecoin-project/go-state-types/rt"
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/ipfs/go-cid"

Expand All @@ -21,7 +19,7 @@ type CodeLoader struct {

// ActorInfo vm contract actor
type ActorInfo struct {
vmActor rtt.VMActor
vmActor builtin.RegistryEntry
// TODO: consider making this a network version range?
predicate ActorPredicate
}
Expand All @@ -33,7 +31,7 @@ func (cl CodeLoader) GetActorImpl(code cid.Cid, rt vmr.Runtime) (Dispatcher, *Ex
if !ok {
return nil, NewExcuteError(exitcode.SysErrorIllegalActor, "Actor code not found. code: %s", code)
}
if err := actor.predicate(rt, actor.vmActor); err != nil {
if err := actor.predicate(rt, code); err != nil {
return nil, NewExcuteError(exitcode.SysErrorIllegalActor, "unsupport actor. code: %s", code)
}

Expand All @@ -50,11 +48,11 @@ func (cl CodeLoader) GetUnsafeActorImpl(code cid.Cid) (Dispatcher, error) {
return &actorDispatcher{code: code, actor: actor.vmActor}, nil
}

func (cl CodeLoader) GetVMActor(code cid.Cid) (rtt.VMActor, error) {
func (cl CodeLoader) GetVMActor(code cid.Cid) (builtin.RegistryEntry, error) {
//todo version check
actor, ok := cl.actors[code]
if !ok {
return nil, fmt.Errorf("unable to get actor for code %s", code)
return builtin.RegistryEntry{}, fmt.Errorf("unable to get actor for code %s", code)
}

return actor.vmActor, nil
Expand All @@ -71,9 +69,9 @@ func NewBuilder() *CodeLoaderBuilder {
}

// Add lets you add an actor dispatch table for a given version.
func (b *CodeLoaderBuilder) Add(av actorstypes.Version, predict ActorPredicate, actor Actor) *CodeLoaderBuilder {
func (b *CodeLoaderBuilder) Add(av actorstypes.Version, predict ActorPredicate, actor builtin.RegistryEntry) *CodeLoaderBuilder {
if predict == nil {
predict = func(vmr.Runtime, rtt.VMActor) error { return nil }
predict = func(vmr.Runtime, cid.Cid) error { return nil }
}

ai := ActorInfo{
Expand All @@ -100,7 +98,7 @@ func (b *CodeLoaderBuilder) Add(av actorstypes.Version, predict ActorPredicate,
}

// Add lets you add an actor dispatch table for a given version.
func (b *CodeLoaderBuilder) AddMany(av actorstypes.Version, predict ActorPredicate, actors ...rt5.VMActor) *CodeLoaderBuilder {
func (b *CodeLoaderBuilder) AddMany(av actorstypes.Version, predict ActorPredicate, actors []builtin.RegistryEntry) *CodeLoaderBuilder {
for _, actor := range actors {
b.Add(av, predict, actor)
}
Expand All @@ -113,17 +111,18 @@ func (b *CodeLoaderBuilder) Build() CodeLoader {
}

// 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
type ActorPredicate func(vmr.Runtime, cid.Cid) error

// ActorsVersionPredicate get actor predicate base on actor version and network version
func ActorsVersionPredicate(ver actorstypes.Version) ActorPredicate {
return func(rt vmr.Runtime, v rtt.VMActor) error {
return func(rt vmr.Runtime, codeCid cid.Cid) error {
nver, err := actorstypes.VersionForNetwork(rt.NetworkVersion())
if err != nil {
return fmt.Errorf("version for network %w", err)
}
if nver != ver {
return fmt.Errorf("actor %s is a version %d actor; chain only supports actor version %d at height %d", v.Code(), ver, nver, rt.CurrentEpoch())
return fmt.Errorf("actor %s is a version %d actor; chain only supports actor version %d at height %d and nver %d",
codeCid, ver, nver, rt.CurrentEpoch(), rt.NetworkVersion())
}
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/vm/register/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ var defaultActors dispatch.CodeLoader

func GetDefaultActros() *dispatch.CodeLoader {
loadOnce.Do(func() {
DefaultActorBuilder.AddMany(actorstypes.Version0, dispatch.ActorsVersionPredicate(actorstypes.Version0), exported0.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version2, dispatch.ActorsVersionPredicate(actorstypes.Version2), exported2.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version3, dispatch.ActorsVersionPredicate(actorstypes.Version3), exported3.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version4, dispatch.ActorsVersionPredicate(actorstypes.Version4), exported4.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version5, dispatch.ActorsVersionPredicate(actorstypes.Version5), exported5.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version6, dispatch.ActorsVersionPredicate(actorstypes.Version6), exported6.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version7, dispatch.ActorsVersionPredicate(actorstypes.Version7), exported7.BuiltinActors()...)
DefaultActorBuilder.AddMany(actorstypes.Version8, dispatch.ActorsVersionPredicate(actorstypes.Version8), builtin.MakeRegistry(actorstypes.Version8)...)
DefaultActorBuilder.AddMany(actorstypes.Version9, dispatch.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9)...)
DefaultActorBuilder.AddMany(actorstypes.Version0, dispatch.ActorsVersionPredicate(actorstypes.Version0), builtin.MakeRegistryLegacy(exported0.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version2, dispatch.ActorsVersionPredicate(actorstypes.Version2), builtin.MakeRegistryLegacy(exported2.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version3, dispatch.ActorsVersionPredicate(actorstypes.Version3), builtin.MakeRegistryLegacy(exported3.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version4, dispatch.ActorsVersionPredicate(actorstypes.Version4), builtin.MakeRegistryLegacy(exported4.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version5, dispatch.ActorsVersionPredicate(actorstypes.Version5), builtin.MakeRegistryLegacy(exported5.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version6, dispatch.ActorsVersionPredicate(actorstypes.Version6), builtin.MakeRegistryLegacy(exported6.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version7, dispatch.ActorsVersionPredicate(actorstypes.Version7), builtin.MakeRegistryLegacy(exported7.BuiltinActors()))
DefaultActorBuilder.AddMany(actorstypes.Version8, dispatch.ActorsVersionPredicate(actorstypes.Version8), builtin.MakeRegistry(actorstypes.Version8))
DefaultActorBuilder.AddMany(actorstypes.Version9, dispatch.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9))
defaultActors = DefaultActorBuilder.Build()
})

Expand Down
5 changes: 3 additions & 2 deletions tools/conformance/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"
rtt "github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/test-vectors/schema"
"github.com/filecoin-project/venus/tools/conformance/chaos"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
Expand Down Expand Up @@ -232,8 +234,7 @@ func (d *Driver) ExecuteMessage(bs blockstoreutil.Blockstore, params ExecuteMess
// register the chaos actor if required by the vector.
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
av, _ := actorstypes.VersionForNetwork(params.NetworkVersion)
chaosActor := chaos.Actor{}
actorBuilder.Add(av, nil, chaosActor)
actorBuilder.AddMany(av, nil, builtin.MakeRegistryLegacy([]rtt.VMActor{chaos.Actor{}}))
}

register.GetDefaultActros()
Expand Down
4 changes: 2 additions & 2 deletions venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/filecoin-project/go-data-transfer v1.15.2
github.com/filecoin-project/go-fil-markets v1.24.0
github.com/filecoin-project/go-jsonrpc v0.1.7
github.com/filecoin-project/go-state-types v0.1.12-beta
github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b
github.com/filecoin-project/lotus v1.17.2-0.20220921145658-94add978b01f
github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-cid v0.2.0
Expand Down
8 changes: 4 additions & 4 deletions venus-devtool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.12-beta h1:QZE00g75shqwhPn0/bZL38sFxVAqnXC7zjmYltRdhxI=
github.com/filecoin-project/go-state-types v0.1.12-beta/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b h1:s4F3e3EBo56j+4xmrzmoAIvtgvDwLn4nsIf5bqcU0Qg=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220920181425-d683559e386b/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
Expand All @@ -427,8 +427,8 @@ github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lI
github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8=
github.com/filecoin-project/index-provider v0.8.1 h1:ggoBWvMSWR91HZQCWfv8SZjoTGNyJBwNMLuN9bJZrbU=
github.com/filecoin-project/index-provider v0.8.1/go.mod h1:c/Ym5HtWPp9NQgNc9dgSBMpSNsZ/DE9FEi9qVubl5RM=
github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc h1:GmnYJOdjmuWZv9wIfwntkit/fI84sUt9lTSnDRwRfXo=
github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc/go.mod h1:DMSDCLtqobi1a8tLSSyNksvaHcEUDQkUaPLDZiQYVoI=
github.com/filecoin-project/lotus v1.17.2-0.20220921145658-94add978b01f h1:Waagfi15+gDrYHW9cIAgO84MQ0PHktZuG5KGHHFDYWk=
github.com/filecoin-project/lotus v1.17.2-0.20220921145658-94add978b01f/go.mod h1:kITnSb8jWWmbwUdc5AUW0ziRp3M/e94JjBt2AOUInTA=
github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM=
github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg=
github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
Expand Down
28 changes: 22 additions & 6 deletions venus-shared/actors/builtin/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,47 @@ import (
"github.com/filecoin-project/venus/venus-shared/actors"
)

var _ rtt.VMActor = (*RegistryEntry)(nil)

type RegistryEntry struct {
state cbor.Er
code cid.Cid
methods []interface{}
methods map[uint64]interface{}
}

func (r RegistryEntry) State() cbor.Er {
return r.state
}

func (r RegistryEntry) Exports() []interface{} {
func (r RegistryEntry) Exports() map[uint64]interface{} {
return r.methods
}

func (r RegistryEntry) Code() cid.Cid {
return r.code
}

func MakeRegistry(av actorstypes.Version) []rtt.VMActor {
func MakeRegistryLegacy(actors []rtt.VMActor) []RegistryEntry {
registry := make([]RegistryEntry, 0)

for _, actor := range actors {
methodMap := make(map[uint64]interface{})
for methodNum, method := range actor.Exports() {
methodMap[uint64(methodNum)] = method
}
registry = append(registry, RegistryEntry{
code: actor.Code(),
methods: methodMap,
state: actor.State(),
})
}

return registry
}

func MakeRegistry(av actorstypes.Version) []RegistryEntry {
if av < actorstypes.Version8 {
panic("expected version v8 and up only, use specs-actors for v0-7")
}
registry := make([]rtt.VMActor, 0)
registry := make([]RegistryEntry, 0)

codeIDs, err := actors.GetActorCodeIDs(av)
if err != nil {
Expand Down
28 changes: 22 additions & 6 deletions venus-shared/actors/builtin/registry.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,47 @@ import (
"github.com/filecoin-project/venus/venus-shared/actors"
)

var _ rtt.VMActor = (*RegistryEntry)(nil)

type RegistryEntry struct {
state cbor.Er
code cid.Cid
methods []interface{}
methods map[uint64]interface{}
}

func (r RegistryEntry) State() cbor.Er {
return r.state
}

func (r RegistryEntry) Exports() []interface{} {
func (r RegistryEntry) Exports() map[uint64]interface{} {
return r.methods
}

func (r RegistryEntry) Code() cid.Cid {
return r.code
}

func MakeRegistry(av actorstypes.Version) []rtt.VMActor {
func MakeRegistryLegacy(actors []rtt.VMActor) []RegistryEntry {
registry := make([]RegistryEntry, 0)

for _, actor := range actors {
methodMap := make(map[uint64]interface{})
for methodNum, method := range actor.Exports() {
methodMap[uint64(methodNum)] = method
}
registry = append(registry, RegistryEntry{
code: actor.Code(),
methods: methodMap,
state: actor.State(),
})
}

return registry
}

func MakeRegistry(av actorstypes.Version) []RegistryEntry {
if av < actorstypes.Version8 {
panic("expected version v8 and up only, use specs-actors for v0-7")
}
registry := make([]rtt.VMActor, 0)
registry := make([]RegistryEntry, 0)

codeIDs, err := actors.GetActorCodeIDs(av)
if err != nil {
Expand Down
19 changes: 9 additions & 10 deletions venus-shared/utils/method_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/rt"
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported"
exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported"
Expand All @@ -33,7 +32,7 @@ var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{}

type actorsWithVersion struct {
av actorstypes.Version
actors []rt.VMActor
actors []builtin.RegistryEntry
}

func init() {
Expand All @@ -49,13 +48,13 @@ func loadMethodsMap() {
// TODO: combine with the runtime actor registry.
var actors []actorsWithVersion

actors = append(actors, actorsWithVersion{av: actorstypes.Version0, actors: exported0.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version2, actors: exported2.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version3, actors: exported3.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version4, actors: exported4.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version5, actors: exported5.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version6, actors: exported6.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version7, actors: exported7.BuiltinActors()})
actors = append(actors, actorsWithVersion{av: actorstypes.Version0, actors: builtin.MakeRegistryLegacy(exported0.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version2, actors: builtin.MakeRegistryLegacy(exported2.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version3, actors: builtin.MakeRegistryLegacy(exported3.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version4, actors: builtin.MakeRegistryLegacy(exported4.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version5, actors: builtin.MakeRegistryLegacy(exported5.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version6, actors: builtin.MakeRegistryLegacy(exported6.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version7, actors: builtin.MakeRegistryLegacy(exported7.BuiltinActors())})
actors = append(actors, actorsWithVersion{av: actorstypes.Version8, actors: builtin.MakeRegistry(actorstypes.Version8)})
actors = append(actors, actorsWithVersion{av: actorstypes.Version9, actors: builtin.MakeRegistry(actorstypes.Version9)})

Expand Down Expand Up @@ -91,7 +90,7 @@ func loadMethodsMap() {
et := ev.Type()

methods[abi.MethodNum(number)] = MethodMeta{
Num: strconv.Itoa(number),
Num: strconv.Itoa(int(number)),
Params: et.In(1),
Ret: et.Out(0),
}
Expand Down

0 comments on commit f1b8f96

Please sign in to comment.